/* Round restart by ceL (aim) ceL142 (email) cel@hackr.org */
/* A replacement for reloading the same map on 1 map only servers
This is a modified version of plugin_timerem2.
Last update on Saturday, Feburary 02, 2002 */
 
#include <core>
#include <console>
#include <string>
#include <admin>
#include <adminlib>
 
/* Default time remaining to 60 minutes */
new time1=60;
 
/* You should not have to edit anything below this line */
new STRING_VERSION[MAX_DATA_LENGTH] = "1.0.0.0";
 
public execute_all(a[]) {
    new username[200];
    new i=0;
    new x = 0;
 
    x = maxplayercount();
    for(i=1; i<=x; i=i+1) {
        strinit(username);
        if(playerinfo(i, username, 200)==1) {
            execclient(username, a);
        }
    }
}
 
public warn1() {
    execute_all("speak ^"fvox/sixty seconds remaining^"");
    centersay("60 seconds remaining!",10,255,0,0);
}
 
public warn5() {
    execute_all("speak ^"fvox/five minutes remaining^"");
    centersay("5 minutes remaining.",10,0,255,0);
}
 
public warn10() {
    execute_all("speak ^"fvox/ten minutes remaining^"");
    centersay("10 minutes remaining.",10,0,255,0);
}
 
public warn20() {
    execute_all("speak ^"fvox/twenty minutes remaining^"");
    centersay("20 minutes remaining.",10,0,255,0);
}
 
public restart() {
    exec("sv_restartround 1");
    plugin_init();
}
 
public plugin_init() {
    plugin_registerinfo("Time Remaining Announcer","Announces time remaining automatically",STRING_VERSION);
 
    /* start timers for "time remaining" warnings */
    set_timer("warn20", time1 * 60 - 1200, 0);
    set_timer("warn10", time1 * 60 - 600, 0);
    set_timer("warn5", time1 * 60 - 300, 0);
    set_timer("warn1", time1 * 60 - 60, 0);
    set_timer("restart", time1 * 60 - 0, 0);
 
    return PLUGIN_CONTINUE;
}