1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Solved Queue bug

Discussion in 'Development' started by SkyZone, Dec 3, 2017.

  1. SkyZone

    SkyZone Slime

    Messages:
    95
    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?
     
    Last edited: Dec 3, 2017
  2. SkyZone

    SkyZone Slime

    Messages:
    95
    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);
            }
        }
     
  3. friscowz

    friscowz Baby Zombie Ban Evader Banned

    Messages:
    128
    GitHub:
    friscowzmcpe
    Who tf use a Config for Queue ????
     
  4. SkyZone

    SkyZone Slime

    Messages:
    95
    me lol
     
  5. friscowz

    friscowz Baby Zombie Ban Evader Banned

    Messages:
    128
    GitHub:
    friscowzmcpe
    You shouldn't dude
     
  6. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    Why not?
     
    EdwardHamHam likes this.
  7. friscowz

    friscowz Baby Zombie Ban Evader Banned

    Messages:
    128
    GitHub:
    friscowzmcpe
    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
     
    jasonwynn10 likes this.
  8. SkyZone

    SkyZone Slime

    Messages:
    95
    Maybe i have multiple lobbyservers?
     
  9. friscowz

    friscowz Baby Zombie Ban Evader Banned

    Messages:
    128
    GitHub:
    friscowzmcpe
    Maybe it doesn't matters ?
     
  10. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    The queue system would need a file or a database for the queue data to be shared between the servers
     
  11. Jack Noordhuis

    Jack Noordhuis Zombie Pigman Poggit Reviewer

    Messages:
    618
    GitHub:
    JackNoordhuis
    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.
     
  12. friscowz

    friscowz Baby Zombie Ban Evader Banned

    Messages:
    128
    GitHub:
    friscowzmcpe
    Thanks i didn't hear about it before :eek:
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.