Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Running one function multiply?

Comments in 'Plugin Development' started by Kvetinac97, Jul 9, 2015.

  1. Kvetinac97
    Offline

    Kvetinac97 Active Member Plugin Developer

    Joined:
    Nov 17, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    Kvetinac97
    Hi

    In my server, I have one simply function

    PHP:
    public function startArena($arena){
    $this->getServer()->getScheduler()->scheduleDelayedTask(new ArenaStartTask($this$arena), $this->config->get("arena-" $arena "-start-time")*20//arena is number of arena
    }
    function startArena is called onCommand /arena start <number of arena>

    What if I type /arena start 1 and (after 2 secons /arena start 2) (arena 1 and arena 2 have both start-time 30 seconds)? It'll lag the server or both arenas will be started?
    Last edited: Jul 9, 2015
  2. ahoj_truhliku
    Offline

    ahoj_truhliku Banned

    Joined:
    Jul 9, 2015
    Posts:
    89
    Minecraft User:
    Creeperface001
    use a magic method named __construct()
    Last edited by a moderator: Jul 9, 2015
  3. Kvetinac97
    Offline

    Kvetinac97 Active Member Plugin Developer

    Joined:
    Nov 17, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    Kvetinac97
    +Where should I put _construct()? In ArenaStartTask.php? (_construct is already put in ArenaStartTask.php)
  4. ahoj_truhliku
    Offline

    ahoj_truhliku Banned

    Joined:
    Jul 9, 2015
    Posts:
    89
    Minecraft User:
    Creeperface001
    Learn how to use it ;) / nauč se jak to používat :D
    Last edited: Jul 9, 2015
  5. Kvetinac97
    Offline

    Kvetinac97 Active Member Plugin Developer

    Joined:
    Nov 17, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    Kvetinac97
    Here is the ArenaStartTask:

    PHP:
    private $arena;
    public function 
    __construct($plugin$arena) {parent::__construct($plugin)  {
    parent::construct($plugin);
    $this->arena$arena;
     } 
     public function 
    onRun($t) {
    foreach (
    $plugin->game->get("arena-" $arena "-players") as $p) {
    $p->sendMessage("Arena started!");
    }
    }
  6. Kvetinac97
    Offline

    Kvetinac97 Active Member Plugin Developer

    Joined:
    Nov 17, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    Kvetinac97
    Will it start both arenas and send message after 30s?
  7. Kvetinac97
    Offline

    Kvetinac97 Active Member Plugin Developer

    Joined:
    Nov 17, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    Kvetinac97
    It's style by PEMapModder
  8. Kvetinac97
    Offline

    Kvetinac97 Active Member Plugin Developer

    Joined:
    Nov 17, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    Kvetinac97
    So it'll work for each arena

Share This Page

Advertisement