View Single Post
  #1  
Old 09-30-2018, 09:34 PM
superpally1
Sarnak
 
Join Date: Jul 2018
Location: Tennessee
Posts: 33
Default Trying to understand.

I can not figure out why this first script works as it should, and the second one does not.

Code:
sub EVENT_SAY {

    if ($text=~/armorset/i) {
	# head armor ids   147587 = leather, 147580 = plate, 147573 = chain, 147566 = cloth
        # chest armor ids  147588 = leather, 147581 = plate, 147574 = chain, 147567 = cloth
        # leg  armor ids   147591 = leather, 147584 = plate, 147577 = chain, 147570 = cloth
	
	my $headid = $client->GetItemIDAt(2);
        my $chestid = $client->GetItemIDAt(17);
        my $legid = $client->GetItemIDAt(18);
	
        if($headid == 147587 && $chestid == 147588 && $legid == 147591){ #leather
	    $client->Message(15,"3 pieces of armor equipped, $headid, $chestid, $legid.");
	}
	elsif($headid == 147587 && $legid == 147591){ #leather
            $client->Message(15,"2 pieces of armor equipped, $headid, $legid.");
	}
	if($headid == 147580 && $chestid == 147581 && $legid == 147584){ #plate
            $client->Message(15,"3 pieces of armor equipped, $headid, $chestid, $legid.");
	}
	elsif($headid == 147580 && $legid == 147584){ #plate
            $client->Message(15,"2 pieces of armor equipped, $headid, $legid.");
	}
	if($headid == 147573 && $chestid == 147574 && $legid == 147577){ #chain
            $client->Message(15,"3 pieces of armor equipped, $headid, $chestid, $legid.");
	}
	elsif($headid == 147573 && $legid == 147577){ #chain
            $client->Message(15,"2 pieces of armor equipped, $headid, $legid.");
	}
	if($headid == 147566 && $chestid == 147567 && $legid == 147570){ #cloth
            $client->Message(15,"3 pieces of armor equipped, $headid, $chestid, $legid.");
	}
	elsif($headid == 147566 && $legid == 147570){ #cloth
            $client->Message(15,"2 pieces of armor equipped, $headid, $legid.");
	}
    }
}


Code:
sub EVENT_SAY {
	if ($text=~/armorset/i) {
	# head armor ids   147587 = leather, 147580 = plate, 147573 = chain, 147566 = cloth
        # chest armor ids  147588 = leather, 147581 = plate, 147574 = chain, 147567 = cloth
        # leg  armor ids   147591 = leather, 147584 = plate, 147577 = chain, 147570 = cloth
	
	my $headid = $client->GetItemIDAt(2);
        my $chestid = $client->GetItemIDAt(17);
        my $legid = $client->GetItemIDAt(18);
	
        if ($headid == 147587||147580||147573||147566 && $chestid == 147588||147581||147574||147567 && $legid == 147591||147584||147577||147570){
            $client->Message(15,"3 pieces of armor equipped, $headid, $chestid, $legid.");
	}
	elsif ($headid == 147587||147580||147573||147566 && $legid == 147591||147584||147577||147570){
            $client->Message(15,"2 pieces of armor equipped, $headid, $legid.");
	}
    }
}
The second script will always output the 3 piece message regardless if you have all 3 pieces of gear on, 2 pieces, 1 piece, or no pieces.
If the item is not equipped the client->Message will just list -1 for the itemid for that slot.

The elsif statement is never reached.

Any help would be greatly appreciated.
Reply With Quote