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.
21 public ReadSimpleUsers()
23 BuildPath(Path_SM, g_Filename, sizeof(g_Filename), "configs/admins_simple.ini");
25 new Handle:file = OpenFile(g_Filename, "rt");
26 if (file == INVALID_HANDLE)
28 ParseError("Could not open file!");
32 while (!IsEndOfFile(file))
34 decl String:line[255];
35 if (!ReadFileLine(file, line, sizeof(line)))
40 if ((line[0] == '/' && line[1] == '/')
41 || (line[0] == ';' || line[0] == '\0'))
52 ReadAdminLine(const String:line[])
55 new cur_idx = StrBreak(line, auth, sizeof(auth));
60 /* This line is bad... we need at least two parameters */
64 /* Create the admin */
65 new AdminId:admin = CreateAdmin(auth);
69 cur_idx = StrBreak(line[idx], flags, sizeof(flags));
74 new GroupId:gid = FindAdmGroup(flags[1]);
75 if (gid == INVALID_GROUP_ID)
77 ParseError("Invalid group detected: %s", flags[1]);
80 AdminInheritGroup(admin, gid);
82 new len = strlen(flags);
83 new bool:is_default = false;
84 for (new i=0; i<len; i++)
86 if (flags[i] < 'a' || flags[i] > 'z')
92 ParseError("Invalid flag detected: %c", flags[i]);
96 new val = flags[i] - 'a';
99 ParseError("Invalid flag detected: %c", flags[i]);
102 SetAdminFlag(admin, g_FlagLetters[val], true);
107 new GroupId:gid = FindAdmGroup("Default");
108 if (gid != INVALID_GROUP_ID)
110 AdminInheritGroup(admin, gid);
115 /* Lastly, is there a password? */
118 decl String:password[64];
119 StrBreak(line[idx], password, sizeof(password));
120 SetAdminPassword(admin, password);
123 /* Now, bind the identity to something */
124 if (StrContains(auth, "STEAM_") == 0)
126 BindAdminIdentity(admin, AUTHMETHOD_STEAM, auth);
130 BindAdminIdentity(admin, AUTHMETHOD_IP, auth[1]);
132 BindAdminIdentity(admin, AUTHMETHOD_NAME, auth);