ID:176295
 
After someone logs out the game checks all the mobs in the world and if a mobs Owner is the loged out guy its gets deleted...How would i make something like that? THanks in advance!

-Crio
mob/Slave //a slave

mob/Player //the player
var/list/Slaves = list() //define a Slaves list

mob/verb/CreateSlave()
var/mob/Slave/S = new /mob/Slave //create a new slave
usr.SLaves.Add(S) //add him to the slaves list

mob/Logout()
for(var/mob/M in world) //for every person in the world
if(Slaves.Find(M)) //if they are in the Slaves list
del(M) //delete them
del(src) //finally delete the player

Something like that. An alternate way would be
mob/Slave
var/owner
mob/verb/CreateSlave()
var/mob/Slave/S = new /mob/Slave //create a new slave
S.owner = usr.key //set players key as the slaves owner
mob/Logout()
for(var/mob/M in world) //for everyone in world
if(M.owner == src.key) //if the owner = players key
del(M) //delete them
del(src) //delete the player


In response to Weedman
Wouldn't it be better just to loop through everything in the Slaves list instead?
In response to Weedman
the second one i used :D thanks!