ID:160534
 
I have been changing the client.mob var to do my mob switching. I recently added a Logout code and discovered that logout is run when reassigning client.mob. Is there a way I can switch mobs without logout running?
No, Login and Logout are there so we know when a mob has been attached to a client. That is its function.

Instead of using mob/Logout() for handling real client disconnection, you can use client/Del().

client
New()
world << "Client connecting to the world."
..()

Del()
world << "Client disconnecting from the world."
..()

mob
Login()
world << "Mob attaching to client."
..()

Logout()
world << "Mob detaching from client."
..()
In response to Keeth
It's also possible to differentiate between the cases within Login() and Logout() with some workarounds, though using client/New() and client/Del() is indeed better and more foolproof.
/*a mob's key var always has the key of the player connected
to it, so when a mob switch occurs only the new mob will have
a key (the player's) and the old one will have it cleared*/

mob/Logout()
if(src.key)
world << "[src] has disconnected from the game."
else world << "[src] has logged out of his mob"
return ..()

/*this one is self-explanatory, though less robust because it
depends on your code to give mobs proper locations before
manually log players into them*/


mob/Login()
if(src.loc)
world << "[src] has logged into an existing mob"
else world "[src] has logged into the game"
return ..()