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



OnPlayerText problem - Crazyboobs - 13.07.2012

I have made if a player chat then his id will show along with his name
Quote:

Crazyboobs (ID): chat

At the same time i have made anti spam too, if a player type anything then others cant see that msg and send message to the player that" Stop repeating"

Here is the code of both
pawn Код:
public OnPlayerText(playerid, text[]){
    new
        msg[128],
        tPlayerName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, tPlayerName, MAX_PLAYER_NAME);
    format(msg, sizeof(msg), "%s (%d): {FFFFFF}%s", tPlayerName, playerid, text);
    SendClientMessageToAll(GetPlayerColor(playerid), msg);
   
    static pText[MAX_PLAYERS][128];
    if(pText[playerid][0] != '\0' && !strcmp(text,pText[playerid],true)) return SendClientMessage(playerid,-1,"* Stop repeating!") & 0;
    strcat((pText[playerid][0]='\0',pText[playerid]),text,128);
    return 1;}
The problem is that if i put return 1;} at the end then anti spam will work where as i put return 0;} then this will work
Quote:

Crazyboobs (ID): chat

Both will not work at the same time, i tried a lot but no use.
Can anyone please make this both work at the same time?

Thanks in advance


Re: OnPlayerText problem - [MM]RoXoR[FS] - 13.07.2012

Easy fix
pawn Код:
public OnPlayerText(playerid, text[])
{
    new  msg[128],tPlayerName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, tPlayerName, MAX_PLAYER_NAME);
    format(msg, sizeof(msg), "%s (%d): {FFFFFF}%s", tPlayerName, playerid, text);

    static pText[MAX_PLAYERS][128];
    if(pText[playerid][0] != '\0' && !strcmp(text,pText[playerid],true)) return SendClientMessage(playerid,-1,"* Stop repeating!") & 0;
    strcat((pText[playerid][0]='\0',pText[playerid]),text,128);

    SendClientMessageToAll(GetPlayerColor(playerid), msg);

    return 0;
}