Players.SetPowerups
Declaration
Players.SetPowerups(number PlayerID, PowerupContainer Powerups, Operation Operation)
Description
Adds, sets or subtracts powerups for a player, depending on Operation.
Powerups such as Bombs, Blast Radius and Speed are stored as numbers in the Powerups container, so if Operation equals Add, then the provided amount of them will be given to the player. And likewise, if Operation equals Subtract, then the given amount will be taken away from the player. Last but not least, Operation.Set will overwrite the powerups of a player entirely.
In case of powerups such as Shield, Pushing and Jumping, which are booleans, they will be given or taken away depending on whether or not they're set to true. That is, if Operation equals Add, and GrantsShield is set to true, then it will be given to the player. And if Operation is set to Subtract, while GrantsShield is set to true, it will be taken away.
--Retrieves all players
local allPlayers = Players.GetAll();
--Creates a PowerupContainer object, and fills it with values
local powers = Powerups();
powers.BlastRadius = 5;
powers.Bombs = 2;
powers.Speed = 3;
powers.GrantsShield = true;
powers.GrantsPushing = false;
powers.GrantsJumping = true;
--Gives the first player the powerups
Players.SetPowerups(allPlayers[1], powers, Operation.Add);
--Takes the powerups from the first player
Players.SetPowerups(allPlayers[1], powers, Operation.Subtract);
--Sets first player's powerups to the contents of the container
Players.SetPowerups(allPlayers[1], powers, Operation.Set);
Declaration
Players.SetPowerups(number PlayerID, TargetPlayer Mode, Vector3 Origin, PowerupContainer Powerups, Operation Operation)
Description
Adds, sets or subtracts powerups for specific players, depending on Operation and Mode. If using Mode set to Closest or Furthest, the Origin parameter will be used as the point of reference, otherwise Vector3.zero can be passed.
Powerups such as Bombs, Blast Radius and Speed are stored as numbers in the Powerups container, so if Operation equals Add, then the provided amount of them will be given to the player. And likewise, if Operation equals Subtract, then the given amount will be taken away from the player. Last but not least, Operation.Set will overwrite the powerups of a player entirely.
In case of powerups such as Shield, Pushing and Jumping, which are booleans, they will be given or taken away depending on whether or not they're set to true. That is, if Operation equals Add, and GrantsShield is set to true, then it will be given to the player. And if Operation is set to Subtract, while GrantsShield is set to true, it will be taken away.
Check TargetPlayer for all possible Mode values.
--Retrieves all players
local allPlayers = Players.GetAll();
--Creates a PowerupContainer object, and fills it with values
local powers = Powerups();
powers.BlastRadius = 5;
powers.Bombs = 2;
powers.Speed = 3;
powers.GrantsShield = true;
powers.GrantsPushing = false;
powers.GrantsJumping = true;
--Gives everyone but the first player the powerups
Players.SetPowerups(allPlayers[1], TargetPlayer.Others, Vector3.zero, powers, Operation.Add);
--Takes away the powerups from a random player
Players.SetPowerups(0, TargetPlayer.Random, Vector3.zero, powers, Operation.Subtract);
--Sets the second player's powerups
Players.SetPowerups(allPlayers[2], TargetPlayer.Initiator, Vector3.zero, powers, Operation.Set);
Declaration
Players.SetPowerups(Dictionary<number> PlayerIDs, PowerupContainer Powerups, Operation Operation)
Description
Adds, sets or subtracts powerups for specific players, depending on Operation.
Powerups such as Bombs, Blast Radius and Speed are stored as numbers in the Powerups container, so if Operation equals Add, then the provided amount of them will be given to the player. And likewise, if Operation equals Subtract, then the given amount will be taken away from the player. Last but not least, Operation.Set will overwrite the powerups of a player entirely.
In case of powerups such as Shield, Pushing and Jumping, which are booleans, they will be given or taken away depending on whether or not they're set to true. That is, if Operation equals Add, and GrantsShield is set to true, then it will be given to the player. And if Operation is set to Subtract, while GrantsShield is set to true, it will be taken away.
--Retrieves all players
local allPlayers = Players.GetAll();
--Creates a PowerupContainer object, and fills it with values
local powers = Powerups();
powers.BlastRadius = 5;
powers.Bombs = 2;
powers.Speed = 3;
powers.GrantsShield = true;
powers.GrantsPushing = false;
powers.GrantsJumping = true;
--Gives everyone the powerups
Players.SetPowerups(allPlayers, powers, Operation.Add);
--Takes away the powerups specifically from player 2 and 4
Players.SetPowerups({allPlayers[2], allPlayers[4]}, powers, Operation.Add);
--Sets the second player's powerups
Players.SetPowerups(allPlayers[2], powers, Operation.Set);
Note
Player IDs must be whole numbers.
Keep in mind the Player IDs aren't necessarily ordered. Players can join and leave in the lobby, potentially several times, increasing their ID, which is why using Players.GetAll is advised if you want to target a player at a specific slot.
You can also pass Player objects instead of numbers as IDs.