[CSGO] Get current map?
[CSGO] Get current map?
Besides events/listeners like OnLevelInit, I was wondering if there was any other way to get the current map the server is on? I have a SayCommand that changes the map so I would like to access the current map on-demand to make sure the user isn't trying to switch to the map we're already on.
Re: [CSGO] Get current map?
engines.server.server.map_name I believe :)
However I think you have to create your own Server instance. So instead import Server and create an instance first.
Either this or update a global variable :P
Syntax: Select all
from engines.server import server
map_name = server.map_name
However I think you have to create your own Server instance. So instead import Server and create an instance first.
Syntax: Select all
from engines.server import Server
server = Server()
map_name = server.map_name
Either this or update a global variable :P
Syntax: Select all
from listeners import OnLevelInit
g_mapname = None
@OnLevelInit
def _levelinit(map):
global g_mapname
g_mapname = map
- L'In20Cible
- Project Leader
- Posts: 1536
- Joined: Sat Jul 14, 2012 9:29 pm
- Location: Québec
Re: [CSGO] Get current map?
Syntax: Select all
from engines.server import global_vars
print(global_vars.map_name)
Re: [CSGO] Get current map?
Predz wrote:However I think you have to create your own Server instance. So instead import Server and create an instance first.Syntax: Select all
from engines.server import Server
server = Server()
map_name = server.map_name
No, you first approach was correct.
http://wiki.sourcepython.com/developing ... r.__init__
But I would stick with L'In20Cible's solution, because the Server interface requires signatures/symbols (which could change and break) in some games while the global_vars instance doesn't.
Re: [CSGO] Get current map?
Thanks Ayuto :)
Yeh my reasoning behind this was due to this .py file not importing "server" anywhere and only being defined as "None".
Yeh my reasoning behind this was due to this .py file not importing "server" anywhere and only being defined as "None".
Re: [CSGO] Get current map?
Thank you all!
Re: [CSGO] Get current map?
Im just wondering why:
never works. It always returns <function getCurrentMap at 0x2549E8A0>
Syntax: Select all
def getCurrentMap():
mapName = global_vars.map_name
return mapName
never works. It always returns <function getCurrentMap at 0x2549E8A0>
Re: [CSGO] Get current map?
How do you call it?

My plugins: Map Cycle • Killstreaker • DeadChat • Infinite Jumping • TripMines • AdPurge • Bot Damage • PLRBots • Entity AntiSpam
Hail, Companion. [...] Hands to yourself, sneak thief.

Re: [CSGO] Get current map?
Looks to me like it's not being 'called' at all. Seems to me to be something like:
when it should be something more like:
Syntax: Select all
def some_function():
current_map = getCurrentMap
print(current_map)
when it should be something more like:
Syntax: Select all
def some_function():
current_map = getCurrentMap()
print(current_map)
Re: [CSGO] Get current map?
Im dumb.. Sorry.
I executed it with () but forgot to save the file, so it was as satoon said, without the ()'.
Damn notepad got me again
I executed it with () but forgot to save the file, so it was as satoon said, without the ()'.
Damn notepad got me again
Return to “Plugin Development Support”
Who is online
Users browsing this forum: No registered users and 70 guests