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

Funcion de kick al jugador.

Discussion in 'Development' started by Brian Medina, Feb 18, 2017.

  1. Brian Medina

    Brian Medina Spider Jockey

    Messages:
    27
    GitHub:
    NintendoCore16
    Como hacer que se kick a algun jugador que entre si el numero de jugadores en linea es = al de una config

    <?php
    #Creado por NintendoCore16
    namespace NintendoCore16;

    use pocketmine\event\Listener;
    use pocketmine\event\player\PlayerLoginEvent;
    use pocketmine\plugin\PluginBase;
    use pocketmine\utils\TextFormat as c;
    use pocketmine\utils\Config;
    use pocketmine\event\player\PlayerKickEvent;
    use pocketmine\event\player\PlayerJoinEvent;
    use pocketmine\event\player;

    class MainSlots extends PluginBase implements Listener
    {

    public function onEnable()
    {
    $this->getServer()->getPluginManager()->registerEvents($this, $this);
    $this->getServer()->getLogger()->info(c::AQUA . "PLUGIN ACTIVADO");
    @mkdir($this->getDataFolder());
    $this->saveResource("config.yml");
    $this->Config = new Config($this->getDataFolder() . "config.yml", Config::YAML);
    }

    public function onPlayerKick(PlayerKickEvent $event)
    {
    if ($event->getReason() === "disconnectionScreen.serverFull") {
    $event->setCancelled("true");
    }
    }

    public function onPlayerJoin(PlayerJoinEvent $event){
    if($this->getServer()->getOnlinePlayers() == 1){
    $event->getPlayer()->kick("example kick");
    }
    }
    }
     
  2. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    Either use the international forums or translate your post. Please explain any issues you have with your current code. Also, please use PHP tags around your code to make it easier to read.
     
  3. Marabou

    Marabou Baby Zombie

    Messages:
    137
    GitHub:
    wiligangster
    PHP:
    <?php
    #Creado por NintendoCore16
    namespace NintendoCore16;

    use 
    pocketmine\event\Listener;
    use 
    pocketmine\event\player\PlayerLoginEvent;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\utils\TextFormat as c;
    use 
    pocketmine\utils\Config;
    use 
    pocketmine\event\player\PlayerKickEvent;
    use 
    pocketmine\event\player\PlayerJoinEvent;
    use 
    pocketmine\event\player;

    class 
    MainSlots extends PluginBase implements Listener
    {

        public function 
    onEnable()
        {
            
    $this->getServer()->getPluginManager()->registerEvents($this$this);
            
    $this->getServer()->getLogger()->info(c::AQUA "PLUGIN ACTIVADO");
            @
    mkdir($this->getDataFolder());
            
    $this->saveResource("config.yml");
            
    $this->Config = new Config($this->getDataFolder() . "config.yml"Config::YAML);
        }

        public function 
    onPlayerKick(PlayerKickEvent $event)
        {
            if (
    $event->getReason() === "disconnectionScreen.serverFull") {
                
    $event->setCancelled("true");
            }
        }

        public function 
    onPlayerJoin(PlayerJoinEvent $event){
            if(
    count($this->getServer()->getOnlinePlayers()) === 1){ //added count()
                
    $event->getPlayer()->kick("example kick");
            }
        }
    }
     
  4. Brian Medina

    Brian Medina Spider Jockey

    Messages:
    27
    GitHub:
    NintendoCore16
    error help pls

    Tesseract Crash Dump Sun Feb 19 06:57:42 CET 2017

    Error: Call to a member function sendContents() on null
    File: /src/pocketmine/Player
    Line: 1041
    Type: notice

    Code:
    [1032] if($this->getHealth() <= 0){
    [1033] $pk = new RespawnPacket();
    [1034] $pos = $this->getSpawn();
    [1035] $pk->x = $pos->x;
    [1036] $pk->y = $pos->y;
    [1037] $pk->z = $pos->z;
    [1038] $this->dataPacket($pk);
    [1039] }
    [1040]
    [1041] $this->inventory->sendContents($this);
    [1042] $this->inventory->sendArmorContents($this);
    [1043] }
    [1044]
    [1045] protected function orderChunks(){
    [1046] if($this->connected === false){
    [1047] return false;
    [1048] }
    [1049]
    [1050] Timings::$playerChunkOrderTimer->startTiming();
    [1051]

    Backtrace:
    #0 /src/pocketmine/Player(1867): pocketmine\Player->sendNextChunk(boolean)
    #1 /src/pocketmine/Server(2710): pocketmine\Player->checkNetwork(boolean)
    #2 /src/pocketmine/Server(2427): pocketmine\Server->tick(boolean)
    #3 /src/pocketmine/Server(2306): pocketmine\Server->tickProcessor(boolean)
    #4 /src/pocketmine/Server(1842): pocketmine\Server->start(boolean)
    #5 /src/pocketmine/PocketMine(452): pocketmine\Server->__construct(pocketmine\CompatibleClassLoader object, pocketmine\utils\MainLogger object, string phar:///home/gs/gs/data/servers/5394019/Tesseract_1.1.0_2017-02-09_06-15-02.phar/, string /home/gs/gs/data/servers/5394019/, string /home/gs/gs/data/servers/5394019/plugins/, string unknown)
    #6 (1): require_once(string phar:///home/gs/gs/data/servers/5394019/Tesseract_1.1.0_2017-02-09_06-15-02.phar/src/pocketmine/PocketMine.php)

    Tesseract version: 0000000000000000000000000000000000000000 [Protocol 101; API 3.0.0]
    uname -a: Linux fr5.server.pro 3.14.32-xxxx-grs-ipv6-64 #1 SMP Sat Feb 7 11:35:27 CET 2015 x86_64
    PHP version: 7.0.9
    Zend version: 3.0.0
    OS : Linux, linux

    Server uptime: 24 seconds
    Number of loaded worlds: 1
    Players online: 0/5

    Loaded plugins:
    Slots 1 by NintendoCore16 for API(s) 1.0.0, 2.0.0, 3.0.0, 3.0.0-ALPHA1, 3.0.0-ALPHA2, 3.0.0-ALPHA3, 3.0.0-ALPHA4
     
  5. InspectorGadget

    InspectorGadget Zombie Pigman

    Messages:
    462
    GitHub:
    InspectorGadget
    WE DON'T GIVE SUPPORT FOR TESSERACT!
     
  6. InspectorGadget

    InspectorGadget Zombie Pigman

    Messages:
    462
    GitHub:
    InspectorGadget
  7. InspectorGadget

    InspectorGadget Zombie Pigman

    Messages:
    462
    GitHub:
    InspectorGadget
    Quieren que hables inglés. Btw, lo que está mal con el jugador Kick.
     
  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.