It works 100%, but i dont like it.
Do you know a better way/method to achieve this?
Whiout the need of NewRound event, or set_tasks...
Thank you. :bee:
fysiks
01-02-2016 00:45
Re: Exec Command at isactly 12:00h
If it works well then I don't see any necessary changes to the core functionality. You should optimize that massive if else if structure. Namely, str_to_num() should only be called once. Also, you should make it such that you only need two prints where you calculate either minutes or seconds left instead of having them hardcoded.
Syturi0
01-02-2016 00:55
Re: Exec Command at isactly 12:00h
Quote:
Originally Posted by fysiks
(Post 2378964)
you should make it such that you only need two prints where you calculate either minutes or seconds left instead of having them hardcoded.
I dont know how.
fysiks
01-02-2016 01:44
Re: Exec Command at isactly 12:00h
Quote:
Originally Posted by Syturi0
(Post 2378967)
I dont know how.
You need to calculate how many minutes/seconds are left then you pass that as an argument of the print function (changing the number from static to dynamic in the format).
Phant
01-02-2016 02:26
Re: Exec Command at isactly 12:00h
This restart useless. It's equal simple map change.
fysiks
01-02-2016 02:50
Re: Exec Command at isactly 12:00h
Quote:
Originally Posted by Phant
(Post 2378982)
This restart useless. It's equal simple map change.
You are correct but might be useful on a 24/7 single-map server. If it's not a 24/7 single-map server then you could replace "restart" with "quit" assuming your host properly handles the server quitting.
Quote:
Originally Posted by Syturi0
(Post 2378967)
I dont know how.
I would do something like this:
PHP Code:
public CmdRestart() { // Get the current time static iHour, iMinute, iSecond, iSecondsLeft time(iHour, iMinute, iSecond)
if( iHour == 11 || iHour == 23 ) // Just in case this function gets executed some other time { // Calculate the seconds until the next hour iSecondsLeft = 3600 - (iMinute * 60 + iSecond)
if( iSecondsLeft % 60 == 0 ) // Every minute on the minute except when we restart { client_print(0, print_chat, "!gO servidor ira reiniciar automaticamente em !n%d!g minutos.", iSecondsLeft / 60) } else if( iSecondsLeft == 30 || iSecondsLeft == 15 || iSecondsLeft <= 10 ) // Select times { client_print(0, print_chat, "!gO servidor ira reiniciar automaticamente em !n%d!g segundos.", iSecondsLeft) }
if( iSecondsLeft == 0 ) // Restart on the hour { server_cmd("restart") } } }
Syturi0
01-02-2016 05:25
Re: Exec Command at isactly 12:00h
Quote:
Originally Posted by Phant
(Post 2378982)
This restart useless. It's equal simple map change.
The map doesnt change, its always the same.
Syturi0
01-02-2016 05:26
Re: Exec Command at isactly 12:00h
Quote:
Originally Posted by fysiks
(Post 2378986)
I would do something like this:
PHP Code:
public CmdRestart()
{
// Get the current time
static iHour, iMinute, iSecond, iSecondsLeft
time(iHour, iMinute, iSecond)
if( iHour == 11 || iHour == 23 ) // Just in case this function gets executed some other time
{
// Calculate the seconds until the next hour
iSecondsLeft = 3600 - (iMinute * 60 + iSecond)
if( iSecondsLeft % 60 == 0 && iSecondsLeft > 0) // Every minute on the minute except when we restart
{
client_print(0, print_chat, "!gO servidor ira reiniciar automaticamente em !n%d!g minutos.", iSecondsLeft / 60)
}
else if( iSecondsLeft == 30 || iSecondsLeft == 15 || iSecondsLeft <= 10 ) // Select times
{
client_print(0, print_chat, "!gO servidor ira reiniciar automaticamente em !n%d!g segundos.", iSecondsLeft)
}
else if( iSecondsLeft == 0 ) // Restart on the hour
{
server_cmd("restart")
}
}
}
Thank you! :fox:
jimaway
01-02-2016 07:31
Re: Exec Command at isactly 12:00h
Quote:
Originally Posted by Syturi0
(Post 2379022)
The map doesnt change, its always the same.
in this case you can get rid of the new round event and task by just setting mp_timelimit to right amount of time in plugin_init
Syturi0
01-02-2016 09:03
Re: Exec Command at isactly 12:00h
fysiks
Everything works well, except this:
Quote:
else if( iSecondsLeft == 0 ) // Restart on the hour
{
server_cmd("restart")
}