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

[New API] Store a variable to specified player

Comments in 'Plugin Development' started by Adaasi, Sep 8, 2014.

  1. Adaasi
    Offline

    Adaasi Active Member

    Joined:
    Aug 14, 2014
    Posts:
    80
    Can I store a variable to a specified player?
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    You should make an array and store the variable to the array with the key as the player's name or entity ID.
    64FF00, Dutok and Adaasi like this.
  3. Adaasi
    Offline

    Adaasi Active Member

    Joined:
    Aug 14, 2014
    Posts:
    80
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Remember, it has to be an array field.
    64FF00 likes this.
  5. EkiFoX
    Offline

    EkiFoX Active Member Plugin Developer

    Joined:
    Feb 28, 2014
    Posts:
    95
    Plugins:
    2
    Minecraft User:
    ekifox
    emm... create an array, add a key by player name...
    example:
    $array = [];
    $array[$player->getName()] = "Example";
    echo $array[$player->getName()]; //Example
    Adaasi likes this.
  6. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    The $array should be declared outside.
    64FF00 and Tuff like this.
  7. EkiFoX
    Offline

    EkiFoX Active Member Plugin Developer

    Joined:
    Feb 28, 2014
    Posts:
    95
    Plugins:
    2
    Minecraft User:
    ekifox
    :eek: (facepalm).
    Array "$array" can be added in anywhere of function.
  8. Tuff
    Offline

    Tuff Active Member

    Joined:
    Jan 25, 2014
    Posts:
    203
    Minecraft User:
    Roboroug2
    So it can be called in other functions.?
  9. EkiFoX
    Offline

    EkiFoX Active Member Plugin Developer

    Joined:
    Feb 28, 2014
    Posts:
    95
    Plugins:
    2
    Minecraft User:
    ekifox
    Noup, but in one "function" it can be function. (c)
  10. Tuff
    Offline

    Tuff Active Member

    Joined:
    Jan 25, 2014
    Posts:
    203
    Minecraft User:
    Roboroug2
    ? After the class deceleration.

    Public $var

    Then you can use it anywhere in the plugin with: $this->var
  11. EkiFoX
    Offline

    EkiFoX Active Member Plugin Developer

    Joined:
    Feb 28, 2014
    Posts:
    95
    Plugins:
    2
    Minecraft User:
    ekifox
    I write, anywhere in one function...

    If u need use var in anywhere of plugin, u can create a var by OOP.
  12. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Yes, but he wants to store the variable, and normally he only has one player in his function so saving a local variable is pointless.
    64FF00 and EkiFoX like this.
  13. EkiFoX
    Offline

    EkiFoX Active Member Plugin Developer

    Joined:
    Feb 28, 2014
    Posts:
    95
    Plugins:
    2
    Minecraft User:
    ekifox
    Okay =\

Share This Page

Advertisement