ID:141145
 
Code:
                for(var/mob/X in world)
if(X.key==usr.ShareWith)
if(usr.ShareWith in world)
spawn(10)
goto CCheck
return
else
usr.icon=Oldicon
return


Problem description:

I want this to keep checking for the key.if its offline your icon goes back to normal..but for some reason it takes me straight to my oldicon
Do not use goto. And you're doing this really horribly. Unless you're screwing around with keys all willy-nilly, you should only need to check for ONE mob. You don't even need to do that: in othermob.Del(), tell the first mob that it's gone and whatever the hell you're trying to do, so I'm going to assume you're creating a creepy stalking system:

mob
var/tmp/list/stalkers
verb/stalk(var/mob/M)
if(!M.stalkers)
M.stalkers = list(src)
else
if(src in M.stalkers)
M.stalkers -= src
//list husbandry:
if(M.stalkers.len == 0)
M.stalkers = null
else
M.stalkers += src
Del()
for(var/mob/M in stalkers)
M << "[src] has left."
..()
In response to Garthor
Garthor wrote:
Do not use goto. And you're doing this really horribly. Unless you're screwing around with keys all willy-nilly, you should only need to check for ONE mob. You don't even need to do that: in othermob.Del(), tell the first mob that it's gone and whatever the hell you're trying to do, so I'm going to assume you're creating a creepy stalking system:

mob
> var/tmp/list/stalkers
> verb/stalk(var/mob/M)
> if(!M.stalkers)
> M.stalkers = list(src)
> else
> if(src in M.stalkers)
> M.stalkers -= src
> //list husbandry:
> if(M.stalkers.len == 0)
> M.stalkers = null
> else
> M.stalkers += src
> Del()
> for(var/mob/M in stalkers)
> M << "[src] has left."
> ..()


Its Suppose To be for my fusion code.When a player decided to leave the game,and in my fusion proc it suppose to check to see if either of the fusers have left the world.If one of them has left the one remaining will go back to his normal state.

I tried editing your codes into it but didnt work
In response to Galacticus
Galacticus wrote:
Garthor wrote:
Do not use goto. And you're doing this really horribly. Unless you're screwing around with keys all willy-nilly, you should only need to check for ONE mob. You don't even need to do that: in othermob.Del(), tell the first mob that it's gone and whatever the hell you're trying to do, so I'm going to assume you're creating a creepy stalking system:

mob
> > var/tmp/list/stalkers
> > verb/stalk(var/mob/M)
> > if(!M.stalkers)
> > M.stalkers = list(src)
> > else
> > if(src in M.stalkers)
> > M.stalkers -= src
> > //list husbandry:
> > if(M.stalkers.len == 0)
> > M.stalkers = null
> > else
> > M.stalkers += src
> > Del()
> > for(var/mob/M in stalkers)
> > M << "[src] has left."
> > ..()

Its Suppose To be for my fusion code.When a player decided to leave the game,and in my fusion proc it suppose to check to see if either of the fusers have left the world.If one of them has left the one remaining will go back to his normal state.

I tried editing your codes into it but didnt work

Garthor is right, there's a much better way to accomplish what you want to do.

Instead of constantly looping a check to loop through the world, just modify mob.Del() I'm assuming sharewith or whatever the variable was is supposed to be a mob. If so, something like this would accomplish what you want:
mob
Del()
if(sharewith) sharewith.Unfuse() //Call a proc to handle the process of unfusing the players
return ..()


Of course, this also assumes that both mobs have their sharewith variables set to each other. If not, I recommend changing it so that they do. It's much more efficient.

The above example will be called when a player logs out (more specifically any time a mob is deleted). If the player's sharewith variable is set to another mob, it will tell that mob to use it's Unfuse() proc (use whatever procedure you would normally call) and then finish deleting itself. No need for loops.