ID:1266703
 
(See the best response by Neimo.)
Code:
mob/proc/Mass_revive()
for(var/mob/M) if(M.dead)
if(M.dead==1)
M << "you will revive in 30 mintunes"
sleep(100)
switch(input("Would you like to be Revive?", "", text) in list ("No", "Yes",))
if("Yes")
M.dead=0
M.overlays-='Halo.dmi'
M.Locate()
spawn(10) Mass_revive()
if("No")
sleep(100)
spawn(10) Mass_revive()

mob/var/masson=1
mob/Admin3/verb
Mass_revive_toggle()
set category = "Admin"
if(masson==0)
usr<<"Mass revive is on"
masson=1
spawn(10) Mass_revive()
return
if(masson==1)
masson=0
usr<<"Mass Revive is off"
return


Problem description:
Hello, its been a long time.So I was wondering why my code will not loop. Its probably because a spawn isnt that good of a loppproc, but altas, I tried anyways.

What would I use to make this code loop, IF the mass revie toggle is on.
It loops, but it'll loop indefinitely (sorta, loops while daed mobs exist) because you spawn Mass_revive() mid Mass_revive(). Your loop will go through all of the dead mobs without it.
Pretty sure you want something like this:

var
masson
currentlyDead[0]



proc
Mass_revive()
while(masson)
for(var/mob/m in currentlyDead) spawn
switch(input(m, "Would you like to be revived?", "", text) in list ("Yes", "No"))
if("Yes")
m.revive()

sleep(18000 /* 30 minutes */)



mob
Admin3/verb
Mass_revive_toggle()
if(masson)
masson = 0
else
masson = 1
Mass_revive()

usr << "Mass Revive is [masson ? "on" : "off"]."


proc
death()
// Input death code
currentlyDead += src


revive()
// Input revive code
currentlyDead -= src

In response to FKI
Best response
It'd be in your best interest to create a while() loop instead of constantly calling the same proc repeatedly.
In response to Neimo
Yeah, I was just thinking about doing that just in case the toggle verb is used multiple times.

Other than that, what's the difference? O_o
In response to FKI
FKI wrote:
Yeah, I was just thinking about doing that just in case the toggle verb is used multiple times.

Other than that, what's the difference? O_o

If you're calling the same proc, in itself, that can lead to stack overflow.
I've modified your original code as little as possible in order to give you what you're looking for.

mob/proc/Mass_revive()
for(var/mob/M)
// spawn allows all the following to code to work on its own, which allows the sleep(100)
// to occur as well as allowing the player to answer the question (do they want to revive)
// meanwhile the code can keep going to do the same for every player.
spawn()
if(M.dead)
M << "you will revive in 30 minutes."
sleep(100)
switch(input(M, "Would you like to be Revived?", "", text) in list ("No", "Yes",))
if("Yes")
M.dead=0
M.overlays-='Halo.dmi'
M.Locate()
// here we have to use spawn to set both the delay before the next revive cycle, as well as
// to prevent a "stack overflow" bug. You COULD use a while loop, however this is crash
// resistant.
spawn(100)
Mass_revive()

mob/var/masson=1

mob/Admin3/verb
Mass_revive_toggle()
set category = "Admin"
if(masson==0)
usr<<"Mass revive is on"
masson=1
spawn(10) Mass_revive()
return
if(masson==1)
masson=0
usr<<"Mass Revive is off"
return