Не открывается меню плагина CW

Статус
В этой теме нельзя размещать новые ответы.

sHk

Сообщения
16
Реакции
2
Неверный раздел форума
Плагин компилится без ошибок,
Но менюшка не открывается....
Почему и как исправить?

Код:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <hamsandwich>

const KEYSMENU = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_6|MENU_KEY_7|MENU_KEY_8|MENU_KEY_9|MENU_KEY_0

enum
{
    NONE = -1,
    LIVE,
    WARM,
}

new const g_Msg[][] =
{

    "LIVE LIVE LIVE",
    "Рестарт"
}
new g_msgSayText

new g_Count, g_CountA
new g_Round = NONE

public plugin_init()
{
    register_plugin("Lite CW", "1.0", "ill")
    
    register_event("CurWeapon", "EventCurWeapon", "be", "2!29")
    register_event("DeathMsg", "on_death", "a")
    register_logevent("logevent_round_end", 2, "1=Round_End")
    register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
    
    register_clcmd("cwmenu", "show_cw_menu")
    register_clcmd("type_password", "clcmd_setpassword", ADMIN_BAN);
    
    register_menu("CW Menu", KEYSMENU, "cw_menu")
    
    RegisterHam(Ham_Spawn, "player", "fw_SpawnPost", 1)
    
    g_msgSayText = get_user_msgid("SayText")
    
    set_task(120.0, "reset_password", .flags = "b")
}

public reset_password()
{
    if(!get_playersnum())
        set_cvar_string("sv_password", "")
        
}
public clcmd_setpassword(id, bitsAccess)
{
    if(!(get_user_flags(id) & bitsAccess))
        return PLUGIN_HANDLED

    new szPwd[32]
    read_argv(1, szPwd, charsmax(szPwd))
    remove_quotes(szPwd)
    
    set_cvar_string("sv_password", szPwd)
    show_cw_menu(id)
    
    return PLUGIN_HANDLED
}
public logevent_round_end()
{
    g_Round = NONE
}

public fnRevivePlayer(id)
{
    if(!is_user_alive(id) && (get_user_team(id) == 1 || get_user_team(id) == 2))
        ExecuteHamB(Ham_CS_RoundRespawn, id)
}

public show_cw_menu(id)
{
    if(!(get_user_flags(id) & ADMIN_BAN))
        return PLUGIN_HANDLED
        
    static menu[512], len
    len = 0
    
    len += formatex(menu[len], charsmax(menu) - len, "\y КВ Меню \w[1/2]^n^n")
    
    len += formatex(menu[len], charsmax(menu) - len, "\r1. \wКикнуть^n")
    len += formatex(menu[len], charsmax(menu) - len, "\r2. \wЗабанить^n")
    len += formatex(menu[len], charsmax(menu) - len, "\r3. \wРестарт^n^n")
    len += formatex(menu[len], charsmax(menu) - len, "\r4. \wПереместить^n")
    len += formatex(menu[len], charsmax(menu) - len, "\r5. \wНачать игру^n^n")

    new iPwd[32];get_cvar_string("sv_password", iPwd, charsmax(iPwd))

    len += formatex(menu[len], charsmax(menu) - len, "\r6. \wПароль [\y%s\w]^n", iPwd[0] ? iPwd : "\rне установлен")
        
    len += formatex(menu[len], charsmax(menu) - len, "\r7. \wСменить карту^n^n")
    len += formatex(menu[len], charsmax(menu) - len, "^n\r0. \wВыход")
    
    show_menu(id, KEYSMENU, menu, -1, "CW Menu")
    
    return PLUGIN_HANDLED
}

public cw_menu(id, key)
{
    switch(key)
    {
        case 0:
        {
            client_cmd(id, "amx_kickmenu")
        }
        case 1:
        {
            client_cmd(id, "amx_banmenu")
        }
        case 2:
        {
            server_cmd("sv_restart 1")
        }
        case 3:
        {
            client_cmd(id, "amx_teammenu")
        }
        case 4:
        {
            set_round(LIVE)
        }
        case 5:
        {
            new iPwd[32]
            get_cvar_string("sv_password", iPwd, charsmax(iPwd))
            if(iPwd[0])
            {
                set_cvar_string("sv_password", "")
                show_cw_menu(id)
            }
            else
                client_cmd(id, "messagemode type_password");
        }
        case 6:
        {
                client_cmd(id, "amx_mapmenu")
        }
    }
    return PLUGIN_HANDLED
}
    
