burtybob Posted November 3, 2007 Share Posted November 3, 2007 if ($weapondmg<=10) { return $victimnewhealth=$killquery+1000; }elseif ($weapondmg<=20) { return $victimnewhealth=$killquery*0.20; }elseif ($weapondmg<=30) { return $victimnewhealth=$killquery*0.50; }elseif ($weapondmg<=40) { return $victimnewhealth=$killquery*0.50; }elseif ($weapondmg>=40) { return $victimnewhealth=$killquery*0.50; } Ok as i understand the above code will co through untill one of them validates as true BTW $weapondmg=somwhere between 40 AND 55 with mt_rand So therefore the last elseif should be the only one to be true however it executes the FIRST one?? Please can anyone see why this is? Quote Link to comment https://forums.phpfreaks.com/topic/75898-if-number/ Share on other sites More sharing options...
ignace Posted November 3, 2007 Share Posted November 3, 2007 remove the return Quote Link to comment https://forums.phpfreaks.com/topic/75898-if-number/#findComment-384130 Share on other sites More sharing options...
burtybob Posted November 3, 2007 Author Share Posted November 3, 2007 remove the return Sorry i didnt quite make it clear, i need that return for the function its in dont it??? Ill try anyway:) Ok so i tried removing the return but same result as before execting the first one Quote Link to comment https://forums.phpfreaks.com/topic/75898-if-number/#findComment-384134 Share on other sites More sharing options...
Barand Posted November 3, 2007 Share Posted November 3, 2007 try echo $weapondmg; before the first "if" to verify value Quote Link to comment https://forums.phpfreaks.com/topic/75898-if-number/#findComment-384135 Share on other sites More sharing options...
ignace Posted November 3, 2007 Share Posted November 3, 2007 if it is a function i would suggest using: function <yourfunction> { if ($weapondmg<=10) { $victimnewhealth=$killquery+1000; }elseif ($weapondmg<=20) { $victimnewhealth=$killquery*0.20; }elseif ($weapondmg<=30) { $victimnewhealth=$killquery*0.50; }elseif ($weapondmg<=40) { $victimnewhealth=$killquery*0.50; }elseif ($weapondmg>=40) { $victimnewhealth=$killquery*0.50; } return $victimnewhealth; } or do return $killquery * <multiplier> or try if (statement) { .. } else if (statement) { } Quote Link to comment https://forums.phpfreaks.com/topic/75898-if-number/#findComment-384143 Share on other sites More sharing options...
burtybob Posted November 3, 2007 Author Share Posted November 3, 2007 OK i have seen that the wepondmg for some reason is terminating before going into the if statement hmm. echo "Wepondmg: $weapondmg<br>"; echo "Victims Health: $killquery<br>"; Shows up twice?? Which is also confusing but a different issue so im not worried about it but thought id mention it incase it is. Quote Link to comment https://forums.phpfreaks.com/topic/75898-if-number/#findComment-384149 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.