Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-12-2012, 09:50 PM   PM User | #1
Gaogier
New to the CF scene

 
Join Date: Nov 2011
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Gaogier is an unknown quantity at this point
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.
Gaogier is offline   Reply With Quote
Old 12-13-2012, 12:03 AM   PM User | #2
Fumigator
UE Antagonizer


 
Fumigator's Avatar
 
Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,686
Thanks: 42
Thanked 637 Times in 625 Posts
Fumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of light
Did you write this code?

Your request is too broad. Can you post more specific portions of the code where the problem might lie?
__________________
Fumigator is offline   Reply With Quote
Old 12-13-2012, 01:05 AM   PM User | #3
Gaogier
New to the CF scene

 
Join Date: Nov 2011
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Gaogier is an unknown quantity at this point
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']); 
Gaogier is offline   Reply With Quote
Old 12-13-2012, 11:31 AM   PM User | #4
lewisstevens1
New Coder

 
Join Date: Apr 2008
Posts: 22
Thanks: 3
Thanked 0 Times in 0 Posts
lewisstevens1 is an unknown quantity at this point
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?
lewisstevens1 is offline   Reply With Quote
Old 12-13-2012, 11:46 AM   PM User | #5
lewisstevens1
New Coder

 
Join Date: Apr 2008
Posts: 22
Thanks: 3
Thanked 0 Times in 0 Posts
lewisstevens1 is an unknown quantity at this point
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
lewisstevens1 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:35 AM.


Advertisement
Log in to turn off these ads.