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
https://forums.phpfreaks.com/topic/261042-elseif-not-working/
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
https://forums.phpfreaks.com/topic/261042-elseif-not-working/#findComment-1337829
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.