[HELP] Use chat every 3 seconds
#1

Anyone know how to disable chat every 3 seconds, to prevent spam. I have a script for anti command spam. but it's only if player use command.

EDIT: Without being muted or kicked. Just a normal one
Reply
#2

me too looking for that.Someone post here a good one
Reply
#3

filterscripts > baseaf
Reply
#4

When a player sends text to the chatbox, store a variable to block his next chattext unless the minimum time has been passed.

Код:
new BlockChat[MAX_PLAYERS];

public OnPlayerText(playerid, text[])
{
	// Check if the chatting for this player is blocked
	if (BlockChat[playerid] == 1)
	{
		// Inform the player about his chat-block
		SendClientMessage(playerid, 0xFF0000FF, "You're not allowed to chat so soon, please wait a few seconds");
		// Disallow the chat to be sent to the chatbox
	    return 0;
	}
	else
	{
		// Set this player to be blocked the next time he chats
		Blockchat[playerid] = 1;
		// Set a timer to unblock his chatting after 3 seconds
		SetTimer(BlockChatTimer, 3000, false);
		// Allow his current chat-text to be sent to the chatbox
		return 1;
	}
}

forward BlockChatTimer(playerid);
public BlockChatTimer(playerid)
{
	// Unblock the chatbox for the given player
	Blockchat[playerid] = 0;

	return 1;
}
Reply
#5

That's easy to make.
  • Create a global variable for each player
    pawn Код:
    new ChatTime[MAX_PLAYERS];
  • When Player Connect set value to 0
    pawn Код:
    public OnPlayerConnect(playerid)
    {
        ChatTime[playerid] = 0;
        return 1;
    }
  • When he enters text get time.
    pawn Код:
    public OnPlayerText(playerid, text[])
    {
        new time = gettime();//get current time in unix
       
        //see if difference is less than 3 seconds
        if ((time - ChatTime[playerid]) < 3)
        {
            SendClientMessage(playerid,-1,"You can send message only once in 3 secomds");
            return 0;
        }
        //if not then get the time they last used chat.
        ChatTime[playerid] = gettime();
       
        return 1;
    }
Reply
#6

@[MM]RoXoR[FS] you have tested this?
Reply
#7

Quote:
Originally Posted by ReVo_
Посмотреть сообщение
@[MM]RoXoR[FS] you have tested this?
Yes i Tested it.
Reply
#8

On top of your script:
pawn Код:
new CanChat[MAX_PLAYERS] = 1;
pawn Код:
public OnPlayerText(playerid, text[])
{
    if(CanChat[playerid] == 0)
    {
        SendClientMessage(playerid, FF0000, "You can send a message every 3 seconds!");
        return 0;
    }

    CanChat[playerid] = 0;
    SetTimerEx("AllowChat", 1000*3, false, "i", playerid);
    return 1;
}
pawn Код:
forward AllowChat(playerid);
public AllowChat(playerid)
{
    CanChat[playerid] = 1;
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)