3 * Reads the admins.cfg file. Do not compile this directly.
4 * This file is part of SourceMod, Copyright (C) 2004-2007 AlliedModders LLC
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 public ReadSimpleUsers()
25 BuildPath(Path_SM, g_Filename, sizeof(g_Filename), "configs/admins_simple.ini");
27 new Handle:file = OpenFile(g_Filename, "rt");
28 if (file == INVALID_HANDLE)
30 ParseError("Could not open file!");
34 while (!IsEndOfFile(file))
36 decl String:line[255];
37 if (!ReadFileLine(file, line, sizeof(line)))
43 new len = strlen(line);
44 new bool:ignoring = false;
45 for (new i=0; i<len; i++)
57 } else if (line[i] == ';') {
60 } else if (line[i] == '/'
72 if ((line[0] == '/' && line[1] == '/')
73 || (line[0] == ';' || line[0] == '\0'))
84 ReadAdminLine(const String:line[])
87 new cur_idx = StrBreak(line, auth, sizeof(auth));
92 /* This line is bad... we need at least two parameters */
96 /* Create the admin */
97 new AdminId:admin = CreateAdmin(auth);
100 new String:flags[64];
101 cur_idx = StrBreak(line[idx], flags, sizeof(flags));
106 new GroupId:gid = FindAdmGroup(flags[1]);
107 if (gid == INVALID_GROUP_ID)
109 ParseError("Invalid group detected: %s", flags[1]);
112 AdminInheritGroup(admin, gid);
114 new len = strlen(flags);
115 new bool:is_default = false;
116 for (new i=0; i<len; i++)
118 if (flags[i] < 'a' || flags[i] > 'z')
124 ParseError("Invalid flag detected: %c", flags[i]);
128 new val = flags[i] - 'a';
129 if (!g_FlagsSet[val])
131 ParseError("Invalid flag detected: %c", flags[i]);
134 SetAdminFlag(admin, g_FlagLetters[val], true);
139 new GroupId:gid = FindAdmGroup("Default");
140 if (gid != INVALID_GROUP_ID)
142 AdminInheritGroup(admin, gid);
147 /* Lastly, is there a password? */
150 decl String:password[64];
151 StrBreak(line[idx], password, sizeof(password));
152 SetAdminPassword(admin, password);
155 /* Now, bind the identity to something */
156 if (StrContains(auth, "STEAM_") == 0)
158 BindAdminIdentity(admin, AUTHMETHOD_STEAM, auth);
162 BindAdminIdentity(admin, AUTHMETHOD_IP, auth[1]);
164 BindAdminIdentity(admin, AUTHMETHOD_NAME, auth);