22.06.2015, 14:21
You need to calculate the velocity of the vehicle when is moves and define the max speed for every single 299 vehicle on the server. Then as Mencent said, use SetVehicleHealth.
To calculate the speed:
To see how fast hes driving:
This is a wery rough piece of code, and you need to tinker alot with it.
A little advice here : when you define the max speeds of vehicles, dont put it the max it goes. I mean if it goes 150, then define it to 149 or 148, also if you want to make the car slowly get damage, then use some timers.
To calculate the speed:
pawn Код:
new vehicleid, Float:speed_x, Float:speed_y, Float:speed_z, Float:final_speed, speed_string[50], final_speed_int;
// Get the vehicles velocity
GetVehicleVelocity(vehicleid, speed_x, speed_y, speed_z);
// Calculate the speed (in kph)
final_speed = floatsqroot(((speed_x * speed_x) + (speed_y * speed_y)) + (speed_z * speed_z)) * 158.179;
// Convert the float value to an int value
final_speed_int = floatround(final_speed, floatround_round);
// Also save the speed
new finealspeed = final_speed_int;
pawn Код:
if(vehicleid == infernus)
{
if ((final_speed_int > MAXSPEEDINFERNUS))
{
SetVehicleHealth(vehicleid, 0);
}
}
A little advice here : when you define the max speeds of vehicles, dont put it the max it goes. I mean if it goes 150, then define it to 149 or 148, also if you want to make the car slowly get damage, then use some timers.