ID:1919271
 
(See the best response by Nadrew.)
Code:
mob
var
bound=0
proc
bind()
for(var/mob/M in oview(4))
M.bound=1
spawn(300) M.bound=0


Problem description:

Sometimes, runtime errors pop up, saying "Cannot read null.bound" etc. My best guess for this is perhaps the person logs out or their src is deleted in between the spawn() set time. If so, what are some methods for avoiding these errors? And if not, which could be the initial problem?
Best response
You simply need to check if M still exists (and you're correct, using spawn() can cause the code to trigger after the reference vanishes)

spawn(300)
if(M) M.bound = 0
Alright, thank you very much for the help, I appreciate it.