public function onPlayerRespawn(PlayerRespawnEvent $event) { $player = $event->getPlayer() { $sender->getInventory()->addItem(Item::get(364,0,4)); $sender->sendMessage("You have just recieved 4 steak!");
This is completely wrong. Please learn the API by reading through the source and it also looks like you need to learn PHP. Here's the fixed code PHP: public function onPlayerRespawn(PlayerRespawnEvent $event) { $player = $event->getPlayer(); $player->getInventory()->addItem(Item::get(364,0,4)); $player->sendMessage("You have just recieved 4 steak!");} Alright, lets see what you did wrong $sender is not defined. You obviously copied this from a command in another plugin. $event->getPlayer() shouldnt have a { after it. You need an } at the end.
Ok, thanks. I'm learning it at the moment. Reading and testing all the time. I was confused when I wrote a { after the getPlayer()!!! But I don't unterstand how else I can do it. Sry if my English is not the best...
Just one thing: don't give 'fixed' code because they're just gonna copy-paste and they will never learn. Additionally, this is the wrong section and they didn't read the guidelines.
Every five year old should know that you can't do stuff with something that doesn't exist (I'm talking about the undefined $sender), though...