SA-MP Forums Archive
Chat - 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: Chat (/showthread.php?tid=498906)



Chat - EmpireSk - 05.03.2014

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


Re: Chat - EmpireSk - 05.03.2014

Help me?


Re: Chat - XK - 05.03.2014

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


Re: Chat - EmpireSk - 05.03.2014

but I do not want to over command I want to have in OnPlayertext


Re: Chat - Konstantinos - 05.03.2014

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



Re: Chat - EmpireSk - 05.03.2014

I love you thank you very much


Re: Chat - EmpireSk - 05.03.2014

It does not work


Re: Chat - Konstantinos - 05.03.2014

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.