mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-25 14:25:38 +03:00
update admin.sma
add stock ShowLoadAdminsMessage(const client, const count, bool:mysql = false) and remove client_infochanged(id) (here there was a conflict with a plugin which changes the names of the players, for example, a kill assist) and remove AdminCount and bool:g_CaseSensitiveName[MAX_PLAYERS + 1]
This commit is contained in:
parent
47f66a3d13
commit
0b307bd083
@ -22,17 +22,13 @@
|
|||||||
|
|
||||||
//new Vector:AdminList;
|
//new Vector:AdminList;
|
||||||
|
|
||||||
new AdminCount;
|
|
||||||
|
|
||||||
new PLUGINNAME[] = "AMX Mod X"
|
new PLUGINNAME[] = "AMX Mod X"
|
||||||
|
|
||||||
#define ADMIN_LOOKUP (1<<0)
|
#define ADMIN_LOOKUP (1<<0)
|
||||||
#define ADMIN_NORMAL (1<<1)
|
#define ADMIN_NORMAL (1<<1)
|
||||||
#define ADMIN_STEAM (1<<2)
|
#define ADMIN_STEAM (1<<2)
|
||||||
#define ADMIN_IPADDR (1<<3)
|
#define ADMIN_IPADDR (1<<3)
|
||||||
#define ADMIN_NAME (1<<4)
|
#define ADMIN_NAME (1<<4)
|
||||||
|
|
||||||
new bool:g_CaseSensitiveName[MAX_PLAYERS + 1];
|
|
||||||
|
|
||||||
// pcvars
|
// pcvars
|
||||||
new amx_mode;
|
new amx_mode;
|
||||||
@ -93,13 +89,10 @@ public plugin_init()
|
|||||||
server_cmd("amx_sqladmins")
|
server_cmd("amx_sqladmins")
|
||||||
#else
|
#else
|
||||||
format(configsDir, 63, "%s/users.ini", configsDir)
|
format(configsDir, 63, "%s/users.ini", configsDir)
|
||||||
loadSettings(configsDir) // Load admins accounts
|
loadSettings(0, configsDir) // Load admins accounts
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
public client_connect(id)
|
|
||||||
{
|
|
||||||
g_CaseSensitiveName[id] = false;
|
|
||||||
}
|
|
||||||
public addadminfn(id, level, cid)
|
public addadminfn(id, level, cid)
|
||||||
{
|
{
|
||||||
if (!cmd_access(id, level, cid, 3))
|
if (!cmd_access(id, level, cid, 3))
|
||||||
@ -230,7 +223,7 @@ public addadminfn(id, level, cid)
|
|||||||
}
|
}
|
||||||
else if (idtype & ADMIN_NAME)
|
else if (idtype & ADMIN_NAME)
|
||||||
{
|
{
|
||||||
get_user_name(player, auth, charsmax(auth))
|
copy(auth, charsmax(auth), Comment);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
copy(auth, charsmax(auth), arg)
|
copy(auth, charsmax(auth), arg)
|
||||||
@ -239,14 +232,11 @@ public addadminfn(id, level, cid)
|
|||||||
new type[16], len
|
new type[16], len
|
||||||
|
|
||||||
if (idtype & ADMIN_STEAM)
|
if (idtype & ADMIN_STEAM)
|
||||||
len += format(type[len], charsmax(type) - len, "c")
|
len += formatex(type[len], charsmax(type) - len, "c")
|
||||||
else if (idtype & ADMIN_IPADDR)
|
else if (idtype & ADMIN_IPADDR)
|
||||||
len += format(type[len], charsmax(type) - len, "d")
|
len += formatex(type[len], charsmax(type) - len, "d")
|
||||||
|
|
||||||
if (strlen(password) > 0)
|
formatex(type[len], charsmax(type) - len, strlen(password) ? "a" : "e")
|
||||||
len += format(type[len], charsmax(type) - len, "a")
|
|
||||||
else
|
|
||||||
len += format(type[len], charsmax(type) - len, "e")
|
|
||||||
|
|
||||||
AddAdmin(id, auth, flags, password, type, Comment)
|
AddAdmin(id, auth, flags, password, type, Comment)
|
||||||
cmdReload(id, ADMIN_CFG, 0)
|
cmdReload(id, ADMIN_CFG, 0)
|
||||||
@ -352,8 +342,9 @@ AddAdmin(id, auth[], accessflags[], password[], flags[], comment[]="")
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
loadSettings(szFilename[])
|
loadSettings(client, szFilename[])
|
||||||
{
|
{
|
||||||
|
new AdminCount = 0;
|
||||||
new File=fopen(szFilename,"r");
|
new File=fopen(szFilename,"r");
|
||||||
|
|
||||||
if (File)
|
if (File)
|
||||||
@ -395,21 +386,15 @@ loadSettings(szFilename[])
|
|||||||
fclose(File);
|
fclose(File);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AdminCount == 1)
|
ShowLoadAdminsMessage(client, AdminCount, false);
|
||||||
{
|
|
||||||
server_print("[AMXX] %L", LANG_SERVER, "LOADED_ADMIN");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
server_print("[AMXX] %L", LANG_SERVER, "LOADED_ADMINS", AdminCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined USING_SQL
|
#if defined USING_SQL
|
||||||
public adminSql()
|
public adminSql(client)
|
||||||
{
|
{
|
||||||
|
new AdminCount = 0;
|
||||||
new table[32], error[128], type[12], errno
|
new table[32], error[128], type[12], errno
|
||||||
|
|
||||||
new Handle:info = SQL_MakeStdTuple()
|
new Handle:info = SQL_MakeStdTuple()
|
||||||
@ -428,7 +413,7 @@ public adminSql()
|
|||||||
|
|
||||||
get_configsdir(configsDir, charsmax(configsDir))
|
get_configsdir(configsDir, charsmax(configsDir))
|
||||||
format(configsDir, charsmax(configsDir), "%s/users.ini", configsDir)
|
format(configsDir, charsmax(configsDir), "%s/users.ini", configsDir)
|
||||||
loadSettings(configsDir) // Load admins accounts
|
loadSettings(0, configsDir) // Load admins accounts
|
||||||
|
|
||||||
return PLUGIN_HANDLED
|
return PLUGIN_HANDLED
|
||||||
}
|
}
|
||||||
@ -452,12 +437,7 @@ public adminSql()
|
|||||||
{
|
{
|
||||||
SQL_QueryError(query, error, charsmax(error))
|
SQL_QueryError(query, error, charsmax(error))
|
||||||
server_print("[AMXX] %L", LANG_SERVER, "SQL_CANT_LOAD_ADMINS", error)
|
server_print("[AMXX] %L", LANG_SERVER, "SQL_CANT_LOAD_ADMINS", error)
|
||||||
} else if (!SQL_NumResults(query)) {
|
} else if (SQL_NumResults(query)) {
|
||||||
server_print("[AMXX] %L", LANG_SERVER, "NO_ADMINS")
|
|
||||||
} else {
|
|
||||||
|
|
||||||
AdminCount = 0
|
|
||||||
|
|
||||||
/** do this incase people change the query order and forget to modify below */
|
/** do this incase people change the query order and forget to modify below */
|
||||||
new qcolAuth = SQL_FieldNameToNum(query, "auth")
|
new qcolAuth = SQL_FieldNameToNum(query, "auth")
|
||||||
new qcolPass = SQL_FieldNameToNum(query, "password")
|
new qcolPass = SQL_FieldNameToNum(query, "password")
|
||||||
@ -482,20 +462,13 @@ public adminSql()
|
|||||||
SQL_NextRow(query)
|
SQL_NextRow(query)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AdminCount == 1)
|
SQL_FreeHandle(query);
|
||||||
{
|
SQL_FreeHandle(sql);
|
||||||
server_print("[AMXX] %L", LANG_SERVER, "SQL_LOADED_ADMIN")
|
SQL_FreeHandle(info);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
server_print("[AMXX] %L", LANG_SERVER, "SQL_LOADED_ADMINS", AdminCount)
|
|
||||||
}
|
|
||||||
|
|
||||||
SQL_FreeHandle(query)
|
|
||||||
SQL_FreeHandle(sql)
|
|
||||||
SQL_FreeHandle(info)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ShowLoadAdminsMessage(client, AdminCount, true);
|
||||||
|
|
||||||
return PLUGIN_HANDLED
|
return PLUGIN_HANDLED
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -511,36 +484,14 @@ public cmdReload(id, level, cid)
|
|||||||
admins_flush();
|
admins_flush();
|
||||||
|
|
||||||
#if !defined USING_SQL
|
#if !defined USING_SQL
|
||||||
new filename[128]
|
new filename[128];
|
||||||
|
|
||||||
get_configsdir(filename, charsmax(filename))
|
get_configsdir(filename, charsmax(filename));
|
||||||
format(filename, charsmax(filename), "%s/users.ini", filename)
|
format(filename, charsmax(filename), "%s/users.ini", filename);
|
||||||
|
|
||||||
AdminCount = 0;
|
loadSettings(id, filename); // Re-Load admins accounts
|
||||||
loadSettings(filename); // Re-Load admins accounts
|
|
||||||
|
|
||||||
if (id != 0)
|
|
||||||
{
|
|
||||||
if (AdminCount == 1)
|
|
||||||
{
|
|
||||||
console_print(id, "[AMXX] %L", LANG_SERVER, "LOADED_ADMIN");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
console_print(id, "[AMXX] %L", LANG_SERVER, "LOADED_ADMINS", AdminCount);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
AdminCount = 0
|
adminSql(id);
|
||||||
adminSql()
|
|
||||||
|
|
||||||
if (id != 0)
|
|
||||||
{
|
|
||||||
if (AdminCount == 1)
|
|
||||||
console_print(id, "[AMXX] %L", LANG_SERVER, "SQL_LOADED_ADMIN")
|
|
||||||
else
|
|
||||||
console_print(id, "[AMXX] %L", LANG_SERVER, "SQL_LOADED_ADMINS", AdminCount)
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
new players[MAX_PLAYERS], num, pv
|
new players[MAX_PLAYERS], num, pv
|
||||||
@ -566,8 +517,6 @@ getAccess(id, name[], authid[], ip[], password[])
|
|||||||
static Access;
|
static Access;
|
||||||
static AuthData[44];
|
static AuthData[44];
|
||||||
static Password[32];
|
static Password[32];
|
||||||
|
|
||||||
g_CaseSensitiveName[id] = false;
|
|
||||||
|
|
||||||
Count=admins_num();
|
Count=admins_num();
|
||||||
for (new i = 0; i < Count; ++i)
|
for (new i = 0; i < Count; ++i)
|
||||||
@ -610,14 +559,12 @@ getAccess(id, name[], authid[], ip[], password[])
|
|||||||
if (contain(name, AuthData) != -1)
|
if (contain(name, AuthData) != -1)
|
||||||
{
|
{
|
||||||
index = i
|
index = i
|
||||||
g_CaseSensitiveName[id] = true
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (equal(name, AuthData))
|
else if (equal(name, AuthData))
|
||||||
{
|
{
|
||||||
index = i
|
index = i
|
||||||
g_CaseSensitiveName[id] = true
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -755,42 +702,28 @@ accessUser(id, name[] = "")
|
|||||||
return PLUGIN_CONTINUE
|
return PLUGIN_CONTINUE
|
||||||
}
|
}
|
||||||
|
|
||||||
public client_infochanged(id)
|
|
||||||
{
|
|
||||||
if (!is_user_connected(id) || !get_pcvar_num(amx_mode))
|
|
||||||
{
|
|
||||||
return PLUGIN_CONTINUE
|
|
||||||
}
|
|
||||||
|
|
||||||
new newname[MAX_NAME_LENGTH], oldname[MAX_NAME_LENGTH]
|
|
||||||
|
|
||||||
get_user_name(id, oldname, charsmax(oldname))
|
|
||||||
get_user_info(id, "name", newname, charsmax(newname))
|
|
||||||
|
|
||||||
if (g_CaseSensitiveName[id])
|
|
||||||
{
|
|
||||||
if (!equal(newname, oldname))
|
|
||||||
{
|
|
||||||
accessUser(id, newname)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!equali(newname, oldname))
|
|
||||||
{
|
|
||||||
accessUser(id, newname)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return PLUGIN_CONTINUE
|
|
||||||
}
|
|
||||||
|
|
||||||
public client_authorized(id)
|
public client_authorized(id)
|
||||||
return get_pcvar_num(amx_mode) ? accessUser(id) : PLUGIN_CONTINUE
|
return get_pcvar_num(amx_mode) ? accessUser(id) : PLUGIN_CONTINUE
|
||||||
|
|
||||||
public client_putinserver(id)
|
public client_putinserver(id)
|
||||||
|
return (id == 1 && !is_dedicated_server() && get_pcvar_num(amx_mode)) ? accessUser(id) : PLUGIN_CONTINUE;
|
||||||
|
|
||||||
|
stock ShowLoadAdminsMessage(const client, const count, bool:mysql = false)
|
||||||
{
|
{
|
||||||
if (!is_dedicated_server() && id == 1)
|
if(count)
|
||||||
return get_pcvar_num(amx_mode) ? accessUser(id) : PLUGIN_CONTINUE
|
{
|
||||||
|
if (count == 1)
|
||||||
return PLUGIN_CONTINUE
|
{
|
||||||
|
console_print(client, "%L", client ? LANG_PLAYER : LANG_SERVER, mysql ? "SQL_LOADED_ADMIN" : "LOADED_ADMIN");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
console_print(client, "%L", client ? LANG_PLAYER : LANG_SERVER, mysql ? "SQL_LOADED_ADMINS" : "LOADED_ADMINS", count);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
console_print(client, "%L", client ? LANG_PLAYER : LANG_SERVER, "NO_ADMINS");
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user