Jump to content

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

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.