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

help with array

Comments in 'Plugin Development' started by Creeperface, Jun 8, 2015.

  1. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    i know this is not about pocketmine but i looked at php.net array but i didn ´t find where is the problem.

    array:
    PHP:
    public $mapdata = ["canyon" => ["bluespawn" => new Vector3(123)]];
                                                              
    method to get content from array:
    PHP:
    public function getMapData($key)
        {
            return isset(
    $this->mapdata[$key]) ? $this->mapdata[$key] : false;
        }
    i want create other method which return "bluespawn" from array
    i tried this but doesn ´t work
    PHP:
    public $map "canyon";

    public function 
    getArenaData($data){
            return isset(
    $this->getMapData($this->map)[$data]) ? $this->getMapData($this->map)[$data] : false;
        }
    pocketmine log: Fatal error: Can't use method return value in write context
    (getArenaData is bad method)

    EDIT: SOLVED
    Last edited: Jun 8, 2015
  2. Intyre
    Offline

    Intyre Staff Member PocketMine Team

    Joined:
    Aug 24, 2013
    Posts:
    118
    Minecraft User:
    Intyre
    Change $mapdata structure to the one in Example #1. You'll see the problem (I hope).
  3. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    i forgot ] but i have it in my code but still doesn´t work
  4. Lambo
    Offline

    Lambo Notable Member Plugin Developer

    Joined:
    Sep 14, 2013
    Posts:
    431
    Plugins:
    4
    Minecraft User:
    Lambo
    You probably post the solution for future readers
  5. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    because i tried $this->getArenaData("bluespawn")++; xD

Share This Page

Advertisement