Ulysses
Welcome,
Guest
. Please
login
or
register
.
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Home
Help
Search
Login
Register
Ulysses
»
General
»
Developers Corner
»
PlayerDisconnected hook, when is it called?
« previous
next »
Print
Pages: [
1
]
Go Down
Author
Topic: PlayerDisconnected hook, when is it called? (Read 4091 times)
0 Members and 1 Guest are viewing this topic.
iViscosity
Respected Community Member
Hero Member
Posts: 803
Karma: 58
PlayerDisconnected hook, when is it called?
«
on:
May 08, 2017, 06:53:09 AM »
So clearly the PlayerDisconnected hook is called when someone disconnects from the server, but I was wondering if it's only called when they manually leave. In the recent release I made it's function relies on the PlayerDisconnected hook, but I don't want it to cause issues when people leave because they were karma kicked or kicked by an admin for some other reason. Is there a way to make it so that it is only caused if someone manually leaves the server and not if they are kicked by either an admin or karma?
Logged
I'm iViscosity. I like gaming and programming. Need some help?
Shoot me PM
.
MrPresident
Ulysses Team Member
Hero Member
Posts: 2728
Karma: 430
Re: PlayerDisconnected hook, when is it called?
«
Reply #1 on:
May 08, 2017, 07:42:20 AM »
It gets called when a player disconnects, for any reason.
kicked, banned, timed out, quits of their own accord. Any reason.
Essentially, as their player object is about to be deleted, it's called.
Logged
iViscosity
Respected Community Member
Hero Member
Posts: 803
Karma: 58
Re: PlayerDisconnected hook, when is it called?
«
Reply #2 on:
May 08, 2017, 07:43:24 AM »
That is what I thought, thanks. Is there a hook or something that calls only when a player manually disconnects?
Logged
I'm iViscosity. I like gaming and programming. Need some help?
Shoot me PM
.
iViscosity
Respected Community Member
Hero Member
Posts: 803
Karma: 58
Re: PlayerDisconnected hook, when is it called?
«
Reply #3 on:
May 08, 2017, 09:39:47 AM »
I have a related question, is there a way to capture when a person is about to leave, before they actually do? Like when they actually hit disconnect (or disconnect in the console), before they actually leave.
Logged
I'm iViscosity. I like gaming and programming. Need some help?
Shoot me PM
.
MrPresident
Ulysses Team Member
Hero Member
Posts: 2728
Karma: 430
Re: PlayerDisconnected hook, when is it called?
«
Reply #4 on:
May 08, 2017, 12:44:48 PM »
The PlayerDisconnect hook is called right before they actually disconnect I believe. Assuming they are not timing out that is.
It is called while the player object is still valid.
If you hook directly into the game event for disconnect, you might be able to tell the difference in the types of disconnects.
Logged
MrPresident
Ulysses Team Member
Hero Member
Posts: 2728
Karma: 430
Re: PlayerDisconnected hook, when is it called?
«
Reply #5 on:
May 08, 2017, 12:45:08 PM »
http://wiki.garrysmod.com/page/gameevent/Listen
Logged
An Error Has Occurred!
array_keys(): Argument #1 ($array) must be of type array, null given
Back