Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to kick players on death and a SpawnWithItems plugin.

Comments in 'Plugin Development' started by Legomite, Jan 18, 2014.

  1. Legomite
    Offline

    Legomite Active Member Plugin Developer

    Joined:
    Sep 8, 2013
    Posts:
    470
    Plugins:
    2
    Minecraft User:
    Legomite
    I won the Hunger games 2 times straight! 5 altogether!
  2. LDX
    Offline

    LDX Notable Member Plugin Developer

    Joined:
    Oct 2, 2013
    Posts:
    1,397
    Plugins:
    14
    Idk just ask me about swi tomorrow
  3. LDX
    Offline

    LDX Notable Member Plugin Developer

    Joined:
    Oct 2, 2013
    Posts:
    1,397
    Plugins:
    14
  4. Legomite
    Offline

    Legomite Active Member Plugin Developer

    Joined:
    Sep 8, 2013
    Posts:
    470
    Plugins:
    2
    Minecraft User:
    Legomite
    I can't,on a friends computer that's volume is broken.
  5. Legomite
    Offline

    Legomite Active Member Plugin Developer

    Joined:
    Sep 8, 2013
    Posts:
    470
    Plugins:
    2
    Minecraft User:
    Legomite
    NOOO!!!!
  6. LDX
    Offline

    LDX Notable Member Plugin Developer

    Joined:
    Oct 2, 2013
    Posts:
    1,397
    Plugins:
    14
    Must... sleep..
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    @LDX can you post the scripts directly using
    Code:
    [php][/php]
    instead of uploading files?
  8. LDX
    Offline

    LDX Notable Member Plugin Developer

    Joined:
    Oct 2, 2013
    Posts:
    1,397
    Plugins:
    14
    I can, but then I can't reread my code because I'm on Android right now and using my text editing app and uploading files is much easier then typing code in this glitchy form box. :p
  9. LDX
    Offline

    LDX Notable Member Plugin Developer

    Joined:
    Oct 2, 2013
    Posts:
    1,397
    Plugins:
    14
    Code boxes cut off the ends of lines on Android.
  10. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Doesn't occur to me...
  11. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    I am using Nexus 4 and it is a lot of trouble to choose the app I want to use to upload my files.
  12. InusualZ
    Offline

    InusualZ Active Member Plugin Developer

    Joined:
    Aug 23, 2013
    Posts:
    218
    Plugins:
    1
    Minecraft User:
    Inusu4lZ
    You could do,
    PHP:
    //$data is the player object
    $data->close();
  13. Nautox
    Offline

    Nautox Banned

    Joined:
    Mar 29, 2014
    Posts:
    8
    Minecraft User:
    Nautox
    This one is tested and works ;) //remove respawn.handler
    PHP:
    <?php
    /*
    __PocketMine Plugin__
    name=kickbydeath
    description=Toggles if a player will be kicked after his death
    version=0.1
    author=Nautox
    class=kickplayer
    apiversion=11,12
    */
       
    class kickplayer implements Plugin{
        private 
    $api;

        private 
    $kickp false;

        public function 
    __construct(ServerAPI $api$server false){
            
    $this->api $api;
            
    $this->server ServerAPI::request();
        }

        public function 
    init(){
            
    $this->api->addHandler("player.death", array($this"eventHandler"), 100);
            
    $this->api->console->register("kickp""Toggles if a player will be kicked after his death", array($this"kicksettings"));
       
            
    $this->config = new Config($this->api->plugin->configPath($this)."config.yml"CONFIG_YAML, array(
                
    "kickplayers" => true,
                ));
       
            
    $this->kickplayers $this->config->get('kickplayers');
            
    $this->config->reload();
            
    console("Kickbydeath is now running!");
        }

        public function 
    __destruct()
        {
        }

        public function 
    eventHandler($data$event)
        {
            switch(
    $event)
            {
                case 
    "player.death":
                    if(
    $this->kickplayers == true)
                    {
                        
    $data['player']->close();
                    }
                    break;
            }
        }


        public function 
    kicksettings($cmd$params$issuer$alias){

        if(
    $cmd "kickp")
        {

        switch(
    array_shift($params)){
                case 
    "":
                    
    $output "/kickp <on/off>";
                    break;
                case 
    "on":
                    
    $this->kickplayers true;
                    break;
                case 
    "off":
                    
    $this->kickplayers false;
                    break;
            }
       
            return 
    $output;

        }

        }

    }
    Last edited: Mar 30, 2014
    PEMapModder likes this.
  14. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Remove the respawn handler. The data for respawn is directly a Player object, not an array.
  15. Nautox
    Offline

    Nautox Banned

    Joined:
    Mar 29, 2014
    Posts:
    8
    Minecraft User:
    Nautox
    Ok thank you for the correction! :)

Share This Page

Advertisement