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



OnPlayerText - Crazyboobs - 05.06.2012

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??


Re: OnPlayerText - Revo - 05.06.2012

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.


Re: OnPlayerText - Crazyboobs - 05.06.2012

Can you post the code please?


Re: OnPlayerText - MP2 - 05.06.2012

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



Re: OnPlayerText - Jefff - 05.06.2012

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


Re: OnPlayerText - Crazyboobs - 06.06.2012

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


Re: OnPlayerText - Crazyboobs - 06.06.2012

Please anyone help


Re: OnPlayerText - MadeMan - 06.06.2012

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?


Re: OnPlayerText - Crazyboobs - 06.06.2012

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.


Re: OnPlayerText - skullmuncher1337 - 06.06.2012

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);