PHP код:
stock GetPlayerSpeed(playerid)
{
new Float:xx,Float:yy,Float:zz,Float:speed;
if(IsPlayerInAnyVehicle(playerid))
{
GetVehicleVelocity(GetPlayerVehicleID(playerid),xx,yy,zz);
}
else
{
GetPlayerVelocity(playerid,xx,yy,zz);
}
speed = floatsqroot((xx * xx) + (yy * yy) + (zz * zz));
return floatround((speed * 165.12));
}
CMD:speed(playerid, params[]) // I'm using zcmd include here
{
new found = 0;
new Float:X,Float:Y,Float:Z;
GetPlayerPos(playerid, X,Y,Z);
for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)
{
if(IsPlayerConnected(i) && GetPlayerState(i) == PLAYER_STATE_DRIVER && IsPlayerInRangeOfPoint(i, 50.0, X, Y, Z) && i != playerid)
{
found = 1;
new string[128];
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "Player: %s(%d), Speed: %d", name, i, GetPlayerSpeed(i));
SendClientMessage(playerid, -1, string);
}
}
if(found == 0)
{
SendClientMessage(playerid, -1, "No players found.");
}
return 1;
}