Theres an event for disconnection , I'm not shure it was event_disconnect exactly smile look the manual. With the event , you dont need to know wich client disconnected.
About the other problems , I'd suggest you start again. I've written my MMO scripts over 15 times smile and the last one looks clean and works good and I know how to make it again in less than a day...


Extensive Multiplayer tutorial:
http://mesetts.com/index.php?page=201