Anti Command spam, /shout system - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Anti Command spam, /shout system (
/showthread.php?tid=252744)
Anti Command spam, /shout system -
Penait1 - 02.05.2011
Hi, i have created a Shout system, with a anti spam, so you need to wait for 2 minuts before you can shout again. Only, if 1 player shouted, NOBODY can shout anymore for 2 minuts. I want that it be that if 1 player shouted, a other player can shout also in that 2 minuts, but need to wait also 2 minuts before shouting again.
This is my code:
Up the script
Quote:
new boolhout;
forward antishoutspam(playerid);
|
public
Quote:
public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(shout, 5, cmdtext);
return 0;
}
dcmd_shout(playerid, params[])
{
#pragma unused params
if(GetPlayerScore(playerid) <= 4999)SendClientMessage(playerid, COLOR_LIGHTBLUE, "You need 5000 score ore more! Try to get 5000 score, and try again.");
else if(shout) return SendClientMessage(playerid, COLOR_RED, "Serverguid : {33FF00}You cant shout so fast! Please wait first ");
else if(!strlen(params)) SendClientMessage(playerid, 0xFF0000AA, "Serverguid: {00FF15}Use: /Shout [Message] - Try again!");
else
{
new PlayerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
format(string, sizeof(string), "Serverguid: {00FF15}%s Shouted: {F0FC03}%s!", PlayerName, params);
SendClientMessageToAll(COLOR_RED, string);
SetPlayerScore(playerid, GetPlayerScore(playerid) - 5000);
PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
Timer1 = SetTimer("antishoutspam",120000,false);
shout= true;
GameTextForAll("-!!- Theres a new shout -!!-",2000,1);
}
return 1;
}
|
Forward
Quote:
public antishoutspam(playerid)
{
shout = false;
KillTimer(Timer1);
return 1;
}
|
init
Quote:
public OnGameModeInit()
{
SetTimer("antishoutspam",0,false);
return 1;
|
No errors, evrything is working
But how can i do that if someone shooted, a other guy can shout again, and if he shouted he needs to wait 2 mins.
Can you give a example?
Thank you
Re: Anti Command spam, /shout system -
Penait1 - 02.05.2011
Erm, really sorry for the bump, but have nobody ideas
?
Re: Anti Command spam, /shout system -
park4bmx - 02.05.2011
Change
new boolhoat or what ever it is to
new boolhoat[MAX_PLAYERS]
the later on where ever you use the
boolhoat use it like this
boolhoat[playerid]
By doing that your making BoolHOat for each playerid not for everyone