set_round(num)
{
    new iRes
    if(num == WARM)
    {
        iRes = 1
        server_cmd("mp_freezetime 0")
        server_cmd("mp_buytime 99")
    }
    else
    {
        iRes = 3
        server_cmd("mp_freezetime 0")
        server_cmd("mp_buytime 0.15")
    }
    
    g_CountA = 0
    g_Count = 0
    g_Round = num
    //log_to_file("cw.log", "Pre: g_Round = %d", g_Round)
    
    set_task(1.0, "restart", _, _, _, "a", iRes)
    set_task(0.2, "show_msg", 44335, _, _, "a", 21)
}

public show_msg()
{
    if(g_Round < 0)
    {
        remove_task(44335)
        return
    }
    //log_to_file("cw.log", "Post: g_Round = %d", g_Round)
        
    new iStart[12], iEnd[12]
    
    if(g_CountA == 11)
        g_Count = 1
        
    for(new s = 0; s < g_Count; s++)
        add(iStart, charsmax(iStart), "-")
    for(new s = 0; s < 10 - g_Count; s++)
        add(iEnd, charsmax(iEnd), "-")
    
    if(g_CountA <= 10)
        ChatColor(0, "^1[%s%s%s]", iStart, g_Msg[g_Round], iEnd)
    else
        ChatColor(0, "^1[%s%s%s]", iEnd, g_Msg[g_Round], iStart)
    
    g_CountA++
    g_Count++
    
    
}

public restart()
{
    server_cmd("sv_restart 1")
}

stock ChatColor(const id, const input[], any:...) {
    new count = 1, players[32]
    static msg[191]
    vformat(msg, 190, input, 3)
    replace_all(msg, 190, "!g", "^4") // Green Color
    replace_all(msg, 190, "!y", "^1") // Default Color
    replace_all(msg, 190, "!team", "^3") // Team Color
    if (id) players[0] = id; else get_players(players, count, "ch"); {
        for (new i = 0; i < count; i++) {
            if (is_user_connected(players[i])) {
                message_begin(MSG_ONE_UNRELIABLE, g_msgSayText, _, players[i])
                write_byte(players[i]);
                write_string(msg);
                message_end();
            }
        }
    }
}
 

Вложения

Сообщения
2,751
Реакции
3,016
Помог
61 раз(а)
А, какой вопрос по модификации или созданию плагина?
 

sHk

Сообщения
16
Реакции
2
wopox1337, Вот плагин изначально какой был, я убрал лишние для меня и hud
Но менюшка теперь открываться не xочет

Код:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <hamsandwich>

const KEYSMENU = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_6|MENU_KEY_7|MENU_KEY_8|MENU_KEY_9|MENU_KEY_0

enum
{
    NONE = -1,
    KNIFEMAP,
    KNIFETEAM,
    LIVE,
    WARM,
    REPLAY
}

new const g_Msg[][] =
{
    "KNIFE MAP",
    "KNIFE TEAM",
    "LIVE LIVE LIVE",
    "Разминка",
    "RE-PLAY 3 ROUNDS"
}
new g_msgSayText, g_MaxPlayers

new g_Count, g_CountA
new g_Round = NONE

public plugin_init()
{
    register_plugin("Lite CW", "1.0", "ill")
    
    register_event("CurWeapon", "EventCurWeapon", "be", "2!29")
    register_event("DeathMsg", "on_death", "a")
    register_logevent("logevent_round_end", 2, "1=Round_End")
    register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
    
    register_clcmd("amxmodmenu", "show_cw_menu")
    register_clcmd("cwmenu", "show_cw_menu")
    register_clcmd("type_password", "clcmd_setpassword", ADMIN_BAN);
    
    register_menu("CW Menu", KEYSMENU, "cw_menu")
    register_menu("Page Menu", KEYSMENU, "cw_menu2")
    
    RegisterHam(Ham_Spawn, "player", "fw_SpawnPost", 1)
    
    g_msgSayText = get_user_msgid("SayText")
    g_MaxPlayers = get_maxplayers()
    
    set_task(120.0, "reset_password", .flags = "b")
}

