#1

How should I do when the servers are kindly requested to chat @ if, somehow ID so give me the name of the player example: @0 went to play tanks ==> EmpireSk went to play tanks
Reply
#2

Help me?
Reply
#3

You mean like if player do a command like /drift it sends a command to the admins that
(playerid) has joined drift?
Reply
#4

but I do not want to over command I want to have in OnPlayertext
Reply
#5

After testing it multiply times, it seems to be working.
pawn Код:
// OnPlayerText:
if (text[0] == '@')
{
    new
        id;
       
    if ((id = RetrieveID(text)) != INVALID_PLAYER_ID)
    {
        new
            name[21];
           
        GetPlayerName(id, name, sizeof (name));
       
        // format and send..
    }
}
pawn Код:
stock RetrieveID(const text[])
{
    new
        pos,
        id[3],
        bool: numeric = true;
       
    while (text[++pos] > ' ')
    {
        if (pos > sizeof (id)) break;
        if (!('0' <= text[pos] <= '9'))
        {
            numeric = false;
            break;
        }
        id[pos - 1] = text[pos];
    }
    if (numeric && !isnull(id)) return strval(id);
    return INVALID_PLAYER_ID;
}
pawn Код:
#if !defined isnull
    #define isnull(%1) \
                ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))
#endif
Reply
#6

I love you thank you very much
Reply
#7

It does not work
Reply
#8

It does work fine for me:

This is what I typed:
pawn Код:
"test1"

"@ test2"

"@0 test3" // it worked because it's valid and connected player

"@3 test4"

"@444444 test5"

"@4@ test6"
I also changed this line:
pawn Код:
if (numeric && !isnull(id)) return strval(id);
to:
pawn Код:
if (numeric && !isnull(id) && IsPlayerConnected(strval(id))) return strval(id);
so it can only return players who are connected only.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)