[ZP]knife Menu v2.2

Статус
В этой теме нельзя размещать новые ответы.
Сообщения
53
Реакции
12
Доброе утро, всем пользователям форума. Дело такое. Установил плагин "zp_addon_knife" на зомби сервер "ZP 5.0.8". Начало раунда, сначала показывает меню покупки оружия, автоматы потом пистолеты и после этого открывается Меню выбора ножей. Но оно открывается слишком быстро. Не успеваю выбрать нужное оружие, как выскакивает Меню выбора ножей. Подскажите, как изменить время появления меню ножей, или сделать так, что бы оно открывалось только после покупки пистолетов.
В настройках "zombieplague.cfg" указал :
Код:
zp_gamemode_delay 20        // Время до старта мода (в секундах)
zp_buy_custom_time 20        // Время в секундах в течение которого разрешено использовать меню закупок после старта раунда
zp_buyzone_time 20            // Время в секундах в течение которого разрешено закупаться в зоне покупке после спавна
Код плагина "zp_addon_knife" :
Код:
#include <amxmodx>
#include <fun>
#include <fakemeta>
#include <hamsandwich>
#include <zombieplague>

#define PLUGIN_NAME         "[ZP]knife Menu"
#define PLUGIN_VERSION        "2.2"
#define PLUGIN_AUTHOR     "Mr.H"

new KNIFE1_V_MODEL[] = "models/zp_knife/Zdorov/v_Zdorov.mdl"
new KNIFE1_P_MODEL[] = "models/zp_knife/Zdorov/p_Zdorov.mdl"

new KNIFE2_V_MODEL[] = "models/zp_knife/CKopocTb/v_CKopocTb.mdl"
new KNIFE2_P_MODEL[] = "models/zp_knife/CKopocTb/p_CKopocTb.mdl"

new KNIFE3_V_MODEL[] = "models/zp_knife/Gravit/v_Gravit.mdl"
new KNIFE3_P_MODEL[] = "models/zp_knife/Gravit/p_Gravit.mdl"

new KNIFE4_V_MODEL[] = "models/zp_knife/Otbros/v_Otbros2.mdl"
new KNIFE4_P_MODEL[] = "models/zp_knife/Otbros/p_Otbros2.mdl"

new KNIFE5_V_MODEL[] = "models/zp_knife/Mega/v_Mega.mdl"
new KNIFE5_P_MODEL[] = "models/zp_knife/Mega/p_Mega.mdl"

new const knife1_sounds[][] =
{
    "knife/Zdorov/knife_draw.wav",
    "knife/Zdorov/knife_slash1.wav",
    "knife/Zdorov/knife_slash2.wav",
    "knife/Zdorov/knife_wall.wav",
    "knife/Zdorov/knife_miss.wav",
    "knife/Zdorov/knife_stab.wav"
}

new const knife2_sounds[][] =
{
    "knife/CKopocTb/knife_draw.wav",
    "knife/CKopocTb/knife_miss.wav",
    "knife/CKopocTb/knife_slash2.wav",
    "knife/CKopocTb/knife_wall.wav",
    "knife/CKopocTb/knife_slash1.wav",
    "knife/CKopocTb/knife_hit.wav"
}

new const knife3_sounds[][] =
{
    "knife/Gravit/knife_draw.wav",
    "knife/Gravit/knife_miss.wav",
    "knife/Gravit/knife_slash2.wav",
    "knife/Gravit/knife_wall.wav",
    "knife/Gravit/knife_slash1.wav",
    "knife/Gravit/knife_hit.wav"
}

new const knife4_sounds[][] =
{
    "knife/Otbros/knife_draw.wav",
    "knife/Otbros/knife_slash1.wav",
    "knife/Otbros/knife_slash2.wav",
    "knife/Otbros/knife_wall.wav",
    "knife/Otbros/knife_miss.wav",
    "knife/Otbros/knife_stab.wav"
}

new const knife5_sounds[][] =
{
    "knife/Mega/knife_draw.wav",
    "knife/Mega/knife_slash1.wav",
    "knife/Mega/knife_slash1.wav",
    "knife/Mega/knife_slash1.wav",
    "knife/Mega/knife_miss.wav",
    "knife/Mega/knife_stab.wav"
}

#define KNIFE1_HEALTH        100
#define KNIFE2_SPEED        270.0
#define KNIFE3_JUMP        350
#define KNIFE4_KNOCK        8.0

new g_maxplayers
new timer[33]

new bool:g_has_knife1[33], bool:g_has_knife2[33], bool:g_has_knife3[33], bool:g_has_knife4[33], bool:g_has_knife5[33]

public plugin_init()
{
    register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)
    
    register_logevent("RoundStart", 2, "1=Round_Start")
    register_event("CurWeapon", "Event_Curweapon", "be", "1=1")
    
    register_forward(FM_EmitSound, "CEntity__EmitSound")
    register_forward(FM_PlayerPreThink, "fw_PlayerPreThink");
    RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage");
    
    g_maxplayers = get_maxplayers()
}

