• find smaller number using logical operator
    3 replies, posted
How can i find a smaller number using a logical operator? Like, if i want to have a team balancing system, how could i tell it to set the team of a newly spawned player to the team with the least amount of players?
[lua]local function getSmallestTeam() local amount, ret = math.huge, 1 for id, t in pairs(team.GetAllTeams()) do local n = team.NumPlayers(id); if n < amount then ret = id; amount = n end end return ret; end ply:SetTeam(getSmallestTeam() or team.Random())[/lua]
But if i just have two teams, how can i use a logical operator to check which one is smaller? Can i?
[lua]if team.NumPlayers(TEAM_ONE) < team.NumPlayers(TEAM_TWO) then -- code here end[/lua]
Sorry, you need to Log In to post a reply to this thread.