ID:262851
 
Code:
mob/proc/Runpop()
world.Repop()
if(agemark==0)
spawn(1000)
usr.agemark=1
else if(agemark==1)
spawn(1000)
usr.agemark=2
else if(agemark==2)
spawn(1000)
usr.agemark=3
else if(agemark==3)
spawn(1000)
usr.agemark=4
else if(agemark==4)
spawn(1000)
usr.agemark=5
usr<<"Client Info: Half of a year has passed"
else if(agemark==5)
spawn(1000)
usr.agemark=6
else if(agemark==6)
spawn(1000)
usr.agemark=7
else if(agemark==7)
spawn(1000)
usr.agemark=8
else if(agemark==8)
spawn(1000)
usr.agemark=9
else if(usr.agemark==9)
spawn(1000)
usr.Age += 1
if(usr.Age==40)
usr<<"Client Info: As you stand there your body feels weak, and your mind fogs. At that moment you realize your life as a warrior has come to an end"
spawn(10)
del(usr)
else
usr<<"Client Info: A year passes as you get older (you are [usr.Age])"
usr.agemark=0
Runpop()


Problem description:I was wondering if there is a more efficent way of coding this.

-Krow

...

By Eris, that's scary.

Why don't you just add one to that variable, and then check what it is for things that happen at different months?

Oh, and don't use usr in procs. usr is likely null there.
In response to Jp
the code works perfectl. Its just that the game im making is so large already that im avoiding writing as many lines of code as i can.
In response to Dark Krow
It shouldn't work perfectly - It's completely wrong. Note that you avoided answering why you don't just add one to the variable you're modifying.
In response to Jp
i cant just add one, the way it works like that of a timer it sets variables 1-9 when it gets to 9, then it will ad to the Age variable. the reason for the variable is to time real time play as closly as i can
I'm in the holiday spirit, so I'll show you the wonderful world of for() loops:

mob/proc/Runpop()
for(agemark=0,agemark<10,agemark++) //Start agemark at zero, as long as it's less than 10, add one to it and sleep 100 seconds
world.Repop() //You might want to rethink this later, with a few players logged in, monsters will come back quickly.
sleep(1000)
Age++ //Since the 9 parts have finished, make them one year older
if(Age==40)
src<<"Client Info: As you stand there your body feels weak, and your mind fogs. At that moment you realize your life as a warrior has come to an end"
sleep(10)
del(src)
else
src<<"Client Info: A year passes as you get older (you are [Age])"
spawn()
Runpop()



Most of it is self-explanitory.
I switched usr with src, and it should work fine as long as it's the player who the proc is being call for.

Also, you seem to have sleep and spawn confused. Although spawn can take an argument to sleep, what it really does is 'split' the process. I don't have a great understanding of it, so you might want to check the reference on that one. But I know sleep would work fine for what you were doing
In response to DarkCampainger
Thank you to both of you for your help.