Raised This Month: $51 Target: $400
 12% 

What can be done at OnClientDisconnect


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Puppetmaster
Senior Member
Join Date: Jun 2015
Location: Probably at a computer.
Old 11-27-2015 , 00:58   What can be done at OnClientDisconnect
Reply With Quote #1

From what I understand the OnClientDisconnect event has some limitations. I have read that one of these is that it is called whenever the map changes. What other things trigger this event? Is it possible to use this event to print the players session statistics at their disconnect time? (I want to add this to my ranks plugin in the future). If not how should I properly detect a client disconnect and print to their console right before they leave?

Event:
OnClientDisconnect(client);
__________________

GZS Servers
Puppetmaster is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 11-27-2015 , 01:12   Re: What can be done at OnClientDisconnect
Reply With Quote #2

Hook the player_disconnect event if you want to detect a "real" disconnect and exclude map changes.

You can't print information to a client who has already disconnected from the server.
__________________

Last edited by ddhoward; 11-27-2015 at 01:12.
ddhoward is offline
grankee
Member
Join Date: Jun 2008
Old 11-27-2015 , 12:26   Re: What can be done at OnClientDisconnect
Reply With Quote #3

Is any way to hook disconnect before the actual disconnection?
grankee is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 11-27-2015 , 14:54   Re: What can be done at OnClientDisconnect
Reply With Quote #4

Unless you can predict the future, no.
__________________
ddhoward is offline
akcaliberg
Senior Member
Join Date: Nov 2011
Location: Istanbul
Old 11-27-2015 , 20:37   Re: What can be done at OnClientDisconnect
Reply With Quote #5

lol

Sorry couldn't hold myself.
akcaliberg is offline
Puppetmaster
Senior Member
Join Date: Jun 2015
Location: Probably at a computer.
Old 11-29-2015 , 21:16   Re: What can be done at OnClientDisconnect
Reply With Quote #6

So this is what I have inferred:

There are two functions in the API: OnClientDisconnect and OnClientDisconnect_Post.
OnClientDisconnect_Post says that it is called when the client is disconnected.
This suggests that OnClientDisconnect is called when a client requests a graceful disconnection.
According to the comments when using this I should check to see if the client is in the game so I am guessing I can in fact use it to send at least *something* prior to their complete disconnection.
In terms of deciding if it is a real disconnect or a map change cant I just check the OnMapEnd/round_end events?
__________________

GZS Servers
Puppetmaster is offline
Phil25
AlliedModders Donor
Join Date: Feb 2015
Old 11-29-2015 , 22:15   Re: What can be done at OnClientDisconnect
Reply With Quote #7

Quote:
Originally Posted by Puppetmaster View Post
According to the comments when using this I should check to see if the client is in the game so I am guessing I can in fact use it to send at least *something* prior to their complete disconnection.
What do you mean by that something thing, and what by complete disconnection? AFAIC, you can do pretty much anything with the client in OnClientDisconnect. Reading their SteamID, having them suicide, grabbing their team, etc.


Quote:
Originally Posted by Puppetmaster View Post
In terms of deciding if it is a real disconnect or a map change cant I just check the OnMapEnd/round_end events?
I guess something could be done with that. However, why wouldn't you simply hook the player_disconnect event, as suggested by ddhoward?
Phil25 is offline
Puppetmaster
Senior Member
Join Date: Jun 2015
Location: Probably at a computer.
Old 11-29-2015 , 22:27   Re: What can be done at OnClientDisconnect
Reply With Quote #8

Quote:
Originally Posted by Phil25 View Post
What do you mean by that something thing, and what by complete disconnection? AFAIC, you can do pretty much anything with the client in OnClientDisconnect. Reading their SteamID, having them suicide, grabbing their team, etc.




I guess something could be done with that. However, why wouldn't you simply hook the player_disconnect event, as suggested by ddhoward?
From the events page the note seems to imply that this event is called a bit too late for me to send data back, it uses the words 'was' and 'disconnected' which in seem to suggest it is past tense. As such I would be unable to print to their console.
https://wiki.alliedmods.net/Generic_...yer_disconnect
__________________

GZS Servers
Puppetmaster is offline
Phil25
AlliedModders Donor
Join Date: Feb 2015
Old 11-30-2015 , 04:56   Re: What can be done at OnClientDisconnect
Reply With Quote #9

I'm pretty sure you are able to do this in that event. If you want to print something to the client's console while disconnecting, why won't you just test it?
Phil25 is offline
Puppetmaster
Senior Member
Join Date: Jun 2015
Location: Probably at a computer.
Old 02-02-2017 , 21:19   Re: What can be done at OnClientDisconnect
Reply With Quote #10

Quote:
Originally Posted by Phil25 View Post
I'm pretty sure you are able to do this in that event. If you want to print something to the client's console while disconnecting, why won't you just test it?
A whole year rolls by and I still have not managed to find the time to test it
__________________

GZS Servers
Puppetmaster is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:56.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode