-/**
- * Takes care of pausing and unpausing the game.
- * Centerprints the information about an upcoming or active timeout to all active
- * players. Also plays reminder sounds.
- */
-void timeoutHandler_Think() {
- entity plr;
- if (timeoutStatus == 1) {
- if (remainingLeadTime > 0) {
- //centerprint the information to every player
- FOR_EACH_REALCLIENT(plr) {
- if(plr.classname == "player") {
- Send_CSQC_Centerprint_Generic(plr, CPID_TIMEOUT_COUNTDOWN, "Timeout begins in %d seconds!", 1, remainingLeadTime);
- }
- }
- remainingLeadTime -= 1;
- //think again in 1 second:
- self.nextthink = time + 1;
- }
- else {
- //now pause the game:
- timeoutStatus = 2;
- //reset all the flood variables
- FOR_EACH_CLIENT(plr) {
- plr.nickspamcount = plr.nickspamtime = plr.floodcontrol_chat = plr.floodcontrol_chatteam = plr.floodcontrol_chattell = plr.floodcontrol_voice = plr.floodcontrol_voiceteam = 0;
- }
- cvar_set("slowmo", ftos(TIMEOUT_SLOWMO_VALUE));
- //copy .v_angle to .lastV_angle for every player in order to fix their view during pause (see PlayerPreThink)
- FOR_EACH_REALPLAYER(plr) {
- plr.lastV_angle = plr.v_angle;
- }
- self.nextthink = time;
- }
- }
- else if (timeoutStatus == 2) {
- if (remainingTimeoutTime > 0) {
- FOR_EACH_REALCLIENT(plr) {
- if(plr.classname == "player") {
- Send_CSQC_Centerprint_Generic(plr, CPID_TIMEOUT_COUNTDOWN, "Timeout ends in %d seconds!", 1, remainingTimeoutTime);
- }
- }
- if(remainingTimeoutTime == autocvar_sv_timeout_resumetime) { //play a warning sound when only <sv_timeout_resumetime> seconds are left
- Announce("prepareforbattle");
- }
- remainingTimeoutTime -= 1;
- self.nextthink = time + TIMEOUT_SLOWMO_VALUE;
- }
- else {
- //unpause the game again
- remainingTimeoutTime = timeoutStatus = 0;
- cvar_set("slowmo", ftos(orig_slowmo));
- //and unlock the fixed view again once there is no timeout active anymore
- FOR_EACH_REALPLAYER(plr) {
- plr.fixangle = FALSE;
- }
- //get rid of the countdown message
- FOR_EACH_REALCLIENT(plr) {
- if(plr.classname == "player") {
- Send_CSQC_Centerprint_Generic_Expire(plr, CPID_TIMEOUT_COUNTDOWN);
- }
- }
- remove(self);
- return;
- }
-
- }
- else if (timeoutStatus == 0) { //if a player called the resumegame command (which set timeoutStatus to 0 already)
- FOR_EACH_REALCLIENT(plr) {
- if(plr.classname == "player") {
- Send_CSQC_Centerprint_Generic_Expire(plr, CPID_TIMEOUT_COUNTDOWN);
- }
- }
- remove(self);
- return;
- }
-}
-