OnPlayerText
#1

Hello!
I want a script like if a player type a text for eg: hi all
Then if he type the same text 1 more time then it should not come.
If should send a message that " You cannot type the same text 1 more time"

Can anyone help me??
Reply
#2

Make a new variable "new AntiSpamChat[MAX_PLAYERS];", Whenever someone says something, increase that value using "AntiSpamChat[playerid]+1;", Add a check if he has said something in that time.

Add a timer that resets every X seconds (e.g. 5 messages per 5 seconds) and if the messages are above 5 simply return 0 and send the player a client message to stop spamming.
Reply
#3

Can you post the code please?
Reply
#4

pawn Код:
new pLastChat[MAX_PLAYERS][129];

public OnPlayerText(playerid, text[])
{
    if(!strcmp(text, pLastChat[playerid], true))
    {
        SendClientMessage(playerid, COLOR_RED, "Do not repeat yourself");
        format(pLastChat[playerid], 128, "%s", text);
        return 0; // Stop the chat from being sent
    }
    return 1;
}
Reply
#5

pawn Код:
static pText[MAX_PLAYERS][128];
if(!strcmp(pText[playerid],text,true)) return SendClientMEssage(playerid,-1,"You cannot type the same text 1 more time.");
strcat((pText[playerid][0]='\0',pText[playerid]),text,128);
All in OnPlayerText public
Reply
#6

Not working
It is showing the text "Do not repeat yourself" but player can type the same text again and again ..
Reply
#7

Please anyone help
Reply
#8

Quote:
Originally Posted by Jefff
Посмотреть сообщение
pawn Код:
static pText[MAX_PLAYERS][128];
if(!strcmp(pText[playerid],text,true)) return SendClientMEssage(playerid,-1,"You cannot type the same text 1 more time.");
strcat((pText[playerid][0]='\0',pText[playerid]),text,128);
All in OnPlayerText public
Did you try this code?
Reply
#9

Yes i have tried but when i type something it shows "You cannot type the same text 1 more time." to me and the text is shown in the chat.I can type the same thing again and again.
Reply
#10

Quote:
Originally Posted by Jefff
Посмотреть сообщение
pawn Код:
static pText[MAX_PLAYERS][128];
if(!strcmp(pText[playerid],text,true)) return SendClientMEssage(playerid,-1,"You cannot type the same text 1 more time.");
strcat((pText[playerid][0]='\0',pText[playerid]),text,128);
All in OnPlayerText public
Dude -.- you need a return 0; in there some where... try this code

pawn Код:
static pText[MAX_PLAYERS][128];
if(!strcmp(pText[playerid],text,true)) {SendClientMEssage(playerid,-1,"You cannot type the same text 1 more time."); return 0;}
strcat((pText[playerid][0]='\0',pText[playerid]),text,128);
Reply


Forum Jump:


Users browsing this thread: 6 Guest(s)