View Single Post
  #4  
Old 11-30-2010, 04:48 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

I didn't mention anything about using an if or elsif or else, I just mentioned the syntax I have used in the past for comparing $class. I think you would just use the following syntax in your script in place of what you have been trying so far:

Code:
$class == 'Warrior'
Though, if you are having 2 classes turn in the same item ID (219592), your script is actually flawed in your logic flow there as well now that I think about it. The problem is that as soon as plugin::check_handin() verifies that the item 219592 matches the turn in, it eats the item, so any ifs or elsifs after that will never work. You must keep in mind that if checks happen from left to right. So, if you want to make sure a certain class is turning in a certain item, then you want to check $class first, not the handin. Generally, the handin is the last thing you ever want to check.

So, your line:
Code:
elsif (plugin::check_handin(\%itemcount, 219592 => 1) && $class == 1) {
Should actually be

Code:
elsif ($class eq "Warrior" && plugin::check_handin(\%itemcount, 219592 => 1)) {
To explain that a bit, if a Monk turned in 219592 with your code, the script that checks for warrior first would result in this:

Code:
elsif (true && false) {
So, obviously it would move on to the next check, but at that point, the handin plugin already ate the item, so the next one for the Monk check would result in this:

Code:
elsif (false) {
It would be false, because the item is already gone, and as soon as it gets a false, it stops any further checks, so the class check doesn't even get made (not like it would matter).

By switching the checks around as suggested, your first result would be this:

Code:
elsif (false) {
This is because it checked of $class was a Warrior and it was not, since we are using a Monk in this example.

Then, the next check would result in this:

Code:
elsif (true && true) {
Because the $class is Monk and the correct item was turned in, so it then results in the correct reward.

I should probably add something like this explanation to the Wiki sometime, as I think it would clear up the understanding of why certain scripts don't seem to be working as intended when they actually are. I didn't know this when I first started out, and learning it has helped quite a bit in my script writing over the years.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!

Last edited by trevius; 11-30-2010 at 05:03 AM..
Reply With Quote