public reset_password()
{
    if(!get_playersnum())
        set_cvar_string("sv_password", "")
        
}
public clcmd_setpassword(id, bitsAccess)
{
    if(!(get_user_flags(id) & bitsAccess))
        return PLUGIN_HANDLED

    new szPwd[32]
    read_argv(1, szPwd, charsmax(szPwd))
    remove_quotes(szPwd)
    
    set_cvar_string("sv_password", szPwd)
    show_cw_menu(id)
    
    return PLUGIN_HANDLED
}
public logevent_round_end()
{
    g_Round = NONE
}

public event_round_start()
{
    set_task(1.0, "show_money")
}

public on_death()
{
    new victim
    victim = read_data(2)
    
    if(g_Round == WARM)
        set_task(1.0, "fnRevivePlayer", victim)
}

public fnRevivePlayer(id)
{
    if(!is_user_alive(id) && (get_user_team(id) == 1 || get_user_team(id) == 2))
        ExecuteHamB(Ham_CS_RoundRespawn, id)
}

public show_money()
{
    new szCt[512], szT[512], szName[32], lenT, lenCT
    for(new id = 1; id <= g_MaxPlayers; id++)
    {
        if(!is_user_alive(id))
        continue
        
        get_user_name(id, szName, charsmax(szName))
        switch(get_user_team(id))
        {
            case 1:
            {
                lenT += formatex(szT[lenT], charsmax(szT) - lenT, "%d - %s^n", cs_get_user_money(id), szName)
            }
            case 2:
            {
                lenCT += formatex(szCt[lenCT], charsmax(szCt) - lenCT, "%d - %s^n", cs_get_user_money(id), szName)
            }
        }
    }
    for(new id = 1; id <= g_MaxPlayers; id++)
    {
        if(!is_user_alive(id))
            continue
        
        switch(get_user_team(id))
        {
            case 1:
            {
                set_hudmessage(42, 85, 255, 0.63, 0.53, 0, 3.0, 8.0)
                show_hudmessage(id, szT)
            }
            case 2:
            {
                set_hudmessage(42, 85, 255, 0.63, 0.53, 0, 3.0, 8.0)
                show_hudmessage(id, szCt)
            }
        }
    }
}

public EventCurWeapon(id)
{
    if(g_Round == KNIFEMAP || g_Round == KNIFETEAM)
    {
        engclient_cmd(id, "weapon_knife")
    }
}

public fw_SpawnPost(id)
{
    if(!is_user_alive(id))
        return
    
    if(g_Round == WARM)
    {
        cs_set_user_money(id, 16000)
    }
    else if(g_Round == REPLAY)
    {
        cs_set_user_money(id, 10000)
    }
    
}

public show_cw_menu(id)
{
    if(!(get_user_flags(id) & ADMIN_BAN))
        return PLUGIN_HANDLED
        
    static menu[512], len
    len = 0
    
    len += formatex(menu[len], charsmax(menu) - len, "\y КВ Меню \w[1/2]^n^n")
    
    len += formatex(menu[len], charsmax(menu) - len, "\r1. \wКикнуть^n")
    len += formatex(menu[len], charsmax(menu) - len, "\r2. \wЗабанить^n")
    len += formatex(menu[len], charsmax(menu) - len, "\r3. \wСменить карту^n^n")
    
    len += formatex(menu[len], charsmax(menu) - len, "\r4. \wKnife раунд за карту^n")
    len += formatex(menu[len], charsmax(menu) - len, "\r5. \wKnife раунд за команду^n")
    len += formatex(menu[len], charsmax(menu) - len, "\r6. \wНачать игру^n^n")

    len += formatex(menu[len], charsmax(menu) - len, "\r7. \wРазминка^n")
    
    new iPwd[32];get_cvar_string("sv_password", iPwd, charsmax(iPwd))

    len += formatex(menu[len], charsmax(menu) - len, "\r8. \wПароль [\y%s\w]^n", iPwd[0] ? iPwd : "\rне установлен")
        
    len += formatex(menu[len], charsmax(menu) - len, "^n\r9. \wДалее")
    len += formatex(menu[len], charsmax(menu) - len, "^n\r0. \wВыход")
    
    show_menu(id, KEYSMENU, menu, -1, "CW Menu")
    
    return PLUGIN_HANDLED
}

