So I’m trying to write a script that modifies all vehicles as i’ve adjusted the kmh speed to what i feel is more realistic.
I’m adjusting the damage multiplier and a few others aswell, but unfortunately it is multiple in a way that if I just slightly touch a wall, the car explodes violently.
I think its something to do with the ‘while true do’ but im just not understanding how to set it up, or if i’ve set it up correctly at all.
Any help would be greatly appreciated! My script below:-
Citizen.CreateThread(function()
while true do
Citizen.Wait(1)
local veh = GetVehiclePedIsIn(PlayerPedId(), false)
local model = GetEntityModel(veh)
local initial_drive_force = GetVehicleHandlingFloat(veh, "CHandlingData", "fInitialDriveForce")
local damage = GetVehicleHandlingFloat(veh, "CHandlingData", "fCollisionDamageMult")
local drag = GetVehicleHandlingFloat(veh, "CHandlingData", "fInitialDragCoeff")
local veh_class = GetVehicleClass(veh)
local top_speed = GetVehicleHandlingFloat(veh, "CHandlingData", "fInitialDriveMaxFlatVel")
if DoesEntityExist(veh) and not IsEntityDead(veh) then
if IsThisModelACar(model) then
SetVehicleHandlingFloat(veh, "CHandlingData", "fCollisionDamageMult", damage * 10) -- For some reason exploding immediately?
if veh_class == 4 or veh_class == 5 or veh_class == 6 or veh_class == 7 then
SetVehicleHandlingFloat(veh, "CHandlingData", "fInitialDriveForce", initial_drive_force * 1.2)
end
if veh_class == 7 then
SetVehicleHandlingFloat(veh, "CHandlingData", "fInitialDragCoeff", 1.5)
else
SetVehicleHandlingFloat(veh, "CHandlingData", "fInitialDragCoeff", 2.5)
end
if veh_class == 4 or veh_class == 5 or veh_class == 6 then
SetVehicleHandlingFloat(veh, "CHandlingData", "fInitialDriveMaxFlatVel", top_speed * 1.5)
elseif veh_class == 7 then
SetVehicleHandlingFloat(veh, "CHandlingData", "fInitialDriveMaxFlatVel", top_speed * 1.8)
else
SetVehicleHandlingFloat(veh, "CHandlingData", "fInitialDriveMaxFlatVel", top_speed * 1.2)
end
end
end
end
end)
Once again, thanks in advance for your help!