public plugin_precache()
{
    precache_model(KNIFE1_V_MODEL)
    precache_model(KNIFE1_P_MODEL)
    precache_model(KNIFE2_V_MODEL)
    precache_model(KNIFE2_P_MODEL)
    precache_model(KNIFE3_V_MODEL)
    precache_model(KNIFE3_P_MODEL)
    precache_model(KNIFE4_V_MODEL)
    precache_model(KNIFE4_P_MODEL)
    precache_model(KNIFE5_V_MODEL)
    precache_model(KNIFE5_P_MODEL)
    
    for(new i = 0; i < sizeof knife1_sounds; i++)
        precache_sound(knife1_sounds[i])

    for(new i = 0; i < sizeof knife2_sounds; i++)
        precache_sound(knife2_sounds[i])

    for(new i = 0; i < sizeof knife3_sounds; i++)
        precache_sound(knife3_sounds[i])

    for(new i = 0; i < sizeof knife4_sounds; i++)
        precache_sound(knife4_sounds[i])
                
    for(new i = 0; i < sizeof knife5_sounds; i++)
        precache_sound(knife5_sounds[i])
}

public RoundStart()
{
    for (new i = 1; i <= g_maxplayers; i++)
    {
        if(task_exists(i))
        {
            show_menu(i, 0, "^n", 1)
            remove_task(i)
        }
        if (!is_user_alive(i))
            continue;
        
        Knifes_Menu(i)
    }
}

public client_connect(id)
{
    g_has_knife1[id] = true     
    g_has_knife2[id] = false   
    g_has_knife3[id] = false
    g_has_knife4[id] = false
    g_has_knife5[id] = false
}

public client_disconnected(id)
{
    g_has_knife1[id] = false     
    g_has_knife2[id] = false   
    g_has_knife3[id] = false
    g_has_knife4[id] = false
    g_has_knife5[id] = false
}

public zp_user_infected_post(id)
{
    g_has_knife1[id] = false     
    g_has_knife2[id] = false   
    g_has_knife3[id] = false
    g_has_knife4[id] = false
    g_has_knife5[id] = false
}

public Knifes_Menu(id)
{
    timer[id] = 15
    
    set_task(1.0, "destroy_menu", id, _, _, "b")
    
    new menu = menu_create("Меню ножей: ", "menu_keys")
    
    menu_additem(menu, "\wРазор \d[+Здоровье]", "1", 0);
    menu_additem(menu, "\wКомбат \d[Скорость+10]", "2", 0);
    menu_additem(menu, "\wКатана \d[+350 Грава]", "3", 0);
    menu_additem(menu, "\wСтронг \d[Отброс]", "4", 0);
    menu_additem(menu, "\wМега Кувалба \d[Всё вместе]", "5", 0);
    
    menu_display( id, menu, 0 );
    return PLUGIN_HANDLED 
}

public destroy_menu(id)
{
    if (timer[id])
    {
        new text_timer[64]
        
        formatex(text_timer, charsmax(text_timer), "Меню закроется через %d секунд", timer[id])
      
        set_hudmessage(255, 255, 255, -1.0, -1.0, 0, 0.0, 1.0, 1.0, 1.0)
        show_hudmessage(id, text_timer)
        
        --timer[id]
    }
    else
    {
        remove_task(id)
        show_menu(id, 0, "^n", 1)
    }
}

