Log in

View Full Version : Using OR in NPC script


tandcemerson
11-27-2009, 05:59 AM
Some strange happenings going on. Awhile ago I tried writing a simple script which would provide a slightly altered quest for each player based on their class. Basically it went something like if $class="Shadowknight" or $class="paladin" { blah blah }. Anyways, I lost the original script when I painstakingly removed all my OR's so I didn't have anything concrete to submit. I don't have direct access to the NPC scripts, but go through someone else and didn't want to trouble him.

However, yesterday one of the other quest writers came acros the same thing so I wanted to submit his example so I can try and figure out why I can't even use a simple OR statement?

*NOTE* In my original example, I used double quotes and when I saw the preliminary quest submitted, I saw that he used single quotes and figured maybe I missed something, but they both cause the NPC to seize up and become unresponsive.

if ($class !='shadowknight' || $class !='necromancer') {
if($text=~/Hail/i) {
quest::say("Blah blah");
}

So this section of code works well if I separate out the two class into their own if statements, but it won't work like this. Any clue?

joligario
11-27-2009, 08:15 AM
When using classes and eq (equal for strings) or ne (not equal for strings), you will need to capitalize the class. So for your given example:

if ($class ne "Shadowknight" || $class ne "Necromancer") {

tandcemerson
11-27-2009, 08:43 AM
Ahhh! Wonderful! This will save me a lot of work in the future. Thanks!