From 213fe7d84ba098fd467e65788486259c6f821ebd Mon Sep 17 00:00:00 2001 From: Romain Beaumont Date: Wed, 26 Aug 2015 23:50:03 +0200 Subject: [PATCH] implement leaving, fix #6 --- lib/playerPlugins/login.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/playerPlugins/login.js b/lib/playerPlugins/login.js index 8e45ff5..d3adc40 100644 --- a/lib/playerPlugins/login.js +++ b/lib/playerPlugins/login.js @@ -181,7 +181,18 @@ function inject(serv,player) player._client.on('end', function () { serv.broadcast(player.username + ' quit the game.', "yellow"); + player._writeOthers('player_info',{ + action: 4, + data: [{ + UUID: transformUuid(player._client.uuid) + }] + }); + player._writeOthers('entity_destroy',{'entityIds':[player.entity.id]}); player.emit('disconnect'); + var index=serv.players.indexOf(player); + if(index>-1) + serv.players.slice(index,1); + delete serv.uuidToPlayer[player._client.uuid]; });