Update CS:GO team score gamedata.
3 * =============================================================================
4 * SourceMod Basecommands Plugin
5 * Provides exec cfg functionality
7 * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
8 * =============================================================================
10 * This program is free software; you can redistribute it and/or modify it under
11 * the terms of the GNU General Public License, version 3.0, as published by the
12 * Free Software Foundation.
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
19 * You should have received a copy of the GNU General Public License along with
20 * this program. If not, see <http://www.gnu.org/licenses/>.
22 * As a special exception, AlliedModders LLC gives you permission to link the
23 * code of this program (as well as its derivative works) to "Half-Life 2," the
24 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
25 * by the Valve Corporation. You must obey the GNU General Public License in
26 * all respects for all other code used. Additionally, AlliedModders LLC grants
27 * this exception to all derivative works. AlliedModders LLC defines further
28 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
29 * or <http://www.sourcemod.net/license.php>.
34 new Handle:g_ConfigMenu = INVALID_HANDLE;
36 PerformExec(client, String:path[])
38 if (!FileExists(path))
40 ReplyToCommand(client, "[SM] %t", "Config not found", path[4]);
44 ShowActivity2(client, "[SM] ", "%t", "Executed config", path[4]);
46 LogAction(client, -1, "\"%L\" executed config (file \"%s\")", client, path[4]);
48 ServerCommand("exec \"%s\"", path[4]);
51 public AdminMenu_ExecCFG(Handle:topmenu,
53 TopMenuObject:object_id,
58 if (action == TopMenuAction_DisplayOption)
60 Format(buffer, maxlength, "%T", "Exec CFG", param);
62 else if (action == TopMenuAction_SelectOption)
64 DisplayMenu(g_ConfigMenu, param, MENU_TIME_FOREVER);
68 public MenuHandler_ExecCFG(Handle:menu, MenuAction:action, param1, param2)
70 if (action == MenuAction_Cancel)
72 if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
74 DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
77 else if (action == MenuAction_Select)
79 decl String:path[256];
81 GetMenuItem(menu, param2, path, sizeof(path));
83 PerformExec(param1, path);
85 else if (action == MenuAction_Display)
87 decl String:title[128];
88 Format(title, sizeof(title), "%T", "Choose Config", param1);
89 SetPanelTitle(Handle:param2, title);
93 public Action:Command_ExecCfg(client, args)
97 ReplyToCommand(client, "[SM] Usage: sm_execcfg <filename>");
98 return Plugin_Handled;
101 new String:path[64] = "cfg/";
102 GetCmdArg(1, path[4], sizeof(path)-4);
104 PerformExec(client, path);
106 return Plugin_Handled;
109 new Handle:config_parser = INVALID_HANDLE;
112 if (config_parser == INVALID_HANDLE)
114 config_parser = SMC_CreateParser();
117 SMC_SetReaders(config_parser, NewSection, KeyValue, EndSection);
119 if (g_ConfigMenu != INVALID_HANDLE)
121 CloseHandle(g_ConfigMenu);
124 g_ConfigMenu = CreateMenu(MenuHandler_ExecCFG, MenuAction_Display);
125 SetMenuTitle(g_ConfigMenu, "%T", "Choose Config", LANG_SERVER);
126 SetMenuExitBackButton(g_ConfigMenu, true);
128 decl String:configPath[256];
129 BuildPath(Path_SM, configPath, sizeof(configPath), "configs/adminmenu_cfgs.txt");
131 if (!FileExists(configPath))
133 LogError("Unable to locate exec config file, no maps loaded.");
139 new SMCError:err = SMC_ParseFile(config_parser, configPath, line);
140 if (err != SMCError_Okay)
142 decl String:error[256];
143 SMC_GetErrorString(err, error, sizeof(error));
144 LogError("Could not parse file (line %d, file \"%s\"):", line, configPath);
145 LogError("Parser encountered error: %s", error);
151 public SMCResult:NewSection(Handle:smc, const String:name[], bool:opt_quotes)
156 public SMCResult:KeyValue(Handle:smc, const String:key[], const String:value[], bool:key_quotes, bool:value_quotes)
158 AddMenuItem(g_ConfigMenu, key, value);
161 public SMCResult:EndSection(Handle:smc)