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

/sw join not respond

Discussion in 'Plugin Help' started by Mochi, May 12, 2020.

  1. Mochi

    Mochi Baby Zombie

    Messages:
    113
    why I can not enter the command / sw join or quit, what happens only raises a message like in the photo??

    Code :
    PHP:
    case 'join':
                        if (!(
    count($args) < 0b11)) {
                            
    $sender->sendMessage(TextFormat::AQUA '→' TextFormat::RED 'Usage: /sw ' TextFormat::GREEN 'join [SWname]' TextFormat::GRAY ' [PlayerName]');
                            break;
                        }

                        if (isset(
    $args[0])) {
                            
    //SW NAME
                            
    $SWname TextFormat::clean(array_shift($args));
                            if (!
    array_key_exists($SWname$this->pg->arenas)) {
                                
    $sender->sendMessage(TextFormat::AQUA '→' TextFormat::RED 'Arena with name: ' TextFormat::WHITE $SWname TextFormat::RED ' doesn\'t exist');
                                break;
                            }
                        } else {
                            if (
    $sender instanceof Player) {
                                foreach (
    $this->pg->arenas as $a) {
                                    if (
    $a->join($senderfalse))
                                        break 
    2;
                                }
                                
    $sender->sendMessage(TextFormat::RED 'No games, retry later');
                            }
                            break;
                        }

                        
    $player TextFormat::clean(array_shift($args));
                        if (
    strlen($player) > && $sender instanceof \pocketmine\command\ConsoleCommandSender) {
                            
    $p $sender->getServer()->getPlayer($player);
                            if (
    $p instanceof Player) {
                                if (
    $this->pg->inArena($p->getName())) {
                                    
    $p->sendMessage(TextFormat::AQUA '→' TextFormat::RED 'You are already inside an arena');
                                    break;
                                }
                                
    $this->pg->arenas[$SWname]->join($p);
                            } else {
                                
    $sender->sendMessage(TextFormat::RED 'Player not found!');
                            }
                        } elseif (
    $sender instanceof Player) {
                            if (
    $this->pg->inArena($sender->getName())) {
                                
    $sender->sendMessage(TextFormat::AQUA '→' TextFormat::RED 'You are already inside an arena');
                                break;
                            }
                            
    $this->pg->arenas[$SWname]->join($sender);
                        } else {
                            
    $sender->sendMessage(TextFormat::RED 'Player not found!');
                        }
                        break;


                    case 
    'quit':
                        if (!empty(
    $args)) {
                            
    $sender->sendMessage(TextFormat::AQUA '→' TextFormat::RED 'Usage: /sw ' TextFormat::GREEN 'quit');
                            break;
                        }

                        if (
    $sender instanceof Player) {
                            foreach (
    $this->pg->arenas as $a) {
                                if (
    $a->closePlayer($sendertrue))
                                    break;
                            }
                        } else {
                            
    $sender->sendMessage('This command is only avaible in game');
                        }
                        break;


                    default:
                        
    //No option found, usage
                        
    $sender->sendMessage(TextFormat::AQUA '→' TextFormat::RED 'Usage: /sw [join|quit]');
                        break;


                endswitch;
                return 
    true;
            }

            
    //Searchs for a valid option
            
    switch (strtolower(array_shift($args))):
     

    Attached Files:

  2. Primus

    Primus Zombie Pigman

    Messages:
    749
    I can't seem to find the problem in the scope of this code. Could you post the full command handler or full switch statement? So we can point you in the right direction?

    Edit: The message shown in the picture isn't even sent in the code given ...
     
  3. Mochi

    Mochi Baby Zombie

    Messages:
    113
  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.