Jump to content

Elseif not working...


zelig

Recommended Posts

Okay, I have a script that if someone is a particular "class", they can't get additional bonus points for their character. However, if they aren't that class, then they get additional points.

 

But, it seems to be ignoring the elseif and gives a strength point no matter what the class is.

 

I don't see where I coded wrong, so I would appreciate any help!

Thanks!

 

if ($expgain + $player->mine_exp >= $player->mine_maxexp)
		{
			echo "<br /><b>Your mining leveled up!</b>";
			echo "$blurb $randeffect<p>";
		    if(($strength + $agility + $wisdom + $vitality >=100) && ($class != 'Apprentice' || $class != 'Mage' || $class != 'Priest' || $class != 'Rogue' || $class != 'Scholar' || $class != 'Wanderer' || $class != 'Warrior' || $class != 'Woodsman'))
           		{
           		echo "<br /><b>You gained 1 strength point!</b>";
			$query = $db->execute("update `users` set `energy`=?, `mine_level`=?, `mine_exp`=?, `minecount`=?,  `strength`=?, `mine_maxexp`=? where `id`=?", array($player->energy - 1, $player->mine_level + 1, $player->mine_exp + 1, $player->minecount + 1, $player->strength + 1, $player->mine_maxexp + $newmax, $player->id));
           		}
           		elseif (($strength + $agility + $wisdom + $vitality >= 100) && ($class = 'Apprentice' || $class = 'Mage' || $class = 'Priest' || $class = 'Rogue' || $class = 'Scholar' || $class = 'Wanderer' || $class = 'Warrior' || $class = 'Woodsman'))
							{
			echo "You have already maxed out your stats at 100!";
              	$query = $db->execute("update `users` set `energy`=?, `mine_level`=?, `mine_exp`=?, `minecount`=?, `mine_maxexp`=? where `id`=?", array($player->energy - 1, $player->mine_level + 1, $player->mine_exp + 1, $player->minecount + 1, $player->mine_maxexp + $newmax, $player->id));
			}
			elseif($strength + $vitality + $wisdom + $agility < 100)
			{
			echo "<br /><b>Your mining leveled up and you gained 1 strength point!</b>";
			$query = $db->execute("update `users` set `energy`=?, `mine_level`=?, `mine_exp`=?, `minecount`=?, `strength`=?, `mine_maxexp`=? where `id`=?", array($player->energy - 1, $player->mine_level + 1, $player->mine_exp + 1, $player->minecount + 1, $player->strength + 1, $player->mine_maxexp + $newmax, $player->id));
		}

           								}
		else
{
                $query = $db->execute("update `users` set `energy`=?, `mine_exp`=?, `minecount`=? where `id`=?", array($player->energy - 1, $player->mine_exp + 1, $player->minecount + 1, $player->id));
                echo "$blurb $randeffect<p>";
            }

Link to comment
Share on other sites

Try changing your || to &&

 

if(($strength + $agility + $wisdom + $vitality >=100) && ($class != 'Apprentice' &&  $class != 'Mage' &&  $class != 'Priest' &&  $class != 'Rogue' &&  $class != 'Scholar' &&  $class != 'Wanderer' &&  $class != 'Warrior' &&  $class != 'Woodsman'))

 

otherwise, it will almost always evaluate to true.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.