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

Game Finish for 1 Player in world

Comments in 'Plugin Development' started by Ritch, Feb 1, 2016.

  1. Ritch
    Offline

    Ritch Active Member

    Joined:
    Oct 4, 2015
    Posts:
    184
    Minecraft User:
    anonymous
    Hi guys, i making à Minigame Plugin And my problem is How Make a GameFinish example : One Player in the World is winner Game .
  2. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    count() the players in that world and check if it is === 1, if so, end the game.
    I personally think you should write the code yourself, as that is very easy from now on. If you can't, I'm asking how you would code a full(and good) minigame.
  3. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    Also, the game should be started :p
  4. Ritch
    Offline

    Ritch Active Member

    Joined:
    Oct 4, 2015
    Posts:
    184
    Minecraft User:
    anonymous
    PHP:
    public $players = [];

    public function ??!??! 
    Help ?????
    if(
    count($this->players) > 1){
       
    //code ........
  5. Nawaf_Craft1b
    Offline

    Nawaf_Craft1b Active Member Plugin Developer

    Joined:
    May 8, 2015
    Posts:
    232
    Plugins:
    1
    Minecraft User:
    Nawaf_Craft1b
    PHP:
    Public function checkandstop(){// make Task
    if(count($this->getServer()->getLevelByName("name")->getPlayers()) == 1){
    //code
    }

    }
    With array !
    PHP:
    Public function checkandstop(){// make task
    If(count($this->p)==1){
    // code
    }}
    Omar2s2 and Ritch like this.
  6. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    I'll suppose that you're working on a pvp minigame.
    PHP:
    public function OnDeath(PlayerDeathEvent $event)
    {
    if((
    $player $event->getEntity()) instanceof Player){
    $game_levels = ["Map 1 Name""Map 2 Name"];
    if(
    in_array(($levelName $player->getLevel()->getName()),$game_levels) and count(($players $player->getLevel()->getPlayers())) === and isGameStarted($levelName/*Do you any for check if a game is started?*/){
    $this->stopGame($levelName);
    foreach(
    $players as $p){
    if{
    $p != $player){
    $p->sendMessage("You're the winner!");
    }
    }
    }
    Ritch likes this.
  7. Ritch
    Offline

    Ritch Active Member

    Joined:
    Oct 4, 2015
    Posts:
    184
    Minecraft User:
    anonymous
    Thank
  8. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    Why a task? ...
  9. Nawaf_Craft1b
    Offline

    Nawaf_Craft1b Active Member Plugin Developer

    Joined:
    May 8, 2015
    Posts:
    232
    Plugins:
    1
    Minecraft User:
    Nawaf_Craft1b
    For Check Players
    If players == 1
    Stop game
    For Example
    PHP:
    public function onRun($tick){
    // code
    $this->getPlugin()->checkandstop();
    }
  10. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    Oh! I was thinking that it was to get your server laggy.
    It's a useless task, why not use events?
  11. Nawaf_Craft1b
    Offline

    Nawaf_Craft1b Active Member Plugin Developer

    Joined:
    May 8, 2015
    Posts:
    232
    Plugins:
    1
    Minecraft User:
    Nawaf_Craft1b
    Events ITS Good
    I dont notice between them
    But i use check with minigames time
  12. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    and here the chat starts...
    because he might not be making a PvP Minigame.
    Last edited: Feb 1, 2016
    PEMapModder and Nawaf_Craft1b like this.
  13. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    Why flame? I was not trying to flame he...
    If he isn't doing a PvP minigame, he has lot of good options...
    1. If it's something like Build Battle: Set winner when his timer get 0.
    2. If it's something like interactive Parkour: PlayerInteractEvent.
    Ritch likes this.
  14. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    It is advisable to track the players in an array. It is very possible that players join that world without actually joining the game. For example, you may have moderators teleporting into them.
    Samueljh1H8sLag and PocketKiller like this.
  15. Ritch
    Offline

    Ritch Active Member

    Joined:
    Oct 4, 2015
    Posts:
    184
    Minecraft User:
    anonymous
    Doesnt work :'(
  16. Nawaf_Craft1b
    Offline

    Nawaf_Craft1b Active Member Plugin Developer

    Joined:
    May 8, 2015
    Posts:
    232
    Plugins:
    1
    Minecraft User:
    Nawaf_Craft1b
    error !
  17. Ritch
    Offline

    Ritch Active Member

    Joined:
    Oct 4, 2015
    Posts:
    184
    Minecraft User:
    anonymous
    I have no error its not work the code :/
  18. Nawaf_Craft1b
    Offline

    Nawaf_Craft1b Active Member Plugin Developer

    Joined:
    May 8, 2015
    Posts:
    232
    Plugins:
    1
    Minecraft User:
    Nawaf_Craft1b
    Look This
    its work xD
    Omar2s2 likes this.
  19. Samueljh1H8sLag
    Offline

    Samueljh1H8sLag Active Member

    Joined:
    Jun 20, 2015
    Posts:
    168
    Minecraft User:
    Samueljh1_
    Why spam the server a billion times? Just register an onDeath event and an onQuit event. Then count the worlds players (or the game-players array if you are going with @PEMapModder 's method [which I reccomend]).
  20. Nawaf_Craft1b
    Offline

    Nawaf_Craft1b Active Member Plugin Developer

    Joined:
    May 8, 2015
    Posts:
    232
    Plugins:
    1
    Minecraft User:
    Nawaf_Craft1b
    while game starts
    Check game is started

    and here the chat starts...
    because he might not be making a PvP Minigame. [Copy PocketKiller Posts :)]

Share This Page

Advertisement