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

Code error :(!

Comments in 'Plugin Development' started by MrReskill, Apr 1, 2016.

  1. MrReskill
    Offline

    MrReskill New Member

    Joined:
    Sep 21, 2015
    Posts:
    29
    Minecraft User:
    MrReskillYT
    Hello,
    I made a small code but its not working normally should prohibits spoken worldwide pvp--
    Code:
    public function onPlayerChat(PlayerChatEvent $e){    
    if($player->getLevel()->getName() == "pvp--"){
    $e->getPlayer()->sendMessage("§cTchat temporairement désactivé.");
    $e->setCancelled(true);
    }  
    }
    Thanks.
  2. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    PHP:
    class Main extends PluginBase implements Listener {

     public function 
    onEnable(){
      
    $this->getServer()->getPluginManager()->registerEvents($this$this); 
    }

    public function 
    onPlayerChat(PlayerChatEvent $e){   
       if(
    $player->getLevel()->getName() == "pvp--"){
       
    $e->getPlayer()->sendMessage("§cTchat temporairement désactivé."); 
       
    $e->setCancelled(true);


    }
  3. Nawaf_Craft1b
    Offline

    Nawaf_Craft1b Active Member Plugin Developer

    Joined:
    May 8, 2015
    Posts:
    232
    Plugins:
    1
    Minecraft User:
    Nawaf_Craft1b
    PHP:
    public function onPlayerChat(PlayerChatEvent $e){
    if(
    $e->getPlayer()->getLevel()->getName() == "pvp--"){
    $e->getPlayer()->sendMessage("§cTchat temporairement désactivé.");
    $e->setCancelled(true);
    }
    }
    Last edited: Apr 1, 2016
  4. MrReskill
    Offline

    MrReskill New Member

    Joined:
    Sep 21, 2015
    Posts:
    29
    Minecraft User:
    MrReskillYT
    I already write this code (Im french)
  5. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    Dump the level name to see if it is really the right level, when your level is downloaded then use getFolderName(), because it doesnt return the name in the level.dat folder, which doesnt get changed when you change the folder name
  6. MCPEPIG
    Offline

    MCPEPIG Notable Member

    Joined:
    Jun 22, 2014
    Posts:
    349
    Minecraft User:
    MCPEPIG
    $player isn't defined.

Share This Page

Advertisement