See the /me command in 5 meters
#1

Hey, how can i make my /me command so, that only players not further then 5 meters can c it?
Reply
#2

Use foreach to loop trough all connected players. Then use https://sampwiki.blast.hk/wiki/IsPlayerInRangeOfPoint to check if the loop itterator is in range of the player. If they are then send the message.
Reply
#3

I just got no idea how to do this.
Reply
#4

I just told you how? Now it's up to you to do it yourself.
Reply
#5

Step 1: Learn to code.
Step 2: Learn to be able to research things yourself.
Reply
#6

ZCMD
pawn Код:
CMD:me( playerid, params[ ] )
{
    for( new i = 0; i < MAX_PLAYERS; i++ )
    {
        new Float:x, Float:y, Float:z;
        GetPlayerPos( i, x, y, z );
        if ( IsPlayerInRangeOfPoint ( i, 5.0, x, y, z ) ) // You can always change the range
        {
            if ( i == playerid ) continue;
            new string[ 128 ];
            new pName[ MAX_PLAYER_NAME ];
            GetPlayerName( playerid, pName, sizeof pName );
            format( string, sizeof string, "%s %s", pName, params );
            SendClientMessage( i, 0xAAAAAA, string );
        }
    }
    return 1;
}
Reply
#7

Psuedocode:
Foreach -> IsPlayerInRangeofPoint( otherplayerid, getpos(playerid), 5) -> sendclientmessage(otherplayerid)
Reply
#8

Can someone give me a /me command, just like the ZCMD but then not ZCMD but the normal command stuff
Reply
#9

pawn Код:
if (strcmp("/me", cmdtext, true, 3) == 0)
{
    for( new i = 0; i < MAX_PLAYERS; i++ )
    {
        new Float:x, Float:y, Float:z;
        GetPlayerPos( i, x, y, z );
        if ( IsPlayerInRangeOfPoint ( i, 5.0, x, y, z ) ) // You can always change the range
        {
            if ( i == playerid ) continue;
            new string[ 128 ];
            new pName[ MAX_PLAYER_NAME ];
            GetPlayerName( playerid, pName, sizeof pName );
            format( string, sizeof string, "%s %s", pName, cmdtext );
            SendClientMessage( i, 0xAAAAAA, string );
        }
    }
    return 1;
}
Reply
#10

Quote:
Originally Posted by Mean
Посмотреть сообщение
pawn Код:
if (strcmp("/me", cmdtext, true, 3) == 0)
{
    for( new i = 0; i < MAX_PLAYERS; i++ )
    {
        new Float:x, Float:y, Float:z;
        GetPlayerPos( i, x, y, z );
        if ( IsPlayerInRangeOfPoint ( i, 5.0, x, y, z ) ) // You can always change the range
        {
            if ( i == playerid ) continue;
            new string[ 128 ];
            new pName[ MAX_PLAYER_NAME ];
            GetPlayerName( playerid, pName, sizeof pName );
            format( string, sizeof string, "%s %s", pName, cmdtext );
            SendClientMessage( i, 0xAAAAAA, string );
        }
    }
    return 1;
}
Please test your code before you post. That code will send the message to every loop itteration in range of their own position. Also, please do not post finished code to people like this. They'll come to this section and ask basic questions like this all the time because they do not learn anything by people like you giving them finished code.

Also, to topic poster. I see no reason to use strcmp as a command processor. There are better ones out there, so why not use them? Or wait, you downloaded The Godfather script, edited it and claimed it as your own. And now you use and learn from the bad code in that script.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)