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'))
95 ReadAdminLine(const String:line[])
98 new cur_idx = BreakString(line, auth, sizeof(auth));
103 /* This line is bad... we need at least two parameters */
107 /* Create the admin */
108 new AdminId:admin = CreateAdmin();
111 new String:flags[64];
112 cur_idx = BreakString(line[idx], flags, sizeof(flags));
115 /* Read immunity level, if any */
118 if ((flag_idx = StringToIntEx(flags, level)) > 0)
120 SetAdminImmunityLevel(admin, level);
121 if (flags[flag_idx] == ':')
127 if (flags[flag_idx] == '@')
129 new GroupId:gid = FindAdmGroup(flags[flag_idx + 1]);
130 if (gid == INVALID_GROUP_ID)
132 ParseError("Invalid group detected: %s", flags[flag_idx + 1]);
135 AdminInheritGroup(admin, gid);
137 new len = strlen(flags[flag_idx]);
138 new bool:is_default = false;
139 for (new i=0; i<len; i++)
141 if (!level && flags[flag_idx + i] == '$')
143 SetAdminImmunityLevel(admin, 1);
147 if (!FindFlagByChar(flags[flag_idx + i], flag))
149 ParseError("Invalid flag detected: %c", flags[flag_idx + i]);
152 SetAdminFlag(admin, flag, true);
158 new GroupId:gid = FindAdmGroup("Default");
159 if (gid != INVALID_GROUP_ID)
161 AdminInheritGroup(admin, gid);
166 /* Lastly, is there a password? */
169 decl String:password[64];
170 BreakString(line[idx], password, sizeof(password));
171 SetAdminPassword(admin, password);
174 /* Now, bind the identity to something */
175 if (StrContains(auth, "STEAM_") == 0)
177 BindAdminIdentity(admin, AUTHMETHOD_STEAM, auth);
181 BindAdminIdentity(admin, AUTHMETHOD_IP, auth[1]);
183 BindAdminIdentity(admin, AUTHMETHOD_NAME, auth);