Raised This Month: $ Target: $400
 0% 

Solved [L4D/L4D2] Is there a way to check what game modes a server has installed?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 04-15-2018 , 08:37   [L4D/L4D2] Is there a way to check what game modes a server has installed?
Reply With Quote #1

I'd like to know if there's a function that can detect what game modes are available on a server? Something similar to how ReadMapList() works.
__________________

Last edited by Psyk0tik; 05-15-2018 at 03:52. Reason: Marked as [Solved]
Psyk0tik is offline
Visual77
Veteran Member
Join Date: Jan 2009
Old 04-15-2018 , 16:19   Re: [L4D/L4D2] Is there a way to check what game modes a server has installed?
Reply With Quote #2

I'm not sure I fully understand. Game modes can be set from lobbies or from root access. Other servers could be running a versus/coop only server, (by preventing mp_gamemode overriding in a plugin or server.cfg).

In general, a game server can support all of the game modes, that's why you probably can't predict what "game modes" a server has installed.

You could however make a query on the sv_gametypes+mp_gamemode value, still that doesn't guarantee anything in my opinion.

Last edited by Visual77; 04-15-2018 at 16:21.
Visual77 is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 05-15-2018 , 03:49   Re: [L4D/L4D2] Is there a way to check what game modes a server has installed?
Reply With Quote #3

Solution:

PHP Code:
g_cvASSGameMode FindConVar("mp_gamemode");
g_cvASSGameType FindConVar("sv_gametypes");

char sModeName[64];
g_cvASSGameMode.GetString(sModeNamesizeof(sModeName)); // Gets the size of the "mp_gamemode" string
if (StrEqual(sModeName"coop"false)) // If the string equals "coop" mode
{
    
// Do stuff here
}
char sGameType[2049]; // Holds the amount of characters within a string (If for whatever reason a server owner wants to filter so many game modes through "sv_gametypes")
g_cvASSGameType.GetString(sGameTypesizeof(sGameType)); // Gets the size of the "sv_gametypes" string
char sTypes[64][32]; // First index = How many game modes buffer can hold, Second index = How many characters allowed for each game mode
ExplodeString(sGameType","sTypessizeof(sTypes), sizeof(sTypes[])); // Separate game modes and stores them inside individual arrays
for (int iMode 0iMode sizeof(sTypes); iMode++)
{
    if (
StrContains(sGameTypesTypes[iMode], false) != -&& sTypes[iMode][0] != '\0'// If one of the arrays contains a game mode and it's not an empty array
    
{
        
// Do stuff here
    
}

__________________

Last edited by Psyk0tik; 05-21-2018 at 14:09.
Psyk0tik is offline
Reply


Thread Tools
Display Modes

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 11:40.


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