I'm stuck here Code: PHP: switch($command->getName()) { case "warn": if(isset($args[2])) { if($this->getServer()->getPlayer($args[0]) instanceof Player) { $PlayerName = $this->getServer()->getPlayer($args[0])->getName(); if($this->warnsys->get($PlayerName == true)) { //Now what? } else { $reasonsArray = array($args[1] => $args[2]); $this->warnsys->set($PlayerName, $reasonsArray); $this->warnsys->save(); } $tempMsgS = "Der Spieler '".$PlayerName."' wurde mit dem Grund '".$args[1]."' mit ".$args[2]." Punkten gewarnt! Er hat insgesamt "."TODO"." Punkte."; $tempMsgToP = TF::RED."\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n DU WURDEST VON '".$sender->getName()."' MIT DEM GRUND '".$args[1]."' mit ".$args[2]." PUNKTEN GEWARNT! DU HAST "."TODO"." PUNKTE! MIT 10 PUNKTEN WIRST DU GEBANNT!"; $args[0]->getPlayer()->sendMessage($tempMsgToP); $this->sendMsgToSender($sender, $tempMsgS); } } else {return false;} return true; break; Some additional explanation: TF = TextFormat sendMsgToSender is an function made by me (It does send an msg to the player or the console) $this->warnsys is an instance of Config Ok, this is plugin should do: /warn <PlayerName> <Reason> <Warning-Points> It already can save that for ONE TIME But then the next time what should i do that i can have unlimited Reason-Points arrays per player? (//Now what?) in the code
$this->warnsys->get($PlayerName == true) I suppose you misplaced == true? Also, == true is as good as nothing. You can omit that. Now, would you mind telling us what $this->warnsys is about?
Ok, it appears no one is understanding what i want to code and what my code does... What I want to code: Player executes /warn Player7373 Do_not_grief! 1 and /warn Player7373 Do_not_grief_again! 3 The warnsys.yml should now look like this: PHP: Player7373: "Do_not_grief!": - 1 "Do_not_grief_again!": - 3 The code I have written so far is only able to store one reason and point pack per player (For the code look above) For more info please read the initial post again!
Explain what this line is supposed to do? PHP: if($this->warnsys->get($PlayerName == true)) Now, I would just do it like this. I won't even make an if-else. PHP: $array = $this->warnsys->get($playerName, []); // return an empty array if the player has no previous warnings$array[$args[1]] = $args[2];$this->warnsys->set($playerName, $array);