public menu_keys(id, menu, item)
{
    if(item < 0)
        return PLUGIN_CONTINUE
        
    new cmd[2];
    new access, callback;
    menu_item_getinfo(menu, item, access, cmd,2,_,_, callback);
    new choice = str_to_num(cmd)
        
    switch (choice)
    {
        case 1:
        {
            buy_knife1(id)
        }
        case 2:
        {
            if (zp_get_user_zombie(id))
                return PLUGIN_HANDLED;
                
            buy_knife2(id)
        }
        case 3:
        {
            buy_knife3(id)
        }
        case 4:
        {       
            buy_knife4(id)
        }
        case 5:
        {   
            if (get_user_flags(id) & ADMIN_LEVEL_H)   
                buy_knife5(id)
            else
                Knifes_Menu(id)
        }   
    }
    
    emit_sound(id, CHAN_BODY, "items/gunpickup2.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
    
    remove_task(id)
    return PLUGIN_HANDLED;
}

public buy_knife1(id)
{
    g_has_knife1[id] = true     
    g_has_knife2[id] = false   
    g_has_knife3[id] = false
    g_has_knife4[id] = false
    g_has_knife5[id] = false
    
    set_user_health(id, get_user_health(id) + KNIFE1_HEALTH)
}

public buy_knife2(id)
{
    g_has_knife1[id] = false     
    g_has_knife2[id] = true   
    g_has_knife3[id] = false
    g_has_knife4[id] = false
    g_has_knife5[id] = false
}

public buy_knife3(id)
{
    g_has_knife1[id] = false     
    g_has_knife2[id] = false   
    g_has_knife3[id] = true
    g_has_knife4[id] = false
    g_has_knife5[id] = false
}

public buy_knife4(id)
{
    g_has_knife1[id] = false     
    g_has_knife2[id] = false   
    g_has_knife3[id] = false
    g_has_knife4[id] = true
    g_has_knife5[id] = false
}

public buy_knife5(id)
{
    g_has_knife1[id] = false     
    g_has_knife2[id] = false   
    g_has_knife3[id] = false
    g_has_knife4[id] = false
    g_has_knife5[id] = true
    
    set_user_health(id, get_user_health(id) + KNIFE1_HEALTH)
}

public Event_Curweapon(id)
{
    if(get_user_weapon(id) != CSW_KNIFE)
        return;
    
    if (g_has_knife1[id])
    {
        set_pev(id, pev_viewmodel2, KNIFE1_V_MODEL)
        set_pev(id, pev_weaponmodel2, KNIFE1_P_MODEL)
    }
    else if (g_has_knife2[id])
    {
        set_pev(id, pev_viewmodel2, KNIFE2_V_MODEL)
        set_pev(id, pev_weaponmodel2, KNIFE2_P_MODEL)
    }
    else if (g_has_knife3[id])
    {
        set_pev(id, pev_viewmodel2, KNIFE3_V_MODEL)
        set_pev(id, pev_weaponmodel2, KNIFE3_P_MODEL)
    }
    else if (g_has_knife4[id])
    {
        set_pev(id, pev_viewmodel2, KNIFE4_V_MODEL)
        set_pev(id, pev_weaponmodel2, KNIFE4_P_MODEL)
    }
    else if (g_has_knife5[id])
    {
        set_pev(id, pev_viewmodel2, KNIFE5_V_MODEL)
        set_pev(id, pev_weaponmodel2, KNIFE5_P_MODEL)
    }
        
    return;
}

public CEntity__EmitSound(id, channel, const sample[], Float:volume, Float:attn, flags, pitch)
{
    if (!is_user_connected(id))
        return HAM_IGNORED
    
    if (sample[8] == 'k' && sample[9] == 'n' && sample[10] == 'i')
    {   
        if (sample[14] == 'd')
        {
            if(g_has_knife1[id])
                emit_sound(id, channel, knife1_sounds[0], volume, attn, flags, pitch)
            if(g_has_knife2[id])
                emit_sound(id, channel, knife2_sounds[0], volume, attn, flags, pitch)
            if(g_has_knife3[id])
                emit_sound(id, channel, knife3_sounds[0], volume, attn, flags, pitch)
            if(g_has_knife4[id])
                emit_sound(id, channel, knife4_sounds[0], volume, attn, flags, pitch)   
            if(g_has_knife5[id])
                emit_sound(id, channel, knife5_sounds[0], volume, attn, flags, pitch)
        }
        else if (sample[14] == 'h')
        {
            if (sample[17] == 'w')
            {
                if(g_has_knife1[id])
                    emit_sound(id, channel, knife1_sounds[3], volume, attn, flags, pitch)
                if(g_has_knife2[id])
                    emit_sound(id, channel, knife2_sounds[3], volume, attn, flags, pitch)
                if(g_has_knife3[id])
                    emit_sound(id, channel, knife3_sounds[3], volume, attn, flags, pitch)
                if(g_has_knife4[id])
                    emit_sound(id, channel, knife4_sounds[3], volume, attn, flags, pitch)
                if(g_has_knife5[id] )
                    emit_sound(id, channel, knife5_sounds[3], volume, attn, flags, pitch)
            }
            else
            {
                if(g_has_knife1[id])
                    emit_sound(id, channel, knife1_sounds[random_num(1,2)], volume, attn, flags, pitch)
                if(g_has_knife2[id])
                    emit_sound(id, channel, knife2_sounds[random_num(1,2)], volume, attn, flags, pitch)
                if(g_has_knife3[id])
                    emit_sound(id, channel, knife3_sounds[random_num(1,2)], volume, attn, flags, pitch)
                if(g_has_knife4[id])
                    emit_sound(id, channel, knife4_sounds[random_num(1,2)], volume, attn, flags, pitch)
                if(g_has_knife5[id])
                    emit_sound(id, channel, knife5_sounds[random_num(1,2)], volume, attn, flags, pitch)
            }
        }
        else
        {
            if (sample[15] == 'l')
            {
                if(g_has_knife1[id])
                    emit_sound(id, channel, knife1_sounds[4], volume, attn, flags, pitch)
                if(g_has_knife2[id])
                    emit_sound(id, channel, knife2_sounds[4], volume, attn, flags, pitch)
                if(g_has_knife3[id])
                    emit_sound(id, channel, knife3_sounds[4], volume, attn, flags, pitch)
                if(g_has_knife4[id])
                    emit_sound(id, channel, knife4_sounds[4], volume, attn, flags, pitch)
                if(g_has_knife5[id])
                    emit_sound(id, channel, knife5_sounds[4], volume, attn, flags, pitch)
            }
            else
            {
                if(g_has_knife1[id])
                    emit_sound(id, channel, knife1_sounds[5], volume, attn, flags, pitch)
                if(g_has_knife2[id] )
                    emit_sound(id, channel, knife2_sounds[5], volume, attn, flags, pitch)
                if(g_has_knife3[id] )
                    emit_sound(id, channel, knife3_sounds[5], volume, attn, flags, pitch)
                if(g_has_knife4[id])
                    emit_sound(id, channel, knife4_sounds[5], volume, attn, flags, pitch)
                if(g_has_knife5[id])
                    emit_sound(id, channel, knife5_sounds[5], volume, attn, flags, pitch)
            }
        }
        return HAM_SUPERCEDE
    }
    return HAM_IGNORED
}

public fw_PlayerPreThink(id)
{
    if(!is_user_alive(id))
        return FMRES_IGNORED

    new temp[2], weapon = get_user_weapon(id, temp[0], temp[1])

    if (weapon == CSW_KNIFE && (g_has_knife2[id] || g_has_knife5[id]))
    {
        set_user_maxspeed(id, KNIFE2_SPEED)
    }     
    
    if(weapon == CSW_KNIFE && (g_has_knife3[id] || g_has_knife5[id]))
    {
        if ((pev(id, pev_button) & IN_JUMP) && !(pev(id, pev_oldbuttons) & IN_JUMP))
        {
            new flags = pev(id, pev_flags)
            new waterlvl = pev(id, pev_waterlevel)
                        
            if (!(flags & FL_ONGROUND))
                return FMRES_IGNORED
                
            if (flags & FL_WATERJUMP)
                return FMRES_IGNORED

            if (waterlvl > 1)
                return FMRES_IGNORED
                    
            new Float:fVelocity[3]
            pev(id, pev_velocity, fVelocity)
                        
            fVelocity[2] += KNIFE3_JUMP
                        
            set_pev(id, pev_velocity, fVelocity)
            set_pev(id, pev_gaitsequence, 6)
        }       
    }
    return FMRES_IGNORED
}

public fw_TakeDamage(victim, inflictor, attacker, Float:damage, damage_type)
{
    if(!is_user_connected(attacker))
        return HAM_IGNORED
        
    new temp[2], weapon = get_user_weapon(attacker, temp[0], temp[1])
    
    if(weapon == CSW_KNIFE && (g_has_knife4[attacker] || g_has_knife5[attacker]))
    {
        new Float:vec[3];
        new Float:oldvelo[3];
        pev(victim, pev_velocity, oldvelo);
        create_velocity_vector(victim , attacker , vec);
        vec[0] += oldvelo[0] + KNIFE4_KNOCK
        vec[1] += oldvelo[1] + 0;
        set_pev(victim, pev_velocity, vec);   
    }
    return HAM_IGNORED
}

stock create_velocity_vector(victim,attacker,Float:velocity[3])
{
    if(!is_user_alive(attacker))
        return 0;

    new Float:vicorigin[3];
    new Float:attorigin[3];
    pev(victim, pev_origin , vicorigin);
    pev(attacker, pev_origin , attorigin);

    new Float:origin2[3]
    origin2[0] = vicorigin[0] - attorigin[0];
    origin2[1] = vicorigin[1] - attorigin[1];

    new Float:largestnum = 0.0;

    if(floatabs(origin2[0])>largestnum) largestnum = floatabs(origin2[0]);
    if(floatabs(origin2[1])>largestnum) largestnum = floatabs(origin2[1]);

    origin2[0] /= largestnum;
    origin2[1] /= largestnum;
        
    if (g_has_knife4[attacker] || g_has_knife5[attacker])
    {
        velocity[0] = ( origin2[0] * KNIFE4_KNOCK * 10000 ) / floatround(get_distance_f(vicorigin, attorigin));
        velocity[1] = ( origin2[1] * KNIFE4_KNOCK * 10000 ) / floatround(get_distance_f(vicorigin, attorigin));
    }
    
    if(velocity[0] <= 20.0 || velocity[1] <= 20.0)
        velocity[2] = random_float(200.0 , 275.0);
        
    return 1;
}
Менял в коде
timer[id] = 15
на
timer[id] = 5
Нужного результата не дало. Изменилось время показа меню, а нужно что бы изменилось время запуска, появления меню.
 
Сообщения
49
Реакции
32
Меню у вас открывается сразу после старта раунда. Тут нужно либо делать еще таски на задержку, либо делать натив открывания меню и в коде зомби мода в обработчике меню пистолетов дергать натив меню ножей
 
Последнее редактирование:

RockTheStreet

Саппорт года
Сообщения
1,743
Реакции
344
Помог
40 раз(а)
Обратите внимание, если вы хотите заключить сделку с этим пользователем, он заблокирован
Тут нужно либо делать еще таски на задержку
Зачем в таких целях вообще использовать время, когда можно по закрытию одного меню открывать другое?
Пружинщик научил везде таски пихать?
 
Сообщения
53
Реакции
12
Я находил решение для ZP 4.3, а вот для ZP 5.0.8 так и не нашел. Ребят, я не скриптер, подскажите, что где поправить, или что куда вписать. Думаю для кого то, это очень просто, кто в этом шарит.
В код, представленный выше, я попробовал добавить такую строку
register_clcmd("say /knife", "display_knife")
ниже строки
register_event("CurWeapon", "Event_Curweapon", "be", "1=1")
Получилось так
Код:
#include <amxmodx>
#include <fun>
#include <fakemeta>
#include <hamsandwich>
#include <zombieplague>

#define PLUGIN_NAME         "[ZP]knife Menu"
#define PLUGIN_VERSION        "2.2"
#define PLUGIN_AUTHOR     "Mr.H"

new KNIFE1_V_MODEL[] = "models/zp_knife/Zdorov/v_Zdorov.mdl"
new KNIFE1_P_MODEL[] = "models/zp_knife/Zdorov/p_Zdorov.mdl"

new KNIFE2_V_MODEL[] = "models/zp_knife/CKopocTb/v_CKopocTb.mdl"
new KNIFE2_P_MODEL[] = "models/zp_knife/CKopocTb/p_CKopocTb.mdl"

new KNIFE3_V_MODEL[] = "models/zp_knife/Gravit/v_Gravit.mdl"
new KNIFE3_P_MODEL[] = "models/zp_knife/Gravit/p_Gravit.mdl"

new KNIFE4_V_MODEL[] = "models/zp_knife/Otbros/v_Otbros2.mdl"
new KNIFE4_P_MODEL[] = "models/zp_knife/Otbros/p_Otbros2.mdl"

new KNIFE5_V_MODEL[] = "models/zp_knife/Mega/v_Mega.mdl"
new KNIFE5_P_MODEL[] = "models/zp_knife/Mega/p_Mega.mdl"

new const knife1_sounds[][] =
{
    "knife/Zdorov/knife_draw.wav",
    "knife/Zdorov/knife_slash1.wav",
    "knife/Zdorov/knife_slash2.wav",
    "knife/Zdorov/knife_wall.wav",
    "knife/Zdorov/knife_miss.wav",
    "knife/Zdorov/knife_stab.wav"
}

new const knife2_sounds[][] =
{
    "knife/CKopocTb/knife_draw.wav",
    "knife/CKopocTb/knife_miss.wav",
    "knife/CKopocTb/knife_slash2.wav",
    "knife/CKopocTb/knife_wall.wav",
    "knife/CKopocTb/knife_slash1.wav",
    "knife/CKopocTb/knife_hit.wav"
}

new const knife3_sounds[][] =
{
    "knife/Gravit/knife_draw.wav",
    "knife/Gravit/knife_miss.wav",
    "knife/Gravit/knife_slash2.wav",
    "knife/Gravit/knife_wall.wav",
    "knife/Gravit/knife_slash1.wav",
    "knife/Gravit/knife_hit.wav"
}

new const knife4_sounds[][] =
{
    "knife/Otbros/knife_draw.wav",
    "knife/Otbros/knife_slash1.wav",
    "knife/Otbros/knife_slash2.wav",
    "knife/Otbros/knife_wall.wav",
    "knife/Otbros/knife_miss.wav",
    "knife/Otbros/knife_stab.wav"
}

new const knife5_sounds[][] =
{
    "knife/Mega/knife_draw.wav",
    "knife/Mega/knife_slash1.wav",
    "knife/Mega/knife_slash1.wav",
    "knife/Mega/knife_slash1.wav",
    "knife/Mega/knife_miss.wav",
    "knife/Mega/knife_stab.wav"
}

#define KNIFE1_HEALTH        100
#define KNIFE2_SPEED        270.0
#define KNIFE3_JUMP        350
#define KNIFE4_KNOCK        8.0

new g_maxplayers
new timer[33]

new bool:g_has_knife1[33], bool:g_has_knife2[33], bool:g_has_knife3[33], bool:g_has_knife4[33], bool:g_has_knife5[33]

public plugin_init()
{
    register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)
   
    register_logevent("RoundStart", 2, "1=Round_Start")
    register_event("CurWeapon", "Event_Curweapon", "be", "1=1")
   
    register_clcmd("say /knife", "display_knife")
   
    register_forward(FM_EmitSound, "CEntity__EmitSound")
    register_forward(FM_PlayerPreThink, "fw_PlayerPreThink");
    RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage");
   
    g_maxplayers = get_maxplayers()
}

