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.

Thanks

X = #players.GetHumans()
or
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
then

else
make it return to the build time?

Correct.

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
			LowerWater()
			RemoveAllWeapons()
			GivePhysGuns()
			RecieveBonus()
			ResetHealth()
			FightTime = FIV
		else  
			FightTime = FightTime - 1
		end
	else
	BuildTime = (BuildTime - 1)

end

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.

[editline]11:28PM[/editline]

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?

[editline]12:40AM[/editline]

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

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

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:
[lua]
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
[/lua]

It is important to know the difference between the two.