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

How am I doing this code?

Comments in 'Plugin Development' started by MyNameIsTriXz, Jan 28, 2016.

  1. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    Id like to create a minigame with thinks like this: arena1 needs to store players, time, teams (2) with players and maybe kd, but I am not sure to store it, what is the best way to do it? I think arrays, but I dont know how to write the array (how it should look)? Can you help me?
  2. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    on the class (not in a function) create a public array with
    PHP:
    public $array = ["hello""HEY""LOL"];
    and you can access it with $this->array.
    MyNameIsTriXz likes this.
  3. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    MyNameIsTriXz likes this.
  4. CrazedMiner
    Offline

    CrazedMiner Notable Member Plugin Developer

    Joined:
    Jan 31, 2015
    Posts:
    348
    Plugins:
    2
    Minecraft User:
    CrazedMinerYT
    Don't store arrays within arrays within arrays, create a class, construct it and store it to make sure it doesn't deconstruct and have all your arrays within that class, like the 1v1 plugin does.
  5. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    I know that, but how can I store things like teams in it array(teams->green,
    Can you create a template pls, I dont really understand those construct things :/
  6. CrazedMiner
    Offline

    CrazedMiner Notable Member Plugin Developer

    Joined:
    Jan 31, 2015
    Posts:
    348
    Plugins:
    2
    Minecraft User:
    CrazedMinerYT
    __construct is a magic constructor that is called when you do:
    PHP:
     new ClassName($args); 
    And it's also how you set up the arguments for the when you init the class, you can store them in variables or call other functions with them.

    Basically if you don't know what a class is, it's like another main, it has its own global variables and functions but it isnt registred as a plugin or kept track of by PocketMine itself.

    If you don't know how to do any of this, I'd suggest you go keep practising making plugins until it's more clear!
    PocketKiller likes this.
  7. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    Construct I already from my schedulers, bu I cant imagine how you create multiworld support using construct?
  8. CrazedMiner
    Offline

    CrazedMiner Notable Member Plugin Developer

    Joined:
    Jan 31, 2015
    Posts:
    348
    Plugins:
    2
    Minecraft User:
    CrazedMinerYT
    Like I said, continue making other plugins until you get the concept, there's no point in telling you if your just going to copy and paste.

Share This Page

Advertisement