05.09.2009, 13:39
A couple of functions to modify vehicle speed. Works in MPH feel free to convert it to km/h.
NOTE: Doesn't work with aircraft, has some interesting effects but aircraft speed will not exceed 150mph.
Another NOTE: Vehicles will slow back down to their default top speed if the function is not constantly called.
P.S. Entering 0 into SetVehicleSpeed makes a handy instant break
and using negative values sends you in the opposite direction (obviously :P)
Screenshots: SF Docks to The Big Ear!




Regards, Code Rae.
NOTE: Doesn't work with aircraft, has some interesting effects but aircraft speed will not exceed 150mph.
Another NOTE: Vehicles will slow back down to their default top speed if the function is not constantly called.
P.S. Entering 0 into SetVehicleSpeed makes a handy instant break
and using negative values sends you in the opposite direction (obviously :P)Screenshots: SF Docks to The Big Ear!




Код:
//Sets Vehicle Speed To MPH Entered
stock SetVehicleSpeed(vehicleid,mph) //Miles Per Hour
{
new Float:Vx,Float:Vy,Float:Vz,Float:DV,Float:multiple;
GetVehicleVelocity(vehicleid,Vx,Vy,Vz);
DV = floatsqroot(Vx*Vx + Vy*Vy + Vz*Vz);
if(DV > 0) //Directional velocity must be greater than 0 (display strobes if 0)
{
multiple = (mph / (DV * 100)); //Multiplying DV by 100 calculates speed in MPH
return SetVehicleVelocity(vehicleid,Vx*multiple,Vy*multiple,Vz*multiple);
}
return 0;
}
//Increases or Decreases Current Vehicle Speed By MPH Entered
stock ModifyVehicleSpeed(vehicleid,mph) //Miles Per Hour
{
new Float:Vx,Float:Vy,Float:Vz,Float:DV,Float:multiple;
GetVehicleVelocity(vehicleid,Vx,Vy,Vz);
DV = floatsqroot(Vx*Vx + Vy*Vy + Vz*Vz);
if(DV > 0) //Directional velocity must be greater than 0 (display strobes if 0)
{
multiple = ((mph + DV * 100) / (DV * 100)); //Multiplying DV by 100 calculates speed in MPH
return SetVehicleVelocity(vehicleid,Vx*multiple,Vy*multiple,Vz*multiple);
}
return 0;
}


)