Help :S OOC FLOOD :S
#1

I need that player wait 2 seconds between ooc messages I made that but it only says Please try again later 2 seconds later! ant I cant write text again :S

Код:
forward OOCFLOOD();
Код:
new AFLOOD = 1;
Код:
new FLOOD = 20000;
Код:
//----------------------------------[ooc]-----------------------------------------------
	if(strcmp(cmd, "/ooc", true) == 0 || strcmp(cmd, "/o", true) == 0)
	{
	  if(IsPlayerConnected(playerid))
	  {
	    if(gPlayerLogged[playerid] == 0)
	    {
	      SendClientMessage(playerid, COLOR_GREY, "You havent logged in yet !");
	      return 1;
	    }
			if ((noooc) && PlayerInfo[playerid][pAdmin] < 1)
			{
				SendClientMessage(playerid, COLOR_GRAD2, "OOC Is Disabled By Admin!");
				return 1;
			}
			if(PlayerInfo[playerid][pMuted] == 1)
			{
				SendClientMessage(playerid, TEAM_CYAN_COLOR, " You Are Muted!");
				return 1;
			}
			GetPlayerName(playerid, sendername, sizeof(sendername));
			new length = strlen(cmdtext);
			while ((idx < length) && (cmdtext[idx] <= ' '))
			{
				idx++;
			}
			new offset = idx;
			new result[64];
			while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
			{
				result[idx - offset] = cmdtext[idx];
				idx++;
			}
			result[idx - offset] = EOS;
			if(!strlen(result))
			{
				SendClientMessage(playerid, COLOR_GRAD2, "USAGE: (/o)oc [ooc chat]");
				return 1;
			}
			if ((!AFLOOD) && (PlayerInfo[playerid][pAdmin] < 1))
			{
				format(string, sizeof(string), "Please try again later %d seconds Later!", (FLOOD/10000));
				SendClientMessage(playerid, COLOR_YELLOW, string);
				return 1;

			}
			format(string, sizeof(string), "[OOC] %s: %s " , sendername, result);
			OOCOff(COLOR_OOC,string);
			printf("%s", string);
			if (PlayerInfo[playerid][pAdmin] < 1){SetTimer("OOCFLOOD", FLOOD, 0);AFLOOD = 0;}
			}
		return 1;
	}
it is my OOC can you help me?
Reply
#2

i think you should use timer
Reply
#3

pawn Код:
#define FLOOD 2000
First the Global Variable:
pawn Код:
new AFLOOD[MAX_PLAYERS];
Now this one to OnPlayerConnect:
pawn Код:
AFLOOD[playerid] = 0;
pawn Код:
//----------------------------------[ooc]-----------------------------------------------
    if(strcmp(cmd, "/ooc", true) == 0 || strcmp(cmd, "/o", true) == 0)
    {
      if(IsPlayerConnected(playerid))
      {
        if(gPlayerLogged[playerid] == 0)
        {
          SendClientMessage(playerid, COLOR_GREY, "You havent logged in yet !");
          return 1;
        }
            if ((noooc) && PlayerInfo[playerid][pAdmin] < 1)
            {
                SendClientMessage(playerid, COLOR_GRAD2, "OOC Is Disabled By Admin!");
                return 1;
            }
            if(PlayerInfo[playerid][pMuted] == 1)
            {
                SendClientMessage(playerid, TEAM_CYAN_COLOR, " You Are Muted!");
                return 1;
            }
            GetPlayerName(playerid, sendername, sizeof(sendername));
            new length = strlen(cmdtext);
            while ((idx < length) && (cmdtext[idx] <= ' '))
            {
                idx++;
            }
            new offset = idx;
            new result[64];
            while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
            {
                result[idx - offset] = cmdtext[idx];
                idx++;
            }
            result[idx - offset] = EOS;
            if(!strlen(result))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "USAGE: (/o)oc [ooc chat]");
                return 1;
            }
            if (AFLOOD[playerid] == 1 && (PlayerInfo[playerid][pAdmin] < 1))
            {
                format(string, sizeof(string), "Please try again later %d seconds Later!", (FLOOD/10000));
                SendClientMessage(playerid, COLOR_YELLOW, string);
                return 1;

            }
            format(string, sizeof(string), "[OOC] %s: %s " , sendername, result);
            OOCOff(COLOR_OOC,string);
            printf("%s", string);
            if (PlayerInfo[playerid][pAdmin] < 1){AFLOOD[playerid] = 1; SetTimerEx("OOCFLOOD", FLOOD, 0, "i", playerid);}
            }
        return 1;
    }
Now just the public function for the OOCFLOOD
pawn Код:
forward OOCFLOOD(playerid);
public OOCFLOOD(playerid)
{
  AFLOOD[playerid] = 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)