AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Solved [L4D/L4D2] Is there a way to check what game modes a server has installed? (https://forums.alliedmods.net/showthread.php?t=306815)

Psyk0tik 04-15-2018 07:37

[L4D/L4D2] Is there a way to check what game modes a server has installed?
 
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.

Visual77 04-15-2018 15:19

Re: [L4D/L4D2] Is there a way to check what game modes a server has installed?
 
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.

Psyk0tik 05-15-2018 02:49

Re: [L4D/L4D2] Is there a way to check what game modes a server has installed?
 
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
    
}




All times are GMT -4. The time now is 07:41.

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