- 28
- 3
Вообщем, сидел, хотел научится делать скрипты, но как всегда я диванные долбо$$, вообщем, суть скрипта заключается в том, что после прописания команды, я должен ездить тупо аккуратно по чикпоинтам, у меня получилось следующее, в чем тут ошибка? Не работает вообще них!я
Lua:
require "lib.moonloader"
require "lib.sampfuncs"
---------------------------------------------------------------------------
function main()
if not isSampfuncsLoaded() or not isSampLoaded() then return end
sampRegisterChatCommand("Abot", cmd_bot)
while true do wait(0) end
end
function Abot(param)
if isPlayerPlaying(playerHandle) then
local posX, posY, posZ = getCharCoordinates(playerPed)
local res, x, y, z = SearchMarker(posX, posY, posZ, 50.0, false)
if res then
sampAddChatMessage(string.format("Найден обычный маркер в координатах %.2f %.2f %.2f", x, y, z), -1)
else
res, x, y, z = SearchMarker(posX, posY, posZ, 50.0, true)
if res then
sampAddChatMessage(string.format("Найден гоночный маркер в координатах %.2f %.2f %.2f", x, y, z), -1)
else
sampAddChatMessage("Маркер не найден", -1)
end
end
end
end
function SearchMarker(posX, posY, posZ, radius, isRace)
local ret_posX = 0.0
local ret_posY = 0.0
local ret_posZ = 0.0
local isFind = false
for id = 0, 31 do
local MarkerStruct = 0
if isRace then MarkerStruct = 0xC7F168 + id * 56
else MarkerStruct = 0xC7DD88 + id * 160 end
local MarkerPosX = representIntAsFloat(readMemory(MarkerStruct + 0, 4, false))
local MarkerPosY = representIntAsFloat(readMemory(MarkerStruct + 4, 4, false))
local MarkerPosZ = representIntAsFloat(readMemory(MarkerStruct + 8, 4, false))
if MarkerPosX ~= 0.0 or MarkerPosY ~= 0.0 or MarkerPosZ ~= 0.0 then
if getDistanceBetweenCoords3d(MarkerPosX, MarkerPosY, MarkerPosZ, posX, posY, posZ) < radius then
ret_posX = MarkerPosX
ret_posY = MarkerPosY
ret_posZ = MarkerPosZ
isFind = true
radius = getDistanceBetweenCoords3d(MarkerPosX, MarkerPosY, MarkerPosZ, posX, posY, posZ)
end
end
end
return isFind, ret_posX, ret_posY, ret_posZ
end
function taskCarDriveToCoord(Ped ped, Vehicle car, float toX, float toY, float toZ, float speed, int int7, int model, int int9)
taskCarDriveToCoord(PLAYER_PED, -1, x, y, z, 15, 2, null, 4)
end