new cleaned-up version of the plugins (no more OLOcode :D)

This commit is contained in:
Borja Ferrer 2005-09-12 21:06:24 +00:00
parent 12bf140931
commit ddf3b6df32
19 changed files with 4609 additions and 3646 deletions

View File

@ -38,205 +38,270 @@
new g_msgChannel new g_msgChannel
#define MAX_CLR 10 #define MAX_CLR 10
new g_Colors[MAX_CLR][] = {"COL_WHITE","COL_RED","COL_GREEN","COL_BLUE","COL_YELLOW","COL_MAGENTA","COL_CYAN","COL_ORANGE","COL_OCEAN","COL_MAROON"}
new g_Values[MAX_CLR][] = {{255,255,255},{255,0,0},{0,255,0},{0,0,255},{255,255,0},{255,0,255},{0,255,255},{227,96,8},{45,89,116},{103,44,38}}
new Float:g_Pos[4][] = {{0.0,0.0},{0.05,0.55},{-1.0,0.2},{-1.0,0.7}}
public plugin_init() { new g_Colors[MAX_CLR][] = {"COL_WHITE", "COL_RED", "COL_GREEN", "COL_BLUE", "COL_YELLOW", "COL_MAGENTA", "COL_CYAN", "COL_ORANGE", "COL_OCEAN", "COL_MAROON"}
register_plugin("Admin Chat",AMXX_VERSION_STR,"AMXX Dev Team") new g_Values[MAX_CLR][] = {{255, 255, 255}, {255, 0, 0}, {0, 255, 0}, {0, 0, 255}, {255, 255, 0}, {255, 0, 255}, {0, 255, 255}, {227, 96, 8}, {45, 89, 116}, {103, 44, 38}}
register_dictionary("adminchat.txt") new Float:g_Pos[4][] = {{0.0, 0.0}, {0.05, 0.55}, {-1.0, 0.2}, {-1.0, 0.7}}
register_dictionary("common.txt")
register_clcmd("say","cmdSayChat",ADMIN_CHAT,"@[@|@|@][w|r|g|b|y|m|c]<text> - displays hud message") public plugin_init()
register_clcmd("say_team","cmdSayAdmin",0,"@<text> - displays message to admins") {
register_concmd("amx_say","cmdSay",ADMIN_CHAT,"<message> - sends message to all players") register_plugin("Admin Chat", AMXX_VERSION_STR, "AMXX Dev Team")
register_concmd("amx_chat","cmdChat",ADMIN_CHAT,"<message> - sends message to admins") register_dictionary("adminchat.txt")
register_concmd("amx_psay","cmdPsay",ADMIN_CHAT,"<name or #userid> <message> - sends private message") register_dictionary("common.txt")
register_concmd("amx_tsay","cmdTsay",ADMIN_CHAT,"<color> <message> - sends left side hud message to all players") register_clcmd("say", "cmdSayChat", ADMIN_CHAT, "@[@|@|@][w|r|g|b|y|m|c]<text> - displays hud message")
register_concmd("amx_csay","cmdTsay",ADMIN_CHAT,"<color> <message> - sends center hud message to all players") register_clcmd("say_team", "cmdSayAdmin", 0, "@<text> - displays message to admins")
register_concmd("amx_say", "cmdSay", ADMIN_CHAT, "<message> - sends message to all players")
register_concmd("amx_chat", "cmdChat", ADMIN_CHAT, "<message> - sends message to admins")
register_concmd("amx_psay", "cmdPsay", ADMIN_CHAT, "<name or #userid> <message> - sends private message")
register_concmd("amx_tsay", "cmdTsay", ADMIN_CHAT, "<color> <message> - sends left side hud message to all players")
register_concmd("amx_csay", "cmdTsay", ADMIN_CHAT, "<color> <message> - sends center hud message to all players")
} }
public cmdSayChat(id) { public cmdSayChat(id)
if (!access(id,ADMIN_CHAT)) return PLUGIN_CONTINUE {
new said[6], i=0 if (!access(id, ADMIN_CHAT))
read_argv(1,said,5) return PLUGIN_CONTINUE
while (said[i]=='@')
i++ new said[6], i = 0
if ( !i || i > 3 ) return PLUGIN_CONTINUE read_argv(1, said, 5)
new message[192], a = 0
read_args(message,191) while (said[i] == '@')
remove_quotes(message) i++
switch(said[i]){
case 'r': a = 1 if (!i || i > 3)
case 'g': a = 2 return PLUGIN_CONTINUE
case 'b': a = 3
case 'y': a = 4 new message[192], a = 0
case 'm': a = 5 read_args(message, 191)
case 'c': a = 6 remove_quotes(message)
case 'o': a = 7
} switch(said[i])
new name[32], authid[32], userid {
get_user_authid(id,authid,31) case 'r': a = 1
get_user_name(id,name,31) case 'g': a = 2
userid = get_user_userid(id) case 'b': a = 3
log_amx("Chat: ^"%s<%d><%s><>^" tsay ^"%s^"",name,userid,authid,message[i+1]) case 'y': a = 4
log_message("^"%s<%d><%s><>^" triggered ^"amx_tsay^" (text ^"%s^") (color ^"%L^")", case 'm': a = 5
name,userid,authid,message[ i+1 ],"en",g_Colors[a]) case 'c': a = 6
if (++g_msgChannel>6||g_msgChannel<3) case 'o': a = 7
g_msgChannel = 3 }
new Float:verpos = g_Pos[i][1] + float(g_msgChannel) / 35.0
set_hudmessage(g_Values[a][0], g_Values[a][1], g_Values[a][2],
g_Pos[i][0], verpos , 0, 6.0, 6.0, 0.5, 0.15, g_msgChannel )
if ( get_cvar_num("amx_show_activity") == 2 ){ new name[32], authid[32], userid
show_hudmessage(0,"%s : %s",name,message[i+1])
client_print(0,print_notify,"%s : %s",name,message[i+1]) get_user_authid(id, authid, 31)
} get_user_name(id, name, 31)
else{ userid = get_user_userid(id)
show_hudmessage(0,"%s", message[i+1])
client_print(0,print_notify,"%s", message[i+1]) log_amx("Chat: ^"%s<%d><%s><>^" tsay ^"%s^"", name, userid, authid, message[i + 1])
} log_message("^"%s<%d><%s><>^" triggered ^"amx_tsay^" (text ^"%s^") (color ^"%L^")", name, userid, authid, message[i + 1], "en", g_Colors[a])
if (++g_msgChannel > 6 || g_msgChannel < 3)
g_msgChannel = 3
new Float:verpos = g_Pos[i][1] + float(g_msgChannel) / 35.0
set_hudmessage(g_Values[a][0], g_Values[a][1], g_Values[a][2], g_Pos[i][0], verpos, 0, 6.0, 6.0, 0.5, 0.15, g_msgChannel)
return PLUGIN_HANDLED if (get_cvar_num("amx_show_activity") == 2)
{
show_hudmessage(0, "%s : %s", name, message[i + 1])
client_print(0, print_notify, "%s : %s", name, message[i + 1])
} else {
show_hudmessage(0, "%s", message[i + 1])
client_print(0, print_notify, "%s", message[i + 1])
}
return PLUGIN_HANDLED
} }
public cmdSayAdmin(id) { public cmdSayAdmin(id)
new said[2] {
read_argv(1,said,1) new said[2]
if (said[0]!='@') return PLUGIN_CONTINUE read_argv(1, said, 1)
new message[192], name[32],authid[32], userid
new players[32], inum if (said[0] != '@')
read_args(message,191) return PLUGIN_CONTINUE
remove_quotes(message)
get_user_authid(id,authid,31) new message[192], name[32], authid[32], userid
get_user_name(id,name,31) new players[32], inum
userid = get_user_userid(id)
log_amx("Chat: ^"%s<%d><%s><>^" chat ^"%s^"",name,userid,authid,message[1]) read_args(message, 191)
log_message("^"%s<%d><%s><>^" triggered ^"amx_chat^" (text ^"%s^")",name,userid,authid,message[1]) remove_quotes(message)
format(message,191,"(ADMINS) %s : %s",name,message[1]) get_user_authid(id, authid, 31)
get_players(players,inum) get_user_name(id, name, 31)
for (new i=0; i<inum; ++i){ userid = get_user_userid(id)
if (players[i] != id && get_user_flags(players[i]) & ADMIN_CHAT)
client_print(players[i],print_chat,"%s",message) log_amx("Chat: ^"%s<%d><%s><>^" chat ^"%s^"", name, userid, authid, message[1])
} log_message("^"%s<%d><%s><>^" triggered ^"amx_chat^" (text ^"%s^")", name, userid, authid, message[1])
client_print(id,print_chat,"%s",message)
return PLUGIN_HANDLED format(message, 191, "(ADMINS) %s : %s", name, message[1])
get_players(players, inum)
for (new i = 0; i < inum; ++i)
{
if (players[i] != id && get_user_flags(players[i]) & ADMIN_CHAT)
client_print(players[i], print_chat, "%s", message)
}
client_print(id, print_chat, "%s", message)
return PLUGIN_HANDLED
} }
public cmdChat(id,level,cid) { public cmdChat(id, level, cid)
if (!cmd_access(id,level,cid,2)) {
return PLUGIN_HANDLED if (!cmd_access(id, level, cid, 2))
new message[192], name[32], players[32], inum, authid[32], userid return PLUGIN_HANDLED
read_args(message,191)
remove_quotes(message) new message[192], name[32], players[32], inum, authid[32], userid
get_user_authid(id,authid,31)
get_user_name(id,name,31) read_args(message, 191)
userid = get_user_userid(id) remove_quotes(message)
get_players(players,inum) get_user_authid(id, authid, 31)
log_amx("Chat: ^"%s<%d><%s><>^" chat ^"%s^"",name,userid,authid,message) get_user_name(id, name, 31)
log_message("^"%s<%d><%s><>^" triggered ^"amx_chat^" (text ^"%s^")",name,userid,authid,message) userid = get_user_userid(id)
format(message,191,"(ADMINS) %s : %s",name,message) get_players(players, inum)
console_print(id,"%s",message)
for (new i = 0; i < inum; ++i) { log_amx("Chat: ^"%s<%d><%s><>^" chat ^"%s^"", name, userid, authid, message)
if ( access(players[i],ADMIN_CHAT) ) log_message("^"%s<%d><%s><>^" triggered ^"amx_chat^" (text ^"%s^")", name, userid, authid, message)
client_print(players[i],print_chat,"%s",message)
} format(message, 191, "(ADMINS) %s : %s", name, message)
return PLUGIN_HANDLED console_print(id, "%s", message)
for (new i = 0; i < inum; ++i)
{
if (access(players[i], ADMIN_CHAT))
client_print(players[i], print_chat, "%s", message)
}
return PLUGIN_HANDLED
} }
public cmdSay(id,level,cid) { public cmdSay(id, level, cid)
if (!cmd_access(id,level,cid,2)) {
return PLUGIN_HANDLED if (!cmd_access(id, level, cid, 2))
new message[192],name[32],authid[32],userid return PLUGIN_HANDLED
read_args(message,191)
remove_quotes(message) new message[192], name[32], authid[32], userid
get_user_authid(id,authid,31)
get_user_name(id,name,31) read_args(message, 191)
userid = get_user_userid(id) remove_quotes(message)
client_print(0,print_chat,"%L",LANG_PLAYER, "PRINT_ALL",name,message) get_user_authid(id, authid, 31)
console_print(id,"%L",LANG_PLAYER,"PRINT_ALL",name,message) get_user_name(id, name, 31)
log_amx("Chat: ^"%s<%d><%s><>^" say ^"%s^"", name,userid,authid,message) userid = get_user_userid(id)
log_message("^"%s<%d><%s><>^" triggered ^"amx_say^" (text ^"%s^")",name,userid,authid,message) client_print(0, print_chat, "%L", LANG_PLAYER, "PRINT_ALL", name, message)
return PLUGIN_HANDLED console_print(id, "%L", LANG_PLAYER, "PRINT_ALL", name, message)
log_amx("Chat: ^"%s<%d><%s><>^" say ^"%s^"", name, userid, authid, message)
log_message("^"%s<%d><%s><>^" triggered ^"amx_say^" (text ^"%s^")", name, userid, authid, message)
return PLUGIN_HANDLED
} }
public cmdPsay(id,level,cid) { public cmdPsay(id, level, cid)
if (!cmd_access(id,level,cid,3)) {
return PLUGIN_HANDLED if (!cmd_access(id, level, cid, 3))
new name[32] return PLUGIN_HANDLED
read_argv(1,name,31)
new priv = cmd_target(id,name,0) new name[32]
if (!priv) return PLUGIN_HANDLED read_argv(1, name, 31)
new length = strlen(name)+1 new priv = cmd_target(id, name, 0)
new message[192], name2[32],authid[32],authid2[32], userid, userid2
get_user_authid(id,authid,31) if (!priv)
get_user_name(id,name2,31) return PLUGIN_HANDLED
userid = get_user_userid(id)
read_args(message,191) new length = strlen(name) + 1
if (message[0]=='"' && message[length]=='"'){ // HLSW fix new message[192], name2[32], authid[32], authid2[32], userid, userid2
message[0]=' '
message[length]=' ' get_user_authid(id, authid, 31)
length+=2 get_user_name(id, name2, 31)
} userid = get_user_userid(id)
remove_quotes(message[length]) read_args(message, 191)
get_user_name(priv,name,31)
if (id&&id!=priv) client_print(id,print_chat,"(%s) %s : %s",name,name2,message[length]) if (message[0] == '"' && message[length] == '"') // HLSW fix
client_print(priv,print_chat,"(%s) %s : %s",name,name2,message[length]) {
console_print(id,"(%s) %s : %s",name,name2,message[length]) message[0] = ' '
get_user_authid(priv,authid2,31) message[length] = ' '
userid2 = get_user_userid(priv) length += 2
log_amx("Chat: ^"%s<%d><%s><>^" psay ^"%s<%d><%s><>^" ^"%s^"", }
name2,userid,authid,name,userid2,authid2,message[length])
log_message("^"%s<%d><%s><>^" triggered ^"amx_psay^" against ^"%s<%d><%s><>^" (text ^"%s^")", remove_quotes(message[length])
name2,userid,authid,name,userid2,authid2,message[length]) get_user_name(priv, name, 31)
return PLUGIN_HANDLED
if (id && id != priv)
client_print(id, print_chat, "(%s) %s : %s", name, name2, message[length])
client_print(priv, print_chat, "(%s) %s : %s", name, name2, message[length])
console_print(id, "(%s) %s : %s", name, name2, message[length])
get_user_authid(priv, authid2, 31)
userid2 = get_user_userid(priv)
log_amx("Chat: ^"%s<%d><%s><>^" psay ^"%s<%d><%s><>^" ^"%s^"", name2, userid, authid, name, userid2, authid2, message[length])
log_message("^"%s<%d><%s><>^" triggered ^"amx_psay^" against ^"%s<%d><%s><>^" (text ^"%s^")", name2, userid, authid, name, userid2, authid2, message[length])
return PLUGIN_HANDLED
} }
public cmdTsay(id,level,cid) { public cmdTsay(id, level, cid)
if (!cmd_access(id,level,cid,3)) {
return PLUGIN_HANDLED if (!cmd_access(id, level, cid, 3))
new cmd[16], color[16], color2[16], message[192], name[32], authid[32], userid = 0 return PLUGIN_HANDLED
read_argv(0,cmd,15)
new bool:tsay = (tolower(cmd[4]) == 't') new cmd[16], color[16], color2[16], message[192], name[32], authid[32], userid = 0
read_args(message,191)
remove_quotes(message) read_argv(0, cmd, 15)
parse(message,color,15) new bool:tsay = (tolower(cmd[4]) == 't')
new found = 0,a = 0
new lang[3],langnum = get_langsnum() read_args(message, 191)
for (new i=0;i<MAX_CLR;++i) { remove_quotes(message)
for (new j=0;j<langnum;j++) { parse(message, color, 15)
get_lang(j,lang)
format(color2,15,"%L",lang,g_Colors[i]) new found = 0, a = 0
if (equali(color,color2)) { new lang[3], langnum = get_langsnum()
a = i
found = 1
break
}
}
if (found==1)
break
}
new length = found ? (strlen(color) + 1) : 0
if (++g_msgChannel>6||g_msgChannel<3)
g_msgChannel = 3
new Float:verpos = ( tsay ? 0.55 : 0.1 ) + float(g_msgChannel) / 35.0
get_user_authid(id,authid,31)
get_user_name(id,name,31)
userid = get_user_userid(id)
set_hudmessage(g_Values[a][0], g_Values[a][1], g_Values[a][2], tsay ? 0.05 : -1.0, verpos, 0, 6.0, 6.0, 0.5, 0.15, g_msgChannel)
if ( get_cvar_num("amx_show_activity") == 2 ){ for (new i = 0; i < MAX_CLR; ++i)
show_hudmessage(0,"%s : %s",name,message[length]) {
client_print(0,print_notify,"%s : %s",name,message[length]) for (new j = 0; j < langnum; j++)
console_print(id,"%s : %s",name,message[length]) {
} get_lang(j, lang)
else{ format(color2, 15, "%L", lang, g_Colors[i])
show_hudmessage(0,"%s",message[length])
client_print(0,print_notify,"%s",message[length]) if (equali(color, color2))
console_print(id,"%s",message[length]) {
} a = i
found = 1
log_amx("Chat: ^"%s<%d><%s><>^" %s ^"%s^"",name,userid,authid,cmd[4],message[length]) break
log_message("^"%s<%d><%s><>^" triggered ^"%s^" (text ^"%s^") (color ^"%s^")", }
name,userid,authid,cmd,message[length],color2) }
return PLUGIN_HANDLED if (found == 1)
} break
}
new length = found ? (strlen(color) + 1) : 0
if (++g_msgChannel > 6 || g_msgChannel < 3)
g_msgChannel = 3
new Float:verpos = (tsay ? 0.55 : 0.1) + float(g_msgChannel) / 35.0
get_user_authid(id, authid, 31)
get_user_name(id, name, 31)
userid = get_user_userid(id)
set_hudmessage(g_Values[a][0], g_Values[a][1], g_Values[a][2], tsay ? 0.05 : -1.0, verpos, 0, 6.0, 6.0, 0.5, 0.15, g_msgChannel)
if (get_cvar_num("amx_show_activity") == 2)
{
show_hudmessage(0, "%s : %s", name, message[length])
client_print(0, print_notify, "%s : %s", name, message[length])
console_print(id, "%s : %s", name, message[length])
} else {
show_hudmessage(0, "%s", message[length])
client_print(0, print_notify, "%s", message[length])
console_print(id, "%s", message[length])
}
log_amx("Chat: ^"%s<%d><%s><>^" %s ^"%s^"", name, userid, authid, cmd[4], message[length])
log_message("^"%s<%d><%s><>^" triggered ^"%s^" (text ^"%s^") (color ^"%s^")", name, userid, authid, cmd, message[length], color2)
return PLUGIN_HANDLED
}

File diff suppressed because it is too large Load Diff

View File

@ -18,12 +18,12 @@
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, * along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* In addition, as a special exception, the author gives permission to * In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL * link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve, * Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all * 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 * 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 * from Valve. If you modify this file, you may extend this exception
@ -34,77 +34,90 @@
#include <amxmodx> #include <amxmodx>
#define DISPLAY_MSG // Comment to disable message on join #define DISPLAY_MSG // Comment to disable message on join
#define HELPAMOUNT 10 // Number of commands per page #define HELPAMOUNT 10 // Number of commands per page
public plugin_init() { public plugin_init()
register_plugin("Admin Help",AMXX_VERSION_STR,"AMXX Dev Team") {
register_dictionary("adminhelp.txt") register_plugin("Admin Help", AMXX_VERSION_STR, "AMXX Dev Team")
register_concmd("amx_help","cmdHelp",0,"<page> [nr of cmds (only for server)] - displays this help") register_dictionary("adminhelp.txt")
register_concmd("amx_help", "cmdHelp", 0, "<page> [nr of cmds (only for server)] - displays this help")
} }
#if defined DISPLAY_MSG #if defined DISPLAY_MSG
public client_putinserver(id) { public client_putinserver(id)
if (is_user_bot(id)) {
return if (is_user_bot(id))
set_task(15.0,"dispInfo",id) return
set_task(15.0, "dispInfo", id)
} }
public client_disconnect(id) { public client_disconnect(id)
{
remove_task(id) remove_task(id)
} }
#endif #endif
public cmdHelp(id,level,cid) { public cmdHelp(id, level, cid)
{
new arg1[8], flags = get_user_flags(id) new arg1[8], flags = get_user_flags(id)
new start = read_argv(1,arg1,7) ? str_to_num(arg1) : 1 new start = read_argv(1, arg1, 7) ? str_to_num(arg1) : 1
new lHelpAmount = HELPAMOUNT new lHelpAmount = HELPAMOUNT
if (id == 0 && read_argc() == 3) if (id == 0 && read_argc() == 3)
lHelpAmount = read_argv(2, arg1, 7) ? str_to_num(arg1) : HELPAMOUNT lHelpAmount = read_argv(2, arg1, 7) ? str_to_num(arg1) : HELPAMOUNT
if (--start < 0) if (--start < 0)
start = 0 start = 0
new clcmdsnum = get_concmdsnum(flags,id) new clcmdsnum = get_concmdsnum(flags, id)
if (start >= clcmdsnum) if (start >= clcmdsnum)
start = clcmdsnum - 1 start = clcmdsnum - 1
console_print(id,"^n----- %L -----",id,"HELP_COMS") console_print(id, "^n----- %L -----", id, "HELP_COMS")
new info[128], cmd[32], eflags new info[128], cmd[32], eflags
new end = start + lHelpAmount // HELPAMOUNT new end = start + lHelpAmount // HELPAMOUNT
if (end > clcmdsnum) if (end > clcmdsnum)
end = clcmdsnum end = clcmdsnum
for (new i = start; i < end; i++) { for (new i = start; i < end; i++)
get_concmd(i,cmd,31,eflags,info,127,flags,id) {
console_print(id,"%3d: %s %s",i+1,cmd,info) get_concmd(i, cmd, 31, eflags, info, 127, flags, id)
console_print(id, "%3d: %s %s", i + 1, cmd, info)
} }
console_print(id,"----- %L -----",id,"HELP_ENTRIES",start+1,end,clcmdsnum)
console_print(id, "----- %L -----", id, "HELP_ENTRIES", start + 1, end, clcmdsnum)
if (end < clcmdsnum) if (end < clcmdsnum)
console_print(id,"----- %L -----",id,"HELP_USE_MORE",end+1) console_print(id, "----- %L -----", id, "HELP_USE_MORE", end + 1)
else else
console_print(id,"----- %L -----",id,"HELP_USE_BEGIN") console_print(id, "----- %L -----", id, "HELP_USE_BEGIN")
return PLUGIN_HANDLED return PLUGIN_HANDLED
} }
#if defined DISPLAY_MSG #if defined DISPLAY_MSG
public dispInfo(id) { public dispInfo(id)
client_print(id,print_chat,"%L",id,"TYPE_HELP") {
new nextmap[32] client_print(id, print_chat, "%L", id, "TYPE_HELP")
get_cvar_string("amx_nextmap",nextmap,31)
if (get_cvar_float("mp_timelimit")) { new nextmap[32]
new timeleft = get_timeleft() get_cvar_string("amx_nextmap", nextmap, 31)
if (timeleft > 0) {
client_print(id,print_chat, "%L" , id, "TIME_INFO_1", timeleft / 60, timeleft % 60,nextmap) if (get_cvar_float("mp_timelimit"))
} {
else { new timeleft = get_timeleft()
client_print(id,print_chat,"%L",id,"TIME_INFO_2",nextmap)
} if (timeleft > 0)
} {
client_print(id, print_chat, "%L", id, "TIME_INFO_1", timeleft / 60, timeleft % 60, nextmap)
} else {
client_print(id, print_chat, "%L", id, "TIME_INFO_2", nextmap)
}
}
} }
#endif #endif

View File

@ -40,67 +40,68 @@
new g_cmdLoopback[16] new g_cmdLoopback[16]
public plugin_init() { public plugin_init()
register_plugin("Slots Reservation",AMXX_VERSION_STR,"AMXX Dev Team") {
register_dictionary("adminslots.txt") register_plugin("Slots Reservation", AMXX_VERSION_STR, "AMXX Dev Team")
register_dictionary("common.txt") register_dictionary("adminslots.txt")
register_cvar("amx_reservation","1") register_dictionary("common.txt")
register_cvar("amx_reservation", "1")
format( g_cmdLoopback, 15, "amxres%c%c%c%c" ,
random_num('A','Z') , random_num('A','Z') ,random_num('A','Z'),random_num('A','Z') ) format(g_cmdLoopback, 15, "amxres%c%c%c%c", random_num('A', 'Z'), random_num('A', 'Z'), random_num('A', 'Z'), random_num('A', 'Z'))
register_clcmd(g_cmdLoopback, "ackSignal")
register_clcmd( g_cmdLoopback, "ackSignal" )
#if defined HIDE_RESERVED_SLOTS #if defined HIDE_RESERVED_SLOTS
new maxplayers = get_maxplayers() new maxplayers = get_maxplayers()
new players = get_playersnum(1) new players = get_playersnum(1)
new limit = maxplayers - get_cvar_num("amx_reservation") new limit = maxplayers - get_cvar_num("amx_reservation")
setVisibleSlots(players, maxplayers, limit) setVisibleSlots(players, maxplayers, limit)
#endif #endif
} }
public ackSignal(id) { public ackSignal(id)
new lReason[64] {
format(lReason,63,"%L",id,"DROPPED_RES") new lReason[64]
server_cmd("kick #%d ^"%s^"", get_user_userid(id), lReason ) format(lReason, 63, "%L", id, "DROPPED_RES")
server_cmd("kick #%d ^"%s^"", get_user_userid(id), lReason)
} }
public client_authorized(id) { public client_authorized(id)
new maxplayers = get_maxplayers() {
new players = get_playersnum( 1 ) new maxplayers = get_maxplayers()
new limit = maxplayers - get_cvar_num("amx_reservation") new players = get_playersnum(1)
new limit = maxplayers - get_cvar_num("amx_reservation")
if ( access(id,ADMIN_RESERVATION) || (players <= limit) )
{ if (access(id, ADMIN_RESERVATION) || (players <= limit))
{
#if defined HIDE_RESERVED_SLOTS #if defined HIDE_RESERVED_SLOTS
setVisibleSlots( players , maxplayers, limit ) setVisibleSlots(players, maxplayers, limit)
#endif #endif
return PLUGIN_CONTINUE return PLUGIN_CONTINUE
} }
client_cmd(id, g_cmdLoopback)
client_cmd(id,g_cmdLoopback) return PLUGIN_HANDLED
return PLUGIN_HANDLED
} }
#if defined HIDE_RESERVED_SLOTS #if defined HIDE_RESERVED_SLOTS
public client_disconnect(id) public client_disconnect(id)
{ {
new maxplayers = get_maxplayers() new maxplayers = get_maxplayers()
setVisibleSlots( get_playersnum(1) - 1 , maxplayers ,
maxplayers - get_cvar_num("amx_reservation") ) setVisibleSlots(get_playersnum(1) - 1, maxplayers, maxplayers - get_cvar_num("amx_reservation"))
return PLUGIN_CONTINUE return PLUGIN_CONTINUE
} }
setVisibleSlots( players , maxplayers , limit ) setVisibleSlots(players, maxplayers, limit)
{ {
new num = players + 1 new num = players + 1
if ( players == maxplayers ) if (players == maxplayers)
num = maxplayers num = maxplayers
else if ( players < limit ) else if (players < limit)
num = limit num = limit
set_cvar_num( "sv_visiblemaxplayers" , num ) set_cvar_num("sv_visiblemaxplayers", num)
} }
#endif #endif

View File

