Hey guys I need help, I want to add a counter in the scheduler I do it so: Add in task a function called $this->plugin->tick(); which gets triggered every second, in my main plugin I just do public function tick(){ which should include a count, Id like to have count = 5; but where can I store the count variable, I mean when I store it in the tick function the count gets set every second to 5.... Any ideas?
Yep, but I dont know where to have that variable ($countOITC = 5 because when I store it in the tick it gets reset every time its called
And where can I store the $countOITC = 5; variable? I mean when I have it in the tick it gets reset every time its called...
I want to know where can I store the variable $countOITC = 5; when I store it in the function which gets called every second it resets of course to 5; but I want that it counts down so where need I store the variable?
Put the variable in your main class or the task class, it doesn't matter. Schedule a repeating task for each second. Within the task class do: PHP: $count--;// or$count++; depending on how you want the timer to count.
When When I store it just at onEnable(){ or in public class Main extends PluginBase(){ it says that it is undefined -.-
You need to define the variable's visibility. Learn about it here: http://php.net/manual/en/language.oop5.visibility.php
Thats not even correct syntax, it will just cause a crash. And that isnt his issue. The issue is that he doesnt know how to access a class member from another class.
why =5 ??????? do you need to set the var $count to 5 each second? you can store $count in a public var PHP: class yourClass{public $count = 0;public function tick(){$this->count = 5; //nosense}
When I store the var public $countOITC = 5; right after that class Main extends PluginBase{ it also crashes ;-;