Trying to make changes myself, but stuck with simple problem, which I don't understand:
Code:
/* AMX Mod X script.
* Admin Base Plugin
*
* by the AMX Mod X Development Team
* originally developed by OLO
*
* This file is part of AMX Mod X.
*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*/
#include <amxmodx>
#include <amxmisc>
#define MAX_ADMINS 64
new g_aPassword[MAX_ADMINS][32]
new g_aName[MAX_ADMINS][32]
new g_aNum = 0
public plugin_init()
{
register_plugin("test", "1.0", "Day")
register_cvar("test_password_field", "_test")
new configsDir[64]
get_configsdir(configsDir, 63)
format(configsDir, 63, "%s/test.ini", configsDir)
loadSettings(configsDir) // Load admins accounts
}
public plugin_cfg()
{
new configsDir2[64]
get_configsdir(configsDir2, 63)
new len = format(configsDir2, 63, "%s/test.ini", configsDir2)
set_task(1.0, "loadSettings", 0, configsDir2, len + 1, "b")
}
public loadSettings(szFilename[])
{
g_aNum = 0
if (!file_exists(szFilename))
return 0
new szText[256]
new a, pos = 0
while (g_aNum < MAX_ADMINS && read_file(szFilename, pos++, szText, 255, a))
{
if (szText[0] == ';')
continue
if (parse(szText, g_aName[g_aNum], 31, g_aPassword[g_aNum], 31) < 2)
continue
++g_aNum
}
return 1
}
accessUser(id, name[] = "")
{
new password[32], passfield[32], username[32]
if (name[0])
copy(username, 31, name)
else
get_user_name(id, username, 31)
get_cvar_string("test_password_field", passfield, 31)
get_user_info(id, passfield, password, 31)
new result = 0
g_aNum = 0
while (g_aNum < MAX_ADMINS)
{
if (g_aName[g_aNum] == username && g_aPassword[g_aNum] == password)
result = 1
++g_aNum
}
if (result == 0)
server_cmd("kick #%d ^"%s^"", get_user_userid(id), "You don't have an access!")
return PLUGIN_CONTINUE
}
public client_infochanged(id)
{
if (!is_user_connected(id))
return PLUGIN_CONTINUE
new newname[32], oldname[32]
get_user_name(id, oldname, 31)
get_user_info(id, "name", newname, 31)
if (!equal(newname, oldname))
accessUser(id, newname)
return PLUGIN_CONTINUE
}
public client_authorized(id)
{
accessUser(id)
return PLUGIN_CONTINUE
}
public client_putinserver(id)
{
if (!is_dedicated_server() && id == 1)
accessUser(id)
return PLUGIN_CONTINUE
}