25.03.2019, 20:03
Your code will NEVER work because you're not calling ANYWHERE the VehicleSpeed function. It's just static, yes you added a message, yes you added the km/h check, but when and how VehicleSpeed gets called?
You have to call it somewhere to be sure the player will get the message. Place it in a timer maybe? (By checking if the player is in the vehicle and in the driver seat obv). Otherwise yours is just a "static" function, stays there just to increase lines in your code, nothing more.
And i suggest you to use this:
You have to call it somewhere to be sure the player will get the message. Place it in a timer maybe? (By checking if the player is in the vehicle and in the driver seat obv). Otherwise yours is just a "static" function, stays there just to increase lines in your code, nothing more.
And i suggest you to use this:
pawn Code:
GetVehicleSpeed(vehicleid, type)
{
//Type 1: MPH - Any other type: KM/H
//GetVehicleSpeed(GetPlayerVehicleID(playerid), 1);
new s;
new Float:x, Float:y, Float:z;
GetVehicleVelocity(vehicleid, x, y, z);
switch(type)
{
case 1: s = floatround((floatsqroot(floatpower(x, 2) + floatpower(y, 2) + floatpower(z, 2)))*112.1577, floatround_round);
default: s = floatround((floatsqroot(floatpower(x, 2) + floatpower(y, 2) + floatpower(z, 2)))*180.5000, floatround_round);
}
return s;
}