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

Kick player when do spam

Comments in 'Plugin Development' started by TonyDroide, Jun 9, 2015.

  1. TonyDroide
    Offline

    TonyDroide Active Member Plugin Developer

    Joined:
    Jun 5, 2015
    Posts:
    122
    Plugins:
    1
    Minecraft User:
    TonyDroidd
    How to kick player when do spam??

    For example: when chat too fast

    (Code please.)
  2. Artide
    Offline

    Artide Active Member

    Joined:
    Apr 20, 2015
    Posts:
    214
    Minecraft User:
    Artide5
    private $last=[];
    public function onChat(PlayerChatEvent $e){$player=$event->getPlayer();$playerId=$player->getId(); // an identifier just for that playerif(isset($this->last[$playerId]) andmicrotime(true)-$this->last[$playerId] < 0.5){ // if this is not the first message the player chatted, and the last message was sent less than 0.5 second ago$event->setCancelled();$player->kick();
    return;
    }$this->last[$playerId]=microtime(true); // save the current time as the time the player last chatted}
    TonyDroide likes this.
  3. TonyDroide
    Offline

    TonyDroide Active Member Plugin Developer

    Joined:
    Jun 5, 2015
    Posts:
    122
    Plugins:
    1
    Minecraft User:
    TonyDroidd
    ill try :)
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Indentation... And missing all line breaks... Please use the [php] tag next time.
    TonyDroide likes this.

Share This Page

Advertisement