need help with timer.. lol
#1

I have these publics....:
Код:
public RestartServerCasovac()
{
new Hour, Minute, Second;
gettime(Hour, Minute, Second);
if(Hour == 3 && Minute == 0 && Second < 4) return SetTimer("Desat",1000, 0) && SetTimer("Devet",2000, 0) && SetTimer("osem",3000, 0) && SetTimer("sedem",4000, 0) && SetTimer("sest",5000, 0) && SetTimer("pet",6000, 0) && SetTimer("styry",7000, 0) && SetTimer("tri",8000, 0) && SetTimer("dva",9000, 0) && SetTimer("jedna",10000, 0) && SetTimer("RestartServer",11000, 0);
return true;
}
public Desat(playerid)
{
format(str,200,"***Automatickэ reљtart servera za... 10");
SendClientMessageToAll(COLOR_ORANGERED,str);
return 1;
}
public Devet(playerid)
{
format(str,200,"***Automatickэ reљtart servera za... 9");
SendClientMessageToAll(COLOR_ORANGERED,str);
return 1;
}
public osem(playerid)
{
format(str,200,"***Automatickэ reљtart servera za... 8");
SendClientMessageToAll(COLOR_ORANGERED,str);
return 1;
}
public sedem(playerid)
{
format(str,200,"***Automatickэ reљtart servera za... 7");
SendClientMessageToAll(COLOR_ORANGERED,str);
return 1;
}
public sest(playerid)
{
format(str,200,"***Automatickэ reљtart servera za... 6");
SendClientMessageToAll(COLOR_ORANGERED,str);
return 1;
}
public pet(playerid)
{
format(str,200,"***Automatickэ reљtart servera za... 5");
SendClientMessageToAll(COLOR_ORANGERED,str);
return 1;
}
public styry(playerid)
{
format(str,200,"***Automatickэ reљtart servera za... 4");
SendClientMessageToAll(COLOR_ORANGERED,str);
return 1;
}
public tri(playerid)
{
format(str,200,"***Automatickэ reљtart servera za... 3");
SendClientMessageToAll(COLOR_ORANGERED,str);
return 1;
}
public dva(playerid)
{
format(str,200,"***Automatickэ reљtart servera za... 2");
SendClientMessageToAll(COLOR_ORANGERED,str);
return 1;
}
public jedna(playerid)
{
format(str,200,"***Automatickэ reљtart servera za... 1");
SendClientMessageToAll(COLOR_ORANGERED,str);
return 1;
}
public RestartServer()
{
SendRconCommand("gmx");
return true;
}
ongamemodeinit:
Код:
SetTimer("RestartServerCasovac",1000,1);
and forwards..
Код:
forward RestartServerCasovac();
forward RestartServer();
forward Desat(playerid);
forward Devet(playerid);
forward osem(playerid);
forward sedem(playerid);
forward sest(playerid);
forward pet(playerid);
forward styry(playerid);
forward tri(playerid);
forward dva(playerid);
forward jedna(playerid);
It works but countdown looks like this...
Quote:

Automatickэ reљtart servera za... 10
Automatickэ reљtart servera za... 10
Automatickэ reљtart servera za... 9
Automatickэ reљtart servera za... 8
Automatickэ reљtart servera za... 9
Automatickэ reљtart servera za... 10
Automatickэ reљtart servera za... 6
Automatickэ reљtart servera za... 8
Automatickэ reљtart servera za... 7
Automatickэ reљtart servera za... 3
Automatickэ reљtart servera za... 5
Automatickэ reљtart servera za... 4
Automatickэ reљtart servera za... 2
Automatickэ reљtart servera za... 1
Automatickэ reљtart servera za... 4
Boom... server restarts....

I dont have any lags, i m testing in on localhost.. how to fix it?

Reply
#2

I made a nice simple system for you ( took 2 mins of my life jk ).

Код:
new counter=10;

forward CountDown(playerid);

public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/countdown", cmdtext, true) == 0)
	{
		if(IsPlayerAdmin(playerid))
		{
			SetTimer("CountDown",1000,1);
			return 1;
		}
	}
	return 0;
}

public CountDown(playerid)
{
	new string[256];
	counter -= 1;
	format(string,sizeof(string),"Server Restarts in %d seconds!", counter);
	GameTextForAll(string,1000,3);
	if(counter == 0)
	{
		Kick(playerid);
	}
}
Just change the
Код:
Kick(playerid);
to your restart server function.
Reply
#3

Quote:
Originally Posted by -=[Serbish
=- ]
I made a nice simple system for you ( took 2 mins of my life jk ).

Код:
new counter=10;

forward CountDown(playerid);

public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/countdown", cmdtext, true) == 0)
	{
		if(IsPlayerAdmin(playerid))
		{
			SetTimer("CountDown",1000,1);
			return 1;
		}
	}
	return 0;
}

public CountDown(playerid)
{
	new string[256];
	counter -= 1;
	format(string,sizeof(string),"Server Restarts in %d seconds!", counter);
	GameTextForAll(string,1000,3);
	if(counter == 0)
	{
		Kick(playerid);
	}
}
Just change the
Код:
Kick(playerid);
to your restart server function.
Nice.. but i need it automaticly restarts... so at 3:00:00 (at night!) it starts counting from 10 to 1 and restarts...
Reply
#4

Код:
if(Hour == 3 && Minute == 0 && Second == 0) return SetTimer("CountDown",1000,1);
After this the counter will start to count and after 10 seconds what would be 3 hours, 0 minutes and 10 seconds it would restart.

EDIT: Just remove the command "/countdown" then.
Reply
#5

Quote:
Originally Posted by -=[Serbish
=- ]
Код:
if(Hour == 3 && Minute == 0 && Second == 0) return SetTimer("CountDown",1000,1);
After this the counter will start to count and after 10 seconds what would be 3 hours, 0 minutes and 10 seconds it would restart.

EDIT: Just remove the command "/countdown" then.
it wont work when i ONLY remove /countdown and isplayeradmin... can u pla write it correctly?
Edit.: Or will it?
Reply
#6

Код:
// top of the script.

new counter=10;

// at forwards.

forward CountDown(playerid);
forward RestartServerCasovac()

// at OnGameModeInit.

SetTimer("RestartServerCasovac",1000,1);

// at public functions.

public RestartServerCasovac()
{
	new Hour, Minute, Second;
	gettime(Hour, Minute, Second);
	if(Hour == 3 && Minute == 0 && Second == 0)
	{
		SetTimer("CountDown",1000,1);
	}
	return 1;
}

public CountDown(playerid)
{
	new string[256];
	counter -= 1;
	format(string,sizeof(string),"Server Restarts in %d seconds!", counter);
	GameTextForAll(string,1000,3);
	if(counter == 0)
	{
		// here your restart server function.
	}
}
Reply
#7

Thx and hvala serbish :P
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)