In this code, normally i must get all player online name but they won't work on the 3 player online the DropDown only shows 1 PHP: if($data === 2){ $pk = new ModalFormRequestPacket(); $form = array(); foreach($this->getServer()->getOnlinePlayers() as $online){ $name = $online->getName(); } $form["title"] = "Members"; $form["type"] = "custom_form"; $form["content"] = [["type" => "dropdown", "text" => "Selectionez le joueur que vous vouliez rejoindre", "options" => ["{$name}"]]]; $pk->formId = 40; $pk->formData = json_encode($form); $player->dataPacket($pk); } } if($id === 40){ if($data === Null){ $player->sendMessage("null"); } if($data === 0){ $player->sendMessage("0"); } if($data === 1){ $player->sendMessage("1"); } if($data === 2){ $player->sendMessage("2"); } if($data === 3){ $player->sendMessage("3"); }
Simple enough. With this, you're redefining the name to a new name every time: PHP: foreach($this->getServer()->getOnlinePlayers() as $online){ $name = $online->getName();} Instead, create an array, and push each name to the array, like so: PHP: $name = array();foreach($this->getServer()->getOnlinePlayers() as $online){ array_push($name, $online->getName());} Then, if there are three players online with the names 'John', 'Fred' and 'George', $name will end up equalling the array ['John', 'Fred', 'George'] OPTIONALLY If you just want the names as a string, you could add each new name to its own line, like so: PHP: $name = '';foreach($this->getServer()->getOnlinePlayers() as $online){ $name .= '\n' . $online->getName();} Other devs please correct me if I'm wrong. Haven't messed with PHP for a while.