I have a new idea about my plugins. And I want to know how to use Task to count the Remaining time of sth. Example, I have a THING with 4 hours and 4 hours later that THING auto disappear. Anyone have that code ??
Define "THING". If you are counting in hours, don't use tasks. Use time() instead. Tasks are for frequent schedules up to seconds or even ticks. Server lag will delay the task to a large extent if you use scheduler tasks. Server restarts will even cancel the scheduler tasks. Do not rely on them for tasks with low frequency. When you start the timer, store time() + 3600 * 4, which is the timestamp when the timer should stop. If you want to execute something 4 hours later, start a repeating task that, for every tick/second/period, check if time() > storedTimestamp. If yes, your timer has expired and you have to reset the timer and execute the task.
Some bits of pseudocode: PHP: //main classfunc onStartTimer(){$endAt = time() + 3600 * 4; //current time in secounds + 4hours in secounds//maybe save it into some file in order to retain it after restartBlahServerObject->blahGetScheduler()->blahRepeatingLag(new YourTask($this, $endAt)); //don't overdo the repeating ticks though}//task class//blah constructor saves $endAtonRun($currentTick){ //was it onRun??if($this->endAt > time()){//do your things after 4hrs in here//BlahStopTask}} Sorry for the lack of indenting i threw this together on mobile
What can getNested() function do ? I dont know how it use for. It so confusing. I want to set a .yml file like this Code: - Something: - Somepeople - AnotherPeople
Hm you should open a new thread, but anyways: PHP: //write ConfigObject->set("Something", ["Somepeople", "AnotherPeople"]);//read$var = ConfigObject->get("Something"); //Will return the array we set earlier//or give SomePeople and AnotherPeople values//write ConfigObject->set("Something", ["Somepeople" => 5, "AnotherPeople" => 6]);//read$var = ConfigObject->get("Something.Somepeople"); //Will return 5 We basically set an array instead of a single value. If you don't know what an array is: http://php.net/manual/en/language.types.array.php