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

Solved unexpected { in code

Comments in 'Plugin Development' started by FlamingGenius, Oct 8, 2015.

  1. FlamingGenius
    Offline

    FlamingGenius Active Member

    Joined:
    Sep 23, 2015
    Posts:
    173
    Minecraft User:
    FlamingGenius
    I have spent 10mins trying to figure it out lol idk maybe it is just my eyes but i cant find the error
    Code:
    unexpected '{' in your code on line 49
    PHP:
    <?php
    namespace FlamingGenius\MessageSystem;
    use 
    pocketmine\command\Command;
    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\utils\Config;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\Server;
    use 
    pocketmine\utils\TextFormat;
    class 
    main extends PluginBase{
    public function 
    onEnable(){
      
    $this->saveDefaultConfig();
    }
    public function 
    onCommand(CommandSender $senderCommand $command$label, array $args){
      
    $cmd $this->command->getName();
      
    $msg implode(" " $args);
      if(
    strtolower($cmd) == "ms"){
       if(
    $args[0] == "broadcast"){
        
    $this->getServer()->broadcastMessage($msg);
       }
       elseif(
    $args[0] == "bgod"){
        
    $this->getServer()->broadcastMessage($msg);
       }
       elseif(
    $args[0] == "bhero"){
        
    $this->getServer()->broadcastMessage($msg);
       }
       elseif(
    $args[0] == "announce"){
        
    $this->getServer()->broadcastMessage($msg);
       }
       elseif(
    $args[0] == "server"){
        
    $this->getServer()->broadcastMessage($msg);
       }
       elseif(
    $args[0] == "console"){
        
    $this->getServer()->broadcastMessage($msg);
       }
       elseif(
    $args[0] == "bcia"){
        
    $this->getServer()->broadcastMessage($msg);
       }
       elseif(
    $args[0] == "help"){
        
    $help $this->getConfig()->get("help-list");
        
    $sender->sendMessage($help);
       }
       else(
    $args[0] == " "){
        
    $sender->sendMessage("That is not a configured command");
       }
      }
    }
    }
    ?>
  2. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    Learn how to use an IDE for your code, stop posting useless threads like this one. BTW the error is in the line with the else statement. There shouldn't be parentheses. Please learn PHP. And I think you forgot a closing parentheses.
    FlamingGenius likes this.
  3. GmWM
    Offline

    GmWM Active Member Plugin Developer

    Joined:
    Sep 8, 2013
    Posts:
    181
    Plugins:
    3
    Use switch() instead of elseif(). It works as if(), but you don't have to check every time the args with elseif()...Its better for command arguments.
    Thanks - GmWM
    FlamingGenius likes this.
  4. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    He was not asking for suggestions, he was asking if you could find the error. Please read the first post. :)
  5. GmWM
    Offline

    GmWM Active Member Plugin Developer

    Joined:
    Sep 8, 2013
    Posts:
    181
    Plugins:
    3
    You solved his problem, I gave him a suggestion. I don't think there is any problem with that. :)
  6. FlamingGenius
    Offline

    FlamingGenius Active Member

    Joined:
    Sep 23, 2015
    Posts:
    173
    Minecraft User:
    FlamingGenius
    oops forgot to put the
    Code:
     if 
    Taha_The_Hacker likes this.
  7. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    True.
  8. FlamingGenius
    Offline

    FlamingGenius Active Member

    Joined:
    Sep 23, 2015
    Posts:
    173
    Minecraft User:
    FlamingGenius
    I have multiple branches of my project one that uses a switch statement and 2 that dont :)
  9. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    You're more offensive than me in Call Of Duty, sir.
    TonyDroide likes this.
  10. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    I have no clue what you're talking about. Please don't reply if you can't help, because I see you posting random stuff, that have nothing to do with the topic of this thread.
  11. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    This is more usefull than my topic true?

    Or this

    I can recolect your messages in other posts and the 75% is telling:

    "Learn PHP".
  12. FlamingGenius
    Offline

    FlamingGenius Active Member

    Joined:
    Sep 23, 2015
    Posts:
    173
    Minecraft User:
    FlamingGenius
    #burn
    AndrewBit likes this.
  13. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    Gamecrafter You see all those users trying to pick fights with you. *continues burning more users*
    1. [​IMG]
      AndrewBit
      It's because you're so popular HAHA
    2. [​IMG]
      Gamecrafter

      And you'll definitely lose a fight you pick against me. >:)



    Come fight with me Gamecrafter. xDDDD Really you think that this was a 'fight' and I lost the 'fight'?
    I think that you play too much times Mortal Kombat.


    *Note:
    At least I didn't think that 2 comments are a "fight"
    Last edited: Oct 9, 2015
    PEMapModder likes this.
  14. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    If you think/hope that you can't talk anything else after answering the question in the main post, not even to give a reminder, I suggest you to have a thorough body check to confirm that you are a human being not a robot. This is not a forum if you are only having one question and one answer here and nothing else.
    Taha_The_Hacker likes this.

Share This Page

Advertisement