Hi, I would like to create a plugin to change the name of the items, but since two days, it shows an error in the console : ParseError: "syntax error, unexpected 'public function onHeld' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST)" (EXCEPTION) in "plugins/FoodEffect-master/src/CookieCode/CustomArmor/Loader" at line 26. My Code a the line 26 : PHP: public function onHeld(PlayerItemHeldEvent $e){If ($e->getItem ()->getId () === 302){$e->getItem()->setCustomName("Alpha Helmet"); }} Please help me
PHP: public function onHeld(PlayerItemHeldEvent $e){ if ($e->getItem ()->getId () === 302){ $e->getItem()->setCustomName("Alpha Helmet");}} the console indicates that this function is not accepted because there is an error. can you send me the function that precedes it
have can not confirm it if we had no integrity of the code but hey that said a syntax error is not very nasty
PHP: <?phpnamespace CookieCode\CustomArmor;use pocketmine\Player;use pocketmine\item\ItemFactory;use pocketmine\item\Item;use pocketmine\plugin\PluginBase;use pocketmine\event\Listener;use pocketmine\event\player\PlayerItemHeldEvent;use pocketmine\utils\{TextFormat as TF, Config};use pocketmine\event\Event;use pocketmine\inventory\PlayerInventory;class Loader extends PluginBase implements Listener{ public function onEnable() { $this->getServer()->getPluginManager()->registerEvents($this, $this); $this->getServer()->getLogger()->info(TF::GREEN . "[FoodEffect]" . TF::YELLOW . " Plugin enabled by CookieCode"); $this->saveDefaultConfig(); } public function onLoad(){ $this->saveResource("config.yml");}public function onHeld(PlayerItemHeldEvent $e){If ($e->getItem ()->getId () === 305){$e->getItem()->setCustomName ("The lonely stone");}}}
Try that with correct syntaxe PHP: <?phpnamespace CookieCode\CustomArmor;use pocketmine\Player;use pocketmine\item\ItemFactory;use pocketmine\item\Item;use pocketmine\plugin\PluginBase;use pocketmine\event\Listener;use pocketmine\event\player\PlayerItemHeldEvent;use pocketmine\utils\{TextFormat as TF, Config};use pocketmine\event\Event;use pocketmine\inventory\PlayerInventory;class Loader extends PluginBase implements Listener{ public function onEnable() { $this->getServer()->getPluginManager()->registerEvents($this, $this); $this->getServer()->getLogger()->info(TF::GREEN . "[FoodEffect]" . TF::YELLOW . " Plugin enabled by ArmTheDev"); $this->saveDefaultConfig(); } public function onLoad(){ $this->saveResource("config.yml"); } public function onHeld(PlayerItemHeldEvent $e){ if($e->getItem ()->getId () === 305){ $e->getItem()->setCustomName ("The lonely stone"); } }}
Code: ParseError: "syntax error, unexpected '{'" (EXCEPTION) in "plugins/FoodEffect-master/src/CookieCode/FoodEffect/Loader" at line 16 My console show me that...