PDA

View Full Version : (Request) A few more questions.


Bridget
03-15-2009, 02:46 PM
I need (if possible) a lua function that:


Forces all players to spectator team.
Picks one random spectator, forces him to blue team.


Second, how do I check the player-count for a team?
Last, how do I move a single player to another team?

Thanks in advance.

squeek.
03-15-2009, 07:59 PM
Forces all players to spectator:

ApplyToAll({ AT.kChangeTeamSpectator })


Forces one random player from spec to blue:
local c = Collection()

c:GetByFilter( {CF.kPlayers, CF.kTeamSpectator} )

local count = c:Count()
local randomplayer = math.random(1, count)

local player = c:Element( randomplayer )

ApplyToPlayer( player, { AT.kChangeTeamBlue } )


Player count for a team:

local team = GetTeam( Team.kBlue )

local numplayers = team:GetNumPlayers()


Single player to another team (with respawn):

ApplyToPlayer( player, { AT.kChangeTeamBlue, AT.kRespawnPlayers } )

Not sure if they are all working. :)