ID:262703
 
Code:
mob
melp
Mission_Giver
icon = 'NPC.dmi'
icon_state = "mission giver"
npc = 1
hp = 99999999999999999999999999999999999999999999999999999999999999999999999
verb
Talk()
set src in oview(1)
set category = "Commands"
for(var/obj/O in usr.contents)
if(O.name=="Puppet")
alert("Yes!! You got the puppet i was looking for...Thanks, here is 300 Yen and 1 D Rank Mission Point.")
usr.yen+=300
usr.D+=1
usr.ondmission = 0
usr.kanktalk = 0
if(usr.ondmission==1)
alert("Im sorry, Finish the mission your on already...","Mission Giver")
return
switch(input("What kind of mission would you like?.","Mission Giver") in list ("S","A","B","C","D"))
if("S")
alert("There are none available right now.")
if("A")
alert("There are none available right now.")
if("B")
alert("There are none available right now.")
if("C")
alert("There are none available right now.")
if("D")
if(usr.rank=="Genin"||"Chuunin"||"Jounin")
switch(input("Are you sure you would like to do this mission?") in list ("Yes","No"))
if("Yes")
alert("Ok, I want you to go talk to a mysterious man in in Sand Village, He is said to use puppets, Get me one.")
ondmission=1
if("No")
alert("Come back when your ready to do a mission")
else
alert("Im sorry you must be at least Genin to do the missions")


Problem description:For some reason it doesnt read the O.name...why? because i have it in my inventory and i still cant get the message to come up it says Im sorry, Finish the mission your on...thats odd

Kurosaki_Ichigo-San wrote:
Code:
mob
> melp
> Mission_Giver
> icon = 'NPC.dmi'
> icon_state = "mission giver"
> npc = 1
> hp = 99999999999999999999999999999999999999999999999999999999999999999999999
> verb
> Talk()
> set src in oview(1)
> set category = "Commands"
> for(var/obj/O in usr.contents)
> if(O.name=="Puppet")
> alert("Yes!! You got the puppet i was looking for...Thanks, here is 300 Yen and 1 D Rank Mission Point.")
> usr.yen+=300
> usr.D+=1
> usr.ondmission = 0
> usr.kanktalk = 0
> if(usr.ondmission==1)
> alert("Im sorry, Finish the mission your on already...","Mission Giver")
> return
> switch(input("What kind of mission would you like?.","Mission Giver") in list ("S","A","B","C","D"))
> if("S")
> alert("There are none available right now.")
> if("A")
> alert("There are none available right now.")
> if("B")
> alert("There are none available right now.")
> if("C")
> alert("There are none available right now.")
> if("D")
> if(usr.rank=="Genin"||"Chuunin"||"Jounin")
> switch(input("Are you sure you would like to do this mission?") in list ("Yes","No"))
> if("Yes")
> alert("Ok, I want you to go talk to a mysterious man in in Sand Village, He is said to use puppets, Get me one.")
> ondmission=1
> if("No")
> alert("Come back when your ready to do a mission")
> else
> alert("Im sorry you must be at least Genin to do the missions")
>


Your problem is that everything after your first if() statement(and its contents) should be unindented by one. Basically, your saying:
"For every object in my contents, if it is named "Puppet" do some stuff, but as long as I am ondmission, send me a message. Then do the switch() proc."
Now if you check if you are ondmission for every object in your contents, imagine if your puppet is the 3rd item. That means that it'll have looped through twice without setting ondmission to 0, and you'll receive that "Im sorry" message.

Now, I don't know why I bother. You never seem to listen. I know for a fact that I have already told you not to check variables like:
if(variable == 1)
or
if(variable == 0)

What you want to use is:
if(variable) // Where variable == 1
or
if(!variable) // Where variable == 0


Another thing I'm pretty sure I've told you is that you can't simplify your if() statements that way.
if(usr.rank=="Genin"||"Chuunin"||"Jounin")
Is completely wrong. What you are asking is:
"If my rank is 'Genin', or if 'Chuunin' or 'Jounin' are nonzero values(which, being text, they are nonzero), execute this code." And since your text is a constant nonzero value, the if() statement will always execute. You have to fully say what you want your if() statement to do:
if(rank=="Genin"||rank=="Chuunin"||rank=="Jounin")

As you can see, for each separate tested statement, you must write out the full statement, no shortcuts.

Please listen to all of what I've said, it's getting annoying to have to repeat myself.

Hiead
In response to Hiead
Hiead wrote:
Another thing I'm pretty sure I've told you is that you can't simplify your if() statements that way.
if(usr.rank=="Genin"||"Chuunin"||"Jounin")
Is completely wrong.

Not completely:

if(usr.rank==("Genin"||"Chuunin"||"Jounin"))


works just fine.
In response to Ben G
Ben G wrote:
Hiead wrote:
Another thing I'm pretty sure I've told you is that you can't simplify your if() statements that way.
if(usr.rank=="Genin"||"Chuunin"||"Jounin")
Is completely wrong.

Not completely:

> if(usr.rank==("Genin"||"Chuunin"||"Jounin"))
>

works just fine.

Actually, due to order of operations, I believe the things in parenthesis would either return one of the strings or a true value, as opposed to checking each individual value. I could be wrong though...

Hiead
In response to Hiead
Hiead wrote:
Ben G wrote:
Hiead wrote:
Another thing I'm pretty sure I've told you is that you can't simplify your if() statements that way.
if(usr.rank=="Genin"||"Chuunin"||"Jounin")
Is completely wrong.
Not completely:

> > if(usr.rank==("Genin"||"Chuunin"||"Jounin"))
> >

works just fine.

Actually, due to order of operations, I believe the things in parenthesis would either return one of the strings or a true value, as opposed to checking each individual value. I could be wrong though...

Hiead

Oh, you're right. I didn't test it too thoroughly. It would return "Genin" because it's the first true value.
In response to Ben G
You can always use switch().
switch(some_var)
if("one","two","three")


You can also put the switch in an if() statement but it gets a bit ugly.