...

View Full Version : Add XP on button click



Hydrian
11-09-2012, 10:21 PM
Hi, ive been working on a leveling system for my class, but im at the point where i need to make it automatic, so when a button is clicked add 5xp to the total xp.

Here is my code for the system


<?php
$array = array(
array(
'xp_required' => 150,
'level' => 1
),
array(
'xp_required' => 225,
'level' => 2
),
array(
'xp_required' => 337,
'level' => 3
),
array(
'xp_required' => 566,
'level' => 4
),
array(
'xp_required' => 846,
'level' => 5
),
array(
'xp_required' => 1274,
'level' => 6
),
array(
'xp_required' => 1911,
'level' => 7
),
array(
'xp_required' => 2866,
'level' => 8
),
array(
'xp_required' => 4299,
'level' => 9
),
array(
'xp_required' => 6449,
'level' => 10
)
);
$current_xp = 155;
foreach( $array as $reqs ){
if( $current_xp > $reqs['xp_required'] ){
$level = $reqs['level'];
}
}
echo 'You are at ' ,$level;

?>


http://pastebin.com/vTriKTkG

Please tell me how to do this.

Fumigator
11-09-2012, 11:30 PM
You really want me to dig through your entire code base without any idea of where I should be looking? You'll need my hourly consulting rate...

Perhaps you could paste the relevant portion of code into your post, we might have a recommendation on what changes you might need to make.

As it is, your question smells like lazy wantin' free work.

Hydrian
11-10-2012, 12:15 AM
You really want me to dig through your entire code base without any idea of where I should be looking? You'll need my hourly consulting rate...

Perhaps you could paste the relevant portion of code into your post, we might have a recommendation on what changes you might need to make.

As it is, your question smells like lazy wantin' free work.

There that should do it, my question is that im not sure on what to do.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum