mirror of
https://codeberg.org/spire/autoexec.git
synced 2026-06-03 18:24:06 +02:00
Add support for ultiduo and cp_hadal
This commit is contained in:
parent
0d8aa60583
commit
5887ca69ec
2 changed files with 58 additions and 25 deletions
Binary file not shown.
|
|
@ -6,7 +6,7 @@ public Plugin:myinfo = {
|
||||||
name = "autoexec",
|
name = "autoexec",
|
||||||
author = "Icewind",
|
author = "Icewind",
|
||||||
description = "Automatically execute the right config for a map",
|
description = "Automatically execute the right config for a map",
|
||||||
version = "0.1",
|
version = "0.2",
|
||||||
url = "https://spire.tf"
|
url = "https://spire.tf"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -14,6 +14,7 @@ new StringMap:mapPrefixMap;
|
||||||
new StringMap:mapOverwriteMap;
|
new StringMap:mapOverwriteMap;
|
||||||
new StringMap:mapTypeMap;
|
new StringMap:mapTypeMap;
|
||||||
new StringMap:gameModeMap;
|
new StringMap:gameModeMap;
|
||||||
|
new StringMap:configOverwriteMap;
|
||||||
|
|
||||||
new Handle:CvarLeague = INVALID_HANDLE;
|
new Handle:CvarLeague = INVALID_HANDLE;
|
||||||
new Handle:CvarMode = INVALID_HANDLE;
|
new Handle:CvarMode = INVALID_HANDLE;
|
||||||
|
|
@ -23,48 +24,88 @@ public OnPluginStart() {
|
||||||
mapOverwriteMap = new StringMap();
|
mapOverwriteMap = new StringMap();
|
||||||
mapTypeMap = new StringMap();
|
mapTypeMap = new StringMap();
|
||||||
gameModeMap = new StringMap();
|
gameModeMap = new StringMap();
|
||||||
|
configOverwriteMap = new StringMap();
|
||||||
|
|
||||||
CvarLeague = CreateConVar("sm_autoexec_league", "ugc", "league to execute the configs for (ugc or etf2l)", FCVAR_PROTECTED);
|
CvarLeague = CreateConVar("sm_autoexec_league", "ugc", "league to execute the configs for (ugc or etf2l)", FCVAR_PROTECTED);
|
||||||
CvarMode = CreateConVar("sm_autoexec_mode", "9v9", "gamemode to execute the config for (9v9, 6v6 or 4v4)", FCVAR_PROTECTED);
|
CvarMode = CreateConVar("sm_autoexec_mode", "9v9", "gamemode to execute the config for (9v9, 6v6 or 4v4)", FCVAR_PROTECTED);
|
||||||
|
|
||||||
RegServerCmd("sm_autoexec", AutoExec, "Execute the config for the current map and select league and gamemode");
|
RegServerCmd("sm_autoexec", AutoExec, "Execute the config for the current map and select league and gamemode");
|
||||||
|
RegServerCmd("sm_getexec", GetExec, "Get the name of the config for a specific map");
|
||||||
|
|
||||||
mapTypeMap.SetString("5cp", "standard");
|
mapTypeMap.SetString("5cp", "standard");
|
||||||
|
|
||||||
mapPrefixMap.SetString("pl_", "stopwatch");
|
mapPrefixMap.SetString("pl_", "stopwatch");
|
||||||
mapPrefixMap.SetString("cp_", "5cp");
|
mapPrefixMap.SetString("cp_", "5cp");
|
||||||
mapPrefixMap.SetString("kot", "koth");
|
mapPrefixMap.SetString("koth_", "koth");
|
||||||
mapPrefixMap.SetString("ctf", "ctf");
|
mapPrefixMap.SetString("ctf_", "ctf");
|
||||||
mapPrefixMap.SetString("ult", "ultiduo");
|
|
||||||
|
configOverwriteMap.SetString("ultiduo_", "etf2l_ultiduo");
|
||||||
|
|
||||||
mapOverwriteMap.SetString("cp_steel", "stopwatch");
|
mapOverwriteMap.SetString("cp_steel", "stopwatch");
|
||||||
mapOverwriteMap.SetString("cp_gravelpit", "stopwatch");
|
mapOverwriteMap.SetString("cp_gravelpit", "stopwatch");
|
||||||
|
mapOverwriteMap.SetString("cp_hadal", "stopwatch");
|
||||||
|
|
||||||
gameModeMap.SetString("9v9", "hl");
|
gameModeMap.SetString("9v9", "hl");
|
||||||
}
|
}
|
||||||
|
|
||||||
public OnMapStart() {
|
public OnMapStart() {
|
||||||
decl String:config[128];
|
decl String:config[128];
|
||||||
GetConfig(config);
|
decl String:map[128];
|
||||||
|
GetCurrentMap(map, sizeof(map));
|
||||||
|
GetConfig(map, config);
|
||||||
|
|
||||||
ExecCFG(config);
|
ExecCFG(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Action:GetExec(args) {
|
||||||
|
new String:map[128];
|
||||||
|
GetCmdArg(1, map, sizeof(map));
|
||||||
|
decl String:config[128];
|
||||||
|
GetConfig(map, config);
|
||||||
|
|
||||||
|
PrintToChatAll("Config: %s", config);
|
||||||
|
return Plugin_Handled;
|
||||||
|
}
|
||||||
|
|
||||||
public Action:AutoExec(args) {
|
public Action:AutoExec(args) {
|
||||||
decl String:config[128];
|
decl String:config[128];
|
||||||
GetConfig(config);
|
decl String:map[128];
|
||||||
|
GetCurrentMap(map, sizeof(map));
|
||||||
|
GetConfig(map, config);
|
||||||
|
|
||||||
ExecCFG(config);
|
ExecCFG(config);
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GetConfig(String:config[128]) {
|
public PrefixSearch(StringMap:map, String:query[128], String:result[128]) {
|
||||||
decl String:mapType[32];
|
new StringMapSnapshot:keys = map.Snapshot();
|
||||||
|
decl String:key[16];
|
||||||
|
new length = keys.Length;
|
||||||
|
bool found = false;
|
||||||
|
for (new i = 0; i < length; i++) {
|
||||||
|
keys.GetKey(i, key, sizeof(key));
|
||||||
|
if (strncmp(key, query, strlen(key)) == 0) {
|
||||||
|
found = true;
|
||||||
|
map.GetString(key, result, sizeof(result));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CloseHandle(keys);
|
||||||
|
return found;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GetConfig(String:map[128], String:config[128]) {
|
||||||
|
decl String:mapType[128];
|
||||||
decl String:league[8];
|
decl String:league[8];
|
||||||
decl String:gamemode[8];
|
decl String:gamemode[8];
|
||||||
|
|
||||||
|
if (PrefixSearch(configOverwriteMap, map, config)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
GetLeague(league);
|
GetLeague(league);
|
||||||
GetLeagueMapType(mapType, league);
|
GetLeagueMapType(map, mapType, league);
|
||||||
GetGameMode(gamemode, league);
|
GetGameMode(gamemode, league);
|
||||||
|
|
||||||
Format(config, sizeof(config), "%s_%s_%s", league, gamemode, mapType);
|
Format(config, sizeof(config), "%s_%s_%s", league, gamemode, mapType);
|
||||||
|
|
@ -86,9 +127,9 @@ public GetGameMode(String:leagueGamemode[8], String:league[8]) {
|
||||||
leagueGamemode = gamemode;
|
leagueGamemode = gamemode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GetLeagueMapType(String:leagueMapType[32], String:league[8]) {
|
public GetLeagueMapType(String:map[128], String:leagueMapType[128], String:league[8]) {
|
||||||
decl String:mapType[32];
|
decl String:mapType[128];
|
||||||
GetMapType(mapType);
|
GetMapType(map, mapType);
|
||||||
|
|
||||||
if (strncmp("ugc", league, strlen(league)) == 0) {
|
if (strncmp("ugc", league, strlen(league)) == 0) {
|
||||||
if (mapTypeMap.GetString(mapType, leagueMapType, sizeof(leagueMapType))) {
|
if (mapTypeMap.GetString(mapType, leagueMapType, sizeof(leagueMapType))) {
|
||||||
|
|
@ -98,22 +139,14 @@ public GetLeagueMapType(String:leagueMapType[32], String:league[8]) {
|
||||||
leagueMapType = mapType;
|
leagueMapType = mapType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GetMapType(String:mapType[32]) {
|
public GetMapType(String:map[128], String:mapType[128]) {
|
||||||
decl String:map[128];
|
if (PrefixSearch(mapOverwriteMap, map, mapType)) {
|
||||||
GetCurrentMap(map, sizeof(map));
|
|
||||||
|
|
||||||
if (mapOverwriteMap.GetString(map, mapType, sizeof(mapType))) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
decl String:prefix[4];
|
|
||||||
strcopy(prefix, sizeof(prefix), map);
|
|
||||||
|
|
||||||
if (mapPrefixMap.GetString(prefix, mapType, sizeof(mapType))) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!PrefixSearch(mapPrefixMap, map, mapType)) {
|
||||||
mapType = "5cp"; //fallback
|
mapType = "5cp"; //fallback
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue