Determing if server is in intermission

Is it possible to determine if the server is currently in intermission (via server code only)?

I was hoping I could call something along the lines of:

if ( sv.state == SS_GAME )

Intermission is only a concept in the game/ mod code. So I’m afraid not.

When you connect to a server, how does the client know how much time is left on the current map?

Is it possible to extrapolate from the server time limit and time elapsed in the current round to find out if the round timer is down to 0?

I can retrieve the timelimit via:

int timeleftsecs;
static cvar_t *timelimit;
timelimit = Cvar_Get (“timelimit”, “0”, CVAR_SERVERINFO);
timeleftsec = timelimit->integer * 60;

Now when a client connects and the server transmits to the client how much time is left on the current map, I could just subtract that number from timeleftsec. And if that result is 0, then I could assume the map has ended and it’s in an intermission state, right?

I just need to figure out now where the round timer’s data is being transmitted from and how to access it.

AFAIK it only counts up not down in base.

And it just uses the server time.

Ensiform, the server time is the accumulated milliseconds since the server process was launched.

There has to be some way to calculate how much time is left on the current map. When a new client connects to a server, the client automatically knows precisely how much time is left.

If the client sets /cg_drawtimer 1 a countdown timer appears with the exact amount of minutes/seconds left before intermission. This value is obviously being transmitted to the client.

I found this configstring value:

define CS_INTERMISSION 22 // when 1, fraglimit/timelimit has been hit and intermission will start in a second or two

void SV_GetConfigstring( int index, char *buffer, int bufferSize ) {

However, I’m not sure how to check the value of it. The following code always returns the else statement:

if(CS_INTERMISSION == 1){
SV_SendServerCommand(NULL, “print “Server is in intermission!\n”” );
} else {
SV_SendServerCommand(NULL, va( “print “Server is NOT in intermission! [%d]\n””, CS_INTERMISSION) );
}

How to read configstrings in server.

char value[10]; // 10 is the max length of data to read, some config strings would need longer (like sound filenames)

SV_GetConfigstring( CS_INTERMISSION, value, sizeof ( value ) );

// value now holds up to 9 characters (index 0 to 8, with 9 being '\0' [a C string terminator]). You can access it or print it.
if ( value[0] == '1' ) {
    Com_Printf( "At intermission!\n" );
}
Com_Printf( "Intermission = %s!\n", value );

Good job finding CS_INTERMISSION. Your attempts to use it seem to signal you don’t really know how C works. You might want to read a book or online articles on intro to C programming.

1 Like

Zturtleman, once again you’ve helped me out tremendously with your descriptive answers. Your code example works perfectly! I’ll take your advice, too, and pick up a C programming book. Thank you.