07.08.2010, 18:12
I have the basics down but, I don't know the equation.
Anyone give me the proper way to detect speed (km/h)?
Thanks,
ScottCFR
Anyone give me the proper way to detect speed (km/h)?
Thanks,
ScottCFR
stock GetPlayerSpeed(playerid)
{
new Float:ST[4];
if(IsPlayerInAnyVehicle(playerid))
GetVehicleVelocity(GetPlayerVehicleID(playerid),ST[0],ST[1],ST[2]);
else GetPlayerVelocity(playerid,ST[0],ST[1],ST[2]);
ST[3] = floatsqroot(floatpower(floatabs(ST[0]), 2.0) + floatpower(floatabs(ST[1]), 2.0) + floatpower(floatabs(ST[2]), 2.0)) * 179.28625;
return floatround(ST[3]);
}
public OnPlayerUpdate(playerid)
{
if(GetPlayerSpeed > /*your speed limit*/) return Kick(playerid);
return 1;
}
pawn Code:
pawn Code:
|
stock GetPlayerSpeed(playerid,bool:kmh)
{
new Float:Vx,Float:Vy,Float:Vz,Float:rtn;
if(IsPlayerInAnyVehicle(playerid)) GetVehicleVelocity(GetPlayerVehicleID(playerid),Vx,Vy,Vz); else GetPlayerVelocity(playerid,Vx,Vy,Vz);
rtn = floatsqroot(floatabs(floatpower(Vx + Vy + Vz,2)));
return kmh?floatround(rtn * 100 * 1.61):floatround(rtn * 100);
}
if(GetVehicleModel(GetPlayerVehicleID(playerid)) == /*Plane model ID*/) {
// Is in a plane
} else {
// Isn't in a plane
}