AMXX 1.9.0 - падения сервера, взаимодействия я меню

Статус
В этой теме нельзя размещать новые ответы.
Сообщения
94
Реакции
16
Помог
2 раз(а)
Ошибка
CRASH: Fri Nov 2 17:19:52 MSK 2018
Start Line: ./hlds_linux -game cstrike +ip 46.174.48.26 +port 27232 +map $2000$ +maxplayers 26 -condebug -debug -timeout 60 +sys_ticrate 10000 -noipx -norestart -pidfile game.pid
[New LWP 6270]
[New LWP 16697]
[New LWP 9011]
[New LWP 16787]
[New LWP 16786]
[New LWP 9012]
[New LWP 6276]
[New LWP 6273]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Core was generated by `./hlds_linux -game cstrike +ip 46.174.48.26 +port 27232 +map $2000$ +maxplayers'.
Program terminated with signal 11, Segmentation fault.
#0 0xf2bdfcd1 in menu_display(tagAMX*, int*) () from /game/cstrike/addons/amxmodx/dlls/amxmodx_mm_i386.so
#0 0xf2bdfcd1 in menu_display(tagAMX*, int*) () from /game/cstrike/addons/amxmodx/dlls/amxmodx_mm_i386.so
No symbol table info available.
From To Syms Read Shared Object Library
0xf76a8914 0xf76eec78 Yes ./libstdc++.so.6
0xf7656a90 0xf765797c Yes (*) /lib/libdl.so.2
0xf763f780 0xf764b857 Yes (*) /lib/libpthread.so.0
0xf7491320 0xf75d791b Yes (*) /lib/libc.so.6
0xf743c460 0xf7466c06 Yes (*) /lib/libm.so.6
0xf7424e04 0xf7434490 Yes ./libgcc_s.so.1
0xf77438a0 0xf775e261 Yes (*) /lib/ld-linux.so.2
0xf6d4ccd0 0xf6dfe157 Yes (*) /game/engine_i486.so
0xf6cd2900 0xf6cd5dca Yes (*) /lib/librt.so.1
0xf6cc05c0 0xf6ccad74 Yes (*) ./libsteam_api.so
0xf6ca5f40 0xf6cb73f8 Yes (*) /game/filesystem_stdio.so
0xf59f61c0 0xf676fb04 Yes (*) /.steam/sdk32/steamclient.so
0xf30db6a0 0xf311df70 Yes (*) /game/./cstrike/addons/metamod/metamod_i386.so
0xf2eae650 0xf3028530 Yes (*) /game/cstrike/dlls/cs.so
0xf2d843a0 0xf2d9a370 Yes (*) /game/cstrike/addons/reunion/reunion_mm_i386.so
0xf2bad8a0 0xf2c10937 Yes (*) /game/cstrike/addons/amxmodx/dlls/amxmodx_mm_i386.so
0xf2874790 0xf290cfc5 Yes (*) cstrike/addons/amxmodx/modules/mysql_amxx_i386.so
0xf275a2d0 0xf283b980 Yes (*) cstrike/addons/amxmodx/modules/sqlite_amxx_i386.so
0xf2733660 0xf2737f94 Yes (*) cstrike/addons/amxmodx/modules/fun_amxx_i386.so
0xf2711d50 0xf2721460 Yes (*) cstrike/addons/amxmodx/modules/cstrike_amxx_i386.so
0xf26b1b60 0xf26f9624 Yes (*) cstrike/addons/amxmodx/modules/hamsandwich_amxx_i386.so
0xf2646740 0xf26757e0 Yes (*) cstrike/addons/amxmodx/modules/reapi_amxx_i386.so
0xf222c8c0 0xf23da571 Yes (*) /game/cstrike/addons/vtc/VoiceTranscoder.so
0xf25fdb40 0xf26070b0 Yes (*) /game/cstrike/addons/reauthcheck/reauthcheck_mm_i386.so
0xf25e0200 0xf25f3120 Yes (*) /game/cstrike/addons/rechecker/rechecker_mm_i386.so
0xf25cfb90 0xf25d92f0 Yes (*) /game/cstrike/addons/resemiclip/resemiclip_mm_i386.so
0xf2113db0 0xf212fec0 Yes (*) /game/cstrike/addons/whblocker/whblocker_mm_i386.so
0xf25b6980 0xf25c2d30 Yes (*) /game/cstrike/addons/resrdetector/resrdetector_mm_i386.so
0xf25689d0 0xf2594d6c Yes (*) cstrike/addons/amxmodx/modules/fakemeta_amxx_i386.so
0xf2539130 0xf253f810 Yes (*) cstrike/addons/amxmodx/modules/reaimdetector_amxx_i386.so
0xf1dae120 0xf1db4404 Yes (*) cstrike/addons/amxmodx/modules/csx_amxx_i386.so
0xf1d989b0 0xf1d9ca08 Yes (*) cstrike/addons/amxmodx/modules/nvault_amxx_i386.so
0xf1d7e290 0xf1d8a80c Yes (*) cstrike/addons/amxmodx/modules/engine_amxx_i386.so
0xec2fce80 0xecde4040 Yes (*) ./steamclient.so
0xf1add670 0xf1b53020 Yes (*) ./crashhandler.so
0xe9be5a50 0xe9becfb9 Yes (*) /lib/libnss_files.so.2
0xf1c0ec00 0xf1c1206e Yes (*) /lib/libnss_dns.so.2
0xf1bf66a0 0xf1c05694 Yes (*) /lib/libresolv.so.2
0xf2525f60 0xf252724c Yes (*) cstrike/addons/amxmodx/modules/sockets_amxx_i386.so
0xf20a25d0 0xf20eb548 Yes (*) cstrike/addons/amxmodx/modules/regex_amxx_i386.so
(*): Shared library is missing debugging information.
Stack level 0, frame at 0x0:
eip = 0xf2bdfcd1 in menu_display(tagAMX*, int*); saved eip 0xf2bdfcd1
Outermost frame: outermost
Arglist at unknown address.
Locals at unknown address, Previous frame's sp in esp
End of crash report
----------------------------------------------
ОС
Linux
Amx Mod X
AMX Mod X 1.9.0.5232
Билд
ReHLDS version: 3.4.0.664-dev
ReGamedll
ReGameDLL version: 5.7.0.312-dev
Версия Metamod
Metamod-r v1.3.0.128
Список метамодулей
[ 1] Reunion          RUN   -    reunion_mm_i386.so          v0.1.0.92       ini  Start Never
[ 2] AMX Mod X RUN - amxmodx_mm_i386.so v1.9.0.5232 ini Start ANY
[ 3] VoiceTranscoder RUN - VoiceTranscoder.so v2017RC3 ini ANY ANY
[ 4] ReAuthCheck RUN - reauthcheck_mm_i386.so v0.1.6 ini Start Never
[ 5] Rechecker RUN - rechecker_mm_i386.so v2.5 ini Chlvl ANY
[ 6] ReSemiclip RUN - resemiclip_mm_i386.so v2.3.9 ini Chlvl ANY
[ 7] WHBlocker RUN - whblocker_mm_i386.so v1.5.695 ini Chlvl ANY
[ 8] ReSRDetector RUN - resrdetector_mm_i386.so v0.1.0 ini Chlvl ANY
[ 9] MySQL RUN - mysql_amxx_i386.so v1.9.0.5232 pl2 ANY ANY
[10] SQLite RUN - sqlite_amxx_i386.so v1.9.0.5232 pl2 ANY ANY
[11] Fun RUN - fun_amxx_i386.so v1.9.0.5232 pl2 ANY ANY
[12] CStrike RUN - cstrike_amxx_i386.so v1.9.0.5232 pl2 ANY ANY
[13] Ham Sandwich RUN - hamsandwich_amxx_i386.so v1.9.0.5232 pl2 ANY ANY
[14] ReAPI RUN - reapi_amxx_i386.so v5.6.0.160-dev pl2 ANY Never
[15] FakeMeta RUN - fakemeta_amxx_i386.so v1.9.0.5232 pl2 ANY ANY
[16] ReAimDetector RUN - reaimdetector_amxx_i386.so v0.2.2 pl2 ANY Never
[17] CSX RUN - csx_amxx_i386.so v1.9.0.5232 pl2 ANY ANY
[18] Engine RUN - engine_amxx_i386.so v1.9.0.5232 pl2 ANY ANY
Список плагинов
[  1] fb_forwards             0.1.5       Kanagava & Realu  fb_forwards.amx  running  
[ 2] admin_loader 0.3.7 kanagava admin_loader.am running
[ 3] FreshBans 1.3.8b kanagava fresh_bans.amxx running
[ 4] ReAimDetector API 0.2.2 ReHLDS Team reaimdetector.a running
[ 5] AdminFreeLook 0.0.0 ReHLDS Team adminfreelook.a running
[ 6] Anti Reklama 0.1 unnamed anti_reklama.am running
[ 7] Admin Commands 1.9.0.5232 AMXX Dev Team admincmd.amxx running
[ 8] Admin Votes 1.9.0.5232 AMXX Dev Team adminvote.amxx running
[ 9] Admin Chat 1.9.0.5232 AMXX Dev Team adminchat.amxx running
[ 10] Commands Menu 1.9.0.5232 AMXX Dev Team cmdmenu.amxx running
[ 11] Map Manager 2.5.61 Mistrick mapmanager.amxx running
[ 12] Maps Menu 1.9.0.5232 AMXX Dev Team mapsmenu.amxx running
[ 13] Multi-Lingual System 1.9.0.5232 AMXX Dev Team multilingual.am running
[ 14] Players Menu 1.9.0.5232 AMXX Dev Team plmenu.amxx running
[ 15] Restrict Weapons 1.9.0.5232 AMXX Dev Team restmenu.amxx running
[ 16] CSStatsX SQL 0.7.4 serfreeman1337 csstatsx_sql.am running
[ 17] CS Stats Logging 1.9.0.5232 AMXX Dev Team stats_logging.a running
[ 18] Stats Configuration 1.9.0.5232 AMXX Dev Team statscfg.amxx running
[ 19] AES: StatsX 0.5 Vega serfreeman1337 aes_statsx_cstr running
[ 20] StatsX 1.9.0.5232 AMXX Dev Team statsx.amxx running
[ 21] Advanced Experience Sy 0.5.7 Vega serfreeman1337/s aes_main.amxx running
[ 22] Mini Sound Esp Fix 1.0 ranget mini_sound_esp_ running
[ 23] Killer ScreenFade 0.0.5 Vaqtincha reapi_killer_sc running
[ 24] Weapon Model + Sound R 1.3 GHW_Chronic GHW_Weapon_Repl running
[ 25] unknown unknown unknown night_vip.amxx running
[ 26] High Ping Kicker 1.0 Shadow/Bo0m! amx_hpk.amxx running
[ 27] AFK Control 1.4.1 [Rnd neygomon afk_control.amx running
[ 28] Vampire VIP 1.0f Leo_[BH] / Shalf vampire_nf.amxx running
[ 29] Kill Manager Sound 1.3 ShaTalKiN kmansound.amxx running
[ 30] aut0_rr 1.0 xramer auto_rr.amxx running
[ 31] Mode 2x2 2.5re s1lent mode.amxx running
[ 32] Server AMXMODMENU [INI 1.0 Leo_[BH] amxmodmenu.amxx running
[ 33] VIP Menu [GENTLEMEN] 0.15 Leo_[BH] vip_reapi.amxx running
[ 34] [ReAPI] AWPoff 1.4.3 PAffAEJIkA :3 awp_off.amxx running
[ 35] [AMXX] Public Menu 0.0.2 steelzorrr public_menu.amx running
[ 36] AMXX Gag /A/ 1.3a Leo_[BH] amx_gaga.amxx running
[ 37] Warning Menu 1.8 Leo_[BH] warn_menu.amxx running
[ 38] Warning for Players 1.8 Leo_[BH] warning_players running
[ 39] Save Slot Steam and VI 1.0 Leo_[BH] save_slot.amxx running
[ 40] Steam Bonus 1.1 ill+F@nToM steam_bonus_a2. running
[ 41] FlashBang DynLight 1.4 neygomon flashbang_dynli running
[ 42] Admin ESP 1.5b_mini KoST admin_esp_mini. running
[ 43] [ReAPI] No Team Flash 1.0 ReHLDS Team noteamflash.amx running
[ 44] Bomb Taker 0.0.1b Vaqtincha c4_taker.amxx running
[ 45] Lite Recoder 1.0.1 neygomon amx_demorec_3.a running
[ 46] Rock to Ban 1.02 Safety1st rock2ban.amxx running
[ 47] Reset Score ReFreshed 0.0.1 wopox1337@Dev-CS ResetScore_ReFr running
[ 48] Mute Menu 1.0 Rjava addon_mute_menu running
[ 49] Advert Messages 1.2 neygomon adverts.amxx running
[ 50] say /adminka 1.1 Pa1n say_admin.amxx running
[ 51] Parachute Lite [ReAPI] 10.0 Leo_[BH] parachute_lite. running
[ 52] [ReAPI] Block 'Fire in 0.0.1 sergrib reapi_block_FIT running
[ 53] [ReAPI] Best player of 0.6 F@nt0M best_player_of_ running
[ 54] Damager Advanced 1.1.2 Radius (based on damager_advance running
[ 55] Kills Counter 0.3 serfreeman1337 kills_counter.a running
[ 56] Spec Money Save 0.2 F@nt0M spec_money_save running
[ 57] Say me and Say hp 1.4 neygomon sayme_reapi.amx running
[ 58] Lite Translit 2.8 neygomon lite_translit.a running
[ 59] AES: CStrike Addon 0.5.7 Vega serfreeman1337/s aes_exp_cstrike running
[ 60] AES: Informer 0.5.7 Vega serfreeman1337/s aes_informer.am running
[ 61] AES: Admin Tools 0.5.7 Vega serfreeman1337/s aes_exp_editor. running
[ 62] AES: Bonus System 0.5.7 Vega serfreeman1337/s aes_bonus_syste running
[ 63] AES: Bonus CSTRIKE 0.5.7 Vega serfreeman1337/s aes_bonus_cstri running
Обновил амхмодх со всеми файлами, перекомпилировал плагины и теперь данная ошибка, знает кто как ее исправить?
 
В этой теме было размещено решение! Перейти к решению.

ifx

Сообщения
331
Реакции
153
Помог
4 раз(а)
не уверен, что это будет решением, но я на билде 5229 не испытываю никаких проблем, попробуй откатится тоже до этого билда
 
Сообщения
1,340
Реакции
529
Помог
91 раз(а)
ifx, естественно не решение: сидеть и ждать пока за тебя кто нибудь напишет в баги, а разрабы исправят. Сидеть и ждать все умеют.
 
Сообщения
90
Реакции
126
Помог
3 раз(а)
Нужно исправить вызов menu_display, в него передается "не правильный" игрок
 
Последнее редактирование:
Сообщения
90
Реакции
126
Помог
3 раз(а)
ofanok, я не экстрасенс, нужно смотреть каждый вызов menu_display и проверять pev_valid(player) == 2, ExecuteHam(Ham_IsPlayer, player)
В новой верси AMXX производиться доступ к приватным данным сущности, в прошлой его не было, поэтому краш происходит наверняка при попытке доступа к приватным данным сущности
 
Сообщения
94
Реакции
16
Помог
2 раз(а)
swank, нашел 7 плагинов использующих menu_display, но не в одном нет pev_valid(player) == 2, ExecuteHam(Ham_IsPlayer, player) таких строк.
их необходимо добавить? кину код одного из них
Код:
#include <amxmodx>


#define MAX_MENU 35         // Максимальное допустимое число пунктов меню
#define MAX_LENGTH 63         // Максимальный размер одной строки

#define INIFILE "/addons/amxmodx/configs/amxmodmenu/menu.ini"                     // Файл настройки меню админа!
new MenuItem[MAX_MENU+1][MAX_LENGTH+1], MenuCmd[MAX_MENU+1][MAX_LENGTH+1], lines

#define INICMDFILE "/addons/amxmodx/configs/amxmodmenu/clcmd.ini"                 // Файл настройки клиентских команд для входа в меню
new MenuClcmd[MAX_MENU+1][MAX_LENGTH+1], cmd_lines

public plugin_precache()
{
    register_plugin("Server AMXMODMENU [INI]", "1.0", "Leo_[BH]")

    cmd_ini_file()
    menu_ini_file()
}

public cmd_ini_file()
{
    new cmd_line = 1, cmd_bufferd[256]
    new cmd_iFiled = fopen(INICMDFILE,"r")
    
    while(!feof(cmd_iFiled))
    {
        fgets(cmd_iFiled,cmd_bufferd,255)
        trim(cmd_bufferd)
        
        if(cmd_bufferd[0]=='"')
        {
            parse(cmd_bufferd, MenuClcmd[cmd_line], MAX_LENGTH)
        }
        else
        {
            continue
        }
        cmd_line++
    }
    cmd_lines = cmd_line
    fclose(cmd_iFiled)
}

public menu_ini_file()
{
    new line = 1, bufferd[256]
    new iFiled = fopen(INIFILE,"r")
    
    while(!feof(iFiled))
    {
        fgets(iFiled,bufferd,255)
        trim(bufferd)
        
        if(bufferd[0]=='"')
        {
            parse(bufferd, MenuItem[line], MAX_LENGTH, MenuCmd[line], MAX_LENGTH)
        }
        else
        {
            continue
        }
        line++
    }
    lines = line
    fclose(iFiled)
}

new g_Menu_Text

public plugin_init()
{
    g_Menu_Text = register_cvar("amxmodmenu_text", "\yМеню \rPREMIUM\w")
    
    for(new num = 1; num < cmd_lines; num++)
    {
        register_clcmd(MenuClcmd[num], "open_admin_menu");
    }
}

// // // // // // // // // // // // // // //

public open_admin_menu(id)
{
    new g_szTextGL[64]
    get_pcvar_string( g_Menu_Text, g_szTextGL, 63 );
    new menu = menu_create(g_szTextGL, "handler_menu")
    
    for(new num = 1; num < lines; num++)
    {
        new Number[4]
        formatex(Number, charsmax(Number), "%i", num)
        menu_additem(menu, MenuItem[num], Number)
    }
    
    menu_setprop(menu, MPROP_NEXTNAME, "Далее")
       menu_setprop(menu, MPROP_BACKNAME, "Назад")
    menu_setprop(menu, MPROP_EXITNAME, "Выход")
    
    menu_display(id, menu, 0)
    
    return PLUGIN_HANDLED
}

public handler_menu(id, menu, item)     
{     
    if(item == MENU_EXIT)     
    {     
        menu_destroy(menu)
        return PLUGIN_HANDLED
    }
    
    new data[15], iName[64]     
    new access, callback     
    menu_item_getinfo(menu, item, access, data, 14, iName, 63, callback)
    
    client_cmd(id, MenuCmd[str_to_num(data)])
    
    menu_destroy(menu)
    
    return PLUGIN_HANDLED
}
 
Сообщения
90
Реакции
126
Помог
3 раз(а)
ofanok, а в нормально работающем плагине их и не должно быть
 
Сообщения
94
Реакции
16
Помог
2 раз(а)
swank, т.е. удалить везде menu_display
 
Сообщения
432
Реакции
410
Помог
14 раз(а)
ofanok, т.е отключать плагины, пока не найдете проблемный, потом исходник сюда
 
Сообщения
1,420
Реакции
2,511
Помог
58 раз(а)
ofanok, м[BGCOLOR=transparent]ожно попробовать обновить AMXX до 1.9.0.5234.[/BGCOLOR]
 
Сообщения
94
Реакции
16
Помог
2 раз(а)
w0w, ifx, обновил амх мод до 5234, проблема осталась, буду искать в чем проблема
 
Сообщения
2,491
Реакции
2,794
Помог
61 раз(а)
ofanok, Для начала отключите плагины с menu_display и смотрите будет ли краш. А далее по одному включайте. Методом тыка найдите тот самый плагин. Ну а дальше уже искать что в него такого передается что вызывает краш
 
Последнее редактирование:
Сообщения
3,049
Реакции
1,739
Помог
80 раз(а)
Заморочился над сравнением твоих и моих плагинов и выяснил совпадения:
Код:
ReAimDetector API       0.2.2
fb_forwards             0.1.4
FreshBan                1.3.1
CSStatsX SQL            0.7.4
AES: StatsX             0.5.9
Advert Messages         1.3.3
Killer ScreenFade       0.0.6
Damager Advanced        1.1.2
Advanced Experience Sy  0.5.9
AES: CStrike Addon      0.5.9
AES: Informer           0.5.9
AES: Admin Tools        0.5.9
Данные плагины у нас совпадают, только некоторые расходятся в версиях.
Нужно смотреть именно их.
Маздану уже задал вопрос про menu_display
 
Последнее редактирование:
Сообщения
94
Реакции
16
Помог
2 раз(а)
Алексеич, на этой версии у меня тоже падал, я заменил амх мод на 1.10.0, при компиляции был варн плагина вотебана, позже скину всю инфу, заменил плагин, уже третий день без подений))
16 Ноя 2018
Алексеич,
Код:
/*
*    Rock to Ban
*      Every player are able to rock the vote to ban somebody.
*
*    Last update:
*      12/05/2012
*
    Credits:
*     Alka for his 'Vote Ban' plugin http://forums.alliedmods.net/showthread.php?t=96586
*      I got the idea and took part of his code
*
*    This file is provided as is (no warranties).
*
*/

#include <amxmodx>

#define PLUGIN "Rock to Ban"
#define VERSION "1.02"
#define AUTHOR "Safety1st"

// customizable parameters
#define MAX_PLAYERS 32
#define IMMUNITY_FLAG ( ADMIN_IMMUNITY | ADMIN_BAN )    /* flags 'a' & 'd', separate by '|' */
new gszPrefix[] = "[VOTEBAN]"    // set prefix for all chat messages; for example ">"
const VOTEBAN_NEED = 4    // how many players are required to enable voteban function
// end of customizable parameters

new giVotedPlayers[MAX_PLAYERS + 1]    // player's voteban targets
new giVotes[MAX_PLAYERS + 1]    // count of votes for ban that player
new giVoted[MAX_PLAYERS + 1]    // count of votes for ban by that player

// macro; %1 - variable being modified, %2 - player id
#define CheckFlag(%1,%2)    ( %1 &   ( 1 << (%2-1) ) )
#define AddFlag(%1,%2)        ( %1 |=  ( 1 << (%2-1) ) )
#define RemoveFlag(%1,%2)    ( %1 &= ~( 1 << (%2-1) ) )

enum _:Labels {
    CVAR_PERCENT = 0,
    CVAR_BANTYPE,
    CVAR_BANTIME,
    CVAR_LIMIT,
    CVAR_REASON,
    CVAR_LOG
}
new pCvar[Labels]

enum _:Types {
    AUTO = 0,
    STEAMID,
    IP,
    AMXBAN,
    AMXBANS5,
    SUPERBAN
}

enum _:LogRecords {
    UNVOTE = 0,
    VOTE
}

new gszLogRecords[LogRecords][] = {
    "Player '%s' has canceled vote for banning '%s'",
    "Player '%s' has been voted for banning by '%s'"
}

public plugin_init() {
    register_plugin( PLUGIN, VERSION, AUTHOR )
    register_dictionary( "rock2ban.txt" )
    register_cvar( "rock2ban", VERSION, FCVAR_SERVER|FCVAR_SPONLY|FCVAR_UNLOGGED )

    register_saycmd( "voteban", "VoteBanMenu" )

    pCvar[CVAR_PERCENT] = register_cvar( "voteban_percent", "30" )
    pCvar[CVAR_BANTYPE] = register_cvar( "voteban_type", "4" )
    pCvar[CVAR_BANTIME] = register_cvar( "voteban_time", "60" )
    pCvar[CVAR_LIMIT] = register_cvar( "voteban_limit", "2" )
    pCvar[CVAR_REASON] = register_cvar( "voteban_reason", " 3a6aHeH /voteban'om Ha %time% MuH.! https://vk.com/server_cs_gentlemen" )
    pCvar[CVAR_LOG] = register_cvar( "voteban_log", "1" )
}

register_saycmd( saycommand[], function[] ) {
    new szTemp[64]
    formatex( szTemp, charsmax(szTemp), "say %s", saycommand )
    register_clcmd( szTemp, function )
    formatex( szTemp, charsmax(szTemp), "say_team %s", saycommand )
    register_clcmd( szTemp, function )
    formatex( szTemp, charsmax(szTemp), "say /%s", saycommand )
    register_clcmd( szTemp, function )
    formatex( szTemp, charsmax(szTemp), "say .%s", saycommand )
    register_clcmd( szTemp, function )
    formatex( szTemp, charsmax(szTemp), "say_team /%s", saycommand )
    register_clcmd( szTemp, function )
    formatex( szTemp, charsmax(szTemp), "say_team .%s", saycommand )
    register_clcmd( szTemp, function )
}

public client_disconnected(id) {
    static iPlayers[32], iPlayersNum, i, iPlayer

    // check whether there were votes for ban by that player
    if ( giVoted[id] ) {
        get_players( iPlayers, iPlayersNum, "ch" )    // skip bots and HLTV
        for ( i = 0; i < iPlayersNum; i++ ) {
            iPlayer = iPlayers[i]
            if ( CheckFlag( giVotedPlayers[id], iPlayer ) )
                giVotes[iPlayer]--
        }
        giVotedPlayers[id] = 0
        giVoted[id] = 0
    }

    // check whether there were votes for ban that player
    if ( giVotes[id] ) {
        get_players( iPlayers, iPlayersNum, "ch" )    // skip bots and HLTV
        for ( i = 0; i < iPlayersNum; i++ ) {
            iPlayer = iPlayers[i]
            if ( CheckFlag( giVotedPlayers[iPlayer], id ) ) {
                RemoveFlag( giVotedPlayers[iPlayer], id )
                giVotes[id]--
                giVoted[iPlayer]--
            }
            if ( !giVotes[id] )
                break
        }
        giVotes[id] = 0    // just in case
    }
}

public VoteBanMenu(id) {
    static iPlayers[32], iPlayersNum, i, iPlayer

    get_players( iPlayers, iPlayersNum, "ch" )    // skip bots and HLTV
    if ( iPlayersNum < VOTEBAN_NEED ) {
        ColorPrint( id, "^4%s %L", gszPrefix, id, "VOTEBAN_NEEDX", VOTEBAN_NEED )
        return PLUGIN_HANDLED
    }

    // create and show menu
    new szTempString[64], szName[32], szInfo[3]
    formatex( szTempString, charsmax(szTempString), "%L\y:", id, "VOTEBAN_MENU" )
    new iMenu = menu_create( szTempString, "MenuHandle", .ml = 1 )
    new iCallback = menu_makecallback( "CallbackMenu" )
    menu_setprop( iMenu, MPROP_NUMBER_COLOR, "\r" )
    menu_setprop( iMenu, MPROP_EXIT, MEXIT_ALL )
    formatex( szTempString, charsmax(szTempString), "%L", id, "VOTEBAN_EXIT" )
    menu_setprop( iMenu, MPROP_EXITNAME, szTempString )
    formatex( szTempString, charsmax(szTempString), "%L", id, "VOTEBAN_NEXT" )
    menu_setprop( iMenu, MPROP_NEXTNAME, szTempString )
    formatex( szTempString, charsmax(szTempString), "%L", id, "VOTEBAN_BACK" )
    menu_setprop( iMenu, MPROP_BACKNAME, szTempString )

    new iPercent
    for ( i = 0; i < iPlayersNum; i++ ) {
        iPlayer = iPlayers[i]
        get_user_name( iPlayer, szName, 31 )
        if ( get_user_flags(iPlayer) & IMMUNITY_FLAG ) {
            // don't set info[] if player has immunity
            menu_additem( iMenu, szName, "", .callback = iCallback )
        }
        else {
            iPercent = get_percent( giVotes[iPlayer], iPlayersNum )
            if ( giVotes[iPlayer] && CheckFlag( giVotedPlayers[id], iPlayer ) )
                formatex( szTempString, charsmax(szTempString), "%s \d(\r%d%%\d) \y%L", szName, iPercent, id, "VOTEBAN_VOTED" )
            else
                formatex( szTempString, charsmax(szTempString), "%s \d(\r%d%%\d)", szName, iPercent )
            num_to_str( iPlayer, szInfo, charsmax(szInfo) )
            menu_additem( iMenu, szTempString, szInfo, .callback = iCallback )
        }
    }

    menu_display( id, iMenu )

    return PLUGIN_CONTINUE
}

public CallbackMenu( id, menu, item ) {
    new access, info[3], callback, szTempString[64]
    menu_item_getinfo( menu, item, access, info, charsmax(info), szTempString, charsmax(szTempString), callback )

    if ( !info[0] )
        // player has immunity
        return ITEM_DISABLED

    if ( str_to_num(info) == id )
        return ITEM_DISABLED

    return ITEM_ENABLED
}

public MenuHandle( id, menu, item ) {
    if ( item == MENU_EXIT ) {
        menu_destroy(menu)
        return PLUGIN_HANDLED
    }

    new access, info[3], callback
    menu_item_getinfo( menu, item, access, info, charsmax(info), .callback = callback )
    menu_destroy(menu)

    new iTarget = str_to_num(info)

    if ( !is_user_connected(iTarget) ) {
        VoteBanMenu(id)
        return PLUGIN_HANDLED
    }

    if ( CheckFlag( giVotedPlayers[id], iTarget ) ) {
        RemoveFlag( giVotedPlayers[id], iTarget )
        giVoted[id]--
        giVotes[iTarget]--

        new szName[32], szTargetName[32]
        get_user_name( id, szName, 31 )
        get_user_name( iTarget, szTargetName, 31 )
        MsgToLog( gszLogRecords[UNVOTE], szName, szTargetName )
        ColorPrint( 0, "^4%s %L", gszPrefix, LANG_SERVER, "VOTEBAN_UNVOTE", szName, szTargetName )
        client_print( id, print_center, "%L", id, "VOTEBAN_CLEAR" )
        return PLUGIN_HANDLED
    }

    new iLimit = get_pcvar_num( pCvar[CVAR_LIMIT] )
    if ( giVoted[id] >= iLimit ) {
        // don't let vote too much ;)
        client_print( id, print_center, "%L", id, "VOTEBAN_LIMIT", iLimit )
        return PLUGIN_HANDLED
    }

    client_print( id, print_center, "%L", id, "VOTEBAN_SET" )
    giVoted[id]++
    giVotes[iTarget]++
    AddFlag( giVotedPlayers[id], iTarget )

    CheckVotes( iTarget, id )

    return PLUGIN_HANDLED
}

CheckVotes( target, voter ) {
    new szName[32], szTargetName[32]
    get_user_name( voter, szName, 31 )
    get_user_name( target, szTargetName, 31 )

    MsgToLog( gszLogRecords[VOTE], szTargetName, szName )
    ColorPrint( 0, "^4%s %L", gszPrefix, LANG_SERVER, "VOTEBAN_VOTE", szName, szTargetName )

    new iPlayers[32], iPlayersNum
    get_players( iPlayers, iPlayersNum, "ch" )    // skip bots and HLTV

    if ( get_percent( giVotes[target], iPlayersNum ) < get_pcvar_num( pCvar[CVAR_PERCENT] ) )
        return

    new iUserid = get_user_userid(target)
    new iType = get_pcvar_num( pCvar[CVAR_BANTYPE] )
    new iBanTime = get_pcvar_num( pCvar[CVAR_BANTIME] )
    new szAuthid[32], szReason[256]
    get_pcvar_string( pCvar[CVAR_REASON], szReason, charsmax(szReason) )

    switch ( iType ) {
        case AMXBAN, AMXBANS5, SUPERBAN : {
            // clear unused template
            replace( szReason, charsmax(szReason), "%time%", " " )
        }
        default : {
            static szHostname[64]
            if ( !szHostname[0] )
                get_cvar_string( "hostname", szHostname, 63 )
            get_user_authid( target, szAuthid, charsmax(szAuthid) )
            log_amx( "Ban: ^"%s<0><><>^" ban and kick ^"%s<%d><%s><>^" (minutes ^"%d^") (reason ^"Voteban^")", szHostname, szTargetName, iUserid, szAuthid, iBanTime )
            ColorPrint( 0, "^4%s %L", gszPrefix, LANG_SERVER, "VOTEBAN_BAN", szTargetName, iBanTime )
            // set actual ban time in the reason
            if ( containi( szReason, "%time%" ) != -1 ) {
                new szBanTime[4]
                num_to_str( iBanTime, szBanTime, 3 )
                replace( szReason, charsmax(szReason), "%time%", szBanTime )
            }
        }
    }

    if ( !iType ) {     // AUTO
        /* AMXX base plugin 'plmenu.amxx', code by MistaGee
        IF AUTHID STEAM_ID_LAN OR VALVE_ID_LAN OR HLTV, BAN PER IP TO DON'T BAN EVERYONE */
        if ( equal( "STEAM_ID_LAN", szAuthid ) || equal( "VALVE_ID_LAN", szAuthid ) || equal( "HLTV", szAuthid ) )
            iType = IP
        else
            iType = STEAMID
    }
    
    switch ( iType ) {
        case STEAMID :
            server_cmd( "kick #%d %s;wait;wait;wait;banid %d %s", iUserid, szReason, iBanTime, szAuthid )
        case IP : {
            new szIp[32]
            get_user_ip( target, szIp, charsmax(szIp), 1 /* without_port */ )
            server_cmd( "kick #%d %s;wait;wait;wait;addip %d %s", iUserid, szReason, iBanTime, szIp )
        }
        case AMXBAN :
            server_cmd( "amx_ban #%d %d ^"%s^"", iUserid, iBanTime, szReason )
        case AMXBANS5 :
            server_cmd( "amx_ban %d #%d ^"%s^"", iBanTime, iUserid, szReason )
        case SUPERBAN :
            server_cmd( "amx_superban #%d %d ^"%s^"", iUserid, iBanTime, szReason )
    }
}

get_percent( value, tvalue ) {
    return floatround( floatmul( float(value) / float(tvalue) , 100.0 ) )
}

MsgToLog( szRawMessage[], any:... ) {
    if ( !get_pcvar_num( pCvar[CVAR_LOG] ) )
        return

    static szLogFile[192] = "", szTime[32], fp
    if ( !szLogFile[0] ) {
        new szLogsDir[64], szDate[16]
        get_time ( "%Y%m", szDate, charsmax(szDate) )
        get_localinfo( "amxx_logs", szLogsDir, 63 )
        formatex( szLogFile, charsmax(szLogFile), "%s/voteban_%s.log", szLogsDir, szDate )
    }

    new szMessage[192]
    vformat( szMessage, charsmax( szMessage ), szRawMessage, 2 )

    get_time( "%m/%d/%Y - %H:%M:%S", szTime, 31 )
    fp = fopen( szLogFile, "a" )
    fprintf( fp, "L %s: %s^n", szTime, szMessage )
    fclose(fp)
}

ColorPrint( iReceiver, const szRawMessage[ ], any:... ) {
    static iMsgSayText = 0
    if( !iMsgSayText )
        iMsgSayText = get_user_msgid( "SayText" )

    new szMessage[192], iPlayers[32], iPlayersNum = 1, iPlayer
    vformat( szMessage, charsmax(szMessage), szRawMessage, 3 )
    replace_all( szMessage, charsmax(szMessage), "!n", "^1" )
    replace_all( szMessage, charsmax(szMessage), "!t", "^3" )
    replace_all( szMessage, charsmax(szMessage), "!g", "^4" )
    if ( szMessage[0] != '^1' || szMessage[0] != '^3' || szMessage[0] != '^4' )
        format( szMessage, charsmax(szMessage), "^1%s", szMessage )    // we must set initial default color if it is not provided explicitly

    if ( iReceiver )
        iPlayers[0] = iReceiver
    else {
        get_players( iPlayers, iPlayersNum, "ch" )    // skip bots and HLTV
        if ( !iPlayersNum )
            return    // don't print useless message
    }

    for ( new i = 0 ; i < iPlayersNum ; i++ ) {
        iPlayer = iPlayers[i]
        message_begin( MSG_ONE_UNRELIABLE, iMsgSayText, _, iPlayer )
        write_byte(iPlayer)    // use target player as sender to see colors at all (and his own team color for ^3)
        write_string(szMessage)
        message_end()
    }
}
там ниже как раз строчка с меню дисплей, просто мои познания не сильны, в чем тут проблема не пойму, может кому поможет.
 

Вложения

  • 19.8 KB Просмотры: 517
Статус
В этой теме нельзя размещать новые ответы.

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу