Check if player loses connection

Discussion in 'Plugin Development' started by StuntHacks, Jun 27, 2017.

Thread Status:
Not open for further replies.
  1. I wrote a simple PvP gamemode in which the player get's banned for a set period of time if they leave the game before a certain time was up. The problem is, they still get banned even if they lose their connection. How can I check whether a user has left the game or lost connection?
     
  2. Offline

    timtower Administrator Administrator Moderator

    @StuntHacks You can't as far as I know. Maybe the clients sends a disconnect when leaving the server but hitting the close button won't send anything.
     
  3. Offline

    InstanceofDeath

    Well you could try to inject into the Keep Alive Packet and look if it doesn't get send back in the next 30 seconds -> Autodisconnect by the server
     
  4. Offline

    Horsey

    Well then wouldn't your plugin have a loop-hole where people can just unplug their router to leave in the middle of the game?
     
  5. @StuntHacks
    PlayerQuitEvent? I don't know why everyone have so complicated alternatives..
     
  6. @Horsey Yes that's true but I get a lot of complaints about people getting banned from the rounds just because their connection dropped and I can't just say "Get a good connection then".


    @AlvinB But PlayerQuitEvent get's fired if the user loses connection as well. That's what I'm currently using.
     
  7. Offline

    Zombie_Striker

    @StuntHacks
    http://wiki.vg/Protocol#Disconnect_.28login.29
    This packet is sent by the player when they choose to disconnect. Use protocol lib to listen for this packet. If this is sent, then you can ban them. If not, they disconnected because of timeouts. But then again, as @Horsey , be ready if a lot of people start holding onto their Ethernet cable while playing on your server.
     
  8. Offline

    Horsey

Thread Status:
Not open for further replies.

Share This Page