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 to the CF scene
    Join Date
    Aug 2009
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question Exp Bar (please help)

    PHP Code:
    //Calculate EXP %
        global $experc;
        global $expopp;
        $expn   = $userstats3[level] * 65;
        $experc = $userstats3[exp] / 100 * $expn;
        $experc = round($experc,0);
        $exopp  = 100 - $experc;
        

    E X P : <?php echo $experc ?>%
            <img src="greenbar.png" width="<?php echo $experc ?>" height="10"><img src="redbar.png" width="<?php echo $exopp ?>" height="10">


    for some reason it wont stop at 100% and i cant seem to fix this problem.
    i could really use the help as i am not the best coder thank you, Nate
    Last edited by rebel-rpg; 08-30-2009 at 10:49 PM.

  • #2
    Regular Coder
    Join Date
    May 2006
    Location
    Wales
    Posts
    820
    Thanks
    1
    Thanked 82 Times in 79 Posts
    You're code isn't very clear but to find percentage you divide by the total then multiply by 100 not divide by 100 then multiply by the total

    PHP Code:
    $experc $userstats3[exp] / $expn 100
    Edit:

    On second thoughts, that will just give a high percentage all the time, what you need to do is this (in pseudo-code):

    Code:
    (UsersXP - totalXPforPreviousLevel)/(totalXPforNextLevel - totalXPforPreviousLevel) * 100
    Last edited by Mwnciau; 08-30-2009 at 11:10 PM.

  • Users who have thanked Mwnciau for this post:

    rebel-rpg (08-30-2009)

  • #3
    New to the CF scene
    Join Date
    Aug 2009
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Mwnciau View Post
    You're code isn't very clear but to find percentage you divide by the total then multiply by 100 not divide by 100 then multiply by the total

    PHP Code:
    $experc $userstats3[exp] / $expn 100
    Edit:

    On second thoughts, that will just give a high percentage all the time, what you need to do is this (in pseudo-code):

    Code:
    (UsersXP - totalXPforPreviousLevel)/(totalXPforNextLevel - totalXPforPreviousLevel) * 100

    accually i used:

    PHP Code:
     $experc $userstats3[exp] / $expn 100
    and that seemed to fix it. it only goes over by a lil bit. but once you battle again then it just goes back down.

    example:
    it will be at 95%, after you click battle again, it goes to 110%, then after you click battle one more time it will go back to 7%. so its working alright i guess, that and i dont know what this means..:
    Code:
    (UsersXP - totalXPforPreviousLevel)/(totalXPforNextLevel - totalXPforPreviousLevel) * 100
    could i paste it were this is?

    PHP Code:
     $experc $userstats3[exp] / $expn 100


  •  

    Posting Permissions

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