@ -48,366 +48,474 @@ new g_execLen
new bool:g_execResult new bool:g_execResult
new Float:g_voteRatio new Float:g_voteRatio
public plugin_init() { public plugin_init()
register_plugin("Admin Votes",AMXX_VERSION_STR,"AMXX Dev Team") {
register_dictionary("adminvote.txt") register_plugin("Admin Votes", AMXX_VERSION_STR, "AMXX Dev Team")
register_dictionary("common.txt") register_dictionary("adminvote.txt")
register_dictionary("mapsmenu.txt") register_dictionary("common.txt")
register_menucmd(register_menuid("Change map to "),MENU_KEY_1|MENU_KEY_2,"voteCount") register_dictionary("mapsmenu.txt")
register_menucmd(register_menuid("Choose map: "),MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4,"voteCount") register_menucmd(register_menuid("Change map to "), MENU_KEY_1|MENU_KEY_2, "voteCount")
register_menucmd(register_menuid("Kick "),MENU_KEY_1|MENU_KEY_2,"voteCount") register_menucmd(register_menuid("Choose map: "), MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4, "voteCount")
register_menucmd(register_menuid("Ban "),MENU_KEY_1|MENU_KEY_2,"voteCount") register_menucmd(register_menuid("Kick "), MENU_KEY_1|MENU_KEY_2, "voteCount")
register_menucmd(register_menuid("Vote: "),MENU_KEY_1|MENU_KEY_2,"voteCount") register_menucmd(register_menuid("Ban "), MENU_KEY_1|MENU_KEY_2, "voteCount")
register_menucmd(register_menuid("The result: "),MENU_KEY_1|MENU_KEY_2,"actionResult") register_menucmd(register_menuid("Vote: "), MENU_KEY_1|MENU_KEY_2, "voteCount")
register_concmd("amx_votemap","cmdVoteMap",ADMIN_VOTE,"<map> [map] [map] [map]") register_menucmd(register_menuid("The result: "), MENU_KEY_1|MENU_KEY_2, "actionResult")
register_concmd("amx_votekick","cmdVoteKickBan",ADMIN_VOTE,"<name or #userid>") register_concmd("amx_votemap", "cmdVoteMap", ADMIN_VOTE, "<map> [map] [map] [map]")
register_concmd("amx_voteban","cmdVoteKickBan",ADMIN_VOTE,"<name or #userid>") register_concmd("amx_votekick", "cmdVoteKickBan", ADMIN_VOTE, "<name or #userid>")
register_concmd("amx_vote","cmdVote",ADMIN_VOTE,"<question> <answer#1> <answer#2>") register_concmd("amx_voteban", "cmdVoteKickBan", ADMIN_VOTE, "<name or #userid>")
register_concmd("amx_cancelvote","cmdCancelVote",ADMIN_VOTE,"- cancels last vote") register_concmd("amx_vote", "cmdVote", ADMIN_VOTE, "<question> <answer#1> <answer#2>")
g_coloredMenus = colored_menus() register_concmd("amx_cancelvote", "cmdCancelVote", ADMIN_VOTE, "- cancels last vote")
g_coloredMenus = colored_menus()
} }
public cmdCancelVote(id,level,cid) { public cmdCancelVote(id, level, cid)
if (!cmd_access(id,level,cid,0)) {
return PLUGIN_HANDLED if (!cmd_access(id, level, cid, 0))
if ( task_exists( 99889988 , 1 ) ) { return PLUGIN_HANDLED
new authid[32],name[32]
get_user_authid(id,authid,31)
get_user_name(id,name,31)
log_amx("Vote: ^"%s<%d><%s><>^" cancel vote session", name,get_user_userid(id),authid)
new players[32],pnum,lTag[16],activity = get_cvar_num("amx_show_activity")
get_players(players,pnum,"c")
for (new i=0;i<pnum;i++) {
format(lTag,15,"%L",players[i],is_user_admin(id) ? "ADMIN" : "PLAYER")
switch (activity) {
case 2: client_print(players[i],print_chat,"%L", LANG_PLAYER, "ADMIN_CANC_VOTE_2", lTag, name)
case 1: client_print(players[i],print_chat,"%L", LANG_PLAYER, "ADMIN_CANC_VOTE_1", lTag)
}
}
console_print(id, "%L", id, "VOTING_CANC" )
client_print(0,print_chat,"%L",LANG_PLAYER,"VOTING_CANC")
remove_task( 99889988 , 1 )
set_cvar_float( "amx_last_voting" , get_gametime() )
}
else
console_print(id, "%L", id, "NO_VOTE_CANC" )
return PLUGIN_HANDLED if (task_exists(99889988, 1))
{
new authid[32], name[32]
get_user_authid(id, authid, 31)
get_user_name(id, name, 31)
log_amx("Vote: ^"%s<%d><%s><>^" cancel vote session", name, get_user_userid(id), authid)
new players[32], pnum, lTag[16], activity = get_cvar_num("amx_show_activity")
get_players(players, pnum, "c")
for (new i = 0; i < pnum;i ++)
{
format(lTag, 15, "%L", players[i], is_user_admin(id) ? "ADMIN" : "PLAYER")
switch (activity)
{
case 2: client_print(players[i], print_chat, "%L", LANG_PLAYER, "ADMIN_CANC_VOTE_2", lTag, name)
case 1: client_print(players[i], print_chat, "%L", LANG_PLAYER, "ADMIN_CANC_VOTE_1", lTag)
}
}
console_print(id, "%L", id, "VOTING_CANC")
client_print(0,print_chat,"%L",LANG_PLAYER,"VOTING_CANC")
remove_task(99889988, 1)
set_cvar_float("amx_last_voting", get_gametime())
}
else
console_print(id, "%L", id, "NO_VOTE_CANC")
return PLUGIN_HANDLED
} }
public delayedExec(cmd[]) public delayedExec(cmd[])
server_cmd(cmd) server_cmd(cmd)
public autoRefuse() { public autoRefuse()
log_amx("Vote: %L","en","RES_REF") {
client_print(0,print_chat,"%L",LANG_PLAYER,"RES_REF") log_amx("Vote: %L", "en", "RES_REF")
client_print(0, print_chat, "%L", LANG_PLAYER, "RES_REF")
} }
public actionResult(id,key) { public actionResult(id, key)
remove_task( 4545454 ) {
switch (key) { remove_task(4545454)
case 0: {
set_task(2.0,"delayedExec",0,g_Execute,g_execLen) switch (key)
log_amx("Vote: %L","en","RES_ACCEPTED") {
client_print(0,print_chat,"%L",LANG_PLAYER,"RES_ACCEPTED") case 0:
} {
case 1: autoRefuse() set_task(2.0, "delayedExec", 0, g_Execute, g_execLen)
} log_amx("Vote: %L", "en", "RES_ACCEPTED")
return PLUGIN_HANDLED client_print(0, print_chat, "%L", LANG_PLAYER, "RES_ACCEPTED")
}
case 1: autoRefuse()
}
return PLUGIN_HANDLED
} }
public checkVotes() { public checkVotes()
new best = 0 {
if ( !g_yesNoVote ) { new best = 0
for (new a = 0; a < 4; ++a)
if (g_voteCount[a] > g_voteCount[best]) if (!g_yesNoVote)
best = a {
} for (new a = 0; a < 4; ++a)
new votesNum = g_voteCount[0] + g_voteCount[1] + g_voteCount[2] + g_voteCount[3] if (g_voteCount[a] > g_voteCount[best])
new iRatio = votesNum ? floatround( g_voteRatio * float( votesNum ) ,floatround_ceil) : 1
new iResult = g_voteCount[best] best = a
new players[32],pnum,i }
get_players(players,pnum,"c")
if ( iResult < iRatio ) { new votesNum = g_voteCount[0] + g_voteCount[1] + g_voteCount[2] + g_voteCount[3]
new lVotingFailed[64] new iRatio = votesNum ? floatround(g_voteRatio * float(votesNum), floatround_ceil) : 1
for (i=0;i<pnum;i++) { new iResult = g_voteCount[best]
format(lVotingFailed,63,"%L",players[i],"VOTING_FAILED") new players[32], pnum, i
if (g_yesNoVote)
client_print(players[i],print_chat,"%L",players[i],"VOTING_RES_1", get_players(players, pnum, "c")
lVotingFailed,g_voteCount[0],g_voteCount[1],iRatio)
else if (iResult < iRatio)
client_print(players[i],print_chat,"%L",players[i],"VOTING_RES_2",lVotingFailed,iResult,iRatio ) {
} new lVotingFailed[64]
format(lVotingFailed,63,"%L","en","VOTING_FAILED")
log_amx("Vote: %s (got ^"%d^") (needed ^"%d^")",lVotingFailed,iResult,iRatio) for (i = 0; i < pnum; i++)
return PLUGIN_CONTINUE {
} format(lVotingFailed, 63, "%L", players[i], "VOTING_FAILED")
g_execLen = format(g_Execute,255,g_Answer,g_optionName[best]) + 1 if (g_yesNoVote)
if (g_execResult) { client_print(players[i], print_chat, "%L", players[i], "VOTING_RES_1", lVotingFailed, g_voteCount[0], g_voteCount[1], iRatio)
g_execResult = false else
if ( is_user_connected(g_voteCaller) ) { client_print(players[i], print_chat, "%L", players[i], "VOTING_RES_2", lVotingFailed, iResult, iRatio)
new menuBody[512],lTheResult[32],lYes[16],lNo[16] }
format(lTheResult,31,"%L",g_voteCaller,"THE_RESULT")
format(lYes,15,"%L",g_voteCaller,"YES") format(lVotingFailed, 63, "%L", "en", "VOTING_FAILED")
format(lNo,15,"%L",g_voteCaller,"NO") log_amx("Vote: %s (got ^"%d^") (needed ^"%d^")", lVotingFailed, iResult, iRatio)
new len = format(menuBody,511,g_coloredMenus ? "\y%s: \w%s^n^n" : "%s: %s^n^n", lTheResult, g_Execute )
len += format( menuBody[len] ,511 - len, g_coloredMenus ? "\y%L^n\w" : "%L^n", g_voteCaller, "WANT_CONTINUE" ) return PLUGIN_CONTINUE
format( menuBody[len] ,511 - len, "^n1. %s^n2. %s",lYes,lNo) }
show_menu( g_voteCaller ,0x03 ,menuBody, 10, "The result: " )
set_task(10.0,"autoRefuse",4545454) g_execLen = format(g_Execute, 255, g_Answer, g_optionName[best]) + 1
}
else if (g_execResult)
set_task(2.0,"delayedExec",0,g_Execute,g_execLen) {
} g_execResult = false
new lVotingSuccess[32]
for (i=0;i<pnum;i++) { if (is_user_connected(g_voteCaller))
format(lVotingSuccess,31,"%L",players[i],"VOTING_SUCCESS") {
client_print(players[i],print_chat,"%L",players[i],"VOTING_RES_3",lVotingSuccess,iResult,iRatio,g_Execute) new menuBody[512], lTheResult[32], lYes[16], lNo[16]
}
format(lVotingSuccess,31,"%L","en","VOTING_SUCCESS") format(lTheResult, 31, "%L", g_voteCaller, "THE_RESULT")
log_amx("Vote: %s (got ^"%d^") (needed ^"%d^") (result ^"%s^")", lVotingSuccess, iResult , iRatio , g_Execute ) format(lYes, 15, "%L", g_voteCaller, "YES")
return PLUGIN_CONTINUE format(lNo, 15, "%L", g_voteCaller, "NO")
new len = format(menuBody, 511, g_coloredMenus ? "\y%s: \w%s^n^n" : "%s: %s^n^n", lTheResult, g_Execute)
len += format(menuBody[len], 511 - len, g_coloredMenus ? "\y%L^n\w" : "%L^n", g_voteCaller, "WANT_CONTINUE")
format(menuBody[len], 511 - len, "^n1. %s^n2. %s", lYes, lNo)
show_menu(g_voteCaller, 0x03, menuBody, 10, "The result: ")
set_task(10.0, "autoRefuse", 4545454)
}
else
set_task(2.0, "delayedExec", 0, g_Execute, g_execLen)
}
new lVotingSuccess[32]
for (i = 0; i < pnum; i++)
{
format(lVotingSuccess, 31, "%L", players[i], "VOTING_SUCCESS")
client_print(players[i], print_chat, "%L", players[i], "VOTING_RES_3", lVotingSuccess, iResult, iRatio, g_Execute)
}
format(lVotingSuccess, 31, "%L", "en", "VOTING_SUCCESS")
log_amx("Vote: %s (got ^"%d^") (needed ^"%d^") (result ^"%s^")", lVotingSuccess, iResult, iRatio, g_Execute)
return PLUGIN_CONTINUE
} }
public voteCount(id,key) { public voteCount(id, key)
if ( get_cvar_num("amx_vote_answers") ) { {
new name[32] if (get_cvar_num("amx_vote_answers"))
get_user_name(id,name,31) {
if (g_yesNoVote) new name[32]
client_print(0,print_chat,"%L",LANG_PLAYER,key ? "VOTED_AGAINST" : "VOTED_FOR",name) get_user_name(id, name, 31)
else
client_print(0,print_chat,"%L",LANG_PLAYER,"VOTED_FOR_OPT",name,key+1) if (g_yesNoVote)
} client_print(0, print_chat, "%L", LANG_PLAYER, key ? "VOTED_AGAINST" : "VOTED_FOR", name)
++g_voteCount[key] else
return PLUGIN_HANDLED client_print(0, print_chat, "%L", LANG_PLAYER, "VOTED_FOR_OPT", name, key + 1)
}
++g_voteCount[key]
return PLUGIN_HANDLED
} }
public cmdVoteMap(id,level,cid) { public cmdVoteMap(id, level, cid)
if (!cmd_access(id,level,cid,2)) {
return PLUGIN_HANDLED if (!cmd_access(id, level, cid, 2))
new Float:voting = get_cvar_float("amx_last_voting") return PLUGIN_HANDLED
if (voting > get_gametime()) {
console_print(id, "%L", id, "ALREADY_VOTING") new Float:voting = get_cvar_float("amx_last_voting")
return PLUGIN_HANDLED if (voting > get_gametime())
} {
if (voting && voting + get_cvar_float("amx_vote_delay") > get_gametime()) { console_print(id, "%L", id, "ALREADY_VOTING")
console_print(id, "%L", id, "VOTING_NOT_ALLOW") return PLUGIN_HANDLED
return PLUGIN_HANDLED }
}
new argc = read_argc() if (voting && voting + get_cvar_float("amx_vote_delay") > get_gametime())
if (argc > 5) argc = 5 {
g_validMaps = 0 console_print(id, "%L", id, "VOTING_NOT_ALLOW")
g_optionName[0][0] = 0 return PLUGIN_HANDLED
g_optionName[1][0] = 0 }
g_optionName[2][0] = 0
g_optionName[3][0] = 0
for (new i = 1; i < argc; ++i) {
read_argv(i,g_optionName[g_validMaps],31)
if (is_map_valid(g_optionName[g_validMaps]))
g_validMaps++
}
if (g_validMaps == 0) {
new lMaps[16]
format(lMaps,15,"%L",id,(argc==2)?"MAP_IS":"MAPS_ARE")
console_print(id,"%L",id,"GIVEN_NOT_VALID",lMaps)
return PLUGIN_HANDLED
}
new menu_msg[256], len = 0
new keys = 0
if (g_validMaps > 1) {
keys = MENU_KEY_0
len = format(menu_msg,255,g_coloredMenus ? "\y%L: \w^n^n" : "%L: ^n^n",LANG_SERVER,"CHOOSE_MAP")
new temp[128]
for (new a = 0; a < g_validMaps; ++a) {
format(temp,127,"%d. %s^n",a+1,g_optionName[a])
len += copy(menu_msg[len],255-len,temp)
keys |= (1<<a)
}
format(menu_msg[len],255-len,"^n0. %L",LANG_SERVER,"NONE")
g_yesNoVote = 0
}
else {
new lChangeMap[32],lYes[16],lNo[16]
format(lChangeMap,31,"%L",LANG_SERVER,"CHANGE_MAP_TO")
format(lYes,15,"%L",LANG_SERVER,"YES")
format(lNo,15,"%L",LANG_SERVER,"NO")
format(menu_msg,255,g_coloredMenus ? "\y%s %s?\w^n^n1. %s^n2. %s"
: "%s %s?^n^n1. %s^n2. %s",lChangeMap,g_optionName[0],lYes,lNo)
keys = MENU_KEY_1|MENU_KEY_2
g_yesNoVote = 1
}
new authid[32],name[32]
get_user_authid(id,authid,31)
get_user_name(id,name,31)
if (argc==2)
log_amx("Vote: ^"%s<%d><%s><>^" vote map (map ^"%s^")",
name,get_user_userid(id),authid,g_optionName[0])
else
log_amx("Vote: ^"%s<%d><%s><>^" vote maps (map#1 ^"%s^") (map#2 ^"%s^") (map#3 ^"%s^") (map#4 ^"%s^")",
name,get_user_userid(id),authid,g_optionName[0],g_optionName[1],g_optionName[2],g_optionName[3])
new lTag[16],activity = get_cvar_num("amx_show_activity") new argc = read_argc()
if (activity>0) { if (argc > 5) argc = 5
new players[32],pnum
get_players(players,pnum,"c") g_validMaps = 0
for (new i=0;i<pnum;i++) { g_optionName[0][0] = 0
format(lTag,15,"%L",players[i],is_user_admin(id)?"ADMIN":"PLAYER") g_optionName[1][0] = 0
switch (activity) { g_optionName[2][0] = 0
case 2: client_print(players[i],print_chat,"%L", g_optionName[3][0] = 0
players[i],"ADMIN_VOTE_MAP_2",lTag,name)
case 1: client_print(players[i],print_chat,"%L", for (new i = 1; i < argc; ++i)
players[i],"ADMIN_VOTE_MAP_1",lTag) {
} read_argv(i, g_optionName[g_validMaps], 31)
}
} if (is_map_valid(g_optionName[g_validMaps]))
g_validMaps++
}
if (g_validMaps == 0)
{
new lMaps[16]
format(lMaps, 15, "%L", id, (argc == 2) ? "MAP_IS" : "MAPS_ARE")
console_print(id, "%L", id, "GIVEN_NOT_VALID", lMaps)
return PLUGIN_HANDLED
}
g_execResult = true new menu_msg[256], len = 0
new Float:vote_time = get_cvar_float("amx_vote_time") + 2.0 new keys = 0
set_cvar_float("amx_last_voting", get_gametime() + vote_time )
g_voteRatio = get_cvar_float("amx_votemap_ratio") if (g_validMaps > 1)
g_Answer = "changelevel %s" {
show_menu(0,keys,menu_msg,floatround(vote_time),(g_validMaps > 1)?"Choose map: ":"Change map to ") keys = MENU_KEY_0
set_task(vote_time,"checkVotes" , 99889988 ) len = format(menu_msg, 255, g_coloredMenus ? "\y%L: \w^n^n" : "%L: ^n^n", LANG_SERVER, "CHOOSE_MAP")
g_voteCaller = id new temp[128]
console_print(id, "%L", id, "VOTING_STARTED")
g_voteCount = { 0,0, 0,0 } for (new a = 0; a < g_validMaps; ++a)
return PLUGIN_HANDLED {
format(temp, 127, "%d. %s^n", a+1, g_optionName[a])
len += copy(menu_msg[len], 255-len, temp)
keys |= (1<<a)
}
format(menu_msg[len], 255-len, "^n0. %L", LANG_SERVER, "NONE")
g_yesNoVote = 0
} else {
new lChangeMap[32], lYes[16], lNo[16]
format(lChangeMap, 31, "%L", LANG_SERVER, "CHANGE_MAP_TO")
format(lYes, 15, "%L", LANG_SERVER, "YES")
format(lNo, 15, "%L", LANG_SERVER, "NO")
format(menu_msg, 255, g_coloredMenus ? "\y%s %s?\w^n^n1. %s^n2. %s" : "%s %s?^n^n1. %s^n2. %s", lChangeMap, g_optionName[0], lYes, lNo)
keys = MENU_KEY_1|MENU_KEY_2
g_yesNoVote = 1
}
new authid[32], name[32]
get_user_authid(id, authid, 31)
get_user_name(id, name, 31)
if (argc == 2)
log_amx("Vote: ^"%s<%d><%s><>^" vote map (map ^"%s^")", name, get_user_userid(id), authid, g_optionName[0])
else
log_amx("Vote: ^"%s<%d><%s><>^" vote maps (map#1 ^"%s^") (map#2 ^"%s^") (map#3 ^"%s^") (map#4 ^"%s^")", name, get_user_userid(id), authid, g_optionName[0], g_optionName[1], g_optionName[2], g_optionName[3])
new lTag[16], activity = get_cvar_num("amx_show_activity")
if (activity > 0)
{
new players[32], pnum
get_players(players, pnum, "c")
for (new i = 0; i < pnum; i++)
{
format(lTag, 15, "%L", players[i], is_user_admin(id) ? "ADMIN" : "PLAYER")
switch (activity)
{
case 2: client_print(players[i], print_chat, "%L", players[i], "ADMIN_VOTE_MAP_2", lTag, name)
case 1: client_print(players[i], print_chat, "%L", players[i], "ADMIN_VOTE_MAP_1", lTag)
}
}
}
g_execResult = true
new Float:vote_time = get_cvar_float("amx_vote_time") + 2.0
set_cvar_float("amx_last_voting", get_gametime() + vote_time)
g_voteRatio = get_cvar_float("amx_votemap_ratio")
g_Answer = "changelevel %s"
show_menu(0, keys, menu_msg, floatround(vote_time), (g_validMaps > 1) ? "Choose map: " : "Change map to ")
set_task(vote_time, "checkVotes", 99889988)
g_voteCaller = id
console_print(id, "%L", id, "VOTING_STARTED")
g_voteCount = {0, 0, 0, 0}
return PLUGIN_HANDLED
} }
public cmdVote(id,level,cid) { public cmdVote(id, level, cid)
if (!cmd_access(id,level,cid,4)) {
return PLUGIN_HANDLED if (!cmd_access(id, level, cid, 4))
new Float:voting = get_cvar_float("amx_last_voting") return PLUGIN_HANDLED
if (voting > get_gametime()) {
console_print(id, "%L", id, "ALREADY_VOTING") new Float:voting = get_cvar_float("amx_last_voting")
return PLUGIN_HANDLED if (voting > get_gametime())
} {
if (voting && voting + get_cvar_float("amx_vote_delay") > get_gametime()) { console_print(id, "%L", id, "ALREADY_VOTING")
console_print(id, "%L", id, "VOTING_NOT_ALLOW") return PLUGIN_HANDLED
return PLUGIN_HANDLED }
}
new quest[48] if (voting && voting + get_cvar_float("amx_vote_delay") > get_gametime())
read_argv(1,quest,47) {
if ((contain(quest,"sv_password")!=-1)||(contain(quest,"rcon_password")!=-1)|| console_print(id, "%L", id, "VOTING_NOT_ALLOW")
(contain(quest,"kick")!=-1)||(contain(quest,"addip")!=-1)||(contain(quest,"ban")!=-1)) return PLUGIN_HANDLED
{ }
console_print(id,"%L",id,"VOTING_FORBIDDEN")
return PLUGIN_HANDLED
}
read_argv(2,g_optionName[0],31)
read_argv(3,g_optionName[1],31)
new authid[32],name[32] new quest[48]
get_user_authid(id,authid,31) read_argv(1, quest, 47)
get_user_name(id,name,31)
log_amx("Vote: ^"%s<%d><%s><>^" vote custom (question ^"%s^") (option#1 ^"%s^") (option#2 ^"%s^")", if ((contain(quest, "sv_password") != -1) || (contain(quest, "rcon_password") != -1) || (contain(quest, "kick") != -1) ||
name,get_user_userid(id),authid,quest,g_optionName[0],g_optionName[1]) (contain(quest, "addip") != -1) || (contain(quest, "ban") != -1))
{
console_print(id, "%L", id, "VOTING_FORBIDDEN")
return PLUGIN_HANDLED
}
read_argv(2, g_optionName[0], 31)
read_argv(3, g_optionName[1], 31)
new activity = get_cvar_num("amx_show_activity") new authid[32], name[32]
if (activity>0) {
new players[32],pnum,lTag[16] get_user_authid(id, authid, 31)
get_players(players,pnum,"c") get_user_name(id, name, 31)
for (new i=0;i<pnum;i++) { log_amx("Vote: ^"%s<%d><%s><>^" vote custom (question ^"%s^") (option#1 ^"%s^") (option#2 ^"%s^")", name, get_user_userid(id), authid, quest, g_optionName[0], g_optionName[1])
format(lTag,15,"%L",players[i],is_user_admin(id)?"ADMIN":"PLAYER")
switch (activity) {
case 2: client_print(players[i],print_chat,"%L",players[i],"ADMIN_VOTE_CUS_2",lTag,name)
case 1: client_print(players[i],print_chat,"%L",players[i],"ADMIN_VOTE_CUS_1",lTag)
}
}
}
new menu_msg[256],lVote[16] new activity = get_cvar_num("amx_show_activity")
format(lVote,15,"%L",LANG_SERVER,"VOTE")
new keys = MENU_KEY_1|MENU_KEY_2 if (activity > 0)
format(menu_msg,255, g_coloredMenus ? "\y%s: %s\w^n^n1. %s^n2. %s" {
: "%s: %s^n^n1. %s^n2. %s",lVote,quest,g_optionName[0],g_optionName[1]) new players[32], pnum, lTag[16]
g_execResult = false
new Float:vote_time = get_cvar_float("amx_vote_time") + 2.0 get_players(players, pnum, "c")
set_cvar_float("amx_last_voting", get_gametime() + vote_time ) for (new i = 0; i < pnum; i++)
g_voteRatio = get_cvar_float("amx_vote_ratio") {
format(g_Answer,127,"%s - %%s",quest) format(lTag, 15, "%L", players[i], is_user_admin(id) ? "ADMIN" : "PLAYER")
show_menu(0,keys,menu_msg,floatround(vote_time),"Vote: ")
set_task(vote_time,"checkVotes" , 99889988 ) switch (activity)
g_voteCaller = id {
console_print(id, "%L", id, "VOTING_STARTED") case 2: client_print(players[i], print_chat, "%L", players[i], "ADMIN_VOTE_CUS_2", lTag, name)
g_voteCount = {0,0,0,0} case 1: client_print(players[i], print_chat, "%L", players[i], "ADMIN_VOTE_CUS_1", lTag)
g_yesNoVote = 0 }
return PLUGIN_HANDLED }
}
new menu_msg[256], lVote[16]
format(lVote, 15, "%L", LANG_SERVER, "VOTE")
new keys = MENU_KEY_1|MENU_KEY_2
format(menu_msg, 255, g_coloredMenus ? "\y%s: %s\w^n^n1. %s^n2. %s" : "%s: %s^n^n1. %s^n2. %s", lVote, quest, g_optionName[0], g_optionName[1])
g_execResult = false
new Float:vote_time = get_cvar_float("amx_vote_time") + 2.0
set_cvar_float("amx_last_voting", get_gametime() + vote_time)
g_voteRatio = get_cvar_float("amx_vote_ratio")
format(g_Answer, 127, "%s - %%s", quest)
show_menu(0, keys, menu_msg, floatround(vote_time), "Vote: ")
set_task(vote_time, "checkVotes", 99889988)
g_voteCaller = id
console_print(id, "%L", id, "VOTING_STARTED")
g_voteCount = {0, 0, 0, 0}
g_yesNoVote = 0
return PLUGIN_HANDLED
} }
public cmdVoteKickBan(id,level,cid) { public cmdVoteKickBan(id, level, cid)
if (!cmd_access(id,level,cid,2)) {
return PLUGIN_HANDLED if (!cmd_access(id, level, cid, 2))
new Float:voting = get_cvar_float("amx_last_voting") return PLUGIN_HANDLED
if (voting > get_gametime()) {
console_print(id, "%L", id, "ALREADY_VOTING") new Float:voting = get_cvar_float("amx_last_voting")
return PLUGIN_HANDLED if (voting > get_gametime())
} {
if (voting && voting + get_cvar_float("amx_vote_delay") > get_gametime()) { console_print(id, "%L", id, "ALREADY_VOTING")
console_print(id, "%L", id, "VOTING_NOT_ALLOW") return PLUGIN_HANDLED
return PLUGIN_HANDLED }
}
new cmd[32]
read_argv(0,cmd,31)
new voteban = equal(cmd,"amx_voteban")
new arg[32]
read_argv(1,arg,31)
new player = cmd_target(id,arg,1)
if (!player) return PLUGIN_HANDLED
if (voteban && is_user_bot(player)) {
new imname[32]
get_user_name(player,imname,31)
console_print(id,"%L",id,"ACTION_PERFORMED",imname)
return PLUGIN_HANDLED
}
new keys = MENU_KEY_1|MENU_KEY_2 if (voting && voting + get_cvar_float("amx_vote_delay") > get_gametime())
new menu_msg[256],lYes[16],lNo[16],lKickBan[16] {
format(lYes,15,"%L",LANG_SERVER,"YES") console_print(id, "%L", id, "VOTING_NOT_ALLOW")
format(lNo,15,"%L",LANG_SERVER,"NO") return PLUGIN_HANDLED
format(lKickBan,15,"%L",LANG_SERVER,voteban?"BAN":"KICK") }
ucfirst(lKickBan)
get_user_name(player,arg,31)
format(menu_msg,255,g_coloredMenus ?
"\y%s %s?\w^n^n1. %s^n2. %s" :
"%s %s?^n^n1. %s^n2. %s",
lKickBan, arg, lYes, lNo)
g_yesNoVote = 1
if (voteban)
get_user_authid(player,g_optionName[0],31)
else
num_to_str(get_user_userid(player),g_optionName[0],31)
new authid[32],name[32]
get_user_authid(id,authid,31)
get_user_name(id,name,31)
log_amx("Vote: ^"%s<%d><%s><>^" vote %s (target ^"%s^")",
name,get_user_userid(id),authid,voteban ? "ban" : "kick",arg)
new activity = get_cvar_num("amx_show_activity") new cmd[32]
if (activity>0) {
new players[32],pnum,lTag[16] read_argv(0, cmd, 31)
get_players(players,pnum,"c")
for (new i=0;i<pnum;i++) { new voteban = equal(cmd, "amx_voteban")
format(lTag,15,"%L",players[i],is_user_admin(id)?"ADMIN":"USER") new arg[32]
format(lKickBan,15,"%L",players[i],voteban?"BAN":"KICK") read_argv(1, arg, 31)
switch (activity) {
case 2: client_print(players[i],print_chat,"%L", new player = cmd_target(id, arg, 1)
players[i],"ADMIN_VOTE_FOR_2",lTag,name,lKickBan,arg)
case 1: client_print(players[i],print_chat,"%L", if (!player)
players[i],"ADMIN_VOTE_FOR_1",lTag,lKickBan,arg) return PLUGIN_HANDLED
}
} if (voteban && is_user_bot(player))
} {
new imname[32]
get_user_name(player, imname, 31)
console_print(id, "%L", id, "ACTION_PERFORMED", imname)
return PLUGIN_HANDLED
}
g_execResult = true new keys = MENU_KEY_1|MENU_KEY_2
new Float:vote_time = get_cvar_float("amx_vote_time") + 2.0 new menu_msg[256], lYes[16], lNo[16], lKickBan[16]
set_cvar_float("amx_last_voting", get_gametime() + vote_time )
g_voteRatio = get_cvar_float(voteban ? "amx_voteban_ratio" : "amx_votekick_ratio") format(lYes, 15, "%L", LANG_SERVER, "YES")
g_Answer = voteban ? "banid 30.0 %s kick" : "kick #%s" format(lNo, 15, "%L", LANG_SERVER, "NO")
show_menu(0,keys,menu_msg,floatround(vote_time),voteban?"Ban ":"Kick ") format(lKickBan, 15, "%L", LANG_SERVER, voteban ? "BAN" : "KICK")
set_task(vote_time,"checkVotes" , 99889988 ) ucfirst(lKickBan)
g_voteCaller = id get_user_name(player, arg, 31)
console_print(id, "%L", id, "VOTING_STARTED") format(menu_msg, 255, g_coloredMenus ? "\y%s %s?\w^n^n1. %s^n2. %s" : "%s %s?^n^n1. %s^n2. %s", lKickBan, arg, lYes, lNo)
g_voteCount = {0,0,0,0} g_yesNoVote = 1
return PLUGIN_HANDLED
if (voteban)
get_user_authid(player, g_optionName[0], 31)
else
num_to_str(get_user_userid(player), g_optionName[0], 31)
new authid[32], name[32]
get_user_authid(id, authid, 31)
get_user_name(id, name, 31)
log_amx("Vote: ^"%s<%d><%s><>^" vote %s (target ^"%s^")", name, get_user_userid(id), authid, voteban ? "ban" : "kick", arg)
new activity = get_cvar_num("amx_show_activity")
if (activity > 0)
{
new players[32], pnum, lTag[16]
get_players(players, pnum, "c")
for (new i = 0; i < pnum; i++)
{
format(lTag, 15, "%L", players[i], is_user_admin(id) ? "ADMIN" : "USER")
format(lKickBan, 15, "%L", players[i], voteban ? "BAN" : "KICK")
switch (activity)
{
case 2: client_print(players[i], print_chat, "%L", players[i], "ADMIN_VOTE_FOR_2", lTag, name, lKickBan, arg)
case 1: client_print(players[i], print_chat, "%L", players[i], "ADMIN_VOTE_FOR_1", lTag, lKickBan, arg)
}
}
}
g_execResult = true
new Float:vote_time = get_cvar_float("amx_vote_time") + 2.0
set_cvar_float("amx_last_voting", get_gametime() + vote_time)
g_voteRatio = get_cvar_float(voteban ? "amx_voteban_ratio" : "amx_votekick_ratio")
g_Answer = voteban ? "banid 30.0 %s kick" : "kick #%s"
show_menu(0, keys, menu_msg, floatround(vote_time), voteban ? "Ban " : "Kick ")
set_task(vote_time, "checkVotes", 99889988)
g_voteCaller = id
console_print(id, "%L", id, "VOTING_STARTED")
g_voteCount = {0, 0, 0, 0}
return PLUGIN_HANDLED
} }

