Amount of players to start round

Hello. My friend and I are trying to modify the FLOODMOD script. We are just using v1.1 or something but anyways I want to take and make it so that if there are not 2 people on the server then the round doesn’t start. Just have it loop back to the build time section.

To do this i was thinking taking “amount of players” and storing that as X. Problem is idk how to store that as a variable or even retrieve the amount of players on the server. I was googling it and came across “number_of_players ()”. Not sure if this is right. If this is would it just be like X = “number_of_players ()”

The rest i think i can figure out pretty easy, i just need to no how to get amount of players stored as X or something.


X = #players.GetHumans()
X = table.Count(players.GetHumans())

Now with this save the amount of players as like 1 2 3 4 5 6 …
so i could do

if x > 2

make it return to the build time?


if ( #player.GetAll( ) > 0 ) then

Ok so my final thing would be:

function FightTimeFunc()

if FightTime <= 0 then
	if ( #player.GetAll( ) < 2 ) then 
			TimerStatus = 4
			Teams = false
			FightTime = FIV
			FightTime = FightTime - 1
	BuildTime = (BuildTime - 1)


I probably didnt do the go back to build time thing correctly. How would i properly set it back to build time?

Holy shit you can use # to do that? I’ve been writing table.Count the entire time…

Yea I don’t see why that wouldn’t work.


lol, Yea they are both the same thing

Hmm, it didnt work. Made my server just stop responding. Is there a steam account i could add to talk to you?


nvm, i figured it out. But how do you make it say somthing in game. I tried

TimerStatus = 4
ChatPrint("Not Enough Players. There must be atleast 2 players on the server to start a round")

but it doesnt send any message

Not true. ‘#’ is equivalent to table.maxn (which gets the max numerical key in a table, and is much faster) whereas table.Count is something added by garry (you can tell by the capital C) that counts ALL indicies of a table (including strings, not including indexes that are not there)

Some examples where they’d give different values:
local tbl = {}
tbl[1] = “first”
tbl[2] = “second”
tbl[“third”] = 3

print(#tbl) --would equal 2, as 2 is the highest numerical key
print(table.Count(tbl)) --would be 3, as there are 3 keys.

– And another example

local another = {}
another[9001] = “lol, lol, lol another meme”

print(#tbl) --would print 9001, even though it is the only key
print(table.Cound(tbl)) – would print 1, because there is only 1 key

It is important to know the difference between the two.