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

error

Discussion in 'Help' started by Choppa, Dec 31, 2020.

  1. Choppa

    Choppa Creeper

    Messages:
    1
    i need help identifying what the sytnax error is.


    Error: syntax error, unexpected 'switch' (T_SWITCH)
    File: plugins/diamondarmor (5).phar/src/gear/main
    Line: 38
    Type: ParseError

    THIS CRASH WAS CAUSED BY A PLUGIN

    Code:
    [29] $player = $event->getPlayer();
    [30] $name = $player->getName();
    [31] $inv = $player->getInventory();
    [32]
    [33] $this->getServer()->broadcastMessage("Welcome $name to 4KT!");
    [34] }
    [35]
    [36] public function onCommand(CommandSender $sender, Command $cmd, string $label, array $args): bool{
    [37] $player = $sender
    [38] switch ($cmd->getName()) {
    [39] case "gear":
    [40] if($player->hasPermission("gear.cmd")) {
    [41] if(!$sender instanceof Player){
    [42] $sender->sendMessage("This Command is for Players ONLY!");
    [43] { else }
    [44] $sender->getInventory()->addItem(Item::get(310,1,1));
    [45] $sender->getInventory()->addItem(Item::get(311,2,1));
    [46] $sender->getInventory()->addItem(Item::get(312,3,1));
    [47] $sender->getInventory()->addItem(Item::get(313,4,1));
    [48] $sender->sendMessage("You are geared up to fuck yo bitch!");
     
  2. HyGlobalHD

    HyGlobalHD Spider Jockey

    Messages:
    25
    GitHub:
    HyGlobalHD
    You forgot to close using semicolon before the switch-statement at line 37

    PHP:
    public function onCommand(CommandSender $senderCommand $cmdstring $label, array $args): bool{
    $player $sender// here you forgot to put semicolon
    switch ($cmd->getName()) {
     
    IvanCraft623 likes this.
  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.