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)))
42 if ((line[0] == '/' && line[1] == '/')
43 || (line[0] == ';' || line[0] == '\0'))
54 ReadAdminLine(const String:line[])
57 new cur_idx = StrBreak(line, auth, sizeof(auth));
62 /* This line is bad... we need at least two parameters */
66 /* Create the admin */
67 new AdminId:admin = CreateAdmin(auth);
71 cur_idx = StrBreak(line[idx], flags, sizeof(flags));
76 new GroupId:gid = FindAdmGroup(flags[1]);
77 if (gid == INVALID_GROUP_ID)
79 ParseError("Invalid group detected: %s", flags[1]);
82 AdminInheritGroup(admin, gid);
84 new len = strlen(flags);
85 new bool:is_default = false;
86 for (new i=0; i<len; i++)
88 if (flags[i] < 'a' || flags[i] > 'z')
94 ParseError("Invalid flag detected: %c", flags[i]);
98 new val = flags[i] - 'a';
101 ParseError("Invalid flag detected: %c", flags[i]);
104 SetAdminFlag(admin, g_FlagLetters[val], true);
109 new GroupId:gid = FindAdmGroup("Default");
110 if (gid != INVALID_GROUP_ID)
112 AdminInheritGroup(admin, gid);
117 /* Lastly, is there a password? */
120 decl String:password[64];
121 StrBreak(line[idx], password, sizeof(password));
122 SetAdminPassword(admin, password);
125 /* Now, bind the identity to something */
126 if (StrContains(auth, "STEAM_") == 0)
128 BindAdminIdentity(admin, AUTHMETHOD_STEAM, auth);
132 BindAdminIdentity(admin, AUTHMETHOD_IP, auth[1]);
134 BindAdminIdentity(admin, AUTHMETHOD_NAME, auth);