-- CarShot.lua — реконструкция из CarShot.luac (LuaJIT 2.0)
-- Автор: BuyBack. Суть: "выстрел" машиной вперёд по курсу, удержание скорости 0.5с
local enabled = false -- вкл/выкл через /cshot
local boosting = false -- флаг удержания форсажа
local speed = 1 -- мощность, по стандарту 1
local key = 88 -- VK-код клавиши тарана ('X')
local boostVelX, boostVelY = 0, 0
function CarShot(speedArg)
if speedArg then
speed = tonumber(speedArg)
end
enabled = not enabled
if enabled then
sampAddChatMessage("CarShot Включен", 65280) -- 0xFF00
else
sampAddChatMessage("CarShot Выключен", 16711680) -- 0xFF0000
end
end
function main()
while not isSampAvailable() do
wait(0)
end
sampAddChatMessage("CarShot by BuyBack Активация:/cshot [мощность, по стандарту 1]", 65280)
sampRegisterChatCommand("cshot", CarShot)
while true do
wait(0)
if wasKeyPressed(key) and enabled and not sampIsCursorActive() and isCharInAnyCar(PLAYER_PED) then
local car = storeCarCharIsInNoSave(PLAYER_PED)
if car ~= 0 then
local heading = math.rad(getCarHeading(car))
boostVelX = speed * -math.sin(heading)
boostVelY = speed * math.cos(heading)
boosting = true
wait(500)
boosting = false
end
end
end
end
require("lib.samp.events").onSendVehicleSync = function(sync)
if enabled and isCharInAnyCar(PLAYER_PED) and boosting and sync then
sync.moveSpeed.x = boostVelX
sync.moveSpeed.y = boostVelY
end
return sync
end