ULX

Author Topic: PlayerDisconnected hook, when is it called?  (Read 3985 times)

0 Members and 1 Guest are viewing this topic.

Offline 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?
I'm iViscosity. I like gaming and programming. Need some help? Shoot me PM.

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
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.

Offline 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?
I'm iViscosity. I like gaming and programming. Need some help? Shoot me PM.

Offline 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.
I'm iViscosity. I like gaming and programming. Need some help? Shoot me PM.

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
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.

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President

An Error Has Occurred!

array_keys(): Argument #1 ($array) must be of type array, null given