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

Minigame Plugin

Comments in 'Plugin Development' started by WitherTube, Jan 16, 2016.

  1. WitherTube
    Offline

    WitherTube New Member

    Joined:
    Dec 21, 2015
    Posts:
    44
    Minecraft User:
    Wither_Tube
    Hey
    i have a problem with the playermoveEvent : I want it that if a Player joined the Server the Plugin stops him to move like SurvivalGames.There must come 12 Persons to cancel this Event. The Players are all on a Block and cant move.And my second Question is where i must put this Code please :). I know i´m a noob and please
    don´t write anything like this .


    namespace Withertube;

    use pocketmine\scheduler\PluginTask;


    class Aufgabe extends PluginTask {

    public function __construct($plugin)
    {
    $this->plugin= $plugin;
    parent::__construct($plugin);
    }


    public function onRun ($tick){

    }

    }
  2. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    Uh, what are you using a task for?
    And just cancel the event.
    PHP:
    $event->setCancelled();
    PocketKiller, KubixQ and applqpak like this.
  3. KubixQ
    Offline

    KubixQ Active Member

    Joined:
    Sep 13, 2015
    Posts:
    85
    Minecraft User:
    KubixQ
    Just use
    Code:
    [PHP]#YOURCODE [/PHP]
    xD
    applqpak likes this.
  4. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    If the amount of players(online) is < 12, cancel PlayerMoveEvent
    wolfdale and applqpak like this.
  5. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    And you shoul check that onPlayerJoinEvent :)
  6. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Why? If you want to cancel PlayerMoveEvent, then why should you use another event to check that?
    Vaivez66 and PEMapModder like this.
  7. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    Oh, my brain was stuck on the online player part
    (Actually it would be faster to only check if the players are 12 onJoin and write that to an variable and readout it on playerMoveEvent)
  8. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Nah, just count the online Players, I don't think that using 3 events(join, quit, move) is better then using 1.(move)
  9. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    It's faster
  10. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    I didn't understand the point of use a task here...

    Well, you should check if the game is started on your Listener, not on a Task (I don't know how you do it on your plugin) and if it's not, cancel the event.
    Example:
    PHP:
    public function OnMove(PlayerMoveEvent $event){
    $games = ["Game1","Game2","Game3"];
    # I'm supposing that you use isGameStarted() for check if the game is started.
    # Also I'm supposing that the level name = game name.
    if(in_array(($levelName $event->getPlayer()->getLevel()->getName()),$games) and !($this->isGameStarted($levelName))){
    $event->setCancelled();
    }
    }
    Where I need write my code?

    If you're new at PM plugins, I suggest you start reading public plugins (Instead decompile they, you can read they with PHPStorm) instead try make a minigame plugin without any knowledge.
    Last edited: Jan 17, 2016
    Vaivez66 likes this.
  11. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    What is not true? You are posting code here, but you don't explain what this code is about. You merely posted a useless example of incrementing a class property, which is as useless as posting code on how to set $player as $event->getPlayer().
    CraftYourBukkit likes this.

Share This Page

Advertisement