[HELP] Use chat every 3 seconds - 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: [HELP] Use chat every 3 seconds (
/showthread.php?tid=365165)
[HELP] Use chat every 3 seconds -
kbalor - 02.08.2012
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
Re: [HELP] Use chat every 3 seconds -
Gamer_007 - 02.08.2012
me too looking for that.Someone post here a good one
Re: [HELP] Use chat every 3 seconds -
newbienoob - 02.08.2012
filterscripts > baseaf
Re: [HELP] Use chat every 3 seconds -
AmigaBlizzard - 02.08.2012
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;
}
Re: [HELP] Use chat every 3 seconds -
[MM]RoXoR[FS] - 02.08.2012
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;
}
Re: [HELP] Use chat every 3 seconds -
ReVo_ - 02.08.2012
@[MM]RoXoR[FS] you have tested this?
Re: [HELP] Use chat every 3 seconds -
[MM]RoXoR[FS] - 02.08.2012
Quote:
Originally Posted by ReVo_
@[MM]RoXoR[FS] you have tested this?
|
Yes i Tested it.
Re: [HELP] Use chat every 3 seconds -
Dan. - 02.08.2012
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;
}