Entity:SetVelocity(Vector(0, 0, 0)) not working on vehicles...
4 replies, posted
Hi all again,
I'm now implementing vehicle's fuel mangement to my own made vehicle controller. So, for the moment the whole fuel management seams to be working fine.
However, when fuel reach 0, the program sets the vehicle's entity velocity to null vector, but the vehicle continue moving...
[code]
GameGlobal:PrintMessage("Initializing rp_vehicles mod...")
hook.Add("VehicleMove", "RealisticRoleplay_RPVehiclesMod", function(ply, vehicle, mv)
if (vehicle.VC_Fuel <= 0) then
vehicle.VC_Fuel = 0
vehicle:SetVelocity(Vector(0, 0, 0))
drive.PlayerStopDriving(ply)
return
end
local vec = vehicle:GetVelocity()
local speed = vec.x + vec.y + vec.z
if (speed < 0) then
speed = speed * -1
end
--999999 This value is when in play mode
--99999 This value is for debugging, to see if everything works correctly
local fuelBurnAmount = speed / 99999
vehicle.VC_Fuel = vehicle.VC_Fuel - fuelBurnAmount
vehicle:SetNWInt("Fuel", vehicle.VC_Fuel)
end)
[/code]
You could try this instead of setting the velocity to 0:
[code]
vehicle:Fire("off", "", 0);
[/code]
[QUOTE=G4MB!T;45399798]You could try this instead of setting the velocity to 0:
[code]
vehicle:Fire("off", "", 0);
[/code][/QUOTE]
Thanks will try
[editline]15th July 2014[/editline]
[QUOTE=Yuri6037;45399881]Thanks will try[/QUOTE]
Unfortunatly it's not working ; it simply changes nothing...
Sorry its "turnoff".
So thank you !!!
So very much thank you ! It's working the vehicle is no longer moving !!!! YAYAY !
Sorry, you need to Log In to post a reply to this thread.