attempted merge at 1.77 back into trunk... Oh MY GOD

This commit is contained in:
David Anderson
2007-03-09 03:04:40 +00:00
parent 7adc49c541
commit 71065a65dd
90 changed files with 16915 additions and 1824 deletions

View File

@ -33,7 +33,7 @@
*/
// Uncomment for SQL version
//#define USING_SQL
// #define USING_SQL
#include <amxmodx>
#include <amxmisc>
@ -41,7 +41,8 @@
#include <sqlx>
#endif
#define MAX_ADMINS 64
new AdminCount;
new PLUGINNAME[] = "AMX Mod X"
#define ADMIN_LOOKUP (1<<0)
@ -50,13 +51,14 @@ new PLUGINNAME[] = "AMX Mod X"
#define ADMIN_IPADDR (1<<3)
#define ADMIN_NAME (1<<4)
new g_aPassword[MAX_ADMINS][32]
new g_aName[MAX_ADMINS][32]
new g_aFlags[MAX_ADMINS]
new g_aAccess[MAX_ADMINS]
new g_aNum = 0
new g_cmdLoopback[16]
// pcvars
new amx_mode;
new amx_password_field;
new amx_default_access;
public plugin_init()
{
#if defined USING_SQL
@ -66,9 +68,9 @@ public plugin_init()
#endif
register_dictionary("admin.txt")
register_dictionary("common.txt")
register_cvar("amx_mode", "1")
register_cvar("amx_password_field", "_pw")
register_cvar("amx_default_access", "")
amx_mode=register_cvar("amx_mode", "1")
amx_password_field=register_cvar("amx_password_field", "_pw")
amx_default_access=register_cvar("amx_default_access", "")
register_cvar("amx_vote_ratio", "0.02")
register_cvar("amx_vote_time", "10")
@ -157,13 +159,13 @@ public addadminfn(id, level, cid)
idtype |= ADMIN_LOOKUP
player = cmd_target(id, arg, 10)
} else {
new _steamid[24]
new _steamid[44]
static _players[32], _num, _pv
get_players(_players, _num)
for (new _i=0; _i<_num; _i++)
{
_pv = _players[_i]
get_user_authid(_pv, _steamid, 23)
get_user_authid(_pv, _steamid, sizeof(_steamid)-1)
if (!_steamid[0])
continue
if (equal(_steamid, arg))
@ -229,8 +231,10 @@ public addadminfn(id, level, cid)
read_argv(3, password, 63)
new auth[33]
new Comment[33]; // name of player to pass to comment field
if (idtype & ADMIN_LOOKUP)
{
get_user_name(player, Comment, sizeof(Comment)-1)
if (idtype & ADMIN_STEAM)
{
get_user_authid(player, auth, 32)
@ -259,7 +263,7 @@ public addadminfn(id, level, cid)
else
len += format(type[len], 15-len, "e")
AddAdmin(id, auth, flags, password, type)
AddAdmin(id, auth, flags, password, type, Comment)
cmdReload(id, ADMIN_CFG, 0)
if (player > 0)
@ -272,7 +276,7 @@ public addadminfn(id, level, cid)
return PLUGIN_HANDLED
}
AddAdmin(id, auth[], accessflags[], password[], flags[])
AddAdmin(id, auth[], accessflags[], password[], flags[], comment[]="")
{
#if defined USING_SQL
new error[128], errno
@ -322,7 +326,14 @@ AddAdmin(id, auth[], accessflags[], password[], flags[])
// If we came here, steamid doesn't exist in users.ini. Add it.
new linetoadd[512]
formatex(linetoadd, 511, "^r^n^"%s^" ^"%s^" ^"%s^" ^"%s^"", auth, password, accessflags, flags)
if (comment[0]==0)
{
formatex(linetoadd, 511, "^r^n^"%s^" ^"%s^" ^"%s^" ^"%s^"", auth, password, accessflags, flags)
}
else
{
formatex(linetoadd, 511, "^r^n^"%s^" ^"%s^" ^"%s^" ^"%s^" ; %s", auth, password, accessflags, flags, comment)
}
console_print(id, "Adding:^n%s", linetoadd)
if (!write_file(configsDir, linetoadd))
@ -357,49 +368,95 @@ AddAdmin(id, auth[], accessflags[], password[], flags[])
}
public plugin_cfg()
{
new configFile[64], curMap[32]
get_configsdir(configFile, 31)
get_mapname(curMap, 31)
new len = format(configFile, 63, "%s/maps/%s.cfg", configFile, curMap)
if (file_exists(configFile))
set_task(6.1, "delayed_load", 0, configFile, len + 1)
set_task(6.1, "delayed_load")
}
public delayed_load(configFile[])
public delayed_load()
{
server_cmd("exec %s", configFile)
new configFile[128], curMap[64], configDir[128]
get_configsdir(configDir, sizeof(configDir)-1)
get_mapname(curMap, sizeof(curMap)-1)
new i=0;
while (curMap[i] != '_' && curMap[i++] != '^0') {/*do nothing*/}
if (curMap[i]=='_')
{
// this map has a prefix
curMap[i]='^0';
formatex(configFile, sizeof(configFile)-1, "%s/maps/prefix_%s.cfg", configDir, curMap);
if (file_exists(configFile))
{
server_cmd("exec %s", configFile);
}
}
get_mapname(curMap, sizeof(curMap)-1)
formatex(configFile, sizeof(configFile)-1, "%s/maps/%s.cfg", configDir, curMap)
if (file_exists(configFile))
{
server_cmd("exec %s", configFile)
}
}
loadSettings(szFilename[])
{
if (!file_exists(szFilename))
return 0
new szText[256], szFlags[32], szAccess[32]
new a, pos = 0
while (g_aNum < MAX_ADMINS && read_file(szFilename, pos++, szText, 255, a))
new File=fopen(szFilename,"r");
if (File)
{
if (szText[0] == ';')
continue
new Text[512];
new Flags[32];
new Access[32]
new AuthData[44];
new Password[32];
while (!feof(File))
{
fgets(File,Text,sizeof(Text)-1);
// comment
if (Text[0]==';')
{
continue;
}
Flags[0]=0;
Access[0]=0;
AuthData[0]=0;
Password[0]=0;
// not enough parameters
if (parse(Text,AuthData,sizeof(AuthData)-1,Password,sizeof(Password)-1,Access,sizeof(Access)-1,Flags,sizeof(Flags)-1) < 2)
{
continue;
}
admins_push(AuthData,Password,read_flags(Access),read_flags(Flags));
if (parse(szText, g_aName[g_aNum], 31, g_aPassword[g_aNum], 31, szAccess, 31, szFlags, 31) < 2)
continue
AdminCount++;
}
fclose(File);
}
g_aAccess[g_aNum] = read_flags(szAccess)
g_aFlags[g_aNum] = read_flags(szFlags)
++g_aNum
if (AdminCount == 1)
{
server_print("[AMXX] %L", LANG_SERVER, "LOADED_ADMIN");
}
else
{
server_print("[AMXX] %L", LANG_SERVER, "LOADED_ADMINS", AdminCount);
}
if (g_aNum == 1)
server_print("[AMXX] %L", LANG_SERVER, "LOADED_ADMIN")
else
server_print("[AMXX] %L", LANG_SERVER, "LOADED_ADMINS", g_aNum)
return 1
return 1;
}
#if defined USING_SQL
@ -450,9 +507,8 @@ public adminSql()
} else if (!SQL_NumResults(query)) {
server_print("[AMXX] %L", LANG_SERVER, "NO_ADMINS")
} else {
new szFlags[32], szAccess[32]
g_aNum = 0
AdminCount = 0
/** do this incase people change the query order and forget to modify below */
new qcolAuth = SQL_FieldNameToNum(query, "auth")
@ -460,25 +516,32 @@ public adminSql()
new qcolAccess = SQL_FieldNameToNum(query, "access")
new qcolFlags = SQL_FieldNameToNum(query, "flags")
while ((g_aNum < MAX_ADMINS) && (SQL_MoreResults(query)))
new AuthData[44];
new Password[44];
new Access[32];
new Flags[32];
while (SQL_MoreResults(query))
{
SQL_ReadResult(query, qcolAuth, g_aName[g_aNum], 31)
SQL_ReadResult(query, qcolPass, g_aPassword[g_aNum], 31)
SQL_ReadResult(query, qcolAccess, szAccess, 31)
SQL_ReadResult(query, qcolFlags, szFlags, 31)
SQL_ReadResult(query, qcolAuth, AuthData, sizeof(AuthData)-1);
SQL_ReadResult(query, qcolPass, Password, sizeof(Password)-1);
SQL_ReadResult(query, qcolAccess, Access, sizeof(Access)-1);
SQL_ReadResult(query, qcolFlags, Flags, sizeof(Flags)-1);
g_aAccess[g_aNum] = read_flags(szAccess)
admins_push(AuthData,Password,read_flags(Access),read_flags(Flags));
g_aFlags[g_aNum] = read_flags(szFlags)
++g_aNum
++AdminCount;
SQL_NextRow(query)
}
if (g_aNum == 1)
if (AdminCount == 1)
{
server_print("[AMXX] %L", LANG_SERVER, "SQL_LOADED_ADMIN")
}
else
server_print("[AMXX] %L", LANG_SERVER, "SQL_LOADED_ADMINS", g_aNum)
{
server_print("[AMXX] %L", LANG_SERVER, "SQL_LOADED_ADMINS", AdminCount)
}
SQL_FreeHandle(query)
SQL_FreeHandle(sql)
@ -503,26 +566,30 @@ public cmdReload(id, level, cid)
get_configsdir(filename, 127)
format(filename, 63, "%s/users.ini", filename)
g_aNum = 0
loadSettings(filename) // Re-Load admins accounts
AdminCount = 0;
loadSettings(filename); // Re-Load admins accounts
if (id != 0)
{
if (g_aNum == 1)
console_print(id, "[AMXX] %L", LANG_SERVER, "LOADED_ADMIN")
if (AdminCount == 1)
{
console_print(id, "[AMXX] %L", LANG_SERVER, "LOADED_ADMIN");
}
else
console_print(id, "[AMXX] %L", LANG_SERVER, "LOADED_ADMINS", g_aNum)
{
console_print(id, "[AMXX] %L", LANG_SERVER, "LOADED_ADMINS", AdminCount);
}
}
#else
g_aNum = 0
AdminCount = 0
adminSql()
if (id != 0)
{
if (g_aNum == 1)
if (AdminCount == 1)
console_print(id, "[AMXX] %L", LANG_SERVER, "SQL_LOADED_ADMIN")
else
console_print(id, "[AMXX] %L", LANG_SERVER, "SQL_LOADED_ADMINS", g_aNum)
console_print(id, "[AMXX] %L", LANG_SERVER, "SQL_LOADED_ADMINS", AdminCount)
}
#endif
@ -544,43 +611,55 @@ getAccess(id, name[], authid[], ip[], password[])
new index = -1
new result = 0
for (new i = 0; i < g_aNum; ++i)
static Count;
static Flags;
static Access;
static AuthData[44];
static Password[32];
Count=admins_num();
for (new i = 0; i < Count; ++i)
{
if (g_aFlags[i] & FLAG_AUTHID)
Flags=admins_lookup(i,AdminProp_Flags);
admins_lookup(i,AdminProp_Auth,AuthData,sizeof(AuthData)-1);
if (Flags & FLAG_AUTHID)
{
if (equal(authid, g_aName[i]))
if (equal(authid, AuthData))
{
index = i
break
}
}
else if (g_aFlags[i] & FLAG_IP)
else if (Flags & FLAG_IP)
{
new c = strlen(g_aName[i])
new c = strlen(AuthData)
if (g_aName[i][c - 1] == '.') /* check if this is not a xxx.xxx. format */
if (AuthData[c - 1] == '.') /* check if this is not a xxx.xxx. format */
{
if (equal(g_aName[i], ip, c))
if (equal(AuthData, ip, c))
{
index = i
break
}
} /* in other case an IP must just match */
else if (equal(ip, g_aName[i]))
else if (equal(ip, AuthData))
{
index = i
break
}
} else {
if (g_aFlags[i] & FLAG_TAG)
}
else
{
if (Flags & FLAG_TAG)
{
if (containi(name, g_aName[i]) != -1)
if (containi(name, AuthData) != -1)
{
index = i
break
}
}
else if (equali(name, g_aName[i]))
else if (equali(name, AuthData))
{
index = i
break
@ -590,45 +669,59 @@ getAccess(id, name[], authid[], ip[], password[])
if (index != -1)
{
if (g_aFlags[index] & FLAG_NOPASS)
Access=admins_lookup(index,AdminProp_Access);
if (Flags & FLAG_NOPASS)
{
result |= 8
new sflags[32]
get_flags(g_aAccess[index], sflags, 31)
set_user_flags(id, g_aAccess[index])
get_flags(Access, sflags, 31)
set_user_flags(id, Access)
log_amx("Login: ^"%s<%d><%s><>^" became an admin (account ^"%s^") (access ^"%s^") (address ^"%s^")", name, get_user_userid(id), authid, g_aName[index], sflags, ip)
log_amx("Login: ^"%s<%d><%s><>^" became an admin (account ^"%s^") (access ^"%s^") (address ^"%s^")", name, get_user_userid(id), authid, AuthData, sflags, ip)
}
else if (equal(password, g_aPassword[index]))
else
{
result |= 12
set_user_flags(id, g_aAccess[index])
new sflags[32]
get_flags(g_aAccess[index], sflags, 31)
log_amx("Login: ^"%s<%d><%s><>^" became an admin (account ^"%s^") (access ^"%s^") (address ^"%s^")", name, get_user_userid(id), authid, g_aName[index], sflags, ip)
} else {
result |= 1
if (g_aFlags[index] & FLAG_KICK)
admins_lookup(index,AdminProp_Password,Password,sizeof(Password)-1);
if (equal(password, Password))
{
result |= 2
log_amx("Login: ^"%s<%d><%s><>^" kicked due to invalid password (account ^"%s^") (address ^"%s^")", name, get_user_userid(id), authid, g_aName[index], ip)
result |= 12
set_user_flags(id, Access)
new sflags[32]
get_flags(Access, sflags, 31)
log_amx("Login: ^"%s<%d><%s><>^" became an admin (account ^"%s^") (access ^"%s^") (address ^"%s^")", name, get_user_userid(id), authid, AuthData, sflags, ip)
}
else
{
result |= 1
if (Flags & FLAG_KICK)
{
result |= 2
log_amx("Login: ^"%s<%d><%s><>^" kicked due to invalid password (account ^"%s^") (address ^"%s^")", name, get_user_userid(id), authid, AuthData, ip)
}
}
}
}
else if (get_cvar_float("amx_mode") == 2.0)
else if (get_pcvar_float(amx_mode) == 2.0)
{
result |= 2
} else {
}
else
{
new defaccess[32]
get_cvar_string("amx_default_access", defaccess, 31)
get_pcvar_string(amx_default_access, defaccess, 31)
if (!strlen(defaccess))
{
copy(defaccess, 32, "z")
}
new idefaccess = read_flags(defaccess)
@ -660,7 +753,7 @@ accessUser(id, name[] = "")
get_user_name(id, username, 31)
}
get_cvar_string("amx_password_field", passfield, 31)
get_pcvar_string(amx_password_field, passfield, 31)
get_user_info(id, passfield, password, 31)
new result = getAccess(id, username, userauthid, userip, password)
@ -691,7 +784,7 @@ accessUser(id, name[] = "")
public client_infochanged(id)
{
if (!is_user_connected(id) || !get_cvar_num("amx_mode"))
if (!is_user_connected(id) || !get_pcvar_num(amx_mode))
{
return PLUGIN_CONTINUE
}
@ -712,15 +805,16 @@ public client_infochanged(id)
public ackSignal(id)
{
server_cmd("kick #%d ^"%L^"", get_user_userid(id), id, "NO_ENTRY")
return PLUGIN_HANDLED
}
public client_authorized(id)
return get_cvar_num("amx_mode") ? accessUser(id) : PLUGIN_CONTINUE
return get_pcvar_num(amx_mode) ? accessUser(id) : PLUGIN_CONTINUE
public client_putinserver(id)
{
if (!is_dedicated_server() && id == 1)
return get_cvar_num("amx_mode") ? accessUser(id) : PLUGIN_CONTINUE
return get_pcvar_num(amx_mode) ? accessUser(id) : PLUGIN_CONTINUE
return PLUGIN_CONTINUE
}

View File

@ -45,11 +45,16 @@ new bool:g_Paused
new bool:g_PauseAllowed = false
new g_addCvar[] = "amx_cvar add %s"
new amx_show_activity;
new pausable;
new rcon_password;
public plugin_init()
{
register_plugin("Admin Commands", AMXX_VERSION_STR, "AMXX Dev Team")
register_dictionary("admincmd.txt")
register_dictionary("common.txt")
register_dictionary("adminhelp.txt")
register_concmd("amx_kick", "cmdKick", ADMIN_KICK, "<name or #userid> [reason]")
register_concmd("amx_ban", "cmdBan", ADMIN_BAN, "<name or #userid> <minutes> [reason]")
register_concmd("amx_banip", "cmdBanIP", ADMIN_BAN, "<name or #userid> <minutes> [reason]")
@ -69,6 +74,18 @@ public plugin_init()
register_clcmd("amx_rcon", "cmdRcon", ADMIN_RCON, "<command line>")
register_clcmd("amx_showrcon", "cmdShowRcon", ADMIN_RCON, "<command line>")
register_clcmd("pauseAck", "cmdLBack")
rcon_password=get_cvar_pointer("rcon_password");
pausable=get_cvar_pointer("pausable");
amx_show_activity=get_cvar_pointer("amx_show_activity");
if (amx_show_activity==0) // cvar does not exist, register it
{
amx_show_activity=register_cvar("amx_show_activity", "2");
}
}
public plugin_cfg()
@ -108,7 +125,7 @@ public cmdKick(id, level, cid)
log_amx("Kick: ^"%s<%d><%s><>^" kick ^"%s<%d><%s><>^" (reason ^"%s^")", name, get_user_userid(id), authid, name2, userid2, authid2, reason)
switch (get_cvar_num("amx_show_activity"))
switch (get_pcvar_num(amx_show_activity))
{
case 2: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_KICK_2", name, name2)
case 1: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_KICK_1", name2)
@ -149,7 +166,7 @@ public cmdUnban(id, level, cid)
get_user_name(id, name, 31)
switch (get_cvar_num("amx_show_activity"))
switch (get_pcvar_num(amx_show_activity))
{
case 2: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_UNBAN_2", name, arg)
case 1: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_UNBAN_1", arg)
@ -183,7 +200,7 @@ public cmdAddBan(id, level, cid)
get_user_name(id, name, 31)
switch (get_cvar_num("amx_show_activity"))
switch (get_pcvar_num(amx_show_activity))
{
case 2: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_ADDBAN_2", name, arg)
case 1: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_ADDBAN_1", arg)
@ -234,7 +251,7 @@ public cmdBan(id, level, cid)
else
server_cmd("kick #%d ^"%s %s^";wait;banid ^"%s^" ^"%s^";wait;writeid", userid2, banned, temp, minutes, authid2)
new activity = get_cvar_num("amx_show_activity")
new activity = get_pcvar_num(amx_show_activity)
if (activity != 0)
{
new players[32], pnum, msg[256], len
@ -306,7 +323,7 @@ public cmdBanIP(id, level, cid)
else
server_cmd("kick #%d ^"%s %s^";wait;addip ^"%s^" ^"%s^";wait;writeip", userid2, banned, temp, minutes, address)
new activity = get_cvar_num("amx_show_activity")
new activity = get_pcvar_num(amx_show_activity)
if (activity != 0)
{
new players[32], pnum, msg[256], len
@ -362,7 +379,7 @@ public cmdSlay(id, level, cid)
log_amx("Cmd: ^"%s<%d><%s><>^" slay ^"%s<%d><%s><>^"", name, get_user_userid(id), authid, name2, get_user_userid(player), authid2)
switch (get_cvar_num("amx_show_activity"))
switch (get_pcvar_num(amx_show_activity))
{
case 2: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_SLAY_2", name, name2)
case 1: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_SLAY_1", name2)
@ -400,7 +417,7 @@ public cmdSlap(id, level, cid)
log_amx("Cmd: ^"%s<%d><%s><>^" slap with %d damage ^"%s<%d><%s><>^"", name, get_user_userid(id), authid, damage, name2, get_user_userid(player), authid2)
switch (get_cvar_num("amx_show_activity"))
switch (get_pcvar_num(amx_show_activity))
{
case 2: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_SLAP_2", name, name2, damage)
case 1: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_SLAP_1", name2, damage)
@ -434,7 +451,7 @@ public cmdMap(id, level, cid)
get_user_authid(id, authid, 31)
get_user_name(id, name, 31)
switch (get_cvar_num("amx_show_activity"))
switch (get_pcvar_num(amx_show_activity))
{
case 2: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_MAP_2", name, arg)
case 1: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_MAP_1", arg)
@ -474,6 +491,8 @@ public cmdCvar(id, level, cid)
read_argv(1, arg, 31)
read_argv(2, arg2, 63)
new pointer;
if (equal(arg, "add") && (get_user_flags(id) & ADMIN_RCON))
{
if (cvar_exists(arg2))
@ -486,7 +505,7 @@ public cmdCvar(id, level, cid)
return PLUGIN_HANDLED
}
if (!cvar_exists(arg))
if ((pointer=get_cvar_pointer(arg))==0)
{
console_print(id, "[AMXX] %L", id, "UNKNOWN_CVAR", arg)
return PLUGIN_HANDLED
@ -497,7 +516,7 @@ public cmdCvar(id, level, cid)
console_print(id, "[AMXX] %L", id, "CVAR_NO_ACC")
return PLUGIN_HANDLED
}
else if (equal(arg, "sv_password") && !(get_user_flags(id) & ADMIN_PASSWORD))
else if (equali(arg, "sv_password") && !(get_user_flags(id) & ADMIN_PASSWORD))
{
console_print(id, "[AMXX] %L", id, "CVAR_NO_ACC")
return PLUGIN_HANDLED
@ -505,7 +524,7 @@ public cmdCvar(id, level, cid)
if (read_argc() < 3)
{
get_cvar_string(arg, arg2, 63)
get_pcvar_string(pointer, arg2, 63)
console_print(id, "[AMXX] %L", id, "CVAR_IS", arg, arg2)
return PLUGIN_HANDLED
}
@ -517,8 +536,9 @@ public cmdCvar(id, level, cid)
log_amx("Cmd: ^"%s<%d><%s><>^" set cvar (name ^"%s^") (value ^"%s^")", name, get_user_userid(id), authid, arg, arg2)
set_cvar_string(arg, arg2)
new activity = get_cvar_num("amx_show_activity")
new activity = get_pcvar_num(amx_show_activity)
if (activity != 0)
{
new players[32], pnum, admin[64], cvar_val[64], len
@ -533,12 +553,12 @@ public cmdCvar(id, level, cid)
else
len += format(admin[len], 255-len, " %s:", name)
if (equal(arg, "rcon_password") || equal(arg, "sv_password"))
if (get_pcvar_flags(pointer) & FCVAR_PROTECTED || equali(arg,"rcon_password"))
format(cvar_val, 63, "*** %L ***", players[i], "PROTECTED")
else
copy(cvar_val, 63, arg2)
client_print(players[i], print_chat, "%L", players[i], "SET_CVAR_TO", admin, arg, arg2)
client_print(players[i], print_chat, "%L", players[i], "SET_CVAR_TO", admin, arg, cvar_val)
}
}
console_print(id, "[AMXX] %L", id, "CVAR_CHANGED", arg, arg2)
@ -550,6 +570,12 @@ public cmdPlugins(id, level, cid)
{
if (!cmd_access(id, level, cid, 1))
return PLUGIN_HANDLED
if (id==0) // If server executes redirect this to "amxx plugins" for more in depth output
{
server_cmd("amxx plugins");
return PLUGIN_HANDLED;
}
new name[32], version[32], author[32], filename[32], status[32]
new lName[32], lVersion[32], lAuthor[32], lFile[32], lStatus[32]
@ -560,21 +586,50 @@ public cmdPlugins(id, level, cid)
format(lFile, 31, "%L", id, "FILE")
format(lStatus, 31, "%L", id, "STATUS")
new StartPLID=0;
new EndPLID;
new Temp[96]
new num = get_pluginsnum()
if (read_argc() > 1)
{
read_argv(1,Temp,sizeof(Temp)-1);
StartPLID=str_to_num(Temp)-1; // zero-based
}
EndPLID=min(StartPLID + 10, num);
new running = 0
console_print(id, "%L:", id, "LOADED_PLUGINS")
console_print(id, "----- %L -----", id, "LOADED_PLUGINS")
console_print(id, "%-18.17s %-8.7s %-17.16s %-16.15s %-9.8s", lName, lVersion, lAuthor, lFile, lStatus)
for (new i = 0; i <num; i++)
new i=StartPLID;
while (i <EndPLID)
{
get_plugin(i, filename, 31, name, 31, version, 31, author, 31, status, 31)
get_plugin(i++, filename, 31, name, 31, version, 31, author, 31, status, 31)
console_print(id, "%-18.17s %-8.7s %-17.16s %-16.15s %-9.8s", name, version, author, filename, status)
if (status[0]=='d' || status[0]=='r') // "debug" or "running"
running++
}
console_print(id, "%L", id, "PLUGINS_RUN", num, running)
console_print(id, "%L", id, "PLUGINS_RUN", EndPLID-StartPLID, running)
console_print(id, "----- %L -----",id,"HELP_ENTRIES",StartPLID + 1,EndPLID,num);
if (EndPLID < num)
{
formatex(Temp,sizeof(Temp)-1,"----- %L -----",id,"HELP_USE_MORE", EndPLID + 1);
replace_all(Temp,sizeof(Temp)-1,"amx_help","amx_plugins");
console_print(id,"%s",Temp);
}
else
{
formatex(Temp,sizeof(Temp)-1,"----- %L -----",id,"HELP_USE_BEGIN");
replace_all(Temp,sizeof(Temp)-1,"amx_help","amx_plugins");
console_print(id,"%s",Temp);
}
return PLUGIN_HANDLED
}
@ -637,7 +692,7 @@ public cmdCfg(id, level, cid)
console_print(id, "[AMXX] Executing file ^"%s^"", arg)
server_cmd("exec %s", arg)
switch(get_cvar_num("amx_show_activity"))
switch(get_pcvar_num(amx_show_activity))
{
case 2: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_CONF_2", name, arg)
case 1: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_CONF_1", arg)
@ -675,7 +730,10 @@ public cmdPause(id, level, cid)
get_user_authid(id, authid, 31)
get_user_name(id, name, 31)
g_pausAble = get_cvar_float("pausable")
if (pausable!=0)
{
g_pausAble = get_pcvar_float(pausable)
}
if (!slayer)
slayer = find_player("h")
@ -694,7 +752,7 @@ public cmdPause(id, level, cid)
console_print(id, "[AMXX] %L", id, g_Paused ? "UNPAUSING" : "PAUSING")
new activity = get_cvar_num("amx_show_activity")
new activity = get_pcvar_num(amx_show_activity)
if (activity != 0)
{
new players[32], pnum, msg[128], len
@ -725,7 +783,7 @@ public cmdShowRcon(id, level, cid)
new password[64]
get_cvar_string("rcon_password", password, 63)
get_pcvar_string(rcon_password, password, 63)
if (!password[0])
{
@ -862,7 +920,7 @@ public cmdLeave(id, level, cid)
get_user_name(id, name, 31)
log_amx("Kick: ^"%s<%d><%s><>^" leave some group (tag1 ^"%s^") (tag2 ^"%s^") (tag3 ^"%s^") (tag4 ^"%s^")", name, get_user_userid(id), authid, ltags[0], ltags[1], ltags[2], ltags[3])
switch(get_cvar_num("amx_show_activity"))
switch(get_pcvar_num(amx_show_activity))
{
case 2: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_LEAVE_2", name, ltags[0], ltags[1], ltags[2], ltags[3])
case 1: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_LEAVE_1", ltags[0], ltags[1], ltags[2], ltags[3])
@ -895,7 +953,7 @@ public cmdNick(id, level, cid)
log_amx("Cmd: ^"%s<%d><%s><>^" change nick to ^"%s^" ^"%s<%d><%s><>^"", name, get_user_userid(id), authid, arg2, name2, get_user_userid(player), authid2)
switch (get_cvar_num("amx_show_activity"))
switch (get_pcvar_num(amx_show_activity))
{
case 2: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_NICK_2", name, name2, arg2)
case 1: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_NICK_1", name2, arg2)

View File

@ -72,6 +72,8 @@ public ackSignal(id)
new lReason[64]
format(lReason, 63, "%L", id, "DROPPED_RES")
server_cmd("kick #%d ^"%s^"", get_user_userid(id), lReason)
return PLUGIN_HANDLED
}
public client_authorized(id)

View File

@ -37,18 +37,20 @@
new Float:g_Flooding[33] = {0.0, ...}
new g_Flood[33] = {0, ...}
new amx_flood_time;
public plugin_init()
{
register_plugin("Anti Flood", AMXX_VERSION_STR, "AMXX Dev Team")
register_dictionary("antiflood.txt")
register_clcmd("say", "chkFlood")
register_clcmd("say_team", "chkFlood")
register_cvar("amx_flood_time", "0.75")
amx_flood_time=register_cvar("amx_flood_time", "0.75")
}
public chkFlood(id)
{
new Float:maxChat = get_cvar_float("amx_flood_time")
new Float:maxChat = get_pcvar_float(amx_flood_time)
if (maxChat)
{

View File

@ -60,6 +60,7 @@ public plugin_init()
register_dictionary("plmenu.txt")
register_dictionary("common.txt")
register_dictionary("admincmd.txt")
register_clcmd("amx_kickmenu", "cmdKickMenu", ADMIN_KICK, "- displays kick menu")
register_clcmd("amx_banmenu", "cmdBanMenu", ADMIN_BAN, "- displays ban menu")
@ -120,8 +121,32 @@ public actionBanMenu(id, key)
switch (get_cvar_num("amx_show_activity"))
{
case 2: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_BAN_2", name, name2)
case 1: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_BAN_1", name2)
case 2:
{
if (g_menuSettings[id]==0) // permanent
{
client_print(0, print_chat, "%L %s: %L %s %L", LANG_PLAYER, "ADMIN", name, LANG_PLAYER, "BAN", name2, LANG_PLAYER, "PERM");
}
else
{
new tempTime[32];
formatex(tempTime,sizeof(tempTime)-1,"%d",g_menuSettings[id]);
client_print(0, print_chat, "%L %s: %L %s %L", LANG_PLAYER, "ADMIN", name, LANG_PLAYER, "BAN", name2, LANG_PLAYER, "FOR_MIN", tempTime);
}
}
case 1:
{
if (g_menuSettings[id]==0) // permanent
{
client_print(0, print_chat, "%L: %L %s %L", LANG_PLAYER, "ADMIN", LANG_PLAYER, "BAN", name2, LANG_PLAYER, "PERM");
}
else
{
new tempTime[32];
formatex(tempTime,sizeof(tempTime)-1,"%d",g_menuSettings[id]);
client_print(0, print_chat, "%L: %L %s %L", LANG_PLAYER, "ADMIN", LANG_PLAYER, "BAN", name2, LANG_PLAYER, "FOR_MIN", tempTime);
}
}
}
if (equal("4294967295", authid2))

View File

@ -312,3 +312,11 @@ enum LibType
LibType_Library,
LibType_Class
};
enum AdminProp
{
AdminProp_Auth = 0,
AdminProp_Password,
AdminProp_Access,
AdminProp_Flags
};

View File

@ -310,3 +310,19 @@ stock constraint_offset(low, high, seed, offset)
return 0; // Makes the compiler happy -_-
}
/* Returns true if the user has ANY of the provided flags
* false if they have none
*/
stock has_flag(id, const flags[])
{
return (get_user_flags(id) & read_flags(flags));
}
/* Returns true if the user has ALL of the provided flags
* false otherwise
*/
stock has_all_flags(id, const flags[])
{
new FlagsNumber=read_flags(flags);
return ((get_user_flags(id) & FlagsNumber)==FlagsNumber);
}

View File

@ -239,7 +239,7 @@ native user_has_weapon(index,weapon,setweapon=-1);
/* Returns id of currently carried weapon. Gets also
* ammount of ammo in clip and backpack. */
native get_user_weapon(index,&clip,&ammo);
native get_user_weapon(index,&clip=0,&ammo=0);
/* Gets ammo and clip from current weapon. */
native get_user_ammo(index,weapon,&clip,&ammo);
@ -474,14 +474,18 @@ native get_user_flags(index,id=0);
native remove_user_flags(index,flags=-1,id=0);
/* Registers function which will be called from client console.
* Set FlagManager to 1 to make FlagManager always include this command
* Set FlagManager to 0 to make FlagManager never include this command
* Returns the command ID.
*/
native register_clcmd(const client_cmd[],const function[],flags=-1, const info[]="");
native register_clcmd(const client_cmd[],const function[],flags=-1, const info[]="", FlagManager=-1);
/* Registers function which will be called from any console.
* Set FlagManager to 1 to make FlagManager always include this command
* Set FlagManager to 0 to make FlagManager never include this command
* Returns the command ID.
*/
native register_concmd(const cmd[],const function[],flags=-1, const info[]="");
native register_concmd(const cmd[],const function[],flags=-1, const info[]="", FlagManager=-1);
/* Registers function which will be called from server console.
* Returns the command ID.
@ -609,7 +613,7 @@ native is_plugin_loaded(const name[]);
* Note: the [...] portion should not be used, and is only for backward compatibility.
* Use index of -1 to use the calling plugin's ID.
*/
native get_plugin(index,filename[],len1,name[],len2,version[],len3,author[],len4,status[],len5,...);
native get_plugin(index,filename[]="",len1=0,name[]="",len2=0,version[]="",len3=0,author[]="",len4=0,status[]="",len5=0,...);
/* Returns number of all loaded plugins. */
native get_pluginsnum();
@ -826,7 +830,8 @@ native menu_destroy(menu);
//Gets info about a player's menu. Returns 1 if the player is viewing a menu.
//menu will be >0 for a valid oldmenu. newmenu will be != -1 for a valid newmenu.
native player_menu_info(id, &menu, &newmenu);
//As of 1.77, there is an optional page parameter.
native player_menu_info(id, &menu, &newmenu, &menupage=0);
//adds a blank line to a menu.
//if slot is nonzero (default), the blank line will increase
@ -1080,6 +1085,7 @@ native set_pcvar_num(pcvar, num);
native Float:get_pcvar_float(pcvar);
native set_pcvar_float(pcvar, Float:num);
native get_pcvar_string(pcvar, string[], maxlen);
native set_pcvar_string(pcvar, const string[]);
/**
* Sets a whole array to a certain value.
@ -1092,5 +1098,29 @@ native arrayset(array[], value, size);
*/
native get_weaponid(const name[]);
/**
* Adds an admin to the dynamic admin storage
* for lookup at a later time
*/
native admins_push(const AuthData[], const Password[], Access, Flags);
/**
* Gets the number of admins in the dynamic admin
* storage list
*/
native admins_num();
/**
* Gets information about a dynamically stored admin
* Use the enum AdminProp
* Returns an integer value: AdminProp_Access, AdminProp_Flags
* Sets the buffer string: AdminProp_Auth, AdminProp_Password
*/
native admins_lookup(num, AdminProp:Property, Buffer[]="", BufferSize=0);
/**
* Clears the list of dynamically stored admins
*/
native admins_flush();
// Keep this always at the bottom of this file
#include <message_stocks>

View File

@ -24,6 +24,27 @@
#define DODMAX_WEAPONS 46 // 5 slots for custom weapons
// DoD Weapon Types
enum
{
DODWT_PRIMARY = 0,
DODWT_SECONDARY,
DODWT_MELEE,
DODWT_GRENADE,
DODWT_OTHER
};
// Ammo Channels
#define AMMO_SMG 1 // thompson, greasegun, sten, mp40
#define AMMO_ALTRIFLE 2 // carbine, k43, mg34
#define AMMO_RIFLE 3 // garand, enfield, scoped enfield, k98, scoped k98
#define AMMO_PISTOL 4 // colt, webley, luger
#define AMMO_SPRING 5 // springfield
#define AMMO_HEAVY 6 // bar, bren, stg44, fg42, scoped fg42
#define AMMO_MG42 7 // mg42
#define AMMO_30CAL 8 // 30cal
#define AMMO_GREN 9 // grenades (should be all 3 types)
#define AMMO_ROCKET 13 // bazooka, piat, panzerschreck
enum {
PS_NOPRONE =0,
PS_PRONE,

View File

@ -23,6 +23,9 @@
/* Function is called after grenade throw */
forward grenade_throw(index,greindex,wId);
/* Function is called after a rocket is shot */
forward rocket_shoot(index,rocketindex,wId);
/* Example: for full stamina use dod_player_stamina(1,STAMINA_SET,100,100) */
/* value is from 0 - 100 */
native dod_set_stamina(index,set=STAMINA_SET,minvalue=0,maxvalue=100);

View File

@ -53,6 +53,44 @@ forward dod_client_changeclass(id, class, oldclass);
/* This Forward is called when a player spawns */
forward dod_client_spawn(id);
/* This will be called whenever a player scopes or unscopes
value = 1 scope up
value = 0 scope down */
forward dod_client_scope(id, value);
/* This will be called whenever a player drops a weapon
weapon is weapon dropped or picked up
value = 1 picked up
value = 0 dropped */
forward dod_client_weaponpickup(id, weapon, value);
/* Called whenever the the player goes to or comes from prone position
value = 1 going down
value = 0 getting up */
forward dod_client_prone(id, value);
/* This will be called whenever a player switches a weapon */
forward dod_client_weaponswitch(id, wpnew, wpnold);
/* Forward for when a grenade explodes and its location */
forward dod_grenade_explosion(id, pos[3], wpnid);
/* Forward for when a rocket explodes and its location */
forward dod_rocket_explosion(id, pos[3], wpnid);
/* Forward for when a player picks up a object */
forward dod_client_objectpickup(id, objid, pos[3], value);
/* Forward for when a users stamina decreases */
forward dod_client_stamina(id, stamina);
/* We want to get just the weapon of whichever type that the player is on him
Use DODWT_* in dodconst.inc for type */
native dod_weapon_type(id, type);
/* This native will change the position of a weapon within the users slots and its ammo ammount */
native dod_set_weaponlist(id, wpnID, slot, dropslot, totalrds);
/* Sets the model for a player */
native dod_set_model(id, const model[]);
@ -102,7 +140,7 @@ native dod_get_map_info( info );
/* Returns id of currently carried weapon. Gets also
* ammount of ammo in clip and backpack. */
native dod_get_user_weapon(index,&clip,&ammo);
native dod_get_user_weapon(index,&clip=0,&ammo=0);
/* Returns team score */
native dod_get_team_score(teamId);

View File

@ -176,4 +176,38 @@ stock bool:operator!(Float:oper)
/* forbidden operations */
forward operator%(Float:oper1, Float:oper2);
forward operator%(Float:oper1, oper2);
forward operator%(oper1, Float:oper2);
forward operator%(oper1, Float:oper2);
stock Float:floatmin(Float:ValueA, Float:ValueB)
{
if (ValueA<=ValueB)
{
return ValueA;
}
return ValueB;
}
stock Float:floatmax(Float:ValueA, Float:ValueB)
{
if (ValueA>=ValueB)
{
return ValueA;
}
return ValueB;
}
stock Float:floatclamp(Float:Value, Float:MinValue, Float:MaxValue)
{
if (Value<=MinValue)
{
return MinValue;
}
if (Value>=MaxValue)
{
return MaxValue;
}
return Value;
}

View File

@ -466,3 +466,16 @@
#define HLW_SNARK 15
#define HLW_SUIT 31
#define HLW_ALLWEAPONS (~(1<<HLW_SUIT))
#define FEV_NOTHOST (1<<0) // Skip local host for event send.
#define FEV_RELIABLE (1<<1) // Send the event reliably. You must specify the origin and angles
// for this to work correctly on the server for anything
// that depends on the event origin/angles. I.e., the origin/angles are not
// taken from the invoking edict for reliable events.
#define FEV_GLOBAL (1<<2) // Don't restrict to PAS/PVS, send this event to _everybody_ on the server ( useful for stopping CHAN_STATIC
// sounds started by client event when client is not in PVS anymore ( hwguy in TFC e.g. ).
#define FEV_UPDATE (1<<3) // If this client already has one of these events in its queue, just update the event instead of sending it as a duplicate
#define FEV_HOSTONLY (1<<4) // Only send to entity specified as the invoker
#define FEV_SERVER (1<<5) // Only send if the event was created on the server.
#define FEV_CLIENT (1<<6) // Only issue event client side ( from shared code )

View File

@ -23,15 +23,64 @@
#define MSG_ONE_UNRELIABLE 8 // Send to one client, but don't put in reliable stream, put in unreliable datagram (could be dropped)
#define MSG_SPEC 9 // Sends to all spectator proxies
/* Message types for message_begin() */
#define SVC_TEMPENTITY 23
#define SVC_INTERMISSION 30
#define SVC_CDTRACK 32
#define SVC_WEAPONANIM 35
#define SVC_ROOMTYPE 37
#define SVC_ADDANGLE 38 // [vec3] add this angle to the view angle
#define SVC_NEWUSERMSG 39
#define SVC_HLTV 50
/* Hardcoded message types for message_begin()
* Look in the actual HLSDK for details!
*/
#define SVC_NOP 1
#define SVC_DISCONNECT 2
#define SVC_EVENT 3
#define SVC_VERSION 4
#define SVC_SETVIEW 5
#define SVC_SOUND 6
#define SVC_TIME 7
#define SVC_PRINT 8
#define SVC_STUFFTEXT 9
#define SVC_SETANGLE 10
#define SVC_SERVERINFO 11
#define SVC_LIGHTSTYLE 12
#define SVC_UPDATEUSERINFO 13
#define SVC_DELTADESCRIPTION 14
#define SVC_CLIENTDATA 15
#define SVC_STOPSOUND 16
#define SVC_PINGS 17
#define SVC_PARTICLE 18
#define SVC_DAMAGE 19
#define SVC_SPAWNSTATIC 20
#define SVC_EVENT_RELIABLE 21
#define SVC_SPAWNBASELINE 22
#define SVC_TEMPENTITY 23
#define SVC_SETPAUSE 24
#define SVC_SIGNONNUM 25
#define SVC_CENTERPRINT 26
#define SVC_KILLEDMONSTER 27
#define SVC_FOUNDSECRET 28
#define SVC_SPAWNSTATICSOUND 29
#define SVC_INTERMISSION 30
#define SVC_FINALE 31
#define SVC_CDTRACK 32
#define SVC_RESTORE 33
#define SVC_CUTSCENE 34
#define SVC_WEAPONANIM 35
#define SVC_DECALNAME 36
#define SVC_ROOMTYPE 37
#define SVC_ADDANGLE 38
#define SVC_NEWUSERMSG 39
#define SVC_PACKETENTITIES 40
#define SVC_DELTAPACKETENTITIES 41
#define SVC_CHOKE 42
#define SVC_RESOURCELIST 43
#define SVC_NEWMOVEVARS 44
#define SVC_RESOURCEREQUEST 45
#define SVC_CUSTOMIZATION 46
#define SVC_CROSSHAIRANGLE 47
#define SVC_SOUNDFADE 48
#define SVC_FILETXFERFAILED 49
#define SVC_HLTV 50
#define SVC_DIRECTOR 51
#define SVC_VOICEINIT 52
#define SVC_VOICEDATA 53
#define SVC_SENDEXTRAINFO 54
#define SVC_TIMESCALE 55
/* Message flags for set_msg_block() */
#define BLOCK_NOT 0
@ -323,8 +372,6 @@ enum
// write_coord(position.z)
// write_short(model index)
// write_byte(scale / 10)
// write_byte(size)
// write_byte(brightness)
#define TE_BEAMRING 24 // Connect a beam ring to two entities
// write_byte(TE_BEAMRING)
@ -364,6 +411,7 @@ enum
// write_byte(red)
// write_byte(green)
// write_byte(blue)
// write_byte(brightness)
// write_byte(life in 10's)
// write_byte(decay rate in 10's)
@ -649,7 +697,7 @@ enum
#define TE_PLAYERSPRITES 121 // Sprites emit from a player's bounding box (ONLY use for players!)
// write_byte(TE_PLAYERSPRITES)
// write_short(playernum)
// write_byte(playernum)
// write_short(sprite modelindex)
// write_byte(count)
// write_byte(variance) (0 = no variance in size) (10 = 10% variance in size)
@ -719,3 +767,35 @@ enum
// write_byte(life * 10)
// write_byte(color) this is an index into an array of color vectors in the engine. (0 - )
// write_byte(length * 10)
// From hltv.h from the HLSDK, these are used in conjunction with SVC_DIRECTOR
// sub commands of svc_director:
#define DRC_CMD_NONE 0 // NULL director command
#define DRC_CMD_START 1 // start director mode
#define DRC_CMD_EVENT 2 // informs about director command
#define DRC_CMD_MODE 3 // switches camera modes
#define DRC_CMD_CAMERA 4 // sets camera registers
#define DRC_CMD_TIMESCALE 5 // sets time scale
#define DRC_CMD_MESSAGE 6 // send HUD centerprint
#define DRC_CMD_SOUND 7 // plays a particular sound
#define DRC_CMD_STATUS 8 // status info about broadcast
#define DRC_CMD_BANNER 9 // banner file name for HLTV gui
#define DRC_CMD_FADE 10 // send screen fade command
#define DRC_CMD_SHAKE 11 // send screen shake command
#define DRC_CMD_STUFFTEXT 12 // like the normal svc_stufftext but as director command
#define DRC_CMD_LAST 12
// HLTV_EVENT event flags
#define DRC_FLAG_PRIO_MASK 0x0F // priorities between 0 and 15 (15 most important)
#define DRC_FLAG_SIDE (1<<4) //
#define DRC_FLAG_DRAMATIC (1<<5) // is a dramatic scene
#define DRC_FLAG_SLOWMOTION (1<<6) // would look good in SloMo
#define DRC_FLAG_FACEPLAYER (1<<7) // player is doning something (reload/defuse bomb etc)
#define DRC_FLAG_INTRO (1<<8) // is a introduction scene
#define DRC_FLAG_FINAL (1<<9) // is a final scene
#define DRC_FLAG_NO_RANDOM (1<<10) // don't randomize event data
#define MAX_DIRECTOR_CMD_PARAMETERS 4
#define MAX_DIRECTOR_CMD_STRING 128

View File

@ -133,3 +133,13 @@ native tfc_setweaponammo(index, value);
* Use the TFC_GOALITEM_* constants to determine the owning team.
*/
native tfc_get_user_goalitem(index, &team);
/* Returns 1 if the player is a spy and is currently feigning death */
native tfc_is_user_feigning(index);
/* Returns 1 if the two teams are allies, 0 otherwise
* Note: Team must be 1->4
* Team 0 will always return 0
* Any other team will result in an error
*/
native tfc_is_team_ally(TeamA,TeamB);

View File

@ -67,7 +67,7 @@ native ts_getuserslots( index );
native ts_setuserslots( index, slots );
native ts_getuserstate( index );
native ts_getuserwpn( index,&clip,&ammo,&mode,&extra );
native ts_getuserwpn( index,&clip=0,&ammo=0,&mode=0,&extra=0 );
native ts_getuserspace( index );
native ts_getuserkillflags(killer);

View File

@ -154,10 +154,33 @@ public actionBanMenu(id, key)
switch (get_cvar_num("amx_show_activity"))
{
case 2: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_BAN_2", name, name2)
case 1: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_BAN_1", name2)
case 2:
{
if (g_menuSettings[id]==0) // permanent
{
client_print(0, print_chat, "%L %s: %L %s %L", LANG_PLAYER, "ADMIN", name, LANG_PLAYER, "BAN", name2, LANG_PLAYER, "PERM");
}
else
{
new tempTime[32];
formatex(tempTime,sizeof(tempTime)-1,"%d",g_menuSettings[id]);
client_print(0, print_chat, "%L %s: %L %s %L", LANG_PLAYER, "ADMIN", name, LANG_PLAYER, "BAN", name2, LANG_PLAYER, "FOR_MIN", tempTime);
}
}
case 1:
{
if (g_menuSettings[id]==0) // permanent
{
client_print(0, print_chat, "%L: %L %s %L", LANG_PLAYER, "ADMIN", LANG_PLAYER, "BAN", name2, LANG_PLAYER, "PERM");
}
else
{
new tempTime[32];
formatex(tempTime,sizeof(tempTime)-1,"%d",g_menuSettings[id]);
client_print(0, print_chat, "%L: %L %s %L", LANG_PLAYER, "ADMIN", LANG_PLAYER, "BAN", name2, LANG_PLAYER, "FOR_MIN", tempTime);
}
}
}
/* ---------- check for Steam ID added by MistaGee --------------------
IF AUTHID == 4294967295 OR VALVE_ID_LAN OR HLTV, BAN PER IP TO NOT BAN EVERYONE */
@ -173,7 +196,9 @@ public actionBanMenu(id, key)
server_cmd("addip %d %s;writeip", g_menuSettings[id], ipa)
}
else
{
server_cmd("banid %d #%d kick;writeid", g_menuSettings[id], userid2)
}
server_exec()

View File

@ -0,0 +1,123 @@
#include <amxmodx>
new __testnumber;
new errcount;
enum TestType
{
TT_Equal = 0,
TT_LessThan,
TT_GreaterThan,
TT_LessThanEqual,
TT_GreaterThanEqual,
TT_NotEqual
};
new TestWords[6][] = {
"==",
"<",
">",
"<=",
">=",
"!="
};
stock test(A,B=0,TestType:Type=TT_Equal)
{
++__testnumber;
new passed=0;
switch (Type)
{
case TT_Equal: if (A==B) passed=1;
case TT_LessThan: if (A<B) passed=1;
case TT_GreaterThan: if (A>B) passed=1;
case TT_LessThanEqual: if (A<=B) passed=1;
case TT_GreaterThanEqual: if (A>=B) passed=1;
case TT_NotEqual: if (A!=B) passed=1;
}
if (!passed)
{
log_amx("Failed test #%d (%d %s %d)",__testnumber,A,TestWords[_:Type],B);
errcount++;
}
}
public plugin_init()
{
register_srvcmd("testadmins","testadmins");
}
public testadmins()
{
new AuthData[44];
new Password[32];
new Access;
new Flags;
new id;
__testnumber=0;
errcount=0;
test(admins_num(),0);
admins_push("STEAM_0:1:23456","",read_flags("abcdefghijklmnopqrstu"),read_flags("ce"));
test(admins_num(),1);
admins_push("ABCDEFGHIJKLMNOP","abcdefghijklmnop",read_flags("z"),read_flags("a"));
test(admins_num(),2);
admins_push("ZYXWVUTSRQPONMLKJIHGFEDCBA","plop",read_flags("a"),read_flags("b"));
test(admins_num(),3);
id=0;
admins_lookup(id,AdminProp_Auth,AuthData,sizeof(AuthData)-1);
admins_lookup(id,AdminProp_Password,Password,sizeof(Password)-1);
Access=admins_lookup(id,AdminProp_Access);
Flags=admins_lookup(id,AdminProp_Flags);
test(strcmp(AuthData,"STEAM_0:1:23456"),0);
test(strcmp(Password,""),0);
test(Access,read_flags("abcdefghijklmnopqrstu"));
test(Flags,read_flags("ce"));
id++;
admins_lookup(id,AdminProp_Auth,AuthData,sizeof(AuthData)-1);
admins_lookup(id,AdminProp_Password,Password,sizeof(Password)-1);
Access=admins_lookup(id,AdminProp_Access);
Flags=admins_lookup(id,AdminProp_Flags);
test(strcmp(AuthData,"ABCDEFGHIJKLMNOP"),0);
test(strcmp(Password,"abcdefghijklmnop"),0);
test(Access,read_flags("z"));
test(Flags,read_flags("a"));
id++;
admins_lookup(id,AdminProp_Auth,AuthData,sizeof(AuthData)-1);
admins_lookup(id,AdminProp_Password,Password,sizeof(Password)-1);
Access=admins_lookup(id,AdminProp_Access);
Flags=admins_lookup(id,AdminProp_Flags);
test(strcmp(AuthData,"ZYXWVUTSRQPONMLKJIHGFEDCBA"),0);
test(strcmp(Password,"plop"),0);
test(Access,read_flags("a"));
test(Flags,read_flags("b"));
admins_flush();
test(admins_num(),0);
server_print("test complete, %d errors",errcount);
}

View File

@ -62,6 +62,7 @@ public plugin_init()
register_dictionary("plmenu.txt")
register_dictionary("common.txt")
register_dictionary("admincmd.txt")
register_clcmd("amx_kickmenu","cmdKickMenu",ADMIN_KICK,"- displays kick menu")
register_clcmd("amx_banmenu","cmdBanMenu",ADMIN_BAN,"- displays ban menu")
@ -122,8 +123,32 @@ public actionBanMenu(id, key)
switch (get_cvar_num("amx_show_activity"))
{
case 2: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_BAN_2", name, name2)
case 1: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_BAN_1", name2)
case 2:
{
if (g_menuSettings[id]==0) // permanent
{
client_print(0, print_chat, "%L %s: %L %s %L", LANG_PLAYER, "ADMIN", name, LANG_PLAYER, "BAN", name2, LANG_PLAYER, "PERM");
}
else
{
new tempTime[32];
formatex(tempTime,sizeof(tempTime)-1,"%d",g_menuSettings[id]);
client_print(0, print_chat, "%L %s: %L %s %L", LANG_PLAYER, "ADMIN", name, LANG_PLAYER, "BAN", name2, LANG_PLAYER, "FOR_MIN", tempTime);
}
}
case 1:
{
if (g_menuSettings[id]==0) // permanent
{
client_print(0, print_chat, "%L: %L %s %L", LANG_PLAYER, "ADMIN", LANG_PLAYER, "BAN", name2, LANG_PLAYER, "PERM");
}
else
{
new tempTime[32];
formatex(tempTime,sizeof(tempTime)-1,"%d",g_menuSettings[id]);
client_print(0, print_chat, "%L: %L %s %L", LANG_PLAYER, "ADMIN", LANG_PLAYER, "BAN", name2, LANG_PLAYER, "FOR_MIN", tempTime);
}
}
}
if (equal("4294967295", authid2))