Hello, I’m having an issue with my script. For some reason my seatbelt script isn’t working. It’s not throwing people out of the car if they do not have a seatbelt on. I’m not quite sure why. Code:
Citizen.CreateThread(function()
local currSpeed = 0
local prevVelocity = { x = 0.0, y = 0.0, z = 0.0 }
while true do
Citizen.Wait(0)
local prevSpeed = currSpeed
local position = GetEntityCoords(player)
currSpeed = GetEntitySpeed(veh)
if not seatbelt then
local vehIsMovingFwd = GetEntitySpeedVector(veh, true).y > 1.0
local vehAcc = (prevSpeed - currSpeed) / GetFrameTime()
if (vehIsMovingFwd and (prevSpeed > seatbeltEjectSpeed) and (vehAcc > (seatbeltEjectAccel * 9.81))) then
SetEntityCoords(player, position.x, position.y, position.z - 0.47, true, true, true)
SetEntityVelocity(player, prevVelocity.x, prevVelocity.y, prevVelocity.z)
Citizen.Wait(1)
SetPedToRagdoll(player, 1000, 1000, 0, 0, 0, 0)
else
prevVelocity = GetEntityVelocity(veh)
end
end
end
end)```