so ive been making this plugin for a server and i need help i got some erros but fixed them by myself . Heres my code PHP: <?php/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */use pocketmine\Player;use pocketmine\Server;use pockemine\plugin\{PluginBase, Plugin};use pocketmine\command\{Command, CommandSender};use pocketmine\utils\TextFormat as C;use pocketmine\item\Item;class Main extends PluginBase{ public function onCommand(CommandSender $sender, command $command, $label, array $args){ if ($command->getName() == "Mask"){ if (!isset($args[0])){ $sender->sendMessage(C::DARK_RED."Usage ".C::DARK_GRAY."/Mask (mask name) (player) (amount)"); return; } switch (strtolower($args[0])){ case "Zombie" if(!$sender->hasPermission("Mask.zombie")){ $amount = $amount = ((int) $args[1]); $item = Item::get(397, 0, $amount); $item->setCustomName("§7Name:§eZombie Mask\n§7Desc:§ePut On for effects\n§7Status:\n§eUNLOCKED"); $player->getInventory()->addItem($item); $sender->sendMessage("§eLatenci §7>> You just recieved a Zombie Mask"); return; } else{$sender->sendMessage("§4YOU DONT HAVE PERMISSION SMH STOPPPP"); return; } } } }} heres the errors Code: [CONSOLE: Reload complete.] 2017-05-14 [mcpeplugin] > [CONSOLE: Reloading server...] 2017-05-14 [mcpeplugin] > Saving levels... 2017-05-14 [mcpeplugin] > Disabling OpSlimeBall v0.1 2017-05-14 [mcpeplugin] > Reloading properties... 2017-05-14 [mcpeplugin] > Loading plugin: Masks v0.1 2017-05-14 [mcpeplugin] > An unknown error occurred while attempting to perform this command 2017-05-14 [mcpeplugin] > Unhandled exception executing command 'reload' in reload: syntax error, unexpected 'if' (T_IF) 2017-05-14 [mcpeplugin] > ParseError: "syntax error, unexpected 'if' (T_IF)" (EXCEPTION) in "/Masks/src/Masks/Main" at line 27 2017-05-14 [mcpeplugin] > [CONSOLE: Reloading server...] 2017-05-14 [mcpeplugin] > Saving levels... 2017-05-14 [mcpeplugin] > Reloading properties... 2017-05-14 [mcpeplugin] > Loading plugin: Masks v0.1 2017-05-14 [mcpeplugin] > An unknown error occurred while attempting to perform this command 2017-05-14 [mcpeplugin] > Unhandled exception executing command 'reload' in reload: syntax error, unexpected variable (T_VARIABLE) 2017-05-14 [mcpeplugin] > ParseError: "syntax error, unexpected variable (T_VARIABLE)" (EXCEPTION) in "/Masks/src/Masks/Main" at line 27 2017-05-14 [mcpeplugin] > TTOp left the game 2017-05-14 [mcpeplugin] > TTOp[/10.0.0.149:19132] logged out due to client disconnect Helping me will be highly appreciated thx
Now it comes with this what to do now i know i have fixed a error similar to this but i cant fix this ik its ez but cant remember Code: [mcpeplugin] > Loading plugin: Masks v0.1 2017-05-14 [mcpeplugin] > An unknown error occurred while attempting to perform this command 2017-05-14 [mcpeplugin] > Unhandled exception executing command 'reload' in reload: syntax error, unexpected '}', expecting end of file 2017-05-14 [mcpeplugin] > ParseError: "syntax error, unexpected '}', expecting end of file" (EXCEPTION) in "/Masks/src/Masks/Main" at line 41 2017-05-14 [mcpeplugin] > DarkStray : :/ PHP: <?php/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */namespace Masks;use pocketmine\Player;use pocketmine\Server;use pockemine\plugin\{PluginBase, Plugin};use pocketmine\command\{Command, CommandSender};use pocketmine\utils\TextFormat as C;use pocketmine\item\Item;class Main extends PluginBase{ public function onCommand(CommandSender $sender, command $command, $label, array $args){ if ($command->getName() == "Mask"){ if (!isset($args[0])){ $sender->sendMessage(C::DARK_RED."Usage ".C::DARK_GRAY."/Mask (mask name) (player) (amount)"); return; } switch (strtolower($args[0])){ case "Zombie": $amount = $amount = ((int) $args[1]); $item = Item::get(397, 0, $amount); $item->setCustomName("§7Name:§eZombie Mask\n§7Desc:§ePut On for effects\n§7Status:\n§eUNLOCKED"); $player->getInventory()->addItem($item); $sender->sendMessage("§eLatenci §7>> You just recieved a Zombie Mask"); return; } } else{$sender->sendMessage("§4YOU DONT HAVE PERMISSION SMH STOPPPP"); return; } } } }
PHP: <?php/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */namespace Masks;use pocketmine\Player;use pocketmine\Server;use pockemine\plugin\{PluginBase, Plugin};use pocketmine\command\{Command, CommandSender};use pocketmine\utils\TextFormat as C;use pocketmine\item\Item;class Main extends PluginBase{ public function onCommand(CommandSender $sender, command $command, $label, array $args){ if ($command->getName() == "Mask"){ if (!isset($args[0])){ $sender->sendMessage(C::DARK_RED."Usage ".C::DARK_GRAY."/Mask (mask name) (player) (amount)"); return; } switch (strtolower($args[0])){ case "zombie": if($sender->hasPermission("mask.zombie")){ $amount = $amount = ((int) $args[1]); $item = Item::get(397, 0, $amount); $item->setCustomName("§7Name:§eZombie Mask\n§7Desc:§ePut On for effects\n§7Status:\n§eUNLOCKED"); $player->getInventory()->addItem($item); $sender->sendMessage("§eLatenci §7>> You just recieved a Zombie Mask"); return true; } else { $sender->sendMessage("§4YOU DONT HAVE PERMISSION SMH STOPPPP"); return true; } } } }} If you reformat your code better it's a whole lot easier to work with.
PHP: <?php/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */use pocketmine\Player;use pocketmine\Server;use pockemine\plugin\{PluginBase, Plugin};use pocketmine\command\{Command, CommandSender};use pocketmine\utils\TextFormat as C;use pocketmine\item\Item;class Main extends PluginBase{ public function onCommand(CommandSender $sender, command $command, $label, array $args){ if (strtolower($command->getName()) == "mask"){ if (!isset($args[0])){ $sender->sendMessage(C::DARK_RED."Usage ".C::DARK_GRAY."/Mask (mask name) (player) (amount)"); return false; // must return a bool } switch (strtolower($args[0])){ case "zombie": // must be lowercase and have a : after the string if(!$sender->hasPermission("mask.zombie")){ $amount = $amount = ((int) $args[1]); $item = Item::get(397, 0, $amount); $item->setCustomName("§7Name:§eZombie Mask\n§7Desc:§ePut On for effects\n§7Status:\n§eUNLOCKED"); $player->getInventory()->addItem($item); $sender->sendMessage("§eLatenci §7>> You just recieved a Zombie Mask"); return true; // must return a bool }else{ $sender->sendMessage("§4YOU DONT HAVE PERMISSION SMH STOPPPP"); return true; // must return a bool } default: // argument switches must have a default return false; // must return a bool } } }}
Wow... Syntax errors in the development section. There should really be a punishment for this. Online php syntax checkers are out there people!
Please don't put syntax errors here, we keep syntax errors where only some see them in the facepalm section for a reason and useful questions in this section. It's just for future developers to find helpful content, not cause we dislike beginners.