ID:139167
 
Code:
mob
var
hunger=100
statreduce=0
proc
hungerdecrease()
var/mob/players/M
if(usr.statreduce==1)
if(usr.hunger==0)
healtdecrease()
else
if(usr.hunger>=51)
M.tempevade+=10
M.Fireres+=10
M.Iceres+=10
M.Litres+=10
M.Darkres+=10
M.Poisres+=10
M.Earthres+=10
usr.statreduce=0
usr<<"Your Evasion and Fire/Ice/Lightning/Dark/Poison/Earth resistence increased!"
hungerdecrease()
else
sleep(250*adventurelevel)
usr.hunger-=1
hungerdecrease()
else
if(usr.hunger>=51)
sleep(250*adventurelevel)
usr.hunger-=1
hungerdecrease()
else
M.tempevade-=10
M.Fireres-=10
M.Iceres-=10
M.Litres-=10
M.Darkres-=10
M.Poisres-=10
M.Earthres-=10
usr.statreduce=1
usr<<"Your too hungry! Evasion and Fire/Ice/Lightning/Dark/Poison/Earth resistence decreased!"
usr<<"Eat some fish to calm your hunger."
hungerdecrease()
healtdecrease()
var/mob/players/M
M.HP-=10
sleep(10)
hungerdecrease()


Problem description:The idea is every once in a while your hunger goes down its in percentage, the problem is whn it reaches 50 it stops the stats dont decrease and the hunger bar just stops at 50 even if you eat wich makes it go up again it never goes down again. So my question am i missing something in the code? this is the whole code btw.

Try this:
mob
var
hunger=100
statreduce=0
proc
hungerdecrease()
var/mob/players/M
if(usr.statreduce==1)
if(usr.hunger==0)
healtdecrease()
else
if(usr.hunger>=51)
M.tempevade+=10
M.Fireres+=10
M.Iceres+=10
M.Litres+=10
M.Darkres+=10
M.Poisres+=10
M.Earthres+=10
usr.statreduce=0
usr<<"Your Evasion and Fire/Ice/Lightning/Dark/Poison/Earth resistence increased!"
hungerdecrease()
if(usr.hunger<=50)
sleep(250*adventurelevel)
usr.hunger-=1
hungerdecrease()
else
if(usr.hunger>=51)
sleep(250*adventurelevel)
usr.hunger-=1
hungerdecrease()
if(usr.hunger<=50)
M.tempevade-=10
M.Fireres-=10
M.Iceres-=10
M.Litres-=10
M.Darkres-=10
M.Poisres-=10
M.Earthres-=10
usr.statreduce=1
usr<<"Your too hungry! Evasion and Fire/Ice/Lightning/Dark/Poison/Earth resistence decreased!"
usr<<"Eat some fish to calm your hunger."
hungerdecrease()
healtdecrease()
var/mob/players/M
M.HP-=10
sleep(10)
hungerdecrease()

In response to Prf X
Thank you for your fast response unfortunatly it didnt work, putted it in tested it but still it stops at 50% no stats decreasing at all. i hope someone might know the solution to this please.
In response to Chaokai
I'd have to see your entire code to know whats going on, and i dont recommend posting that here for all to see, add me on pager?
The problem is it has no idea what M is. All you did was create the variable M, you didn't set it equal to anything. It has no idea whose variable it should change when you do M.Fireres+=10. So since M = nothing, in-game you get a runtime error because its trying to access the Fireres variable of nothing.

Oh and anytime you have a selfmade proc, you definitely want to be using src instead of usr.

Good luck, fix the M stuff and it should work.
In response to Turles
Turles wrote:
The problem is it has no idea what M is. All you did was create the variable M, you didn't set it equal to anything. It has no idea whose variable it should change when you do M.Fireres+=10. So since M = nothing, in-game you get a runtime error because its trying to access the Fireres variable of nothing.

Oh and anytime you have a selfmade proc, you definitely want to be using src instead of usr.

Good luck, fix the M stuff and it should work.

Good point, I miss M=null
also if M = src M is not need
In response to Prf X
Thank you guys for your help the only thing i missed was M=src now it works fine.

Thank you alot.