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
    What is the code for kicking a player that has recently died? Also does anyone have a copy of SpawnWithItems by MinecrafterJPN?
  2. Darunia18
    Offline

    Darunia18 Staff Member Sectional Moderator

    Joined:
    Aug 23, 2013
    Posts:
    755
    Plugins:
    2
    Minecraft User:
    Darunia18
    I hope this works? I'm not 100% sure because I can no longer test these plugins on my network and I'm not 100% sure if I set $username correctly. If it doesn't work, I'll try to figure out the answer.


    PHP:
    <?php
    /*
    __PocketMine Plugin__
    name=DeathKick
    description=When a player dies, they are kicked from the server.
    version=1.0
    author=Darunia18
    class=DeathKick
    apiversion=10,11,12
    */

    class DeathKick implements Plugin {
        private 
    $api;
       
        public function 
    __construct(ServerAPI $api$server false) {
            
    $this->api $api;
        }
       
        public function 
    init() {
            
    $this->api->event("player.death", array($this"playerdeath"));
        }
       
        public function 
    playerdeath($data){
            
    $username $data->username
            $this
    ->api->console->run("kick " $username);
        }
       
        public function 
    __destruct(){
        }
    }
    ?>
    Andrey Nazarchuk and iJoshuaHD like this.
  3. jython234
    Offline

    jython234 Notable Member Plugin Developer

    Joined:
    Nov 4, 2013
    Posts:
    324
    Plugins:
    1
    Minecraft User:
    jython234
    This should work! :)
  4. Legomite
    Offline

    Legomite Active Member Plugin Developer

    Joined:
    Sep 8, 2013
    Posts:
    470
    Plugins:
    2
    Minecraft User:
    Legomite
    Syntax error. line 25
  5. Darunia18
    Offline

    Darunia18 Staff Member Sectional Moderator

    Joined:
    Aug 23, 2013
    Posts:
    755
    Plugins:
    2
    Minecraft User:
    Darunia18
    Oops sorry, forgot a semicolon :/

    PHP:
    <?php
    /*
    __PocketMine Plugin__
    name=DeathKick
    description=When a player dies, they are kicked from the server.
    version=1.0
    author=Darunia18
    class=DeathKick
    apiversion=10,11,12
    */

    class DeathKick implements Plugin {
        private 
    $api;
     
        public function 
    __construct(ServerAPI $api$server false) {
            
    $this->api $api;
        }
     
        public function 
    init() {
            
    $this->api->event("player.death", array($this"playerdeath"));
        }
     
        public function 
    playerdeath($data){
            
    $username $data->username;
            
    $this->api->console->run("kick " $username);
        }
     
        public function 
    __destruct(){
        }
    }
    ?>
  6. Legomite
    Offline

    Legomite Active Member Plugin Developer

    Joined:
    Sep 8, 2013
    Posts:
    470
    Plugins:
    2
    Minecraft User:
    Legomite
    it dosen't kick the user.
  7. Darunia18
    Offline

    Darunia18 Staff Member Sectional Moderator

    Joined:
    Aug 23, 2013
    Posts:
    755
    Plugins:
    2
    Minecraft User:
    Darunia18
    That's what I feared would happen. I'm not sure exactly how to set $username because I can't find anything. The official PocketMine wiki on GitHub has nothing and I couldn't find any plugin that used this in the way I am using it, but I'll keep looking.
  8. Darunia18
    Offline

    Darunia18 Staff Member Sectional Moderator

    Joined:
    Aug 23, 2013
    Posts:
    755
    Plugins:
    2
    Minecraft User:
    Darunia18
    Ok try this:
    PHP:
    <?php
    /*
    __PocketMine Plugin__
    name=DeathKick
    description=When a player dies, they are kicked from the server.
    version=1.0
    author=Darunia18
    class=DeathKick
    apiversion=10,11,12
    */

    class DeathKick implements Plugin {
        private 
    $api;
       
        public function 
    __construct(ServerAPI $api$server false) {
            
    $this->api $api;
        }
       
        public function 
    init() {
            
    $this->api->event("player.death", array($this"playerdeath"));
        }
       
        public function 
    playerdeath($data$event){
            
    $username $data["player"]->username;
            
    $this->api->console->run("kick " $username);
        }
       
        public function 
    __destruct(){
        }
    }
    ?>
    I think I figured out how to get the correct username this time.
  9. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    The fact is, "$playerObject" can directly toString-ize the player object
    Look at the __toString() function in Player.php
  10. LDX
    Offline

    LDX Notable Member Plugin Developer

    Joined:
    Oct 2, 2013
    Posts:
    1,434
    Plugins:
    14
    SpawnWithItems modified by me from API 9 to API 11 and 12.

    Attached Files:

  11. Legomite
    Offline

    Legomite Active Member Plugin Developer

    Joined:
    Sep 8, 2013
    Posts:
    470
    Plugins:
    2
    Minecraft User:
    Legomite
    Can you edit it so it will spawn you new items when you die? add handler player.death?
  12. LDX
    Offline

    LDX Notable Member Plugin Developer

    Joined:
    Oct 2, 2013
    Posts:
    1,434
    Plugins:
    14
    Probably. XD I'll try.
  13. Legomite
    Offline

    Legomite Active Member Plugin Developer

    Joined:
    Sep 8, 2013
    Posts:
    470
    Plugins:
    2
    Minecraft User:
    Legomite
    What the heck does XD mean? I ALWAYS SEE IT AND IT CONFUSES ME!!! XDo_Oo_Oo_O
  14. LDX
    Offline

    LDX Notable Member Plugin Developer

    Joined:
    Oct 2, 2013
    Posts:
    1,434
    Plugins:
    14
    It's a smiley. XD X is two eyes closed, and D is an open super happy mouth. XD
  15. LDX
    Offline

    LDX Notable Member Plugin Developer

    Joined:
    Oct 2, 2013
    Posts:
    1,434
    Plugins:
    14
    See if this works.

    Attached Files:

  16. Legomite
    Offline

    Legomite Active Member Plugin Developer

    Joined:
    Sep 8, 2013
    Posts:
    470
    Plugins:
    2
    Minecraft User:
    Legomite
    Thanks I will look into it! (Im not at my computer right now so I have to install it through a very laggy ios app called pocketcloud) Arrghh! Icons to tiny!
  17. LDX
    Offline

    LDX Notable Member Plugin Developer

    Joined:
    Oct 2, 2013
    Posts:
    1,434
    Plugins:
    14
  18. Legomite
    Offline

    Legomite Active Member Plugin Developer

    Joined:
    Sep 8, 2013
    Posts:
    470
    Plugins:
    2
    Minecraft User:
    Legomite
    Is ther a way to not add the same items if something is already in your inventory? example( If you have meat in your inventory the plugin won't add another piece of meat.)
  19. LDX
    Offline

    LDX Notable Member Plugin Developer

    Joined:
    Oct 2, 2013
    Posts:
    1,434
    Plugins:
    14
    Dude it's 2 AM here and your asking me to think?? Lol
  20. LDX
    Offline

    LDX Notable Member Plugin Developer

    Joined:
    Oct 2, 2013
    Posts:
    1,434
    Plugins:
    14
    Yes no maybe i dont know. (No Malcome in the middle quote intended.)

Share This Page

Advertisement