Global Moderator
Internet Junkie
Gender:
Posts: 1807
9006 credits Members referred : 6
« Reply #1 on: Sep 18, 2006, 09:07:33 pm »
It's kind of hard to understand what you want to do exactly. Try this: tell us in simple steps what you want to do (in plain English) from that we can make your code (probably using case)
Global Moderator
Internet Junkie
Gender:
Posts: 1807
9006 credits Members referred : 6
« Reply #2 on: Sep 18, 2006, 09:13:18 pm »
One thing I quickly notice:
Code:
<?php
if ($melee_combat > $range_combat)
elseif ($range_combat > $melee_combat)
?>
the second has to be true, if the first statement wasn't, so it can be ignored (unless they are the same value, which you are not checking for any of the variables...)
Global Moderator
Internet Junkie
Gender:
Posts: 1807
9006 credits Members referred : 6
« Reply #3 on: Sep 18, 2006, 09:19:14 pm »
Oke, I think I see what you want to do: you have 3 variables and you want $class_combat to have the value of the variable with the highest value of the 3 right? Try this:
aka J Love Community Supporter?
Bill Gates is my home boy
Gender:
Posts: 886
1148 credits Members referred : 4
« Reply #7 on: Sep 18, 2006, 11:36:28 pm »
the method he proposed last will not work, because you say class combat = mage combat at first, so the rest of the if/else is irrelevant.. we ahve 3 variables, mage combat, range combat, and melee combat. we want to find the highest value of those 3 and set that to be the class combat
Global Moderator
Internet Junkie
Gender:
Posts: 1807
9006 credits Members referred : 6
« Reply #8 on: Sep 18, 2006, 11:38:43 pm »
thats exactly what its doing, you set it to the first value first and then override this value if the other turns out to be bigger. The if's are comparing your variable with whats in $class_combat at the time
« Last Edit: Sep 18, 2006, 11:40:38 pm by Mind_nl »
Global Moderator
Internet Junkie
Gender:
Posts: 1807
9006 credits Members referred : 6
« Reply #10 on: Sep 19, 2006, 12:51:22 am »
Like Nikolas said, the array way would probably be slower. You have to create the array, fill it, sort it and extract the highest value. This will cause some overhead. Probably not noticable in this case but still. Heres another way I found which is even more elegant: