"Detecting" number of players.


(==Troy==) #1

I was wondering if it is possible to use the number of players in the map. Is there any tools to do that? Or any alternatives?

I was thinking of making a trigger at the spawn point, which is then, once hit, dissapears and increases one of the accum values. And all the triggers (64) are gone after ~250 ms once map starts. That will provide an accum value for the number of players after warmup and will allow to modify the map, accordingly to the number of players. On the other hand this does not give a constant monitoring.

And as a side question, is there a way to alter any global accum values or setstate visible/invisible entities by an admin of the server?

Thank you,

Troy.


(kamikazee) #2

No, but you can check the values of cvars.


(==Troy==) #3

Do you mean the mapscript has read-only access to server cvars?

If so, is it possible to check the slot state? And also is it possible to create a custom cvar in etmain? (I dont have much experience with ET server.)


(DerSaidin) #4

You can make the mapscript use server cvars.

cvar CVAR_NAME trigger_if_equal VALUE SCRIPTNAME SCRIPTBLOCK

ie (example from Shaderman’s am_hydro_dam)


game_manager 
{
	spawn
	{
		wm_allied_respawntime	20
		wm_axis_respawntime		20

		//skip some stuff...

		cvar hydro_timelimit trigger_if_equal 20 game_manager spawn_20
		cvar hydro_timelimit trigger_if_equal 25 game_manager spawn_25
		cvar hydro_timelimit trigger_if_equal 30 game_manager spawn_30
		cvar hydro_timelimit trigger_if_equal 45 game_manager spawn_45
		cvar hydro_timelimit trigger_if_equal 60 game_manager spawn_60
		
		wait 350
	}

	trigger spawn_20
	{
		wm_set_round_timelimit 20
		trigger game_manager winner
	}

	trigger spawn_25
	{
		wm_set_round_timelimit 25
		trigger game_manager winner
	}

	trigger spawn_30
	{
		wm_set_round_timelimit 30
		trigger game_manager winner
	}

	trigger spawn_45
	{
		wm_set_round_timelimit 45
		trigger game_manager winner
	}

	trigger spawn_60
	{
		wm_set_round_timelimit 60
		trigger game_manager winner
	}

	trigger winner
	{
		// etc...
	}

	// etc...
}

So use that with sv_maxclients or whatever it is.

I’m not sure if you can set cvar values.


(==Troy==) #5

Ok, that makes it a lot simpler. But is it also possible to check the slot state? if it is filled/empty/not avialable? not sv_maxclients.

Thank you!.


(DerSaidin) #6

I don’t think theres a cvar with the current number of players, just the max limit.


(Ragnar_40k) #7
cvar <cvarName> <operation> <value>

You can change cvars this way (I did this in my Timebonus mod with the timelimit cvar to increase the map time limit: cvar timelimit inc “1”). Though this might not work for all cvars. Check g_script_action.c for a complete list of operations and what they do in detail.


(kamikazee) #8

Do note that some of those operations might not work, as I once posted a code fix for it. It is fixed in ETPro and ETPub, but etmain still has the broken behaviour, of course.


(Ragnar_40k) #9

You could make your map .pk3 with scripts for etmain w/o those broken commands and provide additional mapscripts for etpub etc.


(==Troy==) #10

Yes, that will work, but still, the main question is how to get the actual number of players? :slight_smile:


(Ragnar_40k) #11

Don’t know if spawn points trigger something in the script when a player spawns there?

Alternativly you could add something which gets triggered when a player gets near it and then guess the current player count from how often this happens in a certain amount of time. E.g. such a trigger under each team_CTF_redspawn entity and then count the triggered events in 60 second intervals and estimate the player count from it.

This approach should also work better with altered spawn times: shorter spawntimes usually lead to a higher “perceived” player count.