An early example of a fuel mod I decided to make:
function StopVehicleCheck(%this,%obj)
{
if(!isObject(%obj))
return;
if(!%obj.nofuelstop)
return;
if(%obj.fuel > 1)
{
%obj.nofuelstop = 0;
return;
}
%obj.setVelocity("0 0 0");
Schedule(50,0,StopVehicleCheck,%this,%obj);
}
function FuelCheck(%this, %obj)
{
if(!isObject(%obj))
return;
%speed = vectorLen(%obj.getVelocity());
schedule(500,0,"FuelCheck",%this,%obj);
if(%speed < 1 || %obj.GetControllingClient() == 0)
return;
if(%obj.fuel > 0)
%obj.fuel--;
else
{
%obj.nofuelstop = true;
StopVehicleCheck(%this,%obj);
}
}
function JeepVehicle::onadd(%this, %obj)
{
echo("Made a vehicle.");
Parent::onadd(%this,%obj);
%obj.fuel = 25;
FuelCheck(%this, %obj);
}
How do I replace JeepVehicle with something that's generic for all vehicle types?
Any better way of stopping/slowing-down a vehicle than constantly setting it's velocity to 0?
This needs more work than that, but I can't go much farther until I get these questions answered.
Thanks for potential help.