The following code as you will be able to see when posted below will on client/del save the player as a check and then create a new datum called logoutter this is just a simple datum that watches over the player mob until the time for deletion comes. anyway onto the code.
Code: First up we have the datum and client/del
client/Del()
if(!istype(mob,/mob/human/player)) return //just making sure it only does players.
mob.Save() //saving the mob.
new /logoutter(src.mob) //creating the datum using the mob as a argument.
mob.key = null //i wipe the key here so that its not connected to any client. this is so that on relog it doesn't put them back into the mob.
//the reason it is done like this is because i have 3 slots and they may not want to be in the same mob. despite it being 10secs before deletion.
..()
logoutter
var/mob/human/reffer //holding the mob for later use.
New(mob/p)
src.tag = "logoutter |[p.ckey]|[p.name]|" //safety check later it needs to match both the name and ckey.
reffer = p //set the mob reference here for later use.
world << "0.[reffer] = [reffer.x] - [reffer.y] - [reffer.z]" // IMPORTANT DBG TEXT -- when ran this displays the mobs co-ords properly as there meant to be. lets say its 7-7-7 for this
src.DelayedSaveDel(p) //launch proc
Del(client/c) //del with a client argument.
if(c) //make sure it has a client.
world << "1.[reffer] = [reffer.x] - [reffer.y] - [reffer.z]" // IMPORTANT DBG TEXT -- For some reason reffer's co-ords become 0-0-0
reffer.key = c.key //make the inactive zombie mob have the players key. inturn swapping the client over.
world << "2.[reffer] = [reffer.x] - [reffer.y] - [reffer.z]" //it becomes 2-2-2 here.
..()
proc/DelayedSaveDel(mob/P)
spawn(100)
P.Save()
world << "[P] has Successfully logged out."
del P
del(src)
Code: next up is the load and other stuff.
client/proc/Load(playerslot, playername) //first is slot from 1-3, second is the name so "Midgetbuster"
var/savefile/F = new(savedir)
var/logoutter/loutter = locate("logoutter |[src.ckey]|[playername]|") //match "logoutter |midgetbuster|Midgetbuster|" to a logutter datum
if(loutter)
loutter.Del(src) // run the del
src << "System: You have reconnected to your mob."
else
F["/Slot[playerslot]"] >> src.mob //otherwise we just pull it from the savefile.
world << "[src.mob]/[ckey] has Logged into the world"
Now im unsure if its clear in there in any case what is happening is when the mob regains a client it is meant to stay in the same location. instead it gets hurled back to the first available tile and im unsure why this is the case.
I have looked over most of my code and i cant seem to figure out why this is occuring.
If anyone has insight onto this or ways to improve this it would be greatly appreciated.
~Midget
Also, where do you call client/Load?