Hi, I just tried to use RepeatingTask But it doesn't work. here are some info: Spoiler: Error message Code: "Could not pass event 'pocketmine\event\block\SignChangeEvent' to 'Anvil v2.3': Argument 1 passed to TahaTheHacker\Anvil\Timer::__construct() must be an instance of TahaTheHacker\Anvil\Timer, instance of TahaTheHacker\Anvil\Main given, called in phar://C:/Users/somewhere/Desktop/somewhere/somewhere/somewhere/plugins/phar_Anvil-master (96)_z6KJL3QYx1D4Fw6.phar/src/TahaTheHacker/Anvil/Main.php on line 76 and defined on TahaTheHacker\Anvil\Main Spoiler: Main PHP: public function onSignCreate(SignChangeEvent $event){ $player = $event->getPlayer(); //Get the player $this->getServer()->getScheduler()->scheduleRepeatingTask(new Timer($this ,$event ,$player), 60);//line 76 $line_0 = $event->getLine(0); //The sign's line 1 (Despite the number) $line_1 = $event->getLine(1); //The sign's line 2 if(strtolower($line_0) === "[sg]" && !empty($line_1)){ //Check if the line 1 is equal to [sg] (Since strtolower) and if line 1 is not empty $level = $this->getServer()->getLevelByName($line_1); //Get the level object with the name of $line_1 if(!$this->getServer()->isLevelGenerated($line_1)){ //Check if level is generated $player->sendMessage("Failed, Not found."); //LOL return false; //Return a boolean value of false } $player->sendMessage("Created!"); //AGAIN LOL $event->setLine(0, "§c[§l§6SG§r§c]", "[" . count($level->getPlayers()) . "/10]", "§l§aTap To Join"); //Set the text. BTW, better use TextFormat::** $event->setLine(1, "Map :§l§a" . $line_1); $event->setLine(2, "§l§b[" . count($level->getPlayers($line_1)) . "/10]"); $event->setLine(3, "§l§6Tap To Join"); } } Spoiler: Timer file PHP: <?phpnamespace TahaTheHacker\Anvil;use pocketmine\scheduler\PluginTask;use pocketmine\level\Level;use pocketmine\Player;use pocketmine\Server;use pocketmine\event\block\SignChangeEvent;use pocketmine\item\item;use pocketmine\tile\Sign;use pocketmine\scheduler\ServerScheduler;use pocketmine\level\Position;class Timer extends PluginTask {public function __construct(Timer $plugin, $player){//line 18$this->plugin = $plugin;$this->player = $player;parent::__construct($plugin);}public function onRun($tick) {$this->plugin->onSignCreate();}}//Class I was on the computer 5 hours searching about it in pocketmine's search bar.
PHP: public function __construct(Main $plugin, Player $player) {parent::__construct($plugin, $player);$this->plugin = $plugin;$this->player = $player;} "Main" has to be the name of your main class
PHP: $this->getServer()->getScheduler()->scheduleRepeatingTask(new Timer($this ,$event ,$player), 60); Should be: PHP: $this->getServer()->getScheduler()->scheduleRepeatingTask(new Timer($this, $player), 60);
Everybody has beginnings, and stop talking like you're a whole lot better than him, because you aren't. This guy is still learning, he's only been here for 3 months.
You can look at his code for yourself... I think he copy and pasted it from how it looks. https://github.com/TahaTheHacker/Anvil
I can already tell he didn't completely code it on his own, but that still doesn't mean you can be rude to him. Still remember me a little more than half a year ago? If you remember me then and look at me now, you'll notice how much I've changed.
Precisely. And also mind that I didn't have any knowledge of the PHP language, so I copied other's code. But I actually took the initiative to learn PHP and cut the habit of copying code. You should encourage him to learn PHP, not put him down.
Well copying and pasting isnt all that bad sometimes. If he really does care about learning php and pm api, he would study the code he copies and try to understand what it does + copy and pasting other people's code will help him to find new methods of doing things and sparking new ideas for him. Yes, copying and pasting is frowned upon but as beginners i think almost everyone copy and pasted something before. Its just natural. So we should support him while he's learning and eventually he would be able to code without copy and paste(Hopefully).
I don't mind if people copy / paste my code. It is all in GPL, so you are welcome to it. What do I mind is when people then break something (that they did) and expect me to fix it. As the GPL clearly states, the code comes without warranty. So if you break it, you get to keep both pieces.
i really copy and paste codes from plugins, but i always try to know how it works, because if i didn't, my plugin will ever work, because some use $ev instead of $event. and variables, tags, arguments...