Timer Question! [HELP] {+REP}
#1

I want two server commands to happen on their own after every 7 minutes. So the two commands which I want to happen after every 7 mins server running are. /clearbox and /clearallchat.

this is the clearbox CMD.
pawn Код:
CMD:clearbox(playerid)
    {
      if(PlayerInfo[playerid][Level] >= 5)
      {
        for(new line; line<15; line++)
        {
         format(MsgBoxStr[line], 128, "-");
        }
        TextDrawShowForAll(MessageBox[1]);
        TextDrawShowForAll(MessageBox[2]);
        TextDrawShowForAll(MessageBox[3]);
        TextDrawShowForAll(MessageBox[4]);
        TextDrawShowForAll(MessageBox[5]);
        TextDrawShowForAll(MessageBox[6]);
        TextDrawShowForAll(MessageBox[7]);
        TextDrawShowForAll(MessageBox[8]);
        TextDrawShowForAll(MessageBox[9]);
        TextDrawShowForAll(MessageBox[10]);
        TextDrawShowForAll(MessageBox[11]);
        new string[128];
        format(string,sizeof(string),MsgBoxStr[1]);
        SendBoxMsg(playerid,string);
        format(string,sizeof(string),MsgBoxStr[2]);
        SendBoxMsg(playerid,string);
        format(string,sizeof(string),MsgBoxStr[3]);
        SendBoxMsg(playerid,string);
        format(string,sizeof(string),MsgBoxStr[4]);
        SendBoxMsg(playerid,string);
        format(string,sizeof(string),MsgBoxStr[5]);
        SendBoxMsg(playerid,string);
        format(string,sizeof(string),MsgBoxStr[6]);
        SendBoxMsg(playerid,string);
        format(string,sizeof(string),MsgBoxStr[7]);
        SendBoxMsg(playerid,string);
        format(string,sizeof(string),MsgBoxStr[8]);
        SendBoxMsg(playerid,string);
        format(string,sizeof(string),MsgBoxStr[9]);
        SendBoxMsg(playerid,string);
        format(string,sizeof(string),MsgBoxStr[10]);
        SendBoxMsg(playerid,string);
      } else return SP COLOR_RED,"Only Level +5 Admins can use this command");
      return 1;
    }
This is the clearallchat cmd.
pawn Код:
CMD:clearallchat(playerid,params[]) {
    #pragma unused params
    if(PlayerInfo[playerid][Level] >= 1) {
        CMDMessageToAdmins(playerid,"CLEARALLCHAT");
        for(new i = 0; i < 50; i++) SendClientMessageToAll(green," "); return 1;
    } else return SendClientMessage(playerid,red,"ERROR: You need to be level 1 to use this command");
}
So I want server to use each of these CMD on itself after 7 mins. So can someone tell me the codes I have to put in my script in order to do this ?
Reply
#2

Well, You could use a timer which is called every 7 minutes.

Under ongamemode add this:
Код:
SetTimerEx("OnClearChat", 420000, true); // Calling the function OnClearChat every 7 minutes.
Some where else in your script:
Код:
forward OnClearChat();
public OnClearChat()
{
     for(new i = 0; i < 50; i++) SendClientMessageToAll(green," "); return 1;

     for(new line; line<15; line++)
        {
    	 format(MsgBoxStr[line], 128, "-");
        }
        TextDrawShowForAll(MessageBox[1]);
	    TextDrawShowForAll(MessageBox[2]);
	    TextDrawShowForAll(MessageBox[3]);
	    TextDrawShowForAll(MessageBox[4]);
   	    TextDrawShowForAll(MessageBox[5]);
  	    TextDrawShowForAll(MessageBox[6]);
	    TextDrawShowForAll(MessageBox[7]);
	    TextDrawShowForAll(MessageBox[8]);
	    TextDrawShowForAll(MessageBox[9]);
	    TextDrawShowForAll(MessageBox[10]);
	    TextDrawShowForAll(MessageBox[11]);
		new string[128];
		format(string,sizeof(string),MsgBoxStr[1]);
		SendBoxMsg(playerid,string);
		format(string,sizeof(string),MsgBoxStr[2]);
		SendBoxMsg(playerid,string);
		format(string,sizeof(string),MsgBoxStr[3]);
		SendBoxMsg(playerid,string);
		format(string,sizeof(string),MsgBoxStr[4]);
		SendBoxMsg(playerid,string);
		format(string,sizeof(string),MsgBoxStr[5]);
		SendBoxMsg(playerid,string);
		format(string,sizeof(string),MsgBoxStr[6]);
		SendBoxMsg(playerid,string);
		format(string,sizeof(string),MsgBoxStr[7]);
		SendBoxMsg(playerid,string);
		format(string,sizeof(string),MsgBoxStr[8]);
		SendBoxMsg(playerid,string);
		format(string,sizeof(string),MsgBoxStr[9]);
		SendBoxMsg(playerid,string);
		format(string,sizeof(string),MsgBoxStr[10]);
		SendBoxMsg(playerid,string);
	  }
     return 1;
}
Reply
#3

Thanks bro , after setting TimerEx , will I make forwards and put both the commands in it ? So I have to make two timers and use the cmd codes in the forwards and set in timer ?
Reply
#4

Check how I've done it. I've added both of those commands under the same function.

If you're going to add two seperate timers, you shall need two seperate functions.
Reply
#5

Код:
C:\Users\Emaz Ahmed\Desktop\0.3.7\gamemodes\COD9.pwn(1386) : warning 202: number of arguments does not match definition
C:\Users\Emaz Ahmed\Desktop\0.3.7\gamemodes\COD9.pwn(25449) : warning 225: unreachable code
C:\Users\Emaz Ahmed\Desktop\0.3.7\gamemodes\COD9.pwn(25467) : error 017: undefined symbol "playerid"
C:\Users\Emaz Ahmed\Desktop\0.3.7\gamemodes\COD9.pwn(25469) : error 017: undefined symbol "playerid"
C:\Users\Emaz Ahmed\Desktop\0.3.7\gamemodes\COD9.pwn(25471) : error 017: undefined symbol "playerid"
C:\Users\Emaz Ahmed\Desktop\0.3.7\gamemodes\COD9.pwn(25473) : error 017: undefined symbol "playerid"
C:\Users\Emaz Ahmed\Desktop\0.3.7\gamemodes\COD9.pwn(25475) : error 017: undefined symbol "playerid"
C:\Users\Emaz Ahmed\Desktop\0.3.7\gamemodes\COD9.pwn(25477) : error 017: undefined symbol "playerid"
C:\Users\Emaz Ahmed\Desktop\0.3.7\gamemodes\COD9.pwn(25479) : error 017: undefined symbol "playerid"
C:\Users\Emaz Ahmed\Desktop\0.3.7\gamemodes\COD9.pwn(25481) : error 017: undefined symbol "playerid"
C:\Users\Emaz Ahmed\Desktop\0.3.7\gamemodes\COD9.pwn(25483) : error 017: undefined symbol "playerid"
C:\Users\Emaz Ahmed\Desktop\0.3.7\gamemodes\COD9.pwn(25485) : error 017: undefined symbol "playerid"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


10 Errors.
These are the errors. What to do now ?
Reply
#6

On the timer, add "i", playerid); The errors should be gone.

Then change the function your using to functionname(playerid);
Reply
#7

I fixed all but still there is warning. Please give me the codes in correct order Jamester. I'd appriciate it. Show me with the correct order please. Post the codes in correct order.
Reply
#8

First, what warnings do you have? Please input the lines with the line number in a comment.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)