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

Error in my plugin!

Comments in 'Plugin Development' started by JackboyPlay, Mar 24, 2016.

  1. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    Hello I have an error
    PHP:
    WarningInvalid argument supplied for foreach() in /root/benhosting/plugins/QSG/src/JackboyPlay/QuickSG/Main.php on line 646
    Line 646
    PHP:
    $map2 = array();

    646 foreach($this->getOwner()->map2 as $name1 => $player){
    647  $player->sendPopup("§eStart in §a" $this->map2zeit " §eSekunde[n]");
    648  }
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    What is the value of $this->getOwner()->map2? var_dump($this->getOwner()->map2)
    applqpak likes this.
  3. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    Playernames
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    If it is indeed an array at the moment you run that line, it won't throw that error.
    applqpak likes this.
  5. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Then why are you trying to call function sendPopup() on string?
    applqpak likes this.
  6. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    I try to make
    PHP:
     $this->getServer()->getPlayer($this->getOwner()->map1)->sendPopup(); 
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    So is $this->getOwner()->map1 a string or an array :/
    applqpak likes this.
  8. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    I'll answer in german to bring this conversation a bit forward.

    Kannst du mal vor "foreach($this->getOwner()->map2 as $name1 => $player){" das hier machen:
    var_dump($this->getOwner()->map2);

    Dann können wir in der Konsole sehen, was für ein typ die Variable hat.
    Danke!
  9. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Please use English in every post in the main forums. If you don't want to use English, use a PM to translate it for an individual.
    applqpak and Vaivez66 like this.
  10. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    @PEMapModder
    PHP:

    Notice
    Undefined propertyJackboyPlay\QuickSG\Main::$map2 in /root/benhosting/plugins/QSG/src/JackboyPlay/QuickSG/Main.php on line 646 
    Last edited: Mar 24, 2016
  11. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    What is if I don't understand german?
  12. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    that means there is no such variable.
    As long as you don't call the $map2 in a task or so, idk why you should even use getOwner.
    Try $this->map2
  13. minebuilder0110
    Offline

    minebuilder0110 Notable Member

    Joined:
    Dec 8, 2014
    Posts:
    485
    Minecraft User:
    Apparitional
    I'm pretty sure there is a function to check if it is a string or not.
    applqpak likes this.
  14. applqpak
    Offline

    applqpak Active Member Plugin Developer

    Joined:
    Dec 16, 2015
    Posts:
    284
    Plugins:
    1
    Minecraft User:
    applqpak
    PHP:
    is_string();
    minebuilder0110 likes this.
  15. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
  16. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    applqpak likes this.

Share This Page

Advertisement