Page 1 of 1

Find out current map

Posted: Mon Sep 03, 2012 11:09 am
by BackRaw
Hi,

is there a variable provided to find out the current map on the server or is that on the todo list?

Posted: Mon Sep 03, 2012 11:29 am
by Kami
host_map - Current map name.

I found this in the CVar list (CS:GO built in CVars). I hope it fits your needs :)

Posted: Mon Sep 03, 2012 2:08 pm
by satoon101
We have discussed including events and variables with SP. A map start event will probably be getting added at some point. If host_map works, we will not have a need to include a current map variable. If not, that is a possible variable that could be added.

Satoon

Posted: Mon Sep 03, 2012 7:45 pm
by BackRaw
satoon101 wrote:We have discussed including events and variables with SP. A map start event will probably be getting added at some point. If host_map works, we will not have a need to include a current map variable. If not, that is a possible variable that could be added.

Satoon


Alright thanks. host_map would be cool, can't test it now though.

Posted: Mon Sep 03, 2012 9:20 pm
by Spiked
host_map does indeed hold the current map name, this includes ".bsp"
does anyone know if it's possible to pipe the value of one cvar into a console command?

Say I wanted to change the map to the current map (don't ask why)... I would want...
changelevel host_map
or
map host_map

any clue if this is possible to do?

Posted: Mon Sep 03, 2012 9:43 pm
by Ayuto
I'm pretty sure that this will work:

Syntax: Select all

from Source.Engine import GetEngine
from Source.Cvar import GetCvar

engine = GetEngine()
cvar = GetCvar()

def getCurrentMap():
current_map = cvar.FindVar('host_map').GetString()
return '' if not current_map else current_map.rsplit('.bsp', 1)[0]

def player_say(game_event):
current_map = getCurrentMap()
engine.ChangeLevel(current_map, None)

Posted: Mon Sep 03, 2012 9:54 pm
by Spiked
I wanted to do it w/o SP ;P

trying to build out some config files
... warmups don't take affect until you change map... even mp_restartgame doesn't do it