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
#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() {
register_plugin("Admin Chat",AMXX_VERSION_STR,"AMXX Dev Team")
register_dictionary("adminchat.txt")
register_dictionary("common.txt")
register_clcmd("say","cmdSayChat",ADMIN_CHAT,"@[@|@|@][w|r|g|b|y|m|c]<text> - displays hud message")
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")
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()
{
register_plugin("Admin Chat", AMXX_VERSION_STR, "AMXX Dev Team")
register_dictionary("adminchat.txt")
register_dictionary("common.txt")
register_clcmd("say", "cmdSayChat", ADMIN_CHAT, "@[@|@|@][w|r|g|b|y|m|c]<text> - displays hud message")
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) {
if (!access(id,ADMIN_CHAT)) return PLUGIN_CONTINUE
new said[6], i=0
read_argv(1,said,5)
while (said[i]=='@')
i++
if ( !i || i > 3 ) return PLUGIN_CONTINUE
new message[192], a = 0
read_args(message,191)
remove_quotes(message)
switch(said[i]){
case 'r': a = 1
case 'g': a = 2
case 'b': a = 3
case 'y': a = 4
case 'm': a = 5
case 'c': a = 6
case 'o': a = 7
}
new name[32], authid[32], userid
get_user_authid(id,authid,31)
get_user_name(id,name,31)
userid = get_user_userid(id)
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 )
public cmdSayChat(id)
{
if (!access(id, ADMIN_CHAT))
return PLUGIN_CONTINUE
new said[6], i = 0
read_argv(1, said, 5)
while (said[i] == '@')
i++
if (!i || i > 3)
return PLUGIN_CONTINUE
new message[192], a = 0
read_args(message, 191)
remove_quotes(message)
switch(said[i])
{
case 'r': a = 1
case 'g': a = 2
case 'b': a = 3
case 'y': a = 4
case 'm': a = 5
case 'c': a = 6
case 'o': a = 7
}
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])
}
new name[32], authid[32], userid
get_user_authid(id, authid, 31)
get_user_name(id, name, 31)
userid = get_user_userid(id)
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) {
new said[2]
read_argv(1,said,1)
if (said[0]!='@') return PLUGIN_CONTINUE
new message[192], name[32],authid[32], userid
new players[32], inum
read_args(message,191)
remove_quotes(message)
get_user_authid(id,authid,31)
get_user_name(id,name,31)
userid = get_user_userid(id)
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])
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 cmdSayAdmin(id)
{
new said[2]
read_argv(1, said, 1)
if (said[0] != '@')
return PLUGIN_CONTINUE
new message[192], name[32], authid[32], userid
new players[32], inum
read_args(message, 191)
remove_quotes(message)
get_user_authid(id, authid, 31)
get_user_name(id, name, 31)
userid = get_user_userid(id)
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])
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) {
if (!cmd_access(id,level,cid,2))
return PLUGIN_HANDLED
new message[192], name[32], players[32], inum, authid[32], userid
read_args(message,191)
remove_quotes(message)
get_user_authid(id,authid,31)
get_user_name(id,name,31)
userid = get_user_userid(id)
get_players(players,inum)
log_amx("Chat: ^"%s<%d><%s><>^" chat ^"%s^"",name,userid,authid,message)
log_message("^"%s<%d><%s><>^" triggered ^"amx_chat^" (text ^"%s^")",name,userid,authid,message)
format(message,191,"(ADMINS) %s : %s",name,message)
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 cmdChat(id, level, cid)
{
if (!cmd_access(id, level, cid, 2))
return PLUGIN_HANDLED
new message[192], name[32], players[32], inum, authid[32], userid
read_args(message, 191)
remove_quotes(message)
get_user_authid(id, authid, 31)
get_user_name(id, name, 31)
userid = get_user_userid(id)
get_players(players, inum)
log_amx("Chat: ^"%s<%d><%s><>^" chat ^"%s^"", name, userid, authid, message)
log_message("^"%s<%d><%s><>^" triggered ^"amx_chat^" (text ^"%s^")", name, userid, authid, message)
format(message, 191, "(ADMINS) %s : %s", name, message)
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) {
if (!cmd_access(id,level,cid,2))
return PLUGIN_HANDLED
new message[192],name[32],authid[32],userid
read_args(message,191)
remove_quotes(message)
get_user_authid(id,authid,31)
get_user_name(id,name,31)
userid = get_user_userid(id)
client_print(0,print_chat,"%L",LANG_PLAYER, "PRINT_ALL",name,message)
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 cmdSay(id, level, cid)
{
if (!cmd_access(id, level, cid, 2))
return PLUGIN_HANDLED
new message[192], name[32], authid[32], userid
read_args(message, 191)
remove_quotes(message)
get_user_authid(id, authid, 31)
get_user_name(id, name, 31)
userid = get_user_userid(id)
client_print(0, print_chat, "%L", LANG_PLAYER, "PRINT_ALL", name, message)
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) {
if (!cmd_access(id,level,cid,3))
return PLUGIN_HANDLED
new name[32]
read_argv(1,name,31)
new priv = cmd_target(id,name,0)
if (!priv) return PLUGIN_HANDLED
new length = strlen(name)+1
new message[192], name2[32],authid[32],authid2[32], userid, userid2
get_user_authid(id,authid,31)
get_user_name(id,name2,31)
userid = get_user_userid(id)
read_args(message,191)
if (message[0]=='"' && message[length]=='"'){ // HLSW fix
message[0]=' '
message[length]=' '
length+=2
}
remove_quotes(message[length])
get_user_name(priv,name,31)
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 cmdPsay(id, level, cid)
{
if (!cmd_access(id, level, cid, 3))
return PLUGIN_HANDLED
new name[32]
read_argv(1, name, 31)
new priv = cmd_target(id, name, 0)
if (!priv)
return PLUGIN_HANDLED
new length = strlen(name) + 1
new message[192], name2[32], authid[32], authid2[32], userid, userid2
get_user_authid(id, authid, 31)
get_user_name(id, name2, 31)
userid = get_user_userid(id)
read_args(message, 191)
if (message[0] == '"' && message[length] == '"') // HLSW fix
{
message[0] = ' '
message[length] = ' '
length += 2
}
remove_quotes(message[length])
get_user_name(priv, name, 31)
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) {
if (!cmd_access(id,level,cid,3))
return PLUGIN_HANDLED
new cmd[16], color[16], color2[16], message[192], name[32], authid[32], userid = 0
read_argv(0,cmd,15)
new bool:tsay = (tolower(cmd[4]) == 't')
read_args(message,191)
remove_quotes(message)
parse(message,color,15)
new found = 0,a = 0
new lang[3],langnum = get_langsnum()
for (new i=0;i<MAX_CLR;++i) {
for (new j=0;j<langnum;j++) {
get_lang(j,lang)
format(color2,15,"%L",lang,g_Colors[i])
if (equali(color,color2)) {
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)
public cmdTsay(id, level, cid)
{
if (!cmd_access(id, level, cid, 3))
return PLUGIN_HANDLED
new cmd[16], color[16], color2[16], message[192], name[32], authid[32], userid = 0
read_argv(0, cmd, 15)
new bool:tsay = (tolower(cmd[4]) == 't')
read_args(message, 191)
remove_quotes(message)
parse(message, color, 15)
new found = 0, a = 0
new lang[3], langnum = get_langsnum()
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
}
for (new i = 0; i < MAX_CLR; ++i)
{
for (new j = 0; j < langnum; j++)
{
get_lang(j, lang)
format(color2, 15, "%L", lang, g_Colors[i])
if (equali(color, color2))
{
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)
{
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.
*
* 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
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
@ -34,77 +34,90 @@
#include <amxmodx>
#define DISPLAY_MSG // Comment to disable message on join
#define HELPAMOUNT 10 // Number of commands per page
#define DISPLAY_MSG // Comment to disable message on join
#define HELPAMOUNT 10 // Number of commands per page
public plugin_init() {
register_plugin("Admin Help",AMXX_VERSION_STR,"AMXX Dev Team")
register_dictionary("adminhelp.txt")
register_concmd("amx_help","cmdHelp",0,"<page> [nr of cmds (only for server)] - displays this help")
public plugin_init()
{
register_plugin("Admin Help", AMXX_VERSION_STR, "AMXX Dev Team")
register_dictionary("adminhelp.txt")
register_concmd("amx_help", "cmdHelp", 0, "<page> [nr of cmds (only for server)] - displays this help")
}
#if defined DISPLAY_MSG
public client_putinserver(id) {
if (is_user_bot(id))
return
set_task(15.0,"dispInfo",id)
public client_putinserver(id)
{
if (is_user_bot(id))
return
set_task(15.0, "dispInfo", id)
}
public client_disconnect(id) {
public client_disconnect(id)
{
remove_task(id)
}
#endif
public cmdHelp(id,level,cid) {
public cmdHelp(id, level, cid)
{
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
if (id == 0 && read_argc() == 3)
lHelpAmount = read_argv(2, arg1, 7) ? str_to_num(arg1) : HELPAMOUNT
if (--start < 0)
start = 0
new clcmdsnum = get_concmdsnum(flags,id)
new clcmdsnum = get_concmdsnum(flags, id)
if (start >= clcmdsnum)
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 end = start + lHelpAmount // HELPAMOUNT
if (end > clcmdsnum)
end = clcmdsnum
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)
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)
}
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)
console_print(id,"----- %L -----",id,"HELP_USE_MORE",end+1)
console_print(id, "----- %L -----", id, "HELP_USE_MORE", end + 1)
else
console_print(id,"----- %L -----",id,"HELP_USE_BEGIN")
console_print(id, "----- %L -----", id, "HELP_USE_BEGIN")
return PLUGIN_HANDLED
}
#if defined DISPLAY_MSG
public dispInfo(id) {
client_print(id,print_chat,"%L",id,"TYPE_HELP")
new nextmap[32]
get_cvar_string("amx_nextmap",nextmap,31)
if (get_cvar_float("mp_timelimit")) {
new timeleft = get_timeleft()
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)
}
}
public dispInfo(id)
{
client_print(id, print_chat, "%L", id, "TYPE_HELP")
new nextmap[32]
get_cvar_string("amx_nextmap", nextmap, 31)
if (get_cvar_float("mp_timelimit"))
{
new timeleft = get_timeleft()
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]
public plugin_init() {
register_plugin("Slots Reservation",AMXX_VERSION_STR,"AMXX Dev Team")
register_dictionary("adminslots.txt")
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') )
register_clcmd( g_cmdLoopback, "ackSignal" )
public plugin_init()
{
register_plugin("Slots Reservation", AMXX_VERSION_STR, "AMXX Dev Team")
register_dictionary("adminslots.txt")
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'))
register_clcmd(g_cmdLoopback, "ackSignal")
#if defined HIDE_RESERVED_SLOTS
new maxplayers = get_maxplayers()
new players = get_playersnum(1)
new limit = maxplayers - get_cvar_num("amx_reservation")
setVisibleSlots(players, maxplayers, limit)
new maxplayers = get_maxplayers()
new players = get_playersnum(1)
new limit = maxplayers - get_cvar_num("amx_reservation")
setVisibleSlots(players, maxplayers, limit)
#endif
}
public ackSignal(id) {
new lReason[64]
format(lReason,63,"%L",id,"DROPPED_RES")
server_cmd("kick #%d ^"%s^"", get_user_userid(id), lReason )
public ackSignal(id)
{
new lReason[64]
format(lReason, 63, "%L", id, "DROPPED_RES")
server_cmd("kick #%d ^"%s^"", get_user_userid(id), lReason)
}
public client_authorized(id) {
new maxplayers = get_maxplayers()
new players = get_playersnum( 1 )
new limit = maxplayers - get_cvar_num("amx_reservation")
if ( access(id,ADMIN_RESERVATION) || (players <= limit) )
{
public client_authorized(id)
{
new maxplayers = get_maxplayers()
new players = get_playersnum(1)
new limit = maxplayers - get_cvar_num("amx_reservation")
if (access(id, ADMIN_RESERVATION) || (players <= limit))
{
#if defined HIDE_RESERVED_SLOTS
setVisibleSlots( players , maxplayers, limit )
setVisibleSlots(players, maxplayers, limit)
#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
public client_disconnect(id)
{
new maxplayers = get_maxplayers()
setVisibleSlots( get_playersnum(1) - 1 , maxplayers ,
maxplayers - get_cvar_num("amx_reservation") )
return PLUGIN_CONTINUE
new maxplayers = get_maxplayers()
setVisibleSlots(get_playersnum(1) - 1, maxplayers, maxplayers - get_cvar_num("amx_reservation"))
return PLUGIN_CONTINUE
}
setVisibleSlots( players , maxplayers , limit )
setVisibleSlots(players, maxplayers, limit)
{
new num = players + 1
new num = players + 1
if ( players == maxplayers )
num = maxplayers
else if ( players < limit )
num = limit
if (players == maxplayers)
num = maxplayers
else if (players < limit)
num = limit
set_cvar_num( "sv_visiblemaxplayers" , num )
set_cvar_num("sv_visiblemaxplayers", num)
}
#endif

View File

@ -48,366 +48,474 @@ new g_execLen
new bool:g_execResult
new Float:g_voteRatio
public plugin_init() {
register_plugin("Admin Votes",AMXX_VERSION_STR,"AMXX Dev Team")
register_dictionary("adminvote.txt")
register_dictionary("common.txt")
register_dictionary("mapsmenu.txt")
register_menucmd(register_menuid("Change map to "),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("Kick "),MENU_KEY_1|MENU_KEY_2,"voteCount")
register_menucmd(register_menuid("Ban "),MENU_KEY_1|MENU_KEY_2,"voteCount")
register_menucmd(register_menuid("Vote: "),MENU_KEY_1|MENU_KEY_2,"voteCount")
register_menucmd(register_menuid("The result: "),MENU_KEY_1|MENU_KEY_2,"actionResult")
register_concmd("amx_votemap","cmdVoteMap",ADMIN_VOTE,"<map> [map] [map] [map]")
register_concmd("amx_votekick","cmdVoteKickBan",ADMIN_VOTE,"<name or #userid>")
register_concmd("amx_voteban","cmdVoteKickBan",ADMIN_VOTE,"<name or #userid>")
register_concmd("amx_vote","cmdVote",ADMIN_VOTE,"<question> <answer#1> <answer#2>")
register_concmd("amx_cancelvote","cmdCancelVote",ADMIN_VOTE,"- cancels last vote")
g_coloredMenus = colored_menus()
public plugin_init()
{
register_plugin("Admin Votes", AMXX_VERSION_STR, "AMXX Dev Team")
register_dictionary("adminvote.txt")
register_dictionary("common.txt")
register_dictionary("mapsmenu.txt")
register_menucmd(register_menuid("Change map to "), 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("Kick "), MENU_KEY_1|MENU_KEY_2, "voteCount")
register_menucmd(register_menuid("Ban "), MENU_KEY_1|MENU_KEY_2, "voteCount")
register_menucmd(register_menuid("Vote: "), MENU_KEY_1|MENU_KEY_2, "voteCount")
register_menucmd(register_menuid("The result: "), MENU_KEY_1|MENU_KEY_2, "actionResult")
register_concmd("amx_votemap", "cmdVoteMap", ADMIN_VOTE, "<map> [map] [map] [map]")
register_concmd("amx_votekick", "cmdVoteKickBan", ADMIN_VOTE, "<name or #userid>")
register_concmd("amx_voteban", "cmdVoteKickBan", ADMIN_VOTE, "<name or #userid>")
register_concmd("amx_vote", "cmdVote", ADMIN_VOTE, "<question> <answer#1> <answer#2>")
register_concmd("amx_cancelvote", "cmdCancelVote", ADMIN_VOTE, "- cancels last vote")
g_coloredMenus = colored_menus()
}
public cmdCancelVote(id,level,cid) {
if (!cmd_access(id,level,cid,0))
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" )
public cmdCancelVote(id, level, cid)
{
if (!cmd_access(id, level, cid, 0))
return PLUGIN_HANDLED
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[])
server_cmd(cmd)
server_cmd(cmd)
public autoRefuse() {
log_amx("Vote: %L","en","RES_REF")
client_print(0,print_chat,"%L",LANG_PLAYER,"RES_REF")
public autoRefuse()
{
log_amx("Vote: %L", "en", "RES_REF")
client_print(0, print_chat, "%L", LANG_PLAYER, "RES_REF")
}
public actionResult(id,key) {
remove_task( 4545454 )
switch (key) {
case 0: {
set_task(2.0,"delayedExec",0,g_Execute,g_execLen)
log_amx("Vote: %L","en","RES_ACCEPTED")
client_print(0,print_chat,"%L",LANG_PLAYER,"RES_ACCEPTED")
}
case 1: autoRefuse()
}
return PLUGIN_HANDLED
public actionResult(id, key)
{
remove_task(4545454)
switch (key)
{
case 0:
{
set_task(2.0, "delayedExec", 0, g_Execute, g_execLen)
log_amx("Vote: %L", "en", "RES_ACCEPTED")
client_print(0, print_chat, "%L", LANG_PLAYER, "RES_ACCEPTED")
}
case 1: autoRefuse()
}
return PLUGIN_HANDLED
}
public checkVotes() {
new best = 0
if ( !g_yesNoVote ) {
for (new a = 0; a < 4; ++a)
if (g_voteCount[a] > g_voteCount[best])
best = a
}
new votesNum = g_voteCount[0] + g_voteCount[1] + g_voteCount[2] + g_voteCount[3]
new iRatio = votesNum ? floatround( g_voteRatio * float( votesNum ) ,floatround_ceil) : 1
new iResult = g_voteCount[best]
new players[32],pnum,i
get_players(players,pnum,"c")
if ( iResult < iRatio ) {
new lVotingFailed[64]
for (i=0;i<pnum;i++) {
format(lVotingFailed,63,"%L",players[i],"VOTING_FAILED")
if (g_yesNoVote)
client_print(players[i],print_chat,"%L",players[i],"VOTING_RES_1",
lVotingFailed,g_voteCount[0],g_voteCount[1],iRatio)
else
client_print(players[i],print_chat,"%L",players[i],"VOTING_RES_2",lVotingFailed,iResult,iRatio )
}
format(lVotingFailed,63,"%L","en","VOTING_FAILED")
log_amx("Vote: %s (got ^"%d^") (needed ^"%d^")",lVotingFailed,iResult,iRatio)
return PLUGIN_CONTINUE
}
g_execLen = format(g_Execute,255,g_Answer,g_optionName[best]) + 1
if (g_execResult) {
g_execResult = false
if ( is_user_connected(g_voteCaller) ) {
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(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 checkVotes()
{
new best = 0
if (!g_yesNoVote)
{
for (new a = 0; a < 4; ++a)
if (g_voteCount[a] > g_voteCount[best])
best = a
}
new votesNum = g_voteCount[0] + g_voteCount[1] + g_voteCount[2] + g_voteCount[3]
new iRatio = votesNum ? floatround(g_voteRatio * float(votesNum), floatround_ceil) : 1
new iResult = g_voteCount[best]
new players[32], pnum, i
get_players(players, pnum, "c")
if (iResult < iRatio)
{
new lVotingFailed[64]
for (i = 0; i < pnum; i++)
{
format(lVotingFailed, 63, "%L", players[i], "VOTING_FAILED")
if (g_yesNoVote)
client_print(players[i], print_chat, "%L", players[i], "VOTING_RES_1", lVotingFailed, g_voteCount[0], g_voteCount[1], iRatio)
else
client_print(players[i], print_chat, "%L", players[i], "VOTING_RES_2", lVotingFailed, iResult, iRatio)
}
format(lVotingFailed, 63, "%L", "en", "VOTING_FAILED")
log_amx("Vote: %s (got ^"%d^") (needed ^"%d^")", lVotingFailed, iResult, iRatio)
return PLUGIN_CONTINUE
}
g_execLen = format(g_Execute, 255, g_Answer, g_optionName[best]) + 1
if (g_execResult)
{
g_execResult = false
if (is_user_connected(g_voteCaller))
{
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(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) {
if ( get_cvar_num("amx_vote_answers") ) {
new name[32]
get_user_name(id,name,31)
if (g_yesNoVote)
client_print(0,print_chat,"%L",LANG_PLAYER,key ? "VOTED_AGAINST" : "VOTED_FOR",name)
else
client_print(0,print_chat,"%L",LANG_PLAYER,"VOTED_FOR_OPT",name,key+1)
}
++g_voteCount[key]
return PLUGIN_HANDLED
public voteCount(id, key)
{
if (get_cvar_num("amx_vote_answers"))
{
new name[32]
get_user_name(id, name, 31)
if (g_yesNoVote)
client_print(0, print_chat, "%L", LANG_PLAYER, key ? "VOTED_AGAINST" : "VOTED_FOR", name)
else
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) {
if (!cmd_access(id,level,cid,2))
return PLUGIN_HANDLED
new Float:voting = get_cvar_float("amx_last_voting")
if (voting > get_gametime()) {
console_print(id, "%L", id, "ALREADY_VOTING")
return PLUGIN_HANDLED
}
if (voting && voting + get_cvar_float("amx_vote_delay") > get_gametime()) {
console_print(id, "%L", id, "VOTING_NOT_ALLOW")
return PLUGIN_HANDLED
}
new argc = read_argc()
if (argc > 5) argc = 5
g_validMaps = 0
g_optionName[0][0] = 0
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])
public cmdVoteMap(id, level, cid)
{
if (!cmd_access(id, level, cid, 2))
return PLUGIN_HANDLED
new Float:voting = get_cvar_float("amx_last_voting")
if (voting > get_gametime())
{
console_print(id, "%L", id, "ALREADY_VOTING")
return PLUGIN_HANDLED
}
if (voting && voting + get_cvar_float("amx_vote_delay") > get_gametime())
{
console_print(id, "%L", id, "VOTING_NOT_ALLOW")
return PLUGIN_HANDLED
}
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)
}
}
}
new argc = read_argc()
if (argc > 5) argc = 5
g_validMaps = 0
g_optionName[0][0] = 0
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
}
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
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")
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) {
if (!cmd_access(id,level,cid,4))
return PLUGIN_HANDLED
new Float:voting = get_cvar_float("amx_last_voting")
if (voting > get_gametime()) {
console_print(id, "%L", id, "ALREADY_VOTING")
return PLUGIN_HANDLED
}
if (voting && voting + get_cvar_float("amx_vote_delay") > get_gametime()) {
console_print(id, "%L", id, "VOTING_NOT_ALLOW")
return PLUGIN_HANDLED
}
new quest[48]
read_argv(1,quest,47)
if ((contain(quest,"sv_password")!=-1)||(contain(quest,"rcon_password")!=-1)||
(contain(quest,"kick")!=-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)
public cmdVote(id, level, cid)
{
if (!cmd_access(id, level, cid, 4))
return PLUGIN_HANDLED
new Float:voting = get_cvar_float("amx_last_voting")
if (voting > get_gametime())
{
console_print(id, "%L", id, "ALREADY_VOTING")
return PLUGIN_HANDLED
}
if (voting && voting + get_cvar_float("amx_vote_delay") > get_gametime())
{
console_print(id, "%L", id, "VOTING_NOT_ALLOW")
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><>^" vote custom (question ^"%s^") (option#1 ^"%s^") (option#2 ^"%s^")",
name,get_user_userid(id),authid,quest,g_optionName[0],g_optionName[1])
new quest[48]
read_argv(1, quest, 47)
if ((contain(quest, "sv_password") != -1) || (contain(quest, "rcon_password") != -1) || (contain(quest, "kick") != -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")
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":"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 authid[32], name[32]
get_user_authid(id, authid, 31)
get_user_name(id, name, 31)
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])
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
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" : "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]
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) {
if (!cmd_access(id,level,cid,2))
return PLUGIN_HANDLED
new Float:voting = get_cvar_float("amx_last_voting")
if (voting > get_gametime()) {
console_print(id, "%L", id, "ALREADY_VOTING")
return PLUGIN_HANDLED
}
if (voting && voting + get_cvar_float("amx_vote_delay") > get_gametime()) {
console_print(id, "%L", id, "VOTING_NOT_ALLOW")
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
}
public cmdVoteKickBan(id, level, cid)
{
if (!cmd_access(id, level, cid, 2))
return PLUGIN_HANDLED
new Float:voting = get_cvar_float("amx_last_voting")
if (voting > get_gametime())
{
console_print(id, "%L", id, "ALREADY_VOTING")
return PLUGIN_HANDLED
}
new keys = MENU_KEY_1|MENU_KEY_2
new menu_msg[256],lYes[16],lNo[16],lKickBan[16]
format(lYes,15,"%L",LANG_SERVER,"YES")
format(lNo,15,"%L",LANG_SERVER,"NO")
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)
if (voting && voting + get_cvar_float("amx_vote_delay") > get_gametime())
{
console_print(id, "%L", id, "VOTING_NOT_ALLOW")
return PLUGIN_HANDLED
}
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)
}
}
}
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
}
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
new keys = MENU_KEY_1|MENU_KEY_2
new menu_msg[256], lYes[16], lNo[16], lKickBan[16]
format(lYes, 15, "%L", LANG_SERVER, "YES")
format(lNo, 15, "%L", LANG_SERVER, "NO")
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")
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 g_Flood[33] = {0, ...}
public plugin_init() {
register_plugin("Anti Flood",AMXX_VERSION_STR,"AMXX Dev Team")
register_dictionary("antiflood.txt")
register_clcmd("say","chkFlood")
register_clcmd("say_team","chkFlood")
register_cvar("amx_flood_time","0.75")
public plugin_init()
{
register_plugin("Anti Flood", AMXX_VERSION_STR, "AMXX Dev Team")
register_dictionary("antiflood.txt")
register_clcmd("say", "chkFlood")
register_clcmd("say_team", "chkFlood")
register_cvar("amx_flood_time", "0.75")
}
public chkFlood(id) {
new Float:maxChat = get_cvar_float("amx_flood_time")
public chkFlood(id)
{
new Float:maxChat = get_cvar_float("amx_flood_time")
if ( maxChat ) {
new Float:nexTime = get_gametime()
if (maxChat)
{
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 ) {
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
}
return PLUGIN_CONTINUE
}

View File

@ -39,28 +39,32 @@
#define MAX_CMDS_LAYERS 3
new g_cmdMenuName[ MAX_CMDS_LAYERS ][] = {
"CMD_MENU",
"CONF_MENU",
"SPE_MENU"
new g_cmdMenuName[MAX_CMDS_LAYERS][] =
{
"CMD_MENU",
"CONF_MENU",
"SPE_MENU"
}
new g_cmdMenuCmd[ MAX_CMDS_LAYERS ][] = {
"amx_cmdmenu",
"amx_cfgmenu",
"amx_speechmenu"
new g_cmdMenuCmd[MAX_CMDS_LAYERS][] =
{
"amx_cmdmenu",
"amx_cfgmenu",
"amx_speechmenu"
}
new g_cmdMenuCfg[ MAX_CMDS_LAYERS ][] = {
"cmds.ini",
"configs.ini",
"speech.ini"
new g_cmdMenuCfg[MAX_CMDS_LAYERS][] =
{
"cmds.ini",
"configs.ini",
"speech.ini"
}
new g_cmdMenuHelp[ MAX_CMDS_LAYERS ][] = {
"- displays commands menu",
"- displays configs menu",
"- displays speech menu"
new g_cmdMenuHelp[MAX_CMDS_LAYERS][] =
{
"- displays commands menu",
"- displays configs menu",
"- displays speech menu"
}
/* End of Commands Menu */
@ -86,298 +90,325 @@ new g_menuLayer[33]
new g_coloredMenus
public plugin_init() {
register_plugin("Commands Menu",AMXX_VERSION_STR,"AMXX Dev Team")
register_dictionary("cmdmenu.txt")
register_dictionary("common.txt")
public plugin_init()
{
register_plugin("Commands Menu", AMXX_VERSION_STR, "AMXX Dev Team")
register_dictionary("cmdmenu.txt")
register_dictionary("common.txt")
new configsDir[64],config[64]
get_configsdir(configsDir, 63)
for (new a = 0; a < MAX_CMDS_LAYERS; ++a) {
new MenuName[64]
format(MenuName,63,"%L","en",g_cmdMenuName[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)
}
new configsDir[64], config[64]
get_configsdir(configsDir, 63)
for (new a = 0; a < MAX_CMDS_LAYERS; ++a)
{
new MenuName[64]
format(MenuName, 63, "%L", "en", g_cmdMenuName[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_clcmd("amx_cvarmenu","cmdCvarMenu",ADMIN_CVAR,"- displays cvars menu")
register_menucmd(register_menuid("Cvars Menu"), 1023, "actionCvarMenu")
register_clcmd("amx_cvarmenu", "cmdCvarMenu", ADMIN_CVAR, "- displays cvars menu")
new cvars_ini_file[64];
format(cvars_ini_file, 63, "%s/%s", configsDir, "cvars.ini");
loadCvarSettings(cvars_ini_file)
new cvars_ini_file[64];
format(cvars_ini_file, 63, "%s/%s", configsDir, "cvars.ini");
loadCvarSettings(cvars_ini_file)
g_coloredMenus = colored_menus()
g_coloredMenus = colored_menus()
}
/* Commands menu */
public actionCmdMenu(id,key) {
switch (key) {
case 8: displayCmdMenu(id,++g_menuPosition[id])
case 9: displayCmdMenu(id,--g_menuPosition[id])
default:{
new option = g_menuSelect[ id ][ g_menuPosition[id] * 8 + key ]
new flags = g_cmdMisc[ option ][ 1 ]
if ( flags & 1)
server_cmd( g_cmdCmd[ option ] )
else if ( flags & 2)
client_cmd(id, g_cmdCmd[ option ] )
else if ( flags & 4)
client_cmd(0, g_cmdCmd[ option ] )
if ( flags & 8 ) displayCmdMenu(id,g_menuPosition[id])
}
}
return PLUGIN_HANDLED
public actionCmdMenu(id, key)
{
switch (key)
{
case 8: displayCmdMenu(id, ++g_menuPosition[id])
case 9: displayCmdMenu(id, --g_menuPosition[id])
default:
{
new option = g_menuSelect[id][g_menuPosition[id] * 8 + key]
new flags = g_cmdMisc[option][1]
if (flags & 1)
server_cmd(g_cmdCmd[option])
else if (flags & 2)
client_cmd(id, g_cmdCmd[option])
else if (flags & 4)
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) {
if (pos < 0) return
new menuBody[512]
new b = 0
new start = pos * 8
if (start >= g_menuSelectNum[id])
start = pos = g_menuPosition[id] = 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] ],
pos+1,( g_menuSelectNum[id] / 8 + ((g_menuSelectNum[id] % 8) ? 1 : 0 )) )
new end = start + 8
new keys = MENU_KEY_0
if (end > g_menuSelectNum[id])
end = g_menuSelectNum[id]
for(new a = start; a < end; ++a) {
if ( g_cmdCmd[ g_menuSelect[id][ a ] ][0] == '-' ) {
if ( g_coloredMenus )
len += format(menuBody[len],511-len,"\d%s^n\w",g_cmdName[ g_menuSelect[id][ a ] ] )
else
len += format(menuBody[len],511-len,"%s^n",g_cmdName[ g_menuSelect[id][ a ] ] )
++b
}
else {
keys |= (1<<b)
len += format(menuBody[len],511-len,"%d. %s^n",++b, g_cmdName[ g_menuSelect[id][ a ] ] )
}
}
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" )
new MenuName[64]
format(MenuName,63,"%L","en",g_cmdMenuName[g_menuLayer[id]])
show_menu(id,keys,menuBody,-1,MenuName)
new menuBody[512]
new b = 0
new start = pos * 8
if (start >= g_menuSelectNum[id])
start = pos = g_menuPosition[id] = 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]], pos + 1, (g_menuSelectNum[id] / 8 + ((g_menuSelectNum[id] % 8) ? 1 : 0)))
new end = start + 8
new keys = MENU_KEY_0
if (end > g_menuSelectNum[id])
end = g_menuSelectNum[id]
for (new a = start; a < end; ++a)
{
if (g_cmdCmd[g_menuSelect[id][a]][0] == '-')
{
if (g_coloredMenus)
len += format(menuBody[len], 511-len, "\d%s^n\w", g_cmdName[g_menuSelect[id][a]])
else
len += format(menuBody[len], 511-len, "%s^n", g_cmdName[g_menuSelect[id][a]])
++b
} else {
keys |= (1<<b)
len += format(menuBody[len], 511-len, "%d. %s^n", ++b, g_cmdName[g_menuSelect[id][a]])
}
}
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")
new MenuName[64]
format(MenuName, 63, "%L", "en", g_cmdMenuName[g_menuLayer[id]])
show_menu(id, keys, menuBody, -1, MenuName)
}
public cmdCmdMenu(id,level,cid) {
if (!cmd_access(id,level,cid,1)) return PLUGIN_HANDLED
new szCmd[32]
read_argv(0, szCmd, 31)
new lvl = 0
while( lvl < MAX_CMDS_LAYERS ) {
if ( equal( g_cmdMenuCmd[ lvl ], szCmd ) )
break
++lvl
}
g_menuLayer[ id ] = lvl
new flags = get_user_flags(id)
g_menuSelectNum[id] = 0
new a = lvl * MAX_CMDS
new d , c = 0
while( c < g_cmdNum[ lvl ] ) {
d = a + c
if ( g_cmdMisc[ d ][0] & flags ) {
g_menuSelect[id][ g_menuSelectNum[id]++ ] = d
}
++c
}
displayCmdMenu(id,g_menuPosition[id] = 0)
return PLUGIN_HANDLED
public cmdCmdMenu(id, level, cid)
{
if (!cmd_access(id, level, cid, 1))
return PLUGIN_HANDLED
new szCmd[32]
read_argv(0, szCmd, 31)
new lvl = 0
while (lvl < MAX_CMDS_LAYERS)
{
if (equal(g_cmdMenuCmd[lvl], szCmd))
break
++lvl
}
g_menuLayer[id] = lvl
new flags = get_user_flags(id)
g_menuSelectNum[id] = 0
new a = lvl * MAX_CMDS
new d, c = 0
while (c < g_cmdNum[lvl])
{
d = a + c
if (g_cmdMisc[d][0] & flags)
{
g_menuSelect[id][g_menuSelectNum[id]++] = d
}
++c
}
displayCmdMenu(id, g_menuPosition[id] = 0)
return PLUGIN_HANDLED
}
loadCmdSettings(szFilename[], level)
{
if (!file_exists(szFilename))
return 0
loadCmdSettings( szFilename[], level ) {
if ( !file_exists ( szFilename ) )
return 0
new text[256], szFlags[32], szAccess[32]
new a, pos = 0, c, d = level * MAX_CMDS
while ( g_cmdNum[ level ] < MAX_CMDS && read_file (szFilename,pos++,text,255,a) ) {
if ( text[0] == ';' ) continue
c = d + g_cmdNum[ level ]
if ( parse( text , g_cmdName[ c ] , 31 ,
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 ]++
}
}
return 1
new text[256], szFlags[32], szAccess[32]
new a, pos = 0, c, d = level * MAX_CMDS
while (g_cmdNum[level] < MAX_CMDS && read_file(szFilename, pos++, text, 255, a))
{
if (text[0] == ';') continue
c = d + g_cmdNum[level]
if (parse(text, g_cmdName[c], 31, 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]++
}
}
return 1
}
/* Cvars menu */
public actionCvarMenu(id,key) {
switch (key){
case 8: displayCvarMenu(id,++g_menuPosition[id])
case 9: displayCvarMenu(id,--g_menuPosition[id])
default: {
new option = g_menuSelect[ id ][ g_menuPosition[id] * 8 + key ]
new szValue[32]
get_cvar_string( g_cvarNames[ option ], szValue ,31)
new end = g_cvarMisc[ option ][ 2 ]
new start = g_cvarMisc[ option ][ 1 ]
for (new i = start ; ; ++i ) {
if ( i < end ) {
if ( equal( szValue , g_cvarCmd[ i ] ) )
{
if (++i >= end)
{
i = start
}
set_cvar_string( g_cvarNames[ option ], g_cvarCmd[ i ] )
break
}
}
else {
set_cvar_string( g_cvarNames[ option ], g_cvarCmd[ start ] )
break
}
}
displayCvarMenu(id, g_menuPosition[id] )
}
}
return PLUGIN_HANDLED
public actionCvarMenu(id, key)
{
switch (key)
{
case 8: displayCvarMenu(id, ++g_menuPosition[id])
case 9: displayCvarMenu(id, --g_menuPosition[id])
default:
{
new option = g_menuSelect[id][g_menuPosition[id] * 8 + key]
new szValue[32]
get_cvar_string(g_cvarNames[option], szValue, 31)
new end = g_cvarMisc[option][2]
new start = g_cvarMisc[option][1]
for (new i = start; ; ++i)
{
if (i < end)
{
if (equal(szValue, g_cvarCmd[i]))
{
if (++i >= end)
{
i = start
}
set_cvar_string(g_cvarNames[option], g_cvarCmd[i])
break
}
} else {
set_cvar_string(g_cvarNames[option], g_cvarCmd[start])
break
}
}
displayCvarMenu(id, g_menuPosition[id])
}
}
return PLUGIN_HANDLED
}
displayCvarMenu(id, pos)
{
if (pos < 0)
return
displayCvarMenu(id,pos) {
if (pos < 0) return
new menuBody[512]
new b = 0
new start = pos * 8
new menuBody[512]
new b = 0
new start = pos * 8
if (start >= g_menuSelectNum[id])
start = pos = g_menuPosition[id] = 0
if (start >= g_menuSelectNum[id])
start = pos = g_menuPosition[id] = 0
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)))
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 )) )
new end = start + 8
new keys = MENU_KEY_0
new szValue[64]
new end = start + 8
new keys = MENU_KEY_0
new szValue[64]
if (end > g_menuSelectNum[id])
end = g_menuSelectNum[id]
if (end > g_menuSelectNum[id])
end = g_menuSelectNum[id]
for (new a = start; a < end; ++a)
{
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) {
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 )
}
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)
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) {
if (!cmd_access(id,level,cid,1)) return PLUGIN_HANDLED
new flags = get_user_flags(id)
g_menuSelectNum[id] = 0
for(new a = 0; a < g_cvarNum; ++a)
if ( g_cvarMisc[ a ][0] & flags )
g_menuSelect[id][ g_menuSelectNum[id]++ ] = a
displayCvarMenu(id,g_menuPosition[id] = 0)
return PLUGIN_HANDLED
public cmdCvarMenu(id, level, cid)
{
if (!cmd_access(id, level, cid, 1))
return PLUGIN_HANDLED
new flags = get_user_flags(id)
g_menuSelectNum[id] = 0
for (new a = 0; a < g_cvarNum; ++a)
if (g_cvarMisc[a][0] & flags)
g_menuSelect[id][g_menuSelectNum[id]++] = a
displayCvarMenu(id, g_menuPosition[id] = 0)
return PLUGIN_HANDLED
}
loadCvarSettings( szFilename[] ) {
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
loadCvarSettings(szFilename[])
{
if (!file_exists(szFilename))
return 0
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
}
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
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_Current
public plugin_init() {
register_plugin("Info. Messages",AMXX_VERSION_STR,"AMXX Dev Team")
register_dictionary("imessage.txt")
register_dictionary("common.txt")
register_srvcmd("amx_imessage","setMessage")
register_cvar("amx_freq_imessage","10")
new lastinfo[8]
get_localinfo("lastinfomsg",lastinfo,7)
g_Current = str_to_num(lastinfo)
set_localinfo("lastinfomsg","")
public plugin_init()
{
register_plugin("Info. Messages", AMXX_VERSION_STR, "AMXX Dev Team")
register_dictionary("imessage.txt")
register_dictionary("common.txt")
register_srvcmd("amx_imessage", "setMessage")
register_cvar("amx_freq_imessage", "10")
new lastinfo[8]
get_localinfo("lastinfomsg", lastinfo, 7)
g_Current = str_to_num(lastinfo)
set_localinfo("lastinfomsg", "")
}
public infoMessage() {
if (g_Current >= g_MessagesNum)
g_Current = 0
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)
show_hudmessage(0,g_Messages[g_Current])
client_print(0,print_console,g_Messages[g_Current])
++g_Current
new Float:freq_im = get_cvar_float("amx_freq_imessage")
if ( freq_im > 0.0 ) set_task( freq_im ,"infoMessage",12345)
public infoMessage()
{
if (g_Current >= g_MessagesNum)
g_Current = 0
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)
show_hudmessage(0, g_Messages[g_Current])
client_print(0, print_console, g_Messages[g_Current])
++g_Current
new Float:freq_im = get_cvar_float("amx_freq_imessage")
if (freq_im > 0.0)
set_task(freq_im, "infoMessage", 12345)
}
public setMessage() {
if (g_MessagesNum >= MAX_MESSAGES) {
server_print("%L",LANG_SERVER,"INF_REACH")
return PLUGIN_HANDLED
}
remove_task(12345)
read_argv(1,g_Messages[g_MessagesNum],380)
new hostname[64]
get_cvar_string("hostname",hostname,63)
replace(g_Messages[g_MessagesNum],380,"%hostname%",hostname)
while(replace(g_Messages[g_MessagesNum],380,"\n","^n")){}
new mycol[12]
read_argv(2,mycol,11) // RRRGGGBBB
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 setMessage()
{
if (g_MessagesNum >= MAX_MESSAGES)
{
server_print("%L", LANG_SERVER, "INF_REACH")
return PLUGIN_HANDLED
}
remove_task(12345)
read_argv(1, g_Messages[g_MessagesNum], 380)
new hostname[64]
get_cvar_string("hostname", hostname, 63)
replace(g_Messages[g_MessagesNum], 380, "%hostname%", hostname)
while (replace(g_Messages[g_MessagesNum], 380, "\n", "^n")) {}
new mycol[12]
read_argv(2, mycol, 11) // RRRGGGBBB
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() {
new lastinfo[8]
num_to_str(g_Current,lastinfo,7)
set_localinfo("lastinfomsg",lastinfo)
}
public plugin_end()
{
new lastinfo[8]
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_nextName[SELECTMAPS]
new g_voteCount[SELECTMAPS+2]
new g_voteCount[SELECTMAPS + 2]
new g_mapVoteNum
new g_teamScore[2]
new g_lastMap[32]
@ -50,163 +50,204 @@ new g_lastMap[32]
new g_coloredMenus
new bool:g_selected = false
public plugin_init() {
register_plugin("Nextmap Chooser",AMXX_VERSION_STR,"AMXX Dev Team")
register_dictionary("mapchooser.txt")
register_dictionary("common.txt")
new MenuName[64]
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")
public plugin_init()
{
register_plugin("Nextmap Chooser", AMXX_VERSION_STR, "AMXX Dev Team")
register_dictionary("mapchooser.txt")
register_dictionary("common.txt")
new MenuName[64]
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() )
register_event("TeamScore", "team_score", "a")
get_localinfo("lastMap",g_lastMap,31)
set_localinfo("lastMap","")
if (cstrike_running())
register_event("TeamScore", "team_score", "a")
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")
get_localinfo("lastMap", g_lastMap, 31)
set_localinfo("lastMap", "")
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() {
new b = 0
for (new a = 0; a < g_mapVoteNum; ++a)
if (g_voteCount[b] < g_voteCount[a])
b = a
if ( g_voteCount[SELECTMAPS] > g_voteCount[b] ) {
new mapname[32]
get_mapname(mapname,31)
new Float:steptime = get_cvar_float("amx_extendmap_step")
set_cvar_float("mp_timelimit", get_cvar_float("mp_timelimit") + steptime )
client_print(0,print_chat,"%L", LANG_PLAYER, "CHO_FIN_EXT", steptime )
log_amx("Vote: Voting for the nextmap finished. Map %s will be extended to next %.0f minutes",
mapname , steptime )
return
}
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 checkVotes()
{
new b = 0
for (new a = 0; a < g_mapVoteNum; ++a)
if (g_voteCount[b] < g_voteCount[a])
b = a
if (g_voteCount[SELECTMAPS] > g_voteCount[b])
{
new mapname[32]
get_mapname(mapname, 31)
new Float:steptime = get_cvar_float("amx_extendmap_step")
set_cvar_float("mp_timelimit", get_cvar_float("mp_timelimit") + steptime)
client_print(0, print_chat, "%L", LANG_PLAYER, "CHO_FIN_EXT", steptime)
log_amx("Vote: Voting for the nextmap finished. Map %s will be extended to next %.0f minutes", mapname, steptime)
return
}
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) {
if ( get_cvar_float("amx_vote_answers") ) {
new name[32]
get_user_name(id,name,31)
if ( key == SELECTMAPS )
client_print(0,print_chat,"%L", LANG_PLAYER, "CHOSE_EXT", name )
else if ( key < SELECTMAPS )
client_print(0,print_chat,"%L", LANG_PLAYER, "X_CHOSE_X", name, g_mapName[g_nextName[key]] )
}
++g_voteCount[key]
return PLUGIN_HANDLED
public countVote(id, key)
{
if (get_cvar_float("amx_vote_answers"))
{
new name[32]
get_user_name(id, name, 31)
if (key == SELECTMAPS)
client_print(0, print_chat, "%L", LANG_PLAYER, "CHOSE_EXT", name)
else if (key < SELECTMAPS)
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) {
for (new a=0; a<g_mapVoteNum; ++a)
if (id==g_nextName[a])
return true
return false
bool:isInMenu(id)
{
for (new a = 0; a < g_mapVoteNum; ++a)
if (id == g_nextName[a])
return true
return false
}
public voteNextmap() {
new winlimit = get_cvar_num("mp_winlimit")
new maxrounds = get_cvar_num("mp_maxrounds")
if ( winlimit ) {
new c = winlimit - 2
if ( (c > g_teamScore[0]) && (c > g_teamScore[1]) ) {
g_selected = false
return
}
}
else if ( maxrounds ) {
if ( (maxrounds - 2) > (g_teamScore[0] + g_teamScore[1]) ){
g_selected = false
return
}
}
else {
new timeleft = get_timeleft()
if (timeleft<1||timeleft>129){
g_selected = false
return
}
}
if (g_selected)
return
g_selected = true
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")
new dmax = (g_mapNums > SELECTMAPS) ? SELECTMAPS : g_mapNums
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)
public voteNextmap()
{
new winlimit = get_cvar_num("mp_winlimit")
new maxrounds = get_cvar_num("mp_maxrounds")
if (winlimit)
{
new c = winlimit - 2
if ((c > g_teamScore[0]) && (c > g_teamScore[1]))
{
g_selected = false
return
}
}
else if (maxrounds)
{
if ((maxrounds - 2) > (g_teamScore[0] + g_teamScore[1]))
{
g_selected = false
return
}
} else {
new timeleft = get_timeleft()
if (timeleft < 1 || timeleft > 129)
{
g_selected = false
return
}
}
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)
}
if (g_selected)
return
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")
g_selected = true
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")
new dmax = (g_mapNums > SELECTMAPS) ? SELECTMAPS : g_mapNums
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")))
{
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[]) {
if (!file_exists(filename)) return 0
loadSettings(filename[])
{
if (!file_exists(filename))
return 0
new szText[32]
new a, pos = 0
new currentMap[32]
get_mapname(currentMap,31)
new szText[32]
new a, pos = 0
new currentMap[32]
get_mapname(currentMap, 31)
while ( (g_mapNums < MAX_MAPS) && read_file(filename,pos++,szText,31,a) ) {
if ( szText[0] != ';'
&& parse(szText, g_mapName[g_mapNums] ,31 )
&& is_map_valid( g_mapName[g_mapNums] )
&& !equali( g_mapName[g_mapNums] ,g_lastMap)
&& !equali( g_mapName[g_mapNums] ,currentMap) )
++g_mapNums
}
while ((g_mapNums < MAX_MAPS) && read_file(filename, pos++, szText, 31, a))
{
if (szText[0] != ';' && parse(szText, g_mapName[g_mapNums], 31) && is_map_valid(g_mapName[g_mapNums])
&& !equali(g_mapName[g_mapNums], g_lastMap) && !equali(g_mapName[g_mapNums], currentMap))
++g_mapNums
}
return g_mapNums
return g_mapNums
}
public team_score() {
new team[2]
read_data(1,team,1)
g_teamScore[ (team[0]=='C') ? 0 : 1 ] = read_data(2)
public team_score()
{
new team[2]
read_data(1, team, 1)
g_teamScore[(team[0]=='C') ? 0 : 1] = read_data(2)
}
public plugin_end() {
new current_map[32]
get_mapname(current_map,31 )
set_localinfo("lastMap",current_map)
public plugin_end()
{
new current_map[32]
get_mapname(current_map, 31)
set_localinfo("lastMap", current_map)
}

View File

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

View File

@ -63,55 +63,68 @@ new g_clientMenuPlugin[MAXMENUS][STRINGSIZE]
// menuCmd: Command that should be executed to start menu
// menuAccess: Access required for menu
// menuPlugin: The exact case-insensitive name of plugin holding the menu command
public AddMenu(const menuBody[], const menuCmd[], const menuAccess, const menuPlugin[]) {
if (g_menusNumber + 1 == MAXMENUS) {
public AddMenu(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)
return
}
copy(g_menuBody[g_menusNumber], STRINGLENGTH, menuBody)
g_menuBodyPhrase[g_menusNumber] = false
copy(g_menuCmd[g_menusNumber], STRINGLENGTH, menuCmd)
g_menuAccess[g_menusNumber] = menuAccess
copy(g_menuPlugin[g_menusNumber], STRINGLENGTH, menuPlugin)
g_menusNumber++
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)
return
}
copy(g_menuBody[g_menusNumber], STRINGLENGTH, menuBody)
g_menuBodyPhrase[g_menusNumber] = true
copy(g_menuCmd[g_menusNumber], STRINGLENGTH, menuCmd)
g_menuAccess[g_menusNumber] = menuAccess
copy(g_menuPlugin[g_menusNumber], STRINGLENGTH, menuPlugin)
g_menusNumber++
//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)
return
}
copy(g_clientMenuBody[g_clientMenusNumber], STRINGLENGTH, menuBody)
g_clientMenuBodyPhrase[g_clientMenusNumber] = false
copy(g_clientMenuCmd[g_clientMenusNumber], STRINGLENGTH, menuCmd)
g_clientMenuAccess[g_clientMenusNumber] = menuAccess
copy(g_clientMenuPlugin[g_clientMenusNumber], STRINGLENGTH, menuPlugin)
g_clientMenusNumber++
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("BAN_PLAYER", "amx_banmenu", ADMIN_BAN, "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")
}
public actionMenu(id,key) {
switch (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 ] )
public actionMenu(id, key)
{
switch (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
}
public clientActionMenu(id,key) {
switch (key) {
public clientActionMenu(id, key)
{
switch (key)
{
case 8: 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
}
displayMenu(id, pos) {
displayMenu(id, pos)
{
if (pos < 0)
return
@ -155,127 +176,139 @@ displayMenu(id, pos) {
new b = 0
new start = pos * MENUITEMSPERPAGE
if ( start >= g_menusNumber ) // MENUS_NUMBER
if (start >= g_menusNumber) // MENUS_NUMBER
start = pos = g_menuPosition[id] = 0
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))
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))
new end = start + MENUITEMSPERPAGE
new keys = MENU_KEY_0
if (end > g_menusNumber ) // MENUS_NUMBER
end = g_menusNumber // MENUS_NUMBER
if (end > g_menusNumber) // MENUS_NUMBER
end = g_menusNumber // MENUS_NUMBER
new flags = get_user_flags(id)
for (new a = start; a < end; ++a) {
if ( (flags & g_menuAccess[a]) && ( is_plugin_loaded(g_menuPlugin[a])!=-1 ) ) {
for (new a = start; a < end; ++a)
{
if ((flags & g_menuAccess[a]) && (is_plugin_loaded(g_menuPlugin[a]) != -1))
{
keys |= (1<<b)
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
len += format(menuBody[len],511-len,"%d. %s^n",++b, g_menuBody[ a ] )
}
else {
len += format(menuBody[len], 511-len, "%d. %s^n", ++b, g_menuBody[a])
} else {
++b
if ( g_coloredMenus ) {
if (g_coloredMenus)
{
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
len += format(menuBody[len],511-len, "\d%d. %s^n\w",b, g_menuBody[ a ] )
}
else {
len += format(menuBody[len], 511-len, "\d%d. %s^n\w", b, g_menuBody[a])
} else {
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
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
format(menuBody[len],511-len,"^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
if (end != g_menusNumber) // 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)
}
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")
} else {
format(menuBody[len], 511-len, "^n0. %L", id, pos ? "BACK" : "EXIT")
}
show_menu(id, keys, menuBody)
}
public cmdMenu(id,level,cid) {
if (cmd_access(id,level,cid,1))
displayMenu(id, g_menuPosition[id] = 0)
clientDisplayMenu(id, pos)
{
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))
clientDisplayMenu(id, g_clientMenuPosition[id] = 0)
return PLUGIN_HANDLED
}
public addmenuitem_cmd(id, level, cid) {
public addmenuitem_cmd(id, level, cid)
{
if (!cmd_access(id, level, cid, 5))
return PLUGIN_HANDLED
@ -287,12 +320,13 @@ public addmenuitem_cmd(id, level, cid) {
menuAccess = read_flags(flags)
read_argv(4, menuPlugin, STRINGLENGTH)
AddMenu(menuBody, menuCmd, menuAccess, menuPlugin)
return PLUGIN_HANDLED
}
public addclientmenuitem_cmd(id, level, cid) {
public addclientmenuitem_cmd(id, level, cid)
{
if (!cmd_access(id, level, cid, 5))
return PLUGIN_HANDLED
@ -304,15 +338,14 @@ public addclientmenuitem_cmd(id, level, cid) {
menuAccess = read_flags(flags)
read_argv(4, menuPlugin, STRINGLENGTH)
AddClientMenu(menuBody, menuCmd, menuAccess, menuPlugin)
return PLUGIN_HANDLED
}
public plugin_init() {
register_plugin("Menus Front-End",AMXX_VERSION_STR,"AMXX Dev Team")
public plugin_init()
{
register_plugin("Menus Front-End", AMXX_VERSION_STR, "AMXX Dev Team")
register_dictionary("menufront.txt")
register_dictionary("common.txt")
@ -332,4 +365,4 @@ public plugin_init() {
new configs[128]
get_configsdir(configs, 127)
server_cmd("exec %s/custommenuitems.cfg", configs)
}
}

View File

@ -34,7 +34,7 @@
#include <amxmodx>
#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_serverLang
@ -43,167 +43,188 @@ new g_coloredMenus
public plugin_init()
{
register_plugin("Multi-Lingual System",AMXX_VERSION_STR,"AMXX Dev Team")
register_dictionary("multilingual.txt")
register_dictionary("common.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_client_languages", "1")
register_concmd("amx_setlang","cmdLang",ADMIN_CFG,"<language>")
register_clcmd("amx_langmenu","cmdLangMenu",ADMIN_ALL)
register_menu("Language Menu",1023,"actionMenu")
register_plugin("Multi-Lingual System", AMXX_VERSION_STR, "AMXX Dev Team")
register_dictionary("multilingual.txt")
register_dictionary("common.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_client_languages", "1")
register_concmd("amx_setlang", "cmdLang", ADMIN_CFG, "<language>")
register_clcmd("amx_langmenu", "cmdLangMenu", ADMIN_ALL)
register_menu("Language Menu", 1023, "actionMenu")
new lang[3]
if ( vaultdata_exists("server_language") ) {
get_vaultdata("server_language",lang,2)
}
else {
copy(lang,2,"en")
set_vaultdata("server_language",lang)
}
set_cvar_string("amx_language",lang)
new lang[3]
if (vaultdata_exists("server_language"))
{
get_vaultdata("server_language", lang, 2)
} else {
copy(lang, 2, "en")
set_vaultdata("server_language", lang)
}
set_cvar_string("amx_language", lang)
g_langNum = get_langsnum()
g_serverLang = get_lang_id(lang)
g_coloredMenus = colored_menus()
g_langNum = get_langsnum()
g_serverLang = get_lang_id(lang)
g_coloredMenus = colored_menus()
}
#if defined DISPLAY_MSG
public client_putinserver(id) {
if (get_cvar_num("amx_client_languages") && !is_user_bot(id))
set_task(10.0,"dispInfo",id)
public client_putinserver(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)
}
public dispInfo(id)
{
if (get_cvar_num("amx_client_languages"))
client_print(id,print_chat,"%L",id,"TYPE_LANGMENU")
if (get_cvar_num("amx_client_languages"))
client_print(id, print_chat, "%L", id, "TYPE_LANGMENU")
}
#endif
public cmdLang(id,level,cid) {
if (!cmd_access(id,level,cid,2))
return PLUGIN_HANDLED
public cmdLang(id, level, cid)
{
if (!cmd_access(id, level, cid, 2))
return PLUGIN_HANDLED
new arg[3]
read_argv(1,arg,2)
new arg[3]
read_argv(1, arg, 2)
if ( !lang_exists(arg) ) {
console_print(id,"[AMXX] %L",id,"LANG_NOT_EXISTS")
return PLUGIN_HANDLED
}
if (!lang_exists(arg))
{
console_print(id, "[AMXX] %L", id, "LANG_NOT_EXISTS")
return PLUGIN_HANDLED
}
set_vaultdata("server_language",arg)
set_cvar_string("amx_language",arg)
g_serverLang = get_lang_id(arg)
set_vaultdata("server_language", arg)
set_cvar_string("amx_language", 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"))
{
client_print(id, print_console, "[AMXX] %L", LANG_SERVER, "LANG_MENU_DISABLED")
return PLUGIN_HANDLED
}
if (!get_cvar_num("amx_client_languages"))
{
client_print(id, print_console, "[AMXX] %L", LANG_SERVER, "LANG_MENU_DISABLED")
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)
g_menuLang[id][1] = g_serverLang
showMenu(id)
showMenu(id)
return PLUGIN_HANDLED
return PLUGIN_HANDLED
}
showMenu(id)
{
if (!get_cvar_num("amx_client_languages"))
return PLUGIN_HANDLED
new menuBody[512],pLang[3]
if (!get_cvar_num("amx_client_languages"))
return PLUGIN_HANDLED
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" )
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" )
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")
if ( access(id,ADMIN_CFG) ) {
new sLang[3]
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" )
len += format( menuBody[len],511-len,"3. %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" )
if (access(id, ADMIN_CFG))
{
new sLang[3]
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")
len += format(menuBody[len], 511-len, "3. %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")
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) {
if (!get_cvar_num("amx_client_languages"))
return 0
public actionMenu(id, key)
{
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 ( g_menuLang[id][0]<(g_langNum-1) )
g_menuLang[id][0]++
else
g_menuLang[id][0] = 0
showMenu(id)
}
if (key == 0)
{
if (g_menuLang[id][0] < (g_langNum-1))
g_menuLang[id][0]++
else
g_menuLang[id][0] = 0
showMenu(id)
}
if ( isAdmin && (key==1) ) {
if ( g_menuLang[id][1]<(g_langNum-1) )
g_menuLang[id][1]++
else
g_menuLang[id][1] = 0
showMenu(id)
}
if (isAdmin && (key == 1))
{
if (g_menuLang[id][1] < (g_langNum - 1))
g_menuLang[id][1]++
else
g_menuLang[id][1] = 0
showMenu(id)
}
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_user_info(id,"lang",pLang_old,2)
get_lang(g_serverLang,sLang_old)
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_user_info(id, "lang", pLang_old, 2)
get_lang(g_serverLang, sLang_old)
if ( isAdmin && (key==2) && !equali(sLang,sLang_old) ) {
set_vaultdata("server_language",sLang)
set_cvar_string("amx_language",sLang)
g_serverLang = g_menuLang[id][1]
format(lName,63,"%L",sLang,"LANG_NAME")
client_print(id,print_chat,"%L",pLang,"SET_LANG_SERVER",lName)
}
if (isAdmin && (key == 2) && !equali(sLang, sLang_old))
{
set_vaultdata("server_language", sLang)
set_cvar_string("amx_language", sLang)
g_serverLang = g_menuLang[id][1]
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) ) ) ) {
client_cmd(id,"setinfo ^"lang^" ^"%s^"",pLang)
format(lName,63,"%L",pLang,"LANG_NAME")
client_print(id,print_chat,"%L",pLang,"SET_LANG_USER",lName)
}
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_print(id, print_chat, "%L", pLang, "SET_LANG_USER", lName)
}
return 0
return 0
}
get_lang_id(lang[]) {
new tLang[3]
for (new i=0;i<g_langNum;i++) {
get_lang(i,tLang)
if ( equali(tLang,lang) )
return i
}
get_lang_id(lang[])
{
new tLang[3]
for (new i = 0; i < g_langNum; 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_pos
public plugin_init() {
register_plugin("NextMap",AMXX_VERSION_STR,"AMXX Dev Team")
register_dictionary("nextmap.txt")
register_event("30","changeMap","a")
register_clcmd("say nextmap","sayNextMap",0,"- displays nextmap")
register_cvar("amx_nextmap","",FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_SPONLY)
public plugin_init()
{
register_plugin("NextMap", AMXX_VERSION_STR, "AMXX Dev Team")
register_dictionary("nextmap.txt")
register_event("30", "changeMap", "a")
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]
get_localinfo( "lastmapcycle", szString , 31 )
parse( szString, szString2, 31, szString3 , 7 )
g_pos = str_to_num( szString3 )
get_cvar_string( "mapcyclefile" , g_mapCycle , 31 )
new szString[32], szString2[32], szString3[8]
get_localinfo("lastmapcycle", szString, 31)
parse(szString, szString2, 31, szString3, 7)
g_pos = str_to_num(szString3)
get_cvar_string("mapcyclefile", g_mapCycle, 31)
if ( !equal( g_mapCycle , szString2 ) )
g_pos = 0 // mapcyclefile has been changed - go from first
if (!equal(g_mapCycle, szString2))
g_pos = 0 // mapcyclefile has been changed - go from first
readMapCycle( g_mapCycle , g_nextMap , 31 )
set_cvar_string( "amx_nextmap", g_nextMap )
format( szString3 , 31, "%s %d", g_mapCycle , g_pos ) // save lastmapcycle settings
set_localinfo( "lastmapcycle", szString3 )
readMapCycle(g_mapCycle, g_nextMap, 31)
set_cvar_string("amx_nextmap", g_nextMap)
format(szString3, 31, "%s %d", g_mapCycle, g_pos) // save lastmapcycle settings
set_localinfo("lastmapcycle", szString3)
}
getNextMapName(szArg[],iMax) {
new len = get_cvar_string("amx_nextmap",szArg,iMax)
if ( is_map_valid(szArg) ) return len
len = copy(szArg,iMax,g_nextMap)
set_cvar_string("amx_nextmap",g_nextMap)
return len
getNextMapName(szArg[], iMax)
{
new len = get_cvar_string("amx_nextmap", szArg, iMax)
if (is_map_valid(szArg)) return len
len = copy(szArg, iMax, g_nextMap)
set_cvar_string("amx_nextmap", g_nextMap)
return len
}
public sayNextMap() {
new name[32]
getNextMapName(name,31)
client_print(0,print_chat,"%L %s",LANG_PLAYER,"NEXT_MAP",name)
public sayNextMap()
{
new name[32]
getNextMapName(name, 31)
client_print(0, print_chat, "%L %s", LANG_PLAYER, "NEXT_MAP", name)
}
public delayedChange( param[] ) {
set_cvar_float("mp_chattime",get_cvar_float("mp_chattime")-2.0)
server_cmd( "changelevel %s", param )
public delayedChange(param[])
{
set_cvar_float("mp_chattime", get_cvar_float("mp_chattime") - 2.0)
server_cmd("changelevel %s", param)
}
public changeMap() {
new string[32]
new Float:chattime = get_cvar_float("mp_chattime")
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
public changeMap()
{
new string[32]
new Float:chattime = get_cvar_float("mp_chattime")
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^")"
#if defined OBEY_MAPCYCLE
readMapCycle(szFileName[], szNext[], iNext)
{
new b, i = 0, iMaps = 0
new szBuffer[32], szFirst[32]
readMapCycle(szFileName[], szNext[], iNext ) {
new b, i = 0, iMaps = 0
new szBuffer[32], szFirst[32]
if ( file_exists( szFileName ) ) {
while( read_file( szFileName , i++ , szBuffer , 31 , b ) ) {
if ( !isalnum( szBuffer[0] ) || !is_map_valid( szBuffer ) ) continue
if ( !iMaps ) copy( szFirst, 31, szBuffer )
if ( ++iMaps > g_pos ) {
copy( szNext , iNext , szBuffer )
g_pos = iMaps
return
}
}
}
if ( !iMaps ) {
log_amx( g_warning , szFileName )
get_mapname( szFirst , 31 )
}
copy( szNext , iNext , szFirst )
g_pos = 1
if (file_exists(szFileName))
{
while (read_file(szFileName, i++, szBuffer, 31, b))
{
if (!isalnum(szBuffer[0]) || !is_map_valid(szBuffer)) continue
if (!iMaps)
copy(szFirst, 31, szBuffer)
if (++iMaps > g_pos)
{
copy(szNext, iNext, szBuffer)
g_pos = iMaps
return
}
}
}
if (!iMaps)
{
log_amx(g_warning, szFileName)
get_mapname(szFirst, 31)
}
copy(szNext, iNext, szFirst)
g_pos = 1
}
#else
readMapCycle(szFileName[], szNext[], iNext ) {
new b, i = 0, iMaps = 0
new szBuffer[32], szFirst[32], szCurrent[32]
get_mapname( szCurrent , 31 )
new a = g_pos
readMapCycle(szFileName[], szNext[], iNext)
{
new b, i = 0, iMaps = 0
new szBuffer[32], szFirst[32], szCurrent[32]
get_mapname(szCurrent, 31)
new a = g_pos
if ( file_exists( szFileName ) ) {
while( read_file( szFileName , i++ , szBuffer , 31 , b ) ) {
if ( !isalnum( szBuffer[0] ) || !is_map_valid( szBuffer ) ) continue
if ( !iMaps ) {
iMaps = 1
copy( szFirst, 31, szBuffer )
}
if ( iMaps == 1 ) {
if ( equali( szCurrent , szBuffer ) ) {
if ( a-- == 0 )
iMaps = 2
}
}
else {
if ( equali( szCurrent , szBuffer ) )
++g_pos
else
g_pos = 0
copy( szNext , iNext , szBuffer )
return
}
}
}
if ( !iMaps ) {
log_amx( g_warning , szFileName )
copy( szNext ,iNext , szCurrent )
}
else copy( szNext ,iNext , szFirst )
g_pos = 0
if (file_exists(szFileName))
{
while (read_file(szFileName, i++, szBuffer, 31, b))
{
if (!isalnum(szBuffer[0]) || !is_map_valid(szBuffer)) continue
if (!iMaps)
{
iMaps = 1
copy(szFirst, 31, szBuffer)
}
if (iMaps == 1)
{
if (equali(szCurrent, szBuffer))
{
if (a-- == 0)
iMaps = 2
}
} else {
if (equali(szCurrent, szBuffer))
++g_pos
else
g_pos = 0
copy(szNext, iNext, szBuffer)
return
}
}
}
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_systemNum
public plugin_init() {
register_plugin("Pause Plugins",AMXX_VERSION_STR,"AMXX Dev Team")
register_dictionary("pausecfg.txt")
register_dictionary("common.txt")
register_dictionary("admincmd.txt")
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")
public plugin_init()
{
register_plugin("Pause Plugins", AMXX_VERSION_STR, "AMXX Dev Team")
register_dictionary("pausecfg.txt")
register_dictionary("common.txt")
register_dictionary("admincmd.txt")
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
register_concmd("amx_off","cmdOFF",ADMIN_CFG,"- pauses some plugins")
register_concmd("amx_on","cmdON",ADMIN_CFG,"- unpauses some plugins")
register_concmd("amx_off", "cmdOFF", ADMIN_CFG, "- pauses some plugins")
register_concmd("amx_on", "cmdON", ADMIN_CFG, "- unpauses some plugins")
#endif
register_menucmd(register_menuid("Pause/Unpause Plugins"),1023,"actionMenu")
g_coloredMenus = colored_menus()
get_configsdir(g_fileToSave, 63);
format(g_fileToSave, 63, "%s/pausecfg.ini", g_fileToSave);
register_menucmd(register_menuid("Pause/Unpause Plugins"), 1023, "actionMenu")
g_coloredMenus = colored_menus()
get_configsdir(g_fileToSave, 63);
format(g_fileToSave, 63, "%s/pausecfg.ini", g_fileToSave);
return PLUGIN_CONTINUE
return PLUGIN_CONTINUE
}
#if defined DIRECT_ONOFF
public cmdOFF(id,level,cid) {
if (cmd_access(id,level,cid,1))
pausePlugins(id)
return PLUGIN_HANDLED
public cmdOFF(id, level, cid)
{
if (cmd_access(id, level, cid, 1))
pausePlugins(id)
return PLUGIN_HANDLED
}
public cmdON(id,level,cid) {
if (cmd_access(id,level,cid,1))
unpausePlugins(id)
return PLUGIN_HANDLED
public cmdON(id, level, cid)
{
if (cmd_access(id, level, cid, 1))
unpausePlugins(id)
return PLUGIN_HANDLED
}
#endif
public plugin_cfg() {
loadSettings(g_fileToSave)
// Put here titles of plugins which you don't want to pause
server_cmd(g_addCmd, "Admin Base" )
server_cmd(g_addCmd, "Admin Base (SQL)" )
server_cmd(g_addCmd, "Pause Plugins" )
server_cmd(g_addCmd, "TimeLeft" )
server_cmd(g_addCmd, "NextMap" )
server_cmd(g_addCmd, "Slots Reservation" )
public plugin_cfg()
{
loadSettings(g_fileToSave)
// Put here titles of plugins which you don't want to pause
server_cmd(g_addCmd, "Admin Base")
server_cmd(g_addCmd, "Admin Base (SQL)")
server_cmd(g_addCmd, "Pause Plugins")
server_cmd(g_addCmd, "TimeLeft")
server_cmd(g_addCmd, "NextMap")
server_cmd(g_addCmd, "Slots Reservation")
}
public actionMenu(id,key) {
switch (key) {
case 6: {
if (file_exists(g_fileToSave)){
delete_file(g_fileToSave)
client_print(id,print_chat,"* %L",id,"PAUSE_CONF_CLEARED")
}
else
client_print(id,print_chat,"* %L",id,"PAUSE_ALR_CLEARED")
displayMenu(id,g_menuPos[id])
}
case 7: {
if (saveSettings(g_fileToSave)){
g_Modified = 0
client_print(id,print_chat,"* %L",id,"PAUSE_CONF_SAVED")
}
else
client_print(id,print_chat,"* %L",id,"PAUSE_SAVE_FAILED")
displayMenu(id,g_menuPos[id])
}
case 8: displayMenu(id,++g_menuPos[id])
case 9: displayMenu(id,--g_menuPos[id])
default:{
new option = g_menuPos[id] * 6 + key
new file[32],status[2]
get_plugin(option,file,31,status,0,status,0,status,0,status,1)
switch( status[0] ) {
case 'r': pause("ac",file)
case 'p': {
g_Modified = 1
pause("dc",file)
}
case 's': {
g_Modified = 1
unpause("ac",file)
}
}
displayMenu(id,g_menuPos[id])
}
}
return PLUGIN_HANDLED
public actionMenu(id, key)
{
switch (key)
{
case 6:
{
if (file_exists(g_fileToSave))
{
delete_file(g_fileToSave)
client_print(id, print_chat, "* %L", id, "PAUSE_CONF_CLEARED")
}
else
client_print(id, print_chat, "* %L", id, "PAUSE_ALR_CLEARED")
displayMenu(id, g_menuPos[id])
}
case 7:
{
if (saveSettings(g_fileToSave))
{
g_Modified = 0
client_print(id, print_chat, "* %L", id, "PAUSE_CONF_SAVED")
}
else
client_print(id, print_chat, "* %L", id, "PAUSE_SAVE_FAILED")
displayMenu(id, g_menuPos[id])
}
case 8: displayMenu(id, ++g_menuPos[id])
case 9: displayMenu(id, --g_menuPos[id])
default:
{
new option = g_menuPos[id] * 6 + key
new file[32], status[2]
get_plugin(option, file, 31, status, 0, status, 0, status, 0, status, 1)
switch (status[0])
{
case 'r': pause("ac", file)
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 ) {
switch (code) {
case 'r': {
statusCode = 'O'
format( lStatus, lLen, "%L", id, "ON" )
}
case 's': {
statusCode = 'S'
format( lStatus, lLen, "%L", id, "STOPPED" )
}
case 'p': {
statusCode = 'O'
format( lStatus, lLen, "%L", id, "OFF" )
}
case 'b': {
statusCode = 'E'
format( lStatus, lLen, "%L", id, "ERROR" )
}
default: {
statusCode = 'L'
format( lStatus, lLen, "%L", id, "LOCKED" )
}
}
getStatus(id, code, &statusCode, lStatus[], lLen)
{
switch (code)
{
case 'r':
{
statusCode = 'O'
format(lStatus, lLen, "%L", id, "ON")
}
case 's':
{
statusCode = 'S'
format(lStatus, lLen, "%L", id, "STOPPED")
}
case 'p':
{
statusCode = 'O'
format(lStatus, lLen, "%L", id, "OFF")
}
case 'b':
{
statusCode = 'E'
format(lStatus, lLen, "%L", id, "ERROR")
}
default:
{
statusCode = 'L'
format(lStatus, lLen, "%L", id, "LOCKED")
}
}
}
isSystem( id ) {
for( new a = 0; a < g_systemNum; ++a)
if ( g_system[ a ] == id )
return 1
return 0
isSystem(id)
{
for (new a = 0; a < g_systemNum; ++a)
if (g_system[a] == id)
return 1
return 0
}
displayMenu(id, pos) {
if (pos < 0) return
new filename[32],title[32],status[8],statusCode
new datanum = get_pluginsnum()
new menu_body[512], start = pos * 6, k = 0
if (start >= datanum) start = pos = g_menuPos[id] = 0
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)))
new end = start + 6, keys = MENU_KEY_0|MENU_KEY_8|MENU_KEY_7
if (end > datanum) end = datanum
for (new a = start; a < end; ++a) {
get_plugin(a,filename,31,title,31,status,0,status,0,status,1)
getStatus( id, status[0], statusCode, status, 7 )
if ( isSystem( a ) || (statusCode!='O'&&statusCode!='S')) {
if ( g_coloredMenus ) {
len += format(menu_body[len],511-len, "\d%d. %s\R%s^n\w",++k, title, status )
}
else{
++k
len += format(menu_body[len],511-len, "#. %s %s^n", title, status )
}
}
else{
keys |= (1<<k)
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,"^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")
displayMenu(id, pos)
{
if (pos < 0) return
new filename[32], title[32], status[8], statusCode
new datanum = get_pluginsnum()
new menu_body[512], start = pos * 6, k = 0
if (start >= datanum)
start = pos = g_menuPos[id] = 0
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)))
new end = start + 6, keys = MENU_KEY_0|MENU_KEY_8|MENU_KEY_7
if (end > datanum)
end = datanum
for (new a = start; a < end; ++a)
{
get_plugin(a, filename, 31, title, 31, status, 0, status, 0, status, 1)
getStatus(id, status[0], statusCode, status, 7)
if (isSystem(a) || (statusCode != 'O' && statusCode != 'S'))
{
if (g_coloredMenus)
{
len += format(menu_body[len], 511-len, "\d%d. %s\R%s^n\w", ++k, title, status)
} else {
++k
len += format(menu_body[len], 511-len, "#. %s %s^n", title, status)
}
} else {
keys |= (1<<k)
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, "^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) {
if (cmd_access(id,level,cid,1))
displayMenu(id,g_menuPos[id] = 0)
return PLUGIN_HANDLED
public cmdMenu(id, level, cid)
{
if (cmd_access(id, level, cid, 1))
displayMenu(id, g_menuPos[id] = 0)
return PLUGIN_HANDLED
}
pausePlugins(id) {
new filename[32],title[32],status[2]
new count = 0, imax = get_pluginsnum()
for (new a=0;a<imax;++a){
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,"Pausing %s (file ^"%s^")",title,filename)
++count
}
}
console_print(id,"%L",id,(count==1)?"PAUSED_PLUGIN":"PAUSED_PLUGINS",count)
pausePlugins(id)
{
new filename[32], title[32], status[2]
new count = 0, imax = get_pluginsnum()
for (new a = 0; a < imax; ++a)
{
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, "Pausing %s (file ^"%s^")", title, filename)
++count
}
}
console_print(id, "%L", id, (count == 1) ? "PAUSED_PLUGIN" : "PAUSED_PLUGINS", count)
}
unpausePlugins(id) {
new filename[32],title[32],status[2]
new count = 0, imax = get_pluginsnum()
for (new a=0;a<imax;++a){
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,"Unpausing %s (file ^"%s^")",title,filename)
++count
}
}
console_print(id,"%L",id,(count==1)?"UNPAUSED_PLUGIN":"UNPAUSED_PLUGINS",count)
unpausePlugins(id)
{
new filename[32], title[32], status[2]
new count = 0, imax = get_pluginsnum()
for (new a = 0; a < imax; ++a)
{
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, "Unpausing %s (file ^"%s^")", title, filename)
++count
}
}
console_print(id, "%L", id, (count == 1) ? "UNPAUSED_PLUGIN" : "UNPAUSED_PLUGINS", count)
}
findPluginByFile(arg[32],&len) {
new name[32],title[32],status[2]
new inum = get_pluginsnum()
for(new a = 0; a < inum; ++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') ){
len = copy(arg,31,name)
return a
}
}
return -1
findPluginByFile(arg[32], &len)
{
new name[32], title[32], status[2]
new inum = get_pluginsnum()
for (new a = 0; a < inum; ++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'))
{
len = copy(arg, 31, name)
return a
}
}
return -1
}
findPluginByTitle(name[],file[],len) {
new title[32],status[2]
new inum = get_pluginsnum()
for (new a = 0; a < inum; ++a) {
get_plugin(a,file,len,title,31,status,0,status,0,status,1)
if ( equali( title , name ) )
return a
}
return -1
findPluginByTitle(name[], file[], len)
{
new title[32], status[2]
new inum = get_pluginsnum()
for (new a = 0; a < inum; ++a)
{
get_plugin(a, file, len, title, 31, status, 0, status, 0, status, 1)
if (equali(title, name))
return a
}
return -1
}
public cmdPlugin(id,level,cid) {
if (!cmd_access(id,level,cid,1))
return PLUGIN_HANDLED
new cmds[32]
read_argv(1,cmds,31)
if ( equal(cmds, "add" ) && read_argc() > 2 ) {
read_argv(2, cmds ,31)
new file[2]
if ( (g_system[ g_systemNum ] = findPluginByTitle( cmds , file , 0 )) != -1 ) {
if ( g_systemNum < MAX_SYSTEM )
g_systemNum++
else
console_print( id, "%L", id, "CANT_MARK_MORE" )
}
}
else if ( equal(cmds, "off" ) ) {
pausePlugins(id)
}
else if ( equal(cmds, "on" ) ) {
unpausePlugins(id)
}
else if ( equal(cmds, "save" ) ) {
if (saveSettings(g_fileToSave)) {
g_Modified = 0
console_print(id,"%L",id,"PAUSE_CONF_SAVED")
}
else
console_print(id,"%L",id,"PAUSE_SAVE_FAILED")
}
else if ( equal(cmds, "clear" ) ) {
if (file_exists(g_fileToSave)){
delete_file(g_fileToSave)
console_print(id,"%L",id,"PAUSE_CONF_CLEARED")
}
else
console_print(id,"%L",id,"PAUSE_ALR_CLEARED")
}
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("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 if ( equal(cmds, "enable" ) ) {
new arg[32], a , len = read_argv(2,arg,31)
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 console_print(id,"%L",id,"PAUSE_COULDNT_FIND",arg)
}
else if ( equal(cmds, "stop" ) ) {
new arg[32], a, len = read_argv(2,arg,31)
if ( len && (a = findPluginByFile(arg,len)) != -1 && !isSystem( a ) && pause("dc",arg)){
g_Modified = 1
console_print(id,"%L %L",id,"PAUSE_PLUGIN_MATCH",arg,id,"STOPPED")
}
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]
format(lName,31,"%L",id,"NAME")
format(lVersion,31,"%L",id,"VERSION")
format(lAuthor,31,"%L",id,"AUTHOR")
format(lFile,31,"%L",id,"FILE")
format(lStatus,31,"%L",id,"STATUS")
new arg1[8], running = 0
new start = read_argv(2,arg1,7) ? str_to_num(arg1) : 1
if (--start < 0) start = 0
new plgnum = get_pluginsnum()
if (start >= plgnum) 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
public cmdPlugin(id, level, cid)
{
if (!cmd_access(id, level, cid, 1))
return PLUGIN_HANDLED
new cmds[32]
read_argv(1, cmds, 31)
if (equal(cmds, "add") && read_argc() > 2)
{
read_argv(2, cmds, 31)
new file[2]
if ((g_system[g_systemNum] = findPluginByTitle(cmds, file, 0)) != -1)
{
if (g_systemNum < MAX_SYSTEM)
g_systemNum++
else
console_print(id, "%L", id, "CANT_MARK_MORE")
}
}
else if (equal(cmds, "off"))
{
pausePlugins(id)
}
else if (equal(cmds, "on"))
{
unpausePlugins(id)
}
else if (equal(cmds, "save"))
{
if (saveSettings(g_fileToSave))
{
g_Modified = 0
console_print(id, "%L", id, "PAUSE_CONF_SAVED")
}
else
console_print(id, "%L", id, "PAUSE_SAVE_FAILED")
}
else if (equal(cmds, "clear"))
{
if (file_exists(g_fileToSave))
{
delete_file(g_fileToSave)
console_print(id, "%L", id, "PAUSE_CONF_CLEARED")
}
else
console_print(id, "%L", id, "PAUSE_ALR_CLEARED")
}
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("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 if (equal(cmds, "enable"))
{
new arg[32], a, len = read_argv(2, arg, 31)
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
console_print(id, "%L", id, "PAUSE_COULDNT_FIND", arg)
}
else if (equal(cmds, "stop"))
{
new arg[32], a, len = read_argv(2, arg, 31)
if (len && (a = findPluginByFile(arg, len)) != -1 && !isSystem(a) && pause("dc", arg))
{
g_Modified = 1
console_print(id, "%L %L", id, "PAUSE_PLUGIN_MATCH", arg, id, "STOPPED")
}
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]
format(lName, 31, "%L", id, "NAME")
format(lVersion, 31, "%L", id, "VERSION")
format(lAuthor, 31, "%L", id, "AUTHOR")
format(lFile, 31, "%L", id, "FILE")
format(lStatus, 31, "%L", id, "STATUS")
new arg1[8], running = 0
new start = read_argv(2, arg1, 7) ? str_to_num(arg1) : 1
if (--start < 0)
start = 0
new plgnum = get_pluginsnum()
if (start >= plgnum)
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[]) {
if (file_exists(filename))
delete_file(filename)
new text[256], file[32],title[32],status[2]
new inum = get_pluginsnum()
if (!write_file(filename,";Generated by Pause Plugins Plugin. Do not modify!^n;Title Filename"))
return 0
for (new a = 0; a < inum; ++a) {
get_plugin(a,file,31,title,31,status,0,status,0,status,1)
if ( status[0] == 's' ){
format(text,255,"^"%s^" ;%s",title,file)
write_file(filename,text)
}
}
return 1
saveSettings(filename[])
{
if (file_exists(filename))
delete_file(filename)
new text[256], file[32], title[32], status[2]
new inum = get_pluginsnum()
if (!write_file(filename, ";Generated by Pause Plugins Plugin. Do not modify!^n;Title Filename"))
return 0
for (new a = 0; a < inum; ++a)
{
get_plugin(a, file, 31, title, 31, status, 0, status, 0, status, 1)
if (status[0] == 's')
{
format(text, 255, "^"%s^" ;%s", title, file)
write_file(filename, text)
}
}
return 1
}
loadSettings(filename[]) {
if (!file_exists(filename)) return 0
new name[256], file[32], i, pos = 0
while (read_file(filename,pos++,name,255,i)){
if ( name[0]!= ';' && parse(name,name,31) &&
(i = findPluginByTitle( name , file , 31 ) != -1) )
pause("dc", file )
}
return 1
loadSettings(filename[])
{
if (!file_exists(filename))
return 0
new name[256], file[32], i, pos = 0
while (read_file(filename, pos++, name, 255, i))
{
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_Frequency
public plugin_init() {
register_plugin("Scrolling Message",AMXX_VERSION_STR,"AMXX Dev Team")
register_dictionary("scrollmsg.txt")
register_dictionary("common.txt")
register_srvcmd("amx_scrollmsg","setMessage")
public plugin_init()
{
register_plugin("Scrolling Message", AMXX_VERSION_STR, "AMXX Dev Team")
register_dictionary("scrollmsg.txt")
register_dictionary("common.txt")
register_srvcmd("amx_scrollmsg", "setMessage")
}
public showMsg() {
new a = g_startPos, i = 0
public showMsg()
{
new a = g_startPos, i = 0
while( a < g_endPos )
g_displayMsg[i++] = g_scrollMsg[a++]
while (a < g_endPos)
g_displayMsg[i++] = g_scrollMsg[a++]
g_displayMsg[i] = 0
g_displayMsg[i] = 0
if (g_endPos < g_Length)
g_endPos++
if (g_endPos < g_Length)
g_endPos++
if (g_xPos > 0.35)
g_xPos -= 0.0063
else {
g_startPos++
g_xPos = 0.35
}
if (g_xPos > 0.35)
g_xPos -= 0.0063
else
{
g_startPos++
g_xPos = 0.35
}
set_hudmessage(200, 100, 0, g_xPos, 0.90, 0, SPEED, SPEED, 0.05, 0.05, 2)
show_hudmessage(0,g_displayMsg)
set_hudmessage(200, 100, 0, g_xPos, 0.90, 0, SPEED, SPEED, 0.05, 0.05, 2)
show_hudmessage(0, g_displayMsg)
}
public msgInit() {
g_endPos = 1
g_startPos = 0
g_xPos = 0.65
set_task( SPEED , "showMsg",123,"",0,"a", g_Length + 48)
client_print(0,print_console,g_scrollMsg)
public msgInit()
{
g_endPos = 1
g_startPos = 0
g_xPos = 0.65
set_task(SPEED, "showMsg", 123, "", 0, "a", g_Length + 48)
client_print(0, print_console, g_scrollMsg)
}
public setMessage() {
remove_task(123) /* remove current messaging */
read_argv(1,g_scrollMsg,380)
new hostname[64]
get_cvar_string("hostname",hostname,63)
replace(g_scrollMsg,380,"%hostname%",hostname)
g_Length = strlen(g_scrollMsg)
new mytime[32]
read_argv(2,mytime,31)
g_Frequency = str_to_num(mytime)
if (g_Frequency > 0) {
new minimal = floatround((g_Length + 48) * (SPEED + 0.1))
if (g_Frequency < minimal) {
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
public setMessage()
{
remove_task(123) /* remove current messaging */
read_argv(1, g_scrollMsg, 380)
new hostname[64]
get_cvar_string("hostname", hostname, 63)
replace(g_scrollMsg, 380, "%hostname%", hostname)
g_Length = strlen(g_scrollMsg)
new mytime[32]
read_argv(2, mytime, 31)
g_Frequency = str_to_num(mytime)
if (g_Frequency > 0)
{
new minimal = floatround((g_Length + 48) * (SPEED + 0.1))
if (g_Frequency < minimal)
{
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 bool:g_modified
public plugin_precache() {
register_clcmd("amx_statscfgmenu","cmdCfgMenu",ADMIN_CFG,"- displays stats configuration menu")
register_dictionary("statscfg.txt")
register_dictionary("common.txt")
register_concmd("amx_statscfg","cmdCfg",ADMIN_CFG,"- displays help for stats configuration")
public plugin_precache()
{
register_clcmd("amx_statscfgmenu", "cmdCfgMenu", ADMIN_CFG, "- displays stats configuration menu")
register_dictionary("statscfg.txt")
register_dictionary("common.txt")
register_concmd("amx_statscfg", "cmdCfg", ADMIN_CFG, "- displays help for stats configuration")
}
public plugin_init() {
register_plugin("Stats Configuration",AMXX_VERSION_STR,"AMXX Dev Team")
register_menucmd(register_menuid("Stats Configuration"),1023,"actionCfgMenu")
get_configsdir(g_fileToSave, 63)
format(g_fileToSave, 63, "%s/stats.ini", g_fileToSave)
loadSettings(g_fileToSave)
public plugin_init()
{
register_plugin("Stats Configuration", AMXX_VERSION_STR, "AMXX Dev Team")
register_menucmd(register_menuid("Stats Configuration"), 1023, "actionCfgMenu")
get_configsdir(g_fileToSave, 63)
format(g_fileToSave, 63, "%s/stats.ini", g_fileToSave)
loadSettings(g_fileToSave)
}
public cmdCfg( id,level,cid ) {
if (!cmd_access(id,level,cid,1))
return PLUGIN_HANDLED
public cmdCfg(id, level, cid)
{
if (!cmd_access(id, level, cid, 1))
return PLUGIN_HANDLED
new cmds[32]
read_argv(1,cmds,31)
new option = equali(cmds, "on" ) ? 1 : 0
if ( !option ) option = equali(cmds, "off" ) ? 2 : 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 cmds[32]
read_argv(1, cmds, 31)
new option = equali(cmds, "on") ? 1 : 0
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")
}
if (!option)
option = equali(cmds, "off") ? 2 : 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
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) {
if (cmd_access(id,level,cid,1))
displayCfgMenu(id,g_menuPosition[id] = 0)
return PLUGIN_HANDLED
public cmdCfgMenu(id, level, cid)
{
if (cmd_access(id, level, cid, 1))
displayCfgMenu(id, g_menuPosition[id] = 0)
return PLUGIN_HANDLED
}
displayCfgMenu(id,pos) {
if (pos < 0) return
new menu_body[512], start = pos * 7
if (start >= g_menuDataNum) start = pos = g_menuPosition[id] = 0
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 end = start + 7, keys = MENU_KEY_0|MENU_KEY_8, k = 0
if (end > g_menuDataNum) end = g_menuDataNum
for (new a = start; a < end; ++a) {
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" )
}
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")
displayCfgMenu(id, pos)
{
if (pos < 0)
return
new menu_body[512], start = pos * 7
if (start >= g_menuDataNum)
start = pos = g_menuPosition[id] = 0
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 end = start + 7, keys = MENU_KEY_0|MENU_KEY_8, k = 0
if (end > g_menuDataNum)
end = g_menuDataNum
for (new a = start; a < end; ++a)
{
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")
}
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) {
switch(key) {
case 7: {
if (saveSettings(g_fileToSave)) {
g_modified = false
client_print(id,print_chat,"* %L",id,"STATS_CONF_SAVED")
}
else
client_print(id,print_chat,"* %L",id,"STATS_CONF_FAILED")
displayCfgMenu(id,g_menuPosition[id])
}
case 8: displayCfgMenu(id,++g_menuPosition[id])
case 9: displayCfgMenu(id,--g_menuPosition[id])
default: {
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
public actionCfgMenu(id, key)
{
switch (key)
{
case 7:
{
if (saveSettings(g_fileToSave))
{
g_modified = false
client_print(id, print_chat, "* %L", id, "STATS_CONF_SAVED")
}
else
client_print(id, print_chat, "* %L", id, "STATS_CONF_FAILED")
displayCfgMenu(id, g_menuPosition[id])
}
case 8: displayCfgMenu(id, ++g_menuPosition[id])
case 9: displayCfgMenu(id, --g_menuPosition[id])
default:
{
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[]) {
if (file_exists(filename))
delete_file(filename)
if (!write_file(filename,";Generated by Stats Configuration Plugin. Do not modify!^n;Variable Description"))
return 0
new text[256]
for(new a = 0; a < g_menuDataNum; ++a){
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
saveSettings(filename[])
{
if (file_exists(filename))
delete_file(filename)
if (!write_file(filename, ";Generated by Stats Configuration Plugin. Do not modify!^n;Variable Description"))
return 0
new text[256]
for (new a = 0; a < g_menuDataNum; ++a)
{
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[]) {
if (!file_exists(filename))
return 0
new text[256], name[32]
new len, pos = 0, xid
while (read_file(filename,pos++,text,255,len)) {
if ( text[0] == ';' ) continue // line is a comment
parse( text , name , 31 )
if ( ( xid = get_xvar_id( name ) ) != -1 )
set_xvar_num( xid , 1 )
}
return 1
loadSettings(filename[])
{
if (!file_exists(filename))
return 0
new text[256], name[32]
new len, pos = 0, xid
while (read_file(filename, pos++, text, 255, len))
{
if (text[0] == ';') continue // line is a comment
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_menuPlayers[33][32]
new g_menuPlayersNum[33]
new g_menuOption[33] = { -1 , ... }
new g_menuOption[33] = {-1, ...}
new g_menuOrgin[33][3]
new g_coloredMenus
public plugin_init() {
register_plugin("Teleport Menu",AMXX_VERSION_STR,"AMXX Dev Team")
register_dictionary("telemenu.txt")
register_dictionary("common.txt")
register_clcmd("amx_teleportmenu","cmdTelMenu",ADMIN_CFG,"- displays teleport menu")
register_menucmd(register_menuid("Teleport Menu"),1023,"actionTelMenu")
public plugin_init()
{
register_plugin("Teleport Menu", AMXX_VERSION_STR, "AMXX Dev Team")
register_dictionary("telemenu.txt")
register_dictionary("common.txt")
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) {
switch (key) {
case 6: {
g_menuOption[id] = 1 - g_menuOption[id]
displayTelMenu(id,g_menuPosition[id])
}
case 7: {
if (g_menuOption[id] < 0) /* unlocking position for the first time */
g_menuOption[id] = 0
get_user_origin(id,g_menuOrgin[id])
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]
public actionTelMenu(id, key)
{
switch (key)
{
case 6:
{
g_menuOption[id] = 1 - g_menuOption[id]
displayTelMenu(id, g_menuPosition[id])
}
case 7:
{
if (g_menuOption[id] < 0) /* unlocking position for the first time */
g_menuOption[id] = 0
get_user_origin(id, g_menuOrgin[id])
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]
get_user_name(player,name2,31)
if (!is_user_alive(player))
{
client_print(id, print_chat, "%L", id, "CANT_PERF_DEAD", name2)
displayTelMenu(id, g_menuPosition[id])
return PLUGIN_HANDLED
}
if (!is_user_alive(player)) {
client_print(id,print_chat,"%L",id,"CANT_PERF_DEAD",name2)
displayTelMenu(id,g_menuPosition[id])
return PLUGIN_HANDLED
}
if (g_menuOption[id] > 0)
{
set_user_origin(player, g_menuOrgin[id])
} else {
new origin[3]
get_user_origin(id, origin)
set_user_origin(player, origin)
}
if (g_menuOption[id] > 0) {
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]
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)
get_user_authid(player,authid2,31)
get_user_name(id,name,31)
log_amx("Cmd: ^"%s<%d><%s><>^" teleport ^"%s<%d><%s><>^"", name, get_user_userid(id), authid, name2, get_user_userid(player), authid2)
log_amx("Cmd: ^"%s<%d><%s><>^" teleport ^"%s<%d><%s><>^"",
name,get_user_userid(id),authid, name2,get_user_userid(player),authid2 )
switch (get_cvar_num("amx_show_activity"))
{
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")) {
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)
}
displayTelMenu(id,g_menuPosition[id])
}
}
return PLUGIN_HANDLED
displayTelMenu(id, g_menuPosition[id])
}
}
return PLUGIN_HANDLED
}
displayTelMenu(id,pos) {
if (pos < 0)
return
displayTelMenu(id, pos)
{
if (pos < 0)
return
get_players(g_menuPlayers[id],g_menuPlayersNum[id])
get_players(g_menuPlayers[id], g_menuPlayersNum[id])
new menuBody[512]
new b = 0
new i
new name[32]
new start = pos * 6
new bool:blockMenu = (is_user_alive(id)&&g_menuOption[id]<1) ? true : false
new menuBody[512]
new b = 0
new i
new name[32]
new start = pos * 6
new bool:blockMenu = (is_user_alive(id) && g_menuOption[id] < 1) ? true : false
if (start >= g_menuPlayersNum[id])
start = pos = g_menuPosition[id] = 0
if (start >= g_menuPlayersNum[id])
start = pos = g_menuPosition[id] = 0
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 )) )
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)))
new end = start + 6
new keys = MENU_KEY_0|MENU_KEY_8
new end = start + 6
new keys = MENU_KEY_0|MENU_KEY_8
if (end > g_menuPlayersNum[id])
end = g_menuPlayersNum[id]
if (end > g_menuPlayersNum[id])
end = g_menuPlayersNum[id]
for (new a = start; a < end; ++a)
{
i = g_menuPlayers[id][a]
get_user_name(i, name, 31)
for (new a = start; a < end; ++a) {
i = g_menuPlayers[id][a]
get_user_name(i,name,31)
if (blockMenu || !is_user_alive(i) || (get_user_flags(i) & ADMIN_IMMUNITY))
{
++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) ) {
++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 (g_menuOption[id] > 0) // 1
{
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")
}
if ( g_menuOption[id] > 0 ) { // 1
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")
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]) {
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")
show_menu(id, keys, menuBody, -1, "Teleport Menu")
}
public cmdTelMenu(id,level,cid) {
if (cmd_access(id,level,cid,1))
displayTelMenu(id,g_menuPosition[id] = 0)
public cmdTelMenu(id, level, cid)
{
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_Switch
public plugin_init() {
register_plugin("TimeLeft",AMXX_VERSION_STR,"AMXX Dev Team")
register_dictionary("timeleft.txt")
register_cvar("amx_time_voice","1")
register_srvcmd("amx_time_display","setDisplaying")
register_cvar("amx_timeleft","00:00",FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_UNLOGGED|FCVAR_SPONLY)
register_clcmd("say timeleft","sayTimeLeft",0,"- displays timeleft")
register_clcmd("say thetime","sayTheTime",0,"- displays current time")
set_task(0.8,"timeRemain",8648458,"",0,"b")
public plugin_init()
{
register_plugin("TimeLeft", AMXX_VERSION_STR, "AMXX Dev Team")
register_dictionary("timeleft.txt")
register_cvar("amx_time_voice", "1")
register_srvcmd("amx_time_display", "setDisplaying")
register_cvar("amx_timeleft", "00:00", FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_UNLOGGED|FCVAR_SPONLY)
register_clcmd("say timeleft", "sayTimeLeft", 0, "- displays timeleft")
register_clcmd("say thetime", "sayTheTime", 0, "- displays current time")
set_task(0.8, "timeRemain", 8648458, "", 0, "b")
}
public sayTheTime(id){
if ( get_cvar_num("amx_time_voice") ) {
new mhours[6], mmins[6], whours[32], wmins[32], wpm[6]
get_time("%H",mhours,5)
get_time("%M",mmins,5)
new mins = str_to_num(mmins)
new hrs = str_to_num(mhours)
if (mins)
num_to_word(mins,wmins,31)
else
wmins[0] = 0
if (hrs < 12)
wpm = "am "
else {
if (hrs > 12) hrs -= 12
wpm = "pm "
}
if (hrs)
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 sayTheTime(id)
{
if (get_cvar_num("amx_time_voice"))
{
new mhours[6], mmins[6], whours[32], wmins[32], wpm[6]
get_time("%H", mhours, 5)
get_time("%M", mmins, 5)
new mins = str_to_num(mmins)
new hrs = str_to_num(mhours)
if (mins)
num_to_word(mins, wmins, 31)
else
wmins[0] = 0
if (hrs < 12)
wpm = "am "
else
{
if (hrs > 12) hrs -= 12
wpm = "pm "
}
if (hrs)
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) {
if (get_cvar_float("mp_timelimit")) {
new a = get_timeleft()
if ( get_cvar_num("amx_time_voice") ) {
new svoice[128]
setTimeVoice( svoice , 127 , 0 , a )
client_cmd( id , svoice )
}
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
public sayTimeLeft(id)
{
if (get_cvar_float("mp_timelimit"))
{
new a = get_timeleft()
if (get_cvar_num("amx_time_voice"))
{
new svoice[128]
setTimeVoice(svoice, 127, 0, a)
client_cmd(id, svoice)
}
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) {
new secs = tmlf % 60
new mins = tmlf / 60
if (secs == 0)
format(text,len,"%d %L", mins, id, (mins > 1) ? "MINUTES" : "MINUTE" )
else if (mins == 0)
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" )
setTimeText(text[], len, tmlf, id)
{
new secs = tmlf % 60
new mins = tmlf / 60
if (secs == 0)
format(text, len, "%d %L", mins, id, (mins > 1) ? "MINUTES" : "MINUTE")
else if (mins == 0)
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) {
new temp[7][32]
new secs = tmlf % 60
new mins = tmlf / 60
for (new a = 0;a < 7;++a)
temp[a][0] = 0
if (secs > 0){
num_to_word(secs,temp[4],31)
if (!(flags & 8)) temp[5] = "seconds " /* there is no "second" in default hl */
}
if (mins > 59) {
new hours = mins / 60
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] )
setTimeVoice(text[], len, flags, tmlf)
{
new temp[7][32]
new secs = tmlf % 60
new mins = tmlf / 60
for (new a = 0;a < 7;++a)
temp[a][0] = 0
if (secs > 0)
{
num_to_word(secs, temp[4], 31)
if (!(flags & 8))
temp[5] = "seconds " /* there is no "second" in default hl */
}
if (mins > 59)
{
new hours = mins / 60
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) {
for(new i = 0;g_TimeSet[i][0];++i) {
if (g_TimeSet[i][1] & 16) {
if (g_TimeSet[i][0] > time) {
if (!g_Switch) {
g_CountDown = g_Switch = time
remove_task(8648458)
set_task(1.0,"timeRemain",34543,"",0,"b")
}
return i
}
}
else if (g_TimeSet[i][0] == time) {
return i
}
}
return -1
findDispFormat(time)
{
for (new i = 0; g_TimeSet[i][0]; ++i)
{
if (g_TimeSet[i][1] & 16)
{
if (g_TimeSet[i][0] > time)
{
if (!g_Switch)
{
g_CountDown = g_Switch = time
remove_task(8648458)
set_task(1.0, "timeRemain", 34543, "", 0, "b")
}
return i
}
}
else if (g_TimeSet[i][0] == time)
{
return i
}
}
return -1
}
public setDisplaying() {
new arg[32], flags[32], num[32]
new argc = read_argc() - 1
new i = 0
while (i < argc && i < 32) {
read_argv(i+1,arg,31)
parse(arg,flags,31,num,31)
g_TimeSet[i][0] = str_to_num(num)
g_TimeSet[i][1] = read_flags(flags)
i++
}
g_TimeSet[i][0] = 0
return PLUGIN_HANDLED
public setDisplaying()
{
new arg[32], flags[32], num[32]
new argc = read_argc() - 1
new i = 0
while (i < argc && i < 32)
{
read_argv(i + 1, arg, 31)
parse(arg, flags, 31, num, 31)
g_TimeSet[i][0] = str_to_num(num)
g_TimeSet[i][1] = read_flags(flags)
i++
}
g_TimeSet[i][0] = 0
return PLUGIN_HANDLED
}
public timeRemain(param[]) {
new gmtm = get_timeleft()
new tmlf = g_Switch ? --g_CountDown : gmtm
new stimel[12]
format(stimel,11,"%02d:%02d",gmtm / 60, gmtm % 60)
set_cvar_string("amx_timeleft",stimel)
if ( g_Switch && gmtm > g_Switch ) {
remove_task(34543)
g_Switch = 0
set_task(0.8,"timeRemain",8648458,"",0,"b")
return
}
if (tmlf > 0 && g_LastTime != tmlf) {
g_LastTime = tmlf
new tm_set = findDispFormat(tmlf)
if ( tm_set != -1){
new flags = g_TimeSet[tm_set][1]
new arg[128]
if (flags & 1) {
new players[32],pnum
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)
}
}
}
public timeRemain(param[])
{
new gmtm = get_timeleft()
new tmlf = g_Switch ? --g_CountDown : gmtm
new stimel[12]
format(stimel, 11, "%02d:%02d", gmtm / 60, gmtm % 60)
set_cvar_string("amx_timeleft", stimel)
if (g_Switch && gmtm > g_Switch)
{
remove_task(34543)
g_Switch = 0
set_task(0.8, "timeRemain", 8648458, "", 0, "b")
return
}
if (tmlf > 0 && g_LastTime != tmlf)
{
g_LastTime = tmlf
new tm_set = findDispFormat(tmlf)
if (tm_set != -1)
{
new flags = g_TimeSet[tm_set][1]
new arg[128]
if (flags & 1)
{
new players[32], pnum
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)
}
}
}
}