Hello but i found every things about the scheduler from old api can ever make an example scheduler code why than i know how to use but every was i found in the Last 2 days dont work and is really Bad than you Lost the fun on coding pls help me
In old APIs, task schedulers are share between plugin, so it can be get from the Server instance ($this->getServer()->getScheduler()). But in API 3, task schedulers are per plugin, so you have to directly get from the plugin instance instead of the Server instance ($this->getScheduler()).
Ok but im never bevor working with scheduler but i dont know how to use this and on the api site i can see in wat i can get an what i musst implementiert but not war function i muss call of something dor bukkit you can see that all on the learn bukkit api site
@EndermannbugZJFC My Main Class: PHP: <?phpdeclare(strict_types=1);namespace ghax\task;use pocketmine\plugin\PluginBase;use pocketmine\Player;use pocketmine\Server;use pocketmine\scheduler\Task as PluginTask;use ghax\task\RTask;class Main extends PluginBase{ public function onEnable(){ $this->getScheduler()->schedulerReapeatingTask(new RTask($this),20); }} My Task Class: PHP: <?phpnamespace ghax\task;use pocketmine\scheduler\Task;use pocketmine\plugin\Plugin;use pocketmine\Server;use pocketmine\Player;use ghax\task\Main;class RTask extends Task{ private $plugin; public function __construct(Main $plugin){ $plugin = $this->plugin(); } public function onRun($currentTick){ $this->plugin->getServer()->broadcastMessage("test"); }}
scheduleRepeatingTask(), you typed extra r. Here is PocketMine not Bukkit, you are suppose to follow the PocketMine documents and tutorials.
I have dollow a titorial that is the code but dont work an i can php and i lok on the api site but every what i search over scheduler pocketmine dont work and i tell kann every make pls example code that i know how ist work than i can learn it
[Server thread/CRITICAL]: Error: "Call to undefined method ghax\task\RTask:lugin()" (EXCEPTION) in "plugins/task/src/ghax/task/RTask" at line 16
Fixed code: PHP: <?phpnamespace ghax\task;use pocketmine\scheduler\Task;use pocketmine\plugin\Plugin;use pocketmine\Server;use pocketmine\Player;use ghax\task\Main;class RTask extends Task{ private $plugin; public function __construct(Main $plugin){ $this->plugin = $plugin; } public function onRun($currentTick){ $this->plugin->getServer()->broadcastMessage("test"); }} Use code box since emojis will fuck up your errors and codes
You did it wrong. It's not PHP: public function __construct(Main $plugin){ $plugin = $this->plugin(); } it's PHP: public function __construct(Main $plugin){ $this->plugin = $plugin; }