require 'lib.sampfuncs'
require 'lib.moonloader'
function main()
if not isSampfuncsLoaded() or not isSampLoaded() then return end
while not isSampAvailable() do
wait(200)
end
while true do
wait(0)
if isKeyJustPressed(VK_RSHIFT) then -- airbrake
funcsStatus.AirBrk = not funcsStatus.AirBrk
if funcsStatus.AirBrk then
local posX, posY, posZ = getCharCoordinates(playerPed)
airBrkCoords = {posX, posY, posZ, 0.0, 0.0, getCharHeading(playerPed)}
func_change_status('AirBrake', 1, true)
else
func_change_status('AirBrake', 1, false)
end
end
end
end
function al()
if funcsStatus.AirBrk then -- airbrake
if isCharInAnyCar(playerPed) then heading = getCarHeading(storeCarCharIsInNoSave(playerPed))
else heading = getCharHeading(playerPed) end
local camCoordX, camCoordY, camCoordZ = getActiveCameraCoordinates()
local targetCamX, targetCamY, targetCamZ = getActiveCameraPointAt()
local angle = getHeadingFromVector2d(targetCamX - camCoordX, targetCamY - camCoordY)
if isCharInAnyCar(playerPed) then difference = 0.79 else difference = 1.0 end
setCharCoordinates(playerPed, airBrkCoords[1], airBrkCoords[2], airBrkCoords[3] - difference)
if isKeyDown(VK_W) then
airBrkCoords[1] = airBrkCoords[1] + config.AirBrake.Speed * math.sin(-math.rad(angle))
airBrkCoords[2] = airBrkCoords[2] + config.AirBrake.Speed * math.cos(-math.rad(angle))
if not isCharInAnyCar(playerPed) then setCharHeading(playerPed, angle)
else setCarHeading(storeCarCharIsInNoSave(playerPed), angle) end
elseif isKeyDown(VK_S) then
airBrkCoords[1] = airBrkCoords[1] - config.AirBrake.Speed * math.sin(-math.rad(heading))
airBrkCoords[2] = airBrkCoords[2] - config.AirBrake.Speed * math.cos(-math.rad(heading))
end
if isKeyDown(VK_A) then
airBrkCoords[1] = airBrkCoords[1] - config.AirBrake.Speed * math.sin(-math.rad(heading - 90))
airBrkCoords[2] = airBrkCoords[2] - config.AirBrake.Speed * math.cos(-math.rad(heading - 90))
elseif isKeyDown(VK_D) then
airBrkCoords[1] = airBrkCoords[1] - config.AirBrake.Speed * math.sin(-math.rad(heading + 90))
airBrkCoords[2] = airBrkCoords[2] - config.AirBrake.Speed * math.cos(-math.rad(heading + 90))
end
if isKeyDown(VK_UP) then airBrkCoords[3] = airBrkCoords[3] + config.AirBrake.Speed / 2.0 end
if isKeyDown(VK_DOWN) and airBrkCoords[3] > -95.0 then airBrkCoords[3] = airBrkCoords[3] - config.AirBrake.Speed / 2.0 end
if not isSampfuncsConsoleActive() and not sampIsChatInputActive() and not sampIsDialogActive() and not isPauseMenuActive() then
if isKeyDown(VK_OEM_PLUS) and time - tick.Keys.Plus > tick.Time.PlusMinus then
if config.AirBrake.Speed < 14.9 then config.AirBrake.Speed = config.AirBrake.Speed + 0.5 end
post_of_notification(string.format('AirBrk speed changed to: %.1f.', config.AirBrake.Speed))
tick.Keys.Plus = os.clock() * 1000
elseif isKeyDown(VK_OEM_MINUS) and time - tick.Keys.Minus > tick.Time.PlusMinus then
if config.AirBrake.Speed > 0.5 then config.AirBrake.Speed = config.AirBrake.Speed - 0.5 end
post_of_notification(string.format('AirBrk speed changed to: %.1f.', config.AirBrake.Speed))
tick.Keys.Minus = os.clock() * 1000
end
end
end
end