public plugin_precache()
{
    precache_model(KNIFE1_V_MODEL)
    precache_model(KNIFE1_P_MODEL)
    precache_model(KNIFE2_V_MODEL)
    precache_model(KNIFE2_P_MODEL)
    precache_model(KNIFE3_V_MODEL)
    precache_model(KNIFE3_P_MODEL)
    precache_model(KNIFE4_V_MODEL)
    precache_model(KNIFE4_P_MODEL)
    precache_model(KNIFE5_V_MODEL)
    precache_model(KNIFE5_P_MODEL)
   
    for(new i = 0; i < sizeof knife1_sounds; i++)
        precache_sound(knife1_sounds[i])

    for(new i = 0; i < sizeof knife2_sounds; i++)
        precache_sound(knife2_sounds[i])

    for(new i = 0; i < sizeof knife3_sounds; i++)
        precache_sound(knife3_sounds[i])

    for(new i = 0; i < sizeof knife4_sounds; i++)
        precache_sound(knife4_sounds[i])
               
    for(new i = 0; i < sizeof knife5_sounds; i++)
        precache_sound(knife5_sounds[i])
}

public RoundStart()
{
    for (new i = 1; i <= g_maxplayers; i++)
    {
        if(task_exists(i))
        {
            show_menu(i, 0, "^n", 1)
            remove_task(i)
        }
        if (!is_user_alive(i))
            continue;
       
        Knifes_Menu(i)
    }
}

