the error is a syntax error "public" not expected, expected "," or ";" on line 20 here is the code... <?php namespace KnockbackM; use pocketmine\event\Event; use pocketmine\event\entity\EntityDamageByEntityEvent; use pocketmine\event\entity\EntityDamageEvent; use pocketmine\Server; use pocketmine\Player; use pocketmine\PluginBase; use pocketmine\event\Listener; class Main extends PluginBase implements Listener{ public function onEnable() { $this->getServer()->getPluginManager()->registerEvents($this,$this); } 19 - public $knockback = 0.4 20 - public function onCommand(Command $cmd, CommandSender $sender, array $args, $label) { if($cmd->getName() == "kb"{$event->setKnockback($args[0])); $sender->sendMessage(c::RED. "Knockback Set!" } } public function onDamage(EntityDamageEvent $event) { if($event instanceof EntityDamageByEntityEvent){ $event->setKnockback(); } } }
Now I have this error on line 22 "Unexpected ")" on line 22" 22 - if($cmd->getName() == "kb"{$event->setKnockback($args[0])); any idea? Im sure there is no unexpected ")"
it's a SYNTAX ERROR! read the error! this can be resolved by reading every single line and knowledge of PHP syntax OR use a ide
Here, I fixed your syntax, but please, learn the php syntax: PHP: <?phpnamespace KnockbackM;use pocketmine\event\Event;use pocketmine\event\entity\EntityDamageByEntityEvent;use pocketmine\event\entity\EntityDamageEvent;use pocketmine\Server;use pocketmine\Player;use pocketmine\PluginBase;use pocketmine\event\Listener;class Main extends PluginBase implements Listener{ public function onEnable() { $this->getServer()->getPluginManager()->registerEvents($this,$this); } public $knockback = 0.4; public function onCommand(Command $cmd, CommandSender $sender, array $args, $label) { if($cmd->getName() == "kb") { $event->setKnockback($args[0]); $sender->sendMessage(c::RED . "Knockback Set!"); } } public function onDamage(EntityDamageEvent $event) { if($event instanceof EntityDamageByEntityEvent){ $event->setKnockback(); } }}
You didn't fix that Either import TextFormat as c (for whatever reason) or import TextFormat and change it to TextFormat::RED