samp = require "lib.samp.events"
require 'lib.moonloader'
require "lib.sampfuncs"
function main()
if not isSampLoaded() or not isSampfuncsLoaded() then return end
while not isSampAvailable() do wait(100) end
while true do wait(100)
if not sampIsChatInputActive() then
if isKeyJustPressed(VK_2) then
sampSendChat('/produzir')
lua_thread.create(comecar_pd)
end
end
end
end
function samp.onSetRaceCheckpoint(type, position, nextPosition, size)
lua_thread.create(function()
sampAddChatMessage(position.x, -1)
posix = position.x
posiy = position.y
posiz = position.z
print(posix)
if posix == -2145.9108886719 then
sampAddChatMessage("Debug", -1)
end
end)
end
function comecar_pd(arg)
lua_thread.create(function()
wait(1000)
BeginToPoint(-2150.3313,-230.0887,36.5156, 1.000000, -255, true)
BeginToPoint(posix, posiy, posiz, 1.000000, -255, true)
wait(3000)
BeginToPoint(-2147.7261,-235.5677,36.5156, 1.000000, -255, true)
BeginToPoint(-2149.6460,-256.5140,36.5156, 1.000000, -255, true)
BeginToPoint(posix, posiy, posiz, 1.000000, -255, true)
wait(3000)
BeginToPoint(-2166.1631,-256.9752,36.5156, 1.000000, -255, true)
BeginToPoint(-2166.8853,-253.6030,36.5156, 1.000000, -255, true)
BeginToPoint(posix, posiy, posiz, 1.000000, -255, true)
wait(3000)
BeginToPoint(-2154.9424,-247.6093,36.5156, 1.000000, -255, true)
BeginToPoint(-2152.4980,-236.5897,36.5156, 1.000000, -255, true)
end)
end
function renderDrawLineBy3dCoords(posX, posY, posZ, posX2, posY2, posZ2, width, color)
local SposX, SposY = convert3DCoordsToScreen(posX, posY, posZ)
local SposX2, SposY2 = convert3DCoordsToScreen(posX2, posY2, posZ2)
if isPointOnScreen(posX, posY, posZ, 1) and isPointOnScreen(posX2, posY2, posZ2, 1) then
renderDrawLine(SposX, SposY, SposX2, SposY2, width, color)
end
end
function BeginToPoint(x, y, z, radius, move_code, isSprint)
repeat
local posX, posY, posZ = GetCoordinates()
SetAngle(x, y, z)
MovePlayer(move_code, isSprint)
local dist = getDistanceBetweenCoords3d(x, y, z, posX, posY, z)
wait(0)
until dist < radius
end
function MovePlayer(move_code, isSprint)
setGameKeyState(1, move_code)
--[[255 - обычный бег назад
-255 - обычный бег вперед
65535 - идти шагом вперед
-65535 - идти шагом назад]]
if isSprint then setGameKeyState(16, 255) end
end
function SetAngle(x, y, z)
local posX, posY, posZ = getCharCoordinates(PLAYER_PED)
x1 = x - posX
y1 = y - posY
vec2 = getHeadingFromVector2d(x1, y1)
shit = math.rad(vec2)
shit = shit + 4.7
setCameraPositionUnfixed(-0.3, shit)
end
function GetCoordinates()
if isCharInAnyCar(playerPed) then
local car = storeCarCharIsInNoSave(playerPed)
return getCarCoordinates(car)
else
return getCharCoordinates(playerPed)
end
end