public cw_menu(id, key)
{
    switch(key)
    {
        case 0:
        {
            client_cmd(id, "amx_kickmenu")
        }
        case 1:
        {
            client_cmd(id, "amx_banmenu")
        }
        case 2:
        {
            client_cmd(id, "amx_mapmenu")
        }
        case 3:
        {
            set_round(KNIFEMAP)
        }
        case 4:
        {
            set_round(KNIFETEAM)
        }
        case 5:
        {
            set_round(LIVE)
        }
        case 6:
        {
            set_round(WARM)
        }
        case 7:
        {
            new iPwd[32]
            get_cvar_string("sv_password", iPwd, charsmax(iPwd))
            if(iPwd[0])
            {
                set_cvar_string("sv_password", "")
                show_cw_menu(id)
            }
            else
                client_cmd(id, "messagemode type_password");
        }
        case 8:
        {
            show_cw_menu2(id)
        }
    }
    return PLUGIN_HANDLED
}

public show_cw_menu2(id)
{
    static menu[512], len
    len = 0
    
    len += formatex(menu[len], charsmax(menu) - len, "\y КВ Меню \w[2/2]^n^n")
    
    len += formatex(menu[len], charsmax(menu) - len, "\r1. \wПереместить^n")
    len += formatex(menu[len], charsmax(menu) - len, "\r2. \w10 000$^n")
    
    len += formatex(menu[len], charsmax(menu) - len, "^n\r9. \wНазад")
    len += formatex(menu[len], charsmax(menu) - len, "^n\r0. \wВыход")
    
    show_menu(id, KEYSMENU, menu, -1, "Page Menu")
    
    return PLUGIN_HANDLED
}

public cw_menu2(id, key)
{
    switch(key)
    {
        case 0:
        {
            client_cmd(id, "amx_teammenu")
        }
        case 1:
        {
            set_round(REPLAY)
        }
        case 8:
        {
            show_cw_menu(id)
        }
    }
    return PLUGIN_HANDLED
}
        
set_round(num)
{
    new iRes
    if(num == WARM)
    {
        iRes = 1
        server_cmd("mp_freezetime 0")
        server_cmd("mp_buytime 99")
    }
    else
    {
        iRes = 3
        server_cmd("mp_freezetime 8")
        server_cmd("mp_buytime 0.15")
    }
    
    g_CountA = 0
    g_Count = 0
    g_Round = num
    //log_to_file("cw.log", "Pre: g_Round = %d", g_Round)
    
    set_task(1.0, "restart", _, _, _, "a", iRes)
    set_task(0.2, "show_msg", 44335, _, _, "a", 21)
}

public show_msg()
{
    if(g_Round < 0)
    {
        remove_task(44335)
        return
    }
    //log_to_file("cw.log", "Post: g_Round = %d", g_Round)
        
    new iStart[12], iEnd[12]
    
    if(g_CountA == 11)
        g_Count = 1
        
    for(new s = 0; s < g_Count; s++)
        add(iStart, charsmax(iStart), "-")
    for(new s = 0; s < 10 - g_Count; s++)
        add(iEnd, charsmax(iEnd), "-")
    
    if(g_CountA <= 10)
        ChatColor(0, "^1[%s%s%s]", iStart, g_Msg[g_Round], iEnd)
    else
        ChatColor(0, "^1[%s%s%s]", iEnd, g_Msg[g_Round], iStart)
    
    g_CountA++
    g_Count++
    
    
}

public restart()
{
    server_cmd("sv_restart 1")
}

stock ChatColor(const id, const input[], any:...) {
    new count = 1, players[32]
    static msg[191]
    vformat(msg, 190, input, 3)
    replace_all(msg, 190, "!g", "^4") // Green Color
    replace_all(msg, 190, "!y", "^1") // Default Color
    replace_all(msg, 190, "!team", "^3") // Team Color
    if (id) players[0] = id; else get_players(players, count, "ch"); {
        for (new i = 0; i < count; i++) {
            if (is_user_connected(players[i])) {
                message_begin(MSG_ONE_UNRELIABLE, g_msgSayText, _, players[i])
                write_byte(players[i]);
                write_string(msg);
                message_end();
            }
        }
    }
}
29 Авг 2018
wopox1337, Я не пойму, что я сделал не так :(
 

Garey

ninjaCow
Сообщения
422
Реакции
1,056
Помог
10 раз(а)
зачем удалили event_round_start и не убрали из plugin_init?
 

sHk

Сообщения
16
Реакции
2
Garey, register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
Эту строчку над удалить?
 
Сообщения
2,288
Реакции
1,739
Помог
31 раз(а)
sHk, Используйте diff , что б скриптерам было легче видеть ваши исправления
 
Статус
В этой теме нельзя размещать новые ответы.

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

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