This skin was created by Kazuki of the IF Skin Zone



 

 A ready system, intermediate modders only
dutchmeat
Posted: Sep 4 2007, 02:56 PM


Administrator And Modmaker
Group Icon

Group: Admin
Posts: 1,459
Member No.: 1
Joined: 10-August 04



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:

CODE

qboolean teamInfo;


under that, add this:

CODE

int ready;



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:
CODE
int allready;


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!
Top
dutchmeat
Posted: Sep 6 2007, 12:06 PM


Administrator And Modmaker
Group Icon

Group: Admin
Posts: 1,459
Member No.: 1
Joined: 10-August 04



This is the updated cmd_ready_f command:

CODE

/*
=================
Cmd_Ready_f
=================
*/
void Cmd_Ready_f(gentity_t *ent) {
gclient_t *client = ent->client;

if (!level.warmupTime){
trap_SendServerCommand(ent-g_entities, va("print \"The game has already begun!\n\""));
return;
}

if (ent->client->sess.sessionTeam == TEAM_SPECTATOR){
trap_SendServerCommand(ent-g_entities, va("print \"Only playing clients can be ready!\n\""));
return;
}

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));
}
Top
evil
Posted: Oct 1 2007, 06:46 PM


Newbie


Group: Members
Posts: 2
Member No.: 67
Joined: 1-October 07



mesaje error or not?

Waiting on -176453888 players to /ready\

add /ready not off much cp

Waiting on -176453888 players to /ready\
Waiting on -176453888 players to /ready\
Waiting on -176453888 players to /ready\
Top
dutchmeat
Posted: Oct 10 2007, 02:30 PM


Administrator And Modmaker
Group Icon

Group: Admin
Posts: 1,459
Member No.: 1
Joined: 10-August 04



change

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;
}


to:


CODE

/*
=============
IsReady

Checks if all players are ready
=============
*/

int IsReady(){

gclient_t *cl;
int ready, i, allready = 0;
int readynum = 0;

for ( i = 0;  i < level.numPlayingClients; i++ ) {
cl = &level.clients[ level.sortedClients[i] ];

if (cl->pers.ready)
 ready++;
}

readynum = level.numPlayingClients - ready;

if (ready == level.numPlayingClients)
allready = 1;
else
trap_SendServerCommand( -1, va("cp \"Waiting on %i players to /ready\"",readynum));

return allready;
}
Top


Topic Options



Hosted for free by InvisionFree (Terms of Use: Updated 7/7/05) | Powered by Invision Power Board v1.3 Final © 2003 IPS, Inc.
Page creation time: 0.8267 seconds | Archive