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

Fatal error: Call to undefined method HG\Main::sendToAll()

Comments in 'Plugin Development' started by tigerza118, Jun 8, 2015.

  1. tigerza118
    Offline

    tigerza118 Active Member

    Joined:
    Jan 31, 2015
    Posts:
    100
    Minecraft User:
    tigerza117
    Fatal error: Call to undefined method HG\Main::sendToAll() in /home/pm/HGtest/plugins/HG-Fixed/src/HG/Main.php on line 1162
    PHP:
                            if(count($this->players)>=6)
                            {
                                
    $event->getPlayer()->sendMessage("[{$this->getConfig()->get("prefix")}]The match is full.");
                                return;
                            }
                            
    $this->sendToAll("[{$this->getConfig()->get("prefix")}]" .$event->getPlayer()->getName(). " joined the match.");
                            
    $this->players[$event->getPlayer()->getName()]=array("id"=>$event->getPlayer()->getName());
                            
    $event->getPlayer()->sendMessage(TextFormat::BLUE"[{$this->getConfig()->get("prefix")}]You have joined the match!");
                            if(
    $this->gameStatus==&& count($this->players)>=2)
  2. Lambo
    Offline

    Lambo Notable Member Plugin Developer

    Joined:
    Sep 14, 2013
    Posts:
    431
    Plugins:
    4
    Minecraft User:
    Lambo
    What is the sendToAll function?
  3. tigerza118
    Offline

    tigerza118 Active Member

    Joined:
    Jan 31, 2015
    Posts:
    100
    Minecraft User:
    tigerza117
    PHP:
        public function playerBlockTouch(PlayerInteractEvent $event){
            
    $player=$event->getPlayer();
            
    $username=$player->getName();
            
    $block=$event->getBlock();
            
    $levelname=$player->getLevel()->getFolderName();
            if(isset(
    $this->SetStatus[$username]))
            {
                switch (
    $this->SetStatus[$username])
                {
                case 
    0:
                    if(
    $event->getBlock()->getID() != 63 && $event->getBlock()->getID() != 68)
                    {
                        
    $player->sendMessage(TextFormat::GREEN."[HG]please choose a sign to click on");
                        return;
                    }
  4. iJoshuaHD
    Offline

    iJoshuaHD Notable Member Plugin Developer

    Joined:
    Nov 7, 2013
    Posts:
    1,196
    Plugins:
    4
    Minecraft User:
    iJoshuaHD
    this is not a sendToAll function o_O
  5. tigerza118
    Offline

    tigerza118 Active Member

    Joined:
    Jan 31, 2015
    Posts:
    100
    Minecraft User:
    tigerza117
    PHP:
    public function playerBlockTouch(PlayerInteractEvent $event){
    $player=$event->getPlayer();
    $username=$player->getName();
    $block=$event->getBlock();
    $levelname=$player->getLevel()->getFolderName();
    if(isset(
    $this->SetStatus[$username]))
    {
    switch (
    $this->SetStatus[$username])
    {
    case 
    0:
    if(
    $event->getBlock()->getID() != 63 && $event->getBlock()->getID() != 68)
    {
    $player->sendMessage(TextFormat::GREEN."[HG]please choose a sign to click on");
    return;
    }
    $this->sign=array(
    "x" =>$block->getX(),
    "y" =>$block->getY(),
    "z" =>$block->getZ(),
    "level" =>$levelname);
    $this->config->set("sign",$this->sign);
    $this->config->save();
    $this->SetStatus[$username]++;
    $player->sendMessage(TextFormat::GREEN."Sign for condition has been created.");
    $player->sendMessage(TextFormat::GREEN."Please click on the 1st spawnpoint.");
    $this->signlevel=$this->getServer()->getLevelByName($this->config->get("sign")["level"]);
    $this->sign=new Vector3($this->sign["x"],$this->sign["y"],$this->sign["z"]);
    $this->changeStatusSign();
    break;
    case 
    1:
    $this->pos1=array(
    "x" =>$block->x,
    "y" =>$block->y,
    "z" =>$block->z,
    "level" =>$levelname);
    $this->config->set("pos1",$this->pos1);
    $this->config->save();
    $this->SetStatus[$username]++;
    $player->sendMessage(TextFormat::GREEN."Spawnpoint 1 created!");
    $player->sendMessage(TextFormat::GREEN."Please click on the 2nd spawnpoint.");
    $this->pos1=new Vector3($this->pos1["x"]+0.5,$this->pos1["y"],$this->pos1["z"]+0.5);
    break;
    case 
    2:
    $this->pos2=array(
    "x" =>$block->x,
    "y" =>$block->y,
    "z" =>$block->z,
    "level" =>$levelname);
    $this->config->set("pos2",$this->pos2);
    $this->config->save();
    $this->SetStatus[$username]++;
    $player->sendMessage(TextFormat::GREEN."Spawnpoint 2 created!");
    $player->sendMessage(TextFormat::GREEN."Please click on the 3rd spawnpoint.");
    $this->pos2=new Vector3($this->pos2["x"]+0.5,$this->pos2["y"],$this->pos2["z"]+0.5);
    break;
    case 
    3:
    $this->pos3=array(
    "x" =>$block->x,
    "y" =>$block->y,
    "z" =>$block->z,
    "level" =>$levelname);
    $this->config->set("pos3",$this->pos3);
    $this->config->save();
    $this->SetStatus[$username]++;
    $player->sendMessage(TextFormat::GREEN."Spawnpoint 3 created!");
    $player->sendMessage(TextFormat::GREEN."Please click on the 4th spawnpoint");
    $this->pos3=new Vector3($this->pos3["x"]+0.5,$this->pos3["y"],$this->pos3["z"]+0.5);
    break;
    case 
    4:
    $this->pos4=array(
    "x" =>$block->x,
    "y" =>$block->y,
    "z" =>$block->z,
    "level" =>$levelname);
    $this->config->set("pos4",$this->pos4);
    $this->config->save();
    $this->SetStatus[$username]++;
    $player->sendMessage(TextFormat::GREEN."Spawnpoint 4 created!");
    $player->sendMessage(TextFormat::GREEN."Please click on the 5th spawnpoint.");
    $this->pos4=new Vector3($this->pos4["x"]+0.5,$this->pos4["y"],$this->pos4["z"]+0.5);
    break;
    case 
    5:
    $this->pos5=array(
    "x" =>$block->x,
    "y" =>$block->y,
    "z" =>$block->z,
    "level" =>$levelname);
    $this->config->set("pos5",$this->pos5);
    $this->config->save();
    $this->SetStatus[$username]++;
    $player->sendMessage(TextFormat::GREEN."Spawnpoint 5 created!");
    $player->sendMessage(TextFormat::GREEN."Please click on the 6th spawnpoint.");
    $this->pos5=new Vector3($this->pos5["x"]+0.5,$this->pos5["y"],$this->pos5["z"]+0.5);
    break;
    case 
    6:
    $this->pos6=array(
    "x" =>$block->x,
    "y" =>$block->y,
    "z" =>$block->z,
    "level" =>$levelname);
    $this->config->set("pos6",$this->pos6);
    $this->config->save();
    $this->SetStatus[$username]++;
    $player->sendMessage(TextFormat::GREEN."Spawnpoint 6 created!");
    $player->sendMessage(TextFormat::GREEN."Please click on the 7th spawnpoint.");
    $this->pos6=new Vector3($this->pos6["x"]+0.5,$this->pos6["y"],$this->pos6["z"]+0.5);
    break;
    case 
    7:
    $this->pos7=array(
    "x" =>$block->x,
    "y" =>$block->y,
    "z" =>$block->z,
    "level" =>$levelname);
    $this->config->set("pos7",$this->pos7);
    $this->config->save();
    $this->SetStatus[$username]++;
    $player->sendMessage(TextFormat::GREEN."Spawnpoint 7 created!");
    $player->sendMessage(TextFormat::GREEN."Please click on the 8th spawnpoint.");
    $this->pos7=new Vector3($this->pos7["x"]+0.5,$this->pos7["y"],$this->pos7["z"]+0.5);
    break;
    case 
    8:
    $this->pos8=array(
    "x" =>$block->x,
    "y" =>$block->y,
    "z" =>$block->z,
    "level" =>$levelname);
    $this->config->set("pos8",$this->pos8);
    $this->config->save();
    $this->SetStatus[$username]++;
    $player->sendMessage(TextFormat::GREEN."Spawnpoint 8 created!");
    $player->sendMessage(TextFormat::GREEN."Please click on the 9th spawnpoint.");
    $this->pos8=new Vector3($this->pos8["x"]+0.5,$this->pos8["y"],$this->pos8["z"]+0.5);
    break;
    case 
    9:
    $this->pos9=array(
    "x" =>$block->x,
    "y" =>$block->y,
    "z" =>$block->z,
    "level" =>$levelname);
    $this->config->set("pos9",$this->pos9);
    $this->config->save();
    $this->SetStatus[$username]++;
    $player->sendMessage(TextFormat::GREEN."Spawnpoint 9 created!");
    $player->sendMessage(TextFormat::GREEN."Please click on the 10th spawnpoint.");
    $this->pos9=new Vector3($this->pos9["x"]+0.5,$this->pos9["y"],$this->pos9["z"]+0.5);
    break;
    case 
    10:
    $this->pos10=array(
    "x" =>$block->x,
    "y" =>$block->y,
    "z" =>$block->z,
    "level" =>$levelname);
    $this->config->set("pos10",$this->pos10);
    $this->config->save();
    $this->SetStatus[$username]++;
    $player->sendMessage(TextFormat::GREEN."Spawnpoint 10 created!");
    $player->sendMessage(TextFormat::GREEN."Please click on the 11th spawnpoint.");
    $this->pos10=new Vector3($this->pos10["x"]+0.5,$this->pos10["y"],$this->pos10["z"]+0.5);
    break;
    case 
    11:
    $this->pos11=array(
    "x" =>$block->x,
    "y" =>$block->y,
    "z" =>$block->z,
    "level" =>$levelname);
    $this->config->set("pos11",$this->pos11);
    $this->config->save();
    $this->SetStatus[$username]++;
    $player->sendMessage(TextFormat::GREEN."Spawnpoint 11 created!");
    $player->sendMessage(TextFormat::GREEN."Please click on the 12th spawnpoint.");
    $this->pos11=new Vector3($this->pos11["x"]+0.5,$this->pos11["y"],$this->pos11["z"]+0.5);
    break;
    case 
    12:
    $this->pos12=array(
    "x" =>$block->x,
    "y" =>$block->y,
    "z" =>$block->z,
    "level" =>$levelname);
    $this->config->set("pos12",$this->pos12);
    $this->config->save();
    $this->SetStatus[$username]++;
    $player->sendMessage(TextFormat::GREEN."Spawnpoint 12 created!");
    $player->sendMessage(TextFormat::GREEN."Please click on the 13th spawnpoint.");
    $this->pos12=new Vector3($this->pos12["x"]+0.5,$this->pos12["y"],$this->pos12["z"]+0.5);
    break;
    case 
    13:
    $this->pos13=array(
    "x" =>$block->x,
    "y" =>$block->y,
    "z" =>$block->z,
    "level" =>$levelname);
    $this->config->set("pos13",$this->pos13);
    $this->config->save();
    $this->SetStatus[$username]++;
    $player->sendMessage(TextFormat::GREEN."Spawnpoint 13 created!");
    $player->sendMessage(TextFormat::GREEN."Please click on the 14th spawnpoint.");
    $this->pos13=new Vector3($this->pos13["x"]+0.5,$this->pos13["y"],$this->pos13["z"]+0.5);
    break;
    case 
    14:
    $this->pos14=array(
    "x" =>$block->x,
    "y" =>$block->y,
    "z" =>$block->z,
    "level" =>$levelname);
    $this->config->set("pos14",$this->pos14);
    $this->config->save();
    $this->SetStatus[$username]++;
    $player->sendMessage(TextFormat::GREEN."Spawnpoint 14 created!");
    $player->sendMessage(TextFormat::GREEN."Please click on the 15th spawnpoint.");
    $this->pos14=new Vector3($this->pos14["x"]+0.5,$this->pos14["y"],$this->pos14["z"]+0.5);
    break;
    case 
    15:
    $this->pos15=array(
    "x" =>$block->x,
    "y" =>$block->y,
    "z" =>$block->z,
    "level" =>$levelname);
    $this->config->set("pos15",$this->pos15);
    $this->config->save();
    $this->SetStatus[$username]++;
    $player->sendMessage(TextFormat::GREEN."Spawnpoint 15 created!");
    $player->sendMessage(TextFormat::GREEN."Please click on the 16th spawnpoint.");
    $this->pos15=new Vector3($this->pos15["x"]+0.5,$this->pos15["y"],$this->pos15["z"]+0.5);
    break;
    case 
    16:
    $this->pos16=array(
    "x" =>$block->x,
    "y" =>$block->y,
    "z" =>$block->z,
    "level" =>$levelname);
    $this->config->set("pos16",$this->pos16);
    $this->config->save();
    $this->SetStatus[$username]++;
    $player->sendMessage(TextFormat::GREEN."Spawnpoint 16 created!");
    $player->sendMessage(TextFormat::GREEN."Please click on the 17th spawnpoint.");
    $this->pos16=new Vector3($this->pos16["x"]+0.5,$this->pos16["y"],$this->pos16["z"]+0.5);
    break;
    case 
    17:
    $this->pos17=array(
    "x" =>$block->x,
    "y" =>$block->y,
    "z" =>$block->z,
    "level" =>$levelname);
    $this->config->set("pos17",$this->pos17);
    $this->config->save();
    $this->SetStatus[$username]++;
    $player->sendMessage(TextFormat::GREEN."Spawnpoint 17 created!");
    $player->sendMessage(TextFormat::GREEN."Please click on the 18th spawnpoint.");
    $this->pos17=new Vector3($this->pos17["x"]+0.5,$this->pos17["y"],$this->pos17["z"]+0.5);
    break;
    case 
    18:
    $this->pos18=array(
    "x" =>$block->x,
    "y" =>$block->y,
    "z" =>$block->z,
    "level" =>$levelname);
    $this->config->set("pos18",$this->pos18);
    $this->config->save();
    $this->SetStatus[$username]++;
    $player->sendMessage(TextFormat::GREEN."Spawnpoint 18 created!");
    $player->sendMessage(TextFormat::GREEN."Please click on the 19th spawnpoint.");
    $this->pos18=new Vector3($this->pos18["x"]+0.5,$this->pos18["y"],$this->pos18["z"]+0.5);
    break;
    case 
    19:
    $this->pos19=array(
    "x" =>$block->x,
    "y" =>$block->y,
    "z" =>$block->z,
    "level" =>$levelname);
    $this->config->set("pos19",$this->pos19);
    $this->config->save();
    $this->SetStatus[$username]++;
    $player->sendMessage(TextFormat::GREEN."Spawnpoint 19 created!");
    $player->sendMessage(TextFormat::GREEN."Please click on the 20th spawnpoint.");
    $this->pos19=new Vector3($this->pos19["x"]+0.5,$this->pos19["y"],$this->pos19["z"]+0.5);
    break;
    case 
    20:
    $this->pos20=array(
    "x" =>$block->x,
    "y" =>$block->y,
    "z" =>$block->z,
    "level" =>$levelname);
    $this->config->set("pos20",$this->pos20);
    $this->config->save();
    $this->SetStatus[$username]++;
    $player->sendMessage(TextFormat::GREEN."Spawnpoint 20 created!");
    $player->sendMessage(TextFormat::GREEN."Please click on the 21st spawnpoint.");
    $this->pos20=new Vector3($this->pos20["x"]+0.5,$this->pos20["y"],$this->pos20["z"]+0.5);
    break;
    case 
    21:
    $this->pos21=array(
    "x" =>$block->x,
    "y" =>$block->y,
    "z" =>$block->z,
    "level" =>$levelname);
    $this->config->set("pos21",$this->pos21);
    $this->config->save();
    $this->SetStatus[$username]++;
    $player->sendMessage(TextFormat::GREEN."Spawnpoint 21 created!");
    $player->sendMessage(TextFormat::GREEN."Please click on the 22nd spawnpoint.");
    $this->pos21=new Vector3($this->pos21["x"]+0.5,$this->pos21["y"],$this->pos21["z"]+0.5);
    break;
    case 
    22:
    $this->pos22=array(
    "x" =>$block->x,
    "y" =>$block->y,
    "z" =>$block->z,
    "level" =>$levelname);
    $this->config->set("pos22",$this->pos22);
    $this->config->save();
    $this->SetStatus[$username]++;
    $player->sendMessage(TextFormat::GREEN."Spawnpoint 22 created!");
    $player->sendMessage(TextFormat::GREEN."Please click on the 23rd spawnpoint.");
    $this->pos22=new Vector3($this->pos22["x"]+0.5,$this->pos22["y"],$this->pos22["z"]+0.5);
    break;
    case 
    23:
    $this->pos23=array(
    "x" =>$block->x,
    "y" =>$block->y,
    "z" =>$block->z,
    "level" =>$levelname);
    $this->config->set("pos23",$this->pos23);
    $this->config->save();
    $this->SetStatus[$username]++;
    $player->sendMessage(TextFormat::GREEN."Spawnpoint 23 created!");
    $player->sendMessage(TextFormat::GREEN."Please click on the 24th spawnpoint.");
    $this->pos23=new Vector3($this->pos23["x"]+0.5,$this->pos23["y"],$this->pos23["z"]+0.5);
    break;
    case 
    24:
    $this->pos24=array(
    "x" =>$block->x,
    "y" =>$block->y,
    "z" =>$block->z,
    "level" =>$levelname);
    $this->config->set("pos24",$this->pos24);
    $this->config->save();
    $this->SetStatus[$username]++;
    case 
    lastpos:
    $this->lastpos=array(
    "x" =>$block->x,
    "y" =>$block->y,
    "z" =>$block->z,
    "level" =>$levelname);
    $this->config->set("lastpos",$this->lastpos);
    $this->config->save();
    unset(
    $this->SetStatus[$username]);
    $player->sendMessage(TextFormat::GREEN."Deathmatch spawnpoint created!");
    $player->sendMessage(TextFormat::GREEN."All settings completed and you can start a game now.");
    $this->lastpos=new Vector3($this->lastpos["x"]+0.5,$this->lastpos["y"],$this->lastpos["z"]+0.5);
    $this->level=$this->getServer()->getLevelByName($this->config->get("pos1")["level"]);
    }
    }
    else
    {
    $sign=$event->getPlayer()->getLevel()->getTile($event->getBlock());
    if(isset(
    $this->lastpos) && $this->lastpos!=array() && $sign instanceof Sign && $sign->getX()==$this->sign->&& $sign->getY()==$this->sign->&& $sign->getZ()==$this->sign->&& $event->getPlayer()->getLevel()->getFolderName()==$this->config->get("sign")["level"])
    {
    if(!
    $this->config->exists("lastpos"))
    {
    $event->getPlayer()->sendMessage(TextFormat::RED"[{$this->getConfig()->get("prefix")}]The game hasn't been set yet.");
    return;
    }
    if(!
    $event->getPlayer()->hasPermission("hg.touch.startgame"))
    {
    $event->getPlayer()->sendMessage("You don't have permission to join this game.");
    return;
    }
    if(!
    $event->getPlayer()->isOp())
    {
    $inv=$event->getPlayer()->getInventory();
    for(
    $i=0;$i<$inv->getSize();$i++)
    {
    if(
    $inv->getItem($i)->getID()!=0)
    {
    $event->getPlayer()->sendMessage(TextFormat::RED"[{$this->getConfig()->get("prefix")}]Remove all items from your inventory to join the match.");
    return;
    }
    }
    foreach(
    $inv->getArmorContents() as $i)
    {
    if(
    $i->getID()!=0)
    {
    $event->getPlayer()->sendMessage(TextFormat::RED"[{$this->getConfig()->get("prefix")}]Please take your armor off.");
    return;
    }
    }
    }
    if(
    $this->gameStatus==|| $this->gameStatus==1)
    {
    if(!isset(
    $this->players[$event->getPlayer()->getName()]))
    {
    if(
    count($this->players)>=6)
    {
    $event->getPlayer()->sendMessage("[{$this->getConfig()->get("prefix")}]The match is full.");
    return;
    }
    $this->sendToAll("[{$this->getConfig()->get("prefix")}]" .$event->getPlayer()->getName(). " joined the match.");
    $this->players[$event->getPlayer()->getName()]=array("id"=>$event->getPlayer()->getName());
    $event->getPlayer()->sendMessage(TextFormat::BLUE"[{$this->getConfig()->get("prefix")}]You have joined the match!");
    if(
    $this->gameStatus==&& count($this->players)>=2)
    {
    $this->gameStatus=1;
    $this->lastTime=$this->waitTime;
    $this->sendToAll(TextFormat::YELLOW"[{$this->getConfig()->get("prefix")}]The game will countdown when a low amount of players are in");
    }
    if(
    count($this->players)==&& $this->gameStatus==&& $this->lastTime>5)
    {
    $this->sendToAll(TextFormat::GREEN"[{$this->getConfig()->get("prefix")}]The match is already full. Starting the match.");
    $this->lastTime=5;
    }
    $this->changeStatusSign();
    }
    else
    {
    $event->getPlayer()->sendMessage(TextFormat::RED"[{$this->getConfig()->get("prefix")}]You are already in the game. Do /lobby to leave.");
    }
    }
    else
    {
    $event->getPlayer()->sendMessage(TextFormat::RED"[{$this->getConfig()->get("prefix")}]The match has already started.");
    }
    }
    }
    }
    Last edited by a moderator: Jun 8, 2015
  6. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    this still is not function sendToAll() :D BTW use spoilers and
    PHP:
  7. tigerza118
    Offline

    tigerza118 Active Member

    Joined:
    Jan 31, 2015
    Posts:
    100
    Minecraft User:
    tigerza117
    I have to fix it
  8. iJoshuaHD
    Offline

    iJoshuaHD Notable Member Plugin Developer

    Joined:
    Nov 7, 2013
    Posts:
    1,196
    Plugins:
    4
    Minecraft User:
    iJoshuaHD
    that is playerBlockTouch function!
  9. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
  10. xiaoq
    Offline

    xiaoq Active Member

    Joined:
    Dec 23, 2014
    Posts:
    232
    Minecraft User:
    xiaoq
  11. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Apparently he simply doesn't know what sendToAll means.
  12. xiaoq
    Offline

    xiaoq Active Member

    Joined:
    Dec 23, 2014
    Posts:
    232
    Minecraft User:
    xiaoq
    PEMapModder and Legoboy0215 like this.

Share This Page

Advertisement