Page 1 of 1

How do I detect player(-client) disconnects correctly?

Posted: Tue Jul 01, 2014 11:53 pm
by Hyrelius
Hello,

since I am writing some scripts, that depend on the players being online, I'd like to know if there is a way to detect disconnects on the server side. I'd prefer a reliable way, but any way is good.

So far I've been trying to find workarounds - e.g. if a player makes an attempt to login with another char etc. But what I'd really like to do, is be able to reliably determine if a given player is not offline.
The problem is, that so far I determined different behaviors depending on how the user disconnects. If it's a BufferOverflow, caused by e.g. a malformed L2-HTML-file, the client crashes, but it seems it - sometimes - sends a notification to the server about being closed. It seems not to do this if e.g. the connection to the server is closed on the client-side by removing the LAN-cable from the computer.

Does someone know how to - reliably if possible - check, whether a given player is online or not?

Thanks in advance!

Re: How do I detect player(-client) disconnects correctly?

Posted: Wed Jul 02, 2014 12:31 am
by Zoey76
What about loggin/disconnect listeners??

Re: How do I detect player(-client) disconnects correctly?

Posted: Wed Jul 02, 2014 2:43 pm
by UnAfraid
player logout listener will catch L2PcInstance being deleted so it means it will catch every possible logging out.

Re: How do I detect player(-client) disconnects correctly?

Posted: Wed Jul 02, 2014 6:19 pm
by Hyrelius
Alright - so basically onPlayerLogout is what I'd be using, right?

It seems, that onPlayerLogout correctly catches any kind of player logout. However: when a player disconnects it does not necessarily mean, that the player logs out (from what I've seen). Sometimes you see a toon ingame, yet the player client already crashed and the toon did not log out.

So while your information, @UnAfraid, is most likely correct - it is not exactly what I am looking for as I want to be able to catch "onPlayerDisconnect"-events. Currently I implemented behavior on player log-out + log-in in order to determine what to do in such a case. But it is not reliable enough and I also cannot differentiate between a forced player client logout (by killing the L2.exe-process) from a typical client crash. I guess I won't be able to do that, because the client does not send any information to the client in this regard, right?

Anyway - thanks for the suggestions so far :), but is there a way to better determine player client disconnects?