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

Solved Send message to player every 10s

Discussion in 'Development' started by ItsInspire, Jan 11, 2021.

  1. ItsInspire

    ItsInspire Silverfish

    Messages:
    15
    GitHub:
    itsinspire
    Hi, How can I send message to everyone when the killer gets every 10 kills? Example: 10, 20, 30, etc...

    Here is the code that I'm trying to do it on:

    PHP:
                        if ($this->plugin->getPlayerBestStreak($killer) == 10){
                            foreach (
    $this->plugin->getServer()->getOnlinePlayers() as $players){
                                
    $ks $this->plugin->getPlayerStreak($killer);
                                
    $players->sendMessage("§b".$killer->getName()."§7 has reached a streak of §a".$ks);
                            }
                        }
    Any help is appreciated.
     
    Last edited: Jan 11, 2021
  2. RicardoMilos384

    RicardoMilos384 Slime

    Messages:
    82
    GitHub:
    ricardomilos384
    PHP:
         if (in_array($this->plugin->getPlayerBestStreak($killer), [102030etc...])){
                                
    $ks $this->plugin->getPlayerStreak($killer);
                                
    $killer->getServer()->broadcastMessage("§b".$killer->getName()."§7 has reached a streak of §a".$ks);
                            }
                        }
     
    Last edited: Jan 11, 2021
    ItsInspire likes this.
  3. ItsInspire

    ItsInspire Silverfish

    Messages:
    15
    GitHub:
    itsinspire
    But is there a way to get every ten instead of putting it in an array? This will be hard because I'll have to write all of the numbers in a array
     
  4. RicardoMilos384

    RicardoMilos384 Slime

    Messages:
    82
    GitHub:
    ricardomilos384
    Sorry i don't know how to do that
     
  5. Marabou

    Marabou Baby Zombie

    Messages:
    137
    GitHub:
    wiligangster
    PHP:
                       $ks $this->plugin->getPlayerBestStreak($killer);
                                
    $k 10;//you can change it to settings each kills per announcement.
                                
    if(($ks 0) && ($ks%$k == 0)) { 
                                   
    $killer->getServer()->broadcastMessage("§b".$killer->getName()."§7 has reached a streak of §a".$ks);
                            }
    Sorry for the ugly format I'm using my phone.
    I hope to answer your question.
     
    Last edited: Jan 11, 2021
  6. ItsInspire

    ItsInspire Silverfish

    Messages:
    15
    GitHub:
    itsinspire
    Thanks
     
  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.