Can you help me with /speed command (+REP)
#1

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
Reply
#2

"Scripting Help"
It's not "Request command section"
Reply
#3

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;

Reply
#4

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?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)