ID:167691
 
Ok, I have this NPC. When you click him, he gives you the quest fine, but if you click him again, nothing comes up:
/obj/Nirendil
name = "Nirendil"
Click()
if (usr.questNirendil)
for (var/obj/misc/quest/hides/rabbit/O in usr)
if(O)
del O
usr.rabbithide -= 1
else
if (usr.rabbithide)
usr<<alert("So, have you gotten those rabbit hides I needed yet? Looks like you need [usr.rabbithide] more.")
else
usr<<alert("Oh! You got them! Thanks a lot! Here's that reward I promised you.")
usr<<"You gained 2000 Gold for completing the quest"
usr<<"You gained 5000 experience for completing the quest"
usr.questNirendil=0
usr.rabbithide=0
usr.ExpNeed -= 5000
usr.LevelUp()
else
usr<<alert("Why, hello adventurer! You look as if you might be able to help me. Listen, I need 10 rabbit hides for something I'm making. If you can get those for me, I promise I'll give you a reward! So will you accept it?")
if (alert(usr, "Do you accept?", "Rabbit Hide Quest", "Yes", "No") == "Yes")
usr.questNirendil=1
usr<<alert("Thank you so much! I know you'll come through for me!")
usr.rabbithide = 10
new/quests/Nirendil/Rabbit(usr)

What's the problem? Thanks.
You don't want the else's code block in that for-loop to be inside the loop at all. That part never gets executed the way it is set up. Take it out of the loop, delete the else part, and exchange it with a check to see if you have given hides this time around. To do that you also need a new variable inside the function which increments in the loop.
    ...
var/returned_hides = 0
for(var/obj/misc/quest/hides/rabbit/O in usr)
del(O)
returned_hides += 1
usr.rabbithide -= 1
if(!returned_hides)
if(usr.rabbithide <= 0)
...
In response to Loduwijk
Alright, that helps a lot. But now when I talk to him when I don't have any hides, nothing happens. When I do have any hides though, it's fine.
In response to Seraphrevan
Did you put the code block to execute inside the if(usr.rabithide >= 0) statement?