Execute command before client quits

This is the development community to discuss tribes mod coding or to ask questions.

Moderator: Moderators

Post Reply
tompb
Spambot in training
Spambot in training
Posts: 6
Joined: Mon Feb 25, 2013 10:41 am

Execute command before client quits

Post by tompb » Wed Mar 06, 2013 7:58 pm

I would like to push statistics to a database before the client quits the game.
To achieve this I thought I'd use Client::leaveGame(%clientId).

However, I can't access the client anymore since it's already gone when that function is called.

Is there any way I can execute a command accessing the specific client before it leaves the server?

Thanks in advance :)

ProtoManX
Commander
Commander
Posts: 790
Joined: Sun Aug 11, 2002 11:00 pm
Contact:

Re: Execute command before client quits

Post by ProtoManX » Thu Mar 07, 2013 7:42 am

Depending on what you want to track you could just build a global array using the player's name as the key identifier and track everything real time.

bawb
Commander
Commander
Posts: 1203
Joined: Thu Apr 09, 2009 10:55 am

Re: Execute command before client quits

Post by bawb » Thu Mar 07, 2013 10:57 am

look in server.cs for the onDisconnect function and use that

User avatar
C--
Sorry....
Posts: 3299
Joined: Thu Apr 06, 2006 2:32 pm

Re: Execute command before client quits

Post by C-- » Thu Mar 07, 2013 3:54 pm

bawb wrote:look in server.cs for the onDisconnect function and use that


That is clientside man...
He wants serverside.

bugs_
1st Lieutenant
1st Lieutenant
Posts: 303
Joined: Wed Sep 20, 2006 3:05 pm

Re: Execute command before client quits

Post by bugs_ » Thu Mar 07, 2013 5:42 pm

the server calls Server::onClientDisconnect(%clientId)

tompb
Spambot in training
Spambot in training
Posts: 6
Joined: Mon Feb 25, 2013 10:41 am

Re: Execute command before client quits

Post by tompb » Fri Mar 08, 2013 4:08 am

Server::onClientDisconnect(%clientId) did the job for me, thanks a lot. :)

User avatar
Nim Ayanami
your mom is primeth
Posts: 636
Joined: Wed May 25, 2005 1:43 pm

Re: Execute command before client quits

Post by Nim Ayanami » Sun Mar 10, 2013 8:13 am

whatcha makin tom?

tompb
Spambot in training
Spambot in training
Posts: 6
Joined: Mon Feb 25, 2013 10:41 am

Re: Execute command before client quits

Post by tompb » Sun Mar 10, 2013 12:23 pm

Statistics script for the Paintball mod, it's pretty simple. A user is identified by a unique identification phrase in the "Other Infos" field (didn't want it to be name or IP-bound) and statistics are pushed to a MySQL database on mission change or when the user disconnect. Works quite well so far but I'm still improving a few performance things. :)

http://tribespb.net/stats.php

User avatar
Ghost
2nd Lieutenant
2nd Lieutenant
Posts: 94
Joined: Thu Mar 05, 2009 12:53 pm
Location: Mars

Re: Execute command before client quits

Post by Ghost » Sun Mar 10, 2013 2:32 pm

loving sweet tom :D

User avatar
Nim Ayanami
your mom is primeth
Posts: 636
Joined: Wed May 25, 2005 1:43 pm

Re: Execute command before client quits

Post by Nim Ayanami » Thu Mar 21, 2013 6:50 am

thats awsome tom!

Post Reply