|
| 22 Sep 2013 04:30 PM |
| Alright, so ive got my teams all set up. Theres only two. How do i make it so that when a player is added, it places the player on the team with the least amount of players? or if the teams are equal, just places them on a random team. Ive usually scripted tycoons and other single player games, so this "teams" thing is really new to me. Can anyone help me out? |
|
|
| Report Abuse |
|
|
ZachBloxx
|
  |
| Joined: 26 Jun 2013 |
| Total Posts: 2833 |
|
|
| 22 Sep 2013 04:32 PM |
| If you can script a tycoon you can script this. |
|
|
| Report Abuse |
|
|
|
| 22 Sep 2013 04:33 PM |
| Haha funny i thought the same thing, but really i dont know. Theres no set values anywhere i can find determining what team a player is on. And without a value i have no clue how to track these things, so can you help me out. |
|
|
| Report Abuse |
|
|
|
| 22 Sep 2013 04:33 PM |
| You've scripted a tycoon, but you can't do extremely basic table math? Mk... |
|
|
| Report Abuse |
|
|
|
| 22 Sep 2013 04:34 PM |
local team1 = game.Teams["Team1's Name Here"] local team2 = game.Teams["Team2's Name Here"]
game.Players.PlayerAdded:connect(function(player) if #team1:GetChildren() < #team2:GetChildren() then player.TeamColor = team1.TeamColor elseif #team2:GetChildren() < #team1:GetChildren() then player.TeamColor = team2.TeamColor elseif #team1:GetChildren() == #team2:GetChildren() then local randomizer = math.random(1,2) if randomizer == 1 then player.TeamColor = team1.TeamColor else player.TeamColor = team2.TeamColor end end end)
~rekt get |
|
|
| Report Abuse |
|
|
|
| 22 Sep 2013 04:36 PM |
| Anarchy, tycoons are much different. Its not the tables that throw me off, its the fact i cant find a set value determining a players team therefore there is no simple way to count or place players. Unless of course i create by own self-adding table which was more work than i felt like doing. Therefore i went to the forums. |
|
|
| Report Abuse |
|
|
ZachBloxx
|
  |
| Joined: 26 Jun 2013 |
| Total Posts: 2833 |
|
|
| 22 Sep 2013 04:38 PM |
I'll just be honest, I think you use free model tycoon kits. Because if you can script a tycoon, this shouldn't be too hard.
local Team1,Team2 = game:GetService('Teams').Team1,game:GetService('Teams').Team2
local TeamsTab = {Team1,Team2}
local function getTeamPlayers(teamColor) local count = 0 for i,v in pairs(game.Players:GetPlayers()) do if v.TeamColor == teamColor then count = count + 1 end end return count end
game.Players.PlayerAdded:connect(function(Player) if getTeamPlayers(Team1.TeamColor) > getTeamPlayers(Team2.TeamColor) then Player.TeamColor = Team2.TeamColor elseif getTeamPlayers(Team1.TeamColor) < getTeamPlayers(Team2.TeamColor) then Player.TeamColor = Team1.TeamColor else Player.TeamColor = TeamsTab[math.random(1,#TeamsTab)].TeamColor end end) |
|
|
| Report Abuse |
|
|
|
| 22 Sep 2013 04:44 PM |
| Actually i dont use free models to make a tycoon. ITs a totally different thing. Ive never tried this before thats why i cant do it. Cloning and removing products to recall them when a players money value is a certain number or higher is a lot different than tracking players on teams. Just thought id put that out there. |
|
|
| Report Abuse |
|
|
|
| 22 Sep 2013 04:55 PM |
Teams,Amount = game:GetService("Teams"):GetChildren(),{}
for _,Team in pairs(Teams) do for _,Player in pairs(game:GetService("Players"):GetPlayers()) do if Player.TeamColor == Team.TeamColor then Amount[TeamColor] = Amount[TeamColor] + 1 end end end
Okay, so that's part of what I came up with. My computer is broken right now, so I can't test a way to find the max value of a table, so someone will have to fill me in. |
|
|
| Report Abuse |
|
|