1. GSManager
    1. Funktionen
    2. Unterstützte Spiele
    3. Neuigkeiten
    4. Statistiken
    5. Serverliste
  2. Lexikon
  3. Filebase
  4. Entwicklung
  5. Forum
    1. Dashboard
    2. Unerledigte Themen
  6. Mitglieder
    1. Letzte Aktivitäten
    2. Benutzer online
    3. Team
    4. Mitgliedersuche
  • Anmelden
  • Registrieren
  • Suche
Dieses Thema
  • Alles
  • Dieses Thema
  • Dieses Forum
  • Artikel
  • Seiten
  • Dateien
  • Forum
  • Lexikon
  • Erweiterte Suche
  1. GSManager
  2. Forum
  3. Erweiterungen
  4. Anfragen

how we can use job in gsm

  • azadfalah
  • 12. April 2016 um 21:06
Das Projekt GSManager (vormals ManuAdminMod) wurde am 01.01.2020 eingestellt - diese Internetpräsenz bleibt verfügbar, die Software wird aber nicht länger gepflegt. Vielen Dank für eure Unterstützung in den mehr als zehn vergangenen Jahren!
  • azadfalah
    Anfänger
    Punkte
    275
    Beiträge
    44
    • 12. April 2016 um 21:06
    • #1

    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

  • Mirko911
    Entwickler
    Reaktionen
    165
    Punkte
    16.820
    Trophäen
    6
    Beiträge
    3.263
    Einträge
    11
    • 13. April 2016 um 01:15
    • #2

    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 :D

    PHP: Example Class with Jobs
    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
  • Yenz
    Entwickler
    Reaktionen
    90
    Punkte
    10.180
    Trophäen
    5
    Beiträge
    1.988
    Einträge
    9
    • 13. April 2016 um 01:15
    • #3
    Code
    /**
         * 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:

    Code
    $this->job_id = $this->jobs->addPeriodicJob(1, 's', $this->config->get('nuke', 'countdown'), array($this, "countdown"), array($team_id, $params));
  1. Mitarbeiter
  2. Datenschutzerklärung
  3. Nutzungsbedingungen
  4. Impressum
  5. Kontakt
Community-Software: WoltLab Suite™