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

[Request]KILL COUNTER **MUST SEE**

Comments in 'Plugin Development' started by JassperBeastHD, Oct 28, 2013.

  1. JassperBeastHD
    Offline

    JassperBeastHD Banned

    Joined:
    Aug 27, 2013
    Posts:
    436
    Minecraft User:
    JassperBeastHD
    Can someone make a kill counter like WilliamTDR LIKE THIS-->>> <Jassper{kills}> or <Jassper>{kills}:
    BYE BYE
  2. 99leonchang
    Offline

    99leonchang Staff Member Sectional Moderator

    Joined:
    Aug 23, 2013
    Posts:
    165
    Plugins:
    2
    Minecraft User:
    99leonchang
    I made something like that not too long ago
    I guess I might release it if I can find it
  3. JassperBeastHD
    Offline

    JassperBeastHD Banned

    Joined:
    Aug 27, 2013
    Posts:
    436
    Minecraft User:
    JassperBeastHD
    Plz do that would be great :)
  4. 99leonchang
    Offline

    99leonchang Staff Member Sectional Moderator

    Joined:
    Aug 23, 2013
    Posts:
    165
    Plugins:
    2
    Minecraft User:
    99leonchang
    **UPDATE: fixed player username kill displaying
    PHP:
    <?php

    /* 
    __PocketMine Plugin__ 
    name=KillCounter
    description=KillCounter
    version=1.0
    author=99leonchang
    class=KillCounter
    apiversion=9,10
    */
    class KillCounter implements Plugin{
        private 
    $api,$server;
        const 
    DEFAULT_KILLS 0;
        public function 
    __construct(ServerAPI $api$server false)
        {
            
    $this->api $api;
            
    $this->server ServerAPI::request();
        }
        public function 
    init(){
            
    $this->config = new Config($this->api->plugin->configPath($this)."config.yml"CONFIG_YAML);
            
    $this->api->addHandler("player.death", array($this"eventHandler"), 15);
            
    $this->api->addHandler("player.join", array($this"eventHandler"), 15);
            
    $this->api->addHandler("player.chat", array($this"eventHandler"), 15);
            
    $this->api->addHandler("kills.player.get", array($this"eventHandler"));
        }

        public function 
    eventHandler($data$event){
            switch(
    $event){
                case 
    "player.death":
                    if(
    is_numeric($data["cause"])){
                        
    $e $this->api->entity->get($data["cause"]);
                        
    $plr $e->name;
                        if(
    $e instanceof Entity){
                            if(
    $e->class == ENTITY_PLAYER){
                                
    $amount 1;
                                
    $targetKills $this->config->get($plr)['kills'] + $amount;
                                if(
    $targetKills 0) return false;
                                
    $this->config->set($plr, array('kills' => $targetKills));
                            }
                        }
                    }
                    break;
                case 
    "player.join":
                    
    //Registers users on first join
                    
    $target $data->username;
                    if (!
    $this->config->exists($target)) {
                        
    $this->config->set($target, array('kills' => self::DEFAULT_KILLS));
                    }
                    
    $this->config->save();
                    break;
                case 
    "player.chat":
                    
    $this->config->reload();
                    
    $name $data["player"]->username;
                    
    $messages $data["message"];
                    
    $data = array(
                        
    'username' => $name
                    
    );
                    
    $kills $this->config->get($name)['kills'];
                    
    $data = array("player" => $name"message" => str_replace(array("{DISPLAYNAME}""{MESSAGE}""{kills}"), array($name$messages$kills),  "<{DISPLAYNAME}({kills})> {MESSAGE}"));
                    if(
    $this->api->handle("KillCounter.".$event$data) !== false){
                        
    $this->api->chat->broadcast($data["message"]);
                    }
                    return 
    false;
                    break;
                case 
    "kills.player.get":
                    if (
    $this->config->exists($data['username'])) {
                        return 
    $this->config->get($data['username'])['kills'];
                    }
                    return 
    false;
            }
        }

        public function 
    __destruct() {}
    }

    Last edited: Oct 29, 2013
  5. JassperBeastHD
    Offline

    JassperBeastHD Banned

    Joined:
    Aug 27, 2013
    Posts:
    436
    Minecraft User:
    JassperBeastHD
    Om testing it :) Ill pay 10$ where can i pay?
  6. JassperBeastHD
    Offline

    JassperBeastHD Banned

    Joined:
    Aug 27, 2013
    Posts:
    436
    Minecraft User:
    JassperBeastHD
    works But do this <{Displayname}(0)>
  7. JassperBeastHD
    Offline

    JassperBeastHD Banned

    Joined:
    Aug 27, 2013
    Posts:
    436
    Minecraft User:
    JassperBeastHD
    DOESNT WOR WHEN I CHAT IT DOESNT SAY ITK
  8. 99leonchang
    Offline

    99leonchang Staff Member Sectional Moderator

    Joined:
    Aug 23, 2013
    Posts:
    165
    Plugins:
    2
    Minecraft User:
    99leonchang
    Ok I will fix ASAP
  9. Lambo
    Offline

    Lambo Notable Member Plugin Developer

    Joined:
    Sep 14, 2013
    Posts:
    431
    Plugins:
    4
    Minecraft User:
    Lambo
    It doesn't work...
  10. 99leonchang
    Offline

    99leonchang Staff Member Sectional Moderator

    Joined:
    Aug 23, 2013
    Posts:
    165
    Plugins:
    2
    Minecraft User:
    99leonchang
    I know
  11. Lambo
    Offline

    Lambo Notable Member Plugin Developer

    Joined:
    Sep 14, 2013
    Posts:
    431
    Plugins:
    4
    Minecraft User:
    Lambo
    I think
    PHP:
    $e $this->api->entity->get($data["cause"]);
    has to be $this->server->api->entity->get($data["cause"]) and
    PHP:
    $this->api->addHandler("player.death", array($this"eventHandler"), 15); 
    has to be $this->server->api[/php]
  12. 99leonchang
    Offline

    99leonchang Staff Member Sectional Moderator

    Joined:
    Aug 23, 2013
    Posts:
    165
    Plugins:
    2
    Minecraft User:
    99leonchang
    Oh, the kill counting works perfectly fine, but the username prefix thing is messed up
  13. 99leonchang
    Offline

    99leonchang Staff Member Sectional Moderator

    Joined:
    Aug 23, 2013
    Posts:
    165
    Plugins:
    2
    Minecraft User:
    99leonchang
    I have fixed the code
    I have not extensively tested it but it seems to work so far
  14. Lambo
    Offline

    Lambo Notable Member Plugin Developer

    Joined:
    Sep 14, 2013
    Posts:
    431
    Plugins:
    4
    Minecraft User:
    Lambo
    Where did you post the code?
  15. 99leonchang
    Offline

    99leonchang Staff Member Sectional Moderator

    Joined:
    Aug 23, 2013
    Posts:
    165
    Plugins:
    2
    Minecraft User:
    99leonchang
    I edited the post above with the code
  16. Lambo
    Offline

    Lambo Notable Member Plugin Developer

    Joined:
    Sep 14, 2013
    Posts:
    431
    Plugins:
    4
    Minecraft User:
    Lambo
    Oh, but the killer counter itself doesn't count kills... Atleast, not for my server.
  17. 99leonchang
    Offline

    99leonchang Staff Member Sectional Moderator

    Joined:
    Aug 23, 2013
    Posts:
    165
    Plugins:
    2
    Minecraft User:
    99leonchang
    Uh, then idk
    That's odd let me check
  18. Lambo
    Offline

    Lambo Notable Member Plugin Developer

    Joined:
    Sep 14, 2013
    Posts:
    431
    Plugins:
    4
    Minecraft User:
    Lambo
    Wait a sec. Gonna try again.
  19. Lambo
    Offline

    Lambo Notable Member Plugin Developer

    Joined:
    Sep 14, 2013
    Posts:
    431
    Plugins:
    4
    Minecraft User:
    Lambo
    Never mind. It works!
  20. Syriamanal
    Offline

    Syriamanal Ban Evader Banned

    Joined:
    Oct 2, 2013
    Posts:
    221
    Minecraft User:
    Syriamanal
    how do i use this plugin i want to use it with signs

Share This Page

Advertisement