Raised This Month: $51 Target: $400
 12% 

[CS:GO]Getting the Correct Workshop Map Name


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 03-04-2013 , 16:04   [CS:GO]Getting the Correct Workshop Map Name
Reply With Quote #1

Thought I would share this... I'm working on getting spawntools 7 to work with WorkShopMaps..

Since workshop maps aren't required to have unique names I'm not sure yet if i want to make the path.

Code:
confgis/spawntools7/<mapid>/<mapname>
or
Code:
confgis/spawntools7/<mapname>

So right now the stock gives both the ID and map name.

PHP Code:
stock GetCurrentWorkshopMap(String:szMap[], iMapBufString:szWorkShopID[], iWorkShopBuf)
{
    
decl String:szCurMap[128];
    
decl String:szCurMapSplit[2][64];
    
    
GetCurrentMap(szCurMapsizeof(szCurMap));
    
    
ReplaceString(szCurMapsizeof(szCurMap), "workshop/"""false);
    
    
ExplodeString(szCurMap"/"szCurMapSplit264);
    
    
strcopy(szMapiMapBufszCurMapSplit[1]);
    
strcopy(szWorkShopIDiWorkShopBufszCurMapSplit[0]);

TestCode:
Spoiler

Last edited by Doc-Holiday; 03-04-2013 at 16:07.
Doc-Holiday is offline
ajr1234
Senior Member
Join Date: Mar 2011
Location: Chicago, IL, U.S.A.
Old 03-05-2013 , 02:25   Re: [CS:GO]Getting the Correct Workshop Map Name
Reply With Quote #2

Thanks for the stock buddy
ajr1234 is offline
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 03-05-2013 , 03:00   Re: Re: [CS:GO]Getting the Correct Workshop Map Name
Reply With Quote #3

Quote:
Originally Posted by ajr1234 View Post
Thanks for the stock buddy
No problem. If you use spawn tools 7b there is a working Version in the last post
Doc-Holiday is offline
hamilton5
Veteran Member
Join Date: Oct 2012
Location: USA
Old 03-05-2013 , 14:29   Re: [CS:GO]Getting the Correct Workshop Map Name
Reply With Quote #4

very nice, just what I was looking for today. A big thanks for the testcode for noobs like me

edit; but what if its not a workshop map.. id comes up as current map

Last edited by hamilton5; 03-05-2013 at 16:24.
hamilton5 is offline
Acanuck
Junior Member
Join Date: Feb 2014
Old 02-08-2014 , 18:28   Re: [CS:GO]Getting the Correct Workshop Map Name
Reply With Quote #5

Anyone else not having success with Spawn Tool 7 on workshop maps?
The plugin works, but the .cfg spawn files don't seem to get generated, so we're stuck with the original map maker's spawn points.

Any ideas? Would really love to get this to work; the workshop maps really are what is keeping this game alive.
Acanuck is offline
Wilczek
AlliedModders Donor
Join Date: Oct 2012
Location: Poland
Old 10-13-2014 , 11:24   Re: [CS:GO]Getting the Correct Workshop Map Name
Reply With Quote #6

Great stock, Doc-Holiday. However, I have a problem with using it when default map is played. When I used your testcode, got the result:

Quote:
L 10/13/2014 - 16:27:40: [testcode.smx] Current Map: (non-printable character here) Workshop ID: de_train
L 10/13/2014 - 17:00:16: [testcode.smx] Current Map: de_kabul_b3 Workshop ID: 232135055
So my question is how to report correct map name with this stock if it doesn't contain /workshop/id/ string?
__________________

Last edited by Wilczek; 10-13-2014 at 11:24.
Wilczek is offline
LambdaLambda
AlliedModders Donor
Join Date: Oct 2010
Location: London
Old 10-13-2014 , 23:21   Re: [CS:GO]Getting the Correct Workshop Map Name
Reply With Quote #7

Wilczek, use that one https://forums.alliedmods.net/showthread.php?t=249866
LambdaLambda is offline
Wilczek
AlliedModders Donor
Join Date: Oct 2012
Location: Poland
Old 10-14-2014 , 08:23   Re: [CS:GO]Getting the Correct Workshop Map Name
Reply With Quote #8

Thank you LambdaLambda for that link, however I still can't get it to work.

I'm trying to parse plugin's map-specific .cfg with Powerlord's include:

PHP Code:
ParseZoneConfig()
{
    
decl String:sConfigFile[PLATFORM_MAX_PATH], String:inputMap[PLATFORM_MAX_PATH], String:sMap[64];
    
GetCurrentMap(inputMapsizeof(inputMap));
    
RemoveMapPath(inputMapsMapsizeof(sMap));
    
BuildPath(Path_SMsConfigFilesizeof(sConfigFile), "configs/antirush/%s.cfg"sMap);
    
    if(!
FileExists(sConfigFile))
    {
        
LogMessage("Current Path: %s"sConfigFile);
        return;
    }

And when default (non-Workshop) map is played, I got log message:
Quote:
L 10/14/2014 - 14:023: [mytest.smx] Current Path: addons\sourcemod\configs\antirush\.cfg
But when it's a Workshop map, it looks fine:
Quote:
L 10/14/2014 - 143:28: [mytest.smx] Current Path: addons\sourcemod\configs\antirush\de_kabul_b3 .cfg
UPDATE: Nevermid, I think I finally got it. Here is a snippet if anybody needs:
PHP Code:
ParseZoneConfig()
{
    
decl String:sConfigFile[PLATFORM_MAX_PATH], String:inputMap[PLATFORM_MAX_PATH], String:sMap[64];
    
GetCurrentMap(inputMapsizeof(inputMap));
    if (
strncmp(inputMap"workshop"8) == 0)
    {
        
//It's a workshop map
        
RemoveMapPath(inputMapsMapsizeof(sMap));
        
BuildPath(Path_SMsConfigFilesizeof(sConfigFile), "configs/antirush/%s.cfg"sMap);
    }
    else
    {
        
//It's not a workshop map
        
BuildPath(Path_SMsConfigFilesizeof(sConfigFile), "configs/antirush/%s.cfg"inputMap);
    }
    
    if(!
FileExists(sConfigFile))
    {
        
LogMessage("Current Path: %s"sConfigFile);
        return;
    }

Probably code looks ugly, but I can't do anything better
__________________

Last edited by Wilczek; 10-14-2014 at 09:12.
Wilczek is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 10-14-2014 , 10:13   Re: [CS:GO]Getting the Correct Workshop Map Name
Reply With Quote #9

RemoveMapPath has a true/false return value... if it's false, the string returned will likely be empty.

Maybe I should change that...
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 10-14-2014 at 10:14.
Powerlord is offline
LambdaLambda
AlliedModders Donor
Join Date: Oct 2010
Location: London
Old 10-14-2014 , 12:37   Re: [CS:GO]Getting the Correct Workshop Map Name
Reply With Quote #10

Quote:
Originally Posted by Wilczek View Post
PHP Code:
ParseZoneConfig()
{
    
decl String:sConfigFile[PLATFORM_MAX_PATH], String:inputMap[PLATFORM_MAX_PATH], String:sMap[64];
    
GetCurrentMap(inputMapsizeof(inputMap));
    if (
strncmp(inputMap"workshop"8) == 0)
    {
        
//It's a workshop map
        
RemoveMapPath(inputMapsMapsizeof(sMap));
        
BuildPath(Path_SMsConfigFilesizeof(sConfigFile), "configs/antirush/%s.cfg"sMap);
    }
    else
    {
        
//It's not a workshop map
        
BuildPath(Path_SMsConfigFilesizeof(sConfigFile), "configs/antirush/%s.cfg"inputMap);
    }
    
    if(!
FileExists(sConfigFile))
    {
        
LogMessage("Current Path: %s"sConfigFile);
        return;
    }

Probably code looks ugly, but I can't do anything better
I would rather save output of RemoveMapPath() into the same string, so you wouldn't have to build the path twice.

PHP Code:
   // check if the map is taken from workshop
    
if (strncmp(inputMap"workshop"8) == 0
        
RemoveMapPath(inputMapinputMapsizeof(inputMap));
        
    
BuildPath(Path_SMsConfigFilesizeof(sConfigFile), "configs/antirush/%s.cfg"inputMap); 
but your code seems to look cleaner.

Last edited by LambdaLambda; 10-14-2014 at 12:44.
LambdaLambda is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 09:31.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode