SA-MP Forums Archive
Can you help me with /speed command (+REP) - 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: Can you help me with /speed command (+REP) (/showthread.php?tid=648222)



Can you help me with /speed command (+REP) - BluePlayBG - 17.01.2018

The command would tell a vehicle's speed when is executed, for example if I am staying in a vehicle and someone passes, and I type /speed it should tell me the vehicle's speed.

Thanks in advance. +rep


Re: Can you help me with /speed command (+REP) - Dayrion - 17.01.2018

"Scripting Help"
It's not "Request command section"


Re: Can you help me with /speed command (+REP) - Daveosss - 17.01.2018

This will show all the nearby players who are driving a vehicle and their speed:

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(playeridparams[]) // I'm using zcmd include here
{
    new 
found 0;
    new 
Float:X,Float:Y,Float:Z;
    
GetPlayerPos(playeridX,Y,Z);
    for(new 
0GetPlayerPoolSize(); <= ji++)
    {
        if(
IsPlayerConnected(i) && GetPlayerState(i) == PLAYER_STATE_DRIVER && IsPlayerInRangeOfPoint(i50.0XYZ) && != playerid)
        {
            
found 1;
            new 
string[128];
            new 
name[MAX_PLAYER_NAME];
            
GetPlayerName(playeridnamesizeof(name));
            
format(stringsizeof(string), "Player: %s(%d), Speed: %d"nameiGetPlayerSpeed(i));
            
SendClientMessage(playerid, -1string);
        }
    }
    if(
found == 0)
    {
        
SendClientMessage(playerid, -1"No players found.");
    }
    return 
1;




Re: Can you help me with /speed command (+REP) - Abagail - 17.01.2018

Quote:
Originally Posted by Daveosss
Посмотреть сообщение
This will show all the nearby players who are driving a vehicle and their speed:

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(playeridparams[]) // I'm using zcmd include here
{
    new 
found 0;
    new 
Float:X,Float:Y,Float:Z;
    
GetPlayerPos(playeridX,Y,Z);
    for(new 
0GetPlayerPoolSize(); <= ji++)
    {
        if(
IsPlayerConnected(i) && GetPlayerState(i) == PLAYER_STATE_DRIVER && IsPlayerInRangeOfPoint(i50.0XYZ) && != playerid)
        {
            
found 1;
            new 
string[128];
            new 
name[MAX_PLAYER_NAME];
            
GetPlayerName(playeridnamesizeof(name));
            
format(stringsizeof(string), "Player: %s(%d), Speed: %d"nameiGetPlayerSpeed(i));
            
SendClientMessage(playerid, -1string);
        }
    }
    if(
found == 0)
    {
        
SendClientMessage(playerid, -1"No players found.");
    }
    return 
1;

You should've read the above post. This isn't helping him at all, it's simply giving him code. It doesn't even have comments in the code. How does this help him learn anything?