Anti Command spam, /shout system
#1

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
Reply
#2

Erm, really sorry for the bump, but have nobody ideas ?
Reply
#3

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
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)