Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Nov 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need some help with a php calc?

    Hello

    The following is code for a calculator, which I can't get it to display the combat level, and can't see why?

    Ideally I would like someone to throw questions to while I finish the script and others beyond this small project. But any help would be great.

    http://pastebin.com/YyvsG4sb

    The formula for the code is simple, Defence + 2 + highest level out of Attack, Strength, Magic, Ranged, Summoning.

    Anyway I can't get it to display any combat level below calculate. I am not sure why?

    I have not started to work on the next part which will say how many levels of each skill (listed above) till next combat level gain.

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Did you write this code?

    Your request is too broad. Can you post more specific portions of the code where the problem might lie?

  • #3
    New to the CF scene
    Join Date
    Nov 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Updated code.

    http://pastebin.com/0BR5Z9cQ


    View the calculator here http://runehints.com/combat2

    Use Gaogier - to test it.

    Everything works all but the levels required to level up a combat level (at the bottom after you calculated it and it has "" in its place.

    Here is the combat formula again.

    Defence + 2 + highest level out of Attack, Strength, Magic, Ranged, Summoning.

    I need help working out the following formula into php.

    combat level - level - 2 - def level - target level (either attack, strength, magic, ranged, summoning + 1

    PHP Code:
        echo combatLevel($_POST['attack'], $_POST['defence'], $_POST['strength'], $_POST['ranged'], $_POST['magic'], $_POST['summoning']); 

  • #4
    New Coder
    Join Date
    Apr 2008
    Posts
    36
    Thanks
    4
    Thanked 0 Times in 0 Posts
    You do understand you are just calling those individual functions, echo combatLevel($_POST['attack'], $_POST['defence'], $_POST['strength'], $_POST['ranged'], $_POST['magic'], $_POST['summoning']); ....
    i thought you wanted to add them up?

  • #5
    New Coder
    Join Date
    Apr 2008
    Posts
    36
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Oh i think i know what you are getting at... im a bit rusty although do you think something like this would work?

    PHP Code:
    $combat_level $_POST['combat_level'];
    $level $_POST['level'];
    $attack $_POST['attack'];
    $defence $_POST['defence'];
    $strength $_POST['strength'];
    $ranged $_POST['ranged'];
    $magic $_POST['magic'];
    $summoning $_POST['summoning'];

    $target_level1 = array($attack,$defence,$strength,$ranged,$magic,$summoning)
    $target_level2 sort($target_level1SORT_NUMERIC);
    $target_level3 current($target_level2), PHP_EOL ;

    $result $combat_level $level $defence $target_level3 1;

    echo 
    $result


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •