function XVehicle::onAdd(%this, %obj) //called when the vehicle is added
{
Parent::onAdd(%this, %obj); //make sure to call anything else that is supposed to be called and not just overwrite it with one
VehicleSpeedCheck(%obj); //call the speed checking function with the vehicle's object ID as the argument
}
function VehicleSpeedCheck(%obj)
{
if(!isObject(%obj)) //don't do anything if there's no vehicle
return;
%speed = vectorLen(%obj.getVelocity()); //get the vehicle's velocity
if(%speed < 0) //Keeps throwing random negative numbers when X is at dead stop apparently
%speed = 0;
commandToClient(%obj.getControllingClient(), 'bottomPrint', "<color:FFFF00>MPH:" SPC "<color:FFFFFF>" @ mFloor((%speed / 2.64) * 6 * 3600 / 5280), 1); //the function that actually outputs the speed in MPH; code from port's Script_VehicleStatus
schedule(500, %obj, "VehicleSpeedCheck", %obj); //schedule's the function to be done over and over again; linked to the object so if the vehicle disappears, the function will not be called anymore
}
modify as needed
edit: actually, ignore the X placeholder thing for the function, only replace X in the first line for the vehicle's datablock name (example: HydricVehicle::onAdd) since the hydric's datablock name is HydricVehicle)
the best way to add it to many vehicles is to have the VehicleSpeedCheck function as a support script add-on so that you'd only need to have the first four lines in vehicles you want; if you want it like this instead tell me