FloatingTextParticle leaderboards issue

Discussion in 'Development' started by Unknown67, Feb 9, 2020.

  1. Unknown67

    Unknown67 Creeper

    Messages:
    2
    Currently I have an issue with my plugin, everything is good with my floating text feature... however I'm not sure how to properly display top 10 players from a chosen table with the corresponding stats.

    Ex.
    1. Joe > $100
    2. Mc > $71
    (etcetc...)

    But with my code, only the first player is displayed.
    Ex.
    1. Joe > $100
    (nothing else)

    I have no clue how to fix this, I've been trying to solve this for a while now.
    PHP:
    public function topBalance(string $player){
            
    $query=$this->db->query("SELECT * FROM economy ORDER BY balance DESC LIMIT 10;");
            
    $list="";
            
    $i=0;
            while(
    $resultArr=$query->fetchArray(SQLITE3_ASSOC)){
                
    $j=$i 1;
                
    $cf=$resultArr['player'];
                
    $b=$this->getBalance($cf);
                
    $list.=$j.". ".$cf." > $".$b."\n";
                
    $i=$i 1;
                return 
    $list;
            }
        }
     
    Last edited: Feb 9, 2020
  2. SleepSpace9

    SleepSpace9 Slime

    Messages:
    75
    GitHub:
    sleepspace9
    Your return statement is inside the loop, so your loop will be exited immediately after the first run.
     
    GamakCZ likes this.
  3. Unknown67

    Unknown67 Creeper

    Messages:
    2
    Bruh thank u so much, I genuinely dont know how I could be trippin over the smallest thing. I aint even realize that return was in the loop.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.