Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Problem with my code.

Comments in 'Plugin Development' started by TutoGamerWalid, Oct 17, 2016.

  1. TutoGamerWalid
    Offline

    TutoGamerWalid Active Member

    Joined:
    Jun 11, 2015
    Posts:
    69
    Minecraft User:
    TutoGamerWalid
    PHP:
       public function getTop(){
        
    $dir $this->getDataFolder()."KC/";
        
    $files scandir($dir);
        unset(
    $files[0],$files[1]);
        
    $AllCoins = [];
        foreach(
    $files as $file){
            
    $cfg1 = new Config($file);
            
    $cfg $cfg1->getAll();
            
    $coin 0;
            
    $name '';
            foreach(
    $cfg as $c){
                
    $coin $c;
                
    $name array_search($c,$cfg);
            }
            
    $AllCoins[$name] = $coin;
        }
        
    $TOP = [];
        
    $TOP[0]['names'] = [];
        
    $i 1;
        
    $indice 0;
        
    $this->cache = [];
        
    $egale = [];
        while(
    $i 4){
            foreach(
    $AllCoins as $coins){
                if(
    $coins != 0){
                    if(
    $coins $indice){
                        
    $indice $coins;
                        
    $name array_search($coins,$AllCoins);
                            if(!
    in_array($name,$TOP[$i-1]['names'])){
                        
    $this->cache['name'] = $name;
                        
    $this->cache['coins'] = $coins;
                        
    $egale = [];
                        }
                    }else if(
    $coins == $indice){
                        
    array_push($egale,array_search($coins,$AllCoins));
                    }
                }
            }
            
    array_push($egale,$this->cache['name']);
            
    $TOP[$i] = [
            
    'names'=>$egale,
            
    'coins'=>$this->cache['coins']
            ];
            
    $i++;
        }
        unset(
    $TOP[0]);
        return 
    $TOP;
    }
    Hello, the problem is '$this->cache' I see no worries.
  2. ImagicalGamer
    Offline

    ImagicalGamer Active Member

    Joined:
    Feb 25, 2016
    Posts:
    141
    Minecraft User:
    ImagicalGamer
    Whats the issue with
    PHP:
    $this->cache
    ?
  3. TutoGamerWalid
    Offline

    TutoGamerWalid Active Member

    Joined:
    Jun 11, 2015
    Posts:
    69
    Minecraft User:
    TutoGamerWalid

    Attached Files:

  4. ImagicalGamer
    Offline

    ImagicalGamer Active Member

    Joined:
    Feb 25, 2016
    Posts:
    141
    Minecraft User:
    ImagicalGamer
    I prefer to do this in plugins that use arrays:
    PHP:
    $this->cache = [];
    $this->cache['coins'] = 0;
    $this->cache['name'] = "";
    //or
    $this->cache = ['coins' => 0'name' => ""];
    TutoGamerWalid likes this.

Share This Page

Advertisement