|
I just made this function in 10 minutes for Wick, it does compile, but I don't know for 100% if it works.
Let's start...
We first make the Persistant variable called 'ready'
Go to g_local.h, and find this line:
under that, add this:
Now we make a command to /ready yourself
go to g_cmds and add this code above
| CODE | | void ClientCommand( int clientNum ) { |
| CODE | /* ================= Cmd_Ready_f ================= */ void Cmd_Ready_f(gentity_t *ent) { gclient_t *client = ent->client;
client->pers.ready = !client->pers.ready; //set the new value
if (client->pers.ready) trap_SendServerCommand(ent-g_entities, va("chat \"%s is ready!\n\"", client->pers.netname)); else trap_SendServerCommand(ent-g_entities, va("chat \"%s is ^1NOT^7 ready!\n\"", client->pers.netname)); }
|
Find these lines:
| CODE | else if (Q_stricmp (cmd, "setspawnpt") == 0) Cmd_SetSpawnPoint_f( ent );
|
And under that add this:
| CODE | else if (Q_stricmp (cmd, "ready") == 0) Cmd_Ready_f( ent );
|
Now we are going to g_main to the part where it stops the game from restarting after warmup countdown.
Goto g_main.c, and above
| CODE | | void CheckTournement( void ) { |
add this:
| CODE |
/* ============= IsReady
Checks if all players are ready ============= */
int IsReady(){
gclient_t *cl; int ready, i, allready = 0; for ( i = 0; i < level.numPlayingClients; i++ ) { cl = &level.clients[ level.sortedClients[i] ]; if (cl->pers.ready) ready++; }
if (ready == level.numPlayingClients) allready = 1; else trap_SendServerCommand( -1, va("cp \"Waiting on %i players to /ready\"",level.numPlayingClients - ready));
return allready; }
|
Now add this under the 'void CheckWolfMP() {' line:
And find this line in the same function:
| CODE | // if the warmup time has counted down, restart if ( level.time > level.warmupTime) {
|
now change this to:
| CODE | allready = IsReady();
// if the warmup time has counted down, restart if ( level.time > level.warmupTime && allready) {
|
UPDATE: We still have to (re)set the pers.ready variable at teamchange.
First go to g_cmds.c and find
| CODE | void SetTeam( gentity_t *ent, char *s )
|
In that function find this part:
| CODE | // get and distribute relevent paramters ClientUserinfoChanged( clientNum );
|
just before that add this:
| CODE | //We are sure that the player changes teams, so reset the ready variable, this also makes sure that new players(connected) won't be ready. client->pers.ready = 0;
|
Well that's basicly a 'ready system', you can later add a server command, callvote or admin command to force all the clients to be ready.
Good luck!
|