public client_connect(id)
{
    g_has_knife1[id] = true    
    g_has_knife2[id] = false  
    g_has_knife3[id] = false
    g_has_knife4[id] = false
    g_has_knife5[id] = false
}

public client_disconnected(id)
{
    g_has_knife1[id] = false    
    g_has_knife2[id] = false  
    g_has_knife3[id] = false
    g_has_knife4[id] = false
    g_has_knife5[id] = false
}

public zp_user_infected_post(id)
{
    g_has_knife1[id] = false    
    g_has_knife2[id] = false  
    g_has_knife3[id] = false
    g_has_knife4[id] = false
    g_has_knife5[id] = false
}

public Knifes_Menu(id)
{
    timer[id] = 19
   
    set_task(1.0, "destroy_menu", id, _, _, "b")
   
    new menu = menu_create("Меню ножей: ", "menu_keys")
   
    menu_additem(menu, "\wРазор \d[+Здоровье]", "1", 0);
    menu_additem(menu, "\wКомбат \d[Скорость+10]", "2", 0);
    menu_additem(menu, "\wКатана \d[+350 Грава]", "3", 0);
    menu_additem(menu, "\wСтронг \d[Отброс]", "4", 0);
    menu_additem(menu, "\wМега Кувалба \d[Всё вместе]", "5", 0);
   
    menu_display( id, menu, 0 );
    return PLUGIN_HANDLED
}

