Raised This Month: $ Target: $400
 0% 

So I don't understand how to use GetMapDisplayName...


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
BoosterGold
Member
Join Date: Nov 2016
Old 02-22-2017 , 01:56   So I don't understand how to use GetMapDisplayName...
Reply With Quote #1

Hello,

I'm trying to clean up the "workshop/12345678/de_map" print from the Advertisements 2.0 plugin to just read the map's DisplayName.

So the current code is:

PHP Code:
    if (StrContains(sText"{currentmap}"false) != -1) {
        
GetCurrentMap(sBuffersizeof(sBuffer));
        
ReplaceString(sTextsizeof(sText), "{currentmap}"sBufferfalse);
    } 
This makes it look like this:



The code I wrote is:

PHP Code:
    if (StrContains(sText"{currentmapname}"false) != -1) {
        
GetMapDisplayName(mapdisplayNamesizeof(displayName));
        
ReplaceString(sTextsizeof(sText), "{currentmapname}"displayNamefalse);
    } 
Unfortunately, it doesn't seem to grab the right map's name:



So it looks like instead of GetMapDisplayName grabbing the current map's name, it's just taking the first map name it finds. How do I point it at the current map?
BoosterGold is offline
nosoop
Veteran Member
Join Date: Aug 2014
Old 02-22-2017 , 02:01   Re: So I don't understand how to use GetMapDisplayName...
Reply With Quote #2

Use GetCurrentMap to get the full map name, then pass that into GetMapDisplayName to get the current map's display name.
__________________
I do TF2, TF2 servers, and TF2 plugins.
I don't do DMs over Discord -- PM me on the forums regarding inquiries.
AlliedModders Releases / Github / TF2 Server / Donate (BTC / BCH / coffee)

Last edited by nosoop; 02-22-2017 at 02:02.
nosoop is offline
BoosterGold
Member
Join Date: Nov 2016
Old 02-22-2017 , 02:12   Re: So I don't understand how to use GetMapDisplayName...
Reply With Quote #3

Quote:
Originally Posted by nosoop View Post
Use GetCurrentMap to get the full map name, then pass that into GetMapDisplayName to get the current map's display name.
So something like this?

PHP Code:
    if (StrContains(sText"{currentmapname}"false) != -1) {
        
GetCurrentMap(mapsizeof(map));
        
GetMapDisplayName(mapdisplayNamesizeof(displayName));
        
ReplaceString(sTextsizeof(sText), "{currentmapname}"displayNamefalse);
    } 
BoosterGold is offline
nosoop
Veteran Member
Join Date: Aug 2014
Old 02-22-2017 , 05:51   Re: So I don't understand how to use GetMapDisplayName...
Reply With Quote #4

Pretty much.
__________________
I do TF2, TF2 servers, and TF2 plugins.
I don't do DMs over Discord -- PM me on the forums regarding inquiries.
AlliedModders Releases / Github / TF2 Server / Donate (BTC / BCH / coffee)
nosoop is offline
BoosterGold
Member
Join Date: Nov 2016
Old 02-22-2017 , 11:13   Re: So I don't understand how to use GetMapDisplayName...
Reply With Quote #5

Quote:
Originally Posted by nosoop View Post
Pretty much.
Hmm. When I write it this way it still prints the full workshop name. I think I need another hint.
BoosterGold is offline
shanapu
Veteran Member
Join Date: Apr 2015
Location: .de
Old 02-22-2017 , 11:24   Re: So I don't understand how to use GetMapDisplayName...
Reply With Quote #6

workaround:
ExplodeString, use "/" as split and print the last buffer.
__________________
coding & free software
shanapu is offline
BoosterGold
Member
Join Date: Nov 2016
Old 02-22-2017 , 11:40   Re: So I don't understand how to use GetMapDisplayName...
Reply With Quote #7

Quote:
Originally Posted by shanapu View Post
workaround:
ExplodeString, use "/" as split and print the last buffer.
If I can't get it to work the way I want to, I'll look at workarounds. For now I'd like to learn how to do it the 'real way.'

RTV's code does this:

PHP Code:
if (GetNextMap(mapsizeof(map)))
        {
            
GetMapDisplayName(mapmapsizeof(map));
            
            
PrintToChatAll("[SM] %t""Changing Maps"map); 
So it can of course be done. I just don't know which part I'm messing up.
BoosterGold is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 02-22-2017 , 20:30   Re: So I don't understand how to use GetMapDisplayName...
Reply With Quote #8

Is this on a Windows server or a Linux server?
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
BoosterGold
Member
Join Date: Nov 2016
Old 02-22-2017 , 20:53   Re: So I don't understand how to use GetMapDisplayName...
Reply With Quote #9

Quote:
Originally Posted by Powerlord View Post
Is this on a Windows server or a Linux server?
It's Windows, but I don't know what version. I rent it from a 3rd-party service.
BoosterGold is offline
Totenfluch
AlliedModders Donor
Join Date: Jan 2012
Location: Germany
Old 02-23-2017 , 13:50   Re: So I don't understand how to use GetMapDisplayName...
Reply With Quote #10

PHP Code:
#include <map_workshop_functions>
...
    
char sRawMap[PLATFORM_MAX_PATH];
    
char sMap[64];
    
GetCurrentMap(sRawMapsizeof(sRawMap));
    
RemoveMapPath(sRawMapsMapsizeof(sMap));
... 
__________________
Notable Projects:
Event Item Spawner | Scissors, Rock, Paper for ZephStore
tVip | Smart Link Remover
PLG & GGC - CS:GO Roleplay

and countless more...

I can make a helicopter shoot missles if you want me to...
Totenfluch 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 12:43.


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