PHP: public $kitpvp = array();public function onBlaBla(BlaBla $event){unset($this->kitpvp[$event->getPlayer()->getName()]);} Why does this not work?
And so I remove the player: PHP: public function onLeave(PlayerQuitEvent $event){unset($this->kitpvp[$event->getPlayer()->getName()]);}
Don't you see it? Your array is 0 => "JackboyPlay". The key is 0, and the value is "JackboyPlay". $array[$key] means to refer to the entry associated to $key in $array. $key is the key. In this case, you should unset($array[0]). It seems like you defined the array property using $this->kitpvp[] = $playerName, right? In that case, you are adding $playerName to the array as a value, with an automatically incrementing key. In this case, since this value is the first one, the key is int(0). The most efficient way to fix this is to use `$this->kitpvp[$playerName] = true;` instead. `true` is just a dummy value. However, I am pretty sure that you will need to store more data than just whether a player is in the array, so you may want to store some actual value instead, for example, the cached data of the player's statistics. And to check whether the player is in the array, use isset($this->kitpvp[$playerName]).
@PEMapModder I'll input the player so: PHP: if(!isset($this->kitpvp[$event->getPlayer()->getName()])){array_push($this->kitpvp, $event->getPlayer()->getName());}
Excuse me, what did I just say? http://php.net/manual/en/function.array-push.php#refsect1-function.array-push-description array_push() will push $var as the value, not the key. The key will auto-increment. You must set the player name as the key, and then just stuff anything non-null as the value. I have already explained that in the post above -- if you want to associate nothing to the value, just store true.
@PEMapModder PHP: $this->kitpvp[$event->getPlayer()->getName()] = $this->kitpvp[$event->getPlayer()->getName()]; Is that right?