Remove slowhack in amx_nick command and apply general optimizations in admincmd plugin (bug 5832, r=me)

Former-commit-id: 9d85ff7b1f4c5ee9c7b13a3bc362095c002add94
This commit is contained in:
connorr 2013-08-05 18:18:58 +02:00
parent fd47b6e0c6
commit 2385dd3972

View File

@ -214,7 +214,7 @@ public cmdKick(id, level, cid)
return PLUGIN_HANDLED return PLUGIN_HANDLED
new arg[32] new arg[32]
read_argv(1, arg, 31) read_argv(1, arg, charsmax(arg))
new player = cmd_target(id, arg, CMDTARGET_OBEY_IMMUNITY | CMDTARGET_ALLOW_SELF) new player = cmd_target(id, arg, CMDTARGET_OBEY_IMMUNITY | CMDTARGET_ALLOW_SELF)
if (!player) if (!player)
@ -222,12 +222,12 @@ public cmdKick(id, level, cid)
new authid[32], authid2[32], name2[32], name[32], userid2, reason[32] new authid[32], authid2[32], name2[32], name[32], userid2, reason[32]
get_user_authid(id, authid, 31) get_user_authid(id, authid, charsmax(authid))
get_user_authid(player, authid2, 31) get_user_authid(player, authid2, charsmax(authid2))
get_user_name(player, name2, 31) get_user_name(player, name2, charsmax(name2))
get_user_name(id, name, 31) get_user_name(id, name, charsmax(name))
userid2 = get_user_userid(player) userid2 = get_user_userid(player)
read_argv(2, reason, 31) read_argv(2, reason, charsmax(reason))
remove_quotes(reason) remove_quotes(reason)
log_amx("Kick: ^"%s<%d><%s><>^" kick ^"%s<%d><%s><>^" (reason ^"%s^")", name, get_user_userid(id), authid, name2, userid2, authid2, reason) log_amx("Kick: ^"%s<%d><%s><>^" kick ^"%s<%d><%s><>^" (reason ^"%s^")", name, get_user_userid(id), authid, name2, userid2, authid2, reason)
@ -256,7 +256,7 @@ public cmdUnban(id, level, cid)
new arg[32], authid[32], name[32] new arg[32], authid[32], name[32]
read_argv(1, arg, 31) read_argv(1, arg, charsmax(arg))
if (contain(arg, ".") != -1) if (contain(arg, ".") != -1)
{ {
@ -267,11 +267,11 @@ public cmdUnban(id, level, cid)
console_print(id, "[AMXX] %L", id, "AUTHID_REMOVED", arg) console_print(id, "[AMXX] %L", id, "AUTHID_REMOVED", arg)
} }
get_user_name(id, name, 31) get_user_name(id, name, charsmax(name))
show_activity_key("ADMIN_UNBAN_1", "ADMIN_UNBAN_2", name, arg); show_activity_key("ADMIN_UNBAN_1", "ADMIN_UNBAN_2", name, arg);
get_user_authid(id, authid, 31) get_user_authid(id, authid, charsmax(authid))
log_amx("Cmd: ^"%s<%d><%s><>^" unban ^"%s^"", name, get_user_userid(id), authid, arg) log_amx("Cmd: ^"%s<%d><%s><>^" unban ^"%s^"", name, get_user_userid(id), authid, arg)
return PLUGIN_HANDLED return PLUGIN_HANDLED
@ -302,9 +302,9 @@ public cmdAddBan(id, level, cid)
new arg[32], authid[32], name[32], minutes[32], reason[32] new arg[32], authid[32], name[32], minutes[32], reason[32]
read_argv(1, arg, 31) read_argv(1, arg, charsmax(arg))
read_argv(2, minutes, 31) read_argv(2, minutes, charsmax(minutes))
read_argv(3, reason, 31) read_argv(3, reason, charsmax(reason))
if (!(get_user_flags(id) & ADMIN_RCON)) if (!(get_user_flags(id) & ADMIN_RCON))
@ -396,11 +396,11 @@ public cmdAddBan(id, level, cid)
console_print(id, "[AMXX] Authid ^"%s^" added to ban list", arg) console_print(id, "[AMXX] Authid ^"%s^" added to ban list", arg)
} }
get_user_name(id, name, 31) get_user_name(id, name, charsmax(name))
show_activity_key("ADMIN_ADDBAN_1", "ADMIN_ADDBAN_2", name, arg); show_activity_key("ADMIN_ADDBAN_1", "ADMIN_ADDBAN_2", name, arg);
get_user_authid(id, authid, 31) get_user_authid(id, authid, charsmax(authid))
log_amx("Cmd: ^"%s<%d><%s><>^" ban ^"%s^" (minutes ^"%s^") (reason ^"%s^")", name, get_user_userid(id), authid, arg, minutes, reason) log_amx("Cmd: ^"%s<%d><%s><>^" ban ^"%s^" (minutes ^"%s^") (reason ^"%s^")", name, get_user_userid(id), authid, arg, minutes, reason)
return PLUGIN_HANDLED return PLUGIN_HANDLED
@ -413,9 +413,9 @@ public cmdBan(id, level, cid)
new target[32], minutes[8], reason[64] new target[32], minutes[8], reason[64]
read_argv(1, target, 31) read_argv(1, target, charsmax(target))
read_argv(2, minutes, 7) read_argv(2, minutes, charsmax(minutes))
read_argv(3, reason, 63) read_argv(3, reason, charsmax(reason))
new player = cmd_target(id, target, CMDTARGET_OBEY_IMMUNITY | CMDTARGET_NO_BOTS | CMDTARGET_ALLOW_SELF) new player = cmd_target(id, target, CMDTARGET_OBEY_IMMUNITY | CMDTARGET_NO_BOTS | CMDTARGET_ALLOW_SELF)
@ -425,20 +425,20 @@ public cmdBan(id, level, cid)
new authid[32], name2[32], authid2[32], name[32] new authid[32], name2[32], authid2[32], name[32]
new userid2 = get_user_userid(player) new userid2 = get_user_userid(player)
get_user_authid(player, authid2, 31) get_user_authid(player, authid2, charsmax(authid2))
get_user_authid(id, authid, 31) get_user_authid(id, authid, charsmax(authid))
get_user_name(player, name2, 31) get_user_name(player, name2, charsmax(name2))
get_user_name(id, name, 31) get_user_name(id, name, charsmax(name))
log_amx("Ban: ^"%s<%d><%s><>^" ban and kick ^"%s<%d><%s><>^" (minutes ^"%s^") (reason ^"%s^")", name, get_user_userid(id), authid, name2, userid2, authid2, minutes, reason) log_amx("Ban: ^"%s<%d><%s><>^" ban and kick ^"%s<%d><%s><>^" (minutes ^"%s^") (reason ^"%s^")", name, get_user_userid(id), authid, name2, userid2, authid2, minutes, reason)
new temp[64], banned[16], nNum = str_to_num(minutes) new temp[64], banned[16], nNum = str_to_num(minutes)
if (nNum) if (nNum)
format(temp, 63, "%L", player, "FOR_MIN", minutes) formatex(temp, charsmax(temp), "%L", player, "FOR_MIN", minutes)
else else
format(temp, 63, "%L", player, "PERM") formatex(temp, charsmax(temp), "%L", player, "PERM")
format(banned, 15, "%L", player, "BANNED") formatex(banned, charsmax(banned), "%L", player, "BANNED")
if (reason[0]) if (reason[0])
server_cmd("kick #%d ^"%s (%s %s)^";wait;banid %s %s;wait;writeid", userid2, reason, banned, temp, minutes, authid2) server_cmd("kick #%d ^"%s (%s %s)^";wait;banid %s %s;wait;writeid", userid2, reason, banned, temp, minutes, authid2)
@ -450,27 +450,27 @@ public cmdBan(id, level, cid)
new msg[256]; new msg[256];
new len; new len;
new maxpl = get_maxplayers(); new players[32], pnum, plr
for (new i = 1; i <= maxpl; i++) get_players(players, pnum, "ch")
for (new i; i<pnum; i++)
{ {
if (is_user_connected(i) && !is_user_bot(i)) plr = players[i]
len = formatex(msg, charsmax(msg), "%L", plr, "BAN");
len += formatex(msg[len], charsmax(msg) - len, " %s ", name2);
if (nNum)
{ {
len = formatex(msg, charsmax(msg), "%L", i, "BAN"); len += formatex(msg[len], charsmax(msg) - len, "%L", plr, "FOR_MIN", minutes);
len += formatex(msg[len], charsmax(msg) - len, " %s ", name2);
if (nNum)
{
len += formatex(msg[len], charsmax(msg) - len, "%L", i, "FOR_MIN", minutes);
}
else
{
len += formatex(msg[len], charsmax(msg) - len, "%L", i, "PERM");
}
if (strlen(reason) > 0)
{
formatex(msg[len], charsmax(msg) - len, " (%L: %s)", i, "REASON", reason);
}
show_activity_id(i, id, name, msg);
} }
else
{
len += formatex(msg[len], charsmax(msg) - len, "%L", plr, "PERM");
}
if (strlen(reason) > 0)
{
formatex(msg[len], charsmax(msg) - len, " (%L: %s)", plr, "REASON", reason);
}
show_activity_id(plr, id, name, msg);
} }
console_print(id, "[AMXX] %L", id, "CLIENT_BANNED", name2) console_print(id, "[AMXX] %L", id, "CLIENT_BANNED", name2)
@ -485,9 +485,9 @@ public cmdBanIP(id, level, cid)
new target[32], minutes[8], reason[64] new target[32], minutes[8], reason[64]
read_argv(1, target, 31) read_argv(1, target, charsmax(target))
read_argv(2, minutes, 7) read_argv(2, minutes, charsmax(minutes))
read_argv(3, reason, 63) read_argv(3, reason, charsmax(reason))
new player = cmd_target(id, target, CMDTARGET_OBEY_IMMUNITY | CMDTARGET_NO_BOTS | CMDTARGET_ALLOW_SELF) new player = cmd_target(id, target, CMDTARGET_OBEY_IMMUNITY | CMDTARGET_NO_BOTS | CMDTARGET_ALLOW_SELF)
@ -502,22 +502,22 @@ public cmdBanIP(id, level, cid)
new authid[32], name2[32], authid2[32], name[32] new authid[32], name2[32], authid2[32], name[32]
new userid2 = get_user_userid(player) new userid2 = get_user_userid(player)
get_user_authid(player, authid2, 31) get_user_authid(player, authid2, charsmax(authid2))
get_user_authid(id, authid, 31) get_user_authid(id, authid, charsmax(authid))
get_user_name(player, name2, 31) get_user_name(player, name2, charsmax(name2))
get_user_name(id, name, 31) get_user_name(id, name, charsmax(name))
log_amx("Ban: ^"%s<%d><%s><>^" ban and kick ^"%s<%d><%s><>^" (minutes ^"%s^") (reason ^"%s^")", name, get_user_userid(id), authid, name2, userid2, authid2, minutes, reason) log_amx("Ban: ^"%s<%d><%s><>^" ban and kick ^"%s<%d><%s><>^" (minutes ^"%s^") (reason ^"%s^")", name, get_user_userid(id), authid, name2, userid2, authid2, minutes, reason)
new temp[64], banned[16], nNum = str_to_num(minutes) new temp[64], banned[16], nNum = str_to_num(minutes)
if (nNum) if (nNum)
format(temp, 63, "%L", player, "FOR_MIN", minutes) formatex(temp, charsmax(temp), "%L", player, "FOR_MIN", minutes)
else else
format(temp, 63, "%L", player, "PERM") formatex(temp, charsmax(temp), "%L", player, "PERM")
format(banned, 15, "%L", player, "BANNED") format(banned, 15, "%L", player, "BANNED")
new address[32] new address[32]
get_user_ip(player, address, 31, 1) get_user_ip(player, address, charsmax(address), 1)
if (reason[0]) if (reason[0])
server_cmd("kick #%d ^"%s (%s %s)^";wait;addip ^"%s^" ^"%s^";wait;writeip", userid2, reason, banned, temp, minutes, address) server_cmd("kick #%d ^"%s (%s %s)^";wait;addip ^"%s^" ^"%s^";wait;writeip", userid2, reason, banned, temp, minutes, address)
@ -528,27 +528,27 @@ public cmdBanIP(id, level, cid)
new msg[256]; new msg[256];
new len; new len;
new maxpl = get_maxplayers(); new players[32], pnum, plr
for (new i = 1; i <= maxpl; i++) get_players(players, pnum, "ch")
for (new i; i<pnum; i++)
{ {
if (is_user_connected(i) && !is_user_bot(i)) plr = players[i]
len = formatex(msg, charsmax(msg), "%L", plr, "BAN");
len += formatex(msg[len], charsmax(msg) - len, " %s ", name2);
if (nNum)
{ {
len = formatex(msg, charsmax(msg), "%L", i, "BAN"); formatex(msg[len], charsmax(msg) - len, "%L", plr, "FOR_MIN", minutes);
len += formatex(msg[len], charsmax(msg) - len, " %s ", name2);
if (nNum)
{
formatex(msg[len], charsmax(msg) - len, "%L", i, "FOR_MIN", minutes);
}
else
{
formatex(msg[len], charsmax(msg) - len, "%L", i, "PERM");
}
if (strlen(reason) > 0)
{
formatex(msg[len], charsmax(msg) - len, " (%L: %s)", i, "REASON", reason);
}
show_activity_id(i, id, name, msg);
} }
else
{
formatex(msg[len], charsmax(msg) - len, "%L", plr, "PERM");
}
if (strlen(reason) > 0)
{
formatex(msg[len], charsmax(msg) - len, " (%L: %s)", plr, "REASON", reason);
}
show_activity_id(plr, id, name, msg);
} }
console_print(id, "[AMXX] %L", id, "CLIENT_BANNED", name2) console_print(id, "[AMXX] %L", id, "CLIENT_BANNED", name2)
@ -563,7 +563,7 @@ public cmdSlay(id, level, cid)
new arg[32] new arg[32]
read_argv(1, arg, 31) read_argv(1, arg, charsmax(arg))
new player = cmd_target(id, arg, CMDTARGET_OBEY_IMMUNITY | CMDTARGET_ALLOW_SELF | CMDTARGET_ONLY_ALIVE) new player = cmd_target(id, arg, CMDTARGET_OBEY_IMMUNITY | CMDTARGET_ALLOW_SELF | CMDTARGET_ONLY_ALIVE)
@ -574,10 +574,10 @@ public cmdSlay(id, level, cid)
new authid[32], name2[32], authid2[32], name[32] new authid[32], name2[32], authid2[32], name[32]
get_user_authid(id, authid, 31) get_user_authid(id, authid, charsmax(authid))
get_user_name(id, name, 31) get_user_name(id, name, charsmax(name))
get_user_authid(player, authid2, 31) get_user_authid(player, authid2, charsmax(authid2))
get_user_name(player, name2, 31) get_user_name(player, name2, charsmax(name2))
log_amx("Cmd: ^"%s<%d><%s><>^" slay ^"%s<%d><%s><>^"", name, get_user_userid(id), authid, name2, get_user_userid(player), authid2) log_amx("Cmd: ^"%s<%d><%s><>^" slay ^"%s<%d><%s><>^"", name, get_user_userid(id), authid, name2, get_user_userid(player), authid2)
@ -595,7 +595,7 @@ public cmdSlap(id, level, cid)
new arg[32] new arg[32]
read_argv(1, arg, 31) read_argv(1, arg, charsmax(arg))
new player = cmd_target(id, arg, CMDTARGET_OBEY_IMMUNITY | CMDTARGET_ALLOW_SELF | CMDTARGET_ONLY_ALIVE) new player = cmd_target(id, arg, CMDTARGET_OBEY_IMMUNITY | CMDTARGET_ALLOW_SELF | CMDTARGET_ONLY_ALIVE)
if (!player) if (!player)
@ -603,16 +603,16 @@ public cmdSlap(id, level, cid)
new spower[32], authid[32], name2[32], authid2[32], name[32] new spower[32], authid[32], name2[32], authid2[32], name[32]
read_argv(2, spower, 31) read_argv(2, spower, charsmax(spower))
new damage = clamp( str_to_num(spower), 0) new damage = clamp( str_to_num(spower), 0)
user_slap(player, damage) user_slap(player, damage)
get_user_authid(id, authid, 31) get_user_authid(id, authid, charsmax(authid))
get_user_name(id, name, 31) get_user_name(id, name, charsmax(name))
get_user_authid(player, authid2, 31) get_user_authid(player, authid2, charsmax(authid2))
get_user_name(player, name2, 31) get_user_name(player, name2, charsmax(name2))
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) 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)
@ -634,7 +634,7 @@ public cmdMap(id, level, cid)
return PLUGIN_HANDLED return PLUGIN_HANDLED
new arg[32] new arg[32]
new arglen = read_argv(1, arg, 31) new arglen = read_argv(1, arg, charsmax(arg))
if (!is_map_valid(arg)) if (!is_map_valid(arg))
{ {
@ -644,15 +644,15 @@ public cmdMap(id, level, cid)
new authid[32], name[32] new authid[32], name[32]
get_user_authid(id, authid, 31) get_user_authid(id, authid, charsmax(authid))
get_user_name(id, name, 31) get_user_name(id, name, charsmax(name))
show_activity_key("ADMIN_MAP_1", "ADMIN_MAP_2", name, arg); show_activity_key("ADMIN_MAP_1", "ADMIN_MAP_2", name, arg);
log_amx("Cmd: ^"%s<%d><%s><>^" changelevel ^"%s^"", name, get_user_userid(id), authid, arg) log_amx("Cmd: ^"%s<%d><%s><>^" changelevel ^"%s^"", name, get_user_userid(id), authid, arg)
new _modName[10] new _modName[10]
get_modname(_modName, 9) get_modname(_modName, charsmax(_modName))
if (!equal(_modName, "zp")) if (!equal(_modName, "zp"))
{ {
@ -711,8 +711,8 @@ public cmdCvar(id, level, cid)
new arg[32], arg2[64] new arg[32], arg2[64]
read_argv(1, arg, 31) read_argv(1, arg, charsmax(arg))
read_argv(2, arg2, 63) read_argv(2, arg2, charsmax(arg2))
new pointer; new pointer;
@ -749,38 +749,37 @@ public cmdCvar(id, level, cid)
if (read_argc() < 3) if (read_argc() < 3)
{ {
get_pcvar_string(pointer, arg2, 63) get_pcvar_string(pointer, arg2, charsmax(arg2))
console_print(id, "[AMXX] %L", id, "CVAR_IS", arg, arg2) console_print(id, "[AMXX] %L", id, "CVAR_IS", arg, arg2)
return PLUGIN_HANDLED return PLUGIN_HANDLED
} }
new authid[32], name[32] new authid[32], name[32]
get_user_authid(id, authid, 31) get_user_authid(id, authid, charsmax(authid))
get_user_name(id, name, 31) get_user_name(id, name, charsmax(name))
log_amx("Cmd: ^"%s<%d><%s><>^" set cvar (name ^"%s^") (value ^"%s^")", name, get_user_userid(id), authid, arg, arg2) 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) set_pcvar_string(pointer, arg2)
// Display the message to all clients // Display the message to all clients
new cvar_val[64]; new cvar_val[64];
new maxpl = get_maxplayers(); new players[32], pnum, plr
for (new i = 1; i <= maxpl; i++) get_players(players, pnum, "ch")
for (new i; i<pnum; i++)
{ {
if (is_user_connected(i) && !is_user_bot(i)) plr = players[i]
if (get_pcvar_flags(pointer) & FCVAR_PROTECTED || equali(arg, "rcon_password"))
{ {
if (get_pcvar_flags(pointer) & FCVAR_PROTECTED || equali(arg, "rcon_password")) formatex(cvar_val, charsmax(cvar_val), "*** %L ***", plr, "PROTECTED");
{
formatex(cvar_val, charsmax(cvar_val), "*** %L ***", i, "PROTECTED");
}
else
{
copy(cvar_val, charsmax(cvar_val), arg2);
}
show_activity_id(i, id, name, "%L", i, "SET_CVAR_TO", "", arg, cvar_val);
} }
else
{
copy(cvar_val, charsmax(cvar_val), arg2);
}
show_activity_id(plr, id, name, "%L", plr, "SET_CVAR_TO", "", arg, cvar_val);
} }
console_print(id, "[AMXX] %L", id, "CVAR_CHANGED", arg, arg2) console_print(id, "[AMXX] %L", id, "CVAR_CHANGED", arg, arg2)
@ -803,11 +802,11 @@ public cmdPlugins(id, level, cid)
new name[32], version[32], author[32], filename[32], status[32] new name[32], version[32], author[32], filename[32], status[32]
new lName[32], lVersion[32], lAuthor[32], lFile[32], lStatus[32] new lName[32], lVersion[32], lAuthor[32], lFile[32], lStatus[32]
format(lName, 31, "%L", id, "NAME") format(lName, charsmax(lName), "%L", id, "NAME")
format(lVersion, 31, "%L", id, "VERSION") format(lVersion, charsmax(lVersion), "%L", id, "VERSION")
format(lAuthor, 31, "%L", id, "AUTHOR") format(lAuthor, charsmax(lAuthor), "%L", id, "AUTHOR")
format(lFile, 31, "%L", id, "FILE") format(lFile, charsmax(lFile), "%L", id, "FILE")
format(lStatus, 31, "%L", id, "STATUS") format(lStatus, charsmax(lStatus), "%L", id, "STATUS")
new StartPLID=0; new StartPLID=0;
new EndPLID; new EndPLID;
@ -818,7 +817,7 @@ public cmdPlugins(id, level, cid)
if (read_argc() > 1) if (read_argc() > 1)
{ {
read_argv(1,Temp,sizeof(Temp)-1); read_argv(1,Temp,charsmax(Temp));
StartPLID=str_to_num(Temp)-1; // zero-based StartPLID=str_to_num(Temp)-1; // zero-based
} }
@ -832,7 +831,7 @@ public cmdPlugins(id, level, cid)
new i=StartPLID; new i=StartPLID;
while (i <EndPLID) while (i <EndPLID)
{ {
get_plugin(i++, filename, 31, name, 31, version, 31, author, 31, status, 31) get_plugin(i++, filename, charsmax(filename), name, charsmax(name), version, charsmax(version), author, charsmax(author), status, charsmax(status))
console_print(id, "%-18.17s %-11.10s %-17.16s %-16.15s %-9.8s", name, version, author, filename, status) console_print(id, "%-18.17s %-11.10s %-17.16s %-16.15s %-9.8s", name, version, author, filename, status)
if (status[0]=='d' || status[0]=='r') // "debug" or "running" if (status[0]=='d' || status[0]=='r') // "debug" or "running"
@ -843,14 +842,14 @@ public cmdPlugins(id, level, cid)
if (EndPLID < num) if (EndPLID < num)
{ {
formatex(Temp,sizeof(Temp)-1,"----- %L -----",id,"HELP_USE_MORE", EndPLID + 1); formatex(Temp,charsmax(Temp),"----- %L -----",id,"HELP_USE_MORE", EndPLID + 1);
replace_all(Temp,sizeof(Temp)-1,"amx_help","amx_plugins"); replace_all(Temp,charsmax(Temp),"amx_help","amx_plugins");
console_print(id,"%s",Temp); console_print(id,"%s",Temp);
} }
else else
{ {
formatex(Temp,sizeof(Temp)-1,"----- %L -----",id,"HELP_USE_BEGIN"); formatex(Temp,charsmax(Temp),"----- %L -----",id,"HELP_USE_BEGIN");
replace_all(Temp,sizeof(Temp)-1,"amx_help","amx_plugins"); replace_all(Temp,charsmax(Temp),"amx_help","amx_plugins");
console_print(id,"%s",Temp); console_print(id,"%s",Temp);
} }
@ -865,9 +864,9 @@ public cmdModules(id, level, cid)
new name[32], version[32], author[32], status, sStatus[16] new name[32], version[32], author[32], status, sStatus[16]
new lName[32], lVersion[32], lAuthor[32], lStatus[32]; new lName[32], lVersion[32], lAuthor[32], lStatus[32];
format(lName, 31, "%L", id, "NAME") format(lName, charsmax(lName), "%L", id, "NAME")
format(lVersion, 31, "%L", id, "VERSION") format(lVersion, charsmax(lVersion), "%L", id, "VERSION")
format(lAuthor, 31, "%L", id, "AUTHOR") format(lAuthor, charsmax(lAuthor), "%L", id, "AUTHOR")
format(lStatus, charsmax(lStatus), "%L", id, "STATUS") format(lStatus, charsmax(lStatus), "%L", id, "STATUS")
new num = get_modulesnum() new num = get_modulesnum()
@ -877,14 +876,14 @@ public cmdModules(id, level, cid)
for (new i = 0; i < num; i++) for (new i = 0; i < num; i++)
{ {
get_module(i, name, 31, author, 31, version, 31, status) get_module(i, name, charsmax(name), author, charsmax(author), version, charsmax(version), status)
switch (status) switch (status)
{ {
case module_loaded: copy(sStatus, 15, "running") case module_loaded: copy(sStatus, charsmax(sStatus), "running")
default: default:
{ {
copy(sStatus, 15, "bad load"); copy(sStatus, charsmax(sStatus), "bad load");
copy(name, charsmax(name), "unknown"); copy(name, charsmax(name), "unknown");
copy(author, charsmax(author), "unknown"); copy(author, charsmax(author), "unknown");
copy(version, charsmax(version), "unknown"); copy(version, charsmax(version), "unknown");
@ -904,7 +903,7 @@ public cmdCfg(id, level, cid)
return PLUGIN_HANDLED return PLUGIN_HANDLED
new arg[128] new arg[128]
read_argv(1, arg, 127) read_argv(1, arg, charsmax(arg))
if (!file_exists(arg)) if (!file_exists(arg))
{ {
@ -914,8 +913,8 @@ public cmdCfg(id, level, cid)
new authid[32], name[32] new authid[32], name[32]
get_user_authid(id, authid, 31) get_user_authid(id, authid, charsmax(authid))
get_user_name(id, name, 31) get_user_name(id, name, charsmax(name))
log_amx("Cmd: ^"%s<%d><%s><>^" execute cfg (file ^"%s^")", name, get_user_userid(id), authid, arg) log_amx("Cmd: ^"%s<%d><%s><>^" execute cfg (file ^"%s^")", name, get_user_userid(id), authid, arg)
@ -935,7 +934,7 @@ public cmdLBack()
new paused[25] new paused[25]
format(paused, 24, "%L", g_pauseCon, g_Paused ? "UNPAUSED" : "PAUSED") format(paused, 24, "%L", g_pauseCon, g_Paused ? "UNPAUSED" : "PAUSED")
set_cvar_float("pausable", g_pausAble) set_pcvar_float(pausable, g_pausAble)
console_print(g_pauseCon, "[AMXX] Server %s", paused) console_print(g_pauseCon, "[AMXX] Server %s", paused)
g_PauseAllowed = false g_PauseAllowed = false
@ -954,8 +953,8 @@ public cmdPause(id, level, cid)
new authid[32], name[32], slayer = id new authid[32], name[32], slayer = id
get_user_authid(id, authid, 31) get_user_authid(id, authid, charsmax(authid))
get_user_name(id, name, 31) get_user_name(id, name, charsmax(name))
if (pausable!=0) if (pausable!=0)
{ {
g_pausAble = get_pcvar_float(pausable) g_pausAble = get_pcvar_float(pausable)
@ -970,7 +969,7 @@ public cmdPause(id, level, cid)
return PLUGIN_HANDLED return PLUGIN_HANDLED
} }
set_cvar_float("pausable", 1.0) set_pcvar_float(pausable, 1.0)
g_PauseAllowed = true g_PauseAllowed = true
client_cmd(slayer, "pause;pauseAck") client_cmd(slayer, "pause;pauseAck")
@ -980,13 +979,11 @@ public cmdPause(id, level, cid)
// Display the message to all clients // Display the message to all clients
new maxpl = get_maxplayers(); new players[32], pnum
for (new i = 1; i <= maxpl; i++) get_players(players, pnum, "ch")
for (new i; i<pnum; i++)
{ {
if (is_user_connected(i) && !is_user_bot(i)) show_activity_id(players[i], id, name, "%L server", i, g_Paused ? "UNPAUSE" : "PAUSE");
{
show_activity_id(i, id, name, "%L server", i, g_Paused ? "UNPAUSE" : "PAUSE");
}
} }
g_pauseCon = id g_pauseCon = id
@ -1009,7 +1006,7 @@ public cmdShowRcon(id, level, cid)
} else { } else {
new args[128] new args[128]
read_args(args, 127) read_args(args, charsmax(args))
client_cmd(id, "rcon_password %s", password) client_cmd(id, "rcon_password %s", password)
client_cmd(id, "rcon %s", args) client_cmd(id, "rcon %s", args)
} }
@ -1024,9 +1021,9 @@ public cmdRcon(id, level, cid)
new arg[128], authid[32], name[32] new arg[128], authid[32], name[32]
read_args(arg, 127) read_args(arg, charsmax(arg))
get_user_authid(id, authid, 31) get_user_authid(id, authid, charsmax(authid))
get_user_name(id, name, 31) get_user_name(id, name, charsmax(name))
log_amx("Cmd: ^"%s<%d><%s><>^" server console (cmdline ^"%s^")", name, get_user_userid(id), authid, arg) log_amx("Cmd: ^"%s<%d><%s><>^" server console (cmdline ^"%s^")", name, get_user_userid(id), authid, arg)
@ -1041,32 +1038,33 @@ public cmdWho(id, level, cid)
if (!cmd_access(id, level, cid, 1)) if (!cmd_access(id, level, cid, 1))
return PLUGIN_HANDLED return PLUGIN_HANDLED
new players[32], inum, cl_on_server[64], authid[32], name[32], flags, sflags[32] new players[32], inum, cl_on_server[64], authid[32], name[32], flags, sflags[32], plr
new lImm[16], lRes[16], lAccess[16], lYes[16], lNo[16] new lImm[16], lRes[16], lAccess[16], lYes[16], lNo[16]
format(lImm, 15, "%L", id, "IMMU") formatex(lImm, charsmax(lImm), "%L", id, "IMMU")
format(lRes, 15, "%L", id, "RESERV") formatex(lRes, charsmax(lRes), "%L", id, "RESERV")
format(lAccess, 15, "%L", id, "ACCESS") formatex(lAccess, charsmax(lAccess), "%L", id, "ACCESS")
format(lYes, 15, "%L", id, "YES") formatex(lYes, charsmax(lYes), "%L", id, "YES")
format(lNo, 15, "%L", id, "NO") formatex(lNo, charsmax(lNo), "%L", id, "NO")
get_players(players, inum) get_players(players, inum)
format(cl_on_server, 63, "%L", id, "CLIENTS_ON_SERVER") format(cl_on_server, charsmax(cl_on_server), "%L", id, "CLIENTS_ON_SERVER")
console_print(id, "^n%s:^n # %-16.15s %-20s %-8s %-4.3s %-4.3s %s", cl_on_server, "nick", "authid", "userid", lImm, lRes, lAccess) console_print(id, "^n%s:^n # %-16.15s %-20s %-8s %-4.3s %-4.3s %s", cl_on_server, "nick", "authid", "userid", lImm, lRes, lAccess)
for (new a = 0; a < inum; ++a) for (new a = 0; a < inum; ++a)
{ {
get_user_authid(players[a], authid, 31) plr = players[a]
get_user_name(players[a], name, 31) get_user_authid(plr, authid, charsmax(authid))
flags = get_user_flags(players[a]) get_user_name(plr, name, charsmax(name))
get_flags(flags, sflags, 31) flags = get_user_flags(plr)
console_print(id, "%2d %-16.15s %-20s %-8d %-6.5s %-6.5s %s", players[a], name, authid, get_flags(flags, sflags, charsmax(sflags))
get_user_userid(players[a]), (flags&ADMIN_IMMUNITY) ? lYes : lNo, (flags&ADMIN_RESERVATION) ? lYes : lNo, sflags) console_print(id, "%2d %-16.15s %-20s %-8d %-6.5s %-6.5s %s", plr, name, authid,
get_user_userid(plr), (flags&ADMIN_IMMUNITY) ? lYes : lNo, (flags&ADMIN_RESERVATION) ? lYes : lNo, sflags)
} }
console_print(id, "%L", id, "TOTAL_NUM", inum) console_print(id, "%L", id, "TOTAL_NUM", inum)
get_user_authid(id, authid, 31) get_user_authid(id, authid, charsmax(authid))
get_user_name(id, name, 31) get_user_name(id, name, charsmax(name))
log_amx("Cmd: ^"%s<%d><%s><>^" ask for players list", name, get_user_userid(id), authid) log_amx("Cmd: ^"%s<%d><%s><>^" ask for players list", name, get_user_userid(id), authid)
return PLUGIN_HANDLED return PLUGIN_HANDLED
@ -1092,7 +1090,7 @@ public cmdLeave(id, level, cid)
for (new a = 1; a < 5; ++a) for (new a = 1; a < 5; ++a)
{ {
if (a < argnum) if (a < argnum)
read_argv(a, ltags[ltagsnum++], 31) read_argv(a, ltags[ltagsnum++], charsmax(ltags[]))
else else
ltags[ltagsnum++][0] = 0 ltags[ltagsnum++][0] = 0
} }
@ -1103,7 +1101,7 @@ public cmdLeave(id, level, cid)
{ {
if (!is_user_connected(b) && !is_user_connecting(b)) continue if (!is_user_connected(b) && !is_user_connecting(b)) continue
get_user_name(b, nick, 31) get_user_name(b, nick, charsmax(nick))
ires = hasTag(nick, ltags, ltagsnum) ires = hasTag(nick, ltags, ltagsnum)
if (ires != -1) if (ires != -1)
@ -1124,7 +1122,7 @@ public cmdLeave(id, level, cid)
server_cmd("kick #%d", get_user_userid(b)) server_cmd("kick #%d", get_user_userid(b))
else else
{ {
format(lReason, 127, "%L", b, "YOU_DROPPED") formatex(lReason, charsmax(lReason), "%L", b, "YOU_DROPPED")
server_cmd("kick #%d ^"%s^"", get_user_userid(b), lReason) server_cmd("kick #%d ^"%s^"", get_user_userid(b), lReason)
} }
count++ count++
@ -1134,8 +1132,8 @@ public cmdLeave(id, level, cid)
new authid[32], name[32] new authid[32], name[32]
get_user_authid(id, authid, 31) get_user_authid(id, authid, charsmax(authid))
get_user_name(id, name, 31) get_user_name(id, name, charsmax(name))
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]) 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])
show_activity_key("ADMIN_LEAVE_1", "ADMIN_LEAVE_2", name, ltags[0], ltags[1], ltags[2], ltags[3]); show_activity_key("ADMIN_LEAVE_1", "ADMIN_LEAVE_2", name, ltags[0], ltags[1], ltags[2], ltags[3]);
@ -1150,20 +1148,20 @@ public cmdNick(id, level, cid)
new arg1[32], arg2[32], authid[32], name[32], authid2[32], name2[32] new arg1[32], arg2[32], authid[32], name[32], authid2[32], name2[32]
read_argv(1, arg1, 31) read_argv(1, arg1, charsmax(arg1))
read_argv(2, arg2, 31) read_argv(2, arg2, charsmax(arg2))
new player = cmd_target(id, arg1, CMDTARGET_OBEY_IMMUNITY | CMDTARGET_ALLOW_SELF) new player = cmd_target(id, arg1, CMDTARGET_OBEY_IMMUNITY | CMDTARGET_ALLOW_SELF)
if (!player) if (!player)
return PLUGIN_HANDLED return PLUGIN_HANDLED
get_user_authid(id, authid, 31) get_user_authid(id, authid, charsmax(authid))
get_user_name(id, name, 31) get_user_name(id, name, charsmax(name))
get_user_authid(player, authid2, 31) get_user_authid(player, authid2, charsmax(authid2))
get_user_name(player, name2, 31) get_user_name(player, name2, charsmax(name2))
client_cmd(player, "name ^"%s^"", arg2) set_user_info(player, "name", arg2)
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) 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)