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

Solved array - Only variables should be passed by reference

Comments in 'Plugin Development' started by ahoj_truhliku, Jul 9, 2015.

  1. ahoj_truhliku
    Offline

    ahoj_truhliku Banned

    Joined:
    Jul 9, 2015
    Posts:
    89
    Minecraft User:
    Creeperface001
    15:08:48 [CRITICAL] Could not execute task Annihilation\Arena\ArenaSchedule: Only variables should be passed by reference
    15:08:48 [NOTICE] RuntimeException: "Only variables should be passed by reference" (E_STRICT) in "/plugins/Annihilation/src/Annihilation/Arena/Arena" at line 475

    my code:
    PHP:
    public function selectMap(){
            
    $stats $this->votingManager->currentTable['stats'];
            
    $map $this->votingManager->currentTable[array_pop(sort($stats))]; //bad line
            
    $this->map $map;
            
    $this->data $this->plugin->maps[$map];
            foreach(
    $this->arenateams->getAllPlayers() as $p){
                
    $p->sendTip(TextFormat::BOLD.TextFormat::YELLOW.$map.TextFormat::GOLD." was chosen");
            }
            
    $this->worldManager->addWorld($map);
        }
    can you help me? i have never seen this error.
  2. iksaku
    Offline

    iksaku Notable Member Plugin Developer

    Joined:
    Sep 2, 2013
    Posts:
    1,132
    Plugins:
    4
    Minecraft User:
    iksaku
    The "sort" function doesn't make any type of return, it directly modify the array variable, so your code may look like:
    PHP:
    public function selectMap(){
            
    $stats $this->votingManager->currentTable['stats'];
             
    sort($stats// New fixing line
            
    $map $this->votingManager->currentTable[array_pop($stats)]; //Modified bad line
            
    $this->map $map;
            
    $this->data $this->plugin->maps[$map];
            foreach(
    $this->arenateams->getAllPlayers() as $p){
                
    $p->sendTip(TextFormat::BOLD.TextFormat::YELLOW.$map.TextFormat::GOLD." was chosen");
            }
            
    $this->worldManager->addWorld($map);
        }
    PEMapModder and ahoj_truhliku like this.
  3. ahoj_truhliku
    Offline

    ahoj_truhliku Banned

    Joined:
    Jul 9, 2015
    Posts:
    89
    Minecraft User:
    Creeperface001
    thx i try it :)

Share This Page

Advertisement