SA-MP Forums Archive
Text, or command? - 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: Text, or command? (/showthread.php?tid=302782)



Text, or command? - GamingTurf - 10.12.2011

resolved. thanks.


Re: Text, or command? - fordawinzz - 10.12.2011

@ onplayertext

pawn Код:
if(text[0] == '@')
{
//do your code...
}



Re: Text, or command? - GamingTurf - 10.12.2011

Thanks, trying it now.


Re: Text, or command? - Amit_B - 10.12.2011

I've once created a "chat commands" system, I guess that it could be useful:
pawn Код:
// OnPlayerText
    if(text[0] == '@')
    {
        if(!OnPlayerChatCommand(playerid,text)) SendClientMessage(playerid,0xffffffff,"SERVER: Unknown chat command.");
        return 0;
    }
pawn Код:
// New callback
forward OnPlayerChatCommand(playerid,cmdtext[]);
public OnPlayerChatCommand(playerid,cmdtext[])
{
    new cmd[256], idx;
    cmd = strtok(cmdtext,idx);
    if(equal(cmd,"@help") || equal(cmd,"@cmd"))
    {
        SendClientMessage(playerid,0xffffffff,"Help...");
        // ...
        return 1;
    }
    return 0;
}