What is the correct usage for $class
What is the correct usage for $class? The following are the methods I have tried so far with no luck:
Code:
sub EVENT_ITEM { Code:
sub EVENT_ITEM { Code:
sub EVENT_ITEM { Code:
sub EVENT_ITEM { Code:
sub EVENT_ITEM { Code:
sub EVENT_ITEM { Code:
sub EVENT_ITEM { Code:
sub EVENT_ITEM { Code:
sub EVENT_ITEM { Code:
sub EVENT_ITEM { |
I think the last time I used it to compare like that, I used something like:
Code:
if ($class == 'Warrior') Code:
if ($class eq "Warrior") |
Yes I am fully aware of the 120k max id when using an unaltered source which is why I altered mine to 500k.
I cannot imagine why using a plain if statement would make any difference as opposed to using if elsif else but I will give it a shot and see what happens. |
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' So, your line: Code:
elsif (plugin::check_handin(\%itemcount, 219592 => 1) && $class == 1) { Code:
elsif ($class eq "Warrior" && plugin::check_handin(\%itemcount, 219592 => 1)) { Code:
elsif (true && false) { Code:
elsif (false) { By switching the checks around as suggested, your first result would be this: Code:
elsif (false) { Then, the next check would result in this: Code:
elsif (true && true) { 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. |
Good news is using this worked:
Code:
elsif ($class eq "Warrior" && plugin::check_handin(\%itemcount, 219592 => 1)) { This functioned more like an || where if either condition checks true then the entire statement is true. If that were the case then it should have done as you suggested where the first check was true so the entire statement was declared true causing the entire script to stop. Using logic like that means you could put two 1’s into a NAND gate and get a 1 out which would defy mechanical logic. Guess this is why mechanical logic and programming logic are very, very different. |
Well, the reason it works as I explained is because if it finds a false in the first check, there is no need to go past that unless there was an || (OR) statement after the first check.
If your check resulted in the following: Code:
elsif (false && true) { Code:
if ($npc->GetTarget() && $npc->GetTarget()->IsClient()) Code:
if ($npc->GetTarget()->IsClient()) Since the example I gave checks for a target first, and then checks if that target is a client, it is safe from crashes. If Perl worked like you thought it did, that example would still be open to crash issues, as it would check both no matter what. |
I always had trouble getting the script to work when stating it positively (e.g., if($class eq 'Shaman')), so I ended up stating it negatively (e.g., if($class ne 'Shaman')) in questions like this one.
|
If you use eq, you should use double quotes and the class must be capitalized.
|
I guess it doesn't really matter if the logic used is absolute or bendable as long as it can be made to do what we want. To that end, thanks for the help trevius
|
All times are GMT -4. The time now is 05:28 PM. |
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.