Jump to content

IF number<10 ????


burtybob

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/75898-if-number/
Share on other sites

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) {

}

Link to comment
https://forums.phpfreaks.com/topic/75898-if-number/#findComment-384143
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/75898-if-number/#findComment-384149
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.