CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   PHP (http://www.codingforums.com/forumdisplay.php?f=6)
-   -   Add XP on button click (http://www.codingforums.com/showthread.php?t=281685)

Hydrian 11-09-2012 10:21 PM

Add XP on button click
 
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 Code:

<?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

Quote:

Originally Posted by Fumigator (Post 1290511)
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.


All times are GMT +1. The time now is 10:32 AM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.