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

Solved is not the problem

Comments in 'Plugin Development' started by Praxthisnovcht, Oct 1, 2015.

  1. Praxthisnovcht
    Offline

    Praxthisnovcht Notable Member Plugin Developer

    Joined:
    Mar 10, 2014
    Posts:
    699
    Plugins:
    4
    Minecraft User:
    PraxHellTag
    Hi guys,
    it's been a while since I stopped her and I just came back and here's the problem

    Code:
    [13:42:21] [Server thread/CRITICAL]: "Could not pass event 'pocketmine\event\player\PlayerQuitEvent' to 'Skywars-Pro v1.0.0': Undefined index: Praxthisnovcht on Skywars\Main
    [13:42:21] [Server thread/NOTICE]: ArrayOutOfBoundsException: "Undefined index: Praxthisnovcht" (E_NOTICE) in "/Skywars-Pro_v1.0.0/src/Skywars/Main" at line 878
    

    PHP:
        public function onPlayerQuit(PlayerQuitEvent $event){
            
    $player $event->getPlayer()->getName();
            
    $p $event->getPlayer();
                
    $id $this->gamePlayers[$player]; # Lines 878 ERROR
                
    --$this->playersInArena[$id];
                for(
    $n 1$n <=4$n++) {  
                    if(isset(
    $this->pod[$id "-" $n]) && $this->pod[$id "-" $n] == $player) {
                        unset(
    $this->pod[$id "-" $n]);
                    }
                }
        }
  2. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Maybe var_dump the $this->gamePlayers?
  3. TryoneLegendZzz
    Offline

    TryoneLegendZzz Active Member

    Joined:
    May 31, 2015
    Posts:
    201
    Minecraft User:
    SavionLegendZzz
    PHP:
    isset($this->gamePlayers[$player]);
    ???
    Praxthisnovcht likes this.
  4. HotFireyDeath
    Offline

    HotFireyDeath Notable Member Plugin Developer

    Joined:
    Mar 19, 2015
    Posts:
    328
    Plugins:
    1
    Minecraft User:
    HotFireyDeath
    Is $player set with a value in the array $gamePlayers ?

    That error is caused because $gamePlayers[$player] isn't indexed in the array. I believe.
  5. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    The problem is that $player isn't in the array. Show the full code so we know what your doing.
  6. TryoneLegendZzz
    Offline

    TryoneLegendZzz Active Member

    Joined:
    May 31, 2015
    Posts:
    201
    Minecraft User:
    SavionLegendZzz
    i am taking a guess my post fixed it because he liked it :)
    Praxthisnovcht and HotFireyDeath like this.
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    PlayerJoinEvent, PlayerLoginEgent and even PlayerPreLoginEvent may not be fired before PlayerQuitEvent if player quits before he correctly joins. For example, if he joins with an invalid name.

Share This Page

Advertisement