ID:146321
 
Ive added to my game a shadow spar training method but the problem is that when i go and test it out it works fine till i need to rest but when after i rest i still get the message " You cant shadow spar you are too tried when my stamina is 100%

Heres the coding for it

obj
shadowspar
verb
Shadow_Spar()
set name="Shadow Spar"
set category="Fighting"
if(usr.maxstamina > 1)
if(usr.flight == 1)
usr << "Not while flying."
return
if (usr.meditate==1)
usr<<"Not while meditating"
return
flick("sparfury", usr)
usr.move = 1
usr.icon_state = ""
usr.exp += 1
usr.maxstamina -= 2
usr.meditate = 0
usr.rest = 0
usr.levelcheck()
usr.FlightLearn()
usr.KiTechLearn()
usr.AuraMake()
usr.AuraTechLearn()
usr.FocusLearn()
else
usr << "You can't Shadow Spar. You are too tired."


How can i fix this?

Well for starters not many are going to help you because this is a in a Zeta Rip game -_-
Hey man, I will need to see your "rest" code to see your problem.
In response to Dranzer_Solo
lol, he made a typo in the code try this
obj
shadowspar
verb
Shadow_Spar()
set name="Shadow Spar"
set category="Fighting"
if(usr.stamina > 1)
if(usr.flight == 1)
usr << "Not while flying."
return
if (usr.meditate==1)
usr<<"Not while meditating"
return
flick("sparfury", usr)
usr.move = 1
usr.icon_state = ""
usr.exp += 1
usr.maxstamina -= 2
usr.meditate = 0
usr.rest = 0
usr.levelcheck()
usr.FlightLearn()
usr.KiTechLearn()
usr.AuraMake()
usr.AuraTechLearn()
usr.FocusLearn()
else
usr << "You can't Shadow Spar. You are too tired."
In response to Cheetoz
Yeah that is what I was thinking, but he also subtracts 2 from maxstamina, after sparring. He said that he got the sparring to work the first time, and the stamina recharged, but the sparring didn't detect full stamina. So, I think the problem is deeper than that little error, like his "rest" code isnt refilling the same stamina variable, that his sparring code is subtracting from. That is why he needs to show us his "rest code". I'm not sure though, I only started with BYOND last night. So it could be as simple as that.
if(usr.maxstamina > 1)
if(usr.flight == 1)
usr << "Not while flying."
return
if (usr.meditate==1)
usr<<"Not while meditating"
return
flick("sparfury", usr)
usr.move = 1
usr.icon_state = ""
usr.exp += 1
usr.maxstamina -= 2


Problem is here.

Both maxstamina should be stamina

And I believe there should be an '=' after the '>'

(usr.maxstamina > 1) should be (usr.maxstamina >= 1)

Now put them together:

if(usr.stamina >= 1)
if(usr.flight == 1)
usr << "Not while flying."
return
if (usr.meditate==1)
usr<<"Not while meditating"
return
flick("sparfury", usr)
usr.move = 1
usr.icon_state = ""
usr.exp += 1
usr.stamina -= 2


Should work. >_> untested though
Instead of if(var==1), and if(var==0), make them if(var) and if(!var) respectively. It's more robust.

Additionally, why all those usrs? This is a verb, so they should work, assuming you don't call it like a proc for NPCs, but it smacks of misunderstanding to me. Just delete all the usr, and change them into srcs for output purposes, etc. If you just leave a variable name. (say, just put in "name"), it defaults to src, so you can shorten your code dramatically, and improve it's readability.

I suspect the problem is related to your 'resting' code. The stuff that handles stamina/maxstamina. If you could show us that...