hi all
i work on banip plugin i want check players every 5 sec . how i can using job to call my function ?
//i check players at joining but need to check every 5 sec
Tanx all
hi all
i work on banip plugin i want check players every 5 sec . how i can using job to call my function ?
//i check players at joining but need to check every 5 sec
Tanx all
Is there any reason why you want to check all players every 5 seconds?
If an ip is banned, than the GSM should kick this player when he connects. I can't imagine any case where you need to check it every 5 seconds.
Here is an example for a job implementation. I hadn't time to test it but it should work
class MyPlugin{
private $job_id;
public function enable(){
parent::enable();
$this->job_id = $this->jobs->addPeriodicJob(5, 's', -1, [$this, 'callThis'], ['optionalParams']);
}
public function disable(){
parent::disable();
$this->jobs->deleteJob($this->job_id);
}
public function callThis(){
}
}
Alles anzeigen
/**
* Adds a periodic job. Will be executed periodically.
*
* This functions is an easy way for executing a function every x seconds
* or minutes. So you don't need to define an extra counter for time events in your function.
* With this function, it's also possible to execute a job only for a limited count.
*
* @param int $time Execute the command all x secs/mins/hours
* @param string $time_type s/m/h/d define if you want to execute it all x seconds / minutes / hours / days
* @param int $execute_limit Set a limit for executions. If unlimited use -1
* @param callable $callback a valid callback, see http://www.php.net/manual/en/language.types.callable.php
* @param array $parameters optional array with parameters for the callback function
* @return int job id
*/
public function addPeriodicJob($time, $time_type, $execute_limit, callable $callback, array $parameters = []) {
Alles anzeigen
example: