OnPlayerText problem
#1

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
Reply
#2

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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)