SA-MP Forums Archive
Need a script - /speed - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Need a script - /speed (/showthread.php?tid=602834)



Need a script - /speed - SwagMate - 14.03.2016

Hello guys, does anyone know how to make command /speed (nickname) 0km/h (this command would say the speed of the player) (ZCDM)

Thank you


Re: Need a script - /speed - iKarim - 14.03.2016

PHP код:
// You should include sscanf2 and (i)ZCMD.
CMD:speed(playeridparams[])
{
    new 
target;
    if(
sscanf(params"u"target)) return SendClientMessage(playerid0xFF0000FF"[USAGE] speed [playerid/playername]");
    else
    {
        new 
vehicleid;
        if ((
vehicleid GetPlayerVehicleID(target)))
        {
            new
                
Float:vx,
                
Float:vy,
                
Float:vz,
                
_speed
            
;
            
GetVehicleVelocity(vehicleidvxvyvz);
            
speed floatroundfloatsqroot(vx vx vy vy vz vz) * 187.666667 );
            new 
tmp[128], tmp_name[MAX_PLAYER_NAME];
            
GetPlayerName(targettmp_namesizeof tmp_name);
            
format(tmpsizeof tmp"%s's speed: %i"tmp_namespeed);
            
SendClientMessage(playerid, -, "[USAGE] speed [playerid/playername]");
        }
        else return 
SendClientMessage(playerid0xFF0000FF"[ERROR] player is not in vehicle.");
    }
    return 
true;




Re: Need a script - /speed - SwagMate - 14.03.2016

Thank you so much, I see you quite good at it, would u script for money? Please PM me x


Re: Need a script - /speed - Pottus - 14.03.2016

speed = floatround( floatsqroot(vx * vx + vy * vy + vz * vz) * 187.666667 ); That is the incorrect "magic number" the value should be from 180.0 to 181.5 for accurate speed readings.