require "lib.moonloader"
pSpeed = 30
local xX, yY, zZ = 0, 0, 0
function main()
repeat wait(0) until isSampAvailable()
sampRegisterChatCommand("start",function() act = true end)
sampRegisterChatCommand("speed", Speed)
sampRegisterChatCommand("stop", stop)
while true do wait(0)
inf()
if isCharInAnyCar(PLAYER_PED) then
local posX, posY, posZ = getCharCoordinates(playerPed)
local res, x, y, z = SearchMarker(posX, posY, posZ, 99999.0, false) --posX/Y/Z игрока, радиус
if SearchMarker(posX, posY, posZ, 99999.0, false) and act then
inf()
if res then
--sampAddChatMessage(string.format("Найден обычный маркер в координатах %.2f %.2f %.2f", x, y, z), -1)
taskCarDriveToCoord(PLAYER_PED, storeCarCharIsInNoSave(PLAYER_PED), x, y, z, pSpeed, 0, 0, 2)
--sampAddChatMessage(posX..' '..posY..' '..posZ..' - '..x..' '..y..' '..z, -1)
xX, yY, zZ = x, y, z
else
local res, x, y, z = SearchMarker(posX, posY, posZ, 99999.0, true) --posX/Y/Z игрока, радиус
if res then
--sampAddChatMessage(string.format("Найден гоночный маркер в координатах %.2f %.2f %.2f", x, y, z), -1)
taskCarDriveToCoord(PLAYER_PED, storeCarCharIsInNoSave(PLAYER_PED), x, y, z, pSpeed, 0, 0, 2)
local xX, yY, zZ = x, y, z
else
sampAddChatMessage("Маркер не найден", -1)
end
end
end
end
end
end
function inf()
posX, posY, posZ = getCharCoordinates(playerPed)
if getDistanceBetweenCoords3d(posX, posY, posZ, xX, yY, zZ) <= 5 and isCharInAnyCar(PLAYER_PED) and act then
stop()
act = false
sampAddChatMessage('Приплыл',-1)
end
end
function Speed(arg)
pSpeed = arg
printStringNow(pSpeed, 2000)
end
function stop() clearCharTasks(PLAYER_PED) taskWarpCharIntoCarAsDriver(PLAYER_PED, storeCarCharIsInNoSave(PLAYER_PED)) act = false 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