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

Randomize Grouping ?

Comments in 'Plugin Development' started by Radix, Jul 5, 2015.

  1. Radix
    Offline

    Radix Active Member

    Joined:
    Jul 2, 2015
    Posts:
    211
    Minecraft User:
    Dicks123
    I was wondering if there was a way you can place a player in a group via a case.. Ok let me get a bit deeper into this.

    You have a team. You store the team data in a variable.
    PHP:
    // keep track of all points
    public $redTeamPlayers = [ ];
    public 
    $blueTeamPLayers = [ ];
    public 
    $gameStats = [ ];
    Above Code Taken from https://github.com/minecraftgenius76/CaptureTheFlag/blob/master/src/mcg76/game/ctf/CTFPlugIn.php

    You run the command. /team and it would randomly place you in a group! Each Team ( Red & Blue ) would not be able to pvp other players on there team. Is there a way I can track kills by team ? Such as the capture the flag plugin logs that type of data?

    Also was wondering if I could implement this into my plugin. https://github.com/minecraftgenius76/CaptureTheFlag/blob/master/src/mcg76/game/ctf/CTFGameKit.php which is the Kits per team!

    Im new to the API , lol sorry I know php pretty good got done 49% on Code Academy! So I m just looking for help. All i have is the case code where they run the command and a empty space for thixz
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    PHP:
    const RED 0;
    const 
    BLUE 1;
    private 
    $teams;
    public function 
    init() {
      
    $this->teams = [self::RED => [], self::BLUE => []];

    public function 
    enterTeam(Player $player) {
      
    $this->teams[$team array_rand($this->teams)][] = $player;
    }
    LDX and Legoboy0215 like this.

Share This Page

Advertisement