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

SkyWars kills

Discussion in 'Development' started by SergeyIvanov, Jul 15, 2017.

  1. SergeyIvanov

    SergeyIvanov Witch

    Messages:
    59
    GitHub:
    sergeyivanov14
    Hi, I want to add kills of player in SkyWars by svile. How to make this?
    I need to get the players kills here:

    PHP:
       $p->sendPopup("Players:{$slot}, Kills: {HELP ME}, Time: "date('i:s', ($this->maxtime $this->time)));
    Full code:

    PHP:
        public function tick()
        {
            if (
    $this->GAME_STATE == && count($this->players) < ($this->pg->configs['needed.players.to.run.countdown'] + 0))
                return;
            
    $this->time++;

            
    //START and STOP
            
    if ($this->GAME_STATE == && $this->pg->configs['start.when.full'] && $this->slot <= count($this->players)) {
                
    $this->start();
                return;
            }
            if (
    $this->GAME_STATE && count($this->players)) {
                
    $this->stop();
                return;
            }
            if (
    $this->GAME_STATE == && $this->time >= $this->countdown) {
                
    $this->start();
                return;
            }
            if (
    $this->GAME_STATE && $this->time >= $this->maxtime) {
                
    $this->stop();
                return;
            }

            
    //Chest refill
            
    if ($this->GAME_STATE && $this->pg->configs['chest.refill'] && ($this->time $this->pg->configs['chest.refill.rate']) == 0) {
                
    $this->refillChests();
                foreach (
    $this->pg->getServer()->getLevelByName($this->world)->getPlayers() as $p) {
                    
    $p->sendMessage($this->pg->lang['game.chest.refill']);
                }
                return;
            }
            if (
    $this->GAME_STATE == 1) {       
                foreach (
    $this->pg->getServer()->getLevelByName($this->world)->getPlayers() as $p) {
                    
    $slot $this->getSlot(true);
                    
    $p->sendPopup("Players:{$slot}, Kills: {HELP ME}, Time: "date('i:s', ($this->maxtime $this->time)));
                }
                return;
            }

            
    //PvP - updates
            
    if ($this->GAME_STATE == 2) {
                if (
    $this->time <= $this->pg->configs['no.pvp.countdown'])
                    foreach (
    $this->pg->getServer()->getLevelByName($this->world)->getPlayers() as $p)
                        
    $p->sendPopup(str_replace('{COUNT}'$this->pg->configs['no.pvp.countdown'] - $this->time 1$this->pg->lang['no.pvp.countdown']));
                else
                    
    $this->GAME_STATE 1;
                return;
            }

            
    //Chat and Popup messanges
            
    if ($this->GAME_STATE == && $this->time 30 == 0) {
                foreach (
    $this->pg->getServer()->getLevelByName($this->world)->getPlayers() as $p) {
                }
            }
            if (
    $this->GAME_STATE == 0) {
                foreach (
    $this->pg->getServer()->getLevelByName($this->world)->getPlayers() as $p) {
                    
    $p->sendPopup(str_replace('{N}'date('i:s', ($this->countdown $this->time)), $this->pg->lang['popup.countdown']));
                    if ((
    $this->countdown $this->time) <= 45)
                        
    $p->getLevel()->addSound((new \pocketmine\level\sound\ButtonClickSound($p)), [$p]);
                }
            }
        }
     
  2. SkySeven

    SkySeven Baby Zombie

    Messages:
    145
    GitHub:
    SkySevenMC
    PHP:
        public function sendTopKill($player$mapname){
            
    arsort($this->kills[$mapname]);
          
            
    $names array_keys($this->kills[$mapname]);
            
    $kills array_values($this->kills[$mapname]);
            
    $player->sendMessage("§l§a» §r§eTop kills :");
            for(
    $i 0$i 3$i++){
                
    $place $i+1;
                
    $player->sendMessage("§a#".$place." §e".$names[$i]. " - ".$kills[$i]." kill(s)");
            }
        }
    I use that for a mini game plugin, you only have to adapt it x).
     
  3. SkySeven

    SkySeven Baby Zombie

    Messages:
    145
    GitHub:
    SkySevenMC
    You will translate what I said because in English I do not speak well enough , Sorry:
    Copier Coller un code n'est vraiment pas mon genre, de plus il n'y a pas beaucoup de façon de faire ça...Si tu en as une autre dis le moi...
     
  4. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    el use de offtopic forume, it is internationel
     
    SkySeven likes this.
  5. SkySeven

    SkySeven Baby Zombie

    Messages:
    145
    GitHub:
    SkySevenMC
    Hello but sorry, there are no french forums :/
     
  6. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    You can use the off-topic section. There are many good french developers in this community to assist you. You can also use google translate - it will generate broken English (but it's still English and we can figure out what you meant).
     
  7. SkySeven

    SkySeven Baby Zombie

    Messages:
    145
    GitHub:
    SkySevenMC
    I help the person who created this post, and I had trouble expressing myself correctly(sorry it's google translate)
     
  8. SkySeven

    SkySeven Baby Zombie

    Messages:
    145
    GitHub:
    SkySevenMC
    There are more simple :) :
    PHP:
    (Isset($this->kills[$p])) ? $this->kills[$p]++ : $this->kills[$p] =1;
     
  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.