public destroy_menu(id)
{
    if (timer[id])
    {
        new text_timer[64]
       
        formatex(text_timer, charsmax(text_timer), "Меню закроется через %d секунд", timer[id])
     
        set_hudmessage(255, 255, 255, -1.0, -1.0, 0, 0.0, 1.0, 1.0, 1.0)
        show_hudmessage(id, text_timer)
       
        --timer[id]
    }
    else
    {
        remove_task(id)
        show_menu(id, 0, "^n", 1)
    }
}

public menu_keys(id, menu, item)
{
    if(item < 0)
        return PLUGIN_CONTINUE
       
    new cmd[2];
    new access, callback;
    menu_item_getinfo(menu, item, access, cmd,2,_,_, callback);
    new choice = str_to_num(cmd)
       
    switch (choice)
    {
        case 1:
        {
            buy_knife1(id)
        }
        case 2:
        {
            if (zp_get_user_zombie(id))
                return PLUGIN_HANDLED;
               
            buy_knife2(id)
        }
        case 3:
        {
            buy_knife3(id)
        }
        case 4:
        {      
            buy_knife4(id)
        }
        case 5:
        {  
            if (get_user_flags(id) & ADMIN_LEVEL_H)  
                buy_knife5(id)
            else
                Knifes_Menu(id)
        }  
    }
   
    emit_sound(id, CHAN_BODY, "items/gunpickup2.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
   
    remove_task(id)
    return PLUGIN_HANDLED;
}

public buy_knife1(id)
{
    g_has_knife1[id] = true    
    g_has_knife2[id] = false  
    g_has_knife3[id] = false
    g_has_knife4[id] = false
    g_has_knife5[id] = false
   
    set_user_health(id, get_user_health(id) + KNIFE1_HEALTH)
}

public buy_knife2(id)
{
    g_has_knife1[id] = false    
    g_has_knife2[id] = true  
    g_has_knife3[id] = false
    g_has_knife4[id] = false
    g_has_knife5[id] = false
}

public buy_knife3(id)
{
    g_has_knife1[id] = false    
    g_has_knife2[id] = false  
    g_has_knife3[id] = true
    g_has_knife4[id] = false
    g_has_knife5[id] = false
}

public buy_knife4(id)
{
    g_has_knife1[id] = false    
    g_has_knife2[id] = false  
    g_has_knife3[id] = false
    g_has_knife4[id] = true
    g_has_knife5[id] = false
}

public buy_knife5(id)
{
    g_has_knife1[id] = false    
    g_has_knife2[id] = false  
    g_has_knife3[id] = false
    g_has_knife4[id] = false
    g_has_knife5[id] = true
   
    set_user_health(id, get_user_health(id) + KNIFE1_HEALTH)
}

public Event_Curweapon(id)
{
    if(get_user_weapon(id) != CSW_KNIFE)
        return;
   
    if (g_has_knife1[id])
    {
        set_pev(id, pev_viewmodel2, KNIFE1_V_MODEL)
        set_pev(id, pev_weaponmodel2, KNIFE1_P_MODEL)
    }
    else if (g_has_knife2[id])
    {
        set_pev(id, pev_viewmodel2, KNIFE2_V_MODEL)
        set_pev(id, pev_weaponmodel2, KNIFE2_P_MODEL)
    }
    else if (g_has_knife3[id])
    {
        set_pev(id, pev_viewmodel2, KNIFE3_V_MODEL)
        set_pev(id, pev_weaponmodel2, KNIFE3_P_MODEL)
    }
    else if (g_has_knife4[id])
    {
        set_pev(id, pev_viewmodel2, KNIFE4_V_MODEL)
        set_pev(id, pev_weaponmodel2, KNIFE4_P_MODEL)
    }
    else if (g_has_knife5[id])
    {
        set_pev(id, pev_viewmodel2, KNIFE5_V_MODEL)
        set_pev(id, pev_weaponmodel2, KNIFE5_P_MODEL)
    }
       
    return;
}

public CEntity__EmitSound(id, channel, const sample[], Float:volume, Float:attn, flags, pitch)
{
    if (!is_user_connected(id))
        return HAM_IGNORED
   
    if (sample[8] == 'k' && sample[9] == 'n' && sample[10] == 'i')
    {  
        if (sample[14] == 'd')
        {
            if(g_has_knife1[id])
                emit_sound(id, channel, knife1_sounds[0], volume, attn, flags, pitch)
            if(g_has_knife2[id])
                emit_sound(id, channel, knife2_sounds[0], volume, attn, flags, pitch)
            if(g_has_knife3[id])
                emit_sound(id, channel, knife3_sounds[0], volume, attn, flags, pitch)
            if(g_has_knife4[id])
                emit_sound(id, channel, knife4_sounds[0], volume, attn, flags, pitch)  
            if(g_has_knife5[id])
                emit_sound(id, channel, knife5_sounds[0], volume, attn, flags, pitch)
        }
        else if (sample[14] == 'h')
        {
            if (sample[17] == 'w')
            {
                if(g_has_knife1[id])
                    emit_sound(id, channel, knife1_sounds[3], volume, attn, flags, pitch)
                if(g_has_knife2[id])
                    emit_sound(id, channel, knife2_sounds[3], volume, attn, flags, pitch)
                if(g_has_knife3[id])
                    emit_sound(id, channel, knife3_sounds[3], volume, attn, flags, pitch)
                if(g_has_knife4[id])
                    emit_sound(id, channel, knife4_sounds[3], volume, attn, flags, pitch)
                if(g_has_knife5[id] )
                    emit_sound(id, channel, knife5_sounds[3], volume, attn, flags, pitch)
            }
            else
            {
                if(g_has_knife1[id])
                    emit_sound(id, channel, knife1_sounds[random_num(1,2)], volume, attn, flags, pitch)
                if(g_has_knife2[id])
                    emit_sound(id, channel, knife2_sounds[random_num(1,2)], volume, attn, flags, pitch)
                if(g_has_knife3[id])
                    emit_sound(id, channel, knife3_sounds[random_num(1,2)], volume, attn, flags, pitch)
                if(g_has_knife4[id])
                    emit_sound(id, channel, knife4_sounds[random_num(1,2)], volume, attn, flags, pitch)
                if(g_has_knife5[id])
                    emit_sound(id, channel, knife5_sounds[random_num(1,2)], volume, attn, flags, pitch)
            }
        }
        else
        {
            if (sample[15] == 'l')
            {
                if(g_has_knife1[id])
                    emit_sound(id, channel, knife1_sounds[4], volume, attn, flags, pitch)
                if(g_has_knife2[id])
                    emit_sound(id, channel, knife2_sounds[4], volume, attn, flags, pitch)
                if(g_has_knife3[id])
                    emit_sound(id, channel, knife3_sounds[4], volume, attn, flags, pitch)
                if(g_has_knife4[id])
                    emit_sound(id, channel, knife4_sounds[4], volume, attn, flags, pitch)
                if(g_has_knife5[id])
                    emit_sound(id, channel, knife5_sounds[4], volume, attn, flags, pitch)
            }
            else
            {
                if(g_has_knife1[id])
                    emit_sound(id, channel, knife1_sounds[5], volume, attn, flags, pitch)
                if(g_has_knife2[id] )
                    emit_sound(id, channel, knife2_sounds[5], volume, attn, flags, pitch)
                if(g_has_knife3[id] )
                    emit_sound(id, channel, knife3_sounds[5], volume, attn, flags, pitch)
                if(g_has_knife4[id])
                    emit_sound(id, channel, knife4_sounds[5], volume, attn, flags, pitch)
                if(g_has_knife5[id])
                    emit_sound(id, channel, knife5_sounds[5], volume, attn, flags, pitch)
            }
        }
        return HAM_SUPERCEDE
    }
    return HAM_IGNORED
}

public fw_PlayerPreThink(id)
{
    if(!is_user_alive(id))
        return FMRES_IGNORED

    new temp[2], weapon = get_user_weapon(id, temp[0], temp[1])

    if (weapon == CSW_KNIFE && (g_has_knife2[id] || g_has_knife5[id]))
    {
        set_user_maxspeed(id, KNIFE2_SPEED)
    }    
   
    if(weapon == CSW_KNIFE && (g_has_knife3[id] || g_has_knife5[id]))
    {
        if ((pev(id, pev_button) & IN_JUMP) && !(pev(id, pev_oldbuttons) & IN_JUMP))
        {
            new flags = pev(id, pev_flags)
            new waterlvl = pev(id, pev_waterlevel)
                       
            if (!(flags & FL_ONGROUND))
                return FMRES_IGNORED
               
            if (flags & FL_WATERJUMP)
                return FMRES_IGNORED

            if (waterlvl > 1)
                return FMRES_IGNORED
                   
            new Float:fVelocity[3]
            pev(id, pev_velocity, fVelocity)
                       
            fVelocity[2] += KNIFE3_JUMP
                       
            set_pev(id, pev_velocity, fVelocity)
            set_pev(id, pev_gaitsequence, 6)
        }      
    }
    return FMRES_IGNORED
}

public fw_TakeDamage(victim, inflictor, attacker, Float:damage, damage_type)
{
    if(!is_user_connected(attacker))
        return HAM_IGNORED
       
    new temp[2], weapon = get_user_weapon(attacker, temp[0], temp[1])
   
    if(weapon == CSW_KNIFE && (g_has_knife4[attacker] || g_has_knife5[attacker]))
    {
        new Float:vec[3];
        new Float:oldvelo[3];
        pev(victim, pev_velocity, oldvelo);
        create_velocity_vector(victim , attacker , vec);
        vec[0] += oldvelo[0] + KNIFE4_KNOCK
        vec[1] += oldvelo[1] + 0;
        set_pev(victim, pev_velocity, vec);  
    }
    return HAM_IGNORED
}

stock create_velocity_vector(victim,attacker,Float:velocity[3])
{
    if(!is_user_alive(attacker))
        return 0;

    new Float:vicorigin[3];
    new Float:attorigin[3];
    pev(victim, pev_origin , vicorigin);
    pev(attacker, pev_origin , attorigin);

    new Float:origin2[3]
    origin2[0] = vicorigin[0] - attorigin[0];
    origin2[1] = vicorigin[1] - attorigin[1];

    new Float:largestnum = 0.0;

    if(floatabs(origin2[0])>largestnum) largestnum = floatabs(origin2[0]);
    if(floatabs(origin2[1])>largestnum) largestnum = floatabs(origin2[1]);

    origin2[0] /= largestnum;
    origin2[1] /= largestnum;
       
    if (g_has_knife4[attacker] || g_has_knife5[attacker])
    {
        velocity[0] = ( origin2[0] * KNIFE4_KNOCK * 10000 ) / floatround(get_distance_f(vicorigin, attorigin));
        velocity[1] = ( origin2[1] * KNIFE4_KNOCK * 10000 ) / floatround(get_distance_f(vicorigin, attorigin));
    }
   
    if(velocity[0] <= 20.0 || velocity[1] <= 20.0)
        velocity[2] = random_float(200.0 , 275.0);
       
    return 1;
}
Плагин скомпилировался без ошибок, на мое удивление. Поставил на сервер, плагин запустился нормально без ошибок. Но в самой игре, меню вообще пропало. А когда выбрал играть за зомби, то клиент завис.
Коддинг это не мое, по этому прощу помощи знающих людей
 
Последнее редактирование:
Статус
В этой теме нельзя размещать новые ответы.

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

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