View File

@ -37,35 +37,40 @@
new Float:g_Flooding[33] = {0.0, ...} new Float:g_Flooding[33] = {0.0, ...}
new g_Flood[33] = {0, ...} new g_Flood[33] = {0, ...}
public plugin_init() { public plugin_init()
register_plugin("Anti Flood",AMXX_VERSION_STR,"AMXX Dev Team") {
register_dictionary("antiflood.txt") register_plugin("Anti Flood", AMXX_VERSION_STR, "AMXX Dev Team")
register_clcmd("say","chkFlood") register_dictionary("antiflood.txt")
register_clcmd("say_team","chkFlood") register_clcmd("say", "chkFlood")
register_cvar("amx_flood_time","0.75") register_clcmd("say_team", "chkFlood")
register_cvar("amx_flood_time", "0.75")
} }
public chkFlood(id) { public chkFlood(id)
new Float:maxChat = get_cvar_float("amx_flood_time") {
new Float:maxChat = get_cvar_float("amx_flood_time")
if ( maxChat ) { if (maxChat)
new Float:nexTime = get_gametime() {
new Float:nexTime = get_gametime()
if (g_Flooding[id] > nexTime)
{
if (g_Flood[id] >= 3)
{
client_print(id, print_notify, "** %L **", id, "STOP_FLOOD")
g_Flooding[id] = nexTime + maxChat + 3.0
return PLUGIN_HANDLED
}
g_Flood[id]++
}
else if (g_Flood[id])
{
g_Flood[id]--
}
g_Flooding[id] = nexTime + maxChat
}
if ( g_Flooding[id] > nexTime ) { return PLUGIN_CONTINUE
if (g_Flood[id] >= 3) { }
client_print( id , print_notify , "** %L **", id, "STOP_FLOOD" )
g_Flooding[ id ] = nexTime + maxChat + 3.0
return PLUGIN_HANDLED
}
g_Flood[id]++
}
else {
if (g_Flood[id])
g_Flood[id]--
}
g_Flooding[id] = nexTime + maxChat
}
return PLUGIN_CONTINUE
}

View File

