Find out current map

All other Source.Python topics and issues.
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

Find out current map

Postby BackRaw » Mon Sep 03, 2012 11:09 am

Hi,

is there a variable provided to find out the current map on the server or is that on the todo list?
User avatar
Kami
Global Moderator
Posts: 263
Joined: Wed Aug 15, 2012 1:24 am
Location: Germany

Postby Kami » Mon Sep 03, 2012 11:29 am

host_map - Current map name.

I found this in the CVar list (CS:GO built in CVars). I hope it fits your needs :)
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Mon Sep 03, 2012 2:08 pm

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
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

Postby BackRaw » Mon Sep 03, 2012 7:45 pm

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.
User avatar
Spiked
Junior Member
Posts: 15
Joined: Mon Aug 27, 2012 8:00 pm
Location: Texas

Postby Spiked » Mon Sep 03, 2012 9:20 pm

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?
User avatar
Ayuto
Project Leader
Posts: 2195
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Postby Ayuto » Mon Sep 03, 2012 9:43 pm

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)
User avatar
Spiked
Junior Member
Posts: 15
Joined: Mon Aug 27, 2012 8:00 pm
Location: Texas

Postby Spiked » Mon Sep 03, 2012 9:54 pm

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

Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 33 guests