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

I don't know how to fix that

Discussion in 'Plugin Help' started by AsponPL, Jun 24, 2019.

  1. AsponPL

    AsponPL Spider Jockey

    Messages:
    47
    HELLO, i have a problem with my code, this code is for ban player but i don't know how to ban a given player because as in the console he puts in /check ban <player name> and the reason it banns me all the time player with nickname player please help me. Thanks in advance

    PHP:
                    if(isset($args[0])){
                        if(
    $args[0] == "ban"){
                        if (!(
    $sender instanceof Player)) return true;
                    
    $sender->getServer()->dispatchCommand(new ConsoleCommandSender(), "ban $sender Cheats!");
                    
    $sender->sendMessage("§c§lWas benned for cheats!");
     
  2. Gianluxx

    Gianluxx Slime

    Messages:
    94
    GitHub:
    Gianluxx
    if(isset($args[0])){
    if($args[0] == "ban"){
    if (!($sender instanceof Player)) return true;
    if(($player = $sender->getServer()->getPlayer($args[1])) != null){
    $sender->getServer()->dispatchCommand(new ConsoleCommandSender(), "ban $player Cheats!");
    }
    }
    }
     
  3. Gianluxx

    Gianluxx Slime

    Messages:
    94
    GitHub:
    Gianluxx
    Idk why you need this because you can just use /ban ....
     
  4. AsponPL

    AsponPL Spider Jockey

    Messages:
    47
    I do a plugin for Check the players This is a little complicated
     
  5. A354-PH

    A354-PH Baby Zombie

    Messages:
    186
    GitHub:
    Kizu
    PHP:
    if(isset($args[0])){
        if(
    $args[0] == "ban"){
            if(
    $sender instanceof Player) {
                
    $player $this->getServer()->getPlayer($args[1]);
                if(
    $player->isOnline()){
                    
    $sender->getServer()->dispatchCommand(new ConsoleCommandSender(), "ban " $player->getName() . " Cheats!");
                } else {
                    
    $sender->sendMessage("The player is not online!");
                }
            }
        }
    }
     
  6. AsponPL

    AsponPL Spider Jockey

    Messages:
    47
    i'm try it but i've got this error when i say "/check ban nickname"
    PHP:
    [11:20:25] [Server thread/CRITICAL]: Error"Call to a member function isOnline() on null" (EXCEPTIONin "plugins/EasyKomendy/src/EasyKomendy/Main" at line 89
     
  7. Destroyer57

    Destroyer57 Zombie

    Messages:
    275
    if($player->isOnline()!=NULL))
     
  8. AsponPL

    AsponPL Spider Jockey

    Messages:
    47
    it work only in console but when i say /check ban nickname the server was crashed

    PHP:
    [15:26:29] [Server thread/CRITICAL]: Error"Call to a member function isOnline() on null" (EXCEPTIONin "plugins/EasyKomendy/src/EasyKomendy/Main" at line 89
     
  9. Destroyer57

    Destroyer57 Zombie

    Messages:
    275
    $sender->getServer()->getNameBans()->addBan($name, $reason, null, $sender->getName());
     
  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.