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 3 of 3
  1. #1
    New Coder
    Join Date
    Aug 2012
    Posts
    40
    Thanks
    5
    Thanked 0 Times in 0 Posts

    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.
    Last edited by Hydrian; 11-10-2012 at 01:14 AM.

  • #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
    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.

  • #3
    New Coder
    Join Date
    Aug 2012
    Posts
    40
    Thanks
    5
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fumigator View Post
    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.


  •  

    Posting Permissions

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