Hello there, To everyone who clicked this thread to help me, I thank you so much. Please bare with me if I made so many stupid mistakes. I just began getting into plugin development a few days ago My objective of this plugin was to make it so that whenever someone breaks a random amount of stone blocks between 1-30 it would drop a chest that had a custom name called "Relic" and then send a Message but, Unfortunately an error occurs Error: Relics v1.0.1 19.12 12:38:56 [Server] Server thread/CRITICAL ParseError: "syntax error, unexpected ' ' (T_STRING)" (EXCEPTION) in "Relics/src/Relics/Main" at line 31 My code was: PHP: <?phpnamespace Relics;use pocketmine\plugin\PluginBase;use pocketmine\event\Listener;use pocketmine\player\Inventory;use pocketmine\item\Item;use pocketmine\event\block\BlockBreakEvent;use pocketmine\block\Block;class Main extends PluginBase implements Listener{ public function onEnable(){$this->getServer()->getPluginManager()->registerEvents($this, $this);$this->getServer()->getLogger()->info("Relics enabled");} public function onDisable(){$this->getServer()->getLogger()->info("Relics disabled");} public function onBreak(BlockBreakEvent $event){ $block = $event->getId(); $player = $event->getPlayer(); $chance = mt_rand(1, 30); $drops = $event->getItem(); $drops = Item::get(54, 0, 1); $drops->setCustomName("§cRelic"); if($event->getBlock()->getId() === 1) { if(mt_rand(1,30) === 15){$player->sendMessage("§6You Found a Relic!");$event->setDrops($drops); } } }} Any help at all will be very much appreciated!
Try that PHP: <?phpnamespace Relics;use pocketmine\plugin\PluginBase;use pocketmine\event\Listener;use pocketmine\player\Inventory;use pocketmine\item\Item;use pocketmine\event\block\BlockBreakEvent;use pocketmine\block\Block;class Main extends PluginBase implements Listener{ public function onEnable(){ $this->getServer()->getPluginManager()->registerEvents($this, $this); $this->getServer()->getLogger()->info("Relics enabled"); } public function onDisable(){ $this->getServer()->getLogger()->info("Relics disabled"); } public function onBreak(BlockBreakEvent $event){ $block = $event->getId(); $player = $event->getPlayer(); $chance = mt_rand(1, 30); $drops = $event->getItem(); $drops = Item::get(54, 0, 1); $drops->setCustomName("§cRelic"); if($event->getBlock()->getId() === 1) { $player->sendMessage("§6You Found a Relic!"); $event->setDrops($drops); } }}
Hey, Thank you but now it gives a strange error 19.12 15:07:09 [Server] Server thread/INFO Loading source plugin Relics v1.0.1 19.12 15:07:09 [Server] Server thread/CRITICAL ParseError: "syntax error, unexpected '{'" (EXCEPTION) in "Relics/src/Relics/Main" at line 14
Isn't really helping I've used that website before....this error is strange to me, do you mind telling me why this error occurs?
we cant just spoon feed you to recognize syntax errors syntax error just means something in the syntax is not right "like this sentence without a comma and the period and the capital l at the start! and an unexpected exclamation mark" therefore it would be like SYNTAX ERROR: Expecting capital letter, encounter "l" at line 1 SYNTAX ERROR: Unexpected "!" at line 1
Have you try to google it? You're jus missing '{' at line 14. I hope you can find where is line 14 located at.