updated to use the multi-lingual system | better code style

This commit is contained in:
Felix Geyer 2004-08-05 11:09:16 +00:00
parent 9276dbb086
commit 89b4ef92b5
8 changed files with 609 additions and 639 deletions

View File

@ -39,25 +39,25 @@
#define MAX_CMDS_LAYERS 3 #define MAX_CMDS_LAYERS 3
new g_cmdMenuName[ MAX_CMDS_LAYERS ][ ] = { new g_cmdMenuName[ MAX_CMDS_LAYERS ][] = {
"Commands Menu", "CMD_MENU",
"Configs Menu", "CONF_MENU",
"Speech Menu" "SPE_MENU"
} }
new g_cmdMenuCmd[ MAX_CMDS_LAYERS ][ ] = { new g_cmdMenuCmd[ MAX_CMDS_LAYERS ][] = {
"amx_cmdmenu", "amx_cmdmenu",
"amx_cfgmenu", "amx_cfgmenu",
"amx_speechmenu" "amx_speechmenu"
} }
new g_cmdMenuCfg[ MAX_CMDS_LAYERS ][ ] = { new g_cmdMenuCfg[ MAX_CMDS_LAYERS ][] = {
"cmds.ini", "cmds.ini",
"configs.ini", "configs.ini",
"speech.ini" "speech.ini"
} }
new g_cmdMenuHelp[ MAX_CMDS_LAYERS ][ ] = { new g_cmdMenuHelp[ MAX_CMDS_LAYERS ][] = {
"- displays commands menu", "- displays commands menu",
"- displays configs menu", "- displays configs menu",
"- displays speech menu" "- displays speech menu"
@ -86,15 +86,17 @@ new g_menuLayer[33]
new g_coloredMenus new g_coloredMenus
public plugin_init() public plugin_init() {
{
register_plugin("Commands Menu",AMXX_VERSION_STR,"AMXX Dev Team") register_plugin("Commands Menu",AMXX_VERSION_STR,"AMXX Dev Team")
register_dictionary("cmdmenu.txt")
register_dictionary("common.txt")
new configsDir[64]; new configsDir[64],config[64]
get_configsdir(configsDir, 63); get_configsdir(configsDir, 63)
new config[64] for (new a = 0; a < MAX_CMDS_LAYERS; ++a) {
for(new a = 0; a < MAX_CMDS_LAYERS; ++a) { new MenuName[64]
register_menucmd(register_menuid( g_cmdMenuName[ a ] ),1023,"actionCmdMenu") 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 ] ) register_clcmd( g_cmdMenuCmd[ a ] ,"cmdCmdMenu",ADMIN_MENU, g_cmdMenuHelp[ a ] )
format(config,63,"%s/%s",configsDir,g_cmdMenuCfg[a]) format(config,63,"%s/%s",configsDir,g_cmdMenuCfg[a])
loadCmdSettings(config,a) loadCmdSettings(config,a)
@ -112,12 +114,11 @@ public plugin_init()
/* Commands menu */ /* Commands menu */
public actionCmdMenu(id,key) public actionCmdMenu(id,key) {
{ switch (key) {
switch(key){ case 8: displayCmdMenu(id,++g_menuPosition[id])
case 8: displayCmdMenu(id,++g_menuPosition[id]) case 9: displayCmdMenu(id,--g_menuPosition[id])
case 9: displayCmdMenu(id,--g_menuPosition[id]) default:{
default:{
new option = g_menuSelect[ id ][ g_menuPosition[id] * 8 + key ] new option = g_menuSelect[ id ][ g_menuPosition[id] * 8 + key ]
new flags = g_cmdMisc[ option ][ 1 ] new flags = g_cmdMisc[ option ][ 1 ]
if ( flags & 1) if ( flags & 1)
@ -133,8 +134,7 @@ public actionCmdMenu(id,key)
} }
displayCmdMenu(id,pos){ displayCmdMenu(id,pos) {
if (pos < 0) return if (pos < 0) return
new menuBody[512] new menuBody[512]
@ -145,7 +145,7 @@ displayCmdMenu(id,pos){
start = pos = g_menuPosition[id] = 0 start = pos = g_menuPosition[id] = 0
new len = format(menuBody,511,g_coloredMenus ? new len = format(menuBody,511,g_coloredMenus ?
"\y%s\R%d/%d^n\w^n" : "%s %d/%d^n^n" , g_cmdMenuName[ g_menuLayer[id] ], "\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 )) ) pos+1,( g_menuSelectNum[id] / 8 + ((g_menuSelectNum[id] % 8) ? 1 : 0 )) )
new end = start + 8 new end = start + 8
@ -154,33 +154,31 @@ displayCmdMenu(id,pos){
if (end > g_menuSelectNum[id]) if (end > g_menuSelectNum[id])
end = g_menuSelectNum[id] end = g_menuSelectNum[id]
for(new a = start; a < end; ++a) for(new a = start; a < end; ++a) {
{ if ( g_cmdCmd[ g_menuSelect[id][ a ] ][0] == '-' ) {
if ( g_cmdCmd[ g_menuSelect[id][ a ] ][0] == '-' )
{
if ( g_coloredMenus ) if ( g_coloredMenus )
len += format(menuBody[len],511-len,"\d%s^n\w",g_cmdName[ g_menuSelect[id][ a ] ] ) len += format(menuBody[len],511-len,"\d%s^n\w",g_cmdName[ g_menuSelect[id][ a ] ] )
else else
len += format(menuBody[len],511-len,"%s^n",g_cmdName[ g_menuSelect[id][ a ] ] ) len += format(menuBody[len],511-len,"%s^n",g_cmdName[ g_menuSelect[id][ a ] ] )
++b ++b
} }
else else {
{
keys |= (1<<b) keys |= (1<<b)
len += format(menuBody[len],511-len,"%d. %s^n",++b, g_cmdName[ g_menuSelect[id][ a ] ] ) len += format(menuBody[len],511-len,"%d. %s^n",++b, g_cmdName[ g_menuSelect[id][ a ] ] )
} }
} }
if (end != g_menuSelectNum[id]) { if (end != g_menuSelectNum[id]) {
format(menuBody[len],511-len,"^n9. More...^n0. %s", pos ? "Back" : "Exit") format(menuBody[len],511-len,"^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT" )
keys |= MENU_KEY_9 keys |= MENU_KEY_9
} }
else format(menuBody[len],511-len,"^n0. %s", pos ? "Back" : "Exit" ) else format(menuBody[len],511-len,"^n0. %L", id, pos ? "BACK" : "EXIT" )
show_menu(id,keys,menuBody) 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) public cmdCmdMenu(id,level,cid) {
{
if (!cmd_access(id,level,cid,1)) return PLUGIN_HANDLED if (!cmd_access(id,level,cid,1)) return PLUGIN_HANDLED
new szCmd[32] new szCmd[32]
@ -188,8 +186,7 @@ public cmdCmdMenu(id,level,cid)
new lvl = 0 new lvl = 0
while( lvl < MAX_CMDS_LAYERS ) while( lvl < MAX_CMDS_LAYERS ) {
{
if ( equal( g_cmdMenuCmd[ lvl ], szCmd ) ) if ( equal( g_cmdMenuCmd[ lvl ], szCmd ) )
break break
@ -205,12 +202,10 @@ public cmdCmdMenu(id,level,cid)
new a = lvl * MAX_CMDS new a = lvl * MAX_CMDS
new d , c = 0 new d , c = 0
while( c < g_cmdNum[ lvl ] ) while( c < g_cmdNum[ lvl ] ) {
{
d = a + c d = a + c
if ( g_cmdMisc[ d ][0] & flags ) if ( g_cmdMisc[ d ][0] & flags ) {
{
g_menuSelect[id][ g_menuSelectNum[id]++ ] = d g_menuSelect[id][ g_menuSelectNum[id]++ ] = d
} }
@ -223,23 +218,20 @@ public cmdCmdMenu(id,level,cid)
} }
loadCmdSettings( szFilename[], level ) loadCmdSettings( szFilename[], level ) {
{
if ( !file_exists ( szFilename ) ) if ( !file_exists ( szFilename ) )
return 0 return 0
new text[256], szFlags[32], szAccess[32] new text[256], szFlags[32], szAccess[32]
new a, pos = 0, c, d = level * MAX_CMDS new a, pos = 0, c, d = level * MAX_CMDS
while ( g_cmdNum[ level ] < MAX_CMDS && read_file (szFilename,pos++,text,255,a) ) while ( g_cmdNum[ level ] < MAX_CMDS && read_file (szFilename,pos++,text,255,a) ) {
{
if ( text[0] == ';' ) continue if ( text[0] == ';' ) continue
c = d + g_cmdNum[ level ] c = d + g_cmdNum[ level ]
if ( parse( text , g_cmdName[ c ] , 31 , if ( parse( text , g_cmdName[ c ] , 31 ,
g_cmdCmd[ c ] ,63,szFlags,31,szAccess,31 ) > 3 ) g_cmdCmd[ c ] ,63,szFlags,31,szAccess,31 ) > 3 ) {
{
while ( replace( g_cmdCmd[ c ] ,63,"\'","^"") ) { while ( replace( g_cmdCmd[ c ] ,63,"\'","^"") ) {
// do nothing // do nothing
} }
@ -256,13 +248,11 @@ loadCmdSettings( szFilename[], level )
/* Cvars menu */ /* Cvars menu */
public actionCvarMenu(id,key) public actionCvarMenu(id,key) {
{ switch (key){
switch(key){ case 8: displayCvarMenu(id,++g_menuPosition[id])
case 8: displayCvarMenu(id,++g_menuPosition[id]) case 9: displayCvarMenu(id,--g_menuPosition[id])
case 9: displayCvarMenu(id,--g_menuPosition[id]) default: {
default:{
new option = g_menuSelect[ id ][ g_menuPosition[id] * 8 + key ] new option = g_menuSelect[ id ][ g_menuPosition[id] * 8 + key ]
new szValue[32] new szValue[32]
@ -271,10 +261,8 @@ public actionCvarMenu(id,key)
new end = g_cvarMisc[ option ][ 2 ] new end = g_cvarMisc[ option ][ 2 ]
new start = g_cvarMisc[ option ][ 1 ] new start = g_cvarMisc[ option ][ 1 ]
for(new i = start ; ; ++i ) for (new i = start ; ; ++i ) {
{ if ( i < end ) {
if ( i < end )
{
if ( equal( szValue , g_cvarCmd[ i ] ) ) if ( equal( szValue , g_cvarCmd[ i ] ) )
{ {
if (++i >= end) if (++i >= end)
@ -285,8 +273,7 @@ public actionCvarMenu(id,key)
break break
} }
} }
else else {
{
set_cvar_string( g_cvarNames[ option ], g_cvarCmd[ start ] ) set_cvar_string( g_cvarNames[ option ], g_cvarCmd[ start ] )
break break
} }
@ -299,30 +286,28 @@ public actionCvarMenu(id,key)
} }
displayCvarMenu(id,pos){ displayCvarMenu(id,pos) {
if (pos < 0) return if (pos < 0) return
new menuBody[512] new menuBody[512]
new b = 0 new b = 0
new start = pos * 8 new start = pos * 8
if (start >= g_menuSelectNum[id]) if (start >= g_menuSelectNum[id])
start = pos = g_menuPosition[id] = 0 start = pos = g_menuPosition[id] = 0
new len = format(menuBody,511, g_coloredMenus ? new len = format(menuBody,511, g_coloredMenus ?
"\yCvars Menu\R%d/%d^n\w^n" : "Cvars Menu %d/%d^n^n", "\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 )) ) pos+1,( g_menuSelectNum[id] / 8 + ((g_menuSelectNum[id] % 8) ? 1 : 0 )) )
new end = start + 8 new end = start + 8
new keys = MENU_KEY_0 new keys = MENU_KEY_0
new szValue[64] new szValue[64]
if (end > g_menuSelectNum[id]) if (end > g_menuSelectNum[id])
end = g_menuSelectNum[id] end = g_menuSelectNum[id]
for(new a = start; a < end; ++a) for(new a = start; a < end; ++a) {
{
get_cvar_string( g_cvarNames[ g_menuSelect[id][ a ] ],szValue,31) get_cvar_string( g_cvarNames[ g_menuSelect[id][ a ] ],szValue,31)
keys |= (1<<b) keys |= (1<<b)
++b ++b
@ -331,17 +316,16 @@ displayCvarMenu(id,pos){
else else
len += format(menuBody[len],511-len,"%d. %s %s^n", b, g_cvarNames[ g_menuSelect[id][ a ] ], szValue ) len += format(menuBody[len],511-len,"%d. %s %s^n", b, g_cvarNames[ g_menuSelect[id][ a ] ], szValue )
} }
if (end != g_menuSelectNum[id]) { if (end != g_menuSelectNum[id]) {
format(menuBody[len],511-len,"^n9. More...^n0. %s", pos ? "Back" : "Exit") format(menuBody[len],511-len,"^n9. %L...^n0. %L",id,"MORE",id,pos ? "BACK" : "EXIT")
keys |= MENU_KEY_9 keys |= MENU_KEY_9
} }
else format(menuBody[len],511-len,"^n0. %s", pos ? "Back" : "Exit") else format(menuBody[len],511-len,"^n0. %L", id, pos ? "BACK" : "EXIT")
show_menu(id,keys,menuBody) show_menu(id,keys,menuBody)
} }
public cmdCvarMenu(id,level,cid) public cmdCvarMenu(id,level,cid) {
{
if (!cmd_access(id,level,cid,1)) return PLUGIN_HANDLED if (!cmd_access(id,level,cid,1)) return PLUGIN_HANDLED
new flags = get_user_flags(id) new flags = get_user_flags(id)
@ -357,8 +341,7 @@ public cmdCvarMenu(id,level,cid)
return PLUGIN_HANDLED return PLUGIN_HANDLED
} }
loadCvarSettings( szFilename[] ) loadCvarSettings( szFilename[] ) {
{
if ( !file_exists ( szFilename ) ) if ( !file_exists ( szFilename ) )
return 0 return 0
@ -366,8 +349,7 @@ loadCvarSettings( szFilename[] )
new inum , a, pos = 0 new inum , a, pos = 0
new cvar_values = MAX_CVARS * 5 new cvar_values = MAX_CVARS * 5
// a b c d // a b c d
while ( g_cvarNum < MAX_CVARS && read_file (szFilename,pos++,text,255,a) ) while ( g_cvarNum < MAX_CVARS && read_file (szFilename,pos++,text,255,a) ) {
{
if ( text[0] == ';' ) continue if ( text[0] == ';' ) continue
inum = parse( text , g_cvarNames[ g_cvarNum ] , 31 , inum = parse( text , g_cvarNames[ g_cvarNum ] , 31 ,
@ -382,8 +364,7 @@ loadCvarSettings( szFilename[] )
g_cvarMisc[ g_cvarNum ][1] = g_cvarCmdNum g_cvarMisc[ g_cvarNum ][1] = g_cvarCmdNum
for( a = 0 ; a < inum && g_cvarCmdNum < cvar_values ; ++a ) for ( a = 0 ; a < inum && g_cvarCmdNum < cvar_values ; ++a ) {
{
while ( replace( szValues[ a ] ,31 , "\'" , "^"" ) ) { while ( replace( szValues[ a ] ,31 , "\'" , "^"" ) ) {
// do nothing // do nothing
} }

View File

@ -35,18 +35,19 @@
#include <amxmodx> #include <amxmodx>
#include <amxmisc> #include <amxmisc>
#define MAX_MESSAGES 6 #define MAX_MESSAGES 6
#define X_POS -1.0 #define X_POS -1.0
#define Y_POS 0.30 #define Y_POS 0.30
#define HOLD_TIME 12.0 #define HOLD_TIME 12.0
new g_Values[MAX_MESSAGES][3] new g_Values[MAX_MESSAGES][3]
new g_Messages[MAX_MESSAGES][384] new g_Messages[MAX_MESSAGES][384]
new g_MessagesNum new g_MessagesNum
new g_Current new g_Current
public plugin_init(){ public plugin_init() {
register_plugin("Info. Messages",AMXX_VERSION_STR,"AMXX Dev Team") register_plugin("Info. Messages",AMXX_VERSION_STR,"AMXX Dev Team")
register_dictionary("imessage.txt")
register_srvcmd("amx_imessage","setMessage") register_srvcmd("amx_imessage","setMessage")
register_cvar("amx_freq_imessage","10") register_cvar("amx_freq_imessage","10")
new lastinfo[8] new lastinfo[8]
@ -55,7 +56,7 @@ public plugin_init(){
set_localinfo("lastinfomsg","") set_localinfo("lastinfomsg","")
} }
public infoMessage(){ public infoMessage() {
if (g_Current >= g_MessagesNum) if (g_Current >= g_MessagesNum)
g_Current = 0 g_Current = 0
set_hudmessage(g_Values[g_Current][0], g_Values[g_Current][1], g_Values[g_Current][2], set_hudmessage(g_Values[g_Current][0], g_Values[g_Current][1], g_Values[g_Current][2],
@ -67,11 +68,9 @@ public infoMessage(){
if ( freq_im > 0.0 ) set_task( freq_im ,"infoMessage",12345) if ( freq_im > 0.0 ) set_task( freq_im ,"infoMessage",12345)
} }
public setMessage(id,level,cid) { public setMessage() {
if (!cmd_access(id,level,cid,3)) if (g_MessagesNum >= MAX_MESSAGES) {
return PLUGIN_HANDLED server_print("%L",LANG_SERVER,"INF_REACH")
if (g_MessagesNum >= MAX_MESSAGES) {
console_print(id,"Information Messages limit reached!")
return PLUGIN_HANDLED return PLUGIN_HANDLED
} }
remove_task(12345) remove_task(12345)
@ -93,7 +92,7 @@ public setMessage(id,level,cid) {
return PLUGIN_HANDLED return PLUGIN_HANDLED
} }
public plugin_end(){ public plugin_end() {
new lastinfo[8] new lastinfo[8]
num_to_str(g_Current,lastinfo,7) num_to_str(g_Current,lastinfo,7)
set_localinfo("lastinfomsg",lastinfo) set_localinfo("lastinfomsg",lastinfo)

View File

@ -50,10 +50,13 @@ new g_lastMap[32]
new g_coloredMenus new g_coloredMenus
new bool:g_selected = false new bool:g_selected = false
public plugin_init() public plugin_init() {
{
register_plugin("Nextmap Chooser",AMXX_VERSION_STR,"AMXX Dev Team") register_plugin("Nextmap Chooser",AMXX_VERSION_STR,"AMXX Dev Team")
register_menucmd(register_menuid("AMX Choose nextmap:"),(-1^(-1<<(SELECTMAPS+2))),"countVote") 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_max","90")
register_cvar("amx_extendmap_step","15") register_cvar("amx_extendmap_step","15")
@ -63,7 +66,7 @@ public plugin_init()
get_localinfo("lastMap",g_lastMap,31) get_localinfo("lastMap",g_lastMap,31)
set_localinfo("lastMap","") set_localinfo("lastMap","")
new maps_ini_file[64]; new maps_ini_file[64]
get_configsdir(maps_ini_file, 63); get_configsdir(maps_ini_file, 63);
format(maps_ini_file, 63, "%s/maps.ini", maps_ini_file); format(maps_ini_file, 63, "%s/maps.ini", maps_ini_file);
if (!file_exists(maps_ini_file)) if (!file_exists(maps_ini_file))
@ -74,50 +77,50 @@ public plugin_init()
g_coloredMenus = colored_menus() g_coloredMenus = colored_menus()
} }
public checkVotes(){ public checkVotes() {
new b = 0 new b = 0
for(new a = 0; a < g_mapVoteNum; ++a) for (new a = 0; a < g_mapVoteNum; ++a)
if (g_voteCount[b] < g_voteCount[a]) if (g_voteCount[b] < g_voteCount[a])
b = a b = a
if ( g_voteCount[SELECTMAPS] > g_voteCount[b] ) { if ( g_voteCount[SELECTMAPS] > g_voteCount[b] ) {
new mapname[32] new mapname[32]
get_mapname(mapname,31) get_mapname(mapname,31)
new Float:steptime = get_cvar_float("amx_extendmap_step") new Float:steptime = get_cvar_float("amx_extendmap_step")
set_cvar_float("mp_timelimit", get_cvar_float("mp_timelimit") + steptime ) set_cvar_float("mp_timelimit", get_cvar_float("mp_timelimit") + steptime )
client_print(0,print_chat,"Choosing finished. Current map will be extended to next %.0f minutes", 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", log_amx("Vote: Voting for the nextmap finished. Map %s will be extended to next %.0f minutes",
mapname , steptime ) mapname , steptime )
return return
} }
if ( g_voteCount[b] && g_voteCount[SELECTMAPS+1] <= g_voteCount[b] ) if ( g_voteCount[b] && g_voteCount[SELECTMAPS+1] <= g_voteCount[b] )
set_cvar_string("amx_nextmap", g_mapName[g_nextName[b]] ) set_cvar_string("amx_nextmap", g_mapName[g_nextName[b]] )
new smap[32] new smap[32]
get_cvar_string("amx_nextmap",smap,31) get_cvar_string("amx_nextmap",smap,31)
client_print(0,print_chat,"Choosing finished. The nextmap will be %s", smap ) 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) log_amx("Vote: Voting for the nextmap finished. The nextmap will be %s", smap)
} }
public countVote(id,key){ public countVote(id,key) {
if ( get_cvar_float("amx_vote_answers") ) { if ( get_cvar_float("amx_vote_answers") ) {
new name[32] new name[32]
get_user_name(id,name,31) get_user_name(id,name,31)
if ( key == SELECTMAPS ) if ( key == SELECTMAPS )
client_print(0,print_chat,"%s chose map extending", name ) client_print(0,print_chat,"%L", LANG_PLAYER, "CHOSE_EXT", name )
else if ( key < SELECTMAPS ) else if ( key < SELECTMAPS )
client_print(0,print_chat,"%s chose %s", name, g_mapName[g_nextName[key]] ) client_print(0,print_chat,"%L", LANG_PLAYER, "X_CHOSE_X", name, g_mapName[g_nextName[key]] )
} }
++g_voteCount[key] ++g_voteCount[key]
return PLUGIN_HANDLED return PLUGIN_HANDLED
} }
bool:isInMenu(id){ bool:isInMenu(id) {
for(new a=0; a<g_mapVoteNum; ++a) for (new a=0; a<g_mapVoteNum; ++a)
if (id==g_nextName[a]) if (id==g_nextName[a])
return true return true
return false return false
} }
public voteNextmap(){ public voteNextmap() {
new winlimit = get_cvar_num("mp_winlimit") new winlimit = get_cvar_num("mp_winlimit")
new maxrounds = get_cvar_num("mp_maxrounds") new maxrounds = get_cvar_num("mp_maxrounds")
if ( winlimit ) { if ( winlimit ) {
@ -144,7 +147,7 @@ public voteNextmap(){
return return
g_selected = true g_selected = true
new menu[512], a, mkeys = (1<<SELECTMAPS+1) new menu[512], a, mkeys = (1<<SELECTMAPS+1)
new pos = copy(menu,511,g_coloredMenus ? "\yAMX Choose nextmap:\w^n^n" : "AMX Choose nextmap:^n^n") new pos = copy(menu,511,g_coloredMenus ? "\y%L:\w^n^n" : "%L:^n^n", LANG_SERVER, "CHOOSE_NEXTM")
new dmax = (g_mapNums > SELECTMAPS) ? SELECTMAPS : g_mapNums new dmax = (g_mapNums > SELECTMAPS) ? SELECTMAPS : g_mapNums
for(g_mapVoteNum = 0;g_mapVoteNum<dmax;++g_mapVoteNum){ for(g_mapVoteNum = 0;g_mapVoteNum<dmax;++g_mapVoteNum){
a=random_num(0,g_mapNums-1) a=random_num(0,g_mapNums-1)
@ -161,21 +164,22 @@ public voteNextmap(){
new mapname[32] new mapname[32]
get_mapname(mapname,31) get_mapname(mapname,31)
if ( (winlimit + maxrounds)==0 && (get_cvar_float("mp_timelimit") < get_cvar_float("amx_extendmap_max"))){ if ( (winlimit + maxrounds)==0 && (get_cvar_float("mp_timelimit") < get_cvar_float("amx_extendmap_max"))) {
pos += format(menu[pos],511,"%d. Extend map %s^n",SELECTMAPS+1,mapname) pos += format(menu[pos],511,"%d. %L^n",SELECTMAPS+1,LANG_SERVER,"EXTED_MAP",mapname)
mkeys |= (1<<SELECTMAPS) mkeys |= (1<<SELECTMAPS)
} }
format(menu[pos],511,"%d. None",SELECTMAPS+2) format(menu[pos],511,"%d. %L",SELECTMAPS+2,LANG_SERVER,"NONE")
show_menu(0,mkeys,menu,15) new MenuName[64]
format(MenuName,63,"%L","en","CHOOSE_NEXTM")
show_menu(0,mkeys,menu,15,MenuName)
set_task(15.0,"checkVotes") set_task(15.0,"checkVotes")
client_print(0,print_chat,"It's time to choose the nextmap...") client_print(0,print_chat,"%L",LANG_SERVER,"TIME_CHOOSE")
client_cmd(0,"spk Gman/Gman_Choose2") client_cmd(0,"spk Gman/Gman_Choose2")
log_amx("Vote: Voting for the nextmap started") log_amx("Vote: Voting for the nextmap started")
} }
loadSettings(filename[]) loadSettings(filename[]) {
{
if (!file_exists(filename)) return 0 if (!file_exists(filename)) return 0
new szText[32] new szText[32]
@ -183,8 +187,7 @@ loadSettings(filename[])
new currentMap[32] new currentMap[32]
get_mapname(currentMap,31) get_mapname(currentMap,31)
while ( (g_mapNums < MAX_MAPS) && read_file(filename,pos++,szText,31,a) ) while ( (g_mapNums < MAX_MAPS) && read_file(filename,pos++,szText,31,a) ) {
{
if ( szText[0] != ';' if ( szText[0] != ';'
&& parse(szText, g_mapName[g_mapNums] ,31 ) && parse(szText, g_mapName[g_mapNums] ,31 )
&& is_map_valid( g_mapName[g_mapNums] ) && is_map_valid( g_mapName[g_mapNums] )
@ -196,13 +199,13 @@ loadSettings(filename[])
return g_mapNums return g_mapNums
} }
public team_score(){ public team_score() {
new team[2] new team[2]
read_data(1,team,1) read_data(1,team,1)
g_teamScore[ (team[0]=='C') ? 0 : 1 ] = read_data(2) g_teamScore[ (team[0]=='C') ? 0 : 1 ] = read_data(2)
} }
public plugin_end(){ public plugin_end() {
new current_map[32] new current_map[32]
get_mapname(current_map,31 ) get_mapname(current_map,31 )
set_localinfo("lastMap",current_map) set_localinfo("lastMap",current_map)

View File

@ -50,9 +50,10 @@ new g_coloredMenus
new g_choosed new g_choosed
public plugin_init() public plugin_init() {
{
register_plugin("Maps Menu",AMXX_VERSION_STR,"AMXX Dev Team") register_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_mapmenu","cmdMapsMenu",ADMIN_MAP,"- displays changelevel menu")
register_clcmd("amx_votemapmenu","cmdVoteMapMenu",ADMIN_MAP,"- displays votemap menu") register_clcmd("amx_votemapmenu","cmdVoteMapMenu",ADMIN_MAP,"- displays votemap menu")
@ -72,73 +73,67 @@ public plugin_init()
g_coloredMenus = colored_menus() g_coloredMenus = colored_menus()
} }
new g_resultAck[] = "Result accepted" public autoRefuse() {
new g_resultRef[] = "Result refused" log_amx("Vote: %L" , "en", "RESULT_REF")
client_print(0,print_chat, "%L", LANG_PLAYER, "RESULT_REF")
public autoRefuse(){
log_amx("Vote: %s" , g_resultRef)
client_print(0,print_chat, g_resultRef )
} }
public actionResult(id,key) { public actionResult(id,key) {
remove_task( 4545454 ) remove_task( 4545454 )
switch(key){ switch (key){
case 0: { case 0: {
message_begin(MSG_ALL, SVC_INTERMISSION) message_begin(MSG_ALL, SVC_INTERMISSION)
message_end() message_end()
set_task(2.0,"delayedChange",0, g_mapName[ g_choosed ] , strlen(g_mapName[ g_choosed ]) + 1 ) set_task(2.0,"delayedChange",0, g_mapName[ g_choosed ] , strlen(g_mapName[ g_choosed ]) + 1 )
log_amx("Vote: %s" , g_resultAck ) log_amx("Vote: %L" , "en", "RESULT_ACC")
client_print(0,print_chat, g_resultAck) client_print(0,print_chat, "%L", LANG_PLAYER, "RESULT_ACC")
} }
case 1: autoRefuse() case 1: autoRefuse()
} }
return PLUGIN_HANDLED return PLUGIN_HANDLED
} }
new g_voteSuccess[] = "Voting successful. Map will be changed to" public checkVotes( id ) {
new g_VoteFailed[] = "Voting failed"
public checkVotes( id )
{
id -= 34567 id -= 34567
new num, ppl[32],a = 0 new num, ppl[32],a = 0
get_players(ppl,num,"c") get_players(ppl,num,"c")
if (num == 0) num = 1 if (num == 0) num = 1
g_choosed = -1 g_choosed = -1
for(new i = 0; i < g_voteSelectedNum[id] ; ++i) for (new i = 0; i < g_voteSelectedNum[id]; ++i)
if ( g_voteCount[a] < g_voteCount[i] ) if ( g_voteCount[a] < g_voteCount[i] )
a = i a = i
if ( 100 * g_voteCount[a] / num > 50 ) { if ( 100 * g_voteCount[a] / num > 50 ) {
g_choosed = g_voteSelected[id][a] g_choosed = g_voteSelected[id][a]
client_print(0,print_chat, "%s %s" , g_voteSuccess , g_mapName[ g_choosed ] ) client_print(0,print_chat, "%L %s", LANG_PLAYER, "VOTE_SUCCESS", g_mapName[ g_choosed ] )
log_amx("Vote: %s %s" , g_voteSuccess , g_mapName[ g_choosed ] ) log_amx("Vote: %L %s", "en", "VOTE_SUCCESS", g_mapName[ g_choosed ] )
} }
if ( g_choosed != -1 ) { if ( g_choosed != -1 ) {
if ( is_user_connected( id ) ) { if ( is_user_connected( id ) ) {
new menuBody[512] new menuBody[512]
new len = format(menuBody,511,g_coloredMenus ? "\yThe winner: \w%s^n^n" : "The winner: %s^n^n", g_mapName[ g_choosed ] ) 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 += copy( menuBody[len] ,511 - len, g_coloredMenus ? "\yDo you want to continue?^n\w" : "Do you want to continue?^n" ) len += format( menuBody[len] ,511 - len, g_coloredMenus ? "\y%L^n\w" : "%L^n", id, "WANT_CONT" )
copy( menuBody[len] ,511 - len, "^n1. Yes^n2. No") format( menuBody[len], 511-len, "^n1. %L^n2. %L",id,"YES",id,"NO")
show_menu( id ,0x03 ,menuBody, 10 ) new menuName[64]
format(menuName,63,"%L","en","THE_WINNER")
show_menu( id, 0x03, menuBody, 10, menuName )
set_task(10.0,"autoRefuse",4545454) set_task(10.0,"autoRefuse",4545454)
} }
else { else {
message_begin(MSG_ALL, SVC_INTERMISSION) message_begin(MSG_ALL, SVC_INTERMISSION)
message_end() message_end()
set_task(2.0,"delayedChange",0, g_mapName[ g_choosed ] , strlen(g_mapName[ g_choosed ]) + 1 ) set_task(2.0,"delayedChange",0, g_mapName[ g_choosed ] , strlen(g_mapName[ g_choosed ]) + 1 )
} }
} }
else { else {
client_print(0,print_chat, g_VoteFailed ) client_print(0,print_chat, "%L", LANG_PLAYER, "VOTE_FAILED" )
log_amx("Vote: %s" , g_VoteFailed) log_amx("Vote: %L", "en", "VOTE_FAILED")
} }
remove_task(34567 + id) remove_task(34567 + id)
} }
public voteCount(id,key) public voteCount(id,key) {
{
if (key > 3) { if (key > 3) {
client_print(0,print_chat,"Voting has been canceled") client_print(0,print_chat,"%L",LANG_PLAYER,"VOT_CANC")
remove_task(34567 + id) remove_task(34567 + id)
set_cvar_float( "amx_last_voting" , get_gametime() ) set_cvar_float( "amx_last_voting" , get_gametime() )
log_amx("Vote: Cancel vote session") log_amx("Vote: Cancel vote session")
@ -147,130 +142,119 @@ public voteCount(id,key)
if (get_cvar_float("amx_vote_answers")) { if (get_cvar_float("amx_vote_answers")) {
new name[32] new name[32]
get_user_name(id,name,31) get_user_name(id,name,31)
client_print(0,print_chat,"%s voted for option #%d", name , key + 1 ) client_print(0,print_chat,"%L", LANG_PLAYER, "X_VOTED_FOR", name , key + 1 )
} }
++g_voteCount[key] ++g_voteCount[key]
return PLUGIN_HANDLED return PLUGIN_HANDLED
} }
isMapSelected( id , pos ) isMapSelected( id , pos ) {
{ for ( new a = 0 ; a < g_voteSelectedNum[ id ]; ++a )
for( new a = 0 ; a < g_voteSelectedNum[ id ]; ++a )
if ( g_voteSelected[ id ][ a ] == pos ) if ( g_voteSelected[ id ][ a ] == pos )
return 1 return 1
return 0 return 0
} }
displayVoteMapsMenu(id,pos) displayVoteMapsMenu(id,pos) {
{
if (pos < 0) if (pos < 0)
return return
new menuBody[512], b = 0 , start = pos * 7 new menuBody[512], b = 0 , start = pos * 7
if (start >= g_mapNums) if (start >= g_mapNums)
start = pos = g_menuPosition[id] = 0 start = pos = g_menuPosition[id] = 0
new len = format(menuBody,511, g_coloredMenus ? new len = format(menuBody,511, g_coloredMenus ?
"\yVotemap Menu\R%d/%d^n\w^n" : "Votemap Menu %d/%d^n^n", "\y%L\R%d/%d^n\w^n" : "%L %d/%d^n^n",
pos+1,( g_mapNums / 7 + (( g_mapNums % 7) ? 1 : 0 )) ) 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) if (end > g_mapNums)
end = g_mapNums end = g_mapNums
for(new a = start; a < end; ++a) for (new a = start; a < end; ++a) {
{ if ( g_voteSelectedNum[id]==4 || isMapSelected( id , pos * 7 + b ) ) {
if ( g_voteSelectedNum[id]==4 || isMapSelected( id , pos * 7 + b ) )
{
++b ++b
if ( g_coloredMenus) if ( g_coloredMenus)
len += format(menuBody[len],511-len,"\d%d. %s^n\w", b ,g_mapName[ a ]) len += format(menuBody[len],511-len,"\d%d. %s^n\w", b ,g_mapName[ a ])
else else
len += format(menuBody[len],511-len,"#. %s^n", g_mapName[ a ]) len += format(menuBody[len],511-len,"#. %s^n", g_mapName[ a ])
} }
else else {
{
keys |= (1<<b) keys |= (1<<b)
len += format(menuBody[len],511-len,"%d. %s^n", ++b ,g_mapName[ a ]) len += format(menuBody[len],511-len,"%d. %s^n", ++b ,g_mapName[ a ])
} }
} }
if ( g_voteSelectedNum[id] ) if ( g_voteSelectedNum[id] ) {
{
keys |= MENU_KEY_8 keys |= MENU_KEY_8
len += format(menuBody[len],511-len,"^n8. Start Voting^n") len += format(menuBody[len],511-len,"^n8. %L^n",id,"START_VOT")
} }
else else
len += format(menuBody[len],511-len, g_coloredMenus ? len += format(menuBody[len],511-len, g_coloredMenus ?
"^n\d8. Start Voting^n\w" : "^n#. Start Voting^n") "^n\d8. %L^n\w" : "^n#. %L^n",id,"START_VOT")
if (end != g_mapNums) if (end != g_mapNums) {
{ len += format(menuBody[len],511-len,"^n9. %L...^n0. %L^n", id, "MORE", id, pos ? "BACK" : "EXIT")
len += format(menuBody[len],511-len,"^n9. More...^n0. %s^n", pos ? "Back" : "Exit")
keys |= MENU_KEY_9 keys |= MENU_KEY_9
} }
else else
len += format(menuBody[len],511-len,"^n0. %s^n", pos ? "Back" : "Exit") len += format(menuBody[len],511-len,"^n0. %L^n", id, pos ? "BACK" : "EXIT")
len += format(menuBody[len],511-len, g_voteSelectedNum[id] ?
( g_coloredMenus ? "^n\ySelected Maps:^n\w" : "^nSelected Maps:^n") : "^n^n")
for(new c = 0; c < 4; c++) 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] ) if ( c < g_voteSelectedNum[id] )
len += format(menuBody[len],511-len,"%s^n", g_mapName[ g_voteSelected[id][ c ] ] ) len += format(menuBody[len],511-len,"%s^n", g_mapName[ g_voteSelected[id][ c ] ] )
else else
len += format(menuBody[len],511-len,"^n" ) len += format(menuBody[len],511-len,"^n" )
} }
show_menu(id,keys,menuBody) new menuName[64]
format(menuName,63,"%L","en","VOTEMAP_MENU")
show_menu(id,keys,menuBody,-1,menuName)
} }
public cmdVoteMapMenu(id,level,cid) public cmdVoteMapMenu(id,level,cid) {
{
if (!cmd_access(id,level,cid,1)) if (!cmd_access(id,level,cid,1))
return PLUGIN_HANDLED return PLUGIN_HANDLED
if ( get_cvar_float("amx_last_voting") > get_gametime() ) if ( get_cvar_float("amx_last_voting") > get_gametime() ) {
{ client_print(id,print_chat,"%L",id,"ALREADY_VOT")
client_print(id,print_chat,"There is already one voting...")
return PLUGIN_HANDLED return PLUGIN_HANDLED
} }
g_voteSelectedNum[id] = 0 g_voteSelectedNum[id] = 0
if ( g_mapNums ) if ( g_mapNums ) {
{
displayVoteMapsMenu(id,g_menuPosition[id] = 0) displayVoteMapsMenu(id,g_menuPosition[id] = 0)
} }
else else {
{ console_print(id,"%L",id,"NO_MAPS_MENU")
console_print(id,"There are no maps in menu") client_print(id,print_chat,"%L",id,"NO_MAPS_MENU")
client_print(id,print_chat,"There are no maps in menu")
} }
return PLUGIN_HANDLED return PLUGIN_HANDLED
} }
public cmdMapsMenu(id,level,cid) public cmdMapsMenu(id,level,cid) {
{
if (!cmd_access(id,level,cid,1)) if (!cmd_access(id,level,cid,1))
return PLUGIN_HANDLED return PLUGIN_HANDLED
if ( g_mapNums ) if ( g_mapNums ) {
{
displayMapsMenu(id,g_menuPosition[id] = 0) displayMapsMenu(id,g_menuPosition[id] = 0)
} }
else else {
{ console_print(id,"%L",id,"NO_MAPS_MENU")
console_print(id,"There are no maps in menu") client_print(id,print_chat,"%L",id,"NO_MAPS_MENU")
client_print(id,print_chat,"There are no maps in menu")
} }
return PLUGIN_HANDLED return PLUGIN_HANDLED
} }
@ -278,69 +262,68 @@ public delayedChange(mapname[])
server_cmd("changelevel %s",mapname) server_cmd("changelevel %s",mapname)
public actionVoteMapMenu(id,key) public actionVoteMapMenu(id,key) {
{ switch (key) {
switch(key){ case 7: {
case 7:{
new Float:voting = get_cvar_float("amx_last_voting") new Float:voting = get_cvar_float("amx_last_voting")
if ( voting > get_gametime() ){ if ( voting > get_gametime() ) {
client_print(id,print_chat,"There is already one voting...") client_print(id,print_chat,"%L",id,"ALREADY_VOT")
return PLUGIN_HANDLED return PLUGIN_HANDLED
} }
if (voting && voting + get_cvar_float("amx_vote_delay") > get_gametime()) { if (voting && voting + get_cvar_float("amx_vote_delay") > get_gametime()) {
client_print(id,print_chat,"Voting not allowed at this time") client_print(id,print_chat,"%L",id,"VOT_NOW_ALLOW")
return PLUGIN_HANDLED 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 new Float:vote_time = get_cvar_float("amx_vote_time") + 2.0
set_cvar_float("amx_last_voting", get_gametime() + vote_time ) set_cvar_float("amx_last_voting", get_gametime() + vote_time )
new iVoteTime = floatround( 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 menuBody[512]
new players[32] new players[32]
new pnum, keys, len new pnum, keys, len
get_players(players,pnum) get_players(players,pnum)
if ( g_voteSelectedNum[id] > 1 ) if ( g_voteSelectedNum[id] > 1 ) {
{
len = format(menuBody,511,g_coloredMenus ? len = format(menuBody,511,g_coloredMenus ?
"\yWhich map do you want?^n\w^n" : "Which map do you want?^n^n") "\y%L^n\w^n" : "%L^n^n", id, "WHICH_MAP")
for(new c = 0; c < g_voteSelectedNum[id] ; ++c) 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 ] ] ) len += format(menuBody[len],511,"%d. %s^n", c + 1 , g_mapName[ g_voteSelected[id][ c ] ] )
keys |= (1<<c) keys |= (1<<c)
} }
keys |= (1<<8) keys |= (1<<8)
len += format(menuBody[len],511,"^n9. None^n") len += format(menuBody[len],511,"^n9. None^n")
} }
else else {
{ len = format(menuBody,511, g_coloredMenus ? "\y%L^n%s?^n\w^n1. %L^n2. %L^n"
len = format(menuBody,511, g_coloredMenus ? "\yChange map to^n%s?^n\w^n1. Yes^n2. No^n" : "%L^n%s?^n^n1. %L^n2. %L^n", id, "CHANGE_MAP_TO", g_mapName[ g_voteSelected[id][ 0 ] ],
: "Change map to^n%s?^n^n1. Yes^n2. No^n" , g_mapName[ g_voteSelected[id][ 0 ] ] ) id, "YES", id, "NO")
keys = MENU_KEY_1|MENU_KEY_2 keys = MENU_KEY_1|MENU_KEY_2
} }
for(new b = 0; b < pnum; ++b) new menuName[64]
format(menuName,63,"%L","en","WHICH_MAP")
for (new b = 0; b < pnum; ++b)
if ( players[b] != id ) if ( players[b] != id )
show_menu(players[b],keys,menuBody, iVoteTime) show_menu(players[b],keys,menuBody, iVoteTime, menuName)
format(menuBody[len],511,"^n0. Cancel Vote") format(menuBody[len],511,"^n0. %L",id,"CANC_VOTE")
keys |= MENU_KEY_0 keys |= MENU_KEY_0
show_menu(id,keys,menuBody, iVoteTime) show_menu(id,keys,menuBody, iVoteTime, menuName)
new authid[32],name[32] new authid[32],name[32]
get_user_authid(id,authid,31) get_user_authid(id,authid,31)
get_user_name(id,name,31) get_user_name(id,name,31)
switch(get_cvar_num("amx_show_activity")) { switch (get_cvar_num("amx_show_activity")) {
case 2: client_print(0,print_chat,"ADMIN %s: vote map(s)",name) case 2: client_print(0,print_chat,"%L",LANG_PLAYER,"ADMIN_V_MAP_2",name)
case 1: client_print(0,print_chat,"ADMIN: vote map(s)") 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^")", log_amx("Vote: ^"%s<%d><%s><>^" vote maps (map#1 ^"%s^") (map#2 ^"%s^") (map#3 ^"%s^") (map#4 ^"%s^")",
@ -350,12 +333,11 @@ public actionVoteMapMenu(id,key)
g_voteSelectedNum[id] > 2 ? g_mapName[ g_voteSelected[id][ 2 ] ] : "", g_voteSelectedNum[id] > 2 ? g_mapName[ g_voteSelected[id][ 2 ] ] : "",
g_voteSelectedNum[id] > 3 ? g_mapName[ g_voteSelected[id][ 3 ] ] : "") g_voteSelectedNum[id] > 3 ? g_mapName[ g_voteSelected[id][ 3 ] ] : "")
} }
case 8: displayVoteMapsMenu(id,++g_menuPosition[id]) case 8: displayVoteMapsMenu(id,++g_menuPosition[id])
case 9: displayVoteMapsMenu(id,--g_menuPosition[id]) case 9: displayVoteMapsMenu(id,--g_menuPosition[id])
default: default: {
{
g_voteSelected[id][ g_voteSelectedNum[id]++ ] = g_menuPosition[id] * 7 + key g_voteSelected[id][ g_voteSelectedNum[id]++ ] = g_menuPosition[id] * 7 + key
displayVoteMapsMenu(id,g_menuPosition[id]) displayVoteMapsMenu(id,g_menuPosition[id])
} }
} }
@ -363,12 +345,11 @@ public actionVoteMapMenu(id,key)
} }
public actionMapsMenu(id,key) public actionMapsMenu(id,key) {
{ switch (key) {
switch(key){ case 8: displayMapsMenu(id,++g_menuPosition[id])
case 8: displayMapsMenu(id,++g_menuPosition[id]) case 9: displayMapsMenu(id,--g_menuPosition[id])
case 9: displayMapsMenu(id,--g_menuPosition[id]) default:
default:
{ {
new a = g_menuPosition[id] * 8 + key new a = g_menuPosition[id] * 8 + key
@ -379,9 +360,9 @@ public actionMapsMenu(id,key)
get_user_authid(id,authid,31) get_user_authid(id,authid,31)
get_user_name(id,name,31) get_user_name(id,name,31)
switch(get_cvar_num("amx_show_activity")) { switch (get_cvar_num("amx_show_activity")) {
case 2: client_print(0,print_chat,"ADMIN %s: changelevel %s",name,g_mapName[ a ]) case 2: client_print(0,print_chat,"%L",LANG_PLAYER,"ADMIN_CHANGEL_2",name,g_mapName[ a ])
case 1: client_print(0,print_chat,"ADMIN: changelevel %s",g_mapName[ a ]) case 1: client_print(0,print_chat,"%L",LANG_PLAYER,"ADMIN_CHANGEL_2",g_mapName[ a ])
} }
log_amx("Cmd: ^"%s<%d><%s><>^" changelevel ^"%s^"", log_amx("Cmd: ^"%s<%d><%s><>^" changelevel ^"%s^"",
@ -395,63 +376,60 @@ public actionMapsMenu(id,key)
return PLUGIN_HANDLED return PLUGIN_HANDLED
} }
displayMapsMenu(id,pos) displayMapsMenu(id,pos) {
{
if (pos < 0) if (pos < 0)
return return
new menuBody[512] new menuBody[512]
new start = pos * 8 new start = pos * 8
new b = 0 new b = 0
if (start >= g_mapNums) if (start >= g_mapNums)
start = pos = g_menuPosition[id] = 0 start = pos = g_menuPosition[id] = 0
new len = format(menuBody,511, g_coloredMenus ? new len = format(menuBody,511, g_coloredMenus ?
"\yChangelevel Menu\R%d/%d^n\w^n" : "Changelevel Menu %d/%d^n^n", "\y%L\R%d/%d^n\w^n" : "%L %d/%d^n^n",
pos+1,( g_mapNums / 8 + (( g_mapNums % 8) ? 1 : 0 )) ) id,"CHANGLE_MENU",pos+1,( g_mapNums / 8 + (( g_mapNums % 8) ? 1 : 0 )) )
new end = start + 8 new end = start + 8
new keys = MENU_KEY_0 new keys = MENU_KEY_0
if (end > g_mapNums) if (end > g_mapNums)
end = g_mapNums end = g_mapNums
for(new a = start; a < end; ++a) for (new a = start; a < end; ++a) {
{
keys |= (1<<b) keys |= (1<<b)
len += format(menuBody[len],511-len,"%d. %s^n",++b,g_mapName[ a ]) len += format(menuBody[len],511-len,"%d. %s^n",++b,g_mapName[ a ])
} }
if (end != g_mapNums) if (end != g_mapNums) {
{ format(menuBody[len],511-len,"^n9. %L...^n0. %s", id, "MORE", id, pos ? "BACK" : "EXIT")
format(menuBody[len],511-len,"^n9. More...^n0. %s", pos ? "Back" : "Exit")
keys |= MENU_KEY_9 keys |= MENU_KEY_9
} }
else format(menuBody[len],511-len,"^n0. %s", pos ? "Back" : "Exit") else format(menuBody[len],511-len,"^n0. %s", id, pos ? "BACK" : "EXIT")
show_menu(id,keys,menuBody) new menuName[64]
format(menuName,63,"%L","en","CHANGLE_MENU")
show_menu(id,keys,menuBody,-1,menuName)
} }
load_settings(filename[]) load_settings(filename[]) {
{
if (!file_exists(filename)) if (!file_exists(filename))
return 0 return 0
new text[256] new text[256]
new a , pos = 0 new a , pos = 0
while ( g_mapNums < MAX_MAPS && read_file(filename,pos++,text,255,a) ) while ( g_mapNums < MAX_MAPS && read_file(filename,pos++,text,255,a) ) {
{
if ( text[0] == ';' ) continue if ( text[0] == ';' ) continue
if ( parse(text,g_mapName[g_mapNums],31) < 1 ) continue if ( parse(text,g_mapName[g_mapNums],31) < 1 ) continue
if ( !is_map_valid( g_mapName[g_mapNums] ) ) continue if ( !is_map_valid( g_mapName[g_mapNums] ) ) continue
g_mapNums++ g_mapNums++
} }
return 1 return 1
} }

View File

@ -37,58 +37,59 @@
new g_menuPosition[33] new g_menuPosition[33]
#define MENUS_NUMBER 15 #define MENUS_NUMBER 16
new g_menuBody[MENUS_NUMBER][] = { new g_menuBody[MENUS_NUMBER][] = {
"Kick Player", "KICK_PLAYER",
"Ban Player", "BAN_PLAYER",
"Slap/Slay Player", "SLAP_SLAY",
"Team Player^n", "TEAM_PLAYER",
"Changelevel", "CHANGEL",
"Vote for maps^n", "VOTE_MAPS",
"Speech Stuff", "SPECH_STUFF",
"Client Commands", "CLIENT_COM",
// Next Page // Next Page
"Server Commands", "SERVER_COM",
"Cvars Settings", "CVARS_SET",
"Configuration", "CONFIG",
"Stats Settings^n", "LANG_SET",
"STATS_SET",
"Pause Plugins", "PAUSE_PLUG",
"Restrict Weapons", "RES_WEAP",
"Teleport Player" /* Last is Teleport menu - if you want to move
it change also code in displayMenu (look for fun module check) */
"TELE_PLAYER" /* Last is Teleport menu - if you want to move it
change also code in displayMenu (look for fun module check) */
} }
new g_menuCmd[MENUS_NUMBER][] = { new g_menuCmd[MENUS_NUMBER][] = {
"amx_kickmenu", "amx_kickmenu",
"amx_banmenu", "amx_banmenu",
"amx_slapmenu", "amx_slapmenu",
"amx_teammenu", "amx_teammenu",
"amx_mapmenu", "amx_mapmenu",
"amx_votemapmenu", "amx_votemapmenu",
"amx_speechmenu", "amx_speechmenu",
"amx_clcmdmenu", "amx_clcmdmenu",
// Next Page // Next Page
"amx_cmdmenu", "amx_cmdmenu",
"amx_cvarmenu", "amx_cvarmenu",
"amx_cfgmenu", "amx_cfgmenu",
"amx_statscfgmenu", "amx_setlangmenu",
"amx_statscfgmenu",
"amx_pausecfgmenu", "amx_pausecfgmenu",
"amx_restmenu", "amx_restmenu",
"amx_teleportmenu" "amx_teleportmenu"
} }
// Second value sets if menu is only for CS... // Second value sets if menu is only for CS...
@ -104,11 +105,12 @@ new g_menuAccess[MENUS_NUMBER][2] = {
{ADMIN_MENU,0}, {ADMIN_MENU,0},
{ADMIN_LEVEL_A,0}, {ADMIN_LEVEL_A,0},
// Next Page // Next Page
{ADMIN_MENU,0}, {ADMIN_MENU,0},
{ADMIN_CVAR,0}, {ADMIN_CVAR,0},
{ADMIN_MENU,0}, {ADMIN_MENU,0},
{ADMIN_CFG,0},
{ADMIN_CFG,1}, {ADMIN_CFG,1},
{ADMIN_CFG,0}, {ADMIN_CFG,0},
@ -121,10 +123,12 @@ new g_coloredMenus
new g_cstrikeRunning new g_cstrikeRunning
new g_funModule new g_funModule
public plugin_init() public plugin_init() {
{
register_plugin("Menus Front-End",AMXX_VERSION_STR,"AMXX Dev Team") register_plugin("Menus Front-End",AMXX_VERSION_STR,"AMXX Dev Team")
register_dictionary("menufront.txt")
register_dictionary("common.txt")
register_menucmd(register_menuid("AMX Mod X Menu"),1023,"actionMenu") register_menucmd(register_menuid("AMX Mod X Menu"),1023,"actionMenu")
register_clcmd("amxmodmenu","cmdMenu",ADMIN_MENU,"- displays menus") register_clcmd("amxmodmenu","cmdMenu",ADMIN_MENU,"- displays menus")
@ -133,9 +137,8 @@ public plugin_init()
g_funModule = is_module_loaded("Fun") g_funModule = is_module_loaded("Fun")
} }
public actionMenu(id,key) public actionMenu(id,key) {
{ switch (key) {
switch(key){
case 8: displayMenu(id,++g_menuPosition[id]) case 8: displayMenu(id,++g_menuPosition[id])
case 9: displayMenu(id,--g_menuPosition[id]) case 9: displayMenu(id,--g_menuPosition[id])
default: client_cmd(id, g_menuCmd[ g_menuPosition[id] * 8 + key ] ) default: client_cmd(id, g_menuCmd[ g_menuPosition[id] * 8 + key ] )
@ -143,8 +146,7 @@ public actionMenu(id,key)
return PLUGIN_HANDLED return PLUGIN_HANDLED
} }
displayMenu(id,pos){ displayMenu(id,pos) {
if (pos < 0) return if (pos < 0) return
new menuBody[512] new menuBody[512]
@ -165,39 +167,34 @@ displayMenu(id,pos){
new flags = get_user_flags(id) new flags = get_user_flags(id)
for(new a = start; a < end; ++a) for (new a = start; a < end; ++a) {
{
if ( a == MENUS_NUMBER - 1 && !g_funModule ) if ( a == MENUS_NUMBER - 1 && !g_funModule )
continue // checks if there is fun module for teleport menu continue // checks if there is fun module for teleport menu
if ( (flags & g_menuAccess[a][0]) && ( g_menuAccess[a][1] ? g_cstrikeRunning : 1 ) ) if ( (flags & g_menuAccess[a][0]) && ( g_menuAccess[a][1] ? g_cstrikeRunning : 1 ) ) {
{
keys |= (1<<b) keys |= (1<<b)
len += format(menuBody[len],511-len,"%d. %s^n",++b, g_menuBody[ a ] ) len += format(menuBody[len],511-len,"%d. %L^n",++b, id, g_menuBody[ a ] )
} }
else else {
{
++b ++b
if ( g_coloredMenus ) if ( g_coloredMenus )
len += format(menuBody[len],511-len, "\d%d. %s^n\w",b, g_menuBody[ a ] ) len += format(menuBody[len],511-len, "\d%d. %L^n\w",b, id, g_menuBody[ a ] )
else else
len += format(menuBody[len],511-len, "#. %s^n",g_menuBody[ a ] ) len += format(menuBody[len],511-len, "#. %L^n", id, g_menuBody[ a ] )
} }
} }
if (end != MENUS_NUMBER ) if (end != MENUS_NUMBER ) {
{ format(menuBody[len],511-len,"^n9. %L...^n0. %s", id, "MORE", id, pos ? "BACK" : "EXIT")
format(menuBody[len],511-len,"^n9. More...^n0. %s", pos ? "Back" : "Exit")
keys |= MENU_KEY_9 keys |= MENU_KEY_9
} }
else format(menuBody[len],511-len,"^n0. %s", pos ? "Back" : "Exit") else format(menuBody[len],511-len,"^n0. %s", id, pos ? "BACK" : "EXIT")
show_menu(id,keys,menuBody) show_menu(id,keys,menuBody)
} }
public cmdMenu(id,level,cid) public cmdMenu(id,level,cid) {
{
if (cmd_access(id,level,cid,1)) if (cmd_access(id,level,cid,1))
displayMenu(id,g_menuPosition[id] = 0) displayMenu(id,g_menuPosition[id] = 0)
return PLUGIN_HANDLED return PLUGIN_HANDLED

View File

@ -32,7 +32,7 @@
* version. * version.
*/ */
#include <amxmodx> #include <amxmodx>
public MultiKill public MultiKill
public MultiKillSound public MultiKillSound
@ -66,78 +66,78 @@ public FirstBloodSound
new g_streakKills[33][2] new g_streakKills[33][2]
new g_multiKills[33][2] new g_multiKills[33][2]
new g_Planter new g_Planter
new g_Defuser new g_Defuser
new g_C4Timer new g_C4Timer
new g_Defusing new g_Defusing
new Float:g_LastOmg new Float:g_LastOmg
new Float:g_LastPlan new Float:g_LastPlan
new g_LastAnnounce new g_LastAnnounce
new g_roundCount new g_roundCount
new Float:g_doubleKill new Float:g_doubleKill
new g_doubleKillId new g_doubleKillId
new g_friend[33] new g_friend[33]
new g_firstBlood new g_firstBlood
new g_MultiKillMsg[7][] = { new g_MultiKillMsg[7][] = {
"Multi-Kill! %s^nwith %d kills (%d hs)", "Multi-Kill! %s^n%L %d kills (%d hs)",
"Ultra-Kill!!! %s^nwith %d kills (%d hs)", "Ultra-Kill!!! %s^n%L %d kills (%d hs)",
"%s IS ON A KILLING SPREE!!!^nwith %d kills (%d hs)", "%s IS ON A KILLING SPREE!!!^n%L %d kills (%d hs)",
"RAMPAGE!!! %s^nwith %d kills (%d hs)" , "RAMPAGE!!! %s^n%L %d kills (%d hs)" ,
"%s IS UNSTOPPABLE!!!^nwith %d kills (%d hs)" , "%s IS UNSTOPPABLE!!!^n%L %d kills (%d hs)",
"%s IS A MONSTER!^nwith %d kills (%d hs)", "%s IS A MONSTER!^n%L %d kills (%d hs)",
"%s IS GODLIKE!!!!^nwith %d kills (%d hs)" "%s IS GODLIKE!!!!^n%L %d kills (%d hs)"
} }
new g_Sounds[7][] = { new g_Sounds[7][] = {
"multikill", "multikill",
"ultrakill", "ultrakill",
"killingspree", "killingspree",
"rampage", "rampage",
"unstoppable", "unstoppable",
"monsterkill", "monsterkill",
"godlike" "godlike"
} }
new g_KillingMsg[7][] = { new g_KillingMsg[7][] = {
"%s: Multi-Kill!", "%s: Multi-Kill!",
"%s: Ultra-Kill!!!", "%s: Ultra-Kill!!!",
"%s IS ON A KILLING SPREE!!!", "%s IS ON A KILLING SPREE!!!",
"%s: RAMPAGE!!!", "%s: RAMPAGE!!!",
"%s IS UNSTOPPABLE!!!", "%s IS UNSTOPPABLE!!!",
"%s IS A MONSTER!", "%s IS A MONSTER!",
"%s IS GODLIKE!!!" "%s IS GODLIKE!!!"
} }
new g_KinfeMsg[4][] = { new g_KinfeMsg[4][] = {
"%s sliced and diced %s", "KNIFE_MSG_1",
"%s pulled out knife and gutted %s", "KNIFE_MSG_2",
"%s sneaks carefully behind and knifed %s", "KNIFE_MSG_3",
"%s knived %s" "KNIFE_MSG_4"
} }
new g_LastMessages[4][] = { new g_LastMessages[4][] = {
"Now all depend on you!", "LAST_MSG_1",
"I hope you still have a healthpack.", "LAST_MSG_2",
"All your teammates were killed. Good luck!", "LAST_MSG_3",
"Now you are alone. Have fun!" "LAST_MSG_4"
}
new g_HeMessages[4][] = {
"%s sends a little gift to %s",
"%s throws a small present to %s",
"%s made a precision throw to %s",
"%s got a big explosion for %s"
} }
new g_SHeMessages[4][] = { new g_HeMessages[4][] = {
"%s detonated himself with a grenade", "HE_MSG_1",
"%s trys the effect of an HE Grenade", "HE_MSG_2",
"%s swallows grenades whole!", "HE_MSG_3",
"%s explodes!" "HE_MSG_4"
}
new g_SHeMessages[4][] = {
"SHE_MSG_1",
"SHE_MSG_2",
"SHE_MSG_3",
"SHE_MSG_4",
} }
new g_HeadShots[7][] = { new g_HeadShots[7][] = {
"$kn killed $vn with a well^nplaced shot to the head!", "HS_MSG_1",
"$kn removed $vn's^nhead with the $wn", "HS_MSG_2",
"$kn turned $vn's head^ninto pudding with the $wn", "HS_MSG_3",
"$vn got pwned by $kn", "HS_MSG_4",
"$vn's head has been^nturned into red jello", "HS_MSG_5",
"$kn has superb aim with the $wn,^nas $vn well knows.", "HS_MSG_6",
"$vn's head stayed in $kn's^ncrosshairs a bit too long..." "HS_MSG_7"
} }
new g_teamsNames[2][] = { new g_teamsNames[2][] = {
@ -145,8 +145,9 @@ new g_teamsNames[2][] = {
"CT" "CT"
} }
public plugin_init(){ public plugin_init() {
register_plugin("CS Misc. Stats",AMXX_VERSION_STR,"AMXX Dev Team") register_plugin("CS Misc. Stats",AMXX_VERSION_STR,"AMXX Dev Team")
register_dictionary("miscstats.txt")
register_event("DeathMsg","eDeathMsg","a") register_event("DeathMsg","eDeathMsg","a")
register_event("TextMsg","eRestart","a","2&#Game_C","2&#Game_w") register_event("TextMsg","eRestart","a","2&#Game_C","2&#Game_w")
register_event("SendAudio", "eEndRound", "a", "2&%!MRAD_terwin","2&%!MRAD_ctwin","2&%!MRAD_rounddraw") register_event("SendAudio", "eEndRound", "a", "2&%!MRAD_terwin","2&%!MRAD_ctwin","2&%!MRAD_rounddraw")
@ -156,59 +157,59 @@ public plugin_init(){
register_event("StatusValue","hideStatus","be","1=1","2=0") register_event("StatusValue","hideStatus","be","1=1","2=0")
new mapname[32] new mapname[32]
get_mapname(mapname,31) get_mapname(mapname,31)
if (equali(mapname,"de_",3)||equali(mapname,"csde_",5)){ if (equali(mapname,"de_",3)||equali(mapname,"csde_",5)) {
register_event("StatusIcon", "eGotBomb", "be", "1=1", "1=2", "2=c4") register_event("StatusIcon", "eGotBomb", "be", "1=1", "1=2", "2=c4")
register_event("SendAudio", "eBombPlanted", "a", "2&%!MRAD_BOMBPL") register_event("SendAudio", "eBombPlanted", "a", "2&%!MRAD_BOMBPL")
register_event("SendAudio", "eBombDef", "a", "2&%!MRAD_BOMBDEF") register_event("SendAudio", "eBombDef", "a", "2&%!MRAD_BOMBDEF")
register_event("TextMsg", "eBombFail", "a", "2&#Target_B") register_event("TextMsg", "eBombFail", "a", "2&#Target_B")
register_event("BarTime", "eBombDefG", "be", "1=10", "1=5","1=3") register_event("BarTime", "eBombDefG", "be", "1=10", "1=5","1=3")
register_event("BarTime", "eBombDefL", "be", "1=0") register_event("BarTime", "eBombDefL", "be", "1=0")
register_event("TextMsg", "eBombPickUp", "bc", "2&#Got_bomb") register_event("TextMsg", "eBombPickUp", "bc", "2&#Got_bomb")
register_event("TextMsg", "eBombDrop", "bc", "2&#Game_bomb_d") register_event("TextMsg", "eBombDrop", "bc", "2&#Game_bomb_d")
} }
else if ( equali( mapname , "cs_italy" ) ) { else if ( equali( mapname , "cs_italy" ) ) {
register_event( "23" , "chickenKill", "a" , "1=108" , /*"12=106",*/ "15=4" ) register_event( "23" , "chickenKill", "a" , "1=108" , /*"12=106",*/ "15=4" )
register_event( "23" , "radioKill", "a" , "1=108" , /*"12=294",*/ "15=2" ) register_event( "23" , "radioKill", "a" , "1=108" , /*"12=294",*/ "15=2" )
} }
} }
public plugin_cfg(){ public plugin_cfg() {
new g_addStast[] = "amx_statscfg add ^"%s^" %s" new g_addStast[] = "amx_statscfg add ^"%s^" %s"
server_cmd(g_addStast,"MultiKill","MultiKill") server_cmd(g_addStast,"MultiKill","MultiKill")
server_cmd(g_addStast,"MultiKillSound","MultiKillSound") server_cmd(g_addStast,"MultiKillSound","MultiKillSound")
server_cmd(g_addStast,"Bomb Planting","BombPlanting") server_cmd(g_addStast,"Bomb Planting","BombPlanting")
server_cmd(g_addStast,"Bomb Defusing","BombDefusing") server_cmd(g_addStast,"Bomb Defusing","BombDefusing")
server_cmd(g_addStast,"Bomb Planted","BombPlanted") server_cmd(g_addStast,"Bomb Planted","BombPlanted")
server_cmd(g_addStast,"Bomb Defuse Succ.","BombDefused") server_cmd(g_addStast,"Bomb Defuse Succ.","BombDefused")
server_cmd(g_addStast,"Bomb Def. Failure","BombFailed") server_cmd(g_addStast,"Bomb Def. Failure","BombFailed")
server_cmd(g_addStast,"Bomb PickUp","BombPickUp") server_cmd(g_addStast,"Bomb PickUp","BombPickUp")
server_cmd(g_addStast,"Bomb Drop","BombDrop") server_cmd(g_addStast,"Bomb Drop","BombDrop")
server_cmd(g_addStast,"Bomb Count Down","BombCountVoice") server_cmd(g_addStast,"Bomb Count Down","BombCountVoice")
server_cmd(g_addStast,"Bomb Count Down (def)","BombCountDef") server_cmd(g_addStast,"Bomb Count Down (def)","BombCountDef")
server_cmd(g_addStast,"Bomb Site Reached","BombReached") server_cmd(g_addStast,"Bomb Site Reached","BombReached")
server_cmd(g_addStast,"Italy Bonus Kill","ItalyBonusKill") server_cmd(g_addStast,"Italy Bonus Kill","ItalyBonusKill")
server_cmd(g_addStast,"Last Man","LastMan") server_cmd(g_addStast,"Last Man","LastMan")
server_cmd(g_addStast,"Knife Kill","KnifeKill") server_cmd(g_addStast,"Knife Kill","KnifeKill")
server_cmd(g_addStast,"Knife Kill Sound","KnifeKillSound") server_cmd(g_addStast,"Knife Kill Sound","KnifeKillSound")
server_cmd(g_addStast,"Grenade Kill","GrenadeKill") server_cmd(g_addStast,"Grenade Kill","GrenadeKill")
server_cmd(g_addStast,"Grenade Suicide","GrenadeSuicide") server_cmd(g_addStast,"Grenade Suicide","GrenadeSuicide")
server_cmd(g_addStast,"HeadShot Kill","HeadShotKill") server_cmd(g_addStast,"HeadShot Kill","HeadShotKill")
server_cmd(g_addStast,"HeadShot Kill Sound","HeadShotKillSound") server_cmd(g_addStast,"HeadShot Kill Sound","HeadShotKillSound")
server_cmd(g_addStast,"Round Counter","RoundCounter") server_cmd(g_addStast,"Round Counter","RoundCounter")
server_cmd(g_addStast,"Round Counter Sound","RoundCounterSound") server_cmd(g_addStast,"Round Counter Sound","RoundCounterSound")
server_cmd(g_addStast,"Killing Streak","KillingStreak") server_cmd(g_addStast,"Killing Streak","KillingStreak")
server_cmd(g_addStast,"Killing Streak Sound","KillingStreakSound") server_cmd(g_addStast,"Killing Streak Sound","KillingStreakSound")
server_cmd(g_addStast,"Enemy Remaining","EnemyRemaining") server_cmd(g_addStast,"Enemy Remaining","EnemyRemaining")
server_cmd(g_addStast,"Double Kill","DoubleKill") server_cmd(g_addStast,"Double Kill","DoubleKill")
server_cmd(g_addStast,"Double Kill Sound","DoubleKillSound") server_cmd(g_addStast,"Double Kill Sound","DoubleKillSound")
server_cmd(g_addStast,"Player Name","PlayerName") server_cmd(g_addStast,"Player Name","PlayerName")
server_cmd(g_addStast,"First Blood Sound","FirstBloodSound") server_cmd(g_addStast,"First Blood Sound","FirstBloodSound")
} }
public client_putinserver(id) public client_putinserver(id)
g_multiKills[id] = g_streakKills[ id ] = { 0 , 0 } g_multiKills[id] = g_streakKills[ id ] = { 0 , 0 }
public eDeathMsg(){ public eDeathMsg() {
new killerId = read_data(1) new killerId = read_data(1)
if ( killerId == 0 ) return if ( killerId == 0 ) return
new victimId = read_data(2) new victimId = read_data(2)
@ -232,7 +233,7 @@ public eDeathMsg(){
set_hudmessage(0, 100, 255, 0.05, 0.55, 2, 0.02, 6.0, 0.01, 0.1, 3) set_hudmessage(0, 100, 255, 0.05, 0.55, 2, 0.02, 6.0, 0.01, 0.1, 3)
show_hudmessage(0,g_KillingMsg[ a ], name ) show_hudmessage(0,g_KillingMsg[ a ], name )
} }
if ( KillingStreakSound ) client_cmd( 0 , "spk misc/%s" , g_Sounds[ a ] ) if ( KillingStreakSound ) client_cmd( 0, "spk misc/%s", g_Sounds[ a ] )
} }
} }
if ( MultiKill || MultiKillSound ) { if ( MultiKill || MultiKillSound ) {
@ -249,7 +250,7 @@ public eDeathMsg(){
new ppl[32], pplnum new ppl[32], pplnum
new team = get_user_team( victimId ) - 1 new team = get_user_team( victimId ) - 1
get_players(ppl,pplnum,"e", g_teamsNames[1 - team] ) get_players(ppl,pplnum,"e", g_teamsNames[1 - team] )
if (pplnum){ if (pplnum) {
new eppl[32], epplnum new eppl[32], epplnum
get_players(eppl,epplnum,"ae",g_teamsNames[team]) get_players(eppl,epplnum,"ae",g_teamsNames[team])
if (epplnum) { if (epplnum) {
@ -265,7 +266,7 @@ public eDeathMsg(){
new cts[32], ts[32], ctsnum, tsnum new cts[32], ts[32], ctsnum, tsnum
get_players(cts,ctsnum,"ae", g_teamsNames[1] ) get_players(cts,ctsnum,"ae", g_teamsNames[1] )
get_players(ts,tsnum,"ae", g_teamsNames[0] ) get_players(ts,tsnum,"ae", g_teamsNames[0] )
if ( ctsnum == 1 && tsnum == 1 ){ if ( ctsnum == 1 && tsnum == 1 ) {
new ctname[32], tname[32] new ctname[32], tname[32]
get_user_name(cts[0],ctname,31) get_user_name(cts[0],ctname,31)
get_user_name(ts[0],tname,31) get_user_name(ts[0],tname,31)
@ -285,51 +286,54 @@ public eDeathMsg(){
oposite = ctsnum oposite = ctsnum
team = 1 team = 1
} }
if (g_LastAnnounce){ if (g_LastAnnounce) {
new name[32] new name[32]
get_user_name(g_LastAnnounce,name,31) get_user_name(g_LastAnnounce,name,31)
set_hudmessage(0, 255, 255, -1.0, 0.35, 0, 6.0, 6.0, 0.5, 0.15, 3) set_hudmessage(0, 255, 255, -1.0, 0.35, 0, 6.0, 6.0, 0.5, 0.15, 3)
show_hudmessage(0,"%s (%d HP) vs. %d %s%s: %s",name, show_hudmessage(0,"%s (%d HP) vs. %d %s%s: %L",name,
get_user_health(g_LastAnnounce),oposite, get_user_health(g_LastAnnounce),oposite,
g_teamsNames[team],(oposite==1)?"":"S" ,g_LastMessages[ random_num(0,3) ] ) g_teamsNames[team],(oposite==1)?"":"S",LANG_PLAYER,g_LastMessages[ random_num(0,3) ] )
client_cmd(g_LastAnnounce,"spk misc/oneandonly") client_cmd(g_LastAnnounce,"spk misc/oneandonly")
} }
} }
} }
new arg[4] new arg[4]
read_data( 4 , arg , 3 ) read_data( 4 , arg , 3 )
if ( equal( arg, "kni" ) && ( KnifeKill || KnifeKillSound ) ) { if ( equal( arg, "kni" ) && ( KnifeKill || KnifeKillSound ) ) {
if ( KnifeKill ) { if ( KnifeKill ) {
new killer[32], victim[32] new killer[32], victim[32]
get_user_name(killerId,killer,31) get_user_name(killerId,killer,31)
get_user_name(victimId,victim,31) get_user_name(victimId,victim,31)
set_hudmessage(255, 100, 100, -1.0, 0.25, 1, 6.0, 6.0, 0.5, 0.15, 1) set_hudmessage(255, 100, 100, -1.0, 0.25, 1, 6.0, 6.0, 0.5, 0.15, 1)
show_hudmessage(0,g_KinfeMsg[ random_num(0,3) ],killer,victim) show_hudmessage(0,"%L",LANG_PLAYER,g_KinfeMsg[ random_num(0,3) ],killer,victim)
} }
if ( KnifeKillSound ) client_cmd(0,"spk misc/humiliation") if ( KnifeKillSound ) client_cmd(0,"spk misc/humiliation")
} }
else if ( equal( arg, "gre" ) && (GrenadeKill || GrenadeSuicide) ) { else if ( equal( arg, "gre" ) && (GrenadeKill || GrenadeSuicide) ) {
new killer[32], victim[32] new killer[32], victim[32]
get_user_name(killerId,killer,32) get_user_name(killerId,killer,32)
get_user_name(victimId,victim,32) get_user_name(victimId,victim,32)
set_hudmessage(255, 100, 100, -1.0, 0.25, 1, 6.0, 6.0, 0.5, 0.15, 1) set_hudmessage(255, 100, 100, -1.0, 0.25, 1, 6.0, 6.0, 0.5, 0.15, 1)
if ( killerId != victimId ){ if ( killerId != victimId ) {
if ( GrenadeKill ) show_hudmessage(0,g_HeMessages[ random_num(0,3)],killer,victim) if ( GrenadeKill ) show_hudmessage(0,"%L",LANG_PLAYER,g_HeMessages[ random_num(0,3)],killer,victim)
} }
else if ( GrenadeSuicide ) show_hudmessage(0,g_SHeMessages[ random_num(0,3) ],victim) else if ( GrenadeSuicide ) show_hudmessage(0,"%L",LANG_PLAYER,g_SHeMessages[ random_num(0,3) ],victim)
} }
if ( headshot && (HeadShotKill || HeadShotKillSound) ) { if ( headshot && (HeadShotKill || HeadShotKillSound) ) {
if ( HeadShotKill ){ if ( HeadShotKill ) {
new killer[32], victim[32], weapon[32], message[128] new killer[32], victim[32], weapon[32], message[128], players[32], pnum
get_user_name(killerId,killer,31) get_user_name(killerId,killer,31)
get_user_name(victimId,victim,31) get_user_name(victimId,victim,31)
read_data( 4 , weapon , 31 ) read_data( 4 , weapon , 31 )
copy( message, 127, g_HeadShots[ random_num(0,6) ] ) get_players(players,pnum,"c")
replace( message, 127 , "$vn", victim ) for (new i=0;i<pnum;i++) {
replace( message, 127 , "$wn", weapon ) fromat( message, 127, "%L",players[i],g_HeadShots[ random_num(0,6) ] )
replace( message, 127 , "$kn", killer ) replace( message, 127 , "$vn", victim )
set_hudmessage(100, 100, 255, -1.0, 0.29, 0, 6.0, 6.0, 0.5, 0.15, 1) replace( message, 127 , "$wn", weapon )
show_hudmessage(0,message ) replace( message, 127 , "$kn", killer )
set_hudmessage(100, 100, 255, -1.0, 0.29, 0, 6.0, 6.0, 0.5, 0.15, 1)
show_hudmessage(players[i],message )
}
} }
if ( HeadShotKillSound ) { if ( HeadShotKillSound ) {
client_cmd(killerId,"spk misc/headshot") client_cmd(killerId,"spk misc/headshot")
@ -343,7 +347,7 @@ public eDeathMsg(){
new name[32] new name[32]
get_user_name( killerId , name , 31 ) get_user_name( killerId , name , 31 )
set_hudmessage(255, 0, 255, -1.0, 0.35, 0, 6.0, 6.0, 0.5, 0.15, 3) set_hudmessage(255, 0, 255, -1.0, 0.35, 0, 6.0, 6.0, 0.5, 0.15, 3)
show_hudmessage(0,"Wow! %s made a double kill!!!" ,name ) show_hudmessage(0,"%L",LANG_PLAYER,"DOUBLE_KILL",name )
} }
if ( DoubleKillSound ) client_cmd(0,"spk misc/doublekill") if ( DoubleKillSound ) client_cmd(0,"spk misc/doublekill")
} }
@ -352,17 +356,18 @@ public eDeathMsg(){
} }
} }
public hideStatus(id) public hideStatus(id) {
if ( PlayerName ){ if ( PlayerName ) {
set_hudmessage(0,0,0,0.0,0.0,0, 0.0, 0.01, 0.0, 0.0, 4) set_hudmessage(0,0,0,0.0,0.0,0, 0.0, 0.01, 0.0, 0.0, 4)
show_hudmessage(id,"") show_hudmessage(id,"")
} }
}
public setTeam(id) public setTeam(id)
g_friend[id] = read_data(2) g_friend[id] = read_data(2)
public showStatus(id) public showStatus(id) {
if ( PlayerName ){ if ( PlayerName ) {
new name[32],pid = read_data(2) new name[32],pid = read_data(2)
get_user_name(pid,name,31) get_user_name(pid,name,31)
new color1 = 0,color2 = 0 new color1 = 0,color2 = 0
@ -370,7 +375,7 @@ public showStatus(id)
color1 = 255 color1 = 255
else else
color2 = 255 color2 = 255
if (g_friend[id]==1){ // friend if (g_friend[id]==1) { // friend
new clip, ammo, wpnid = get_user_weapon(pid,clip,ammo) new clip, ammo, wpnid = get_user_weapon(pid,clip,ammo)
new wpnname[32] new wpnname[32]
get_weaponname(wpnid,wpnname,31) get_weaponname(wpnid,wpnname,31)
@ -383,6 +388,7 @@ public showStatus(id)
show_hudmessage(id,name) show_hudmessage(id,name)
} }
} }
}
public eNewRound() public eNewRound()
if ( read_data(1) == floatround(get_cvar_float("mp_roundtime") * 60.0) ) { if ( read_data(1) == floatround(get_cvar_float("mp_roundtime") * 60.0) ) {
@ -391,29 +397,29 @@ public eNewRound()
++g_roundCount ++g_roundCount
if ( RoundCounter ) { if ( RoundCounter ) {
set_hudmessage(200, 0, 0, -1.0, 0.30, 0, 6.0, 6.0, 0.5, 0.15, 1) set_hudmessage(200, 0, 0, -1.0, 0.30, 0, 6.0, 6.0, 0.5, 0.15, 1)
show_hudmessage(0, "Prepare to FIGHT!^nRound %d" , g_roundCount ) show_hudmessage(0, "%L", LANG_PLAYER, "PREPARE_FIGHT", g_roundCount )
} }
if ( RoundCounterSound ) client_cmd( 0 , "spk misc/prepare" ) if ( RoundCounterSound ) client_cmd( 0 , "spk misc/prepare" )
if ( KillingStreak ) { if ( KillingStreak ) {
new appl[32],ppl, i new appl[32],ppl, i
get_players(appl,ppl, "ac" ) get_players(appl,ppl, "ac" )
for(new a = 0; a < ppl; ++a) { for (new a = 0; a < ppl; ++a) {
i = appl[ a ] i = appl[ a ]
if ( g_streakKills[ i ][ 0 ] >= 2 ) if ( g_streakKills[ i ][ 0 ] >= 2 )
client_print( i , print_chat , "* You've killed %d in a row so far", g_streakKills[ i ][ 0 ] ) client_print( i , print_chat , "* %L", i, "KILLED_ROW", g_streakKills[ i ][ 0 ] )
else if ( g_streakKills[ i ][ 1 ] >= 2 ) else if ( g_streakKills[ i ][ 1 ] >= 2 )
client_print( i , print_chat , "* Careful! You've died %d rounds in a row now...", g_streakKills[ i ][ 1 ] ) client_print( i , print_chat , "* %L", i, "DIED_ROUNDS", g_streakKills[ i ][ 1 ] )
} }
} }
} }
public eRestart(){ public eRestart() {
eEndRound() eEndRound()
g_roundCount = 0 g_roundCount = 0
g_firstBlood = 1 g_firstBlood = 1
} }
public eEndRound(){ public eEndRound() {
g_C4Timer = -2 g_C4Timer = -2
g_LastPlan = 0.0 g_LastPlan = 0.0
g_LastOmg = 0.0 g_LastOmg = 0.0
@ -422,18 +428,18 @@ public eEndRound(){
g_LastAnnounce = 0 g_LastAnnounce = 0
} }
public checkKills(param[]){ public checkKills(param[]) {
new id = param[0] new id = param[0]
new a = param[1] new a = param[1]
if (a == g_multiKills[id][0]){ if (a == g_multiKills[id][0]) {
a -= 3 a -= 3
if ( a > -1 ){ if ( a > -1 ) {
if ( MultiKill ) { if ( MultiKill ) {
new name[32] new name[32]
get_user_name(id,name,31) get_user_name(id,name,31)
set_hudmessage(255, 0, 100, 0.05, 0.65, 2, 0.02, 6.0, 0.01, 0.1, 2) set_hudmessage(255, 0, 100, 0.05, 0.65, 2, 0.02, 6.0, 0.01, 0.1, 2)
if ( a > 6 ) a = 6 if ( a > 6 ) a = 6
show_hudmessage(0,g_MultiKillMsg[a],name,g_multiKills[id][0],g_multiKills[id][1]) show_hudmessage(0,g_MultiKillMsg[a],name,LANG_PLAYER,"WITH",g_multiKills[id][0],g_multiKills[id][1])
} }
if ( MultiKillSound ) client_cmd(0,"spk misc/%s",g_Sounds[a]) if ( MultiKillSound ) client_cmd(0,"spk misc/%s",g_Sounds[a])
} }
@ -441,40 +447,41 @@ public checkKills(param[]){
} }
} }
public chickenKill() public chickenKill()
if ( ItalyBonusKill ) announceEvent( 0 , "Somebody killed a chicken!!!" ) if ( ItalyBonusKill ) announceEvent( 0 , "KILLED_CHICKEN" )
public radioKill() public radioKill() {
if ( ItalyBonusKill ) announceEvent( 0 , "Somebody blew up the radio!!!" ) if ( ItalyBonusKill ) announceEvent( 0 , "BLEW_RADIO" )
}
announceEvent( id , message[] ){ announceEvent( id, message[] ) {
new name[32] new name[32]
get_user_name(id, name , 31) get_user_name(id, name , 31)
set_hudmessage(255, 100, 50, -1.0, 0.30, 0, 6.0, 6.0, 0.5, 0.15, 1) set_hudmessage(255, 100, 50, -1.0, 0.30, 0, 6.0, 6.0, 0.5, 0.15, 1)
show_hudmessage(0,message,name) show_hudmessage(0,"%L",LANG_PLAYER,message,name)
} }
public eGotBomb(id){ public eGotBomb(id) {
g_Planter = id g_Planter = id
g_Defuser = g_Defusing = 0 g_Defuser = g_Defusing = 0
if ( BombReached && read_data(1)==2 && g_LastOmg<get_gametime()){ if ( BombReached && read_data(1)==2 && g_LastOmg<get_gametime()) {
g_LastOmg = get_gametime() + 15.0 g_LastOmg = get_gametime() + 15.0
announceEvent(g_Planter , "Omg! %s reached the target!" ) announceEvent(g_Planter, "REACHED_TARGET" )
} }
} }
public eBombDefG(id){ public eBombDefG(id) {
if (read_data(1) == 3){ if (read_data(1) == 3) {
if ( BombPlanting && g_LastPlan<get_gametime() ){ if ( BombPlanting && g_LastPlan<get_gametime() ) {
g_LastPlan = get_gametime() + 15.0 g_LastPlan = get_gametime() + 15.0
announceEvent(g_Planter , "%s is planting the bomb!" ) announceEvent(g_Planter, "PLANT_BOMB" )
} }
} }
else { else {
g_Defuser = g_Defusing = id g_Defuser = g_Defusing = id
if ( BombDefusing && g_LastPlan<get_gametime()){ if ( BombDefusing && g_LastPlan<get_gametime()) {
g_LastPlan = get_gametime() + 15.0 g_LastPlan = get_gametime() + 15.0
announceEvent(g_Defusing , "%s is defusing the bomb..." ) announceEvent(g_Defusing, "DEFUSING_BOMB" )
} }
} }
} }
@ -483,22 +490,22 @@ public eBombDefL(id)
g_Defusing = 0 g_Defusing = 0
public eBombPlanted() public eBombPlanted()
if ( g_C4Timer != -2 ){ if ( g_C4Timer != -2 ) {
if (BombPlanted) announceEvent(g_Planter , "%s set us up the bomb!!!" ) if (BombPlanted) announceEvent(g_Planter, "SET_UP_BOMB" )
g_C4Timer = get_cvar_num("mp_c4timer") - 2 g_C4Timer = get_cvar_num("mp_c4timer") - 2
set_task(1.0,"bombTimer",8038,"",0,"b") set_task(1.0,"bombTimer",8038,"",0,"b")
g_LastPlan = 0.0 g_LastPlan = 0.0
} }
public bombTimer(){ public bombTimer() {
if (--g_C4Timer > 0){ if (--g_C4Timer > 0) {
if (BombCountVoice) { if (BombCountVoice) {
if (g_C4Timer == 30 || g_C4Timer == 20){ if (g_C4Timer == 30 || g_C4Timer == 20) {
new temp[48] new temp[48]
num_to_word(g_C4Timer,temp,47) num_to_word(g_C4Timer,temp,47)
client_cmd(0,"spk ^"vox/%s seconds until explosion^"",temp) client_cmd(0,"spk ^"vox/%s seconds until explosion^"",temp)
} }
else if (g_C4Timer < 11){ else if (g_C4Timer < 11) {
new temp[48] new temp[48]
num_to_word(g_C4Timer,temp,47) num_to_word(g_C4Timer,temp,47)
client_cmd(0,"spk ^"vox/%s^"",temp) client_cmd(0,"spk ^"vox/%s^"",temp)
@ -510,13 +517,13 @@ public bombTimer(){
} }
public eBombDef() public eBombDef()
if (BombDefused) announceEvent(g_Defuser , "%s defused the bomb!" ) if (BombDefused) announceEvent(g_Defuser, "DEFUSED_BOMB" )
public eBombFail() public eBombFail()
if (BombFailed && g_Defuser ) announceEvent(g_Defuser , "%s failed to defuse the bomb..." ) if (BombFailed && g_Defuser ) announceEvent(g_Defuser , "FAILED_DEFU" )
public eBombPickUp(id) public eBombPickUp(id)
if (BombPickUp) announceEvent(id , "%s pick up the bomb...") if (BombPickUp) announceEvent(id , "PICKED_BOMB")
public eBombDrop() public eBombDrop()
if (BombDrop) announceEvent(g_Planter , "%s dropped the bomb!!!") if (BombDrop) announceEvent(g_Planter , "DROPPED_BOMB")

View File

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

View File

@ -46,14 +46,15 @@ new g_menuPos[33]
new g_fileToSave[64] new g_fileToSave[64]
new g_coloredMenus new g_coloredMenus
new g_Modified new g_Modified
new g_couldntFind[] = "Couldn't find a plugin matching ^"%s^"" new g_pluginMatch[] = ""
new g_pluginMatch[] = "Plugin matching ^"%s^" %s"
new g_addCmd[] = "amx_pausecfg add ^"%s^"" new g_addCmd[] = "amx_pausecfg add ^"%s^""
new g_system[MAX_SYSTEM] new g_system[MAX_SYSTEM]
new g_systemNum new g_systemNum
public plugin_init() { public plugin_init() {
register_plugin("Pause Plugins",AMXX_VERSION_STR,"AMXX Dev Team") register_plugin("Pause Plugins",AMXX_VERSION_STR,"AMXX Dev Team")
register_dictionary("pausecfg.txt")
register_dictionary("common.txt")
register_concmd("amx_pausecfg","cmdPlugin",ADMIN_CFG,"- list commands for pause/unpause managment") 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") register_clcmd("amx_pausecfgmenu","cmdMenu",ADMIN_CFG,"- pause/unpause plugins with menu")
#if defined DIRECT_ONOFF #if defined DIRECT_ONOFF
@ -64,7 +65,7 @@ public plugin_init() {
g_coloredMenus = colored_menus() g_coloredMenus = colored_menus()
get_configsdir(g_fileToSave, 63); get_configsdir(g_fileToSave, 63);
format(g_fileToSave, 63, "%s/pausecfg.ini", g_fileToSave); format(g_fileToSave, 63, "%s/pausecfg.ini", g_fileToSave);
return PLUGIN_CONTINUE return PLUGIN_CONTINUE
} }
@ -95,40 +96,40 @@ public plugin_cfg() {
server_cmd(g_addCmd, "NextMap" ) server_cmd(g_addCmd, "NextMap" )
server_cmd(g_addCmd, "Admin Help" ) server_cmd(g_addCmd, "Admin Help" )
server_cmd(g_addCmd, "Admin Base" ) server_cmd(g_addCmd, "Admin Base" )
server_cmd(g_addCmd, "Admin Votes" ) server_cmd(g_addCmd, "Admin Votes" )
server_cmd(g_addCmd, "Welcome Message" ) server_cmd(g_addCmd, "Welcome Message" )
server_cmd(g_addCmd, "Stats Configuration" ) server_cmd(g_addCmd, "Stats Configuration" )
server_cmd(g_addCmd, "Commands Menu" ) server_cmd(g_addCmd, "Commands Menu" )
server_cmd(g_addCmd, "Maps Menu" ) server_cmd(g_addCmd, "Maps Menu" )
server_cmd(g_addCmd, "Menus Front-End" ) server_cmd(g_addCmd, "Menus Front-End" )
server_cmd(g_addCmd, "Admin Base for MySQL" ) server_cmd(g_addCmd, "Admin Base (SQL)" )
server_cmd(g_addCmd, "Players Menu" ) server_cmd(g_addCmd, "Players Menu" )
server_cmd(g_addCmd, "Teleport Menu" ) server_cmd(g_addCmd, "Teleport Menu" )
} }
public actionMenu(id,key) { public actionMenu(id,key) {
switch(key){ switch (key) {
case 6:{ case 6: {
if (file_exists(g_fileToSave)){ if (file_exists(g_fileToSave)){
delete_file(g_fileToSave) delete_file(g_fileToSave)
client_print(id,print_chat,"* Configuration file cleared. Reload the map if needed") client_print(id,print_chat,"* %L",id,"CONF_CLEARED")
} }
else else
client_print(id,print_chat,"* Configuration was already cleared!") client_print(id,print_chat,"* %L",id,"ALR_CLEARED")
displayMenu(id,g_menuPos[id])
}
case 7:{
if (saveSettings(g_fileToSave)){
g_Modified = 0
client_print(id,print_chat,"* Configuration saved successfully")
}
else
client_print(id,print_chat,"* Configuration saving failed!!!")
displayMenu(id,g_menuPos[id]) displayMenu(id,g_menuPos[id])
} }
case 8: displayMenu(id,++g_menuPos[id]) case 7: {
case 9: displayMenu(id,--g_menuPos[id]) if (saveSettings(g_fileToSave)){
default:{ g_Modified = 0
client_print(id,print_chat,"* %L",id,"CONF_SAVED")
}
else
client_print(id,print_chat,"* %L",id,"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 option = g_menuPos[id] * 6 + key
new file[32],status[2] new file[32],status[2]
get_plugin(option,file,31,status,0,status,0,status,0,status,1) get_plugin(option,file,31,status,0,status,0,status,0,status,1)
@ -149,13 +150,13 @@ public actionMenu(id,key) {
return PLUGIN_HANDLED return PLUGIN_HANDLED
} }
getStatus( code, arg[], iarg ) { getStatus( id, code, arg[], iarg ) {
switch(code){ switch (code) {
case 'r': copy( arg, iarg , "ON" ) case 'r': format( arg, iarg, "%L", id, "ON" )
case 's': copy( arg, iarg , "STOPPED" ) case 's': format( arg, iarg, "%L", id, "STOPPED" )
case 'p': copy( arg, iarg , "OFF" ) case 'p': format( arg, iarg, "%L", id, "OFF" )
case 'b': copy( arg, iarg , "ERROR" ) case 'b': format( arg, iarg, "%L", id, "ERROR" )
default: copy( arg, iarg , "LOCKED" ) default: format( arg, iarg, "%L", id, "LOCKED" )
} }
} }
@ -173,13 +174,13 @@ displayMenu(id, pos) {
new menu_body[512], start = pos * 6, k = 0 new menu_body[512], start = pos * 6, k = 0
if (start >= datanum) start = pos = g_menuPos[id] = 0 if (start >= datanum) start = pos = g_menuPos[id] = 0
new len = format(menu_body,511, new len = format(menu_body,511,
g_coloredMenus ? "\yPause/Unpause Plugins\R%d/%d^n\w^n" : "Pause/Unpause Plugins %d/%d^n^n" , g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%L %d/%d^n^n" ,
pos + 1,((datanum/6)+((datanum%6)?1:0))) 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 new end = start + 6, keys = MENU_KEY_0|MENU_KEY_8|MENU_KEY_7
if (end > datanum) end = datanum if (end > datanum) end = datanum
for(new a = start; a < end; ++a){ for (new a = start; a < end; ++a) {
get_plugin(a,filename,31,title,31,status,0,status,0,status,1) get_plugin(a,filename,31,title,31,status,0,status,0,status,1)
getStatus( status[0] , status , 7 ) getStatus( id, status[0] , status , 7 )
if ( isSystem( a ) || (status[0]!='O'&&status[0]!='S')) { if ( isSystem( a ) || (status[0]!='O'&&status[0]!='S')) {
if ( g_coloredMenus ) { if ( g_coloredMenus ) {
len += format(menu_body[len],511-len, "\d%d. %s\R%s^n\w",++k, title, status ) len += format(menu_body[len],511-len, "\d%d. %s\R%s^n\w",++k, title, status )
@ -194,24 +195,24 @@ displayMenu(id, pos) {
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,g_coloredMenus ? "%d. %s\y\R%s^n\w" : "%d. %s %s^n",++k,title, status )
} }
} }
len += format(menu_body[len],511-len,"^n7. Clear file with stopped^n") len += format(menu_body[len],511-len,"^n7. %L^n",id,"CLEAR_STOPPED")
len += format(menu_body[len],511-len,g_coloredMenus ? "8. Save stopped \y\R%s^n\w" len += format(menu_body[len],511-len,g_coloredMenus ? "8. %L \y\R%s^n\w"
: "8. Save stopped %s^n" ,g_Modified ? "*" : "") : "8. %L %s^n", id, "SAVE_STOPPED", g_Modified ? "*" : "")
if (end != datanum){ if (end != datanum){
format(menu_body[len],511-len,"^n9. More...^n0. %s", pos ? "Back" : "Exit") format(menu_body[len],511-len,"^n9. %L...^n0. %s", id, "MORE", id, pos ? "BACK" : "EXIT")
keys |= MENU_KEY_9 keys |= MENU_KEY_9
} }
else format(menu_body[len],511-len,"^n0. %s", pos ? "Back" : "Exit") else format(menu_body[len],511-len,"^n0. %s", id, pos ? "BACK" : "EXIT")
show_menu(id,keys,menu_body) show_menu(id,keys,menu_body,-1,"Pause/Unpause Plugins")
} }
public cmdMenu(id,level,cid){ public cmdMenu(id,level,cid) {
if (cmd_access(id,level,cid,1)) if (cmd_access(id,level,cid,1))
displayMenu(id,g_menuPos[id] = 0) displayMenu(id,g_menuPos[id] = 0)
return PLUGIN_HANDLED return PLUGIN_HANDLED
} }
pausePlugins(id){ pausePlugins(id) {
new filename[32],title[32],status[2] new filename[32],title[32],status[2]
new count = 0, imax = get_pluginsnum() new count = 0, imax = get_pluginsnum()
for (new a=0;a<imax;++a){ for (new a=0;a<imax;++a){
@ -221,10 +222,10 @@ pausePlugins(id){
++count ++count
} }
} }
console_print(id,"Paused %d plugin%s",count,(count==1)?"":"s") console_print(id,"%L",id,(count==1)?"PAUSED_PLUGIN":"PAUSED_PLUGINS",count)
} }
unpausePlugins(id){ unpausePlugins(id) {
new filename[32],title[32],status[2] new filename[32],title[32],status[2]
new count = 0, imax = get_pluginsnum() new count = 0, imax = get_pluginsnum()
for (new a=0;a<imax;++a){ for (new a=0;a<imax;++a){
@ -234,10 +235,10 @@ unpausePlugins(id){
++count ++count
} }
} }
console_print(id,"Unpaused %d plugin%s",count,(count==1)?"":"s") console_print(id,"%L",id,(count==1)?"UNPAUSED_PLUGIN":"UNPAUSED_PLUGINS",count)
} }
findPluginByFile(arg[32],&len){ findPluginByFile(arg[32],&len) {
new name[32],title[32],status[2] new name[32],title[32],status[2]
new inum = get_pluginsnum() new inum = get_pluginsnum()
for(new a = 0; a < inum; ++a){ for(new a = 0; a < inum; ++a){
@ -250,10 +251,10 @@ findPluginByFile(arg[32],&len){
return -1 return -1
} }
findPluginByTitle(name[],file[],len){ findPluginByTitle(name[],file[],len) {
new title[32],status[2] new title[32],status[2]
new inum = get_pluginsnum() new inum = get_pluginsnum()
for(new a = 0; a < inum; ++a){ for (new a = 0; a < inum; ++a) {
get_plugin(a,file,len,title,31,status,0,status,0,status,1) get_plugin(a,file,len,title,31,status,0,status,0,status,1)
if ( equali( title , name ) ) if ( equali( title , name ) )
return a return a
@ -261,7 +262,7 @@ findPluginByTitle(name[],file[],len){
return -1 return -1
} }
public cmdPlugin(id,level,cid){ public cmdPlugin(id,level,cid) {
if (!cmd_access(id,level,cid,1)) if (!cmd_access(id,level,cid,1))
return PLUGIN_HANDLED return PLUGIN_HANDLED
new cmds[32] new cmds[32]
@ -273,98 +274,103 @@ public cmdPlugin(id,level,cid){
if ( g_systemNum < MAX_SYSTEM ) if ( g_systemNum < MAX_SYSTEM )
g_systemNum++ g_systemNum++
else else
console_print( id , "Can't mark more plugins as unpauseable!" ) console_print( id, "%L", id, "CANT_MARK_MORE" )
} }
} }
else if ( equal(cmds, "off" ) ){ else if ( equal(cmds, "off" ) ) {
pausePlugins(id) pausePlugins(id)
} }
else if ( equal(cmds, "on" ) ){ else if ( equal(cmds, "on" ) ) {
unpausePlugins(id) unpausePlugins(id)
} }
else if ( equal(cmds, "save" ) ){ else if ( equal(cmds, "save" ) ) {
if (saveSettings(g_fileToSave)){ if (saveSettings(g_fileToSave)) {
g_Modified = 0 g_Modified = 0
console_print(id,"Configuration saved successfully") console_print(id,"%L",id,"CONF_SAVED")
} }
else else
console_print(id,"Configuration saving failed!!!") console_print(id,"%L",id,"SAVE_FAILED")
} }
else if ( equal(cmds, "clear" ) ) { else if ( equal(cmds, "clear" ) ) {
if (file_exists(g_fileToSave)){ if (file_exists(g_fileToSave)){
delete_file(g_fileToSave) delete_file(g_fileToSave)
console_print(id,"Configuration file cleared. Reload the map if needed") console_print(id,"%L",id,"CONF_CLEARED")
} }
else else
console_print(id,"Configuration was already cleared!") console_print(id,"%L",id,"ALR_CLEARED")
} }
else if ( equal(cmds, "pause" ) ) { else if ( equal(cmds, "pause" ) ) {
new arg[32], a ,len = read_argv(2,arg,31) new arg[32], a ,len = read_argv(2,arg,31)
if ( len && ((a = findPluginByFile(arg,len)) != -1) && !isSystem( a ) && pause("ac",arg) ) if ( len && ((a = findPluginByFile(arg,len)) != -1) && !isSystem( a ) && pause("ac",arg) )
console_print(id,g_pluginMatch,arg , "paused") console_print(id,"%L",id,"PLUGIN_MATCH",arg,id,"PAUSED")
else console_print(id,g_couldntFind,arg) else console_print(id,"%L",id,"COULDNT_FIND",arg)
} }
else if ( equal(cmds, "enable" ) ) { else if ( equal(cmds, "enable" ) ) {
new arg[32], a , len = read_argv(2,arg,31) new arg[32], a , len = read_argv(2,arg,31)
if ( len && (a = findPluginByFile(arg,len)) != -1 && !isSystem( a ) && unpause("ac",arg) ) if ( len && (a = findPluginByFile(arg,len)) != -1 && !isSystem( a ) && unpause("ac",arg) )
console_print(id,g_pluginMatch,arg , "unpaused") console_print(id,"%L",id,"PLUGIN_MATCH",arg,id,"UNPAUSED")
else console_print(id,g_couldntFind,arg) else console_print(id,"%L",id,"COULDNT_FIND",arg)
} }
else if ( equal(cmds, "stop" ) ) { else if ( equal(cmds, "stop" ) ) {
new arg[32], a, len = read_argv(2,arg,31) new arg[32], a, len = read_argv(2,arg,31)
if ( len && (a = findPluginByFile(arg,len)) != -1 && !isSystem( a ) && pause("dc",arg)){ if ( len && (a = findPluginByFile(arg,len)) != -1 && !isSystem( a ) && pause("dc",arg)){
g_Modified = 1 g_Modified = 1
console_print(id,g_pluginMatch,arg , "stopped") console_print(id,"%L",id,"PLUGIN_MATCH",arg,id,"STOPPED")
} }
else console_print(id,g_couldntFind,arg) else console_print(id,"%L",id,"COULDNT_FIND",arg)
} }
else if ( equal(cmds, "list" ) ) { else if ( equal(cmds, "list" ) ) {
new arg1[8], running = 0 new lName[32],lVersion[32],lAuthor[32],lFile[32],lStatus[32]
new start = read_argv(2,arg1,7) ? str_to_num(arg1) : 1 format(lName,31,"%L",id,"NAME")
if (--start < 0) start = 0 format(lVersion,31,"%L",id,"VERSION")
new plgnum = get_pluginsnum() format(lAuthor,31,"%L",id,"AUTHOR")
if (start >= plgnum) start = plgnum - 1 format(lFile,31,"%L",id,"FILE")
console_print(id,"^n----- Pause Plugins: Loaded plugins -----") format(lStatus,31,"%L",id,"STATUS")
console_print(id, " %-18.17s %-8.7s %-17.16s %-16.15s %-9.8s","name","version","author","file","status") new arg1[8], running = 0
new plugin[32],title[32],version[16],author[32],status[16] new start = read_argv(2,arg1,7) ? str_to_num(arg1) : 1
new end = start + 10 if (--start < 0) start = 0
if (end > plgnum) end = plgnum new plgnum = get_pluginsnum()
for (new a = start; a < end; ++a){ if (start >= plgnum) start = plgnum - 1
get_plugin(a,plugin,31,title,31,version,15,author,31,status,15) console_print(id,"^n----- %L -----",id,"PAUSE_LOADED")
if (status[0] == 'r') ++running console_print(id, " %-18.17s %-8.7s %-17.16s %-16.15s %-9.8s",lName,lVersion,lAuthor,lFile,lStatus)
console_print(id, " [%3d] %-18.17s %-8.7s %-17.16s %-16.15s %-9.8s",a+1,title,version,author,plugin, status ) new plugin[32],title[32],version[16],author[32],status[16]
new end = start + 10
} if (end > plgnum) end = plgnum
console_print(id,"----- Entries %d - %d of %d (%d running) -----",start+1,end,plgnum,running) for (new a = start; a < end; ++a) {
if (end < plgnum) get_plugin(a,plugin,31,title,31,version,15,author,31,status,15)
console_print(id,"----- Use 'amx_pausecfg list %d' for more -----",end+1) if (status[0] == 'r') ++running
else console_print(id, " [%3d] %-18.17s %-8.7s %-17.16s %-16.15s %-9.8s",a+1,title,version,author,plugin, status )
console_print(id,"----- Use 'amx_pausecfg list 1' for begin -----") }
console_print(id,"----- %L -----",id,"ENTRIES",start+1,end,plgnum,running)
if (end < plgnum)
console_print(id,"----- %L -----",id,"USE_MORE",end+1)
else
console_print(id,"----- %L -----",id,"USE_BEGIN")
} }
else { else {
console_print(id,"Usage: amx_pausecfg <command> [name]") console_print(id,"%L",id,"USAGE")
console_print(id,"Commands:") console_print(id,"%L:",id,"COMMANDS")
console_print(id,"^toff - pauses all plugins not in the list") console_print(id,"%L",id,"COM_TOFF")
console_print(id,"^ton - unpauses all plugins") console_print(id,"%L",id,"COM_TON")
console_print(id,"^tstop <file> - stops a plugin") console_print(id,"%L",id,"COM_TSTOP")
console_print(id,"^tpause <file> - pauses a plugin") console_print(id,"%L",id,"COM_TPAUSE")
console_print(id,"^tenable <file> - enables a plugin") console_print(id,"%L",id,"COM_TENABLE")
console_print(id,"^tsave - saves a list of stopped plugins") console_print(id,"%L",id,"COM_TSAVE")
console_print(id,"^tclear - clears a list of stopped plugins") console_print(id,"%L",id,"COM_TCLEAR")
console_print(id,"^tlist [id] - lists plugins") console_print(id,"%L",id,"COM_TLIST")
console_print(id,"^tadd <title> - marks a plugin as unpauseable") console_print(id,"%L",id,"COM_TADD")
} }
return PLUGIN_HANDLED return PLUGIN_HANDLED
} }
saveSettings(filename[]){ saveSettings(filename[]) {
if (file_exists(filename)) if (file_exists(filename))
delete_file(filename) delete_file(filename)
new text[256], file[32],title[32],status[2] new text[256], file[32],title[32],status[2]
new inum = get_pluginsnum() new inum = get_pluginsnum()
if (!write_file(filename,";Generated by Pause Plugins Plugin. Do not modify!^n;Title Filename")) if (!write_file(filename,";Generated by Pause Plugins Plugin. Do not modify!^n;Title Filename"))
return 0 return 0
for(new a = 0; a < inum; ++a){ for (new a = 0; a < inum; ++a) {
get_plugin(a,file,31,title,31,status,0,status,0,status,1) get_plugin(a,file,31,title,31,status,0,status,0,status,1)
if ( status[0] == 's' ){ if ( status[0] == 's' ){
format(text,255,"^"%s^" ;%s",title,file) format(text,255,"^"%s^" ;%s",title,file)
@ -374,7 +380,7 @@ saveSettings(filename[]){
return 1 return 1
} }
loadSettings(filename[]){ loadSettings(filename[]) {
if (!file_exists(filename)) return 0 if (!file_exists(filename)) return 0
new name[256], file[32], i, pos = 0 new name[256], file[32], i, pos = 0
while (read_file(filename,pos++,name,255,i)){ while (read_file(filename,pos++,name,255,i)){
@ -383,4 +389,4 @@ loadSettings(filename[]){
pause("dc", file ) pause("dc", file )
} }
return 1 return 1
} }