This is a small sample of a larger script I wrote.
PHP Code:
if (this.item in db_quests.items3) {
temp.prefix = FindPrefix();
if (temp.prefix == -1) {
echo("Level not found in quest database");
}
else {
// CODE
}
}
// find NPC level prefix then check if it is in the quest database
function FindPrefix() {
for (temp.a=0;temp.a<=this.level.length();temp.a++) {
temp.search = this.level.substring(temp.a,1);
if (temp.search == "_") {
temp.checkprefix = this.level.substring(0,temp.a);
if (temp.checkprefix in db_quests.quests) {
return temp.checkprefix;
}
else return -1;
}
}
}
The problem is the if statement
temp.prefix == -1 in the first block of code. Despite findPrefix returning a value not equal to -1 (verified by echo) it will activate regardless and the else statement will be ignored. Any ideas as to why?