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 rektpixel, Mar 4, 2017.

  1. rektpixel

    rektpixel Baby Zombie

    Messages:
    186
    i'm getting an error with this plugin and i don't know what's wrong with the line of code someone pls help?

    Console message:

    CRITICAL> ParseError: "syntax error, unexpected ';', expecting ',' or ')'" (EXCEPTION) in "/phar_CrateKeys-master_5gsYfMCBxQTzFKf.phar/src/Blubberboy333/CrateKeys/Main" at line 47

    Line 47 - 48:

    $this->getServer()->dispatchCommand(new ConsoleCommandSender, str_replace(array("{PLAYER}", "{NAME}"), $player, $player->getName());
    }

    Can anyone tell me what's wrong? also I uploaded the zip if you wanna take a closer look in 'main.php'
     

    Attached Files:

  2. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    Syntax errors are pretty simple.

    This
    PHP:
     $this->getServer()->dispatchCommand(new ConsoleCommandSenderstr_replace(array("{PLAYER}""{NAME}"), $player$player->getName());
    needs to be this:
    PHP:
     //You need to define the string or array to str_replace in
    $this->getServer()->dispatchCommand(new ConsoleCommandSenderstr_replace(["{PLAYER}""{NAME}"], [$player$player->getName()], $command));
    }
    //Define $command as whatever command you want to execute. 
    You were missing multiple closing parentheses. Remember, for every (, [, or {, you must have a cooresponding ), ], }, respectively. You also used str_replace a little inaccurately. You can get some information on that from here, but basically, you need two arrays(or variables) and a third argument, either an array or string, to do the replacing in.
     
  3. rektpixel

    rektpixel Baby Zombie

    Messages:
    186
    thanks
     
    corytortoise 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.