Forum

> > CS2D > Scripts > Detect gamemode
Forums overviewCS2D overview Scripts overviewLog in to reply

English Detect gamemode

4 replies
To the start Previous 1 Next To the start

old Detect gamemode

sheeL
User Off Offline

Quote
Hello us

Is possible detect the gamemode on server with lua or other command?

Thanks

old Re: Detect gamemode

sheeL
User Off Offline

Quote
user Cure Pikachu has written
This Lua command, I believe:
1
game("sv_gamemode")
cs2d lua cmd game cs2d cmd sv_gamemode

No, it no go works

Quote
version: the current game version
dedicated: boolean, true if server is dedicated, false otherwise
phase: game phase, 0 for freezetime, 1 for actual game
round: current round
score_t: score of terrorists (rounds won)
score_ct: score of counter-terrorists (rounds won)
winrow_t: rounds won in a row by terrorists
winrow_ct: rounds won in a row by counter-terrorists
nextmap: the next map in the map cycle (sys/mapcycle.cfg)
port: UDP port used by the server
bombplanted: boolean, true if bomb is currently planted and blinking, false otherwise


--------
@edit : Really, this command exists, but not works.
1
2
3
4
5
6
7
8
9
addhook("say","check_gamemode"); -- test
function check_gamemode(id,text)
if (string.lower(text) == "!check") then
	if game("sv_gamemode") == 1 then
		msg("It Works!")
		return 1
		end
	end
end

old Re: Detect gamemode

Cure Pikachu
User Off Offline

Quote
Of course it won't work?
cs2d lua cmd game has written
Attention: This command ALWAYS returns a string when used with game settings! Even if the setting is a number! This is important to know in case you want to use this command with mathematical/boolean operators! It may lead to problems without proper casting!

So try this:
1
2
3
4
5
6
7
8
9
addhook("say","check_gamemode"); -- test
function check_gamemode(id,text)
	if (string.lower(text) == "!check") then
		if tonumber(game("sv_gamemode")) == 1 then
			msg("It Works!")
			return 1
		end
	end
end
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview