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

setDifficulty

Discussion in 'Facepalm' started by Daniel23, Nov 5, 2017.

  1. Daniel23

    Daniel23 Witch

    Messages:
    65
    GitHub:
    daniel23
    if command is used /pvp off it doesnt turn off



    PHP:
    public function EnablePvP(){
      
    $plugin $this->plugin;
      
    $plugin->getServer()->setConfigInt("difficulty"1);
      
    $pk = new SetDifficultyPacket();
      
    $pk->difficulty $plugin->getServer()->getDifficulty();
      }

      public function 
    DisablePvP(){
      
    $plugin $this->plugin;
      
    $plugin->getServer()->setConfigInt("difficulty"0);
      
    $pk = new SetDifficultyPacket();
      
    $pk->difficulty $plugin->getServer()->getDifficulty();
         }
    here is when the command
    PHP:
    if($sender->isOp()){
      foreach(
    $this->plugin->getServer()->getOnlinePlayers() as $pl){
      if(
    $args[0] == "on"){
      
    $this->EnablePvP();
      }else if(
    $args[0] == "off"){
      
    $this->DisablePvP();
     
  2. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    You aren't sending the packet, are you?
     
  3. Daniel23

    Daniel23 Witch

    Messages:
    65
    GitHub:
    daniel23
  4. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    $player->dataPacket($package);
     
  5. Daniel23

    Daniel23 Witch

    Messages:
    65
    GitHub:
    daniel23
    PHP:
    if($sender->isOp()){
      foreach(
    $this->plugin->getServer()->getOnlinePlayers() as $pl){
      if(
    $args[0] == "on"){
      
    $pl->dataPacket($pk);
     
    $plugin $this->plugin;
      
    $plugin->getServer()->setConfigInt("difficulty"1);
      
    $pk = new SetDifficultyPacket();
      
    $pk->difficulty $plugin->getServer()->getDifficulty();
     
  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.