Hello, i am developing an 1vs1 plugin. The only thing that doesn't work well now, is the queue. When theres are 4 players in the queue and i transfer 2 of them to the game server, the array start looking like this: --- UHC: 1: OfficialDrixz 2: xBlitziiiPvP SOUP: [] SG: [] ARCHER: [] ... But i want, that it look like this: --- UHC: - OfficialDrixz - xBlitziiiPvP SOUP: [] SG: [] ARCHER: [] ... Here's my remove function: PHP: public function removeFromQueue(Player $p) { $pn = $p->getName(); $lobby = new Config($this->plugin->path . 'lobby.yml'); $modes = $lobby->getAll(); foreach ($modes as $mode) { if (in_array($pn, $mode)) { $n = array_diff($mode, [$pn]); $lobby->set(key($modes), $n); $lobby->save(); } next($modes); } } Does anyone know how to fix this?
Oh, i already fixed it by myself. Im now using this: PHP: public function removeFromQueue(Player $p) { $pn = $p->getName(); $lobby = new Config($this->plugin->path . 'lobby.yml'); $modes = $lobby->getAll(); foreach ($modes as $mode) { if (in_array($pn, $mode)) { /*$n = array_diff($mode, [$pn]); $lobby->set(key($modes), $n); $lobby->save();*/ $key = array_search($pn, $mode); unset($mode[$key]); $lobby->set(key($modes), array_values($mode)); $lobby->save(); } next($modes); } }
He's making a 1v1 queue, what's the point of making a config for a var that will change every sec or minute, we don't even need it when the server restarts
I'd suggest using something like redis to handle this sort of data transfer between servers as the data is constantly changing and doesn't need to be stored permanently.