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

[L4D2] how to get the entire chapter in one map


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
LinLinLin
Senior Member
Join Date: Sep 2021
Old 01-13-2024 , 03:39   [L4D2] how to get the entire chapter in one map
Reply With Quote #1

for example, if i am playing c2m1, how can i get the entire chapter name of c2? such as c2m1_highway and c2m2_fairgrounds and so on.
LinLinLin is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 01-13-2024 , 06:53   Re: [L4D2] how to get the entire chapter in one map
Reply With Quote #2

https://sm.alliedmods.net/new-api/ha.../GetCurrentMap

https://sm.alliedmods.net/new-api/ha...MapDisplayName
__________________
Do not Private Message @me
Bacardi is offline
LinLinLin
Senior Member
Join Date: Sep 2021
Old 01-13-2024 , 09:17   Re: [L4D2] how to get the entire chapter in one map
Reply With Quote #3

sorry for my poor english.
what i truely want to do is that if i am playing c2m1, i can get all the mission belong to c2, such as c2m1, c2m2, c2m3 and c2m4.

and if i am playing c5m3, i can get all the mission name about c5, etc.

Last edited by LinLinLin; 01-13-2024 at 09:17.
LinLinLin is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 01-13-2024 , 09:42   Re: [L4D2] how to get the entire chapter in one map
Reply With Quote #4

Look at my VoteMode plugin, it does this basically using Info Editor plugin:
PHP Code:
for( int i 115i++ )
{
    
Format(sTempsizeof(sTemp), "modes/coop/%d/map"i);
    
InfoEditor_GetString(0sTempsMapsizeof(sMap));

__________________
Silvers is offline
LinLinLin
Senior Member
Join Date: Sep 2021
Old 01-13-2024 , 10:29   Re: [L4D2] how to get the entire chapter in one map
Reply With Quote #5

thanks help, i finish it by myself
PHP Code:
    DirectoryListing missionlist OpenDirectory("missions"true);
    if( 
missionlist == null )
    {
        
PrintToChatAll("fail to open");
    }

    while( 
missionlist.GetNextmission_namesizeof(mission_name)) )
    {
        
PrintToChatAll("%s"mission_name);
        if( 
StrContains(mission_name".txt") == -)
            continue;
        
        
FormatEx(pathsizeof(path), "missions/%s"mission_name);
        
KeyValues kv = new KeyValues("");
        
kv.ImportFromFile(path);
        
kv.JumpToKey("modes");
        
kv.JumpToKey("coop");
        
kv.GotoFirstSubKey();
        do
        {
            
kv.GetString("Map"chapter_namesizeof(chapter_name));
            
PrintToChatAll("Get Chapter %s IN %s"chapter_namemission_name);
        }
        while( 
kv.GotoNextKey() );

        
delete kv;
    } 
LinLinLin is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 01-24-2024 , 11:47   Re: [L4D2] how to get the entire chapter in one map
Reply With Quote #6

You can extract similar parser along with already tested beautifier from my Map Changer project.
See GetMissions() + GetAddonMissions()
Of course, it require a certain amount of patience to convert it into an API due to complex algorithm.
It doesn't rely on KeyValues, per-char analysis is done, and that's why it can read malformed vpk's mission.txt
However, it store a parsed result back to KeyValues. So, please not that KeyValues methodmap is not reliable to use for Unicode range due to Valve bug. Better to store it elsewhere or write own KeyValues true Unicode implementation.
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]

Last edited by Dragokas; 01-24-2024 at 11:51.
Dragokas 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 14:40.


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