ID:142304
 
Code:
StartChunintest()
if(Chunin>1)
return
Chunintakers=0
world<<"<font size=2><font color=green>CHUNIN EXAM HAS JUST STARTED RIGHT CLICK TO TAKE TEST!!!"
Chunin=2
var/mob/M
sleep(2400)
for(M in world)
if(M.chunin>0)
M<<"<font size=2><font color=red>You have 1 minute to complete the exam"
sleep(600)
if(Chunintakers<2)
M<<"<font size=2><B><font color=red>There were not enough people to start the next part."
M.chunin=0
Chunin=0
M.loc=M.Spawn
M.Attacking=0
Heavens=0
Earths=0
for(var/obj/Heaven_Scroll/H in M.contents)
del(H)
for(var/obj/Earth_Scroll/E in M.contents)
del(E)
M.verbs-=typesof(/mob/chunin/verb)
return
else
Startforest()
Startforest()
if(Chunin>2)
return
Chunintakers=0
var/mob/M
Chunin=3
for(M in world)
if(M.chunin==1)
alert("Sorry but you failed the test work on your observation skills")
usr.chunin=0
usr.loc=usr.Spawn
usr.chunintest=0
usr.freeze=0
usr.cheated=0
usr.caught=0
usr.verbs-=/mob/chunin/verb/Cheat
usr.Attacking=0
return
if(M.chunin>1)
M<<"<font size=2><font color=red>You will enter the forest in.."
M<<"<font size=2><font color=red>5"
sleep(10)
M<<"<font size=2><font color=red>4"
sleep(10)
M<<"<font size=2><font color=red>3"
sleep(10)
M<<"<font size=2><font color=red>2"
sleep(10)
M<<"<font size=2><font color=red>1"
sleep(10)
if(M.cgate==1)
M.loc=locate(48,4,17)
if(M.cgate==2)
M.loc=locate(48,4,17)
if(M.cgate==3)
M.loc=locate(48,4,17)
if(M.cgate==4)
M.loc=locate(48,4,17)
if(M.cgate==5)
M.loc=locate(48,4,17)
if(M.cgate==6)
M.loc=locate(48,4,17)
if(M.cgate==7)
M.loc=locate(48,4,17)
if(M.cgate==8)
M.loc=locate(48,4,17)
M<<"<font size=2><font color=red>You have 10 minutes to kill someone with the other scroll"
sleep(5400)
M<<"<font size=2><font color=red>You have 1 minute to kill someone with the other scroll"
sleep(600)
for(M in world)
if(M.chunin<3)
M<<"<font size=2><B><font color=red>You did not pass the forest of death"
M.chunin=0
M.loc=M.Spawn
M.Attacking=0
Heavens=0
Earths=0
for(var/obj/Heaven_Scroll/H in M.contents)
del(H)
for(var/obj/Earth_Scroll/E in M.contents)
del(E)
if(Chunintakers==1)
if(M.chunin==3)
M<<"<font size=2><B><font color=red>Congratulations you were the only one to pass the forest."
M.rank="Chunin"
M.loc=M.Spawn
M.Attacking=0
M.chunin=0
M.chuninlevel()


Problem description:
Ok Im trying to make an auto chunin exam and it works ok except the for(M in world)...and yes the M is defined as a mob...doesnt always include all the players. If you need the end of the chunin test and what it does i can post that also but any help would be appreciated.
Just use
for(var/mob/M in world)


Also, no usr in procs.
In response to Andre-g1
yeah i fixed that usr problem missed that, but if you look i define M right above the for statement as var/mob/M so its not that
for(var/mob/M in world)
//or
for(var/M as mob in world)
//setting it beforehand doesn't cause it to only find mobs...

You're probably getting error messages such as null.chunin and not knowing.
In response to Naokohiro
not getting errors i had it as for(var/mob/M in world) before hand but changed it cause was getting some difficulty with it so changed it to var/mob/M before hand and then for(M in world) im running in debug to look for errors and not receiving any
In response to NightJumper88
That doesn't make any sense.
As long as you've set mob/var/chunin, etc. The way I showed you should work.
In response to Naokohiro
yeah i have it defined as mob/var/tmp/chunin
In response to NightJumper88
It's nonsense to define the var beforehand. Just use for(var/mob/M in world) like we've said. Replace all those usr with M as well.
In response to Naokohiro
already fixed the usr stuff and i changed it back to not defining it before hand but i still have the problem. And thanks for any help
In response to NightJumper88
It doesn't matter whether you define M before the loop, or in the for() statement: the problem is this bit:

     for(M in world)
if(M.chunin==1)
alert("Sorry but you failed the test work on your observation skills")
// blah blah
return


The first time in the loop that it comes across a mob with M.chunin==1, the proc will return (thus not checking any more mobs). Replace "return" with "continue" and the it will resume the loop at the next mob in the world, thus it'll check every mob in the world.
In response to Hobnob
thank you ill try that hopefully it works
In response to Hobnob
I still think it's nonsense to waste a line, though. Especially, when he thinks it causes problems, when they're the same thing...
In response to Hobnob
Another problem is the fact it's not M that is alerted, but usr, which is the default. Of course, apparently he misuses usr afterwards as well, but that's pretty clear.