Triggering build.
3 * =============================================================================
4 * SourceMod Admin File Reader Plugin
5 * Reads the admins.cfg file. Do not compile this directly.
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 public ReadSimpleUsers()
36 BuildPath(Path_SM, g_Filename, sizeof(g_Filename), "configs/admins_simple.ini");
38 new Handle:file = OpenFile(g_Filename, "rt");
39 if (file == INVALID_HANDLE)
41 ParseError("Could not open file!");
45 while (!IsEndOfFile(file))
47 decl String:line[255];
48 if (!ReadFileLine(file, line, sizeof(line)))
54 new len = strlen(line);
55 new bool:ignoring = false;
56 for (new i=0; i<len; i++)
68 } else if (line[i] == ';') {
71 } else if (line[i] == '/'
83 if ((line[0] == '/' && line[1] == '/')
84 || (line[0] == ';' || line[0] == '\0'))
97 DecodeAuthMethod(const String:auth[], String:method[32], &offset)
99 if ((StrContains(auth, "STEAM_") == 0) || (strncmp("0:", auth, 2) == 0) || (strncmp("1:", auth, 2) == 0))
101 strcopy(method, sizeof(method), AUTHMETHOD_STEAM);
108 strcopy(method, sizeof(method), AUTHMETHOD_IP);
113 strcopy(method, sizeof(method), AUTHMETHOD_NAME);
119 ReadAdminLine(const String:line[])
124 decl String:auth_method[32];
125 new idx, cur_idx, auth_offset;
127 if ((cur_idx = BreakString(line, auth, sizeof(auth))) == -1)
129 /* This line is bad... we need at least two parameters */
135 /* Check if we can bind beforehand */
136 DecodeAuthMethod(auth, auth_method, auth_offset);
137 if ((admin = FindAdminByIdentity(auth_method, auth[auth_offset])) == INVALID_ADMIN_ID)
139 /* There is no binding, create the admin */
140 admin = CreateAdmin();
148 new String:flags[64];
149 cur_idx = BreakString(line[idx], flags, sizeof(flags));
152 /* Read immunity level, if any */
155 if ((flag_idx = StringToIntEx(flags, level)) > 0)
157 SetAdminImmunityLevel(admin, level);
158 if (flags[flag_idx] == ':')
164 if (flags[flag_idx] == '@')
166 new GroupId:gid = FindAdmGroup(flags[flag_idx + 1]);
167 if (gid == INVALID_GROUP_ID)
169 ParseError("Invalid group detected: %s", flags[flag_idx + 1]);
172 AdminInheritGroup(admin, gid);
176 new len = strlen(flags[flag_idx]);
177 new bool:is_default = false;
178 for (new i=0; i<len; i++)
180 if (!level && flags[flag_idx + i] == '$')
182 SetAdminImmunityLevel(admin, 1);
186 if (!FindFlagByChar(flags[flag_idx + i], flag))
188 ParseError("Invalid flag detected: %c", flags[flag_idx + i]);
191 SetAdminFlag(admin, flag, true);
197 new GroupId:gid = FindAdmGroup("Default");
198 if (gid != INVALID_GROUP_ID)
200 AdminInheritGroup(admin, gid);
205 /* Lastly, is there a password? */
208 decl String:password[64];
209 BreakString(line[idx], password, sizeof(password));
210 SetAdminPassword(admin, password);
213 /* Now, bind the identity to something */
216 if (!BindAdminIdentity(admin, auth_method, auth[auth_offset]))
218 /* We should never reach here */
220 ParseError("Failed to bind identity %s (method %s)", auth[auth_offset], auth_method);