@ -39,28 +39,32 @@
#define MAX_CMDS_LAYERS 3 #define MAX_CMDS_LAYERS 3
new g_cmdMenuName[ MAX_CMDS_LAYERS ][] = { new g_cmdMenuName[MAX_CMDS_LAYERS][] =
"CMD_MENU", {
"CONF_MENU", "CMD_MENU",
"SPE_MENU" "CONF_MENU",
"SPE_MENU"
} }
new g_cmdMenuCmd[ MAX_CMDS_LAYERS ][] = { new g_cmdMenuCmd[MAX_CMDS_LAYERS][] =
"amx_cmdmenu", {
"amx_cfgmenu", "amx_cmdmenu",
"amx_speechmenu" "amx_cfgmenu",
"amx_speechmenu"
} }
new g_cmdMenuCfg[ MAX_CMDS_LAYERS ][] = { new g_cmdMenuCfg[MAX_CMDS_LAYERS][] =
"cmds.ini", {
"configs.ini", "cmds.ini",
"speech.ini" "configs.ini",
"speech.ini"
} }
new g_cmdMenuHelp[ MAX_CMDS_LAYERS ][] = { new g_cmdMenuHelp[MAX_CMDS_LAYERS][] =
"- displays commands menu", {
"- displays configs menu", "- displays commands menu",
"- displays speech menu" "- displays configs menu",
"- displays speech menu"
} }
/* End of Commands Menu */ /* End of Commands Menu */
@ -86,298 +90,325 @@ new g_menuLayer[33]
new g_coloredMenus new g_coloredMenus
public plugin_init() { public plugin_init()
register_plugin("Commands Menu",AMXX_VERSION_STR,"AMXX Dev Team") {
register_dictionary("cmdmenu.txt") register_plugin("Commands Menu", AMXX_VERSION_STR, "AMXX Dev Team")
register_dictionary("common.txt") register_dictionary("cmdmenu.txt")
register_dictionary("common.txt")
new configsDir[64],config[64] new configsDir[64], config[64]
get_configsdir(configsDir, 63) get_configsdir(configsDir, 63)
for (new a = 0; a < MAX_CMDS_LAYERS; ++a) {
new MenuName[64] for (new a = 0; a < MAX_CMDS_LAYERS; ++a)
format(MenuName,63,"%L","en",g_cmdMenuName[a]) {
register_menucmd(register_menuid( MenuName ),1023,"actionCmdMenu") new MenuName[64]
register_clcmd( g_cmdMenuCmd[ a ] ,"cmdCmdMenu",ADMIN_MENU, g_cmdMenuHelp[ a ] )
format(config,63,"%s/%s",configsDir,g_cmdMenuCfg[a]) format(MenuName, 63, "%L", "en", g_cmdMenuName[a])
loadCmdSettings(config,a) register_menucmd(register_menuid(MenuName), 1023, "actionCmdMenu")
} register_clcmd(g_cmdMenuCmd[a], "cmdCmdMenu", ADMIN_MENU, g_cmdMenuHelp[a])
format(config, 63, "%s/%s", configsDir, g_cmdMenuCfg[a])
loadCmdSettings(config, a)
}
register_menucmd(register_menuid("Cvars Menu"),1023,"actionCvarMenu") register_menucmd(register_menuid("Cvars Menu"), 1023, "actionCvarMenu")
register_clcmd("amx_cvarmenu","cmdCvarMenu",ADMIN_CVAR,"- displays cvars menu") register_clcmd("amx_cvarmenu", "cmdCvarMenu", ADMIN_CVAR, "- displays cvars menu")
new cvars_ini_file[64]; new cvars_ini_file[64];
format(cvars_ini_file, 63, "%s/%s", configsDir, "cvars.ini"); format(cvars_ini_file, 63, "%s/%s", configsDir, "cvars.ini");
loadCvarSettings(cvars_ini_file) loadCvarSettings(cvars_ini_file)
g_coloredMenus = colored_menus() g_coloredMenus = colored_menus()
} }
/* Commands menu */ /* Commands menu */
public actionCmdMenu(id,key) { public actionCmdMenu(id, key)
switch (key) { {
case 8: displayCmdMenu(id,++g_menuPosition[id]) switch (key)
case 9: displayCmdMenu(id,--g_menuPosition[id]) {
default:{ case 8: displayCmdMenu(id, ++g_menuPosition[id])
new option = g_menuSelect[ id ][ g_menuPosition[id] * 8 + key ] case 9: displayCmdMenu(id, --g_menuPosition[id])
new flags = g_cmdMisc[ option ][ 1 ] default:
if ( flags & 1) {
server_cmd( g_cmdCmd[ option ] ) new option = g_menuSelect[id][g_menuPosition[id] * 8 + key]
else if ( flags & 2) new flags = g_cmdMisc[option][1]
client_cmd(id, g_cmdCmd[ option ] )
else if ( flags & 4) if (flags & 1)
client_cmd(0, g_cmdCmd[ option ] ) server_cmd(g_cmdCmd[option])
if ( flags & 8 ) displayCmdMenu(id,g_menuPosition[id]) else if (flags & 2)
} client_cmd(id, g_cmdCmd[option])
} else if (flags & 4)
return PLUGIN_HANDLED client_cmd(0, g_cmdCmd[option])
if (flags & 8)
displayCmdMenu(id, g_menuPosition[id])
}
}
return PLUGIN_HANDLED
} }
displayCmdMenu(id, pos)
{
if (pos < 0)
return
displayCmdMenu(id,pos) { new menuBody[512]
if (pos < 0) return new b = 0
new start = pos * 8
new menuBody[512]
new b = 0 if (start >= g_menuSelectNum[id])
new start = pos * 8 start = pos = g_menuPosition[id] = 0
if (start >= g_menuSelectNum[id]) new len = format(menuBody, 511, g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%L %d/%d^n^n", id, g_cmdMenuName[g_menuLayer[id]], pos + 1, (g_menuSelectNum[id] / 8 + ((g_menuSelectNum[id] % 8) ? 1 : 0)))
start = pos = g_menuPosition[id] = 0 new end = start + 8
new keys = MENU_KEY_0
new len = format(menuBody,511,g_coloredMenus ?
"\y%L\R%d/%d^n\w^n" : "%L %d/%d^n^n" , id, g_cmdMenuName[ g_menuLayer[id] ], if (end > g_menuSelectNum[id])
pos+1,( g_menuSelectNum[id] / 8 + ((g_menuSelectNum[id] % 8) ? 1 : 0 )) ) end = g_menuSelectNum[id]
new end = start + 8 for (new a = start; a < end; ++a)
new keys = MENU_KEY_0 {
if (g_cmdCmd[g_menuSelect[id][a]][0] == '-')
if (end > g_menuSelectNum[id]) {
end = g_menuSelectNum[id] if (g_coloredMenus)
len += format(menuBody[len], 511-len, "\d%s^n\w", g_cmdName[g_menuSelect[id][a]])
for(new a = start; a < end; ++a) { else
if ( g_cmdCmd[ g_menuSelect[id][ a ] ][0] == '-' ) { len += format(menuBody[len], 511-len, "%s^n", g_cmdName[g_menuSelect[id][a]])
if ( g_coloredMenus ) ++b
len += format(menuBody[len],511-len,"\d%s^n\w",g_cmdName[ g_menuSelect[id][ a ] ] ) } else {
else keys |= (1<<b)
len += format(menuBody[len],511-len,"%s^n",g_cmdName[ g_menuSelect[id][ a ] ] ) len += format(menuBody[len], 511-len, "%d. %s^n", ++b, g_cmdName[g_menuSelect[id][a]])
++b }
} }
else {
keys |= (1<<b) if (end != g_menuSelectNum[id])
len += format(menuBody[len],511-len,"%d. %s^n",++b, g_cmdName[ g_menuSelect[id][ a ] ] ) {
} format(menuBody[len], 511-len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
} keys |= MENU_KEY_9
}
if (end != g_menuSelectNum[id]) { else
format(menuBody[len],511-len,"^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT" ) format(menuBody[len], 511-len, "^n0. %L", id, pos ? "BACK" : "EXIT")
keys |= MENU_KEY_9
} new MenuName[64]
else format(menuBody[len],511-len,"^n0. %L", id, pos ? "BACK" : "EXIT" )
new MenuName[64] format(MenuName, 63, "%L", "en", g_cmdMenuName[g_menuLayer[id]])
format(MenuName,63,"%L","en",g_cmdMenuName[g_menuLayer[id]]) show_menu(id, keys, menuBody, -1, MenuName)
show_menu(id,keys,menuBody,-1,MenuName)
} }
public cmdCmdMenu(id,level,cid) { public cmdCmdMenu(id, level, cid)
if (!cmd_access(id,level,cid,1)) return PLUGIN_HANDLED {
if (!cmd_access(id, level, cid, 1))
new szCmd[32] return PLUGIN_HANDLED
read_argv(0, szCmd, 31)
new szCmd[32]
new lvl = 0 read_argv(0, szCmd, 31)
new lvl = 0
while( lvl < MAX_CMDS_LAYERS ) {
if ( equal( g_cmdMenuCmd[ lvl ], szCmd ) ) while (lvl < MAX_CMDS_LAYERS)
break {
if (equal(g_cmdMenuCmd[lvl], szCmd))
++lvl break
} ++lvl
}
g_menuLayer[ id ] = lvl
g_menuLayer[id] = lvl
new flags = get_user_flags(id) new flags = get_user_flags(id)
g_menuSelectNum[id] = 0
g_menuSelectNum[id] = 0
new a = lvl * MAX_CMDS
new a = lvl * MAX_CMDS new d, c = 0
new d , c = 0
while (c < g_cmdNum[lvl])
while( c < g_cmdNum[ lvl ] ) { {
d = a + c d = a + c
if ( g_cmdMisc[ d ][0] & flags ) { if (g_cmdMisc[d][0] & flags)
g_menuSelect[id][ g_menuSelectNum[id]++ ] = d {
} g_menuSelect[id][g_menuSelectNum[id]++] = d
}
++c
} ++c
}
displayCmdMenu(id,g_menuPosition[id] = 0)
displayCmdMenu(id, g_menuPosition[id] = 0)
return PLUGIN_HANDLED
return PLUGIN_HANDLED
} }
loadCmdSettings(szFilename[], level)
{
if (!file_exists(szFilename))
return 0
loadCmdSettings( szFilename[], level ) { new text[256], szFlags[32], szAccess[32]
if ( !file_exists ( szFilename ) ) new a, pos = 0, c, d = level * MAX_CMDS
return 0
while (g_cmdNum[level] < MAX_CMDS && read_file(szFilename, pos++, text, 255, a))
new text[256], szFlags[32], szAccess[32] {
new a, pos = 0, c, d = level * MAX_CMDS if (text[0] == ';') continue
c = d + g_cmdNum[level]
while ( g_cmdNum[ level ] < MAX_CMDS && read_file (szFilename,pos++,text,255,a) ) {
if ( text[0] == ';' ) continue if (parse(text, g_cmdName[c], 31, g_cmdCmd[c], 63, szFlags, 31, szAccess, 31) > 3)
{
c = d + g_cmdNum[ level ] while (replace(g_cmdCmd[c], 63, "\'", "^""))
{
if ( parse( text , g_cmdName[ c ] , 31 , // do nothing
g_cmdCmd[ c ] ,63,szFlags,31,szAccess,31 ) > 3 ) { }
while ( replace( g_cmdCmd[ c ] ,63,"\'","^"") ) {
// do nothing g_cmdMisc[c][1] = read_flags(szFlags)
} g_cmdMisc[c][0] = read_flags(szAccess)
g_cmdNum[level]++
g_cmdMisc[ c ][ 1 ] = read_flags ( szFlags ) }
g_cmdMisc[ c ][ 0 ] = read_flags ( szAccess ) }
g_cmdNum[ level ]++
} return 1
}
return 1
} }
/* Cvars menu */ /* Cvars menu */
public actionCvarMenu(id,key) { public actionCvarMenu(id, key)
switch (key){ {
case 8: displayCvarMenu(id,++g_menuPosition[id]) switch (key)
case 9: displayCvarMenu(id,--g_menuPosition[id]) {
default: { case 8: displayCvarMenu(id, ++g_menuPosition[id])
new option = g_menuSelect[ id ][ g_menuPosition[id] * 8 + key ] case 9: displayCvarMenu(id, --g_menuPosition[id])
default:
new szValue[32] {
get_cvar_string( g_cvarNames[ option ], szValue ,31) new option = g_menuSelect[id][g_menuPosition[id] * 8 + key]
new szValue[32]
new end = g_cvarMisc[ option ][ 2 ]
new start = g_cvarMisc[ option ][ 1 ] get_cvar_string(g_cvarNames[option], szValue, 31)
for (new i = start ; ; ++i ) { new end = g_cvarMisc[option][2]
if ( i < end ) { new start = g_cvarMisc[option][1]
if ( equal( szValue , g_cvarCmd[ i ] ) )
{ for (new i = start; ; ++i)
if (++i >= end) {
{ if (i < end)
i = start {
} if (equal(szValue, g_cvarCmd[i]))
set_cvar_string( g_cvarNames[ option ], g_cvarCmd[ i ] ) {
break if (++i >= end)
} {
} i = start
else { }
set_cvar_string( g_cvarNames[ option ], g_cvarCmd[ start ] )
break set_cvar_string(g_cvarNames[option], g_cvarCmd[i])
} break
} }
} else {
displayCvarMenu(id, g_menuPosition[id] ) set_cvar_string(g_cvarNames[option], g_cvarCmd[start])
} break
} }
return PLUGIN_HANDLED }
displayCvarMenu(id, g_menuPosition[id])
}
}
return PLUGIN_HANDLED
} }
displayCvarMenu(id, pos)
{
if (pos < 0)
return
displayCvarMenu(id,pos) { new menuBody[512]
if (pos < 0) return new b = 0
new start = pos * 8
new menuBody[512] if (start >= g_menuSelectNum[id])
new b = 0 start = pos = g_menuPosition[id] = 0
new start = pos * 8
if (start >= g_menuSelectNum[id]) new len = format(menuBody, 511, g_coloredMenus ? "\yCvars Menu\R%d/%d^n\w^n" : "Cvars Menu %d/%d^n^n", pos + 1, (g_menuSelectNum[id] / 8 + ((g_menuSelectNum[id] % 8) ? 1 : 0)))
start = pos = g_menuPosition[id] = 0
new len = format(menuBody,511, g_coloredMenus ? new end = start + 8
"\yCvars Menu\R%d/%d^n\w^n" : "Cvars Menu %d/%d^n^n", new keys = MENU_KEY_0
pos+1,( g_menuSelectNum[id] / 8 + ((g_menuSelectNum[id] % 8) ? 1 : 0 )) ) new szValue[64]
new end = start + 8 if (end > g_menuSelectNum[id])
new keys = MENU_KEY_0 end = g_menuSelectNum[id]
new szValue[64]
if (end > g_menuSelectNum[id]) for (new a = start; a < end; ++a)
end = g_menuSelectNum[id] {
get_cvar_string(g_cvarNames[g_menuSelect[id][a]], szValue, 31)
keys |= (1<<b)
++b
if (g_coloredMenus)
len += format(menuBody[len], 511-len, "%d. %s\R%s^n\w", b, g_cvarNames[g_menuSelect[id][a]], szValue)
else
len += format(menuBody[len], 511-len, "%d. %s %s^n", b, g_cvarNames[g_menuSelect[id][a]], szValue)
}
for(new a = start; a < end; ++a) { if (end != g_menuSelectNum[id])
get_cvar_string( g_cvarNames[ g_menuSelect[id][ a ] ],szValue,31) {
keys |= (1<<b) format(menuBody[len], 511-len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
++b keys |= MENU_KEY_9
if ( g_coloredMenus ) }
len += format(menuBody[len],511-len,"%d. %s\R%s^n\w", b, g_cvarNames[ g_menuSelect[id][ a ] ], szValue ) else
else format(menuBody[len], 511-len, "^n0. %L", id, pos ? "BACK" : "EXIT")
len += format(menuBody[len],511-len,"%d. %s %s^n", b, g_cvarNames[ g_menuSelect[id][ a ] ], szValue )
} show_menu(id, keys, menuBody)
if (end != g_menuSelectNum[id]) {
format(menuBody[len],511-len,"^n9. %L...^n0. %L",id,"MORE",id,pos ? "BACK" : "EXIT")
keys |= MENU_KEY_9
}
else format(menuBody[len],511-len,"^n0. %L", id, pos ? "BACK" : "EXIT")
show_menu(id,keys,menuBody)
} }
public cmdCvarMenu(id,level,cid) { public cmdCvarMenu(id, level, cid)
if (!cmd_access(id,level,cid,1)) return PLUGIN_HANDLED {
if (!cmd_access(id, level, cid, 1))
new flags = get_user_flags(id) return PLUGIN_HANDLED
g_menuSelectNum[id] = 0 new flags = get_user_flags(id)
g_menuSelectNum[id] = 0
for(new a = 0; a < g_cvarNum; ++a)
if ( g_cvarMisc[ a ][0] & flags ) for (new a = 0; a < g_cvarNum; ++a)
g_menuSelect[id][ g_menuSelectNum[id]++ ] = a if (g_cvarMisc[a][0] & flags)
g_menuSelect[id][g_menuSelectNum[id]++] = a
displayCvarMenu(id,g_menuPosition[id] = 0)
displayCvarMenu(id, g_menuPosition[id] = 0)
return PLUGIN_HANDLED
return PLUGIN_HANDLED
} }
loadCvarSettings( szFilename[] ) { loadCvarSettings(szFilename[])
if ( !file_exists ( szFilename ) ) {
return 0 if (!file_exists(szFilename))
return 0
new text[256], szValues[12][32]
new inum , a, pos = 0
new cvar_values = MAX_CVARS * 5
// a b c d
while ( g_cvarNum < MAX_CVARS && read_file (szFilename,pos++,text,255,a) ) {
if ( text[0] == ';' ) continue
inum = parse( text , g_cvarNames[ g_cvarNum ] , 31 ,
szValues[0] ,31 , szValues[1] ,31 , szValues[2] ,31 ,
szValues[3] ,31 , szValues[4] ,31 , szValues[5] ,31 ,
szValues[6] ,31 , szValues[7] ,31 , szValues[8] ,31 ,
szValues[9] ,31 , szValues[10] ,31 , szValues[11] ,31 )
inum -= 2
if ( inum < 2 ) continue
g_cvarMisc[ g_cvarNum ][1] = g_cvarCmdNum new text[256], szValues[12][32]
new inum, a, pos = 0
for ( a = 0 ; a < inum && g_cvarCmdNum < cvar_values ; ++a ) { new cvar_values = MAX_CVARS * 5
while ( replace( szValues[ a ] ,31 , "\'" , "^"" ) ) {
// do nothing // a b c d
} while (g_cvarNum < MAX_CVARS && read_file(szFilename, pos++, text, 255, a))
{
copy ( g_cvarCmd[ g_cvarCmdNum ] , 31 , szValues[ a ] ) if (text[0] == ';') continue
g_cvarCmdNum++
} inum = parse(text, g_cvarNames[g_cvarNum], 31,
szValues[0], 31, szValues[1], 31, szValues[2], 31,
g_cvarMisc[ g_cvarNum ][2] = g_cvarCmdNum szValues[3], 31, szValues[4], 31, szValues[5], 31,
g_cvarMisc[ g_cvarNum ][0] = read_flags( szValues[ inum ] ) szValues[6], 31, szValues[7], 31, szValues[8], 31,
g_cvarNum++ szValues[9], 31, szValues[10], 31, szValues[11], 31)
} inum -= 2
if (inum < 2) continue
return 1 g_cvarMisc[g_cvarNum][1] = g_cvarCmdNum
}
for (a = 0; a < inum && g_cvarCmdNum < cvar_values; ++a)
{
while (replace(szValues[a], 31, "\'", "^""))
{
// do nothing
}
copy(g_cvarCmd[g_cvarCmdNum], 31, szValues[a])
g_cvarCmdNum++
}
g_cvarMisc[g_cvarNum][2] = g_cvarCmdNum
g_cvarMisc[g_cvarNum][0] = read_flags(szValues[inum])
g_cvarNum++
}
return 1
}

View File

@ -45,56 +45,79 @@ new g_Messages[MAX_MESSAGES][384]
new g_MessagesNum new g_MessagesNum
new g_Current new g_Current
public plugin_init() { public plugin_init()
register_plugin("Info. Messages",AMXX_VERSION_STR,"AMXX Dev Team") {
register_dictionary("imessage.txt") register_plugin("Info. Messages", AMXX_VERSION_STR, "AMXX Dev Team")
register_dictionary("common.txt") register_dictionary("imessage.txt")
register_srvcmd("amx_imessage","setMessage") register_dictionary("common.txt")
register_cvar("amx_freq_imessage","10") register_srvcmd("amx_imessage", "setMessage")
new lastinfo[8] register_cvar("amx_freq_imessage", "10")
get_localinfo("lastinfomsg",lastinfo,7)
g_Current = str_to_num(lastinfo) new lastinfo[8]
set_localinfo("lastinfomsg","") get_localinfo("lastinfomsg", lastinfo, 7)
g_Current = str_to_num(lastinfo)
set_localinfo("lastinfomsg", "")
} }
public infoMessage() { public infoMessage()
if (g_Current >= g_MessagesNum) {
g_Current = 0 if (g_Current >= g_MessagesNum)
set_hudmessage(g_Values[g_Current][0], g_Values[g_Current][1], g_Values[g_Current][2], g_Current = 0
X_POS, Y_POS, 0, 0.5, HOLD_TIME , 2.0, 2.0, 1)
show_hudmessage(0,g_Messages[g_Current]) set_hudmessage(g_Values[g_Current][0], g_Values[g_Current][1], g_Values[g_Current][2], X_POS, Y_POS, 0, 0.5, HOLD_TIME, 2.0, 2.0, 1)
client_print(0,print_console,g_Messages[g_Current]) show_hudmessage(0, g_Messages[g_Current])
++g_Current client_print(0, print_console, g_Messages[g_Current])
new Float:freq_im = get_cvar_float("amx_freq_imessage") ++g_Current
if ( freq_im > 0.0 ) set_task( freq_im ,"infoMessage",12345)
new Float:freq_im = get_cvar_float("amx_freq_imessage")
if (freq_im > 0.0)
set_task(freq_im, "infoMessage", 12345)
} }
public setMessage() { public setMessage()
if (g_MessagesNum >= MAX_MESSAGES) { {
server_print("%L",LANG_SERVER,"INF_REACH") if (g_MessagesNum >= MAX_MESSAGES)
return PLUGIN_HANDLED {
} server_print("%L", LANG_SERVER, "INF_REACH")
remove_task(12345) return PLUGIN_HANDLED
read_argv(1,g_Messages[g_MessagesNum],380) }
new hostname[64]
get_cvar_string("hostname",hostname,63) remove_task(12345)
replace(g_Messages[g_MessagesNum],380,"%hostname%",hostname) read_argv(1, g_Messages[g_MessagesNum], 380)
while(replace(g_Messages[g_MessagesNum],380,"\n","^n")){}
new mycol[12] new hostname[64]
read_argv(2,mycol,11) // RRRGGGBBB
g_Values[g_MessagesNum][2] = str_to_num(mycol[6]) get_cvar_string("hostname", hostname, 63)
mycol[6] = 0 replace(g_Messages[g_MessagesNum], 380, "%hostname%", hostname)
g_Values[g_MessagesNum][1] = str_to_num(mycol[3])
mycol[3] = 0 while (replace(g_Messages[g_MessagesNum], 380, "\n", "^n")) {}
g_Values[g_MessagesNum][0] = str_to_num(mycol[0])
g_MessagesNum++ new mycol[12]
new Float:freq_im = get_cvar_float("amx_freq_imessage")
if ( freq_im > 0.0 ) set_task( freq_im ,"infoMessage",12345) read_argv(2, mycol, 11) // RRRGGGBBB
return PLUGIN_HANDLED g_Values[g_MessagesNum][2] = str_to_num(mycol[6])
mycol[6] = 0
g_Values[g_MessagesNum][1] = str_to_num(mycol[3])
mycol[3] = 0
g_Values[g_MessagesNum][0] = str_to_num(mycol[0])
g_MessagesNum++
new Float:freq_im = get_cvar_float("amx_freq_imessage")
if (freq_im > 0.0)
set_task(freq_im, "infoMessage", 12345)
return PLUGIN_HANDLED
} }
public plugin_end() { public plugin_end()
new lastinfo[8] {
num_to_str(g_Current,lastinfo,7) new lastinfo[8]
set_localinfo("lastinfomsg",lastinfo)
} num_to_str(g_Current, lastinfo, 7)
set_localinfo("lastinfomsg", lastinfo)
}

View File

@ -42,7 +42,7 @@ new g_mapName[MAX_MAPS][32]
new g_mapNums new g_mapNums
new g_nextName[SELECTMAPS] new g_nextName[SELECTMAPS]
new g_voteCount[SELECTMAPS+2] new g_voteCount[SELECTMAPS + 2]
new g_mapVoteNum new g_mapVoteNum
new g_teamScore[2] new g_teamScore[2]
new g_lastMap[32] new g_lastMap[32]
@ -50,163 +50,204 @@ new g_lastMap[32]
new g_coloredMenus new g_coloredMenus
new bool:g_selected = false new bool:g_selected = false
public plugin_init() { public plugin_init()
register_plugin("Nextmap Chooser",AMXX_VERSION_STR,"AMXX Dev Team") {
register_dictionary("mapchooser.txt") register_plugin("Nextmap Chooser", AMXX_VERSION_STR, "AMXX Dev Team")
register_dictionary("common.txt") register_dictionary("mapchooser.txt")
new MenuName[64] register_dictionary("common.txt")
format(MenuName,63,"%L","en","CHOOSE_NEXTM")
register_menucmd(register_menuid(MenuName),(-1^(-1<<(SELECTMAPS+2))),"countVote") new MenuName[64]
register_cvar("amx_extendmap_max","90")
register_cvar("amx_extendmap_step","15") format(MenuName, 63, "%L", "en", "CHOOSE_NEXTM")
register_menucmd(register_menuid(MenuName), (-1^(-1<<(SELECTMAPS+2))), "countVote")
register_cvar("amx_extendmap_max", "90")
register_cvar("amx_extendmap_step", "15")
if ( cstrike_running() ) if (cstrike_running())
register_event("TeamScore", "team_score", "a") register_event("TeamScore", "team_score", "a")
get_localinfo("lastMap",g_lastMap,31)
set_localinfo("lastMap","")
new maps_ini_file[64] get_localinfo("lastMap", g_lastMap, 31)
get_configsdir(maps_ini_file, 63); set_localinfo("lastMap", "")
format(maps_ini_file, 63, "%s/maps.ini", maps_ini_file);
if (!file_exists(maps_ini_file))
get_cvar_string("mapcyclefile", maps_ini_file, 63)
if ( loadSettings(maps_ini_file) )
set_task(15.0,"voteNextmap",987456,"",0,"b")
g_coloredMenus = colored_menus() new maps_ini_file[64]
get_configsdir(maps_ini_file, 63);
format(maps_ini_file, 63, "%s/maps.ini", maps_ini_file);
if (!file_exists(maps_ini_file))
get_cvar_string("mapcyclefile", maps_ini_file, 63)
if (loadSettings(maps_ini_file))
set_task(15.0, "voteNextmap", 987456, "", 0, "b")
g_coloredMenus = colored_menus()
} }
public checkVotes() { public checkVotes()
new b = 0 {
for (new a = 0; a < g_mapVoteNum; ++a) new b = 0
if (g_voteCount[b] < g_voteCount[a])
b = a for (new a = 0; a < g_mapVoteNum; ++a)
if ( g_voteCount[SELECTMAPS] > g_voteCount[b] ) { if (g_voteCount[b] < g_voteCount[a])
new mapname[32] b = a
get_mapname(mapname,31)
new Float:steptime = get_cvar_float("amx_extendmap_step") if (g_voteCount[SELECTMAPS] > g_voteCount[b])
set_cvar_float("mp_timelimit", get_cvar_float("mp_timelimit") + steptime ) {
client_print(0,print_chat,"%L", LANG_PLAYER, "CHO_FIN_EXT", steptime ) new mapname[32]
log_amx("Vote: Voting for the nextmap finished. Map %s will be extended to next %.0f minutes",
mapname , steptime ) get_mapname(mapname, 31)
return new Float:steptime = get_cvar_float("amx_extendmap_step")
} set_cvar_float("mp_timelimit", get_cvar_float("mp_timelimit") + steptime)
if ( g_voteCount[b] && g_voteCount[SELECTMAPS+1] <= g_voteCount[b] ) client_print(0, print_chat, "%L", LANG_PLAYER, "CHO_FIN_EXT", steptime)
set_cvar_string("amx_nextmap", g_mapName[g_nextName[b]] ) log_amx("Vote: Voting for the nextmap finished. Map %s will be extended to next %.0f minutes", mapname, steptime)
new smap[32]
get_cvar_string("amx_nextmap",smap,31) return
client_print(0,print_chat,"%L", LANG_PLAYER, "CHO_FIN_NEXT", smap ) }
log_amx("Vote: Voting for the nextmap finished. The nextmap will be %s", smap)
if (g_voteCount[b] && g_voteCount[SELECTMAPS + 1] <= g_voteCount[b])
set_cvar_string("amx_nextmap", g_mapName[g_nextName[b]])
new smap[32]
get_cvar_string("amx_nextmap", smap, 31)
client_print(0, print_chat, "%L", LANG_PLAYER, "CHO_FIN_NEXT", smap)
log_amx("Vote: Voting for the nextmap finished. The nextmap will be %s", smap)
} }
public countVote(id,key) { public countVote(id, key)
if ( get_cvar_float("amx_vote_answers") ) { {
new name[32] if (get_cvar_float("amx_vote_answers"))
get_user_name(id,name,31) {
if ( key == SELECTMAPS ) new name[32]
client_print(0,print_chat,"%L", LANG_PLAYER, "CHOSE_EXT", name ) get_user_name(id, name, 31)
else if ( key < SELECTMAPS )
client_print(0,print_chat,"%L", LANG_PLAYER, "X_CHOSE_X", name, g_mapName[g_nextName[key]] ) if (key == SELECTMAPS)
} client_print(0, print_chat, "%L", LANG_PLAYER, "CHOSE_EXT", name)
++g_voteCount[key] else if (key < SELECTMAPS)
return PLUGIN_HANDLED client_print(0, print_chat, "%L", LANG_PLAYER, "X_CHOSE_X", name, g_mapName[g_nextName[key]])
}
++g_voteCount[key]
return PLUGIN_HANDLED
} }
bool:isInMenu(id) { bool:isInMenu(id)
for (new a=0; a<g_mapVoteNum; ++a) {
if (id==g_nextName[a]) for (new a = 0; a < g_mapVoteNum; ++a)
return true if (id == g_nextName[a])
return false return true
return false
} }
public voteNextmap() { public voteNextmap()
new winlimit = get_cvar_num("mp_winlimit") {
new maxrounds = get_cvar_num("mp_maxrounds") new winlimit = get_cvar_num("mp_winlimit")
if ( winlimit ) { new maxrounds = get_cvar_num("mp_maxrounds")
new c = winlimit - 2
if ( (c > g_teamScore[0]) && (c > g_teamScore[1]) ) { if (winlimit)
g_selected = false {
return new c = winlimit - 2
}
} if ((c > g_teamScore[0]) && (c > g_teamScore[1]))
else if ( maxrounds ) { {
if ( (maxrounds - 2) > (g_teamScore[0] + g_teamScore[1]) ){ g_selected = false
g_selected = false return
return }
} }
} else if (maxrounds)
else { {
new timeleft = get_timeleft() if ((maxrounds - 2) > (g_teamScore[0] + g_teamScore[1]))
if (timeleft<1||timeleft>129){ {
g_selected = false g_selected = false
return return
} }
} } else {
if (g_selected) new timeleft = get_timeleft()
return
g_selected = true if (timeleft < 1 || timeleft > 129)
new menu[512], a, mkeys = (1<<SELECTMAPS+1) {
new pos = format(menu,511,g_coloredMenus ? "\y%L:\w^n^n" : "%L:^n^n", LANG_SERVER, "CHOOSE_NEXTM") g_selected = false
new dmax = (g_mapNums > SELECTMAPS) ? SELECTMAPS : g_mapNums return
for(g_mapVoteNum = 0;g_mapVoteNum<dmax;++g_mapVoteNum){ }
a=random_num(0,g_mapNums-1) }
while( isInMenu(a) )
if (++a >= g_mapNums) a = 0
g_nextName[g_mapVoteNum] = a
pos += format(menu[pos],511,"%d. %s^n",g_mapVoteNum+1,g_mapName[a])
mkeys |= (1<<g_mapVoteNum)
g_voteCount[g_mapVoteNum] = 0
}
menu[pos++]='^n'
g_voteCount[SELECTMAPS] = 0
g_voteCount[SELECTMAPS+1] = 0
new mapname[32]
get_mapname(mapname,31)
if ( (winlimit + maxrounds)==0 && (get_cvar_float("mp_timelimit") < get_cvar_float("amx_extendmap_max"))) { if (g_selected)
pos += format(menu[pos],511,"%d. %L^n",SELECTMAPS+1,LANG_SERVER,"EXTED_MAP",mapname) return
mkeys |= (1<<SELECTMAPS)
}
format(menu[pos],511,"%d. %L",SELECTMAPS+2,LANG_SERVER,"NONE") g_selected = true
new MenuName[64]
format(MenuName,63,"%L","en","CHOOSE_NEXTM") new menu[512], a, mkeys = (1<<SELECTMAPS + 1)
show_menu(0,mkeys,menu,15,MenuName) new pos = format(menu, 511, g_coloredMenus ? "\y%L:\w^n^n" : "%L:^n^n", LANG_SERVER, "CHOOSE_NEXTM")
set_task(15.0,"checkVotes") new dmax = (g_mapNums > SELECTMAPS) ? SELECTMAPS : g_mapNums
client_print(0,print_chat,"%L",LANG_SERVER,"TIME_CHOOSE")
client_cmd(0,"spk Gman/Gman_Choose2") for (g_mapVoteNum = 0; g_mapVoteNum < dmax; ++g_mapVoteNum)
log_amx("Vote: Voting for the nextmap started") {
a = random_num(0, g_mapNums - 1)
while (isInMenu(a))
if (++a >= g_mapNums) a = 0
g_nextName[g_mapVoteNum] = a
pos += format(menu[pos], 511, "%d. %s^n", g_mapVoteNum + 1, g_mapName[a])
mkeys |= (1<<g_mapVoteNum)
g_voteCount[g_mapVoteNum] = 0
}
menu[pos++] = '^n'
g_voteCount[SELECTMAPS] = 0
g_voteCount[SELECTMAPS + 1] = 0
new mapname[32]
get_mapname(mapname, 31)
if ((winlimit + maxrounds) == 0 && (get_cvar_float("mp_timelimit") < get_cvar_float("amx_extendmap_max")))
{
pos += format(menu[pos], 511, "%d. %L^n", SELECTMAPS + 1, LANG_SERVER, "EXTED_MAP", mapname)
mkeys |= (1<<SELECTMAPS)
}
format(menu[pos], 511, "%d. %L", SELECTMAPS+2, LANG_SERVER, "NONE")
new MenuName[64]
format(MenuName, 63, "%L", "en", "CHOOSE_NEXTM")
show_menu(0, mkeys, menu, 15, MenuName)
set_task(15.0, "checkVotes")
client_print(0, print_chat, "%L", LANG_SERVER, "TIME_CHOOSE")
client_cmd(0, "spk Gman/Gman_Choose2")
log_amx("Vote: Voting for the nextmap started")
} }
loadSettings(filename[]) { loadSettings(filename[])
if (!file_exists(filename)) return 0 {
if (!file_exists(filename))
return 0
new szText[32] new szText[32]
new a, pos = 0 new a, pos = 0
new currentMap[32] new currentMap[32]
get_mapname(currentMap,31)
get_mapname(currentMap, 31)
while ( (g_mapNums < MAX_MAPS) && read_file(filename,pos++,szText,31,a) ) { while ((g_mapNums < MAX_MAPS) && read_file(filename, pos++, szText, 31, a))
if ( szText[0] != ';' {
&& parse(szText, g_mapName[g_mapNums] ,31 ) if (szText[0] != ';' && parse(szText, g_mapName[g_mapNums], 31) && is_map_valid(g_mapName[g_mapNums])
&& is_map_valid( g_mapName[g_mapNums] ) && !equali(g_mapName[g_mapNums], g_lastMap) && !equali(g_mapName[g_mapNums], currentMap))
&& !equali( g_mapName[g_mapNums] ,g_lastMap) ++g_mapNums
&& !equali( g_mapName[g_mapNums] ,currentMap) ) }
++g_mapNums
}
return g_mapNums return g_mapNums
} }
public team_score() { public team_score()
new team[2] {
read_data(1,team,1) new team[2]
g_teamScore[ (team[0]=='C') ? 0 : 1 ] = read_data(2)
read_data(1, team, 1)
g_teamScore[(team[0]=='C') ? 0 : 1] = read_data(2)
} }
public plugin_end() { public plugin_end()
new current_map[32] {
get_mapname(current_map,31 ) new current_map[32]
set_localinfo("lastMap",current_map)
get_mapname(current_map, 31)
set_localinfo("lastMap", current_map)
} }

View File

@ -50,396 +50,445 @@ new g_coloredMenus
new g_choosed new g_choosed
public plugin_init() { public plugin_init()
register_plugin("Maps Menu",AMXX_VERSION_STR,"AMXX Dev Team") {
register_dictionary("mapsmenu.txt") register_plugin("Maps Menu", AMXX_VERSION_STR, "AMXX Dev Team")
register_dictionary("common.txt") register_dictionary("mapsmenu.txt")
register_clcmd("amx_mapmenu","cmdMapsMenu",ADMIN_MAP,"- displays changelevel menu") register_dictionary("common.txt")
register_clcmd("amx_votemapmenu","cmdVoteMapMenu",ADMIN_MAP,"- displays votemap menu") register_clcmd("amx_mapmenu", "cmdMapsMenu", ADMIN_MAP, "- displays changelevel menu")
register_clcmd("amx_votemapmenu", "cmdVoteMapMenu", ADMIN_MAP, "- displays votemap menu")
register_menucmd(register_menuid("Changelevel Menu"),1023,"actionMapsMenu") register_menucmd(register_menuid("Changelevel Menu"), 1023, "actionMapsMenu")
register_menucmd(register_menuid("Which map do you want?"),527,"voteCount") register_menucmd(register_menuid("Which map do you want?"), 527, "voteCount")
register_menucmd(register_menuid("Change map to"),527,"voteCount") register_menucmd(register_menuid("Change map to"), 527, "voteCount")
register_menucmd(register_menuid("Votemap Menu"),1023,"actionVoteMapMenu") register_menucmd(register_menuid("Votemap Menu"), 1023, "actionVoteMapMenu")
register_menucmd(register_menuid("The winner: ") ,3,"actionResult") register_menucmd(register_menuid("The winner: "), 3, "actionResult")
new maps_ini_file[64]; new maps_ini_file[64];
get_configsdir(maps_ini_file, 63); get_configsdir(maps_ini_file, 63);
format(maps_ini_file, 63, "%s/maps.ini", maps_ini_file); format(maps_ini_file, 63, "%s/maps.ini", maps_ini_file);
if (!file_exists(maps_ini_file))
format(maps_ini_file, 63, "mapcycle.txt")
load_settings(maps_ini_file)
g_coloredMenus = colored_menus() if (!file_exists(maps_ini_file))
format(maps_ini_file, 63, "mapcycle.txt")
load_settings(maps_ini_file)
g_coloredMenus = colored_menus()
} }
public autoRefuse() { public autoRefuse()
log_amx("Vote: %L" , "en", "RESULT_REF") {
client_print(0,print_chat, "%L", LANG_PLAYER, "RESULT_REF") log_amx("Vote: %L", "en", "RESULT_REF")
client_print(0, print_chat, "%L", LANG_PLAYER, "RESULT_REF")
} }
public actionResult(id,key) { public actionResult(id, key)
remove_task( 4545454 ) {
switch (key){ remove_task(4545454)
case 0: {
new _modName[10] switch (key)
get_modname(_modName,9) {
if (!equal(_modName,"zp")) { case 0:
message_begin(MSG_ALL, SVC_INTERMISSION) {
message_end() new _modName[10]
} get_modname(_modName, 9)
set_task(2.0,"delayedChange",0, g_mapName[ g_choosed ] , strlen(g_mapName[ g_choosed ]) + 1 )
log_amx("Vote: %L" , "en", "RESULT_ACC") if (!equal(_modName, "zp"))
client_print(0,print_chat, "%L", LANG_PLAYER, "RESULT_ACC") {
} message_begin(MSG_ALL, SVC_INTERMISSION)
case 1: autoRefuse() message_end()
} }
return PLUGIN_HANDLED
set_task(2.0, "delayedChange", 0, g_mapName[g_choosed], strlen(g_mapName[g_choosed]) + 1)
log_amx("Vote: %L", "en", "RESULT_ACC")
client_print(0, print_chat, "%L", LANG_PLAYER, "RESULT_ACC")
}
case 1: autoRefuse()
}
return PLUGIN_HANDLED
} }
public checkVotes( id ) { public checkVotes(id)
id -= 34567 {
new num, ppl[32],a = 0 id -= 34567
get_players(ppl,num,"c") new num, ppl[32], a = 0
if (num == 0) num = 1
g_choosed = -1 get_players(ppl, num, "c")
for (new i = 0; i < g_voteSelectedNum[id]; ++i) if (num == 0) num = 1
if ( g_voteCount[a] < g_voteCount[i] ) g_choosed = -1
a = i
if ( 100 * g_voteCount[a] / num > 50 ) { for (new i = 0; i < g_voteSelectedNum[id]; ++i)
g_choosed = g_voteSelected[id][a] if (g_voteCount[a] < g_voteCount[i])
client_print(0,print_chat, "%L %s", LANG_PLAYER, "VOTE_SUCCESS", g_mapName[ g_choosed ] ) a = i
log_amx("Vote: %L %s", "en", "VOTE_SUCCESS", g_mapName[ g_choosed ] )
}
if ( g_choosed != -1 ) {
if ( is_user_connected( id ) ) {
new menuBody[512]
new len = format(menuBody,511,g_coloredMenus ? "\y%L: \w%s^n^n" : "%L: %s^n^n", id, "THE_WINNER", g_mapName[ g_choosed ] )
len += format( menuBody[len] ,511 - len, g_coloredMenus ? "\y%L^n\w" : "%L^n", id, "WANT_CONT" )
format( menuBody[len], 511-len, "^n1. %L^n2. %L",id,"YES",id,"NO")
show_menu( id, 0x03, menuBody, 10, "The winner: ") if (100 * g_voteCount[a] / num > 50)
set_task(10.0,"autoRefuse",4545454) {
} g_choosed = g_voteSelected[id][a]
else { client_print(0, print_chat, "%L %s", LANG_PLAYER, "VOTE_SUCCESS", g_mapName[g_choosed])
new _modName[10] log_amx("Vote: %L %s", "en", "VOTE_SUCCESS", g_mapName[g_choosed])
get_modname(_modName,9) }
if (!equal(_modName,"zp")) {
message_begin(MSG_ALL, SVC_INTERMISSION) if (g_choosed != -1)
message_end() {
} if (is_user_connected(id))
set_task(2.0,"delayedChange",0, g_mapName[ g_choosed ] , strlen(g_mapName[ g_choosed ]) + 1 ) {
} new menuBody[512]
} new len = format(menuBody, 511, g_coloredMenus ? "\y%L: \w%s^n^n" : "%L: %s^n^n", id, "THE_WINNER", g_mapName[g_choosed])
else {
client_print(0,print_chat, "%L", LANG_PLAYER, "VOTE_FAILED" ) len += format(menuBody[len], 511 - len, g_coloredMenus ? "\y%L^n\w" : "%L^n", id, "WANT_CONT")
log_amx("Vote: %L", "en", "VOTE_FAILED") format(menuBody[len], 511-len, "^n1. %L^n2. %L", id, "YES", id, "NO")
}
remove_task(34567 + id) show_menu(id, 0x03, menuBody, 10, "The winner: ")
set_task(10.0, "autoRefuse", 4545454)
} else {
new _modName[10]
get_modname(_modName, 9)
if (!equal(_modName, "zp"))
{
message_begin(MSG_ALL, SVC_INTERMISSION)
message_end()
}
set_task(2.0, "delayedChange", 0, g_mapName[g_choosed], strlen(g_mapName[g_choosed]) + 1)
}
} else {
client_print(0, print_chat, "%L", LANG_PLAYER, "VOTE_FAILED")
log_amx("Vote: %L", "en", "VOTE_FAILED")
}
remove_task(34567 + id)
} }
public voteCount(id,key) { public voteCount(id, key)
if (key > 3) { {
client_print(0,print_chat,"%L",LANG_PLAYER,"VOT_CANC") if (key > 3)
remove_task(34567 + id) {
set_cvar_float( "amx_last_voting" , get_gametime() ) client_print(0, print_chat, "%L", LANG_PLAYER, "VOT_CANC")
log_amx("Vote: Cancel vote session") remove_task(34567 + id)
return PLUGIN_HANDLED set_cvar_float("amx_last_voting", get_gametime())
} log_amx("Vote: Cancel vote session")
if (get_cvar_float("amx_vote_answers")) {
new name[32] return PLUGIN_HANDLED
get_user_name(id,name,31) }
client_print(0,print_chat,"%L", LANG_PLAYER, "X_VOTED_FOR", name , key + 1 )
} if (get_cvar_float("amx_vote_answers"))
++g_voteCount[key] {
return PLUGIN_HANDLED new name[32]
get_user_name(id, name, 31)
client_print(0, print_chat, "%L", LANG_PLAYER, "X_VOTED_FOR", name, key + 1)
}
++g_voteCount[key]
return PLUGIN_HANDLED
} }
isMapSelected( id , pos ) { isMapSelected(id, pos)
for ( new a = 0 ; a < g_voteSelectedNum[ id ]; ++a ) {
if ( g_voteSelected[ id ][ a ] == pos ) for (new a = 0; a < g_voteSelectedNum[id]; ++a)
return 1 if (g_voteSelected[id][a] == pos)
return 0 return 1
return 0
} }
displayVoteMapsMenu(id,pos) { displayVoteMapsMenu(id, pos)
if (pos < 0) {
return if (pos < 0)
return
new menuBody[512], b = 0 , start = pos * 7 new menuBody[512], b = 0, start = pos * 7
if (start >= g_mapNums) if (start >= g_mapNums)
start = pos = g_menuPosition[id] = 0 start = pos = g_menuPosition[id] = 0
new len = format(menuBody,511, g_coloredMenus ? new len = format(menuBody, 511, g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%L %d/%d^n^n", id, "VOTEMAP_MENU", pos + 1, (g_mapNums / 7 + ((g_mapNums % 7) ? 1 : 0)))
"\y%L\R%d/%d^n\w^n" : "%L %d/%d^n^n", new end = start + 7, keys = MENU_KEY_0
id,"VOTEMAP_MENU",pos+1,( g_mapNums / 7 + (( g_mapNums % 7) ? 1 : 0 )) )
new end = start + 7, keys = MENU_KEY_0 if (end > g_mapNums)
end = g_mapNums
if (end > g_mapNums) for (new a = start; a < end; ++a)
end = g_mapNums {
if (g_voteSelectedNum[id] == 4 || isMapSelected(id, pos * 7 + b))
{
++b
if (g_coloredMenus)
len += format(menuBody[len], 511-len, "\d%d. %s^n\w", b, g_mapName[a])
else
len += format(menuBody[len], 511-len, "#. %s^n", g_mapName[a])
} else {
keys |= (1<<b)
len += format(menuBody[len], 511-len, "%d. %s^n", ++b, g_mapName[a])
}
}
for (new a = start; a < end; ++a) { if (g_voteSelectedNum[id])
if ( g_voteSelectedNum[id]==4 || isMapSelected( id , pos * 7 + b ) ) { {
++b keys |= MENU_KEY_8
if ( g_coloredMenus) len += format(menuBody[len], 511-len, "^n8. %L^n", id, "START_VOT")
len += format(menuBody[len],511-len,"\d%d. %s^n\w", b ,g_mapName[ a ]) }
else else
len += format(menuBody[len],511-len,"#. %s^n", g_mapName[ a ]) len += format(menuBody[len], 511-len, g_coloredMenus ? "^n\d8. %L^n\w" : "^n#. %L^n", id, "START_VOT")
}
else {
keys |= (1<<b)
len += format(menuBody[len],511-len,"%d. %s^n", ++b ,g_mapName[ a ])
}
}
if ( g_voteSelectedNum[id] ) { if (end != g_mapNums)
keys |= MENU_KEY_8 {
len += format(menuBody[len],511-len,"^n8. %L^n",id,"START_VOT") len += format(menuBody[len], 511-len, "^n9. %L...^n0. %L^n", id, "MORE", id, pos ? "BACK" : "EXIT")
} keys |= MENU_KEY_9
else }
len += format(menuBody[len],511-len, g_coloredMenus ? else
"^n\d8. %L^n\w" : "^n#. %L^n",id,"START_VOT") len += format(menuBody[len], 511-len, "^n0. %L^n", id, pos ? "BACK" : "EXIT")
if (end != g_mapNums) { if (g_voteSelectedNum[id])
len += format(menuBody[len],511-len,"^n9. %L...^n0. %L^n", id, "MORE", id, pos ? "BACK" : "EXIT") len += format(menuBody[len], 511-len, g_coloredMenus ? "^n\y%L:^n\w" : "^n%L:^n", id, "SEL_MAPS")
keys |= MENU_KEY_9 else
} len += format(menuBody[len], 511-len, "^n^n")
else
len += format(menuBody[len],511-len,"^n0. %L^n", id, pos ? "BACK" : "EXIT")
if (g_voteSelectedNum[id]) for (new c = 0; c < 4; c++)
len += format(menuBody[len],511-len, g_coloredMenus ? "^n\y%L:^n\w" : "^n%L:^n",id,"SEL_MAPS") {
else if (c < g_voteSelectedNum[id])
len += format(menuBody[len],511-len, "^n^n") len += format(menuBody[len], 511-len, "%s^n", g_mapName[g_voteSelected[id][c]])
else
len += format(menuBody[len], 511-len, "^n")
}
for (new c = 0; c < 4; c++) { new menuName[64]
if ( c < g_voteSelectedNum[id] ) format(menuName, 63, "%L", "en", "VOTEMAP_MENU")
len += format(menuBody[len],511-len,"%s^n", g_mapName[ g_voteSelected[id][ c ] ] )
else
len += format(menuBody[len],511-len,"^n" )
}
new menuName[64] show_menu(id, keys, menuBody, -1, menuName)
format(menuName,63,"%L","en","VOTEMAP_MENU")
show_menu(id,keys,menuBody,-1,menuName)
} }
public cmdVoteMapMenu(id, level, cid)
{
if (!cmd_access(id, level, cid, 1))
return PLUGIN_HANDLED
public cmdVoteMapMenu(id,level,cid) { if (get_cvar_float("amx_last_voting") > get_gametime())
if (!cmd_access(id,level,cid,1)) {
return PLUGIN_HANDLED client_print(id, print_chat, "%L", id, "ALREADY_VOT")
return PLUGIN_HANDLED
}
if ( get_cvar_float("amx_last_voting") > get_gametime() ) { g_voteSelectedNum[id] = 0
client_print(id,print_chat,"%L",id,"ALREADY_VOT")
return PLUGIN_HANDLED
}
g_voteSelectedNum[id] = 0 if (g_mapNums)
{
displayVoteMapsMenu(id, g_menuPosition[id] = 0)
} else {
console_print(id, "%L", id, "NO_MAPS_MENU")
client_print(id, print_chat, "%L", id, "NO_MAPS_MENU")
}
if ( g_mapNums ) { return PLUGIN_HANDLED
displayVoteMapsMenu(id,g_menuPosition[id] = 0)
}
else {
console_print(id,"%L",id,"NO_MAPS_MENU")
client_print(id,print_chat,"%L",id,"NO_MAPS_MENU")
}
return PLUGIN_HANDLED
} }
public cmdMapsMenu(id,level,cid) { public cmdMapsMenu(id, level, cid)
if (!cmd_access(id,level,cid,1)) {
return PLUGIN_HANDLED if (!cmd_access(id, level, cid, 1))
return PLUGIN_HANDLED
if ( g_mapNums ) { if (g_mapNums)
displayMapsMenu(id,g_menuPosition[id] = 0) {
} displayMapsMenu(id, g_menuPosition[id] = 0)
else { } else {
console_print(id,"%L",id,"NO_MAPS_MENU") console_print(id, "%L", id, "NO_MAPS_MENU")
client_print(id,print_chat,"%L",id,"NO_MAPS_MENU") client_print(id, print_chat, "%L", id, "NO_MAPS_MENU")
} }
return PLUGIN_HANDLED return PLUGIN_HANDLED
} }
public delayedChange(mapname[]) public delayedChange(mapname[])
server_cmd("changelevel %s",mapname) server_cmd("changelevel %s", mapname)
public actionVoteMapMenu(id, key)
{
switch (key)
{
case 7:
{
new Float:voting = get_cvar_float("amx_last_voting")
if (voting > get_gametime())
{
client_print(id, print_chat, "%L", id, "ALREADY_VOT")
return PLUGIN_HANDLED
}
public actionVoteMapMenu(id,key) { if (voting && voting + get_cvar_float("amx_vote_delay") > get_gametime())
switch (key) { {
case 7: { client_print(id, print_chat, "%L", id, "VOT_NOW_ALLOW")
new Float:voting = get_cvar_float("amx_last_voting") return PLUGIN_HANDLED
if ( voting > get_gametime() ) { }
client_print(id,print_chat,"%L",id,"ALREADY_VOT")
return PLUGIN_HANDLED
}
if (voting && voting + get_cvar_float("amx_vote_delay") > get_gametime()) {
client_print(id,print_chat,"%L",id,"VOT_NOW_ALLOW")
return PLUGIN_HANDLED
}
g_voteCount = { 0 , 0 , 0 , 0 , 0 } g_voteCount = {0, 0, 0, 0, 0}
new Float:vote_time = get_cvar_float("amx_vote_time") + 2.0
set_cvar_float("amx_last_voting", get_gametime() + vote_time)
new iVoteTime = floatround(vote_time)
new Float:vote_time = get_cvar_float("amx_vote_time") + 2.0 set_task(vote_time, "checkVotes", 34567 + id)
set_cvar_float("amx_last_voting", get_gametime() + vote_time )
new iVoteTime = floatround( vote_time )
set_task( vote_time , "checkVotes",34567 + id) new menuBody[512]
new players[32]
new pnum, keys, len
new menuBody[512] get_players(players, pnum)
new players[32]
new pnum, keys, len
get_players(players,pnum) if (g_voteSelectedNum[id] > 1)
{
len = format(menuBody, 511, g_coloredMenus ? "\y%L^n\w^n" : "%L^n^n", id, "WHICH_MAP")
for (new c = 0; c < g_voteSelectedNum[id]; ++c)
{
len += format(menuBody[len], 511, "%d. %s^n", c + 1, g_mapName[g_voteSelected[id][c]])
keys |= (1<<c)
}
keys |= (1<<8)
len += format(menuBody[len], 511, "^n9. None^n")
} else {
len = format(menuBody, 511, g_coloredMenus ? "\y%L^n%s?^n\w^n1. %L^n2. %L^n" : "%L^n%s?^n^n1. %L^n2. %L^n", id, "CHANGE_MAP_TO", g_mapName[g_voteSelected[id][0]], id, "YES", id, "NO")
keys = MENU_KEY_1|MENU_KEY_2
}
if ( g_voteSelectedNum[id] > 1 ) { new menuName[64]
len = format(menuBody,511,g_coloredMenus ? format(menuName, 63, "%L", "en", "WHICH_MAP")
"\y%L^n\w^n" : "%L^n^n", id, "WHICH_MAP")
for (new c = 0; c < g_voteSelectedNum[id] ; ++c) {
len += format(menuBody[len],511,"%d. %s^n", c + 1 , g_mapName[ g_voteSelected[id][ c ] ] )
keys |= (1<<c)
}
keys |= (1<<8)
len += format(menuBody[len],511,"^n9. None^n")
}
else {
len = format(menuBody,511, g_coloredMenus ? "\y%L^n%s?^n\w^n1. %L^n2. %L^n"
: "%L^n%s?^n^n1. %L^n2. %L^n", id, "CHANGE_MAP_TO", g_mapName[ g_voteSelected[id][ 0 ] ],
id, "YES", id, "NO")
keys = MENU_KEY_1|MENU_KEY_2
}
new menuName[64] for (new b = 0; b < pnum; ++b)
format(menuName,63,"%L","en","WHICH_MAP") if (players[b] != id)
show_menu(players[b], keys, menuBody, iVoteTime, menuName)
for (new b = 0; b < pnum; ++b) format(menuBody[len], 511, "^n0. %L", id, "CANC_VOTE")
if ( players[b] != id ) keys |= MENU_KEY_0
show_menu(players[b],keys,menuBody, iVoteTime, menuName) show_menu(id, keys, menuBody, iVoteTime, menuName)
format(menuBody[len],511,"^n0. %L",id,"CANC_VOTE") new authid[32], name[32]
keys |= MENU_KEY_0
show_menu(id,keys,menuBody, iVoteTime, menuName) get_user_authid(id, authid, 31)
get_user_name(id, name, 31)
new authid[32],name[32] switch (get_cvar_num("amx_show_activity"))
get_user_authid(id,authid,31) {
get_user_name(id,name,31) case 2: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_V_MAP_2", name)
case 1: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_V_MAP_1")
}
switch (get_cvar_num("amx_show_activity")) { log_amx("Vote: ^"%s<%d><%s><>^" vote maps (map#1 ^"%s^") (map#2 ^"%s^") (map#3 ^"%s^") (map#4 ^"%s^")",
case 2: client_print(0,print_chat,"%L",LANG_PLAYER,"ADMIN_V_MAP_2",name) name, get_user_userid(id), authid,
case 1: client_print(0,print_chat,"%L",LANG_PLAYER,"ADMIN_V_MAP_1") g_voteSelectedNum[id] > 0 ? g_mapName[g_voteSelected[id][0]] : "",
} g_voteSelectedNum[id] > 1 ? g_mapName[g_voteSelected[id][1]] : "",
g_voteSelectedNum[id] > 2 ? g_mapName[g_voteSelected[id][2]] : "",
g_voteSelectedNum[id] > 3 ? g_mapName[g_voteSelected[id][3]] : "")
}
case 8: displayVoteMapsMenu(id, ++g_menuPosition[id])
case 9: displayVoteMapsMenu(id, --g_menuPosition[id])
default:
{
g_voteSelected[id][g_voteSelectedNum[id]++] = g_menuPosition[id] * 7 + key
displayVoteMapsMenu(id, g_menuPosition[id])
}
}
log_amx("Vote: ^"%s<%d><%s><>^" vote maps (map#1 ^"%s^") (map#2 ^"%s^") (map#3 ^"%s^") (map#4 ^"%s^")", return PLUGIN_HANDLED
name,get_user_userid(id),authid,
g_voteSelectedNum[id] > 0 ? g_mapName[ g_voteSelected[id][ 0 ] ] : "" ,
g_voteSelectedNum[id] > 1 ? g_mapName[ g_voteSelected[id][ 1 ] ] : "" ,
g_voteSelectedNum[id] > 2 ? g_mapName[ g_voteSelected[id][ 2 ] ] : "",
g_voteSelectedNum[id] > 3 ? g_mapName[ g_voteSelected[id][ 3 ] ] : "")
}
case 8: displayVoteMapsMenu(id,++g_menuPosition[id])
case 9: displayVoteMapsMenu(id,--g_menuPosition[id])
default: {
g_voteSelected[id][ g_voteSelectedNum[id]++ ] = g_menuPosition[id] * 7 + key
displayVoteMapsMenu(id,g_menuPosition[id])
}
}
return PLUGIN_HANDLED
} }
public actionMapsMenu(id, key)
{
switch (key)
{
case 8: displayMapsMenu(id, ++g_menuPosition[id])
case 9: displayMapsMenu(id, --g_menuPosition[id])
default:
{
new a = g_menuPosition[id] * 8 + key
new _modName[10]
public actionMapsMenu(id,key) { get_modname(_modName, 9)
switch (key) { if (!equal(_modName, "zp"))
case 8: displayMapsMenu(id,++g_menuPosition[id]) {
case 9: displayMapsMenu(id,--g_menuPosition[id]) message_begin(MSG_ALL, SVC_INTERMISSION)
default: message_end()
{ }
new a = g_menuPosition[id] * 8 + key
new authid[32], name[32]
get_user_authid(id, authid, 31)
get_user_name(id, name, 31)
new _modName[10] switch (get_cvar_num("amx_show_activity"))
get_modname(_modName,9) {
if (!equal(_modName,"zp")) { case 2: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_CHANGEL_2", name, g_mapName[a])
message_begin(MSG_ALL, SVC_INTERMISSION) case 1: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_CHANGEL_1", g_mapName[a])
message_end() }
}
new authid[32],name[32]
get_user_authid(id,authid,31)
get_user_name(id,name,31)
switch (get_cvar_num("amx_show_activity")) { log_amx("Cmd: ^"%s<%d><%s><>^" changelevel ^"%s^"", name, get_user_userid(id), authid, g_mapName[a])
case 2: client_print(0,print_chat,"%L",LANG_PLAYER,"ADMIN_CHANGEL_2",name,g_mapName[ a ]) set_task(2.0, "delayedChange", 0, g_mapName[a], strlen(g_mapName[a]) + 1)
case 1: client_print(0,print_chat,"%L",LANG_PLAYER,"ADMIN_CHANGEL_1",g_mapName[ a ]) /* displayMapsMenu(id, g_menuPosition[id]) */
} }
}
log_amx("Cmd: ^"%s<%d><%s><>^" changelevel ^"%s^"",
name,get_user_userid(id),authid, g_mapName[ a ] ) return PLUGIN_HANDLED
set_task(2.0,"delayedChange",0, g_mapName[ a ] , strlen(g_mapName[ a ]) + 1 )
/* displayMapsMenu(id,g_menuPosition[id]) */
}
}
return PLUGIN_HANDLED
} }
displayMapsMenu(id,pos) { displayMapsMenu(id, pos)
if (pos < 0) {
return if (pos < 0)
return
new menuBody[512] new menuBody[512]
new start = pos * 8 new start = pos * 8
new b = 0 new b = 0
if (start >= g_mapNums) if (start >= g_mapNums)
start = pos = g_menuPosition[id] = 0 start = pos = g_menuPosition[id] = 0
new len = format(menuBody,511, g_coloredMenus ? new len = format(menuBody, 511, g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%L %d/%d^n^n", id, "CHANGLE_MENU", pos + 1, (g_mapNums / 8 + ((g_mapNums % 8) ? 1 : 0)))
"\y%L\R%d/%d^n\w^n" : "%L %d/%d^n^n", new end = start + 8
id,"CHANGLE_MENU",pos+1,( g_mapNums / 8 + (( g_mapNums % 8) ? 1 : 0 )) ) new keys = MENU_KEY_0
new end = start + 8 if (end > g_mapNums)
new keys = MENU_KEY_0 end = g_mapNums
if (end > g_mapNums) for (new a = start; a < end; ++a)
end = g_mapNums {
keys |= (1<<b)
len += format(menuBody[len], 511-len, "%d. %s^n", ++b, g_mapName[a])
}
for (new a = start; a < end; ++a) { if (end != g_mapNums)
keys |= (1<<b) {
len += format(menuBody[len],511-len,"%d. %s^n",++b,g_mapName[ a ]) format(menuBody[len], 511-len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
} keys |= MENU_KEY_9
}
else
format(menuBody[len], 511-len, "^n0. %L", id, pos ? "BACK" : "EXIT")
if (end != g_mapNums) { new menuName[64]
format(menuBody[len],511-len,"^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT") format(menuName, 63, "%L", "en", "CHANGLE_MENU")
keys |= MENU_KEY_9
}
else format(menuBody[len],511-len,"^n0. %L", id, pos ? "BACK" : "EXIT")
new menuName[64] show_menu(id, keys, menuBody, -1, menuName)
format(menuName,63,"%L","en","CHANGLE_MENU")
show_menu(id,keys,menuBody,-1,menuName)
} }
load_settings(filename[]) { load_settings(filename[])
if (!file_exists(filename)) {
return 0 if (!file_exists(filename))
return 0
new text[256] new text[256]
new a , pos = 0 new a, pos = 0
while ( g_mapNums < MAX_MAPS && read_file(filename,pos++,text,255,a) ) { while (g_mapNums < MAX_MAPS && read_file(filename, pos++, text, 255, a))
if ( text[0] == ';' ) continue {
if (text[0] == ';') continue
if (parse(text, g_mapName[g_mapNums], 31) < 1) continue
if (!is_map_valid(g_mapName[g_mapNums])) continue
if ( parse(text,g_mapName[g_mapNums],31) < 1 ) continue g_mapNums++
}
if ( !is_map_valid( g_mapName[g_mapNums] ) ) continue return 1
g_mapNums++
}
return 1
} }

View File

@ -63,55 +63,68 @@ new g_clientMenuPlugin[MAXMENUS][STRINGSIZE]
// menuCmd: Command that should be executed to start menu // menuCmd: Command that should be executed to start menu
// menuAccess: Access required for menu // menuAccess: Access required for menu
// menuPlugin: The exact case-insensitive name of plugin holding the menu command // menuPlugin: The exact case-insensitive name of plugin holding the menu command
public AddMenu(const menuBody[], const menuCmd[], const menuAccess, const menuPlugin[]) { public AddMenu(const menuBody[], const menuCmd[], const menuAccess, const menuPlugin[])
if (g_menusNumber + 1 == MAXMENUS) { {
if (g_menusNumber + 1 == MAXMENUS)
{
log_amx("Error: Plugin ^"%s^" tried to add a menu item to Menu Front-End plugin with maximum menu items reached!", menuPlugin) log_amx("Error: Plugin ^"%s^" tried to add a menu item to Menu Front-End plugin with maximum menu items reached!", menuPlugin)
return return
} }
copy(g_menuBody[g_menusNumber], STRINGLENGTH, menuBody) copy(g_menuBody[g_menusNumber], STRINGLENGTH, menuBody)
g_menuBodyPhrase[g_menusNumber] = false g_menuBodyPhrase[g_menusNumber] = false
copy(g_menuCmd[g_menusNumber], STRINGLENGTH, menuCmd) copy(g_menuCmd[g_menusNumber], STRINGLENGTH, menuCmd)
g_menuAccess[g_menusNumber] = menuAccess g_menuAccess[g_menusNumber] = menuAccess
copy(g_menuPlugin[g_menusNumber], STRINGLENGTH, menuPlugin) copy(g_menuPlugin[g_menusNumber], STRINGLENGTH, menuPlugin)
g_menusNumber++ g_menusNumber++
server_print("Menu item %d added to Menus Front-End: ^"%s^" from plugin ^"%s^"", g_menusNumber, menuBody, menuPlugin) server_print("Menu item %d added to Menus Front-End: ^"%s^" from plugin ^"%s^"", g_menusNumber, menuBody, menuPlugin)
} }
public AddMenuLang(const menuBody[], const menuCmd[], const menuAccess, const menuPlugin[]) {
if (g_menusNumber + 1 == MAXMENUS) { public AddMenuLang(const menuBody[], const menuCmd[], const menuAccess, const menuPlugin[])
{
if (g_menusNumber + 1 == MAXMENUS)
{
log_amx("Error: Plugin ^"%s^" tried to add a menu item to Menu Front-End plugin with maximum menu items reached!", menuPlugin) log_amx("Error: Plugin ^"%s^" tried to add a menu item to Menu Front-End plugin with maximum menu items reached!", menuPlugin)
return return
} }
copy(g_menuBody[g_menusNumber], STRINGLENGTH, menuBody) copy(g_menuBody[g_menusNumber], STRINGLENGTH, menuBody)
g_menuBodyPhrase[g_menusNumber] = true g_menuBodyPhrase[g_menusNumber] = true
copy(g_menuCmd[g_menusNumber], STRINGLENGTH, menuCmd) copy(g_menuCmd[g_menusNumber], STRINGLENGTH, menuCmd)
g_menuAccess[g_menusNumber] = menuAccess g_menuAccess[g_menusNumber] = menuAccess
copy(g_menuPlugin[g_menusNumber], STRINGLENGTH, menuPlugin) copy(g_menuPlugin[g_menusNumber], STRINGLENGTH, menuPlugin)
g_menusNumber++ g_menusNumber++
//server_print("Menu item %d added to Menus Front-End: ^"%s^" (LANG) from plugin ^"%s^"", g_menusNumber, menuBody, menuPlugin) //server_print("Menu item %d added to Menus Front-End: ^"%s^" (LANG) from plugin ^"%s^"", g_menusNumber, menuBody, menuPlugin)
} }
public AddClientMenu(const menuBody[], const menuCmd[], const menuAccess, const menuPlugin[]) {
if (g_clientMenusNumber + 1 == MAXMENUS) { public AddClientMenu(const menuBody[], const menuCmd[], const menuAccess, const menuPlugin[])
{
if (g_clientMenusNumber + 1 == MAXMENUS)
{
log_amx("Error: Plugin ^"%s^" tried to add a menu item to Menu Front-End plugin with maximum menu items reached!", menuPlugin) log_amx("Error: Plugin ^"%s^" tried to add a menu item to Menu Front-End plugin with maximum menu items reached!", menuPlugin)
return return
} }
copy(g_clientMenuBody[g_clientMenusNumber], STRINGLENGTH, menuBody) copy(g_clientMenuBody[g_clientMenusNumber], STRINGLENGTH, menuBody)
g_clientMenuBodyPhrase[g_clientMenusNumber] = false g_clientMenuBodyPhrase[g_clientMenusNumber] = false
copy(g_clientMenuCmd[g_clientMenusNumber], STRINGLENGTH, menuCmd) copy(g_clientMenuCmd[g_clientMenusNumber], STRINGLENGTH, menuCmd)
g_clientMenuAccess[g_clientMenusNumber] = menuAccess g_clientMenuAccess[g_clientMenusNumber] = menuAccess
copy(g_clientMenuPlugin[g_clientMenusNumber], STRINGLENGTH, menuPlugin) copy(g_clientMenuPlugin[g_clientMenusNumber], STRINGLENGTH, menuPlugin)
g_clientMenusNumber++ g_clientMenusNumber++
server_print("Client menu item %d added to Client Menus Front-End: ^"%s^" from plugin ^"%s^"", g_clientMenusNumber, menuBody, menuPlugin) server_print("Client menu item %d added to Client Menus Front-End: ^"%s^" from plugin ^"%s^"", g_clientMenusNumber, menuBody, menuPlugin)
} }
AddDefaultMenus() { AddDefaultMenus()
{
AddMenuLang("KICK_PLAYER", "amx_kickmenu", ADMIN_KICK, "Players Menu") AddMenuLang("KICK_PLAYER", "amx_kickmenu", ADMIN_KICK, "Players Menu")
AddMenuLang("BAN_PLAYER", "amx_banmenu", ADMIN_BAN, "Players Menu") AddMenuLang("BAN_PLAYER", "amx_banmenu", ADMIN_BAN, "Players Menu")
AddMenuLang("SLAP_SLAY", "amx_slapmenu", ADMIN_SLAY, "Players Menu") AddMenuLang("SLAP_SLAY", "amx_slapmenu", ADMIN_SLAY, "Players Menu")
@ -130,24 +143,32 @@ AddDefaultMenus() {
AddMenuLang("TELE_PLAYER", "amx_teleportmenu", ADMIN_LEVEL_A, "Teleport Menu") AddMenuLang("TELE_PLAYER", "amx_teleportmenu", ADMIN_LEVEL_A, "Teleport Menu")
} }
public actionMenu(id,key) { public actionMenu(id, key)
switch (key) { {
case 8: displayMenu(id,++g_menuPosition[id]) switch (key)
case 9: displayMenu(id,--g_menuPosition[id]) {
default: client_cmd(id, g_menuCmd[ g_menuPosition[id] * 8 + key ] ) case 8: displayMenu(id, ++g_menuPosition[id])
case 9: displayMenu(id, --g_menuPosition[id])
default: client_cmd(id, g_menuCmd[g_menuPosition[id] * 8 + key])
} }
return PLUGIN_HANDLED return PLUGIN_HANDLED
} }
public clientActionMenu(id,key) {
switch (key) { public clientActionMenu(id, key)
{
switch (key)
{
case 8: clientDisplayMenu(id, ++g_clientMenuPosition[id]) case 8: clientDisplayMenu(id, ++g_clientMenuPosition[id])
case 9: clientDisplayMenu(id, --g_clientMenuPosition[id]) case 9: clientDisplayMenu(id, --g_clientMenuPosition[id])
default: client_cmd(id, g_clientMenuCmd[ g_clientMenuPosition[id] * 8 + key ]) default: client_cmd(id, g_clientMenuCmd[g_clientMenuPosition[id] * 8 + key])
} }
return PLUGIN_HANDLED return PLUGIN_HANDLED
} }
displayMenu(id, pos) { displayMenu(id, pos)
{
if (pos < 0) if (pos < 0)
return return
@ -155,127 +176,139 @@ displayMenu(id, pos) {
new b = 0 new b = 0
new start = pos * MENUITEMSPERPAGE new start = pos * MENUITEMSPERPAGE
if ( start >= g_menusNumber ) // MENUS_NUMBER if (start >= g_menusNumber) // MENUS_NUMBER
start = pos = g_menuPosition[id] = 0 start = pos = g_menuPosition[id] = 0
new len = format(menuBody,511, new len = format(menuBody, 511,
g_coloredMenus ? "\yAMX Mod X Menu\R%d/%d^n\w^n" : "AMX Mod X Menu %d/%d^n^n" , pos+1, (g_menusNumber / MENUITEMSPERPAGE) + (((g_menusNumber % MENUITEMSPERPAGE) > 0) ? 1 : 0))
g_coloredMenus ? "\yAMX Mod X Menu\R%d/%d^n\w^n" : "AMX Mod X Menu %d/%d^n^n" , pos + 1, (g_menusNumber / MENUITEMSPERPAGE) + (((g_menusNumber % MENUITEMSPERPAGE) > 0) ? 1 : 0))
new end = start + MENUITEMSPERPAGE new end = start + MENUITEMSPERPAGE
new keys = MENU_KEY_0 new keys = MENU_KEY_0
if (end > g_menusNumber ) // MENUS_NUMBER if (end > g_menusNumber) // MENUS_NUMBER
end = g_menusNumber // MENUS_NUMBER end = g_menusNumber // MENUS_NUMBER
new flags = get_user_flags(id) new flags = get_user_flags(id)
for (new a = start; a < end; ++a) { for (new a = start; a < end; ++a)
if ( (flags & g_menuAccess[a]) && ( is_plugin_loaded(g_menuPlugin[a])!=-1 ) ) { {
if ((flags & g_menuAccess[a]) && (is_plugin_loaded(g_menuPlugin[a]) != -1))
{
keys |= (1<<b) keys |= (1<<b)
if (g_menuBodyPhrase[a]) if (g_menuBodyPhrase[a])
len += format(menuBody[len],511-len,"%d. %L^n",++b, id, g_menuBody[ a ] ) len += format(menuBody[len], 511-len, "%d. %L^n", ++b, id, g_menuBody[a])
else else
len += format(menuBody[len],511-len,"%d. %s^n",++b, g_menuBody[ a ] ) len += format(menuBody[len], 511-len, "%d. %s^n", ++b, g_menuBody[a])
} } else {
else {
++b ++b
if ( g_coloredMenus ) {
if (g_coloredMenus)
{
if (g_menuBodyPhrase[a]) if (g_menuBodyPhrase[a])
len += format(menuBody[len],511-len, "\d%d. %L^n\w",b, id, g_menuBody[ a ] ) len += format(menuBody[len], 511-len, "\d%d. %L^n\w", b, id, g_menuBody[a])
else else
len += format(menuBody[len],511-len, "\d%d. %s^n\w",b, g_menuBody[ a ] ) len += format(menuBody[len], 511-len, "\d%d. %s^n\w", b, g_menuBody[a])
} } else {
else {
if (g_menuBodyPhrase[a]) if (g_menuBodyPhrase[a])
len += format(menuBody[len],511-len, "#. %L^n", id, g_menuBody[ a ] ) len += format(menuBody[len], 511-len, "#. %L^n", id, g_menuBody[a])
else else
len += format(menuBody[len],511-len, "#. %s^n", g_menuBody[ a ] ) len += format(menuBody[len], 511-len, "#. %s^n", g_menuBody[a])
} }
} }
} }
if (end != g_menusNumber ) { // MENUS_NUMBER if (end != g_menusNumber) // MENUS_NUMBER
format(menuBody[len],511-len,"^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT") {
format(menuBody[len], 511-len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
keys |= MENU_KEY_9 keys |= MENU_KEY_9
} } else {
else { format(menuBody[len], 511-len, "^n0. %L", id, pos ? "BACK" : "EXIT")
format(menuBody[len],511-len,"^n0. %L", id, pos ? "BACK" : "EXIT")
}
show_menu(id,keys,menuBody)
}
clientDisplayMenu(id,pos) {
if (pos < 0)
return
new menuBody[512]
new b = 0
new start = pos * MENUITEMSPERPAGE
if ( start >= g_clientMenusNumber ) // MENUS_NUMBER
start = pos = g_clientMenuPosition[id] = 0
new len = format(menuBody,511,
g_coloredMenus ? "\yAMX Mod X Client Menu\R%d/%d^n\w^n" : "AMX Mod X Client Menu %d/%d^n^n" , pos+1, (g_clientMenusNumber / MENUITEMSPERPAGE) + (((g_clientMenusNumber % MENUITEMSPERPAGE) > 0) ? 1 : 0))
new end = start + MENUITEMSPERPAGE
new keys = MENU_KEY_0
if (end > g_clientMenusNumber ) // MENUS_NUMBER
end = g_clientMenusNumber // MENUS_NUMBER
new flags = get_user_flags(id)
for (new a = start; a < end; ++a) {
if ( (flags & g_clientMenuAccess[a]) && ( is_plugin_loaded(g_clientMenuPlugin[a])!=-1 ) ) {
keys |= (1<<b)
if (g_clientMenuBodyPhrase[a])
len += format(menuBody[len],511-len,"%d. %L^n",++b, id, g_clientMenuBody[ a ] )
else
len += format(menuBody[len],511-len,"%d. %s^n",++b, g_clientMenuBody[ a ] )
}
else {
++b
if ( g_coloredMenus ) {
if (g_clientMenuBodyPhrase[a])
len += format(menuBody[len],511-len, "\d%d. %L^n\w",b, id, g_clientMenuBody[ a ] )
else
len += format(menuBody[len],511-len, "\d%d. %s^n\w",b, g_clientMenuBody[ a ] )
}
else {
if (g_clientMenuBodyPhrase[a])
len += format(menuBody[len],511-len, "#. %L^n", id, g_clientMenuBody[ a ] )
else
len += format(menuBody[len],511-len, "#. %s^n", g_clientMenuBody[ a ] )
}
}
}
if (end != g_clientMenusNumber ) { // MENUS_NUMBER
format(menuBody[len],511-len,"^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
keys |= MENU_KEY_9
}
else {
format(menuBody[len],511-len,"^n0. %L", id, pos ? "BACK" : "EXIT")
} }
show_menu(id, keys, menuBody) show_menu(id, keys, menuBody)
} }
public cmdMenu(id,level,cid) { clientDisplayMenu(id, pos)
if (cmd_access(id,level,cid,1)) {
displayMenu(id, g_menuPosition[id] = 0) if (pos < 0)
return
return PLUGIN_HANDLED new menuBody[512]
new b = 0
new start = pos * MENUITEMSPERPAGE
if (start >= g_clientMenusNumber) // MENUS_NUMBER
start = pos = g_clientMenuPosition[id] = 0
new len = format(menuBody, 511, g_coloredMenus ? "\yAMX Mod X Client Menu\R%d/%d^n\w^n" : "AMX Mod X Client Menu %d/%d^n^n" , pos + 1, (g_clientMenusNumber / MENUITEMSPERPAGE) + (((g_clientMenusNumber % MENUITEMSPERPAGE) > 0) ? 1 : 0))
new end = start + MENUITEMSPERPAGE
new keys = MENU_KEY_0
if (end > g_clientMenusNumber) // MENUS_NUMBER
end = g_clientMenusNumber // MENUS_NUMBER
new flags = get_user_flags(id)
for (new a = start; a < end; ++a)
{
if ((flags & g_clientMenuAccess[a]) && (is_plugin_loaded(g_clientMenuPlugin[a]) != -1))
{
keys |= (1<<b)
if (g_clientMenuBodyPhrase[a])
len += format(menuBody[len], 511-len, "%d. %L^n", ++b, id, g_clientMenuBody[a])
else
len += format(menuBody[len], 511-len, "%d. %s^n", ++b, g_clientMenuBody[a])
} else {
++b
if (g_coloredMenus)
{
if (g_clientMenuBodyPhrase[a])
len += format(menuBody[len], 511-len, "\d%d. %L^n\w", b, id, g_clientMenuBody[a])
else
len += format(menuBody[len], 511-len, "\d%d. %s^n\w", b, g_clientMenuBody[a])
} else {
if (g_clientMenuBodyPhrase[a])
len += format(menuBody[len], 511-len, "#. %L^n", id, g_clientMenuBody[a])
else
len += format(menuBody[len], 511-len, "#. %s^n", g_clientMenuBody[a])
}
}
}
if (end != g_clientMenusNumber) // MENUS_NUMBER
{
format(menuBody[len], 511-len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
keys |= MENU_KEY_9
}
else {
format(menuBody[len], 511-len, "^n0. %L", id, pos ? "BACK" : "EXIT")
}
show_menu(id, keys, menuBody)
} }
public clientCmdMenu(id,level,cid) {
public cmdMenu(id, level, cid)
{
if (cmd_access(id, level, cid, 1))
displayMenu(id, g_menuPosition[id] = 0)
return PLUGIN_HANDLED
}
public clientCmdMenu(id, level, cid)
{
if (cmd_access(id, level, cid, 1)) if (cmd_access(id, level, cid, 1))
clientDisplayMenu(id, g_clientMenuPosition[id] = 0) clientDisplayMenu(id, g_clientMenuPosition[id] = 0)
return PLUGIN_HANDLED return PLUGIN_HANDLED
} }
public addmenuitem_cmd(id, level, cid) { public addmenuitem_cmd(id, level, cid)
{
if (!cmd_access(id, level, cid, 5)) if (!cmd_access(id, level, cid, 5))
return PLUGIN_HANDLED return PLUGIN_HANDLED
@ -287,12 +320,13 @@ public addmenuitem_cmd(id, level, cid) {
menuAccess = read_flags(flags) menuAccess = read_flags(flags)
read_argv(4, menuPlugin, STRINGLENGTH) read_argv(4, menuPlugin, STRINGLENGTH)
AddMenu(menuBody, menuCmd, menuAccess, menuPlugin) AddMenu(menuBody, menuCmd, menuAccess, menuPlugin)
return PLUGIN_HANDLED return PLUGIN_HANDLED
} }
public addclientmenuitem_cmd(id, level, cid) {
public addclientmenuitem_cmd(id, level, cid)
{
if (!cmd_access(id, level, cid, 5)) if (!cmd_access(id, level, cid, 5))
return PLUGIN_HANDLED return PLUGIN_HANDLED
@ -304,15 +338,14 @@ public addclientmenuitem_cmd(id, level, cid) {
menuAccess = read_flags(flags) menuAccess = read_flags(flags)
read_argv(4, menuPlugin, STRINGLENGTH) read_argv(4, menuPlugin, STRINGLENGTH)
AddClientMenu(menuBody, menuCmd, menuAccess, menuPlugin) AddClientMenu(menuBody, menuCmd, menuAccess, menuPlugin)
return PLUGIN_HANDLED return PLUGIN_HANDLED
} }
public plugin_init() { public plugin_init()
register_plugin("Menus Front-End",AMXX_VERSION_STR,"AMXX Dev Team") {
register_plugin("Menus Front-End", AMXX_VERSION_STR, "AMXX Dev Team")
register_dictionary("menufront.txt") register_dictionary("menufront.txt")
register_dictionary("common.txt") register_dictionary("common.txt")
@ -332,4 +365,4 @@ public plugin_init() {
new configs[128] new configs[128]
get_configsdir(configs, 127) get_configsdir(configs, 127)
server_cmd("exec %s/custommenuitems.cfg", configs) server_cmd("exec %s/custommenuitems.cfg", configs)
} }

View File

@ -34,7 +34,7 @@
#include <amxmodx> #include <amxmodx>
#include <amxmisc> #include <amxmisc>
#define DISPLAY_MSG // Comment to disable message on join #define DISPLAY_MSG // Comment to disable message on join
new g_menuLang[33][2] new g_menuLang[33][2]
new g_serverLang new g_serverLang
@ -43,167 +43,188 @@ new g_coloredMenus
public plugin_init() public plugin_init()
{ {
register_plugin("Multi-Lingual System",AMXX_VERSION_STR,"AMXX Dev Team") register_plugin("Multi-Lingual System", AMXX_VERSION_STR, "AMXX Dev Team")
register_dictionary("multilingual.txt") register_dictionary("multilingual.txt")
register_dictionary("common.txt") register_dictionary("common.txt")
register_dictionary("languages.txt") register_dictionary("languages.txt")
register_cvar("amx_language","en",FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_SPONLY)
//Set to zero to disable client effects register_cvar("amx_language", "en", FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_SPONLY)
register_cvar("amx_client_languages", "1") //Set to zero to disable client effects
register_concmd("amx_setlang","cmdLang",ADMIN_CFG,"<language>") register_cvar("amx_client_languages", "1")
register_clcmd("amx_langmenu","cmdLangMenu",ADMIN_ALL) register_concmd("amx_setlang", "cmdLang", ADMIN_CFG, "<language>")
register_menu("Language Menu",1023,"actionMenu") register_clcmd("amx_langmenu", "cmdLangMenu", ADMIN_ALL)
register_menu("Language Menu", 1023, "actionMenu")
new lang[3] new lang[3]
if ( vaultdata_exists("server_language") ) {
get_vaultdata("server_language",lang,2) if (vaultdata_exists("server_language"))
} {
else { get_vaultdata("server_language", lang, 2)
copy(lang,2,"en") } else {
set_vaultdata("server_language",lang) copy(lang, 2, "en")
} set_vaultdata("server_language", lang)
set_cvar_string("amx_language",lang) }
set_cvar_string("amx_language", lang)
g_langNum = get_langsnum() g_langNum = get_langsnum()
g_serverLang = get_lang_id(lang) g_serverLang = get_lang_id(lang)
g_coloredMenus = colored_menus() g_coloredMenus = colored_menus()
} }
#if defined DISPLAY_MSG #if defined DISPLAY_MSG
public client_putinserver(id) { public client_putinserver(id)
if (get_cvar_num("amx_client_languages") && !is_user_bot(id)) {
set_task(10.0,"dispInfo",id) if (get_cvar_num("amx_client_languages") && !is_user_bot(id))
set_task(10.0, "dispInfo", id)
} }
public client_disconnect(id) { public client_disconnect(id)
{
remove_task(id) remove_task(id)
} }
public dispInfo(id) public dispInfo(id)
{ {
if (get_cvar_num("amx_client_languages")) if (get_cvar_num("amx_client_languages"))
client_print(id,print_chat,"%L",id,"TYPE_LANGMENU") client_print(id, print_chat, "%L", id, "TYPE_LANGMENU")
} }
#endif #endif
public cmdLang(id,level,cid) { public cmdLang(id, level, cid)
if (!cmd_access(id,level,cid,2)) {
return PLUGIN_HANDLED if (!cmd_access(id, level, cid, 2))
return PLUGIN_HANDLED
new arg[3] new arg[3]
read_argv(1,arg,2) read_argv(1, arg, 2)
if ( !lang_exists(arg) ) { if (!lang_exists(arg))
console_print(id,"[AMXX] %L",id,"LANG_NOT_EXISTS") {
return PLUGIN_HANDLED console_print(id, "[AMXX] %L", id, "LANG_NOT_EXISTS")
} return PLUGIN_HANDLED
}
set_vaultdata("server_language",arg) set_vaultdata("server_language", arg)
set_cvar_string("amx_language",arg) set_cvar_string("amx_language", arg)
g_serverLang = get_lang_id(arg) g_serverLang = get_lang_id(arg)
return PLUGIN_HANDLED return PLUGIN_HANDLED
} }
public cmdLangMenu(id,level,cid) public cmdLangMenu(id, level, cid)
{ {
new buffer[3] new buffer[3]
if (!get_cvar_num("amx_client_languages")) if (!get_cvar_num("amx_client_languages"))
{ {
client_print(id, print_console, "[AMXX] %L", LANG_SERVER, "LANG_MENU_DISABLED") client_print(id, print_console, "[AMXX] %L", LANG_SERVER, "LANG_MENU_DISABLED")
return PLUGIN_HANDLED return PLUGIN_HANDLED
} }
get_user_info(id,"lang",buffer,2) get_user_info(id, "lang", buffer, 2)
g_menuLang[id][0] = get_lang_id(buffer)
g_menuLang[id][1] = g_serverLang
g_menuLang[id][0] = get_lang_id(buffer) showMenu(id)
g_menuLang[id][1] = g_serverLang
showMenu(id) return PLUGIN_HANDLED
return PLUGIN_HANDLED
} }
showMenu(id) showMenu(id)
{ {
if (!get_cvar_num("amx_client_languages")) if (!get_cvar_num("amx_client_languages"))
return PLUGIN_HANDLED return PLUGIN_HANDLED
new menuBody[512],pLang[3]
new menuBody[512], pLang[3]
get_lang(g_menuLang[id][0],pLang) get_lang(g_menuLang[id][0], pLang)
new len = format( menuBody,511,(g_coloredMenus ? "\y%L\w^n^n" : "%L^n^n"),id,"LANG_MENU" ) new len = format(menuBody, 511, (g_coloredMenus ? "\y%L\w^n^n" : "%L^n^n"), id, "LANG_MENU")
len += format( menuBody[len],511-len,(g_coloredMenus ? "1. %L\R\r%L\w^n" : "1. %L %L^n"),id,"PERSO_LANG",pLang,"LANG_NAME" )
len += format(menuBody[len], 511-len, (g_coloredMenus ? "1. %L\R\r%L\w^n" : "1. %L %L^n"), id, "PERSO_LANG", pLang, "LANG_NAME")
if ( access(id,ADMIN_CFG) ) { if (access(id, ADMIN_CFG))
new sLang[3] {
get_lang(g_menuLang[id][1],sLang) new sLang[3]
len += format( menuBody[len],511-len,(g_coloredMenus ? "2. %L\R\r%L\w^n^n" : "2. %L %L^n^n"),id,"SERVER_LANG",sLang,"LANG_NAME" )
len += format( menuBody[len],511-len,"3. %L",id,"SAVE_LANG" ) get_lang(g_menuLang[id][1], sLang)
} len += format(menuBody[len], 511-len, (g_coloredMenus ? "2. %L\R\r%L\w^n^n" : "2. %L %L^n^n"), id, "SERVER_LANG", sLang, "LANG_NAME")
else { len += format(menuBody[len], 511-len, "3. %L", id, "SAVE_LANG")
len += format( menuBody[len],511-len,"^n2. %L",id,"SAVE_LANG" ) } else {
} len += format(menuBody[len], 511-len, "^n2. %L", id, "SAVE_LANG")
format( menuBody[len],511-len,"^n^n0. %L",id,"EXIT" ) }
format(menuBody[len], 511-len, "^n^n0. %L", id, "EXIT")
show_menu(id,MENU_KEY_0|MENU_KEY_1|MENU_KEY_2|MENU_KEY_3,menuBody,-1,"Language Menu") show_menu(id, MENU_KEY_0|MENU_KEY_1|MENU_KEY_2|MENU_KEY_3, menuBody, -1, "Language Menu")
return 1 return 1
} }
public actionMenu(id,key) { public actionMenu(id, key)
if (!get_cvar_num("amx_client_languages")) {
return 0 if (!get_cvar_num("amx_client_languages"))
return 0
new isAdmin = access(id,ADMIN_CFG) new isAdmin = access(id, ADMIN_CFG)
if ( key==0 ) { if (key == 0)
if ( g_menuLang[id][0]<(g_langNum-1) ) {
g_menuLang[id][0]++ if (g_menuLang[id][0] < (g_langNum-1))
else g_menuLang[id][0]++
g_menuLang[id][0] = 0 else
showMenu(id) g_menuLang[id][0] = 0
}
showMenu(id)
}
if ( isAdmin && (key==1) ) { if (isAdmin && (key == 1))
if ( g_menuLang[id][1]<(g_langNum-1) ) {
g_menuLang[id][1]++ if (g_menuLang[id][1] < (g_langNum - 1))
else g_menuLang[id][1]++
g_menuLang[id][1] = 0 else
showMenu(id) g_menuLang[id][1] = 0
}
showMenu(id)
}
new pLang[3],pLang_old[3],sLang[3],sLang_old[3],lName[64] new pLang[3], pLang_old[3], sLang[3], sLang_old[3], lName[64]
get_lang(g_menuLang[id][0],pLang)
get_lang(g_menuLang[id][1],sLang) get_lang(g_menuLang[id][0], pLang)
get_user_info(id,"lang",pLang_old,2) get_lang(g_menuLang[id][1], sLang)
get_lang(g_serverLang,sLang_old) get_user_info(id, "lang", pLang_old, 2)
get_lang(g_serverLang, sLang_old)
if ( isAdmin && (key==2) && !equali(sLang,sLang_old) ) { if (isAdmin && (key == 2) && !equali(sLang, sLang_old))
set_vaultdata("server_language",sLang) {
set_cvar_string("amx_language",sLang) set_vaultdata("server_language", sLang)
g_serverLang = g_menuLang[id][1] set_cvar_string("amx_language", sLang)
format(lName,63,"%L",sLang,"LANG_NAME") g_serverLang = g_menuLang[id][1]
client_print(id,print_chat,"%L",pLang,"SET_LANG_SERVER",lName) format(lName, 63, "%L", sLang, "LANG_NAME")
} client_print(id, print_chat, "%L", pLang, "SET_LANG_SERVER", lName)
}
if ( !equali(pLang,pLang_old) && ( ( isAdmin && (key==2) ) || ( !isAdmin && (key==1) ) ) ) { if (!equali(pLang, pLang_old) && ((isAdmin && (key == 2)) || (!isAdmin && (key == 1))))
client_cmd(id,"setinfo ^"lang^" ^"%s^"",pLang) {
format(lName,63,"%L",pLang,"LANG_NAME") client_cmd(id, "setinfo ^"lang^" ^"%s^"", pLang)
client_print(id,print_chat,"%L",pLang,"SET_LANG_USER",lName) format(lName, 63, "%L", pLang, "LANG_NAME")
} client_print(id, print_chat, "%L", pLang, "SET_LANG_USER", lName)
}
return 0 return 0
} }
get_lang_id(lang[]) { get_lang_id(lang[])
new tLang[3] {
for (new i=0;i<g_langNum;i++) { new tLang[3]
get_lang(i,tLang)
if ( equali(tLang,lang) ) for (new i = 0; i < g_langNum; i++)
return i {
} get_lang(i, tLang)
if (equali(tLang, lang))
return i
}
return 0 return 0
} }

View File

@ -43,118 +43,150 @@ new g_nextMap[32]
new g_mapCycle[32] new g_mapCycle[32]
new g_pos new g_pos
public plugin_init() { public plugin_init()
register_plugin("NextMap",AMXX_VERSION_STR,"AMXX Dev Team") {
register_dictionary("nextmap.txt") register_plugin("NextMap", AMXX_VERSION_STR, "AMXX Dev Team")
register_event("30","changeMap","a") register_dictionary("nextmap.txt")
register_clcmd("say nextmap","sayNextMap",0,"- displays nextmap") register_event("30", "changeMap", "a")
register_cvar("amx_nextmap","",FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_SPONLY) register_clcmd("say nextmap", "sayNextMap", 0, "- displays nextmap")
register_cvar("amx_nextmap", "", FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_SPONLY)
new szString[32], szString2[32], szString3[8] new szString[32], szString2[32], szString3[8]
get_localinfo( "lastmapcycle", szString , 31 )
parse( szString, szString2, 31, szString3 , 7 ) get_localinfo("lastmapcycle", szString, 31)
g_pos = str_to_num( szString3 ) parse(szString, szString2, 31, szString3, 7)
get_cvar_string( "mapcyclefile" , g_mapCycle , 31 ) g_pos = str_to_num(szString3)
get_cvar_string("mapcyclefile", g_mapCycle, 31)
if ( !equal( g_mapCycle , szString2 ) ) if (!equal(g_mapCycle, szString2))
g_pos = 0 // mapcyclefile has been changed - go from first g_pos = 0 // mapcyclefile has been changed - go from first
readMapCycle( g_mapCycle , g_nextMap , 31 ) readMapCycle(g_mapCycle, g_nextMap, 31)
set_cvar_string( "amx_nextmap", g_nextMap ) set_cvar_string("amx_nextmap", g_nextMap)
format( szString3 , 31, "%s %d", g_mapCycle , g_pos ) // save lastmapcycle settings format(szString3, 31, "%s %d", g_mapCycle, g_pos) // save lastmapcycle settings
set_localinfo( "lastmapcycle", szString3 ) set_localinfo("lastmapcycle", szString3)
} }
getNextMapName(szArg[],iMax) { getNextMapName(szArg[], iMax)
new len = get_cvar_string("amx_nextmap",szArg,iMax) {
if ( is_map_valid(szArg) ) return len new len = get_cvar_string("amx_nextmap", szArg, iMax)
len = copy(szArg,iMax,g_nextMap)
set_cvar_string("amx_nextmap",g_nextMap) if (is_map_valid(szArg)) return len
return len len = copy(szArg, iMax, g_nextMap)
set_cvar_string("amx_nextmap", g_nextMap)
return len
} }
public sayNextMap() { public sayNextMap()
new name[32] {
getNextMapName(name,31) new name[32]
client_print(0,print_chat,"%L %s",LANG_PLAYER,"NEXT_MAP",name)
getNextMapName(name, 31)
client_print(0, print_chat, "%L %s", LANG_PLAYER, "NEXT_MAP", name)
} }
public delayedChange( param[] ) { public delayedChange(param[])
set_cvar_float("mp_chattime",get_cvar_float("mp_chattime")-2.0) {
server_cmd( "changelevel %s", param ) set_cvar_float("mp_chattime", get_cvar_float("mp_chattime") - 2.0)
server_cmd("changelevel %s", param)
} }
public changeMap() { public changeMap()
new string[32] {
new Float:chattime = get_cvar_float("mp_chattime") new string[32]
set_cvar_float( "mp_chattime" , chattime + 2.0 ) // make sure mp_chattime is long new Float:chattime = get_cvar_float("mp_chattime")
new len = getNextMapName(string, 31) + 1
set_task( chattime , "delayedChange" , 0 , string , len ) // change with 1.5 sec. delay set_cvar_float("mp_chattime", chattime + 2.0) // make sure mp_chattime is long
new len = getNextMapName(string, 31) + 1
set_task(chattime, "delayedChange", 0, string, len) // change with 1.5 sec. delay
} }
new g_warning[] = "WARNING: Couldn't find a valid map or the file doesn't exist (file ^"%s^")" new g_warning[] = "WARNING: Couldn't find a valid map or the file doesn't exist (file ^"%s^")"
#if defined OBEY_MAPCYCLE #if defined OBEY_MAPCYCLE
readMapCycle(szFileName[], szNext[], iNext)
{
new b, i = 0, iMaps = 0
new szBuffer[32], szFirst[32]
readMapCycle(szFileName[], szNext[], iNext ) { if (file_exists(szFileName))
new b, i = 0, iMaps = 0 {
new szBuffer[32], szFirst[32] while (read_file(szFileName, i++, szBuffer, 31, b))
if ( file_exists( szFileName ) ) { {
while( read_file( szFileName , i++ , szBuffer , 31 , b ) ) { if (!isalnum(szBuffer[0]) || !is_map_valid(szBuffer)) continue
if ( !isalnum( szBuffer[0] ) || !is_map_valid( szBuffer ) ) continue if (!iMaps)
if ( !iMaps ) copy( szFirst, 31, szBuffer ) copy(szFirst, 31, szBuffer)
if ( ++iMaps > g_pos ) {
copy( szNext , iNext , szBuffer ) if (++iMaps > g_pos)
g_pos = iMaps {
return copy(szNext, iNext, szBuffer)
} g_pos = iMaps
} return
} }
if ( !iMaps ) { }
log_amx( g_warning , szFileName ) }
get_mapname( szFirst , 31 )
} if (!iMaps)
copy( szNext , iNext , szFirst ) {
g_pos = 1 log_amx(g_warning, szFileName)
get_mapname(szFirst, 31)
}
copy(szNext, iNext, szFirst)
g_pos = 1
} }
#else #else
readMapCycle(szFileName[], szNext[], iNext ) { readMapCycle(szFileName[], szNext[], iNext)
new b, i = 0, iMaps = 0 {
new szBuffer[32], szFirst[32], szCurrent[32] new b, i = 0, iMaps = 0
get_mapname( szCurrent , 31 ) new szBuffer[32], szFirst[32], szCurrent[32]
new a = g_pos
get_mapname(szCurrent, 31)
new a = g_pos
if ( file_exists( szFileName ) ) { if (file_exists(szFileName))
while( read_file( szFileName , i++ , szBuffer , 31 , b ) ) { {
if ( !isalnum( szBuffer[0] ) || !is_map_valid( szBuffer ) ) continue while (read_file(szFileName, i++, szBuffer, 31, b))
if ( !iMaps ) { {
iMaps = 1 if (!isalnum(szBuffer[0]) || !is_map_valid(szBuffer)) continue
copy( szFirst, 31, szBuffer )
} if (!iMaps)
if ( iMaps == 1 ) { {
if ( equali( szCurrent , szBuffer ) ) { iMaps = 1
if ( a-- == 0 ) copy(szFirst, 31, szBuffer)
iMaps = 2 }
}
} if (iMaps == 1)
else { {
if ( equali( szCurrent , szBuffer ) ) if (equali(szCurrent, szBuffer))
++g_pos {
else if (a-- == 0)
g_pos = 0 iMaps = 2
copy( szNext , iNext , szBuffer ) }
return } else {
} if (equali(szCurrent, szBuffer))
} ++g_pos
} else
if ( !iMaps ) { g_pos = 0
log_amx( g_warning , szFileName )
copy( szNext ,iNext , szCurrent ) copy(szNext, iNext, szBuffer)
} return
else copy( szNext ,iNext , szFirst ) }
g_pos = 0 }
}
if (!iMaps)
{
log_amx(g_warning, szFileName)
copy(szNext, iNext, szCurrent)
}
else
copy(szNext, iNext, szFirst)
g_pos = 0
} }
#endif
#endif

View File

@ -50,347 +50,465 @@ new g_addCmd[] = "amx_pausecfg add ^"%s^""
new g_system[MAX_SYSTEM] new g_system[MAX_SYSTEM]
new g_systemNum new g_systemNum
public plugin_init() { public plugin_init()
register_plugin("Pause Plugins",AMXX_VERSION_STR,"AMXX Dev Team") {
register_dictionary("pausecfg.txt") register_plugin("Pause Plugins", AMXX_VERSION_STR, "AMXX Dev Team")
register_dictionary("common.txt") register_dictionary("pausecfg.txt")
register_dictionary("admincmd.txt") register_dictionary("common.txt")
register_concmd("amx_pausecfg","cmdPlugin",ADMIN_CFG,"- list commands for pause/unpause managment") register_dictionary("admincmd.txt")
register_clcmd("amx_pausecfgmenu","cmdMenu",ADMIN_CFG,"- pause/unpause plugins with menu")
register_concmd("amx_pausecfg", "cmdPlugin", ADMIN_CFG, "- list commands for pause/unpause managment")
register_clcmd("amx_pausecfgmenu", "cmdMenu", ADMIN_CFG, "- pause/unpause plugins with menu")
#if defined DIRECT_ONOFF #if defined DIRECT_ONOFF
register_concmd("amx_off","cmdOFF",ADMIN_CFG,"- pauses some plugins") register_concmd("amx_off", "cmdOFF", ADMIN_CFG, "- pauses some plugins")
register_concmd("amx_on","cmdON",ADMIN_CFG,"- unpauses some plugins") register_concmd("amx_on", "cmdON", ADMIN_CFG, "- unpauses some plugins")
#endif #endif
register_menucmd(register_menuid("Pause/Unpause Plugins"),1023,"actionMenu") register_menucmd(register_menuid("Pause/Unpause Plugins"), 1023, "actionMenu")
g_coloredMenus = colored_menus()
get_configsdir(g_fileToSave, 63); g_coloredMenus = colored_menus()
format(g_fileToSave, 63, "%s/pausecfg.ini", g_fileToSave); get_configsdir(g_fileToSave, 63);
format(g_fileToSave, 63, "%s/pausecfg.ini", g_fileToSave);
return PLUGIN_CONTINUE return PLUGIN_CONTINUE
} }
#if defined DIRECT_ONOFF #if defined DIRECT_ONOFF
public cmdOFF(id, level, cid)
public cmdOFF(id,level,cid) { {
if (cmd_access(id,level,cid,1)) if (cmd_access(id, level, cid, 1))
pausePlugins(id) pausePlugins(id)
return PLUGIN_HANDLED
return PLUGIN_HANDLED
} }
public cmdON(id,level,cid) { public cmdON(id, level, cid)
if (cmd_access(id,level,cid,1)) {
unpausePlugins(id) if (cmd_access(id, level, cid, 1))
return PLUGIN_HANDLED unpausePlugins(id)
return PLUGIN_HANDLED
} }
#endif #endif
public plugin_cfg() { public plugin_cfg()
loadSettings(g_fileToSave) {
// Put here titles of plugins which you don't want to pause loadSettings(g_fileToSave)
server_cmd(g_addCmd, "Admin Base" )
server_cmd(g_addCmd, "Admin Base (SQL)" ) // Put here titles of plugins which you don't want to pause
server_cmd(g_addCmd, "Pause Plugins" ) server_cmd(g_addCmd, "Admin Base")
server_cmd(g_addCmd, "TimeLeft" ) server_cmd(g_addCmd, "Admin Base (SQL)")
server_cmd(g_addCmd, "NextMap" ) server_cmd(g_addCmd, "Pause Plugins")
server_cmd(g_addCmd, "Slots Reservation" ) server_cmd(g_addCmd, "TimeLeft")
server_cmd(g_addCmd, "NextMap")
server_cmd(g_addCmd, "Slots Reservation")
} }
public actionMenu(id,key) { public actionMenu(id, key)
switch (key) { {
case 6: { switch (key)
if (file_exists(g_fileToSave)){ {
delete_file(g_fileToSave) case 6:
client_print(id,print_chat,"* %L",id,"PAUSE_CONF_CLEARED") {
} if (file_exists(g_fileToSave))
else {
client_print(id,print_chat,"* %L",id,"PAUSE_ALR_CLEARED") delete_file(g_fileToSave)
displayMenu(id,g_menuPos[id]) client_print(id, print_chat, "* %L", id, "PAUSE_CONF_CLEARED")
} }
case 7: { else
if (saveSettings(g_fileToSave)){ client_print(id, print_chat, "* %L", id, "PAUSE_ALR_CLEARED")
g_Modified = 0
client_print(id,print_chat,"* %L",id,"PAUSE_CONF_SAVED") displayMenu(id, g_menuPos[id])
} }
else case 7:
client_print(id,print_chat,"* %L",id,"PAUSE_SAVE_FAILED") {
displayMenu(id,g_menuPos[id]) if (saveSettings(g_fileToSave))
} {
case 8: displayMenu(id,++g_menuPos[id]) g_Modified = 0
case 9: displayMenu(id,--g_menuPos[id]) client_print(id, print_chat, "* %L", id, "PAUSE_CONF_SAVED")
default:{ }
new option = g_menuPos[id] * 6 + key else
new file[32],status[2] client_print(id, print_chat, "* %L", id, "PAUSE_SAVE_FAILED")
get_plugin(option,file,31,status,0,status,0,status,0,status,1)
switch( status[0] ) { displayMenu(id, g_menuPos[id])
case 'r': pause("ac",file) }
case 'p': { case 8: displayMenu(id, ++g_menuPos[id])
g_Modified = 1 case 9: displayMenu(id, --g_menuPos[id])
pause("dc",file) default:
} {
case 's': { new option = g_menuPos[id] * 6 + key
g_Modified = 1 new file[32], status[2]
unpause("ac",file)
} get_plugin(option, file, 31, status, 0, status, 0, status, 0, status, 1)
}
displayMenu(id,g_menuPos[id]) switch (status[0])
} {
} case 'r': pause("ac", file)
return PLUGIN_HANDLED case 'p':
{
g_Modified = 1
pause("dc", file)
}
case 's':
{
g_Modified = 1
unpause("ac", file)
}
}
displayMenu(id, g_menuPos[id])
}
}
return PLUGIN_HANDLED
} }
getStatus( id, code, &statusCode, lStatus[], lLen ) { getStatus(id, code, &statusCode, lStatus[], lLen)
switch (code) { {
case 'r': { switch (code)
statusCode = 'O' {
format( lStatus, lLen, "%L", id, "ON" ) case 'r':
} {
case 's': { statusCode = 'O'
statusCode = 'S' format(lStatus, lLen, "%L", id, "ON")
format( lStatus, lLen, "%L", id, "STOPPED" ) }
} case 's':
case 'p': { {
statusCode = 'O' statusCode = 'S'
format( lStatus, lLen, "%L", id, "OFF" ) format(lStatus, lLen, "%L", id, "STOPPED")
} }
case 'b': { case 'p':
statusCode = 'E' {
format( lStatus, lLen, "%L", id, "ERROR" ) statusCode = 'O'
} format(lStatus, lLen, "%L", id, "OFF")
default: { }
statusCode = 'L' case 'b':
format( lStatus, lLen, "%L", id, "LOCKED" ) {
} statusCode = 'E'
} format(lStatus, lLen, "%L", id, "ERROR")
}
default:
{
statusCode = 'L'
format(lStatus, lLen, "%L", id, "LOCKED")
}
}
} }
isSystem( id ) { isSystem(id)
for( new a = 0; a < g_systemNum; ++a) {
if ( g_system[ a ] == id ) for (new a = 0; a < g_systemNum; ++a)
return 1 if (g_system[a] == id)
return 0 return 1
return 0
} }
displayMenu(id, pos) { displayMenu(id, pos)
if (pos < 0) return {
new filename[32],title[32],status[8],statusCode if (pos < 0) return
new datanum = get_pluginsnum()
new menu_body[512], start = pos * 6, k = 0 new filename[32], title[32], status[8], statusCode
if (start >= datanum) start = pos = g_menuPos[id] = 0 new datanum = get_pluginsnum()
new len = format(menu_body,511, new menu_body[512], start = pos * 6, k = 0
g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%L %d/%d^n^n",
id,"PAUSE_UNPAUSE",pos + 1,((datanum/6)+((datanum%6)?1:0))) if (start >= datanum)
new end = start + 6, keys = MENU_KEY_0|MENU_KEY_8|MENU_KEY_7 start = pos = g_menuPos[id] = 0
if (end > datanum) end = datanum
for (new a = start; a < end; ++a) { new len = format(menu_body, 511, g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%L %d/%d^n^n", id, "PAUSE_UNPAUSE", pos + 1, ((datanum / 6) + ((datanum % 6) ? 1 : 0)))
get_plugin(a,filename,31,title,31,status,0,status,0,status,1) new end = start + 6, keys = MENU_KEY_0|MENU_KEY_8|MENU_KEY_7
getStatus( id, status[0], statusCode, status, 7 )
if ( isSystem( a ) || (statusCode!='O'&&statusCode!='S')) { if (end > datanum)
if ( g_coloredMenus ) { end = datanum
len += format(menu_body[len],511-len, "\d%d. %s\R%s^n\w",++k, title, status )
} for (new a = start; a < end; ++a)
else{ {
++k get_plugin(a, filename, 31, title, 31, status, 0, status, 0, status, 1)
len += format(menu_body[len],511-len, "#. %s %s^n", title, status ) getStatus(id, status[0], statusCode, status, 7)
}
} if (isSystem(a) || (statusCode != 'O' && statusCode != 'S'))
else{ {
keys |= (1<<k) if (g_coloredMenus)
len += format(menu_body[len],511-len,g_coloredMenus ? "%d. %s\y\R%s^n\w" : "%d. %s %s^n",++k,title, status ) {
} len += format(menu_body[len], 511-len, "\d%d. %s\R%s^n\w", ++k, title, status)
} } else {
len += format(menu_body[len],511-len,"^n7. %L^n",id,"CLEAR_STOPPED") ++k
len += format(menu_body[len],511-len,g_coloredMenus ? "8. %L \y\R%s^n\w" len += format(menu_body[len], 511-len, "#. %s %s^n", title, status)
: "8. %L %s^n", id, "SAVE_STOPPED", g_Modified ? "*" : "") }
if (end != datanum){ } else {
format(menu_body[len],511-len,"^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT") keys |= (1<<k)
keys |= MENU_KEY_9 len += format(menu_body[len], 511-len, g_coloredMenus ? "%d. %s\y\R%s^n\w" : "%d. %s %s^n", ++k, title, status)
} }
else format(menu_body[len],511-len,"^n0. %L", id, pos ? "BACK" : "EXIT") }
show_menu(id,keys,menu_body,-1,"Pause/Unpause Plugins")
len += format(menu_body[len], 511-len, "^n7. %L^n", id, "CLEAR_STOPPED")
len += format(menu_body[len], 511-len, g_coloredMenus ? "8. %L \y\R%s^n\w" : "8. %L %s^n", id, "SAVE_STOPPED", g_Modified ? "*" : "")
if (end != datanum)
{
format(menu_body[len], 511-len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
keys |= MENU_KEY_9
}
else
format(menu_body[len], 511-len, "^n0. %L", id, pos ? "BACK" : "EXIT")
show_menu(id, keys, menu_body, -1, "Pause/Unpause Plugins")
} }
public cmdMenu(id,level,cid) { public cmdMenu(id, level, cid)
if (cmd_access(id,level,cid,1)) {
displayMenu(id,g_menuPos[id] = 0) if (cmd_access(id, level, cid, 1))
return PLUGIN_HANDLED displayMenu(id, g_menuPos[id] = 0)
return PLUGIN_HANDLED
} }
pausePlugins(id) { pausePlugins(id)
new filename[32],title[32],status[2] {
new count = 0, imax = get_pluginsnum() new filename[32], title[32], status[2]
for (new a=0;a<imax;++a){ new count = 0, imax = get_pluginsnum()
get_plugin(a,filename,31,title,31,status,0,status,0,status,1)
if ( !isSystem( a ) && status[0]=='r' && pause("ac",filename) ) { for (new a = 0; a < imax; ++a)
//console_print(id,"Pausing %s (file ^"%s^")",title,filename) {
++count get_plugin(a, filename, 31, title, 31, status, 0, status, 0, status, 1)
}
} if (!isSystem(a) && status[0] == 'r' && pause("ac", filename))
console_print(id,"%L",id,(count==1)?"PAUSED_PLUGIN":"PAUSED_PLUGINS",count) {
//console_print(id, "Pausing %s (file ^"%s^")", title, filename)
++count
}
}
console_print(id, "%L", id, (count == 1) ? "PAUSED_PLUGIN" : "PAUSED_PLUGINS", count)
} }
unpausePlugins(id) { unpausePlugins(id)
new filename[32],title[32],status[2] {
new count = 0, imax = get_pluginsnum() new filename[32], title[32], status[2]
for (new a=0;a<imax;++a){ new count = 0, imax = get_pluginsnum()
get_plugin(a,filename,31,title,31,status,0,status,0,status,1)
if ( !isSystem( a ) && status[0]=='p' && unpause("ac",filename) ) { for (new a = 0; a < imax; ++a)
//console_print(id,"Unpausing %s (file ^"%s^")",title,filename) {
++count get_plugin(a, filename, 31, title, 31, status, 0, status, 0, status, 1)
}
} if (!isSystem(a) && status[0] == 'p' && unpause("ac", filename))
console_print(id,"%L",id,(count==1)?"UNPAUSED_PLUGIN":"UNPAUSED_PLUGINS",count) {
//console_print(id, "Unpausing %s (file ^"%s^")", title, filename)
++count
}
}
console_print(id, "%L", id, (count == 1) ? "UNPAUSED_PLUGIN" : "UNPAUSED_PLUGINS", count)
} }
findPluginByFile(arg[32],&len) { findPluginByFile(arg[32], &len)
new name[32],title[32],status[2] {
new inum = get_pluginsnum() new name[32], title[32], status[2]
for(new a = 0; a < inum; ++a){ new inum = get_pluginsnum()
get_plugin(a,name,31,title,31,status,0,status,0,status,1)
if ( equali(name,arg,len) && (status[0]=='r'||status[0]=='p'||status[0]=='s') ){ for (new a = 0; a < inum; ++a)
len = copy(arg,31,name) {
return a get_plugin(a, name, 31, title, 31, status, 0, status, 0, status, 1)
}
} if (equali(name, arg, len) && (status[0] == 'r' || status[0] == 'p' || status[0] == 's'))
return -1 {
len = copy(arg, 31, name)
return a
}
}
return -1
} }
findPluginByTitle(name[],file[],len) { findPluginByTitle(name[], file[], len)
new title[32],status[2] {
new inum = get_pluginsnum() new title[32], status[2]
for (new a = 0; a < inum; ++a) { new inum = get_pluginsnum()
get_plugin(a,file,len,title,31,status,0,status,0,status,1)
if ( equali( title , name ) ) for (new a = 0; a < inum; ++a)
return a {
} get_plugin(a, file, len, title, 31, status, 0, status, 0, status, 1)
return -1
if (equali(title, name))
return a
}
return -1
} }
public cmdPlugin(id,level,cid) { public cmdPlugin(id, level, cid)
if (!cmd_access(id,level,cid,1)) {
return PLUGIN_HANDLED if (!cmd_access(id, level, cid, 1))
new cmds[32] return PLUGIN_HANDLED
read_argv(1,cmds,31)
if ( equal(cmds, "add" ) && read_argc() > 2 ) { new cmds[32]
read_argv(2, cmds ,31) read_argv(1, cmds, 31)
new file[2]
if ( (g_system[ g_systemNum ] = findPluginByTitle( cmds , file , 0 )) != -1 ) { if (equal(cmds, "add") && read_argc() > 2)
if ( g_systemNum < MAX_SYSTEM ) {
g_systemNum++ read_argv(2, cmds, 31)
else new file[2]
console_print( id, "%L", id, "CANT_MARK_MORE" )
} if ((g_system[g_systemNum] = findPluginByTitle(cmds, file, 0)) != -1)
} {
else if ( equal(cmds, "off" ) ) { if (g_systemNum < MAX_SYSTEM)
pausePlugins(id) g_systemNum++
} else
else if ( equal(cmds, "on" ) ) { console_print(id, "%L", id, "CANT_MARK_MORE")
unpausePlugins(id) }
} }
else if ( equal(cmds, "save" ) ) { else if (equal(cmds, "off"))
if (saveSettings(g_fileToSave)) { {
g_Modified = 0 pausePlugins(id)
console_print(id,"%L",id,"PAUSE_CONF_SAVED") }
} else if (equal(cmds, "on"))
else {
console_print(id,"%L",id,"PAUSE_SAVE_FAILED") unpausePlugins(id)
} }
else if ( equal(cmds, "clear" ) ) { else if (equal(cmds, "save"))
if (file_exists(g_fileToSave)){ {
delete_file(g_fileToSave) if (saveSettings(g_fileToSave))
console_print(id,"%L",id,"PAUSE_CONF_CLEARED") {
} g_Modified = 0
else console_print(id, "%L", id, "PAUSE_CONF_SAVED")
console_print(id,"%L",id,"PAUSE_ALR_CLEARED") }
} else
else if ( equal(cmds, "pause" ) ) { console_print(id, "%L", id, "PAUSE_SAVE_FAILED")
new arg[32], a ,len = read_argv(2,arg,31) }
if ( len && ((a = findPluginByFile(arg,len)) != -1) && !isSystem( a ) && pause("ac",arg) ) else if (equal(cmds, "clear"))
console_print(id,"%L %L",id,"PAUSE_PLUGIN_MATCH",arg,id,"PAUSED") {
else console_print(id,"%L",id,"PAUSE_COULDNT_FIND",arg) if (file_exists(g_fileToSave))
} {
else if ( equal(cmds, "enable" ) ) { delete_file(g_fileToSave)
new arg[32], a , len = read_argv(2,arg,31) console_print(id, "%L", id, "PAUSE_CONF_CLEARED")
if ( len && (a = findPluginByFile(arg,len)) != -1 && !isSystem( a ) && unpause("ac",arg) ) }
console_print(id,"%L %L",id,"PAUSE_PLUGIN_MATCH",arg,id,"UNPAUSED") else
else console_print(id,"%L",id,"PAUSE_COULDNT_FIND",arg) console_print(id, "%L", id, "PAUSE_ALR_CLEARED")
} }
else if ( equal(cmds, "stop" ) ) { else if (equal(cmds, "pause"))
new arg[32], a, len = read_argv(2,arg,31) {
if ( len && (a = findPluginByFile(arg,len)) != -1 && !isSystem( a ) && pause("dc",arg)){ new arg[32], a, len = read_argv(2, arg, 31)
g_Modified = 1
console_print(id,"%L %L",id,"PAUSE_PLUGIN_MATCH",arg,id,"STOPPED") if (len && ((a = findPluginByFile(arg, len)) != -1) && !isSystem(a) && pause("ac", arg))
} console_print(id, "%L %L", id, "PAUSE_PLUGIN_MATCH", arg, id, "PAUSED")
else console_print(id,"%L",id,"PAUSE_COULDNT_FIND",arg) else
} console_print(id, "%L", id, "PAUSE_COULDNT_FIND", arg)
else if ( equal(cmds, "list" ) ) { }
new lName[32],lVersion[32],lAuthor[32],lFile[32],lStatus[32] else if (equal(cmds, "enable"))
format(lName,31,"%L",id,"NAME") {
format(lVersion,31,"%L",id,"VERSION") new arg[32], a, len = read_argv(2, arg, 31)
format(lAuthor,31,"%L",id,"AUTHOR")
format(lFile,31,"%L",id,"FILE") if (len && (a = findPluginByFile(arg, len)) != -1 && !isSystem(a) && unpause("ac", arg))
format(lStatus,31,"%L",id,"STATUS") console_print(id, "%L %L", id, "PAUSE_PLUGIN_MATCH", arg, id, "UNPAUSED")
new arg1[8], running = 0 else
new start = read_argv(2,arg1,7) ? str_to_num(arg1) : 1 console_print(id, "%L", id, "PAUSE_COULDNT_FIND", arg)
if (--start < 0) start = 0 }
new plgnum = get_pluginsnum() else if (equal(cmds, "stop"))
if (start >= plgnum) start = plgnum - 1 {
console_print(id,"^n----- %L -----",id,"PAUSE_LOADED") new arg[32], a, len = read_argv(2, arg, 31)
console_print(id, " %-18.17s %-8.7s %-17.16s %-16.15s %-9.8s",lName,lVersion,lAuthor,lFile,lStatus)
new plugin[32],title[32],version[16],author[32],status[16] if (len && (a = findPluginByFile(arg, len)) != -1 && !isSystem(a) && pause("dc", arg))
new end = start + 10 {
if (end > plgnum) end = plgnum g_Modified = 1
for (new a = start; a < end; ++a) { console_print(id, "%L %L", id, "PAUSE_PLUGIN_MATCH", arg, id, "STOPPED")
get_plugin(a,plugin,31,title,31,version,15,author,31,status,15) }
if (status[0] == 'r') ++running else
console_print(id, " [%3d] %-18.17s %-8.7s %-17.16s %-16.15s %-9.8s",a+1,title,version,author,plugin, status ) console_print(id, "%L", id, "PAUSE_COULDNT_FIND", arg)
} }
console_print(id,"----- %L -----",id,"PAUSE_ENTRIES",start+1,end,plgnum,running) else if (equal(cmds, "list"))
if (end < plgnum) {
console_print(id,"----- %L -----",id,"PAUSE_USE_MORE",end+1) new lName[32], lVersion[32], lAuthor[32], lFile[32], lStatus[32]
else
console_print(id,"----- %L -----",id,"PAUSE_USE_BEGIN") format(lName, 31, "%L", id, "NAME")
} format(lVersion, 31, "%L", id, "VERSION")
else { format(lAuthor, 31, "%L", id, "AUTHOR")
console_print(id,"%L",id,"PAUSE_USAGE") format(lFile, 31, "%L", id, "FILE")
console_print(id,"%L:",id,"PAUSE_COMMANDS") format(lStatus, 31, "%L", id, "STATUS")
console_print(id,"%L",id,"COM_PAUSE_OFF")
console_print(id,"%L",id,"COM_PAUSE_ON") new arg1[8], running = 0
console_print(id,"%L",id,"COM_PAUSE_STOP") new start = read_argv(2, arg1, 7) ? str_to_num(arg1) : 1
console_print(id,"%L",id,"COM_PAUSE_PAUSE")
console_print(id,"%L",id,"COM_PAUSE_ENABLE") if (--start < 0)
console_print(id,"%L",id,"COM_PAUSE_SAVE") start = 0
console_print(id,"%L",id,"COM_PAUSE_CLEAR")
console_print(id,"%L",id,"COM_PAUSE_LIST") new plgnum = get_pluginsnum()
console_print(id,"%L",id,"COM_PAUSE_ADD")
} if (start >= plgnum)
return PLUGIN_HANDLED start = plgnum - 1
console_print(id, "^n----- %L -----", id, "PAUSE_LOADED")
console_print(id, " %-18.17s %-8.7s %-17.16s %-16.15s %-9.8s", lName, lVersion, lAuthor, lFile, lStatus)
new plugin[32], title[32], version[16], author[32], status[16]
new end = start + 10
if (end > plgnum) end = plgnum
for (new a = start; a < end; ++a)
{
get_plugin(a, plugin, 31, title, 31, version, 15, author, 31, status, 15)
if (status[0] == 'r') ++running
console_print(id, " [%3d] %-18.17s %-8.7s %-17.16s %-16.15s %-9.8s", a + 1, title, version, author, plugin, status)
}
console_print(id, "----- %L -----", id, "PAUSE_ENTRIES", start + 1, end, plgnum, running)
if (end < plgnum)
console_print(id, "----- %L -----", id, "PAUSE_USE_MORE", end + 1)
else
console_print(id, "----- %L -----", id, "PAUSE_USE_BEGIN")
} else {
console_print(id, "%L", id, "PAUSE_USAGE")
console_print(id, "%L:", id, "PAUSE_COMMANDS")
console_print(id, "%L", id, "COM_PAUSE_OFF")
console_print(id, "%L", id, "COM_PAUSE_ON")
console_print(id, "%L", id, "COM_PAUSE_STOP")
console_print(id, "%L", id, "COM_PAUSE_PAUSE")
console_print(id, "%L", id, "COM_PAUSE_ENABLE")
console_print(id, "%L", id, "COM_PAUSE_SAVE")
console_print(id, "%L", id, "COM_PAUSE_CLEAR")
console_print(id, "%L", id, "COM_PAUSE_LIST")
console_print(id, "%L", id, "COM_PAUSE_ADD")
}
return PLUGIN_HANDLED
} }
saveSettings(filename[]) { saveSettings(filename[])
if (file_exists(filename)) {
delete_file(filename) if (file_exists(filename))
new text[256], file[32],title[32],status[2] delete_file(filename)
new inum = get_pluginsnum()
if (!write_file(filename,";Generated by Pause Plugins Plugin. Do not modify!^n;Title Filename")) new text[256], file[32], title[32], status[2]
return 0 new inum = get_pluginsnum()
for (new a = 0; a < inum; ++a) {
get_plugin(a,file,31,title,31,status,0,status,0,status,1) if (!write_file(filename, ";Generated by Pause Plugins Plugin. Do not modify!^n;Title Filename"))
if ( status[0] == 's' ){ return 0
format(text,255,"^"%s^" ;%s",title,file)
write_file(filename,text) for (new a = 0; a < inum; ++a)
} {
} get_plugin(a, file, 31, title, 31, status, 0, status, 0, status, 1)
return 1
if (status[0] == 's')
{
format(text, 255, "^"%s^" ;%s", title, file)
write_file(filename, text)
}
}
return 1
} }
loadSettings(filename[]) { loadSettings(filename[])
if (!file_exists(filename)) return 0 {
new name[256], file[32], i, pos = 0 if (!file_exists(filename))
while (read_file(filename,pos++,name,255,i)){ return 0
if ( name[0]!= ';' && parse(name,name,31) &&
(i = findPluginByTitle( name , file , 31 ) != -1) ) new name[256], file[32], i, pos = 0
pause("dc", file )
} while (read_file(filename, pos++, name, 255, i))
return 1 {
if (name[0] != ';' && parse(name, name, 31) && (i = findPluginByTitle(name, file, 31) != -1))
pause("dc", file)
}
return 1
} }

File diff suppressed because it is too large Load Diff

View File

@ -45,64 +45,80 @@ new Float:g_xPos
new g_Length new g_Length
new g_Frequency new g_Frequency
public plugin_init() { public plugin_init()
register_plugin("Scrolling Message",AMXX_VERSION_STR,"AMXX Dev Team") {
register_dictionary("scrollmsg.txt") register_plugin("Scrolling Message", AMXX_VERSION_STR, "AMXX Dev Team")
register_dictionary("common.txt") register_dictionary("scrollmsg.txt")
register_srvcmd("amx_scrollmsg","setMessage") register_dictionary("common.txt")
register_srvcmd("amx_scrollmsg", "setMessage")
} }
public showMsg() { public showMsg()
new a = g_startPos, i = 0 {
new a = g_startPos, i = 0
while( a < g_endPos ) while (a < g_endPos)
g_displayMsg[i++] = g_scrollMsg[a++] g_displayMsg[i++] = g_scrollMsg[a++]
g_displayMsg[i] = 0 g_displayMsg[i] = 0
if (g_endPos < g_Length) if (g_endPos < g_Length)
g_endPos++ g_endPos++
if (g_xPos > 0.35) if (g_xPos > 0.35)
g_xPos -= 0.0063 g_xPos -= 0.0063
else { else
g_startPos++ {
g_xPos = 0.35 g_startPos++
} g_xPos = 0.35
}
set_hudmessage(200, 100, 0, g_xPos, 0.90, 0, SPEED, SPEED, 0.05, 0.05, 2) set_hudmessage(200, 100, 0, g_xPos, 0.90, 0, SPEED, SPEED, 0.05, 0.05, 2)
show_hudmessage(0,g_displayMsg) show_hudmessage(0, g_displayMsg)
} }
public msgInit() { public msgInit()
g_endPos = 1 {
g_startPos = 0 g_endPos = 1
g_xPos = 0.65 g_startPos = 0
set_task( SPEED , "showMsg",123,"",0,"a", g_Length + 48) g_xPos = 0.65
client_print(0,print_console,g_scrollMsg)
set_task(SPEED, "showMsg", 123, "", 0, "a", g_Length + 48)
client_print(0, print_console, g_scrollMsg)
} }
public setMessage() { public setMessage()
remove_task(123) /* remove current messaging */ {
read_argv(1,g_scrollMsg,380) remove_task(123) /* remove current messaging */
new hostname[64] read_argv(1, g_scrollMsg, 380)
get_cvar_string("hostname",hostname,63)
replace(g_scrollMsg,380,"%hostname%",hostname) new hostname[64]
g_Length = strlen(g_scrollMsg)
new mytime[32] get_cvar_string("hostname", hostname, 63)
read_argv(2,mytime,31) replace(g_scrollMsg, 380, "%hostname%", hostname)
g_Frequency = str_to_num(mytime) g_Length = strlen(g_scrollMsg)
if (g_Frequency > 0) {
new minimal = floatround((g_Length + 48) * (SPEED + 0.1)) new mytime[32]
if (g_Frequency < minimal) {
server_print("%L",LANG_SERVER,"MIN_FREQ",minimal) read_argv(2, mytime, 31)
g_Frequency = minimal
} g_Frequency = str_to_num(mytime)
server_print("%L",LANG_SERVER,"MSG_FREQ",
g_Frequency/60,g_Frequency%60) if (g_Frequency > 0)
set_task(float(g_Frequency),"msgInit",123,"",0,"b") {
} new minimal = floatround((g_Length + 48) * (SPEED + 0.1))
else
server_print("%L",LANG_SERVER,"MSG_DISABLED") if (g_Frequency < minimal)
return PLUGIN_HANDLED {
server_print("%L", LANG_SERVER, "MIN_FREQ", minimal)
g_Frequency = minimal
}
server_print("%L", LANG_SERVER, "MSG_FREQ", g_Frequency / 60, g_Frequency % 60)
set_task(float(g_Frequency), "msgInit", 123, "", 0, "b")
}
else
server_print("%L", LANG_SERVER, "MSG_DISABLED")
return PLUGIN_HANDLED
} }

View File

@ -45,196 +45,266 @@ new g_menuPosition[33]
new g_fileToSave[64] new g_fileToSave[64]
new bool:g_modified new bool:g_modified
public plugin_precache() { public plugin_precache()
register_clcmd("amx_statscfgmenu","cmdCfgMenu",ADMIN_CFG,"- displays stats configuration menu") {
register_dictionary("statscfg.txt") register_clcmd("amx_statscfgmenu", "cmdCfgMenu", ADMIN_CFG, "- displays stats configuration menu")
register_dictionary("common.txt") register_dictionary("statscfg.txt")
register_concmd("amx_statscfg","cmdCfg",ADMIN_CFG,"- displays help for stats configuration") register_dictionary("common.txt")
register_concmd("amx_statscfg", "cmdCfg", ADMIN_CFG, "- displays help for stats configuration")
} }
public plugin_init() { public plugin_init()
register_plugin("Stats Configuration",AMXX_VERSION_STR,"AMXX Dev Team") {
register_menucmd(register_menuid("Stats Configuration"),1023,"actionCfgMenu") register_plugin("Stats Configuration", AMXX_VERSION_STR, "AMXX Dev Team")
get_configsdir(g_fileToSave, 63) register_menucmd(register_menuid("Stats Configuration"), 1023, "actionCfgMenu")
format(g_fileToSave, 63, "%s/stats.ini", g_fileToSave)
loadSettings(g_fileToSave) get_configsdir(g_fileToSave, 63)
format(g_fileToSave, 63, "%s/stats.ini", g_fileToSave)
loadSettings(g_fileToSave)
} }
public cmdCfg( id,level,cid ) { public cmdCfg(id, level, cid)
if (!cmd_access(id,level,cid,1)) {
return PLUGIN_HANDLED if (!cmd_access(id, level, cid, 1))
return PLUGIN_HANDLED
new cmds[32] new cmds[32]
read_argv(1,cmds,31) read_argv(1, cmds, 31)
new option = equali(cmds, "on" ) ? 1 : 0
if ( !option ) option = equali(cmds, "off" ) ? 2 : 0 new option = equali(cmds, "on") ? 1 : 0
if ( read_argc() > 2 && option ) {
new var[32], enabled = 0
read_argv( 2 , var , 31 )
for ( new a = 0; a < g_menuDataNum; ++a ) {
if ( containi( g_menuDataVar[ a ] , var ) != -1 ) {
g_modified = true
++enabled
if ( option == 1 ) {
set_xvar_num( g_menuDataId[a] , 1 )
console_print(id,"%L: %s", id, "STATS_ENABLED", g_menuData[a] )
}
else {
set_xvar_num( g_menuDataId[a] , 0 )
console_print(id,"%L: %s", id, "STATS_DISABLED", g_menuData[a] )
}
}
}
if ( enabled )
console_print(id,"%L", id, "TOTAL_NUM", enabled )
else
console_print(id,"%L",id,"NO_OPTION", var )
}
else if ( equali(cmds, "save" ) ) {
if ( saveSettings( g_fileToSave ) ){
g_modified = false
console_print(id,"%L",id,"STATS_CONF_SAVED")
}
else
console_print(id,"%L",id,"STATS_CONF_FAILED")
}
else if ( equali(cmds, "load" ) ) {
if ( loadSettings( g_fileToSave ) ){
g_modified = false
console_print(id,"%L",id,"STATS_CONF_LOADED")
}
else
console_print(id,"%L",id,"STATS_CONF_FAIL_LOAD")
}
else if ( equali(cmds, "list" ) ) {
new arg1[8]
new start = read_argv(2,arg1,7) ? str_to_num(arg1) : 1
if (--start < 0) start = 0
if (start >= g_menuDataNum) start = g_menuDataNum - 1
new end = start + 10
if (end > g_menuDataNum) end = g_menuDataNum
new lName[16],lVariable[16],lStatus[16] if (!option)
format(lName,15,"%L",id,"NAME") option = equali(cmds, "off") ? 2 : 0
format(lVariable,15,"%L",id,"VARIABLE")
format(lStatus,15,"%L",id,"STATUS") if (read_argc() > 2 && option)
console_print(id, "^n----- %L: -----",id,"STATS_CONF") {
console_print(id, " %-29.28s %-24.23s %-9.8s",lName,lVariable,lStatus) new var[32], enabled = 0
if ( start != -1 ) { read_argv(2, var, 31)
new lOnOff[16]
for (new a = start; a < end; ++a) { for (new a = 0; a < g_menuDataNum; ++a)
format(lOnOff,15,"%L",id,get_xvar_num( g_menuDataId[ a ] ) ? "ON" : "OFF") {
console_print(id, "%3d: %-29.28s %-24.23s %-9.8s",a + 1, if (containi(g_menuDataVar[a], var) != -1)
g_menuData[a], g_menuDataVar[a], lOnOff) {
} g_modified = true
} ++enabled
console_print(id,"----- %L -----",id,"STATS_ENTRIES_OF",start+1,end,g_menuDataNum) if (option == 1)
if (end < g_menuDataNum) {
console_print(id,"----- %L -----",id,"STATS_USE_MORE",end+1) set_xvar_num(g_menuDataId[a], 1)
else console_print(id, "%L: %s", id, "STATS_ENABLED", g_menuData[a])
console_print(id,"----- %L -----",id,"STATS_USE_BEGIN") } else {
} set_xvar_num(g_menuDataId[a], 0)
else if ( equali(cmds, "add" ) && read_argc() > 3 ) { console_print(id, "%L: %s", id, "STATS_DISABLED", g_menuData[a])
if ( g_menuDataNum < MAX_MENU_DATA ) { }
read_argv(2, g_menuData[g_menuDataNum] , 31 ) }
read_argv(3, g_menuDataVar[g_menuDataNum] , 31 ) }
g_menuDataId[g_menuDataNum] = get_xvar_id( g_menuDataVar[g_menuDataNum] )
++g_menuDataNum if (enabled)
} console_print(id, "%L", id, "TOTAL_NUM", enabled)
else console_print(id, "%L",id,"CANT_ADD_STATS") else
} console_print(id, "%L", id, "NO_OPTION", var)
else { }
console_print(id,"%L",id,"COM_STATS_USAGE") else if (equali(cmds, "save"))
console_print(id,"%L",id,"COM_STATS_COM") {
console_print(id,"%L",id,"COM_STATS_ON") if (saveSettings(g_fileToSave))
console_print(id,"%L",id,"COM_STATS_OFF") {
console_print(id,"%L",id,"COM_STATS_SAVE") g_modified = false
console_print(id,"%L",id,"COM_STATS_LOAD") console_print(id, "%L", id, "STATS_CONF_SAVED")
console_print(id,"%L",id,"COM_STATS_LIST") }
console_print(id,"%L",id,"COM_STATS_ADD") else
} console_print(id, "%L", id, "STATS_CONF_FAILED")
}
else if (equali(cmds, "load"))
{
if (loadSettings(g_fileToSave))
{
g_modified = false
console_print(id, "%L", id, "STATS_CONF_LOADED")
}
else
console_print(id, "%L", id, "STATS_CONF_FAIL_LOAD")
}
else if (equali(cmds, "list"))
{
new arg1[8]
new start = read_argv(2, arg1, 7) ? str_to_num(arg1) : 1
return PLUGIN_HANDLED if (--start < 0) start = 0
if (start >= g_menuDataNum)
start = g_menuDataNum - 1
new end = start + 10
if (end > g_menuDataNum)
end = g_menuDataNum
new lName[16], lVariable[16], lStatus[16]
format(lName, 15, "%L", id, "NAME")
format(lVariable, 15, "%L", id, "VARIABLE")
format(lStatus, 15, "%L", id, "STATUS")
console_print(id, "^n----- %L: -----", id, "STATS_CONF")
console_print(id, " %-29.28s %-24.23s %-9.8s", lName, lVariable, lStatus)
if (start != -1)
{
new lOnOff[16]
for (new a = start; a < end; ++a)
{
format(lOnOff, 15, "%L", id, get_xvar_num(g_menuDataId[a]) ? "ON" : "OFF")
console_print(id, "%3d: %-29.28s %-24.23s %-9.8s", a + 1, g_menuData[a], g_menuDataVar[a], lOnOff)
}
}
console_print(id, "----- %L -----", id, "STATS_ENTRIES_OF", start + 1, end, g_menuDataNum)
if (end < g_menuDataNum)
console_print(id, "----- %L -----", id, "STATS_USE_MORE", end + 1)
else
console_print(id, "----- %L -----", id, "STATS_USE_BEGIN")
}
else if (equali(cmds, "add") && read_argc() > 3)
{
if (g_menuDataNum < MAX_MENU_DATA)
{
read_argv(2, g_menuData[g_menuDataNum], 31)
read_argv(3, g_menuDataVar[g_menuDataNum], 31)
g_menuDataId[g_menuDataNum] = get_xvar_id(g_menuDataVar[g_menuDataNum])
++g_menuDataNum
}
else
console_print(id, "%L", id, "CANT_ADD_STATS")
} else {
console_print(id, "%L", id, "COM_STATS_USAGE")
console_print(id, "%L", id, "COM_STATS_COM")
console_print(id, "%L", id, "COM_STATS_ON")
console_print(id, "%L", id, "COM_STATS_OFF")
console_print(id, "%L", id, "COM_STATS_SAVE")
console_print(id, "%L", id, "COM_STATS_LOAD")
console_print(id, "%L", id, "COM_STATS_LIST")
console_print(id, "%L", id, "COM_STATS_ADD")
}
return PLUGIN_HANDLED
} }
public cmdCfgMenu(id,level,cid) { public cmdCfgMenu(id, level, cid)
if (cmd_access(id,level,cid,1)) {
displayCfgMenu(id,g_menuPosition[id] = 0) if (cmd_access(id, level, cid, 1))
return PLUGIN_HANDLED displayCfgMenu(id, g_menuPosition[id] = 0)
return PLUGIN_HANDLED
} }
displayCfgMenu(id,pos) { displayCfgMenu(id, pos)
if (pos < 0) return {
new menu_body[512], start = pos * 7 if (pos < 0)
if (start >= g_menuDataNum) start = pos = g_menuPosition[id] = 0 return
new len = format(menu_body,511,"\y%L\R%d/%d^n\w^n",
id,"STATS_CONF",pos + 1,((g_menuDataNum/7)+((g_menuDataNum%7)?1:0))) new menu_body[512], start = pos * 7
new end = start + 7, keys = MENU_KEY_0|MENU_KEY_8, k = 0
if (end > g_menuDataNum) end = g_menuDataNum if (start >= g_menuDataNum)
for (new a = start; a < end; ++a) { start = pos = g_menuPosition[id] = 0
keys |= (1<<k)
len += format(menu_body[len],511-len,"%d. %s\y\R%L^n\w",++k, new len = format(menu_body, 511, "\y%L\R%d/%d^n\w^n", id, "STATS_CONF", pos + 1, ((g_menuDataNum / 7)+((g_menuDataNum % 7) ? 1 : 0)))
g_menuData[a], id, get_xvar_num( g_menuDataId[ a ] ) ? "ON" : "OFF" ) new end = start + 7, keys = MENU_KEY_0|MENU_KEY_8, k = 0
}
if ( g_menuDataNum == 0 ) if (end > g_menuDataNum)
len += format(menu_body[len],511-len,"\d%L\w",id,"NO_STATS") end = g_menuDataNum
len += format(menu_body[len],511-len,"^n8. %L\y\R%s^n\w",id,"SAVE_CONF",g_modified ? "*" : "")
if (end != g_menuDataNum) { for (new a = start; a < end; ++a)
format(menu_body[len],511-len,"^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT") {
keys |= MENU_KEY_9 keys |= (1<<k)
} len += format(menu_body[len], 511-len, "%d. %s\y\R%L^n\w", ++k, g_menuData[a], id, get_xvar_num(g_menuDataId[a]) ? "ON" : "OFF")
else format(menu_body[len],511-len,"^n0. %L", id, pos ? "BACK" : "EXIT") }
show_menu(id,keys,menu_body,-1,"Stats Configuration")
if (g_menuDataNum == 0)
len += format(menu_body[len], 511-len, "\d%L\w", id, "NO_STATS")
len += format(menu_body[len], 511-len, "^n8. %L\y\R%s^n\w", id, "SAVE_CONF", g_modified ? "*" : "")
if (end != g_menuDataNum)
{
format(menu_body[len], 511-len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
keys |= MENU_KEY_9
}
else
format(menu_body[len], 511-len, "^n0. %L", id, pos ? "BACK" : "EXIT")
show_menu(id, keys, menu_body, -1, "Stats Configuration")
} }
public actionCfgMenu(id,key) { public actionCfgMenu(id, key)
switch(key) { {
case 7: { switch (key)
if (saveSettings(g_fileToSave)) { {
g_modified = false case 7:
client_print(id,print_chat,"* %L",id,"STATS_CONF_SAVED") {
} if (saveSettings(g_fileToSave))
else {
client_print(id,print_chat,"* %L",id,"STATS_CONF_FAILED") g_modified = false
displayCfgMenu(id,g_menuPosition[id]) client_print(id, print_chat, "* %L", id, "STATS_CONF_SAVED")
} }
case 8: displayCfgMenu(id,++g_menuPosition[id]) else
case 9: displayCfgMenu(id,--g_menuPosition[id]) client_print(id, print_chat, "* %L", id, "STATS_CONF_FAILED")
default: {
g_modified = true displayCfgMenu(id, g_menuPosition[id])
new a = g_menuPosition[id] * 7 + key }
set_xvar_num( g_menuDataId[ a ] , 1 - get_xvar_num( g_menuDataId[ a ] ) ) case 8: displayCfgMenu(id, ++g_menuPosition[id])
displayCfgMenu( id , g_menuPosition[ id ] ) case 9: displayCfgMenu(id, --g_menuPosition[id])
} default:
} {
return PLUGIN_HANDLED g_modified = true
new a = g_menuPosition[id] * 7 + key
set_xvar_num(g_menuDataId[a], 1 - get_xvar_num(g_menuDataId[a]))
displayCfgMenu(id, g_menuPosition[id])
}
}
return PLUGIN_HANDLED
} }
saveSettings(filename[]) { saveSettings(filename[])
if (file_exists(filename)) {
delete_file(filename) if (file_exists(filename))
if (!write_file(filename,";Generated by Stats Configuration Plugin. Do not modify!^n;Variable Description")) delete_file(filename)
return 0
new text[256] if (!write_file(filename, ";Generated by Stats Configuration Plugin. Do not modify!^n;Variable Description"))
for(new a = 0; a < g_menuDataNum; ++a){ return 0
if ( get_xvar_num( g_menuDataId[ a ] ) ) {
format(text,255,"%-24.23s ;%s",g_menuDataVar[a],g_menuData[a]) new text[256]
write_file(filename,text)
} for (new a = 0; a < g_menuDataNum; ++a)
} {
return 1 if (get_xvar_num(g_menuDataId[a]))
{
format(text, 255, "%-24.23s ;%s", g_menuDataVar[a], g_menuData[a])
write_file(filename, text)
}
}
return 1
} }
loadSettings(filename[]) { loadSettings(filename[])
if (!file_exists(filename)) {
return 0 if (!file_exists(filename))
new text[256], name[32] return 0
new len, pos = 0, xid
while (read_file(filename,pos++,text,255,len)) { new text[256], name[32]
if ( text[0] == ';' ) continue // line is a comment new len, pos = 0, xid
parse( text , name , 31 )
if ( ( xid = get_xvar_id( name ) ) != -1 ) while (read_file(filename, pos++, text, 255, len))
set_xvar_num( xid , 1 ) {
} if (text[0] == ';') continue // line is a comment
return 1
parse(text, name, 31)
if ((xid = get_xvar_id(name)) != -1)
set_xvar_num(xid, 1)
}
return 1
} }

View File

@ -39,149 +39,161 @@
new g_menuPosition[33] new g_menuPosition[33]
new g_menuPlayers[33][32] new g_menuPlayers[33][32]
new g_menuPlayersNum[33] new g_menuPlayersNum[33]
new g_menuOption[33] = { -1 , ... } new g_menuOption[33] = {-1, ...}
new g_menuOrgin[33][3] new g_menuOrgin[33][3]
new g_coloredMenus new g_coloredMenus
public plugin_init() { public plugin_init()
register_plugin("Teleport Menu",AMXX_VERSION_STR,"AMXX Dev Team") {
register_dictionary("telemenu.txt") register_plugin("Teleport Menu", AMXX_VERSION_STR, "AMXX Dev Team")
register_dictionary("common.txt") register_dictionary("telemenu.txt")
register_clcmd("amx_teleportmenu","cmdTelMenu",ADMIN_CFG,"- displays teleport menu") register_dictionary("common.txt")
register_menucmd(register_menuid("Teleport Menu"),1023,"actionTelMenu") register_clcmd("amx_teleportmenu", "cmdTelMenu", ADMIN_CFG, "- displays teleport menu")
register_menucmd(register_menuid("Teleport Menu"), 1023, "actionTelMenu")
g_coloredMenus = colored_menus() g_coloredMenus = colored_menus()
} }
public actionTelMenu(id,key) { public actionTelMenu(id, key)
switch (key) { {
case 6: { switch (key)
g_menuOption[id] = 1 - g_menuOption[id] {
displayTelMenu(id,g_menuPosition[id]) case 6:
} {
case 7: { g_menuOption[id] = 1 - g_menuOption[id]
if (g_menuOption[id] < 0) /* unlocking position for the first time */ displayTelMenu(id, g_menuPosition[id])
g_menuOption[id] = 0 }
get_user_origin(id,g_menuOrgin[id]) case 7:
displayTelMenu(id,g_menuPosition[id]) {
} if (g_menuOption[id] < 0) /* unlocking position for the first time */
case 8: displayTelMenu(id,++g_menuPosition[id]) g_menuOption[id] = 0
case 9: displayTelMenu(id,--g_menuPosition[id])
default: { get_user_origin(id, g_menuOrgin[id])
new player = g_menuPlayers[id][g_menuPosition[id] * 6 + key] displayTelMenu(id, g_menuPosition[id])
}
case 8: displayTelMenu(id, ++g_menuPosition[id])
case 9: displayTelMenu(id, --g_menuPosition[id])
default:
{
new player = g_menuPlayers[id][g_menuPosition[id] * 6 + key]
new name2[32]
get_user_name(player, name2, 31)
new name2[32] if (!is_user_alive(player))
get_user_name(player,name2,31) {
client_print(id, print_chat, "%L", id, "CANT_PERF_DEAD", name2)
displayTelMenu(id, g_menuPosition[id])
return PLUGIN_HANDLED
}
if (!is_user_alive(player)) { if (g_menuOption[id] > 0)
client_print(id,print_chat,"%L",id,"CANT_PERF_DEAD",name2) {
displayTelMenu(id,g_menuPosition[id]) set_user_origin(player, g_menuOrgin[id])
return PLUGIN_HANDLED } else {
} new origin[3]
get_user_origin(id, origin)
set_user_origin(player, origin)
}
if (g_menuOption[id] > 0) { new authid[32], authid2[32], name[32]
set_user_origin(player,g_menuOrgin[id])
}
else {
new origin[3]
get_user_origin(id,origin)
set_user_origin(player,origin)
}
new authid[32],authid2[32], name[32] get_user_authid(id, authid, 31)
get_user_authid(player, authid2, 31)
get_user_name(id, name, 31)
get_user_authid(id,authid,31) log_amx("Cmd: ^"%s<%d><%s><>^" teleport ^"%s<%d><%s><>^"", name, get_user_userid(id), authid, name2, get_user_userid(player), authid2)
get_user_authid(player,authid2,31)
get_user_name(id,name,31)
log_amx("Cmd: ^"%s<%d><%s><>^" teleport ^"%s<%d><%s><>^"", switch (get_cvar_num("amx_show_activity"))
name,get_user_userid(id),authid, name2,get_user_userid(player),authid2 ) {
case 2: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_TELEPORT_2", name, name2)
case 1: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_TELEPORT_1", name2)
}
switch (get_cvar_num("amx_show_activity")) { displayTelMenu(id, g_menuPosition[id])
case 2: client_print(0,print_chat,"%L",LANG_PLAYER,"ADMIN_TELEPORT_2",name,name2) }
case 1: client_print(0,print_chat,"%L",LANG_PLAYER,"ADMIN_TELEPORT_1",name2) }
}
return PLUGIN_HANDLED
displayTelMenu(id,g_menuPosition[id])
}
}
return PLUGIN_HANDLED
} }
displayTelMenu(id,pos) { displayTelMenu(id, pos)
if (pos < 0) {
return if (pos < 0)
return
get_players(g_menuPlayers[id],g_menuPlayersNum[id]) get_players(g_menuPlayers[id], g_menuPlayersNum[id])
new menuBody[512] new menuBody[512]
new b = 0 new b = 0
new i new i
new name[32] new name[32]
new start = pos * 6 new start = pos * 6
new bool:blockMenu = (is_user_alive(id)&&g_menuOption[id]<1) ? true : false new bool:blockMenu = (is_user_alive(id) && g_menuOption[id] < 1) ? true : false
if (start >= g_menuPlayersNum[id]) if (start >= g_menuPlayersNum[id])
start = pos = g_menuPosition[id] = 0 start = pos = g_menuPosition[id] = 0
new len = format(menuBody,511, g_coloredMenus ? new len = format(menuBody, 511, g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%L %d/%d^n^n", id, "TELE_MENU", pos + 1, (g_menuPlayersNum[id] / 6 + ((g_menuPlayersNum[id] % 6) ? 1 : 0)))
"\y%L\R%d/%d^n\w^n" : "%L %d/%d^n^n" , new end = start + 6
id, "TELE_MENU", pos+1,( g_menuPlayersNum[id] / 6 + ((g_menuPlayersNum[id] % 6) ? 1 : 0 )) ) new keys = MENU_KEY_0|MENU_KEY_8
new end = start + 6 if (end > g_menuPlayersNum[id])
new keys = MENU_KEY_0|MENU_KEY_8 end = g_menuPlayersNum[id]
if (end > g_menuPlayersNum[id]) for (new a = start; a < end; ++a)
end = g_menuPlayersNum[id] {
i = g_menuPlayers[id][a]
get_user_name(i, name, 31)
for (new a = start; a < end; ++a) { if (blockMenu || !is_user_alive(i) || (get_user_flags(i) & ADMIN_IMMUNITY))
i = g_menuPlayers[id][a] {
get_user_name(i,name,31) ++b
if (g_coloredMenus)
len += format(menuBody[len], 511-len, "\d%d. %s^n\w", b, name)
else
len += format(menuBody[len], 511-len, "#. %s^n", name)
} else {
keys |= (1<<b)
len += format(menuBody[len], 511-len, "%d. %s^n", ++b, name)
}
}
if ( blockMenu || !is_user_alive(i) || (get_user_flags(i)&ADMIN_IMMUNITY) ) { if (g_menuOption[id] > 0) // 1
++b {
if ( g_coloredMenus ) keys |= MENU_KEY_7
len += format(menuBody[len],511-len,"\d%d. %s^n\w",b,name) len += format(menuBody[len], 511-len, "^n7. To location: %d %d %d^n", g_menuOrgin[id][0], g_menuOrgin[id][1], g_menuOrgin[id][2])
else }
len += format(menuBody[len],511-len,"#. %s^n",name) else if (g_menuOption[id]) // -1
} {
else { if (g_coloredMenus)
keys |= (1<<b) len += format(menuBody[len], 511-len, "^n\d7. %L^n\w", id, "CUR_LOC")
len += format(menuBody[len],511-len,"%d. %s^n",++b,name) else
} len += format(menuBody[len], 511-len, "^n#. %L^n", id, "CUR_LOC")
} } else { // 0
keys |= MENU_KEY_7
len += format(menuBody[len], 511-len, "^n7. %L^n", id, "CUR_LOC")
}
if ( g_menuOption[id] > 0 ) { // 1 len += format(menuBody[len], 511-len, "8. %L^n", id, "SAVE_LOC")
keys |= MENU_KEY_7
len += format(menuBody[len],511-len,"^n7. To location: %d %d %d^n",
g_menuOrgin[id][0],g_menuOrgin[id][1] ,g_menuOrgin[id][2])
}
else if ( g_menuOption[id] ) { // -1
if ( g_coloredMenus )
len += format(menuBody[len],511-len,"^n\d7. %L^n\w",id,"CUR_LOC")
else
len += format(menuBody[len],511-len,"^n#. %L^n",id,"CUR_LOC")
}
else { // 0
keys |= MENU_KEY_7
len += format(menuBody[len],511-len,"^n7. %L^n",id,"CUR_LOC")
}
len += format(menuBody[len],511-len,"8. %L^n",id,"SAVE_LOC") if (end != g_menuPlayersNum[id])
{
format(menuBody[len], 511-len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
keys |= MENU_KEY_9
}
else
format(menuBody[len], 511-len, "^n0. %L", id, pos ? "BACK" : "EXIT")
if (end != g_menuPlayersNum[id]) { show_menu(id, keys, menuBody, -1, "Teleport Menu")
format(menuBody[len],511-len,"^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
keys |= MENU_KEY_9
}
else
format(menuBody[len],511-len,"^n0. %L", id, pos ? "BACK" : "EXIT")
show_menu(id,keys,menuBody,-1,"Teleport Menu")
} }
public cmdTelMenu(id,level,cid) { public cmdTelMenu(id, level, cid)
if (cmd_access(id,level,cid,1)) {
displayTelMenu(id,g_menuPosition[id] = 0) if (cmd_access(id, level, cid, 1))
displayTelMenu(id, g_menuPosition[id] = 0)
return PLUGIN_HANDLED return PLUGIN_HANDLED
} }

View File

@ -39,164 +39,236 @@ new g_LastTime
new g_CountDown new g_CountDown
new g_Switch new g_Switch
public plugin_init() { public plugin_init()
register_plugin("TimeLeft",AMXX_VERSION_STR,"AMXX Dev Team") {
register_dictionary("timeleft.txt") register_plugin("TimeLeft", AMXX_VERSION_STR, "AMXX Dev Team")
register_cvar("amx_time_voice","1") register_dictionary("timeleft.txt")
register_srvcmd("amx_time_display","setDisplaying") register_cvar("amx_time_voice", "1")
register_cvar("amx_timeleft","00:00",FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_UNLOGGED|FCVAR_SPONLY) register_srvcmd("amx_time_display", "setDisplaying")
register_clcmd("say timeleft","sayTimeLeft",0,"- displays timeleft") register_cvar("amx_timeleft", "00:00", FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_UNLOGGED|FCVAR_SPONLY)
register_clcmd("say thetime","sayTheTime",0,"- displays current time") register_clcmd("say timeleft", "sayTimeLeft", 0, "- displays timeleft")
set_task(0.8,"timeRemain",8648458,"",0,"b") register_clcmd("say thetime", "sayTheTime", 0, "- displays current time")
set_task(0.8, "timeRemain", 8648458, "", 0, "b")
} }
public sayTheTime(id){ public sayTheTime(id)
if ( get_cvar_num("amx_time_voice") ) { {
new mhours[6], mmins[6], whours[32], wmins[32], wpm[6] if (get_cvar_num("amx_time_voice"))
get_time("%H",mhours,5) {
get_time("%M",mmins,5) new mhours[6], mmins[6], whours[32], wmins[32], wpm[6]
new mins = str_to_num(mmins)
new hrs = str_to_num(mhours) get_time("%H", mhours, 5)
if (mins) get_time("%M", mmins, 5)
num_to_word(mins,wmins,31)
else new mins = str_to_num(mmins)
wmins[0] = 0 new hrs = str_to_num(mhours)
if (hrs < 12)
wpm = "am " if (mins)
else { num_to_word(mins, wmins, 31)
if (hrs > 12) hrs -= 12 else
wpm = "pm " wmins[0] = 0
}
if (hrs) if (hrs < 12)
num_to_word(hrs,whours,31) wpm = "am "
else else
whours = "twelve " {
client_cmd(id, "spk ^"fvox/time_is_now %s_period %s%s^"",whours,wmins,wpm ) if (hrs > 12) hrs -= 12
} wpm = "pm "
new ctime[64] }
get_time("%m/%d/%Y - %H:%M:%S",ctime,63)
client_print(0,print_chat, "%L: %s",LANG_PLAYER,"THE_TIME",ctime ) if (hrs)
return PLUGIN_CONTINUE num_to_word(hrs, whours, 31)
else
whours = "twelve "
client_cmd(id, "spk ^"fvox/time_is_now %s_period %s%s^"", whours, wmins, wpm)
}
new ctime[64]
get_time("%m/%d/%Y - %H:%M:%S", ctime, 63)
client_print(0, print_chat, "%L: %s", LANG_PLAYER, "THE_TIME", ctime)
return PLUGIN_CONTINUE
} }
public sayTimeLeft(id) { public sayTimeLeft(id)
if (get_cvar_float("mp_timelimit")) { {
new a = get_timeleft() if (get_cvar_float("mp_timelimit"))
if ( get_cvar_num("amx_time_voice") ) { {
new svoice[128] new a = get_timeleft()
setTimeVoice( svoice , 127 , 0 , a )
client_cmd( id , svoice ) if (get_cvar_num("amx_time_voice"))
} {
client_print(0,print_chat, "%L: %d:%02d", LANG_PLAYER, "TIME_LEFT", (a / 60) , (a % 60) ) new svoice[128]
} setTimeVoice(svoice, 127, 0, a)
else client_cmd(id, svoice)
client_print(0,print_chat, "%L",LANG_PLAYER,"NO_T_LIMIT" ) }
return PLUGIN_CONTINUE client_print(0, print_chat, "%L: %d:%02d", LANG_PLAYER, "TIME_LEFT", (a / 60), (a % 60))
}
else
client_print(0, print_chat, "%L", LANG_PLAYER, "NO_T_LIMIT")
return PLUGIN_CONTINUE
} }
setTimeText(text[],len,tmlf,id) { setTimeText(text[], len, tmlf, id)
new secs = tmlf % 60 {
new mins = tmlf / 60 new secs = tmlf % 60
if (secs == 0) new mins = tmlf / 60
format(text,len,"%d %L", mins, id, (mins > 1) ? "MINUTES" : "MINUTE" )
else if (mins == 0) if (secs == 0)
format(text,len,"%d %L", secs, id, (secs > 1) ? "SECONDS" : "SECOND" ) format(text, len, "%d %L", mins, id, (mins > 1) ? "MINUTES" : "MINUTE")
else else if (mins == 0)
format(text,len,"%d %L %d %L", mins, id, (mins > 1) ? "MINUTES" : "MINUTE", secs, id, (secs > 1) ? "SECONDS" : "SECOND" ) format(text, len, "%d %L", secs, id, (secs > 1) ? "SECONDS" : "SECOND")
else
format(text, len, "%d %L %d %L", mins, id, (mins > 1) ? "MINUTES" : "MINUTE", secs, id, (secs > 1) ? "SECONDS" : "SECOND")
} }
setTimeVoice(text[],len,flags,tmlf) { setTimeVoice(text[], len, flags, tmlf)
new temp[7][32] {
new secs = tmlf % 60 new temp[7][32]
new mins = tmlf / 60 new secs = tmlf % 60
for (new a = 0;a < 7;++a) new mins = tmlf / 60
temp[a][0] = 0
if (secs > 0){ for (new a = 0;a < 7;++a)
num_to_word(secs,temp[4],31) temp[a][0] = 0
if (!(flags & 8)) temp[5] = "seconds " /* there is no "second" in default hl */
} if (secs > 0)
if (mins > 59) { {
new hours = mins / 60 num_to_word(secs, temp[4], 31)
num_to_word(hours,temp[0],31)
if (!(flags & 8)) temp[1] = "hours " if (!(flags & 8))
mins = mins % 60 temp[5] = "seconds " /* there is no "second" in default hl */
} }
if (mins > 0) {
num_to_word(mins ,temp[2],31) if (mins > 59)
if (!(flags & 8)) temp[3] = "minutes " {
} new hours = mins / 60
if (!(flags & 4)) temp[6] = "remaining "
return format(text,len,"spk ^"vox/%s%s%s%s%s%s%s^"", temp[0],temp[1],temp[2],temp[3],temp[4],temp[5],temp[6] ) num_to_word(hours, temp[0], 31)
if (!(flags & 8))
temp[1] = "hours "
mins = mins % 60
}
if (mins > 0)
{
num_to_word(mins, temp[2], 31)
if (!(flags & 8))
temp[3] = "minutes "
}
if (!(flags & 4))
temp[6] = "remaining "
return format(text, len, "spk ^"vox/%s%s%s%s%s%s%s^"", temp[0], temp[1], temp[2], temp[3], temp[4], temp[5], temp[6])
} }
findDispFormat(time) { findDispFormat(time)
for(new i = 0;g_TimeSet[i][0];++i) { {
if (g_TimeSet[i][1] & 16) { for (new i = 0; g_TimeSet[i][0]; ++i)
if (g_TimeSet[i][0] > time) { {
if (!g_Switch) { if (g_TimeSet[i][1] & 16)
g_CountDown = g_Switch = time {
remove_task(8648458) if (g_TimeSet[i][0] > time)
set_task(1.0,"timeRemain",34543,"",0,"b") {
} if (!g_Switch)
return i {
} g_CountDown = g_Switch = time
} remove_task(8648458)
else if (g_TimeSet[i][0] == time) { set_task(1.0, "timeRemain", 34543, "", 0, "b")
return i }
}
} return i
return -1 }
}
else if (g_TimeSet[i][0] == time)
{
return i
}
}
return -1
} }
public setDisplaying() { public setDisplaying()
new arg[32], flags[32], num[32] {
new argc = read_argc() - 1 new arg[32], flags[32], num[32]
new i = 0 new argc = read_argc() - 1
while (i < argc && i < 32) { new i = 0
read_argv(i+1,arg,31)
parse(arg,flags,31,num,31) while (i < argc && i < 32)
g_TimeSet[i][0] = str_to_num(num) {
g_TimeSet[i][1] = read_flags(flags) read_argv(i + 1, arg, 31)
i++ parse(arg, flags, 31, num, 31)
}
g_TimeSet[i][0] = 0 g_TimeSet[i][0] = str_to_num(num)
return PLUGIN_HANDLED g_TimeSet[i][1] = read_flags(flags)
i++
}
g_TimeSet[i][0] = 0
return PLUGIN_HANDLED
} }
public timeRemain(param[]) { public timeRemain(param[])
new gmtm = get_timeleft() {
new tmlf = g_Switch ? --g_CountDown : gmtm new gmtm = get_timeleft()
new stimel[12] new tmlf = g_Switch ? --g_CountDown : gmtm
format(stimel,11,"%02d:%02d",gmtm / 60, gmtm % 60) new stimel[12]
set_cvar_string("amx_timeleft",stimel)
if ( g_Switch && gmtm > g_Switch ) { format(stimel, 11, "%02d:%02d", gmtm / 60, gmtm % 60)
remove_task(34543) set_cvar_string("amx_timeleft", stimel)
g_Switch = 0
set_task(0.8,"timeRemain",8648458,"",0,"b") if (g_Switch && gmtm > g_Switch)
return {
} remove_task(34543)
if (tmlf > 0 && g_LastTime != tmlf) { g_Switch = 0
g_LastTime = tmlf set_task(0.8, "timeRemain", 8648458, "", 0, "b")
new tm_set = findDispFormat(tmlf)
if ( tm_set != -1){ return
new flags = g_TimeSet[tm_set][1] }
new arg[128]
if (flags & 1) { if (tmlf > 0 && g_LastTime != tmlf)
new players[32],pnum {
get_players(players,pnum,"c") g_LastTime = tmlf
for (new i=0;i<pnum;i++) { new tm_set = findDispFormat(tmlf)
setTimeText(arg,127,tmlf,players[i])
if (flags & 16) if (tm_set != -1)
set_hudmessage(255, 255, 255, -1.0, 0.85, 0, 0.0, 1.1, 0.1, 0.5, 1) {
else new flags = g_TimeSet[tm_set][1]
set_hudmessage(255, 255, 255, -1.0, 0.85, 0, 0.0, 3.0, 0.0, 0.5, 1) new arg[128]
show_hudmessage(players[i],arg)
} if (flags & 1)
} {
if (flags & 2) { new players[32], pnum
setTimeVoice(arg,127,flags,tmlf)
client_cmd(0,arg) get_players(players, pnum, "c")
}
} for (new i = 0; i < pnum; i++)
} {
setTimeText(arg, 127, tmlf, players[i])
if (flags & 16)
set_hudmessage(255, 255, 255, -1.0, 0.85, 0, 0.0, 1.1, 0.1, 0.5, 1)
else
set_hudmessage(255, 255, 255, -1.0, 0.85, 0, 0.0, 3.0, 0.0, 0.5, 1)
show_hudmessage(players[i], arg)
}
}
if (flags & 2)
{
setTimeVoice(arg, 127, flags, tmlf)
client_cmd(0, arg)
}
}
}
} }