[AMX] Tổng hợp Code, Plug do Mem chế hoặc giới thiệu

Thảo luận trong 'Counter Strike' bắt đầu bởi Orpheus, 22/1/11.

  1. teobrvt1995

    teobrvt1995 T.E.T.Я.I.S

    Tham gia ngày:
    19/9/10
    Bài viết:
    691
    sprites thì nên dùng eexplo.spr, cái này nhìn đẹp hơn cái zerogxlode.spr ý :D
     
  2. legiondark

    legiondark Donkey Kong

    Tham gia ngày:
    2/5/11
    Bài viết:
    357
    Nơi ở:
    Skynet !
    1 pé đang ngồi yên thì bị ta cho nổ =)):
    [​IMG]
    Àh, có 1 lỗi nữa là tỉ lệ spr quá to, phải cho nhỏ lại, làm nó tỉ lệ với radius là tốt nhất (cái này để mình tự làm xem thế nào)
     
  3. buiducduy111

    buiducduy111 Dragon Quest

    Tham gia ngày:
    3/5/11
    Bài viết:
    1,257
    Tốn money phải bít đấy...
    P/s: Đọc trong plguins
    nó viết :
    set_hudmessage(100,100,100,0.5,0.5......) là cái gì thê ạ???
     
  4. rocxman800

    rocxman800 Dragon Quest

    Tham gia ngày:
    7/11/05
    Bài viết:
    1,215
    Nơi ở:
    trên Trển áh
    ^
    Nếu không có dấu ... thì đoán thử nhé, 3 số đầu là mã màu, 2 số sau là tỉ lệ của hud so với gốc :-?
     
  5. NguLongHaKhac

    NguLongHaKhac T.E.T.Я.I.S

    Tham gia ngày:
    5/2/11
    Bài viết:
    653
    Nơi ở:
    MC
    Không có ai giúp mình ak :(
    P/S:Topic này kiểu gì vậy ? Hỏi về AMX cũng không được ak,Hỏi mấy lần chả có ai nói gì cứ mặc kệ :-w Hay là mọi người coi thường tôi quá :|Chả hiểu mọi người ntn đi nữa :-w
     
  6. legiondark

    legiondark Donkey Kong

    Tham gia ngày:
    2/5/11
    Bài viết:
    357
    Nơi ở:
    Skynet !
    Ko hiểu, tách tức là sao, paste code lên đây sẽ có người giúp
     
  7. NguLongHaKhac

    NguLongHaKhac T.E.T.Я.I.S

    Tham gia ngày:
    5/2/11
    Bài viết:
    653
    Nơi ở:
    MC
    Code Đây :|:
    [spoil]/* Plugin generated by AMXX-Studio */

    #include <amxmodx>
    #include <amxmisc>
    #include <cstrike>
    #include <fakemeta>
    #include <hamsandwich>
    #include <xs>
    #include <csx>
    #include <engine>
    #include <g4u>
    #include <zombie_mod>
    #include <ghost>
    #include <character>
    #define max_wpn 255
    #define task_register_function 52301616
    #define PLUGIN "G4U Knife"
    #define VERSION "1.0"
    #define AUTHOR "Nguyen Duy Linh"
    #define knives (1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<7)|(1<<8)|(1<<9) // Keys: 1234567890
    #define key_menu (1<<9) // Keys: 0
    #define task_execute_my_damage 25251325
    #define TASK_DO_MY_FIRST_ATK 2592
    #define TASK_DO_MY_SECOND_ATK 100000
    #define TASK_CAN_ATK 200300400
    new weapon_name[max_wpn][64]
    new weapon_hud_kill[max_wpn][100]
    new Float:damage_player[max_wpn][2]
    new Float:damage_entity[max_wpn][2], weapon_cost[max_wpn]
    new Float:damage_hostage[max_wpn][2]
    new weapon_level[max_wpn], weapon_cost_type[max_wpn]
    new weapon_v_model[max_wpn][256], weapon_p_model[max_wpn][256]
    new has_weapon[33], weapon_deploy[max_wpn][256], weapon_slash[max_wpn][256]
    new weapon_hitbody[max_wpn][256], weapon_stab[max_wpn][256], weapon_hitwall[max_wpn][256]
    new weapon_fSlashType[max_wpn], weapon_sSlashType[max_wpn]
    new Float:weapon_fRange[max_wpn], Float:weapon_sRange[max_wpn]
    new Float:weapon_deploy_time[max_wpn], Float:weapon_fSlashTime[max_wpn], Float:weapon_sSlashTime[max_wpn]
    new Float:weapon_fDmgDelay[max_wpn], Float:weapon_sDmgDelay[max_wpn]
    new g_weapon_count = 0
    new g_page[32], menuid
    new g_knife, g_result
    new bool:ham_cz
    new g_normal_selected, g_new_selected
    new g_KnifefAtk, g_KnifesAtk
    new weapon_files[max_wpn][256]
    const Float:def_first_attack = 1.0
    const Float:def_second_attack = 1.2
    const Float:def_range = 67.0
    const Float:def_first_dmg_delay = 0.25
    const Float:def_second_dmg_delay = 0.5
    const Float:def_second_dmg = 100.0
    const Float:def_deploy_time = 1.5
    new bool:is_attacking[33]
    new Float:g_fDelay[33]
    new g_knife_kill
    const m_pPlayer = 41
    const m_iId = 43
    const m_fKnown = 44
    const m_flNextPrimaryAttack = 46
    const m_flNextSecondaryAttack = 47
    const m_flTimeWeaponIdle = 48
    const m_iPrimaryAmmoType = 49
    const m_iClip = 51
    const m_fInReload = 54
    const m_fInSpecialReload = 55
    const m_fSilent = 74
    const m_flNextAttack = 83
    const m_rgAmmo_player_Slot0 = 376
    enum
    {
    ANIM_IDLE,
    ANIM_SLASH1,
    ANIM_SLASH2,
    ANIM_DRAW,
    ANIM_STAB,
    ANIM_STAB_MISS,
    ANIM_MIDSLASH1,
    ANIM_MIDSLASH2
    }

    new Float:g_fDeploy[33], Float:g_fAtkTime[33], Float:g_sAtkTime[33]
    new fUserAnim[64]
    new bool:is_connected[33]
    new weapon_model_index[max_wpn]
    new Float:g_sDelay[33]
    new Float:weapon_weight[max_wpn], Float:weapon_dspeed[max_wpn]
    public plugin_natives()
    {
    register_native("g4u_equip_knife", "_equip_player", 1)
    register_native("g4u_get_knife_hud", "_get_hud", 1)
    register_native("g4u_force_user_buy_knife", "_force_buy", 1)
    register_native("g4u_user_has_knife", "_get_knife", 1)
    register_native("g4u_get_knife_name", "_get_name", 1)
    register_native("g4u_strip_user_knife", "_strip_knife", 1)
    register_native("g4u_get_knife_amount", "_get_amount", 1)
    register_native("g4u_knifeid_by_model", "_knifeid_by_model", 1)
    register_native("g4u_equip_knife_level", "_knife_level", 1)
    register_native("g4u_get_knife_cost", "_knife_cost", 1)
    register_native("g4u_get_knife_cost_type", "_knife_cost_type", 1)
    register_native("g4u_get_knife_weight", "_get_knife_weight", 1)
    register_native("g4u_get_knife_dspeed", "_get_knife_dspeed", 1)
    }

    public Float:_get_knife_weight(wid)
    {
    if (wid < 0 || wid > g_weapon_count - 1)
    return 0.0
    return weapon_weight[wid]
    }

    public Float:_get_knife_dspeed(wid)
    {
    if (wid < 0 || wid > g_weapon_count - 1)
    return 0.0
    return weapon_dspeed[wid]
    }

    public _knife_cost(wid)
    {
    if (wid < 0 || wid > g_weapon_count - 1)
    return -1
    return weapon_cost[wid]
    }

    public _knife_cost_type(wid)
    {
    if (wid < 0 || wid > g_weapon_count - 1)
    return -1
    return weapon_cost_type[wid]
    }

    public plugin_init()
    {
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_clcmd("g4u_knife", "cmdbuy")
    register_clcmd("g4u_kmenu", "cmdmenu")
    register_event("CurWeapon","checkWeapon","b","1=1")
    register_event("35", "event_weapon_anim", "b")
    register_message(get_user_msgid("DeathMsg"), "func_death")
    register_message(get_user_msgid("WeapPickup"),"message_weappickup")
    //register_message(get_user_msgid("HideWeapon"), "message_hideweapon")
    menuid = register_menuid("[MELEE LIST]")
    g_knife = CreateMultiForward("g4u_player_equip_knife", ET_IGNORE, FP_CELL, FP_CELL)
    g_knife_kill = CreateMultiForward("g4u_knife_hit", ET_IGNORE, FP_CELL, FP_CELL, FP_CELL)
    g_normal_selected = CreateMultiForward("g4u_normal_knife_selected", ET_IGNORE, FP_CELL)
    g_new_selected = CreateMultiForward("g4u_new_knife_selected", ET_IGNORE, FP_CELL, FP_CELL, FP_STRING, FP_STRING, FP_STRING)
    g_KnifefAtk = CreateMultiForward("g4u_knife_first_atk", ET_IGNORE, FP_CELL)
    g_KnifesAtk = CreateMultiForward("g4u_knife_second_atk", ET_IGNORE, FP_CELL)
    register_menucmd(menuid, knives, "show_weapon")
    register_forward(FM_EmitSound, "fw_emitsound")
    register_forward(FM_CmdStart, "fw_cmdstart")
    register_forward(FM_UpdateClientData, "fm_update_data", 1)
    RegisterHam(Ham_Player_PreThink, "player", "pl_prethink")
    RegisterHam(Ham_Spawn, "player", "pl_spawn", 1)
    RegisterHam(Ham_Use, "player_weaponstrip", "fw_strip")
    RegisterHam(Ham_Item_Deploy, "weapon_knife", "fw_KnifeDeploy")
    RegisterHam(Ham_TakeDamage, "player", "pl_take_damage")
    RegisterHam(Ham_TakeDamage, "hostage_entity", "hs_take_damage")
    RegisterHam(Ham_TakeDamage, "monster_scientist", "hs_take_damage")
    RegisterHam(Ham_TakeDamage, "func_breakable", "ent_take_damage")
    RegisterHam(Ham_TakeDamage, "func_pushable", "ent_take_damage")

    }

    public plugin_precache()
    {
    new con_dir[256], trash, mapname[32]
    get_mapname(mapname, 31)
    ham_cz = false
    get_configsdir(con_dir, 255)
    new manager[256]
    format(manager, 255, "%s/g4u_weapon/knife/weapon_config/manager.cfg", con_dir)
    if (file_exists(manager))
    {
    for (new i = 0; i < file_size(manager, 1); i++)
    {
    if (i < max_wpn)
    {
    new con_file[256], txt[256], len
    read_file(manager, i, txt, 255, len)
    format(con_file, 255, "%s/g4u_weapon/knife/weapon_config/%s.ini", con_dir, txt)
    if (file_exists(con_file))
    {
    new text[256]
    read_file(con_file, 0, text, 255, trash)
    replace(text, 255, "[name]", "")
    format(weapon_name[g_weapon_count], 255, "%s", text)
    read_file(con_file, 1, text, 255, trash)
    replace(text, 255, "[first-type]", "")
    weapon_fSlashType[g_weapon_count] = str_to_num(text)
    read_file(con_file, 2, text, 255, trash)
    replace(text, 255, "[second-type]", "")
    weapon_sSlashType[g_weapon_count] = str_to_num(text)
    new fArg[32], sArg[32]
    read_file(con_file, 3, text, 255, trash)
    replace(text, 255, "[range]", "")
    parse(text, fArg, 31, sArg, 31)
    weapon_fRange[g_weapon_count] = str_to_float(fArg)
    weapon_sRange[g_weapon_count] = str_to_float(sArg)
    read_file(con_file, 4, text, 255, trash)
    replace(text, 255, "[atk-time]", "")
    parse(text, fArg, 31, sArg, 31)
    weapon_fSlashTime[g_weapon_count] = str_to_float(fArg)
    weapon_sSlashTime[g_weapon_count] = str_to_float(sArg)
    read_file(con_file, 5, text, 255, trash)
    replace(text, 255, "[dmg-delay]", "")
    parse(text, fArg, 31, sArg, 31)
    weapon_fDmgDelay[g_weapon_count] = str_to_float(fArg)
    weapon_sDmgDelay[g_weapon_count] = str_to_float(sArg)
    read_file(con_file, 6, text, 255, trash)
    replace(text, 255, "[hud_kill]", "")
    format(weapon_hud_kill[g_weapon_count], 255, "%s", text)
    read_file(con_file, 7, text, 255, trash)
    replace(text, 255, "[damage_player]", "")
    parse(text, fArg, 31, sArg, 31)
    damage_player[g_weapon_count][0] = str_to_float(fArg)
    damage_player[g_weapon_count][1] = str_to_float(sArg)
    read_file(con_file, 8, text, 255, trash)
    replace(text, 255, "[damage_entity]", "")
    parse(text, fArg, 31, sArg, 31)
    damage_entity[g_weapon_count][0] = str_to_float(fArg)
    damage_entity[g_weapon_count][1] = str_to_float(sArg)
    read_file(con_file, 9, text, 255, trash)
    replace(text, 255, "[damage_hostage]", "")
    parse(text, fArg, 31, sArg, 31)
    damage_hostage[g_weapon_count][0] = str_to_float(fArg)
    damage_hostage[g_weapon_count][1] = str_to_float(sArg)
    read_file(con_file, 10, text, 255, trash)
    replace(text, 255, "[cost_type]", "")
    weapon_cost_type[g_weapon_count] = str_to_num(text)
    if (weapon_cost_type[g_weapon_count] != 1 && weapon_cost_type[g_weapon_count] != 2)
    weapon_cost_type[g_weapon_count] = 1
    read_file(con_file, 11, text, 255, trash)
    replace(text, 255, "[cost]", "")
    weapon_cost[g_weapon_count] = str_to_num(text)
    if (weapon_cost[g_weapon_count] < 0)
    weapon_cost[g_weapon_count] = 10
    read_file(con_file, 12, text, 255, trash)
    replace(text, 255, "[model]", "")
    format(weapon_p_model[g_weapon_count], 255, "models/g4u_wpn/%s/p_%s.mdl", text, text)
    format(weapon_v_model[g_weapon_count], 255, "models/g4u_wpn/%s/v_%s.mdl", text, text)
    weapon_model_index[g_weapon_count] = precache_model(weapon_v_model[g_weapon_count])
    precache_model(weapon_p_model[g_weapon_count])
    read_file(con_file, 13, text, 255, trash)
    replace(text, 255, "[level]", "")
    weapon_level[g_weapon_count] = str_to_num(text)
    if (weapon_level[g_weapon_count] > g4u_get_max_level())
    weapon_level[g_weapon_count] = g4u_get_max_level()
    read_file(con_file, 14, text, 255, trash)
    replace(text, 255, "[deploy-sound]", "")
    format(weapon_deploy[g_weapon_count], 255, "weapons/g4u_wpn/%s.wav", text)
    read_file(con_file, 15, text, 255, trash)
    replace(text, 255, "[slash-sound]", "")
    format(weapon_slash[g_weapon_count], 255, "weapons/g4u_wpn/%s.wav", text)
    read_file(con_file, 16, text, 255, trash)
    replace(text, 255, "[hitbody-sound]", "")
    format(weapon_hitbody[g_weapon_count], 255, "weapons/g4u_wpn/%s.wav", text)
    read_file(con_file, 17, text, 255, trash)
    replace(text, 255, "[stab-sound]", "")
    format(weapon_stab[g_weapon_count], 255, "weapons/g4u_wpn/%s.wav", text)
    read_file(con_file, 18, text, 255, trash)
    replace(text, 255, "[hitwall-sound]", "")
    format(weapon_hitwall[g_weapon_count], 255, "weapons/g4u_wpn/%s.wav", text)
    precache_sound(weapon_deploy[g_weapon_count])
    precache_sound(weapon_slash[g_weapon_count])
    precache_sound(weapon_hitbody[g_weapon_count])
    precache_sound(weapon_stab[g_weapon_count])
    precache_sound(weapon_hitwall[g_weapon_count])
    read_file(con_file, 19, text, 255, trash)
    replace(text, 255, "[deploy-time]", "")
    weapon_deploy_time[g_weapon_count] = str_to_float(text)
    format(weapon_files[g_weapon_count], 255, "%s/g4u_weapon/knife/weapon_config/%s", con_dir, txt)
    read_file(con_file, 20, text, 255, trash)
    replace(text, 255, "[weight]", "")
    weapon_weight[g_weapon_count] = str_to_float(text)
    read_file(con_file, 21, text, 255, trash)
    replace(text, 255, "[dspeed", "")
    weapon_dspeed[g_weapon_count] = str_to_float(text)
    g_weapon_count++
    }
    }
    }
    }
    }

    public _equip_player(id, weaponid, show_message)
    {
    if (weaponid > g_weapon_count)
    return
    if (weaponid < 0)
    return
    if (!pev_valid(id))
    return
    if (g4u_get_user_zombie(id))
    return
    has_weapon[id] = weaponid
    if (!user_has_weapon(id, CSW_KNIFE))
    fm_give_item(id, "weapon_knife")
    engclient_cmd(id, "weapon_knife")
    reset_knife(id)

    }

    public _get_hud(weaponid, hud[], len)
    {
    param_convert(2)
    if (weaponid < 0 || weaponid > g_weapon_count)
    format(hud, len, "NULL")
    format(hud, len, weapon_hud_kill[weaponid])
    }

    public _force_buy(id, weaponid)
    buy_weapon(id, weaponid)

    public _get_knife(id)
    return has_weapon[id]

    public _get_name(wpnid, wpnname[], len)
    {
    param_convert(2)
    if (wpnid > g_weapon_count || wpnid < 0)
    format(wpnname, len, "NULL")
    else format(wpnname, len, "%s", weapon_name[wpnid])
    }

    public _strip_knife(id)
    {
    ham_strip_weapon(id, "weapon_knife")
    has_weapon[id] = -1
    }

    public _get_amount()
    return g_weapon_count

    public _knifeid_by_model(const model[], len)
    {
    param_convert(1)
    for (new i = 0; i < g_weapon_count; i++)
    if (equal(model, weapon_v_model, len))
    return i
    return -1
    }
    stock get_knifeid_by_model(const model[], len)
    {
    param_convert(1)
    for (new i = 0; i < g_weapon_count; i++)
    if (equal(model, weapon_v_model, len))
    return i
    return -1
    }
    public _knife_level(id, model[], len)
    {
    param_convert(2)
    new weaponid = get_knifeid_by_model(model, len)
    if (!is_user_alive(id))
    return -1
    if (g4u_get_user_zombie(id))
    {
    client_print(id, print_center, "[G4U MSG] Vu khi nay khong danh cho Zombie")
    return -1
    }
    if (weaponid > g_weapon_count || weaponid < 0)
    return -1
    if (g4u_get_level(id) < weapon_level[weaponid])
    {
    new need_to_level[256]
    g4u_get_level_name(weapon_level[weaponid], need_to_level, 255)
    client_print(id, print_center, "[G4U MSG] Ban phai dat %s de trang bi vu khi nay", need_to_level)
    return -1

    }
    ham_strip_weapon(id, "weapon_knife")
    has_weapon[id] = -1
    //if (!user_has_weapon(id, CSW_KNIFE))
    // fm_give_item(id, "weapon_knife")
    //engclient_cmd(id, "weapon_knife")
    //engclient_cmd(id, "weapon_knife")
    //reset_knife(id)
    //set_pev(id, pev_viewmodel2, weapon_v_model[has_weapon[id]])
    //set_pev(id, pev_viewmodel, weapon_v_model[has_weapon[id]])
    //set_pev(id, pev_weaponmodel2, weapon_p_model[has_weapon[id]])
    //set_pev(id, pev_weaponmodel, weapon_p_model[has_weapon[id]])
    // client_print(id, print_chat, "[G4U MSG] Ban da trang bi %s", weapon_name[weaponid])
    has_weapon[id] = weaponid
    //_equip_player(id, weaponid, 0)
    ExecuteForward(g_knife, g_result, id, weaponid)
    return 1
    }

    public client_connect(id)
    {
    has_weapon[id] = -1
    }

    public client_putinserver(id)
    {
    if (is_user_bot(id))
    set_task(0.1, "register_bot_function", id + task_register_function)
    is_connected[id] = true
    }

    public register_bot_function(taskid)
    {
    new id = taskid - task_register_function
    if (pev_valid(id) && !ham_cz && get_cvar_num("bot_quota"))
    {
    RegisterHamFromEntity(Ham_Spawn, id, "pl_spawn", 1)
    RegisterHamFromEntity(Ham_TakeDamage, id, "pl_take_damage")
    //RegisterHamFromEntity(Ham_Killed, id , "pl_death", 1)
    RegisterHamFromEntity(Ham_Player_UpdateClientData, id, "fw_BotUpdate")
    ham_cz = true
    }
    }

    public client_death(killer, victim)
    {
    if (pev_valid(victim))
    {
    has_weapon[victim] = -1
    new menuindex, keys
    get_user_menu(victim, menuindex, keys)
    if (menuindex == menuid)
    client_cmd(victim, "slot10")
    }
    is_attacking[victim] = false
    }

    public cmdbuy(id, level, cid)
    {
    if (cmd_access(id, level, cid, 2))
    {
    new fArg[3]
    read_argv(1, fArg, 3)
    new weapon_id = str_to_num(fArg)
    buy_weapon(id, weapon_id)
    }
    }

    public cmdmenu(id)
    {
    if (!is_user_alive(id) || g4u_get_user_zombie(id))
    return
    g_page[id] = 0
    show_weapon_now(id, 0)
    }

    public checkWeapon(id)
    {
    if (get_user_weapon(id) == CSW_KNIFE)
    {
    if (!g4u_get_user_zombie(id))
    {
    if (has_weapon[id] > -1)
    {
    set_pev(id, pev_viewmodel2, weapon_v_model[has_weapon[id]])
    set_pev(id, pev_weaponmodel2, weapon_p_model[has_weapon[id]])
    ExecuteForward(g_new_selected, g_result, id, has_weapon[id], weapon_name[has_weapon[id]], weapon_hud_kill[has_weapon[id]], weapon_files[has_weapon[id]])
    //hide_cross(id)
    }
    else ExecuteForward(g_normal_selected, g_result, id)
    }
    //else
    // set_pev(id, pev_weaponmodel2, "")
    }

    }

    public event_weapon_anim()
    {
    // Because of a weird bug within the AMXX event system, we need to
    // hook this message to prevent some weird behavior when calling
    // engclient_cmd(id, "weapon_knife") in the CurWeapon Event forward.
    // http://forums.alliedmods.net/showthread.php?t=85161&page=2
    }

    public g4u_infected_pre(victim, infector)
    has_weapon[victim] = -1

    public g4u_zombie_appear_post(zombieid)
    has_weapon[zombieid] = -1

    public g4u_user_become_zombie(id)
    has_weapon[id] = -1
    public func_death(msg_id, msg_dest, msg_entity)
    {
    static szTruncatedWeapon[33], iAttacker, iVictim
    get_msg_arg_string(4, szTruncatedWeapon, charsmax(szTruncatedWeapon))
    // Get attacker and victim
    iAttacker = get_msg_arg_int(1)
    iVictim = get_msg_arg_int(2)
    // Non-player attacker or self kill
    if(!is_user_connected(iAttacker) || iAttacker == iVictim)
    return PLUGIN_CONTINUE
    if(equal(szTruncatedWeapon, "knife", 5) && get_user_weapon(iAttacker) == CSW_KNIFE)
    {
    if (has_weapon[iAttacker] >-1)
    set_msg_arg_string(4, weapon_hud_kill[has_weapon[iAttacker]])
    }
    return PLUGIN_CONTINUE
    }

    public message_weappickup(msg_id, msg_dest, msg_entity)
    return PLUGIN_HANDLED

    public show_weapon(id, key)
    {
    if (key < 7)
    {
    new weapon_index = g_page[id] * 7 + key
    buy_weapon(id, weapon_index)
    }
    if (key == 7)
    { // 8
    if (g_page[id] - 1 < 0)
    g_page[id] = 0
    else g_page[id]--
    show_weapon_now(id, g_page[id])
    }
    if (key == 8)
    {
    new start = g_page[id] * 7
    if (start > g_weapon_count)
    show_weapon_now(id, g_page[id])
    else
    {
    g_page[id]++
    show_weapon_now(id, g_page[id])
    }
    }
    if (key == 9)
    {}
    }

    public fw_emitsound(id, channel, const sample[], Float:volume, Float:attn, flags, pitch)
    {
    if (!is_user_connected(id) || !is_user_alive(id) || has_weapon[id] < 0)
    return FMRES_IGNORED
    // Zombie attacks with knife
    if (equal(sample[8], "kni", 3))
    {
    if (equal(sample[14], "sla", 3)) // slash
    {
    engfunc(EngFunc_EmitSound, id, channel, weapon_slash[has_weapon[id]], volume, attn, flags, pitch)
    return FMRES_SUPERCEDE;
    }
    if (equal(sample[14], "hit", 3))
    {
    if (sample[17] == 'w') // wall
    {
    engfunc(EngFunc_EmitSound, id, channel, weapon_hitwall[has_weapon[id]], volume, attn, flags, pitch)
    return FMRES_SUPERCEDE;
    }
    else // hit
    {
    engfunc(EngFunc_EmitSound, id, channel, weapon_hitbody[has_weapon[id]], volume, attn, flags, pitch)
    return FMRES_SUPERCEDE;
    }
    }
    if (equal(sample[14], "sta", 3)) // stab
    {
    engfunc(EngFunc_EmitSound, id, channel, weapon_stab[has_weapon[id]], volume, attn, flags, pitch)
    return FMRES_SUPERCEDE;
    }
    }

    return FMRES_IGNORED;
    }

    public fw_cmdstart(id, uchandle, seed)
    {
    if (!is_user_alive(id))
    return FMRES_IGNORED
    if (has_weapon[id] > -1)
    {
    if (get_user_weapon(id) == CSW_KNIFE)
    {
    if (!g4u_get_user_zombie(id))
    {
    new button = get_uc(uchandle, UC_Buttons)
    new Float:fCurrentTime = get_gametime()
    new ent = find_ent_by_owner(-1, "weapon_knife", id)
    if (button & IN_ATTACK)
    {
    set_uc(uchandle, UC_Buttons, button &~IN_ATTACK)
    if (fCurrentTime - g_fDeploy[id] >= weapon_deploy_time[has_weapon[id]] && fCurrentTime - g_fAtkTime[id] >= weapon_fSlashTime[has_weapon[id]])
    {
    if (fCurrentTime - g_fDeploy[id] >= weapon_deploy_time[has_weapon[id]] && fCurrentTime - g_sAtkTime[id] >= weapon_sSlashTime[has_weapon[id]])
    {
    if (weapon_fSlashType[has_weapon[id]] == 0)
    ExecuteHamB(Ham_Weapon_PrimaryAttack, ent)
    else if (weapon_fSlashType[has_weapon[id]] == 1 || weapon_fSlashType[has_weapon[id]] == 2)
    {
    if (task_exists(id + TASK_DO_MY_FIRST_ATK))
    remove_task(id + TASK_DO_MY_FIRST_ATK)
    if (task_exists(id + TASK_DO_MY_SECOND_ATK))
    remove_task(id + TASK_DO_MY_SECOND_ATK)

    if (fUserAnim[id] == 6)
    fUserAnim[id] = 7
    else if (fUserAnim[id] != 6)
    fUserAnim[id] = 6
    SendWeaponAnim(id, fUserAnim[id])
    //SendWeaponAnim(id, 6)
    emit_sound(id, CHAN_AUTO, weapon_slash[has_weapon[id]], 1.0, ATTN_NORM, 0, PITCH_NORM)
    set_task(weapon_fDmgDelay[has_weapon[id]], "DoMyFirstDamage", id + TASK_DO_MY_FIRST_ATK)
    g_fAtkTime[id] = get_gametime()
    is_attacking[id] = true
    if (task_exists(id + TASK_CAN_ATK))
    remove_task(id + TASK_CAN_ATK)
    set_task(weapon_fSlashTime[has_weapon[id]], "fw_IcanAtk", id + TASK_CAN_ATK)
    ExecuteForward(g_KnifefAtk, g_result, id)
    }
    }
    }
    }
    else if (button & IN_ATTACK2)
    {
    set_uc(uchandle, UC_Buttons, button &~IN_ATTACK2)
    if (fCurrentTime - g_fDeploy[id] >= weapon_deploy_time[has_weapon[id]] && fCurrentTime - g_sAtkTime[id] >= weapon_sSlashTime[has_weapon[id]])
    {
    if (fCurrentTime - g_fDeploy[id] >= weapon_deploy_time[has_weapon[id]] && fCurrentTime - g_fAtkTime[id] >= weapon_fSlashTime[has_weapon[id]])
    {
    if (weapon_sSlashType[has_weapon[id]] == 0)
    ExecuteHamB(Ham_Weapon_SecondaryAttack, ent)
    else if (weapon_sSlashType[has_weapon[id]] == 1 || weapon_sSlashType[has_weapon[id]] == 2)
    {
    if (task_exists(id + TASK_DO_MY_FIRST_ATK))
    remove_task(id + TASK_DO_MY_FIRST_ATK)
    if (task_exists(id + TASK_DO_MY_SECOND_ATK))
    remove_task(id + TASK_DO_MY_SECOND_ATK)
    set_task(weapon_sDmgDelay[has_weapon[id]], "DoMySecondDamage", id + TASK_DO_MY_SECOND_ATK)
    SendWeaponAnim(id, 4)
    emit_sound(id, CHAN_AUTO, weapon_stab[has_weapon[id]], 1.0, ATTN_NORM, 0, PITCH_NORM)
    g_sAtkTime[id] = get_gametime()
    is_attacking[id] = true
    if (task_exists(id + TASK_CAN_ATK))
    remove_task(id + TASK_CAN_ATK)
    set_task(weapon_sSlashTime[has_weapon[id]], "fw_IcanAtk", id + TASK_CAN_ATK)
    ExecuteForward(g_KnifesAtk, g_result, id)
    }
    }
    }
    }
    }
    }
    }
    if (has_weapon[id] < 0)
    {
    if (get_user_weapon(id) == CSW_KNIFE)
    {
    if (!g4u_get_user_zombie(id))
    {
    new button = get_uc(uchandle, UC_Buttons)
    new Float:fCurrentTime = get_gametime()
    if (button & IN_ATTACK)
    {
    new Float:fCurentTime = get_gametime()
    set_uc(uchandle, UC_Buttons, button &~IN_ATTACK)
    if (fCurentTime - g_fDeploy[id] >= def_deploy_time && fCurrentTime - g_fDelay[id] >= def_first_attack)
    {
    if (fCurrentTime - g_fDeploy[id] >= def_deploy_time && fCurrentTime - g_sDelay[id] >= def_second_attack)
    {
    g_fDelay[id] = get_gametime()
    SlashKnifeNormal(id, def_range, 125.0, 100.0 ,100.0)
    if (fUserAnim[id] == 6)
    fUserAnim[id] = 7
    else if (fUserAnim[id] != 6)
    fUserAnim[id] = 6
    is_attacking[id] = true
    SendWeaponAnim(id, fUserAnim[id])
    if (task_exists(id + TASK_CAN_ATK))
    remove_task(id + TASK_CAN_ATK)
    set_task(def_first_attack, "fw_IcanAtk", id + TASK_CAN_ATK)
    ExecuteForward(g_KnifefAtk, g_result, id)
    }

    }
    }
    else if (button & IN_ATTACK2)
    {
    set_uc(uchandle, UC_Buttons, button &~IN_ATTACK2)
    new Float:fCurentTime = get_gametime()
    if (fCurrentTime - g_fDeploy[id] >= def_deploy_time && fCurrentTime - g_sDelay[id] >= def_second_attack)
    {
    if (fCurentTime - g_fDeploy[id] >= def_deploy_time && fCurrentTime - g_fDelay[id] >= def_first_attack)
    {
    //if (task_exists(id + task_execute_my_damage))
    //remove_task(id + task_execute_my_damage)
    // new ent = find_ent_by_owner(-1, "weapon_knife", id)
    set_task(def_second_dmg_delay, "execute_my_damage", id + task_execute_my_damage)
    SendWeaponAnim(id, ANIM_STAB)
    g_fDelay[id] = get_gametime()
    is_attacking[id] = true
    if (task_exists(id + TASK_CAN_ATK))
    remove_task(id + TASK_CAN_ATK)
    set_task(def_first_attack, "fw_IcanAtk", id + TASK_CAN_ATK)
    ExecuteForward(g_KnifesAtk, g_result, id)
    }
    }
    }
    }
    }
    }
    return FMRES_IGNORED
    }

    public fw_IcanAtk(TASKID)
    {
    new id = TASKID - TASK_CAN_ATK
    if (!is_user_alive(id))
    is_attacking[id] = false
    is_attacking[id] = false
    }

    public DoMyFirstDamage(TASKID)
    {
    new id = TASKID - TASK_DO_MY_FIRST_ATK
    if (!is_user_alive(id))
    return
    if (get_user_weapon(id) != CSW_KNIFE)
    return
    if (g4u_get_user_zombie(id))
    return
    if (weapon_fSlashType[has_weapon[id]] == 1)
    {
    new Float:faimOrigin[3], RetVec[3], Float:fRetVec[3]
    new aimOrigin[3], target, body
    get_user_origin(id, aimOrigin, 1)
    get_user_aiming(id, target, body)
    get_user_origin(id, RetVec, 3)
    IVecFVec(aimOrigin, faimOrigin)
    IVecFVec(RetVec, fRetVec)
    new hitplace
    new ent = find_ent_by_owner(-1, "weapon_knife", id)
    if(target > 0 && target <= get_maxplayers())
    {
    new Float:range = vector_distance(faimOrigin, fRetVec)
    if (range <= weapon_fRange[has_weapon[id]])
    {
    if (body != 8)
    {
    if (!get_cvar_num("mp_friendlyfire"))
    if (get_user_team(id) == get_user_team(target))
    return
    new msgid = get_user_msgid("DeathMsg")
    new msgblock = get_msg_block(msgid)
    set_msg_block(msgid, BLOCK_ONCE);
    ExecuteHamB(Ham_TakeDamage, target, ent, id, damage_player[has_weapon[id]][0], DMG_SLASH)
    set_msg_block(msgid, msgblock)
    new tr_result
    engfunc(EngFunc_TraceLine, faimOrigin, fRetVec, DONT_IGNORE_MONSTERS, id, tr_result)
    //fakedamage(target, "", damage , DMG_BULLET)
    if (body == HIT_HEAD)
    hitplace = 1
    if (body != HIT_HEAD)
    hitplace = 0
    emit_sound(target, CHAN_AUTO, weapon_hitbody[has_weapon[id]], 1.0, ATTN_NORM, 0, PITCH_NORM)
    if (!is_user_alive(target))
    {
    g4u_set_knife_kill(id, hitplace)
    ExecuteForward(g_knife_kill, g_result, id, target, hitplace)
    //make_deathmsg(id, target, body, "knife")
    make_deathmsg(id, target, hitplace, weapon_hud_kill[has_weapon[id]])
    //ExecuteHamB(Ham_TraceAttack, target, id, def_second_dmg, fRetVec, tr_result, DMG_SLASH)
    }
    }
    else
    {
    new random_sound = random_num(1, 2)
    new random_file[256]
    format(random_file, 255, "weapons/ric_metal-%d.wav", random_sound)
    emit_sound(target, CHAN_AUTO, random_file, 1.0, ATTN_NORM, 0, PITCH_NORM)
    }
    }
    }
    else
    {
    if(target)
    {
    new Float:range = vector_distance(faimOrigin, fRetVec)
    if (range <= weapon_fRange[has_weapon[id]])
    {
    new classname[32]
    pev(target, pev_classname, classname, 31)
    if (equal(classname, "hostage_entity", 14) || equal(classname, "monster_scientist", 17))
    {
    emit_sound(target, CHAN_AUTO, weapon_hitbody[has_weapon[id]], 1.0, ATTN_NORM, 0, PITCH_NORM)
    ExecuteHamB(Ham_TakeDamage, target, ent, id, damage_hostage[has_weapon[id]][0], DMG_SLASH)
    }
    if (equal(classname, "func_breakable", 14 ) || equal(classname, "func_pushable", 13))
    {
    new flags = pev(target, pev_spawnflags)
    if (flags != SF_BREAK_TRIGGER_ONLY)
    ExecuteHamB(Ham_TakeDamage, target, ent, id, damage_hostage[has_weapon[id]][0], DMG_SLASH)
    //fakedamage(target, hud, random_float(damage, damage * 1.7) , DMG_SLASH)
    emit_sound(target, CHAN_AUTO, weapon_hitwall[has_weapon[id]], 1.0, ATTN_NORM, 0, PITCH_NORM)
    }
    }
    }
    else
    {
    new Float:range = vector_distance(faimOrigin, fRetVec)
    if (range <= weapon_fRange[has_weapon[id]])
    emit_sound(id, CHAN_AUTO, weapon_hitwall[has_weapon[id]], 1.0, ATTN_NORM, 0, PITCH_NORM)
    }
    }
    }
    if (weapon_fSlashType[has_weapon[id]] == 2)
    SlashKnife(id, weapon_fRange[has_weapon[id]], damage_player[has_weapon[id]][0], damage_hostage[has_weapon[id]][0], damage_entity[has_weapon[id]][0])

    }

    public DoMySecondDamage(TASKID)
    {
    new id = TASKID - TASK_DO_MY_SECOND_ATK
    if (!is_user_alive(id))
    return
    if (get_user_weapon(id) != CSW_KNIFE)
    return
    if (g4u_get_user_zombie(id))
    return
    if (weapon_sSlashType[has_weapon[id]] == 1)
    {
    new Float:faimOrigin[3], RetVec[3], Float:fRetVec[3]
    new aimOrigin[3], target, body
    get_user_origin(id, aimOrigin, 1)
    get_user_aiming(id, target, body)
    get_user_origin(id, RetVec, 3)
    IVecFVec(aimOrigin, faimOrigin)
    IVecFVec(RetVec, fRetVec)
    new hitplace
    new ent = find_ent_by_owner(-1, "weapon_knife", id)
    if(target > 0 && target <= get_maxplayers())
    {
    new Float:range = vector_distance(faimOrigin, fRetVec)
    if (range <= weapon_sRange[has_weapon[id]])
    {
    if (body != 8)
    {
    if (!get_cvar_num("mp_friendlyfire"))
    if (get_user_team(id) == get_user_team(target))
    return
    new msgid = get_user_msgid("DeathMsg")
    new msgblock = get_msg_block(msgid)
    set_msg_block(msgid, BLOCK_ONCE);
    ExecuteHamB(Ham_TakeDamage, target, ent, id, damage_player[has_weapon[id]][1], DMG_SLASH)
    set_msg_block(msgid, msgblock)
    new tr_result
    engfunc(EngFunc_TraceLine, faimOrigin, fRetVec, DONT_IGNORE_MONSTERS, id, tr_result)
    //fakedamage(target, "", damage , DMG_BULLET)
    if (body == HIT_HEAD)
    hitplace = 1
    if (body != HIT_HEAD)
    hitplace = 0
    emit_sound(target, CHAN_AUTO, weapon_hitbody[has_weapon[id]], 1.0, ATTN_NORM, 0, PITCH_NORM)
    if (!is_user_alive(target))
    {
    g4u_set_knife_kill(id, hitplace)
    ExecuteForward(g_knife_kill, g_result, id, target, hitplace)
    //make_deathmsg(id, target, body, "knife")
    make_deathmsg(id, target, hitplace, weapon_hud_kill[has_weapon[id]])
    //ExecuteHamB(Ham_TraceAttack, target, id, def_second_dmg, fRetVec, tr_result, DMG_SLASH)
    }
    }
    else
    {
    new random_sound = random_num(1, 2)
    new random_file[256]
    format(random_file, 255, "weapons/ric_metal-%d.wav", random_sound)
    emit_sound(target, CHAN_AUTO, random_file, 1.0, ATTN_NORM, 0, PITCH_NORM)
    }
    }
    }
    else
    {
    if(target)
    {
    new Float:range = vector_distance(faimOrigin, fRetVec)
    if (range <= weapon_sRange[has_weapon[id]])
    {
    new classname[32]
    pev(target, pev_classname, classname, 31)
    if (equal(classname, "hostage_entity", 14) || equal(classname, "monster_scientist", 17))
    {
    emit_sound(target, CHAN_AUTO, weapon_hitbody[has_weapon[id]], 1.0, ATTN_NORM, 0, PITCH_NORM)
    ExecuteHamB(Ham_TakeDamage, target, ent, id, damage_hostage[has_weapon[id]][1], DMG_SLASH)
    }
    if (equal(classname, "func_breakable", 14 ) || equal(classname, "func_pushable", 13))
    {
    new flags = pev(target, pev_spawnflags)
    if (flags != SF_BREAK_TRIGGER_ONLY)
    ExecuteHamB(Ham_TakeDamage, target, ent, id, damage_hostage[has_weapon[id]][0], DMG_SLASH)
    //fakedamage(target, hud, random_float(damage, damage * 1.7) , DMG_SLASH)
    emit_sound(target, CHAN_AUTO, weapon_hitwall[has_weapon[id]], 1.0, ATTN_NORM, 0, PITCH_NORM)
    }
    }
    }
    else
    {
    new Float:range = vector_distance(faimOrigin, fRetVec)
    if (range <= weapon_sRange[has_weapon[id]])
    emit_sound(id, CHAN_AUTO, weapon_hitwall[has_weapon[id]], 1.0, ATTN_NORM, 0, PITCH_NORM)
    }
    }
    }
    if (weapon_sSlashType[has_weapon[id]] == 2)
    SlashKnife(id, weapon_sRange[has_weapon[id]], damage_player[has_weapon[id]][1], damage_hostage[has_weapon[id]][1], damage_entity[has_weapon[id]][1])
    }
    public fm_update_data(id, sendweapon, cd_handle)
    {
    if (!is_user_alive(id))
    return FMRES_IGNORED
    if (get_user_weapon(id) != CSW_KNIFE)
    return FMRES_IGNORED
    if (g4u_get_user_zombie(id))
    return FMRES_IGNORED
    if (has_weapon[id] < 0)
    {
    new Float:next_attack = get_pdata_float(id, m_flNextAttack, 5)
    if (next_attack <= 0.0)
    {
    set_cd(cd_handle, CD_flNextAttack, get_gametime() + 0.001)
    // return FMRES_HANDLED
    }
    if (is_attacking[id])
    {
    new Sequence = pev(id, pev_sequence)
    if (Sequence == 73)
    set_pev(id, pev_sequence, 74)
    if (Sequence == 75)
    set_pev(id, pev_sequence, 76)
    }
    //return FMRES_HANDLED

    }
    if (has_weapon[id] > -1)
    {
    new Float:next_attack = get_pdata_float(id, m_flNextAttack, 5)
    if (next_attack <= 0.0)
    {
    set_cd(cd_handle, CD_flNextAttack, get_gametime() + 0.001)
    // return FMRES_HANDLED
    }
    if (is_attacking[id])
    {
    new Sequence = pev(id, pev_sequence)
    if (Sequence == 73)
    set_pev(id, pev_sequence, 74)
    if (Sequence == 75)
    set_pev(id, pev_sequence, 76)
    }
    }
    return FMRES_IGNORED
    }

    public execute_my_damage(taskid)
    {
    new id = taskid - task_execute_my_damage
    if (!is_user_alive(id))
    return
    if (g4u_get_user_zombie(id))
    return
    if (get_user_weapon(id) != CSW_KNIFE)
    return
    // Find target
    new Float:faimOrigin[3], RetVec[3], Float:fRetVec[3]
    new aimOrigin[3], target, body
    get_user_origin(id, aimOrigin, 1)
    get_user_aiming(id, target, body)
    get_user_origin(id, RetVec, 3)
    IVecFVec(aimOrigin, faimOrigin)
    IVecFVec(RetVec, fRetVec)
    new hitplace
    new ent = find_ent_by_owner(-1, "weapon_knife", id)
    if(target > 0 && target <= get_maxplayers())
    {
    new Float:range = vector_distance(faimOrigin, fRetVec)
    if (range <= def_range)
    {
    if (body != 8)
    {
    if (!get_cvar_num("mp_friendlyfire"))
    if (get_user_team(id) == get_user_team(target))
    return
    new msgid = get_user_msgid("DeathMsg")
    new msgblock = get_msg_block(msgid)
    set_msg_block(msgid, BLOCK_ONCE);
    ExecuteHamB(Ham_TakeDamage, target, ent, id, def_second_dmg, DMG_SLASH)
    set_msg_block(msgid, msgblock)
    new tr_result
    engfunc(EngFunc_TraceLine, faimOrigin, fRetVec, DONT_IGNORE_MONSTERS, id, tr_result)
    //fakedamage(target, "", damage , DMG_BULLET)
    if (body == HIT_HEAD)
    hitplace = 1
    if (body != HIT_HEAD)
    hitplace = 0
    new random_sound = random_num(1, 4)
    new random_file[256]
    format(random_file, 255, "weapons/knife_hit%d.wav", random_sound)
    emit_sound(target, CHAN_AUTO, random_file, 1.0, ATTN_NORM, 0, PITCH_NORM)
    if (!is_user_alive(target))
    {
    g4u_set_knife_kill(id, hitplace)
    ExecuteForward(g_knife_kill, g_result, id, target, hitplace)
    make_deathmsg(id, target, hitplace, "knife")
    //ExecuteHamB(Ham_TraceAttack, target, id, def_second_dmg, fRetVec, tr_result, DMG_SLASH)
    }
    }
    else
    {
    new random_sound = random_num(1, 2)
    new random_file[256]
    format(random_file, 255, "weapons/ric_metal-%d.wav", random_sound)
    emit_sound(target, CHAN_AUTO, random_file, 1.0, ATTN_NORM, 0, PITCH_NORM)
    }
    }
    }
    else
    {
    if(target)
    {
    new Float:range = vector_distance(faimOrigin, fRetVec)
    if (range <= def_range)
    {
    new classname[32]
    pev(target, pev_classname, classname, 31)
    if (equal(classname, "hostage_entity", 14) || equal(classname, "monster_scientist", 17))
    {
    new random_sound = random_num(1, 4)
    new random_file[256]
    format(random_file, 255, "weapons/knife_hit%d.wav", random_sound)
    ExecuteHamB(Ham_TakeDamage, target, ent, id, def_second_dmg, DMG_SLASH)
    emit_sound(target, CHAN_AUTO, random_file, 1.0, ATTN_NORM, 0, PITCH_NORM)
    }
    if (equal(classname, "func_breakable", 14 ) || equal(classname, "func_pushable", 13))
    {
    new flags = pev(target, pev_spawnflags)
    if (flags != SF_BREAK_TRIGGER_ONLY)
    ExecuteHamB(Ham_TakeDamage, target, ent, id, random_float(80.0, 100.0), DMG_SLASH)
    //fakedamage(target, hud, random_float(damage, damage * 1.7) , DMG_SLASH)
    emit_sound(id, CHAN_AUTO, "weapons/knife_hitwall1.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
    }
    }
    }
    else
    {
    new Float:range = vector_distance(faimOrigin, fRetVec)
    if (range <= def_range)
    emit_sound(id, CHAN_AUTO, "weapons/knife_hitwall1.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
    }
    }
    }

    public pl_prethink(id)
    {
    if (get_user_weapon(id) != CSW_KNIFE || !is_user_alive(id))
    {
    if (task_exists(id + TASK_DO_MY_FIRST_ATK))
    remove_task(id + TASK_DO_MY_FIRST_ATK)
    if (task_exists(id + TASK_DO_MY_SECOND_ATK))
    remove_task(id + TASK_DO_MY_SECOND_ATK)
    }
    //if (get_user_weapon(id) == CSW_KNIFE)
    // if (is_user_alive(id))
    // if (g_KnifeDeployed[id])
    // hide_cross(id)

    }

    public pl_spawn(id)
    {
    if (has_weapon[id] > -1)
    if (!user_has_weapon(id, CSW_KNIFE))
    has_weapon[id] = -1
    is_attacking[id] = false
    }

    public fw_strip(ient, id)
    {
    has_weapon[id] = -1
    return PLUGIN_CONTINUE
    }

    public fw_KnifeDeploy(ent)
    {
    new id = pev(ent, pev_owner)
    if (!is_connected[id])
    return
    if (!is_user_alive(id))
    return
    g_fDeploy[id] = get_gametime()
    g_fDelay[id] = - 1000000.0
    g_sDelay[id] = - 10000000.0
    g_fAtkTime[id] = -1000000.0
    g_sAtkTime[id] = - 1000000.0
    fUserAnim[id] = 6
    if (has_weapon[id] > -1)
    emit_sound(id, CHAN_AUTO, weapon_deploy[has_weapon[id]], 1.0, ATTN_NORM, 0, PITCH_NORM)
    }

    public pl_take_damage(victim, inflictor, attacker, Float:damage, damagebit)
    {
    new classname[32]
    pev(attacker, pev_classname, classname, 31)
    if (equal(classname, "trigger_hurt", 12))
    return
    if (is_connected[attacker] && has_weapon[attacker] > -1 && is_connected[victim] && get_user_weapon(attacker) == CSW_KNIFE)
    if (weapon_fSlashType[has_weapon[attacker]] == 0 || weapon_sSlashType[has_weapon[attacker]] == 0)
    SetHamParamFloat(4, damage * damage_player[has_weapon[attacker]][0])
    }


    public hs_take_damage(victim, inflictor, attacker, Float:damage, damagebit)
    {
    new classname[32]
    pev(attacker, pev_classname, classname, 31)
    if (equal(classname, "trigger_hurt", 12))
    return
    if (is_connected[attacker] && has_weapon[attacker] > -1 && get_user_weapon(attacker) == CSW_KNIFE)
    if (weapon_fSlashType[has_weapon[attacker]] == 0 || weapon_sSlashType[has_weapon[attacker]] == 0)
    SetHamParamFloat(4, damage * damage_hostage[has_weapon[attacker]][0])
    }

    public ent_take_damage(victim, inflictor, attacker, Float:damage, damagebit)
    {
    new classname[32]
    pev(attacker, pev_classname, classname, 31)
    if (equal(classname, "trigger_hurt", 12))
    return
    if (is_connected[attacker] && has_weapon[attacker] > -1 && get_user_weapon(attacker) == CSW_KNIFE)
    if (weapon_fSlashType[has_weapon[attacker]] == 0 || weapon_sSlashType[has_weapon[attacker]] == 0)
    SetHamParamFloat(4, damage * damage_entity[has_weapon[attacker]][0])
    }

    public fw_BotUpdate(id)
    {
    if (!is_user_alive(id))
    return
    if (get_user_weapon(id) != CSW_KNIFE)
    return
    if (g4u_get_user_zombie(id))
    return
    if (has_weapon[id] < 0)
    {
    new Float:next_attack = get_pdata_float(id, m_flNextAttack, 5)
    if (next_attack <= 0.0)
    set_pdata_float(id, m_flNextAttack, 0.0001)
    if (is_attacking[id])
    {
    new Sequence = pev(id, pev_sequence)
    if (Sequence == 73)
    set_pev(id, pev_sequence, 74)
    if (Sequence == 75)
    set_pev(id, pev_sequence, 76)
    }
    //return FMRES_HANDLED

    }
    if (has_weapon[id] > -1)
    {
    new Float:next_attack = get_pdata_float(id, m_flNextAttack, 5)
    if (next_attack <= 0.0)
    {
    set_pdata_float(id, m_flNextAttack, 0.0001)
    // return FMRES_HANDLED
    }
    if (is_attacking[id])
    {
    new Sequence = pev(id, pev_sequence)
    if (Sequence == 73)
    set_pev(id, pev_sequence, 74)
    if (Sequence == 75)
    set_pev(id, pev_sequence, 76)
    }
    }
    }

    stock buy_weapon(id, weaponid)
    {
    if (!is_user_alive(id))
    return PLUGIN_HANDLED
    if (g4u_get_user_zombie(id))
    {
    client_print(id, print_center, "[G4U MSG] Vu khi nay khong danh cho Zombie hoac Ghost")
    return PLUGIN_HANDLED
    }
    if (weaponid > g_weapon_count)
    return PLUGIN_HANDLED
    if (!g4u_get_zombie_toggle() && !get_cvar_num("g4u_option/death_match/active") && !get_cvar_num("sgm_option/active"))
    {
    if (!(cs_get_user_mapzones(id) & CS_MAPZONE_BUY))
    {
    client_print(id, print_chat, "[G4U MSG] Ban chi trang bi duoc %s khi o Cua Hang", weapon_name[weaponid])
    return PLUGIN_HANDLED
    }
    }
    if (g4u_get_level(id) < weapon_level[weaponid])
    {
    //new need_to_level[256]
    //g4u_get_level_name(weapon_level[weaponid], need_to_level, 255)
    client_print(id, print_center, "[G4U MSG] Ban khong du level de trang bi %s", weapon_name[weaponid])
    return PLUGIN_HANDLED

    }
    new money = cs_get_user_money(id)
    new ent = find_ent_by_owner(-1, "weapon_knife", id)
    if (weapon_cost_type[weaponid] == 1)
    {
    if (money >= weapon_cost[weaponid])
    {
    if (!user_has_weapon(id, CSW_KNIFE))
    fm_give_item(id, "weapon_knife")
    has_weapon[id] = weaponid
    engclient_cmd(id, "weapon_knife")
    ExecuteHamB(Ham_Item_Deploy, ent)
    reset_knife(id)
    engclient_cmd(id, "lastinv")
    cs_set_user_money(id, money - weapon_cost[weaponid], 1)
    client_print(id, print_chat, "[G4U MSG] Ban da trang bi %s", weapon_name[weaponid])
    ExecuteForward(g_knife, g_result, id, weaponid)
    return PLUGIN_HANDLED
    }
    }
    if (weapon_cost_type[weaponid] == 2)
    {
    new coin = g4u_get_user_coin(id)
    if (coin >= weapon_cost[weaponid])
    {
    if (!user_has_weapon(id, CSW_KNIFE))
    fm_give_item(id, "weapon_knife")
    has_weapon[id] = weaponid
    engclient_cmd(id, "weapon_knife")
    ExecuteHamB(Ham_Item_Deploy, ent)
    reset_knife(id)
    engclient_cmd(id, "lastinv")
    g4u_set_user_coin(id, g4u_get_user_coin(id) - weapon_cost[weaponid])
    client_print(id, print_chat, "[G4U MSG] Ban da trang bi %s", weapon_name[weaponid])
    ExecuteForward(g_knife, g_result, id, weaponid)
    return PLUGIN_HANDLED
    }
    }
    return PLUGIN_HANDLED
    }

    stock fm_give_item(index, const item[]) {
    if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5) && !equal(item, "item_", 5) && !equal(item, "tf_weapon_", 10))
    return 0;

    new ent = fm_create_entity(item)
    if (!pev_valid(ent))
    return 0;

    new Float:origin[3];
    pev(index, pev_origin, origin);
    set_pev(ent, pev_origin, origin);
    set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN);
    dllfunc(DLLFunc_Spawn, ent);

    new save = pev(ent, pev_solid);
    dllfunc(DLLFunc_Touch, ent, index);
    if (pev(ent, pev_solid) != save)
    return ent;

    engfunc(EngFunc_RemoveEntity, ent);

    return -1;
    }

    stock fm_create_entity(const classname[])
    return engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, classname))

    stock fm_find_ent_by_owner(index, const classname[], owner, jghgtype = 0) {
    new strtype[11] = "classname", ent = index;
    switch (jghgtype) {
    case 1: strtype = "target";
    case 2: strtype = "targetname";
    }

    while ((ent = engfunc(EngFunc_FindEntityByString, ent, strtype, classname)) && pev(ent, pev_owner) != owner) {}

    return ent;
    }

    stock fm_remove_entity_name(const classname[]) {
    new ent = -1, num = 0;
    while ((ent = fm_find_ent_by_class(ent, classname)))
    num += fm_remove_entity(ent);

    return num;
    }

    stock str_count(const str[], searchchar)
    {
    new count, i
    //count = 0

    for (i = 0; i <= strlen(str); i++)
    {
    if(str == searchchar)
    count++
    }

    return count;
    }

    stock fm_find_ent_by_class(index, const classname[])
    return engfunc(EngFunc_FindEntityByString, index, "classname", classname)

    stock fm_remove_entity(index)
    return engfunc(EngFunc_RemoveEntity, index)

    stock fm_set_user_origin(index, origin[3]) {
    new Float:orig[3];
    IVecFVec(origin, orig);
    return fm_entity_set_origin(index, orig)
    }

    stock fm_entity_set_origin(index, const Float:origin[3]) {
    new Float:mins[3], Float:maxs[3];
    pev(index, pev_mins, mins);
    pev(index, pev_maxs, maxs);
    engfunc(EngFunc_SetSize, index, mins, maxs);
    return engfunc(EngFunc_SetOrigin, index, origin);
    }

    stock SendWeaponAnim(id, iAnim)
    {
    set_pev(id, pev_weaponanim, iAnim)
    message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, _, id)
    write_byte(iAnim)
    write_byte(g4u_character_hand(id))
    message_end()
    /*new ent = find_ent_by_owner(-1, "weapon_knife", id)
    if (!ent)
    return
    ExecuteHamB(Ham_Weapon_SendWeaponAnim, ent, iAnim, 0, g4u_character_hand(id))*/
    }

    stock show_weapon_now(id, page)
    {
    new start = page * 7
    new end = (page * 7) + 7
    static menu[8192], len
    len = 0
    new count = 1
    if (end > g_weapon_count)
    end = g_weapon_count
    len += formatex(menu[len], sizeof menu - 1 - len, "\y[G4U SHOP - MELEE WEAPON]^n")
    for (new i = start; i < end; i++)
    {
    //new level_name[256]
    //g4u_get_level_name(weapon_level, level_name, 255)
    if (weapon_cost_type == 1)
    len += formatex(menu[len], sizeof menu - 1 - len, "^n\w%d. \r%s \w[MONEY] %d \w[LEVEL]: %d", count, weapon_name, weapon_cost, weapon_level)
    if (weapon_cost_type == 2)
    len += formatex(menu[len], sizeof menu - 1 - len, "^n\w%d. \r%s \y[COIN]: %d \w[LEVEL]: %d", count, weapon_name, weapon_cost, weapon_level)
    count++
    }
    len += formatex(menu[len], sizeof menu - 1 - len, "^n^n\y8.Back^n\w9.Next^n\r0.Exit")
    show_menu(id, knives, menu, -1, "[MELEE LIST]")
    }

    stock fm_set_rendering(entity, fx = kRenderFxNone, r = 255, g = 255, b = 255, render = kRenderNormal, amount = 16) {
    new Float:RenderColor[3];
    RenderColor[0] = float(r);
    RenderColor[1] = float(g);
    RenderColor[2] = float(b);

    set_pev(entity, pev_renderfx, fx);
    set_pev(entity, pev_rendercolor, RenderColor);
    set_pev(entity, pev_rendermode, render);
    set_pev(entity, pev_renderamt, float(amount));

    return 1;
    }

    stock ham_strip_weapon(id,weapon[])
    {
    if(!equal(weapon,"weapon_",7)) return 0;

    new wId = get_weaponid(weapon);
    if(!wId) return 0;

    new wEnt;
    while((wEnt = engfunc(EngFunc_FindEntityByString, wEnt, "classname", weapon)) && pev(wEnt, pev_owner) != id) {}
    if(!wEnt) return 0;

    new iTmp;
    if(get_user_weapon(id, iTmp, iTmp) == wId) ExecuteHamB(Ham_Weapon_RetireWeapon, wEnt);

    if(!ExecuteHamB(Ham_RemovePlayerItem, id, any:wEnt)) return 0;

    ExecuteHamB(Ham_Item_Kill, wEnt);
    set_pev(id, pev_weapons, pev(id, pev_weapons) & ~(1<<wId));

    return 1;
    }

    stock reset_knife(id)
    {
    message_begin(MSG_ONE, get_user_msgid("CurWeapon"), _, id)
    write_byte(1)
    write_byte(CSW_KNIFE)
    write_byte(1)
    message_end()
    emessage_begin(MSG_ONE, get_user_msgid("CurWeapon"), _, id)
    ewrite_byte(1)
    ewrite_byte(CSW_KNIFE)
    ewrite_byte(1)
    emessage_end()
    }

    stock SlashKnife(id, Float:Range, Float:Damage, Float:DamageHostage, Float:DamageEntity)
    {
    if (!is_user_alive(id))
    return
    if (get_user_weapon(id) != CSW_KNIFE)
    return
    if (!user_has_weapon(id, CSW_KNIFE))
    return
    if (has_weapon[id] < 0)
    return
    new iOrigin[3], tr
    get_user_origin(id, iOrigin, 3)
    new Float:fAimOrigin[3], Float:fOrigin[3]
    IVecFVec(iOrigin, fAimOrigin)
    new iAim[3]
    get_user_origin(id, iAim, 1)
    //pev(id, pev_origin, fOrigin)
    IVecFVec(iAim, fOrigin)
    new players[32], number
    get_players(players, number, "a")
    new ent = find_ent_by_owner(-1, "weapon_knife", id)
    new target, body
    get_user_aiming(id, target, body)
    new hitplace
    new g_IgnoreEnt = -1000000000
    if(target > 0 && target <= get_maxplayers())
    {
    new Float:RealDistance = vector_distance(fOrigin, fAimOrigin)
    if (RealDistance <= Range)
    {
    g_IgnoreEnt = target
    if (body != 8)
    {
    if (!get_cvar_num("mp_friendlyfire"))
    if (get_user_team(id) == get_user_team(target))
    return
    new msgid = get_user_msgid("DeathMsg")
    new msgblock = get_msg_block(msgid)
    set_msg_block(msgid, BLOCK_ONCE);
    new Float:fTmpDmg = Damage - (Damage / Range) * RealDistance;
    new tr_result
    engfunc(EngFunc_TraceLine, fOrigin, fAimOrigin, DONT_IGNORE_MONSTERS, id, tr_result)
    ExecuteHamB(Ham_TakeDamage, target, ent, id, fTmpDmg, DMG_SLASH)
    set_msg_block(msgid, msgblock)
    //fakedamage(target, "", damage , DMG_BULLET)
    if (body == HIT_HEAD)
    hitplace = 1
    if (body != HIT_HEAD)
    hitplace = 0
    emit_sound(target, CHAN_AUTO, weapon_hitbody[has_weapon[id]], 1.0, ATTN_NORM, 0, PITCH_NORM)
    if (!is_user_alive(target))
    {
    g4u_set_knife_kill(id, hitplace)
    ExecuteForward(g_knife_kill, g_result, id, target, hitplace)
    //make_deathmsg(id, target, body, "knife")
    make_deathmsg(id, target, hitplace, weapon_hud_kill[has_weapon[id]])
    //ExecuteHamB(Ham_TraceAttack, target, id, def_second_dmg, fRetVec, tr_result, DMG_SLASH)
    }
    }
    else
    {
    new random_sound = random_num(1, 2)
    new random_file[256]
    format(random_file, 255, "weapons/ric_metal-%d.wav", random_sound)
    emit_sound(target, CHAN_AUTO, random_file, 1.0, ATTN_NORM, 0, PITCH_NORM)
    }
    }
    }
    else
    {
    if(target)
    {
    g_IgnoreEnt = target
    new Float:RealDistance = vector_distance(fOrigin, fAimOrigin)
    if (RealDistance <= Range)
    {
    new classname[32]
    pev(target, pev_classname, classname, 31)
    if (equal(classname, "hostage_entity", 14) || equal(classname, "monster_scientist", 17))
    {
    if (pev(target, pev_iuser1) < 1)
    {
    emit_sound(target, CHAN_AUTO, weapon_hitbody[has_weapon[id]], 1.0, ATTN_NORM, 0, PITCH_NORM)
    new Float:fTmpDmg = DamageHostage - (DamageHostage / Range) * RealDistance;
    ExecuteHamB(Ham_TakeDamage, target, ent , id, fTmpDmg , DMG_SLASH)
    }
    }
    if (equal(classname, "func_breakable", 14 ) || equal(classname, "func_pushable", 13))
    {
    new flags = pev(target, pev_spawnflags)
    if (flags != SF_BREAK_TRIGGER_ONLY)
    {
    new Float:fTmpDmg = DamageEntity - (DamageEntity / Range) * RealDistance;
    ExecuteHamB(Ham_TakeDamage, target, ent, id, fTmpDmg, DMG_SLASH)
    }
    emit_sound(target, CHAN_AUTO, weapon_hitwall[has_weapon[id]], 1.0, ATTN_NORM, 0, PITCH_NORM)
    }
    }
    }
    else
    {
    new Float:RealDistance = vector_distance(fOrigin, fAimOrigin)
    if (RealDistance <= Range)
    emit_sound(id, CHAN_AUTO, weapon_hitwall[has_weapon[id]], 1.0, ATTN_NORM, 0, PITCH_NORM)
    }
    }
    for (new i = 0; i < number; i++)
    {
    new iPlayer = players
    new Float:pOrigin[3]
    pev(iPlayer, pev_origin, pOrigin)
    if (!is_in_viewcone(id, pOrigin))
    continue
    // Find X position
    new Float:A1 = (fOrigin[1] - pOrigin[1]) * fOrigin[0] + (pOrigin[0] - fOrigin[0]) * fOrigin[1] - (pOrigin[0] - fOrigin[0]) * fAimOrigin[1]
    new Float:A2 = fOrigin[1] - pOrigin[1]
    new Float:XPOS = A1 / A2
    pOrigin[0] = XPOS
    pOrigin[1] = fAimOrigin[1]
    pOrigin[2] = fAimOrigin[2]
    engfunc(EngFunc_TraceLine, fOrigin, pOrigin, DONT_IGNORE_MONSTERS, id, tr)
    new hitent = get_tr2(tr, TR_pHit)
    if (hitent == iPlayer)
    {
    new Float:vEnd[3]
    get_tr2(tr, TR_vecEndPos, vEnd)
    new Float:RealDistance = vector_distance(fOrigin, vEnd)
    if (RealDistance <= Range)
    {
    if (iPlayer == g_IgnoreEnt)
    continue
    new iHitGroup = get_tr2(tr, TR_iHitgroup)
    if (iHitGroup == 8) // Hit shield?
    {
    new random_sound = random_num(1, 2)
    new random_file[256]
    format(random_file, 255, "weapons/ric_metal-%d.wav", random_sound)
    emit_sound(iPlayer, CHAN_AUTO, random_file, 1.0, ATTN_NORM, 0, PITCH_NORM)
    continue
    }
    emit_sound(iPlayer, CHAN_AUTO, weapon_hitbody[has_weapon[id]], 1.0, ATTN_NORM, 0, PITCH_NORM)
    new msgid = get_user_msgid("DeathMsg")
    new msgblock = get_msg_block(msgid)
    set_msg_block(msgid, BLOCK_ONCE);
    new Float:fTmpDmg = Damage - (Damage / Range) * RealDistance;
    if (!is_connected[iPlayer])
    continue
    ExecuteHamB(Ham_TakeDamage, iPlayer, ent , id, fTmpDmg , DMG_SLASH)
    set_msg_block(msgid, msgblock)
    //ExecuteHamB(Ham_TraceAttack, iPlayer, id, fTmpDmg, vEnd, tr, DMG_SLASH)
    if (!is_user_alive(iPlayer))
    {
    if (iHitGroup == HIT_HEAD)
    {
    make_deathmsg(id, iPlayer, 1, weapon_hud_kill[has_weapon[id]])
    ExecuteForward(g_knife_kill, g_result, id, iPlayer, 1)
    }
    else
    {
    make_deathmsg(id, iPlayer, 0, weapon_hud_kill[has_weapon[id]])
    ExecuteForward(g_knife_kill, g_result, id, iPlayer, 0)
    }
    }
    }
    }
    }
    for (new iEnt = 0; iEnt < entity_count(); iEnt++)
    {
    if (!iEnt || !pev_valid(iEnt))
    continue
    new Float:pOrigin[3]
    pev(iEnt, pev_origin, pOrigin)
    if (!is_in_viewcone(id, pOrigin))
    continue
    if (pev(iEnt, pev_takedamage) == DAMAGE_NO)
    continue
    new Float:A1 = (fOrigin[1] - pOrigin[1]) * fOrigin[0] + (pOrigin[0] - fOrigin[0]) * fOrigin[1] - (pOrigin[0] - fOrigin[0]) * fAimOrigin[1]
    new Float:A2 = fOrigin[1] - pOrigin[1]
    new Float:XPOS = A1 / A2
    pOrigin[0] = XPOS
    pOrigin[1] = fAimOrigin[1]
    pOrigin[2] = fAimOrigin[2]
    engfunc(EngFunc_TraceLine, fOrigin, pOrigin, DONT_IGNORE_MONSTERS, id, tr)
    new hitent = get_tr2(tr, TR_pHit)
    if (hitent == iEnt)
    {
    new Float:vEnd[3]
    get_tr2(tr, TR_vecEndPos, vEnd)
    new Float:RealDistance = vector_distance(fOrigin, vEnd)
    if (RealDistance <= Range)
    {
    new classname[32]
    pev(iEnt, pev_classname, classname, 31)
    new Float:fTmpDmg
    if (g_IgnoreEnt == iEnt)
    continue
    if (equal(classname, "player"))
    continue
    else if (equal(classname, "hostage_entity") || equal(classname, "monster_scientist"))
    {
    if (pev(iEnt, pev_iuser1) > 0)
    continue
    emit_sound(iEnt, CHAN_AUTO, weapon_hitbody[has_weapon[id]], 1.0, ATTN_NORM, 0, PITCH_NORM)
    fTmpDmg = DamageHostage - (DamageHostage / Range) * RealDistance;
    ExecuteHamB(Ham_TakeDamage, iEnt, ent , id, fTmpDmg , DMG_SLASH)
    }
    else if (equal(classname, "func_breakable") || equal(classname, "func_pushable"))
    {
    emit_sound(iEnt, CHAN_AUTO, weapon_hitwall[has_weapon[id]], 1.0, ATTN_NORM, 0, PITCH_NORM)
    fTmpDmg = DamageEntity - (DamageEntity / Range) * RealDistance;
    ExecuteHamB(Ham_TakeDamage, iEnt, ent , id, fTmpDmg , DMG_SLASH)
    }
    else
    {
    emit_sound(iEnt, CHAN_AUTO, weapon_hitwall[has_weapon[id]], 1.0, ATTN_NORM, 0, PITCH_NORM)
    fTmpDmg = DamageEntity - (DamageEntity / Range) * RealDistance;
    ExecuteHamB(Ham_TakeDamage, iEnt, ent , id, fTmpDmg , DMG_SLASH)
    }
    }
    }
    }
    }

    stock SlashKnifeNormal(id, Float:Range, Float:Damage, Float:DamageHostage, Float:DamageEntity)
    {
    if (!is_user_alive(id))
    return
    if (get_user_weapon(id) != CSW_KNIFE)
    return
    if (!user_has_weapon(id, CSW_KNIFE))
    return
    new iOrigin[3], tr
    get_user_origin(id, iOrigin, 3)
    new Float:fAimOrigin[3], Float:fOrigin[3]
    IVecFVec(iOrigin, fAimOrigin)
    //pev(id, pev_origin, fOrigin)
    new iEyeOrigin[3]
    get_user_origin(id, iEyeOrigin, 1)
    IVecFVec(iEyeOrigin, fOrigin)
    new players[32], number
    get_players(players, number, "a")
    new ent = find_ent_by_owner(-1, "weapon_knife", id)
    new target, body
    get_user_aiming(id, target, body)
    new hitplace
    new g_IgnoreEnt = -1000000000
    if(target > 0 && target <= get_maxplayers())
    {
    new Float:RealDistance = vector_distance(fOrigin, fAimOrigin)
    if (RealDistance <= Range)
    {
    g_IgnoreEnt = target
    if (body != 8)
    {
    if (!get_cvar_num("mp_friendlyfire"))
    if (get_user_team(id) == get_user_team(target))
    return
    new msgid = get_user_msgid("DeathMsg")
    new msgblock = get_msg_block(msgid)
    set_msg_block(msgid, BLOCK_ONCE);
    new Float:fTmpDmg = Damage - (Damage / Range) * RealDistance;
    new tr_result
    engfunc(EngFunc_TraceLine, fOrigin, fAimOrigin, DONT_IGNORE_MONSTERS, id, tr_result)
    ExecuteHamB(Ham_TakeDamage, target, ent, id, fTmpDmg, DMG_SLASH)
    set_msg_block(msgid, msgblock)
    //fakedamage(target, "", damage , DMG_BULLET)
    if (body == HIT_HEAD)
    hitplace = 1
    if (body != HIT_HEAD)
    hitplace = 0
    new random_sound = random_num(1, 4)
    new random_file[256]
    format(random_file, 255, "weapons/knife_hit%d.wav", random_sound)
    if (!is_user_alive(target))
    {
    g4u_set_knife_kill(id, hitplace)
    ExecuteForward(g_knife_kill, g_result, id, target, hitplace)
    //make_deathmsg(id, target, body, "knife")
    make_deathmsg(id, target, hitplace, "knife")
    //ExecuteHamB(Ham_TraceAttack, target, id, def_second_dmg, fRetVec, tr_result, DMG_SLASH)
    }
    }
    else
    {
    new random_sound = random_num(1, 2)
    new random_file[256]
    format(random_file, 255, "weapons/ric_metal-%d.wav", random_sound)
    emit_sound(target, CHAN_AUTO, random_file, 1.0, ATTN_NORM, 0, PITCH_NORM)
    }
    }
    }
    else
    {
    if(target)
    {
    g_IgnoreEnt = target
    new Float:RealDistance = vector_distance(fOrigin, fAimOrigin)
    if (RealDistance <= Range)
    {
    new classname[32]
    pev(target, pev_classname, classname, 31)
    if (equal(classname, "hostage_entity", 14) || equal(classname, "monster_scientist", 17))
    {
    if (pev(target, pev_iuser1) < 1)
    {
    new random_sound = random_num(1, 4)
    new random_file[256]
    format(random_file, 255, "weapons/knife_hit%d.wav", random_sound)
    new Float:fTmpDmg = DamageHostage - (DamageHostage / Range) * RealDistance;
    ExecuteHamB(Ham_TakeDamage, target, ent , id, fTmpDmg , DMG_SLASH)
    }
    }
    if (equal(classname, "func_breakable", 14 ) || equal(classname, "func_pushable", 13))
    {
    new flags = pev(target, pev_spawnflags)
    if (flags != SF_BREAK_TRIGGER_ONLY)
    {
    new Float:fTmpDmg = DamageEntity - (DamageEntity / Range) * RealDistance;
    ExecuteHamB(Ham_TakeDamage, target, ent, id, fTmpDmg, DMG_SLASH)
    }
    emit_sound(target, CHAN_AUTO, "weapons/knife_hitwall1.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
    }
    }
    }
    else
    {
    new Float:RealDistance = vector_distance(fOrigin, fAimOrigin)
    if (RealDistance <= Range)
    emit_sound(id, CHAN_AUTO, "weapons/knife_hitwall1.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
    }
    }
    for (new i = 0; i < number; i++)
    {
    new iPlayer = players
    new Float:pOrigin[3]
    pev(iPlayer, pev_origin, pOrigin)
    if (!is_in_viewcone(id, pOrigin))
    continue
    // Find X position
    new Float:A1 = (fOrigin[1] - pOrigin[1]) * fOrigin[0] + (pOrigin[0] - fOrigin[0]) * fOrigin[1] - (pOrigin[0] - fOrigin[0]) * fAimOrigin[1]
    new Float:A2 = fOrigin[1] - pOrigin[1]
    new Float:XPOS = A1 / A2
    pOrigin[0] = XPOS
    pOrigin[1] = fAimOrigin[1]
    pOrigin[2] = fAimOrigin[2]
    engfunc(EngFunc_TraceLine, fOrigin, pOrigin, DONT_IGNORE_MONSTERS, id, tr)
    new hitent = get_tr2(tr, TR_pHit)
    if (hitent == iPlayer)
    {
    new Float:vEnd[3]
    get_tr2(tr, TR_vecEndPos, vEnd)
    new Float:RealDistance = vector_distance(fOrigin, vEnd)
    if (RealDistance <= Range)
    {
    if (hitent == g_IgnoreEnt)
    continue
    new iHitGroup = get_tr2(tr, TR_iHitgroup)
    if (iHitGroup == 8) // Hit shield?
    {
    new random_sound = random_num(1, 2)
    new random_file[256]
    format(random_file, 255, "weapons/ric_metal-%d.wav", random_sound)
    //emit_sound(iPlayer, CHAN_AUTO, random_file, 1.0, ATTN_NORM, 0, PITCH_NORM)
    continue
    }
    new random_sound = random_num(1, 4)
    new random_file[256]
    format(random_file, 255, "weapons/knife_hit%d.wav", random_sound)
    //emit_sound(iPlayer, CHAN_AUTO, random_file, 1.0, ATTN_NORM, 0, PITCH_NORM)
    new msgid = get_user_msgid("DeathMsg")
    new msgblock = get_msg_block(msgid)
    set_msg_block(msgid, BLOCK_ONCE);
    new Float:fTmpDmg = Damage - (Damage / Range) * RealDistance;
    if (!is_connected[iPlayer])
    continue
    ExecuteHamB(Ham_TakeDamage, iPlayer, ent , id, fTmpDmg , DMG_SLASH)
    //ExecuteHamB(Ham_TraceAttack, iPlayer, id, fTmpDmg, vEnd, tr, DMG_SLASH)
    set_msg_block(msgid, msgblock)
    //if (get_tr2(tr, TR_flFraction) <= 1.0)
    if (!is_user_alive(iPlayer))
    {
    if (iHitGroup == HIT_HEAD)
    {
    make_deathmsg(id, iPlayer, 1, "knife")
    ExecuteForward(g_knife_kill, g_result, id , iPlayer, 1)
    }
    else
    {
    make_deathmsg(id, iPlayer, 0, "knife")
    ExecuteForward(g_knife_kill, g_result, id, iPlayer, 0)
    }

    }
    }
    }
    }
    for (new iEnt = 0; iEnt < entity_count(); iEnt++)
    {
    if (!iEnt || !pev_valid(iEnt))
    continue
    new Float:pOrigin[3]
    pev(iEnt, pev_origin, pOrigin)
    if (!is_in_viewcone(id, pOrigin))
    continue
    if (pev(iEnt, pev_takedamage) == DAMAGE_NO)
    continue
    new Float:A1 = (fOrigin[1] - pOrigin[1]) * fOrigin[0] + (pOrigin[0] - fOrigin[0]) * fOrigin[1] - (pOrigin[0] - fOrigin[0]) * fAimOrigin[1]
    new Float:A2 = fOrigin[1] - pOrigin[1]
    new Float:XPOS = A1 / A2
    pOrigin[0] = XPOS
    pOrigin[1] = fAimOrigin[1]
    pOrigin[2] = fAimOrigin[2]
    engfunc(EngFunc_TraceLine, fOrigin, pOrigin, DONT_IGNORE_MONSTERS, id, tr)
    new hitent = get_tr2(tr, TR_pHit)
    if (hitent == iEnt)
    {
    new Float:vEnd[3]
    get_tr2(tr, TR_vecEndPos, vEnd)
    new Float:RealDistance = vector_distance(fOrigin, vEnd)
    if (RealDistance <= Range)
    {
    new classname[32]
    pev(iEnt, pev_classname, classname, 31)
    new Float:fTmpDmg
    if (g_IgnoreEnt == hitent)
    continue
    if (equal(classname, "player"))
    continue
    else if (equal(classname, "hostage_entity") || equal(classname, "monster_scientist"))
    {
    if (pev(iEnt, pev_iuser1) > 0)
    continue
    new random_sound = random_num(1, 4)
    new random_file[256]
    format(random_file, 255, "weapons/knife_hit%d.wav", random_sound)
    emit_sound(iEnt, CHAN_AUTO, random_file, 1.0, ATTN_NORM, 0, PITCH_NORM)
    fTmpDmg = DamageHostage - (DamageHostage / Range) * RealDistance;
    ExecuteHamB(Ham_TakeDamage, iEnt, ent , id, fTmpDmg , DMG_SLASH)
    }
    else if (equal(classname, "func_breakable") || equal(classname, "func_pushable"))
    {
    emit_sound(iEnt, CHAN_AUTO, "weapons/knife_hitwall1.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
    fTmpDmg = DamageEntity - (DamageEntity / Range) * RealDistance;
    ExecuteHamB(Ham_TakeDamage, iEnt, ent , id, fTmpDmg , DMG_SLASH)
    }
    else
    {
    emit_sound(iEnt, CHAN_AUTO, "weapons/knife_hitwall1.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
    fTmpDmg = DamageEntity - (DamageEntity / Range) * RealDistance;
    ExecuteHamB(Ham_TakeDamage, iEnt, ent , id, fTmpDmg , DMG_SLASH)
    }
    }
    }
    }
    } [/spoil]
    Chú ý coi chừng lag máy :D
     
  8. My Own Way

    My Own Way S.V.E.N Commander Lão Làng GVN

    Tham gia ngày:
    30/7/09
    Bài viết:
    12,231
    Nơi ở:
    Hải Phòng
    [spoil]
    PHP:
    /* Plugin generated by AMXX-Studio */

    #include <amxmodx>
    #include <amxmisc>
    #include <cstrike>
    #include <fakemeta>
    #include <hamsandwich>
    #include <xs>
    #include <csx>
    #include <engine>
    #include <g4u>
    #include <zombie_mod>
    #include <ghost>
    #include <character>
    #define max_wpn 255
    #define task_register_function 52301616
    #define PLUGIN "G4U Knife"
    #define VERSION "1.0"
    #define AUTHOR "Nguyen Duy Linh"
    #define knives (1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<7)|(1<<8)|(1<<9) // Keys: 1234567890
    #define key_menu (1<<9) // Keys: 0
    #define task_execute_my_damage 25251325
    #define TASK_DO_MY_FIRST_ATK 2592
    #define TASK_DO_MY_SECOND_ATK 100000
    #define TASK_CAN_ATK 200300400
    new weapon_name[max_wpn][64]
    new 
    weapon_hud_kill[max_wpn][100]
    new 
    Float:damage_player[max_wpn][2]
    new 
    Float:damage_entity[max_wpn][2], weapon_cost[max_wpn]
    new 
    Float:damage_hostage[max_wpn][2]
    new 
    weapon_level[max_wpn], weapon_cost_type[max_wpn]
    new 
    weapon_v_model[max_wpn][256], weapon_p_model[max_wpn][256]
    new 
    has_weapon[33], weapon_deploy[max_wpn][256], weapon_slash[max_wpn][256]
    new 
    weapon_hitbody[max_wpn][256], weapon_stab[max_wpn][256], weapon_hitwall[max_wpn][256]
    new 
    weapon_fSlashType[max_wpn], weapon_sSlashType[max_wpn]
    new 
    Float:weapon_fRange[max_wpn], Float:weapon_sRange[max_wpn]
    new 
    Float:weapon_deploy_time[max_wpn], Float:weapon_fSlashTime[max_wpn], Float:weapon_sSlashTime[max_wpn]
    new 
    Float:weapon_fDmgDelay[max_wpn], Float:weapon_sDmgDelay[max_wpn]
    new 
    g_weapon_count 0
    new g_page[32], menuid
    new g_knifeg_result
    new bool:ham_cz
    new g_normal_selectedg_new_selected
    new g_KnifefAtkg_KnifesAtk
    new weapon_files[max_wpn][256]
    const 
    Float:def_first_attack 1.0
    const Float:def_second_attack 1.2
    const Float:def_range 67.0
    const Float:def_first_dmg_delay 0.25
    const Float:def_second_dmg_delay 0.5
    const Float:def_second_dmg 100.0
    const Float:def_deploy_time 1.5
    new bool:is_attacking[33]
    new 
    Float:g_fDelay[33]
    new 
    g_knife_kill
    const m_pPlayer            41
    const m_iId                43
    const m_fKnown                44
    const m_flNextPrimaryAttack    46
    const m_flNextSecondaryAttack    47
    const m_flTimeWeaponIdle        48
    const m_iPrimaryAmmoType        49
    const m_iClip                51
    const m_fInReload            54
    const m_fInSpecialReload        55
    const m_fSilent            74
    const m_flNextAttack        83
    const m_rgAmmo_player_Slot0    376
    enum
    {
        
    ANIM_IDLE,
        
    ANIM_SLASH1,
        
    ANIM_SLASH2,
        
    ANIM_DRAW,
        
    ANIM_STAB,
        
    ANIM_STAB_MISS,
        
    ANIM_MIDSLASH1,
        
    ANIM_MIDSLASH2
    }

    new 
    Float:g_fDeploy[33], Float:g_fAtkTime[33], Float:g_sAtkTime[33]
    new 
    fUserAnim[64]
    new 
    bool:is_connected[33]
    new 
    weapon_model_index[max_wpn]
    new 
    Float:g_sDelay[33]
    new 
    Float:weapon_weight[max_wpn], Float:weapon_dspeed[max_wpn]
    public 
    plugin_natives()
    {
        
    register_native("g4u_equip_knife""_equip_player"1)
        
    register_native("g4u_get_knife_hud""_get_hud"1)
        
    register_native("g4u_force_user_buy_knife""_force_buy"1)
        
    register_native("g4u_user_has_knife""_get_knife"1)
        
    register_native("g4u_get_knife_name""_get_name"1)
        
    register_native("g4u_strip_user_knife""_strip_knife"1)
        
    register_native("g4u_get_knife_amount""_get_amount"1)
        
    register_native("g4u_knifeid_by_model""_knifeid_by_model"1)
        
    register_native("g4u_equip_knife_level""_knife_level"1)
        
    register_native("g4u_get_knife_cost""_knife_cost"1)
        
    register_native("g4u_get_knife_cost_type""_knife_cost_type"1)
        
    register_native("g4u_get_knife_weight""_get_knife_weight"1)
        
    register_native("g4u_get_knife_dspeed""_get_knife_dspeed"1)
    }

    public 
    Float:_get_knife_weight(wid)
    {
        if (
    wid || wid g_weapon_count 1)
            return 
    0.0
        
    return weapon_weight[wid]
    }

    public 
    Float:_get_knife_dspeed(wid)
    {
        if (
    wid || wid g_weapon_count 1)
            return 
    0.0
        
    return weapon_dspeed[wid]
    }

    public 
    _knife_cost(wid)
    {
        if (
    wid || wid g_weapon_count 1)
            return -
    1
        
    return weapon_cost[wid]
    }

    public 
    _knife_cost_type(wid)
    {
        if (
    wid || wid g_weapon_count 1)
            return -
    1
        
    return weapon_cost_type[wid]
    }

    public 
    plugin_init() 
    {
        
    register_plugin(PLUGINVERSIONAUTHOR)
        
    register_clcmd("g4u_knife""cmdbuy")
        
    register_clcmd("g4u_kmenu""cmdmenu")
        
    register_event("CurWeapon","checkWeapon","b","1=1")
        
    register_event("35""event_weapon_anim""b")
        
    register_message(get_user_msgid("DeathMsg"), "func_death")
        
    register_message(get_user_msgid("WeapPickup"),"message_weappickup")
        
    //register_message(get_user_msgid("HideWeapon"), "message_hideweapon")
        
    menuid register_menuid("[MELEE LIST]")
        
    g_knife CreateMultiForward("g4u_player_equip_knife"ET_IGNOREFP_CELLFP_CELL)
        
    g_knife_kill CreateMultiForward("g4u_knife_hit"ET_IGNOREFP_CELLFP_CELLFP_CELL)
        
    g_normal_selected CreateMultiForward("g4u_normal_knife_selected"ET_IGNOREFP_CELL)
        
    g_new_selected CreateMultiForward("g4u_new_knife_selected"ET_IGNOREFP_CELLFP_CELLFP_STRINGFP_STRINGFP_STRING)
        
    g_KnifefAtk CreateMultiForward("g4u_knife_first_atk"ET_IGNOREFP_CELL)
        
    g_KnifesAtk CreateMultiForward("g4u_knife_second_atk"ET_IGNOREFP_CELL)
        
    register_menucmd(menuidknives"show_weapon")
        
    register_forward(FM_EmitSound"fw_emitsound")
        
    register_forward(FM_CmdStart"fw_cmdstart")
        
    register_forward(FM_UpdateClientData"fm_update_data"1)
        
    RegisterHam(Ham_Player_PreThink"player""pl_prethink")
        
    RegisterHam(Ham_Spawn"player""pl_spawn"1)
        
    RegisterHam(Ham_Use"player_weaponstrip""fw_strip")
        
    RegisterHam(Ham_Item_Deploy"weapon_knife""fw_KnifeDeploy")
        
    RegisterHam(Ham_TakeDamage"player""pl_take_damage")
        
    RegisterHam(Ham_TakeDamage"hostage_entity""hs_take_damage")
        
    RegisterHam(Ham_TakeDamage"monster_scientist""hs_take_damage")
        
    RegisterHam(Ham_TakeDamage"func_breakable""ent_take_damage")
        
    RegisterHam(Ham_TakeDamage"func_pushable""ent_take_damage")

    }

    public 
    plugin_precache()
    {
        new 
    con_dir[256], trashmapname[32]
        
    get_mapname(mapname31)
        
    ham_cz false
        get_configsdir
    (con_dir255)
        new 
    manager[256]
        
    format(manager255"%s/g4u_weapon/knife/weapon_config/manager.cfg"con_dir)
        if (
    file_exists(manager))
        {
            for (new 
    0file_size(manager1); i++)
            {
                if (
    max_wpn)
                {
                    new 
    con_file[256], txt[256], len
                    read_file
    (manageritxt255len)
                    
    format(con_file255"%s/g4u_weapon/knife/weapon_config/%s.ini"con_dirtxt)
                    if (
    file_exists(con_file))
                    {
                        new 
    text[256]
                        
    read_file(con_file0text255trash)
                        
    replace(text255"[name]""")
                        
    format(weapon_name[g_weapon_count], 255"%s"text)
                        
    read_file(con_file1text255trash)
                        
    replace(text255"[first-type]""")
                        
    weapon_fSlashType[g_weapon_count] = str_to_num(text)
                        
    read_file(con_file2text255trash)
                        
    replace(text255"[second-type]""")
                        
    weapon_sSlashType[g_weapon_count] = str_to_num(text)
                        new 
    fArg[32], sArg[32]
                        
    read_file(con_file3text255trash)
                        
    replace(text255"[range]""")
                        
    parse(textfArg31sArg31)
                        
    weapon_fRange[g_weapon_count] = str_to_float(fArg)
                        
    weapon_sRange[g_weapon_count] = str_to_float(sArg)
                        
    read_file(con_file4text255trash)
                        
    replace(text255"[atk-time]""")
                        
    parse(textfArg31sArg31)
                        
    weapon_fSlashTime[g_weapon_count] = str_to_float(fArg)
                        
    weapon_sSlashTime[g_weapon_count] = str_to_float(sArg)
                        
    read_file(con_file5text255trash)
                        
    replace(text255"[dmg-delay]""")
                        
    parse(textfArg31sArg31)
                        
    weapon_fDmgDelay[g_weapon_count] = str_to_float(fArg)
                        
    weapon_sDmgDelay[g_weapon_count] = str_to_float(sArg)
                        
    read_file(con_file6text255trash)
                        
    replace(text255"[hud_kill]""")
                        
    format(weapon_hud_kill[g_weapon_count], 255"%s"text)
                        
    read_file(con_file7text255trash)
                        
    replace(text255"[damage_player]""")
                        
    parse(textfArg31sArg31)
                        
    damage_player[g_weapon_count][0] = str_to_float(fArg)
                        
    damage_player[g_weapon_count][1] = str_to_float(sArg)
                        
    read_file(con_file8text255trash)
                        
    replace(text255"[damage_entity]""")
                        
    parse(textfArg31sArg31)
                        
    damage_entity[g_weapon_count][0] = str_to_float(fArg)
                        
    damage_entity[g_weapon_count][1] = str_to_float(sArg)
                        
    read_file(con_file9text255trash)
                        
    replace(text255"[damage_hostage]""")
                        
    parse(textfArg31sArg31)
                        
    damage_hostage[g_weapon_count][0] = str_to_float(fArg)
                        
    damage_hostage[g_weapon_count][1] = str_to_float(sArg)
                        
    read_file(con_file10text255trash)
                        
    replace(text255"[cost_type]""")
                        
    weapon_cost_type[g_weapon_count] = str_to_num(text)
                        if (
    weapon_cost_type[g_weapon_count] != && weapon_cost_type[g_weapon_count] != 2)
                            
    weapon_cost_type[g_weapon_count] = 1
                        read_file
    (con_file11text255trash)
                        
    replace(text255"[cost]""")
                        
    weapon_cost[g_weapon_count] = str_to_num(text)
                        if (
    weapon_cost[g_weapon_count] < 0)
                            
    weapon_cost[g_weapon_count] = 10
                        read_file
    (con_file12text255trash)
                        
    replace(text255"[model]""")
                        
    format(weapon_p_model[g_weapon_count], 255"models/g4u_wpn/%s/p_%s.mdl"texttext)
                        
    format(weapon_v_model[g_weapon_count], 255"models/g4u_wpn/%s/v_%s.mdl"texttext)
                        
    weapon_model_index[g_weapon_count] = precache_model(weapon_v_model[g_weapon_count])
                        
    precache_model(weapon_p_model[g_weapon_count])
                        
    read_file(con_file13text255trash)
                        
    replace(text255"[level]""")
                        
    weapon_level[g_weapon_count] = str_to_num(text)
                        if (
    weapon_level[g_weapon_count] > g4u_get_max_level())
                            
    weapon_level[g_weapon_count] = g4u_get_max_level()
                        
    read_file(con_file14text255trash)
                        
    replace(text255"[deploy-sound]""")
                        
    format(weapon_deploy[g_weapon_count], 255"weapons/g4u_wpn/%s.wav"text)
                        
    read_file(con_file15text255trash)
                        
    replace(text255"[slash-sound]""")
                        
    format(weapon_slash[g_weapon_count], 255"weapons/g4u_wpn/%s.wav"text)
                        
    read_file(con_file16text255trash)
                        
    replace(text255"[hitbody-sound]""")
                        
    format(weapon_hitbody[g_weapon_count], 255"weapons/g4u_wpn/%s.wav"text)
                        
    read_file(con_file17text255trash)
                        
    replace(text255"[stab-sound]""")
                        
    format(weapon_stab[g_weapon_count], 255"weapons/g4u_wpn/%s.wav"text)
                        
    read_file(con_file18text255trash)
                        
    replace(text255"[hitwall-sound]""")
                        
    format(weapon_hitwall[g_weapon_count], 255"weapons/g4u_wpn/%s.wav"text)
                        
    precache_sound(weapon_deploy[g_weapon_count])
                        
    precache_sound(weapon_slash[g_weapon_count])
                        
    precache_sound(weapon_hitbody[g_weapon_count])
                        
    precache_sound(weapon_stab[g_weapon_count])
                        
    precache_sound(weapon_hitwall[g_weapon_count])
                        
    read_file(con_file19text255trash)
                        
    replace(text255"[deploy-time]""")
                        
    weapon_deploy_time[g_weapon_count] = str_to_float(text)
                        
    format(weapon_files[g_weapon_count], 255"%s/g4u_weapon/knife/weapon_config/%s"con_dirtxt)
                        
    read_file(con_file20text255trash)
                        
    replace(text255"[weight]""")
                        
    weapon_weight[g_weapon_count] = str_to_float(text)
                        
    read_file(con_file21text255trash)
                        
    replace(text255"[dspeed""")
                        
    weapon_dspeed[g_weapon_count] = str_to_float(text)
                        
    g_weapon_count++
                    }
                }
            }
        }
    }

    public 
    _equip_player(idweaponidshow_message)
    {
        if (
    weaponid g_weapon_count)
            return
        if (
    weaponid 0)
            return
        if (!
    pev_valid(id))
            return
        if (
    g4u_get_user_zombie(id))
            return
        
    has_weapon[id] = weaponid
        
    if (!user_has_weapon(idCSW_KNIFE))
            
    fm_give_item(id"weapon_knife")
        
    engclient_cmd(id"weapon_knife")
        
    reset_knife(id)
        
    }

    public 
    _get_hud(weaponidhud[], len)
    {
        
    param_convert(2)
        if (
    weaponid || weaponid g_weapon_count)
            
    format(hudlen"NULL")
        
    format(hudlenweapon_hud_kill[weaponid])
    }

    public 
    _force_buy(idweaponid)
        
    buy_weapon(idweaponid)

    public 
    _get_knife(id)
        return 
    has_weapon[id]
        
    public 
    _get_name(wpnidwpnname[], len)
    {
        
    param_convert(2)
        if (
    wpnid g_weapon_count || wpnid 0)
            
    format(wpnnamelen"NULL")
        else 
    format(wpnnamelen"%s"weapon_name[wpnid])
    }

    public 
    _strip_knife(id)
    {
        
    ham_strip_weapon(id"weapon_knife")
        
    has_weapon[id] = -1
    }    

    public 
    _get_amount()
        return 
    g_weapon_count

    public _knifeid_by_model(const model[], len)
    {
        
    param_convert(1)
        for (new 
    0g_weapon_counti++)
            if (
    equal(modelweapon_v_model[i], len))
                return 
    i
        
    return -1
    }
    stock get_knifeid_by_model(const model[], len)
    {
        
    param_convert(1)
        for (new 
    0g_weapon_counti++)
            if (
    equal(modelweapon_v_model[i], len))
                return 
    i
        
    return -1
    }
    public 
    _knife_level(idmodel[], len)
    {
        
    param_convert(2)
        new 
    weaponid get_knifeid_by_model(modellen)
        if (!
    is_user_alive(id))
            return -
    1
        
    if (g4u_get_user_zombie(id))
        {
            
    client_print(idprint_center"[G4U MSG] Vu khi nay khong danh cho Zombie")
            return -
    1
        
    }
        if (
    weaponid g_weapon_count || weaponid 0)
            return -
    1
        
    if (g4u_get_level(id) < weapon_level[weaponid])
        {
            new 
    need_to_level[256]
            
    g4u_get_level_name(weapon_level[weaponid], need_to_level255)
            
    client_print(idprint_center"[G4U MSG] Ban phai dat %s de trang bi vu khi nay"need_to_level)
            return -
    1
            
        
    }
        
    ham_strip_weapon(id"weapon_knife")
        
    has_weapon[id] = -1
        
    //if (!user_has_weapon(id, CSW_KNIFE))
        //    fm_give_item(id, "weapon_knife")
        //engclient_cmd(id, "weapon_knife")
        //engclient_cmd(id, "weapon_knife")
        //reset_knife(id)
        //set_pev(id, pev_viewmodel2, weapon_v_model[has_weapon[id]])
        //set_pev(id, pev_viewmodel, weapon_v_model[has_weapon[id]])
        //set_pev(id, pev_weaponmodel2, weapon_p_model[has_weapon[id]])
        //set_pev(id, pev_weaponmodel, weapon_p_model[has_weapon[id]])
        // client_print(id, print_chat, "[G4U MSG] Ban da trang bi %s", weapon_name[weaponid])
        
    has_weapon[id] = weaponid
        
    //_equip_player(id, weaponid, 0)
        
    ExecuteForward(g_knifeg_resultidweaponid)
        return 
    1
    }

    public 
    client_connect(id)
    {
        
    has_weapon[id] = -1
    }

    public 
    client_putinserver(id)
    {
        if (
    is_user_bot(id))
            
    set_task(0.1"register_bot_function"id task_register_function)
        
    is_connected[id] = true
    }
                
    public 
    register_bot_function(taskid)
    {
        new 
    id taskid task_register_function
        
    if (pev_valid(id) && !ham_cz && get_cvar_num("bot_quota"))
        {
            
    RegisterHamFromEntity(Ham_Spawnid"pl_spawn"1)
            
    RegisterHamFromEntity(Ham_TakeDamageid"pl_take_damage")
            
    //RegisterHamFromEntity(Ham_Killed, id , "pl_death", 1)
            
    RegisterHamFromEntity(Ham_Player_UpdateClientDataid"fw_BotUpdate")
            
    ham_cz true
        
    }
    }

    public 
    client_death(killervictim)
    {
        if (
    pev_valid(victim))
        {
            
    has_weapon[victim] = -1
            
    new menuindexkeys
            get_user_menu
    (victimmenuindexkeys)
            if (
    menuindex == menuid)
                
    client_cmd(victim"slot10")
        }
        
    is_attacking[victim] = false
    }

    public 
    cmdbuy(idlevelcid)
    {
        if (
    cmd_access(idlevelcid2))
        {
            new 
    fArg[3]
            
    read_argv(1fArg3)
            new 
    weapon_id str_to_num(fArg)
            
    buy_weapon(idweapon_id)
        }
    }

    public 
    cmdmenu(id)
    {
        if (!
    is_user_alive(id) || g4u_get_user_zombie(id))
            return
        
    g_page[id] = 0
        show_weapon_now
    (id0)
    }

    public 
    checkWeapon(id)
    {
        if (
    get_user_weapon(id) == CSW_KNIFE)
        {
            if (!
    g4u_get_user_zombie(id))
            {
                if (
    has_weapon[id] > -1)
                {
                    
    set_pev(idpev_viewmodel2weapon_v_model[has_weapon[id]])
                    
    set_pev(idpev_weaponmodel2weapon_p_model[has_weapon[id]])
                    
    ExecuteForward(g_new_selectedg_resultidhas_weapon[id], weapon_name[has_weapon[id]], weapon_hud_kill[has_weapon[id]], weapon_files[has_weapon[id]])
                    
    //hide_cross(id)
                
    }
                else    
    ExecuteForward(g_normal_selectedg_resultid)
            }
            
    //else
            //    set_pev(id, pev_weaponmodel2, "")
        
    }
                
    }

    public 
    event_weapon_anim()
    {
        
    // Because of a weird bug within the AMXX event system, we need to
        // hook this message to prevent some weird behavior when calling
        // engclient_cmd(id, "weapon_knife") in the CurWeapon Event forward.
        // [url]http://forums.alliedmods.net/showthread.php?t=85161&page=2[/url]
    }

    public 
    g4u_infected_pre(victiminfector)
        
    has_weapon[victim] = -1

    public g4u_zombie_appear_post(zombieid)
        
    has_weapon[zombieid] = -1

    public g4u_user_become_zombie(id)
        
    has_weapon[id] = -1
    public func_death(msg_idmsg_destmsg_entity)
    {
        static 
    szTruncatedWeapon[33], iAttackeriVictim
        get_msg_arg_string
    (4szTruncatedWeaponcharsmax(szTruncatedWeapon))
        
    // Get attacker and victim
        
    iAttacker get_msg_arg_int(1)
        
    iVictim get_msg_arg_int(2)
        
    // Non-player attacker or self kill
        
    if(!is_user_connected(iAttacker) || iAttacker == iVictim)
            return 
    PLUGIN_CONTINUE
        
    if(equal(szTruncatedWeapon"knife"5) && get_user_weapon(iAttacker) == CSW_KNIFE)
        {
            if (
    has_weapon[iAttacker] >-1)
                
    set_msg_arg_string(4weapon_hud_kill[has_weapon[iAttacker]])
        }
        return 
    PLUGIN_CONTINUE
    }

    public 
    message_weappickup(msg_idmsg_destmsg_entity)
        return 
    PLUGIN_HANDLED

    public show_weapon(idkey
    {    
        if (
    key 7)
        {
            new 
    weapon_index g_page[id] * key 
            buy_weapon
    (idweapon_index)
        }
        if (
    key == 7)
        { 
    // 8
            
    if (g_page[id] - 0)
                
    g_page[id] = 0
            
    else  g_page[id]--
            
    show_weapon_now(idg_page[id])
        }
        if (
    key == 8
        { 
            new 
    start g_page[id] * 7
            
    if (start g_weapon_count)
                
    show_weapon_now(idg_page[id])
            else
            {
                
    g_page[id]++
                
    show_weapon_now(idg_page[id])
            }
        }
        if (
    key == 9)
        {}
    }

    public 
    fw_emitsound(idchannel, const sample[], Float:volumeFloat:attnflagspitch)
    {
        if (!
    is_user_connected(id) || !is_user_alive(id) || has_weapon[id] < 0)
            return 
    FMRES_IGNORED
        
    // Zombie attacks with knife
        
    if (equal(sample[8], "kni"3))
        {
            if (
    equal(sample[14], "sla"3)) // slash
            
    {
                
    engfunc(EngFunc_EmitSoundidchannelweapon_slash[has_weapon[id]], volumeattnflagspitch)
                return 
    FMRES_SUPERCEDE;
            }
            if (
    equal(sample[14], "hit"3))
            {
                if (
    sample[17] == 'w'// wall
                
    {
                    
    engfunc(EngFunc_EmitSoundidchannelweapon_hitwall[has_weapon[id]], volumeattnflagspitch)
                    return 
    FMRES_SUPERCEDE;
                }
                else 
    // hit
                
    {
                    
    engfunc(EngFunc_EmitSoundidchannelweapon_hitbody[has_weapon[id]], volumeattnflagspitch)
                    return 
    FMRES_SUPERCEDE;
                }
            }
            if (
    equal(sample[14], "sta"3)) // stab
            
    {
                
    engfunc(EngFunc_EmitSoundidchannelweapon_stab[has_weapon[id]], volumeattnflagspitch)
                return 
    FMRES_SUPERCEDE;
            }
        }
        
        return 
    FMRES_IGNORED;
    }

    public 
    fw_cmdstart(iduchandleseed)
    {
        if (!
    is_user_alive(id))
            return 
    FMRES_IGNORED
        
    if (has_weapon[id] > -1)
        {
            if (
    get_user_weapon(id) == CSW_KNIFE)
            {
                if (!
    g4u_get_user_zombie(id))
                {
                    new 
    button get_uc(uchandleUC_Buttons)
                    new 
    Float:fCurrentTime get_gametime()
                    new 
    ent find_ent_by_owner(-1"weapon_knife"id)
                    if (
    button IN_ATTACK)
                    {
                        
    set_uc(uchandleUC_Buttonsbutton &~IN_ATTACK)
                        if (
    fCurrentTime g_fDeploy[id] >= weapon_deploy_time[has_weapon[id]] && fCurrentTime g_fAtkTime[id] >= weapon_fSlashTime[has_weapon[id]])
                        {
                            if (
    fCurrentTime g_fDeploy[id] >= weapon_deploy_time[has_weapon[id]] && fCurrentTime g_sAtkTime[id] >= weapon_sSlashTime[has_weapon[id]])
                            {
                                if (
    weapon_fSlashType[has_weapon[id]] == 0)
                                    
    ExecuteHamB(Ham_Weapon_PrimaryAttackent)
                                else if (
    weapon_fSlashType[has_weapon[id]] == || weapon_fSlashType[has_weapon[id]] == 2)
                                {
                                    if (
    task_exists(id TASK_DO_MY_FIRST_ATK))
                                        
    remove_task(id TASK_DO_MY_FIRST_ATK)
                                    if (
    task_exists(id TASK_DO_MY_SECOND_ATK))
                                        
    remove_task(id TASK_DO_MY_SECOND_ATK)
                                        
                                    if (
    fUserAnim[id] == 6)
                                        
    fUserAnim[id] = 7
                                    
    else if (fUserAnim[id] != 6)
                                        
    fUserAnim[id] = 6
                                    SendWeaponAnim
    (idfUserAnim[id])
                                    
    //SendWeaponAnim(id, 6)
                                    
    emit_sound(idCHAN_AUTOweapon_slash[has_weapon[id]], 1.0ATTN_NORM0PITCH_NORM)
                                    
    set_task(weapon_fDmgDelay[has_weapon[id]], "DoMyFirstDamage"id TASK_DO_MY_FIRST_ATK)
                                    
    g_fAtkTime[id]  = get_gametime()
                                    
    is_attacking[id] = true
                                    
    if (task_exists(id TASK_CAN_ATK))
                                        
    remove_task(id TASK_CAN_ATK)
                                    
    set_task(weapon_fSlashTime[has_weapon[id]], "fw_IcanAtk"id TASK_CAN_ATK)
                                    
    ExecuteForward(g_KnifefAtkg_resultid)
                                }
                            }
                        }
                    }
                    else if (
    button IN_ATTACK2)
                    {
                        
    set_uc(uchandleUC_Buttonsbutton &~IN_ATTACK2)
                        if (
    fCurrentTime g_fDeploy[id] >= weapon_deploy_time[has_weapon[id]] && fCurrentTime g_sAtkTime[id] >= weapon_sSlashTime[has_weapon[id]])
                        {
                            if (
    fCurrentTime g_fDeploy[id] >= weapon_deploy_time[has_weapon[id]] && fCurrentTime g_fAtkTime[id] >= weapon_fSlashTime[has_weapon[id]])
                            {
                                if (
    weapon_sSlashType[has_weapon[id]] == 0)
                                    
    ExecuteHamB(Ham_Weapon_SecondaryAttackent)
                                else if (
    weapon_sSlashType[has_weapon[id]] == || weapon_sSlashType[has_weapon[id]] == 2)
                                {
                                    if (
    task_exists(id TASK_DO_MY_FIRST_ATK))
                                        
    remove_task(id TASK_DO_MY_FIRST_ATK)
                                    if (
    task_exists(id TASK_DO_MY_SECOND_ATK))
                                        
    remove_task(id TASK_DO_MY_SECOND_ATK)
                                    
    set_task(weapon_sDmgDelay[has_weapon[id]], "DoMySecondDamage"id TASK_DO_MY_SECOND_ATK)
                                    
    SendWeaponAnim(id4)
                                    
    emit_sound(idCHAN_AUTOweapon_stab[has_weapon[id]], 1.0ATTN_NORM0PITCH_NORM)
                                    
    g_sAtkTime[id] = get_gametime()
                                    
    is_attacking[id] = true
                                    
    if (task_exists(id TASK_CAN_ATK))
                                        
    remove_task(id TASK_CAN_ATK)
                                    
    set_task(weapon_sSlashTime[has_weapon[id]], "fw_IcanAtk"id TASK_CAN_ATK)
                                    
    ExecuteForward(g_KnifesAtkg_resultid)
                                }
                            }
                        }
                    }
                }
            }
        }                                    
        if (
    has_weapon[id] < 0)
        {
            if (
    get_user_weapon(id) == CSW_KNIFE)
            {
                if (!
    g4u_get_user_zombie(id))
                {
                    new 
    button get_uc(uchandleUC_Buttons)
                    new 
    Float:fCurrentTime get_gametime()
                    if (
    button IN_ATTACK)
                    {
                        new 
    Float:fCurentTime get_gametime()
                        
    set_uc(uchandleUC_Buttonsbutton &~IN_ATTACK)
                        if (
    fCurentTime g_fDeploy[id] >= def_deploy_time && fCurrentTime g_fDelay[id] >= def_first_attack)
                        {
                            if (
    fCurrentTime g_fDeploy[id] >= def_deploy_time && fCurrentTime g_sDelay[id] >= def_second_attack)
                            {
                                
    g_fDelay[id] = get_gametime()
                                
    SlashKnifeNormal(iddef_range125.0100.0 ,100.0)
                                if (
    fUserAnim[id] == 6)
                                    
    fUserAnim[id] = 7
                                
    else if (fUserAnim[id] != 6)
                                    
    fUserAnim[id] = 6
                                is_attacking
    [id] = true
                                SendWeaponAnim
    (idfUserAnim[id])
                                if (
    task_exists(id TASK_CAN_ATK))
                                    
    remove_task(id TASK_CAN_ATK)
                                
    set_task(def_first_attack"fw_IcanAtk"id TASK_CAN_ATK)
                                
    ExecuteForward(g_KnifefAtkg_resultid)
                            }
                            
                        }
                    }
                    else if (
    button IN_ATTACK2)
                    {
                        
    set_uc(uchandleUC_Buttonsbutton &~IN_ATTACK2)
                        new 
    Float:fCurentTime get_gametime()
                        if (
    fCurrentTime g_fDeploy[id] >= def_deploy_time && fCurrentTime g_sDelay[id] >= def_second_attack)
                        {
                            if (
    fCurentTime g_fDeploy[id] >= def_deploy_time && fCurrentTime g_fDelay[id] >= def_first_attack)
                            {
                            
    //if (task_exists(id + task_execute_my_damage))
                                    //remove_task(id + task_execute_my_damage)
                                // new ent = find_ent_by_owner(-1, "weapon_knife", id)
                                
    set_task(def_second_dmg_delay"execute_my_damage"id task_execute_my_damage)
                                
    SendWeaponAnim(idANIM_STAB)
                                
    g_fDelay[id] = get_gametime()
                                
    is_attacking[id] = true
                                
    if (task_exists(id TASK_CAN_ATK))
                                    
    remove_task(id TASK_CAN_ATK)
                                
    set_task(def_first_attack"fw_IcanAtk"id TASK_CAN_ATK)
                                
    ExecuteForward(g_KnifesAtkg_resultid)
                            }
                        }
                    }
                }
            }
        }
        return 
    FMRES_IGNORED
    }

    public 
    fw_IcanAtk(TASKID)
    {
        new 
    id TASKID TASK_CAN_ATK
        
    if (!is_user_alive(id))
            
    is_attacking[id] = false
        is_attacking
    [id] = false
    }

    public 
    DoMyFirstDamage(TASKID)
    {
        new 
    id TASKID TASK_DO_MY_FIRST_ATK
        
    if (!is_user_alive(id))
            return
        if (
    get_user_weapon(id) != CSW_KNIFE)
            return
        if (
    g4u_get_user_zombie(id))
            return
        if (
    weapon_fSlashType[has_weapon[id]] == 1)
        {
            new 
    Float:faimOrigin[3], RetVec[3], Float:fRetVec[3]
            new 
    aimOrigin[3], targetbody
            get_user_origin
    (idaimOrigin1)
            
    get_user_aiming(idtargetbody)
            
    get_user_origin(idRetVec3)
            
    IVecFVec(aimOriginfaimOrigin)
            
    IVecFVec(RetVecfRetVec)
            new 
    hitplace
            
    new ent find_ent_by_owner(-1"weapon_knife"id)
            if(
    target && target <= get_maxplayers())
            {    
                new 
    Float:range vector_distance(faimOriginfRetVec)
                if (
    range <= weapon_fRange[has_weapon[id]])
                {
                    if (
    body != 8)
                    {
                        if (!
    get_cvar_num("mp_friendlyfire"))
                            if (
    get_user_team(id) == get_user_team(target))
                                return
                        new 
    msgid get_user_msgid("DeathMsg")
                        new 
    msgblock get_msg_block(msgid)
                        
    set_msg_block(msgidBLOCK_ONCE);    
                        
    ExecuteHamB(Ham_TakeDamagetargetentiddamage_player[has_weapon[id]][0], DMG_SLASH)
                        
    set_msg_block(msgidmsgblock)
                        new 
    tr_result
                        engfunc
    (EngFunc_TraceLinefaimOriginfRetVecDONT_IGNORE_MONSTERSidtr_result)
                        
    //fakedamage(target, "", damage , DMG_BULLET)
                        
    if (body == HIT_HEAD)
                            
    hitplace 1
                        
    if (body != HIT_HEAD)
                            
    hitplace 0
                        emit_sound
    (targetCHAN_AUTOweapon_hitbody[has_weapon[id]], 1.0ATTN_NORM0PITCH_NORM)
                        if (!
    is_user_alive(target))
                        {
                            
    g4u_set_knife_kill(idhitplace)
                            
    ExecuteForward(g_knife_killg_resultidtargethitplace)
                            
    //make_deathmsg(id, target, body, "knife")
                            
    make_deathmsg(idtargethitplaceweapon_hud_kill[has_weapon[id]])
                            
    //ExecuteHamB(Ham_TraceAttack, target, id, def_second_dmg, fRetVec, tr_result, DMG_SLASH)
                        
    }
                    }
                    else
                    {
                        new 
    random_sound random_num(12)
                        new 
    random_file[256]
                        
    format(random_file255"weapons/ric_metal-%d.wav"random_sound)
                        
    emit_sound(targetCHAN_AUTOrandom_file1.0ATTN_NORM0PITCH_NORM)
                    }
                } 
            }
            else 
            {
                if(
    target)
                {
                    new 
    Float:range vector_distance(faimOriginfRetVec)
                    if (
    range <= weapon_fRange[has_weapon[id]])
                    {
                        new 
    classname[32]
                        
    pev(targetpev_classnameclassname31)
                        if (
    equal(classname"hostage_entity"14) || equal(classname"monster_scientist"17))
                        {
                            
    emit_sound(targetCHAN_AUTOweapon_hitbody[has_weapon[id]], 1.0ATTN_NORM0PITCH_NORM)
                            
    ExecuteHamB(Ham_TakeDamagetargetentiddamage_hostage[has_weapon[id]][0], DMG_SLASH)
                        }
                        if (
    equal(classname"func_breakable"14 ) || equal(classname"func_pushable"13))
                        {
                            new 
    flags pev(targetpev_spawnflags)
                            if (
    flags != SF_BREAK_TRIGGER_ONLY)
                                
    ExecuteHamB(Ham_TakeDamagetargetentiddamage_hostage[has_weapon[id]][0], DMG_SLASH)
                            
    //fakedamage(target, hud, random_float(damage, damage * 1.7) , DMG_SLASH)
                            
    emit_sound(targetCHAN_AUTOweapon_hitwall[has_weapon[id]], 1.0ATTN_NORM0PITCH_NORM)
                        }
                    } 
                }
                else 
                {
                    new 
    Float:range vector_distance(faimOriginfRetVec)
                    if (
    range <= weapon_fRange[has_weapon[id]])
                        
    emit_sound(idCHAN_AUTOweapon_hitwall[has_weapon[id]], 1.0ATTN_NORM0PITCH_NORM)
                }
            }
        }
        if (
    weapon_fSlashType[has_weapon[id]] == 2)
            
    SlashKnife(idweapon_fRange[has_weapon[id]], damage_player[has_weapon[id]][0], damage_hostage[has_weapon[id]][0], damage_entity[has_weapon[id]][0])
            
    }

    public 
    DoMySecondDamage(TASKID)
    {
        new 
    id TASKID TASK_DO_MY_SECOND_ATK    
        
    if (!is_user_alive(id))
            return
        if (
    get_user_weapon(id) != CSW_KNIFE)
            return
        if (
    g4u_get_user_zombie(id))
            return
        if (
    weapon_sSlashType[has_weapon[id]] == 1)
        {
            new 
    Float:faimOrigin[3], RetVec[3], Float:fRetVec[3]
            new 
    aimOrigin[3], targetbody
            get_user_origin
    (idaimOrigin1)
            
    get_user_aiming(idtargetbody)
            
    get_user_origin(idRetVec3)
            
    IVecFVec(aimOriginfaimOrigin)
            
    IVecFVec(RetVecfRetVec)
            new 
    hitplace
            
    new ent find_ent_by_owner(-1"weapon_knife"id)
            if(
    target && target <= get_maxplayers())
            {    
                new 
    Float:range vector_distance(faimOriginfRetVec)
                if (
    range <= weapon_sRange[has_weapon[id]])
                {
                    if (
    body != 8)
                    {
                        if (!
    get_cvar_num("mp_friendlyfire"))
                            if (
    get_user_team(id) == get_user_team(target))
                                return
                        new 
    msgid get_user_msgid("DeathMsg")
                        new 
    msgblock get_msg_block(msgid)
                        
    set_msg_block(msgidBLOCK_ONCE);    
                        
    ExecuteHamB(Ham_TakeDamagetargetentiddamage_player[has_weapon[id]][1], DMG_SLASH)
                        
    set_msg_block(msgidmsgblock)
                        new 
    tr_result
                        engfunc
    (EngFunc_TraceLinefaimOriginfRetVecDONT_IGNORE_MONSTERSidtr_result)
                        
    //fakedamage(target, "", damage , DMG_BULLET)
                        
    if (body == HIT_HEAD)
                            
    hitplace 1
                        
    if (body != HIT_HEAD)
                            
    hitplace 0
                        emit_sound
    (targetCHAN_AUTOweapon_hitbody[has_weapon[id]], 1.0ATTN_NORM0PITCH_NORM)
                        if (!
    is_user_alive(target))
                        {
                            
    g4u_set_knife_kill(idhitplace)
                            
    ExecuteForward(g_knife_killg_resultidtargethitplace)
                            
    //make_deathmsg(id, target, body, "knife")
                            
    make_deathmsg(idtargethitplaceweapon_hud_kill[has_weapon[id]])
                            
    //ExecuteHamB(Ham_TraceAttack, target, id, def_second_dmg, fRetVec, tr_result, DMG_SLASH)
                        
    }
                    }
                    else
                    {
                        new 
    random_sound random_num(12)
                        new 
    random_file[256]
                        
    format(random_file255"weapons/ric_metal-%d.wav"random_sound)
                        
    emit_sound(targetCHAN_AUTOrandom_file1.0ATTN_NORM0PITCH_NORM)
                    }
                } 
            }
            else 
            {
                if(
    target)
                {
                    new 
    Float:range vector_distance(faimOriginfRetVec)
                    if (
    range <= weapon_sRange[has_weapon[id]])
                    {
                        new 
    classname[32]
                        
    pev(targetpev_classnameclassname31)
                        if (
    equal(classname"hostage_entity"14) || equal(classname"monster_scientist"17))
                        {    
                            
    emit_sound(targetCHAN_AUTOweapon_hitbody[has_weapon[id]], 1.0ATTN_NORM0PITCH_NORM)
                            
    ExecuteHamB(Ham_TakeDamagetargetentiddamage_hostage[has_weapon[id]][1], DMG_SLASH)
                        }
                        if (
    equal(classname"func_breakable"14 ) || equal(classname"func_pushable"13))
                        {
                            new 
    flags pev(targetpev_spawnflags)
                            if (
    flags != SF_BREAK_TRIGGER_ONLY)
                                
    ExecuteHamB(Ham_TakeDamagetargetentiddamage_hostage[has_weapon[id]][0], DMG_SLASH)
                            
    //fakedamage(target, hud, random_float(damage, damage * 1.7) , DMG_SLASH)
                            
    emit_sound(targetCHAN_AUTOweapon_hitwall[has_weapon[id]], 1.0ATTN_NORM0PITCH_NORM)
                        }
                    } 
                }
                else 
                {
                    new 
    Float:range vector_distance(faimOriginfRetVec)
                    if (
    range <= weapon_sRange[has_weapon[id]])
                        
    emit_sound(idCHAN_AUTOweapon_hitwall[has_weapon[id]], 1.0ATTN_NORM0PITCH_NORM)
                }
            }
        }
        if (
    weapon_sSlashType[has_weapon[id]] == 2)
            
    SlashKnife(idweapon_sRange[has_weapon[id]], damage_player[has_weapon[id]][1], damage_hostage[has_weapon[id]][1], damage_entity[has_weapon[id]][1])        
    }
    public 
    fm_update_data(idsendweaponcd_handle)
    {
        if (!
    is_user_alive(id))
            return 
    FMRES_IGNORED
        
    if (get_user_weapon(id) != CSW_KNIFE)
            return 
    FMRES_IGNORED
        
    if (g4u_get_user_zombie(id))
            return 
    FMRES_IGNORED
        
    if (has_weapon[id] < 0)
        {
            new 
    Float:next_attack get_pdata_float(idm_flNextAttack5)
            if (
    next_attack <= 0.0)
            {
                
    set_cd(cd_handleCD_flNextAttackget_gametime() + 0.001)
            
    //    return FMRES_HANDLED
            
    }
            if (
    is_attacking[id])
            {
                new 
    Sequence pev(idpev_sequence)
                if (
    Sequence == 73)
                    
    set_pev(idpev_sequence74)
                if (
    Sequence == 75)
                    
    set_pev(idpev_sequence76)
            }
            
    //return FMRES_HANDLED
            
        
    }
        if (
    has_weapon[id] > -1)
        {
            new 
    Float:next_attack get_pdata_float(idm_flNextAttack5)
            if (
    next_attack <= 0.0)
            {
                
    set_cd(cd_handleCD_flNextAttackget_gametime() + 0.001)
            
    //    return FMRES_HANDLED
            
    }
            if (
    is_attacking[id])
            {
                new 
    Sequence pev(idpev_sequence)
                if (
    Sequence == 73)
                    
    set_pev(idpev_sequence74)
                if (
    Sequence == 75)
                    
    set_pev(idpev_sequence76)
            }    
        }
        return 
    FMRES_IGNORED
    }

    public 
    execute_my_damage(taskid)
    {
        new 
    id taskid task_execute_my_damage
        
    if (!is_user_alive(id))
            return
        if (
    g4u_get_user_zombie(id))
            return
        if (
    get_user_weapon(id) != CSW_KNIFE)
            return
        
    // Find target
        
    new Float:faimOrigin[3], RetVec[3], Float:fRetVec[3]
        new 
    aimOrigin[3], targetbody
        get_user_origin
    (idaimOrigin1)
        
    get_user_aiming(idtargetbody)
        
    get_user_origin(idRetVec3)
        
    IVecFVec(aimOriginfaimOrigin)
        
    IVecFVec(RetVecfRetVec)
        new 
    hitplace
        
    new ent find_ent_by_owner(-1"weapon_knife"id)
        if(
    target && target <= get_maxplayers())
        {    
            new 
    Float:range vector_distance(faimOriginfRetVec)
            if (
    range <= def_range)
            {
                if (
    body != 8)
                {
                    if (!
    get_cvar_num("mp_friendlyfire"))
                        if (
    get_user_team(id) == get_user_team(target))
                            return
                    new 
    msgid get_user_msgid("DeathMsg")
                    new 
    msgblock get_msg_block(msgid)
                    
    set_msg_block(msgidBLOCK_ONCE);    
                    
    ExecuteHamB(Ham_TakeDamagetargetentiddef_second_dmgDMG_SLASH)
                    
    set_msg_block(msgidmsgblock)
                    new 
    tr_result
                    engfunc
    (EngFunc_TraceLinefaimOriginfRetVecDONT_IGNORE_MONSTERSidtr_result)
                    
    //fakedamage(target, "", damage , DMG_BULLET)
                    
    if (body == HIT_HEAD)
                        
    hitplace 1
                    
    if (body != HIT_HEAD)
                        
    hitplace 0
                    
    new random_sound random_num(14)
                    new 
    random_file[256]
                    
    format(random_file255"weapons/knife_hit%d.wav"random_sound)
                    
    emit_sound(targetCHAN_AUTOrandom_file1.0ATTN_NORM0PITCH_NORM)
                    if (!
    is_user_alive(target))
                    {
                        
    g4u_set_knife_kill(idhitplace)
                        
    ExecuteForward(g_knife_killg_resultidtargethitplace)
                        
    make_deathmsg(idtargethitplace"knife")
                        
    //ExecuteHamB(Ham_TraceAttack, target, id, def_second_dmg, fRetVec, tr_result, DMG_SLASH)
                    
    }
                }
                else
                {
                    new 
    random_sound random_num(12)
                    new 
    random_file[256]
                    
    format(random_file255"weapons/ric_metal-%d.wav"random_sound)
                    
    emit_sound(targetCHAN_AUTOrandom_file1.0ATTN_NORM0PITCH_NORM)
                }
            } 
        }
        else 
        {
            if(
    target)
            {
                new 
    Float:range vector_distance(faimOriginfRetVec)
                if (
    range <= def_range)
                {
                    new 
    classname[32]
                    
    pev(targetpev_classnameclassname31)
                    if (
    equal(classname"hostage_entity"14) || equal(classname"monster_scientist"17))
                    {
                        new 
    random_sound random_num(14)
                        new 
    random_file[256]
                        
    format(random_file255"weapons/knife_hit%d.wav"random_sound)
                        
    ExecuteHamB(Ham_TakeDamagetargetentiddef_second_dmgDMG_SLASH)
                        
    emit_sound(targetCHAN_AUTOrandom_file1.0ATTN_NORM0PITCH_NORM)
                    }
                    if (
    equal(classname"func_breakable"14 ) || equal(classname"func_pushable"13))
                    {
                        new 
    flags pev(targetpev_spawnflags)
                        if (
    flags != SF_BREAK_TRIGGER_ONLY)
                            
    ExecuteHamB(Ham_TakeDamagetargetentidrandom_float(80.0100.0), DMG_SLASH)
                        
    //fakedamage(target, hud, random_float(damage, damage * 1.7) , DMG_SLASH)
                        
    emit_sound(idCHAN_AUTO"weapons/knife_hitwall1.wav"1.0ATTN_NORM0PITCH_NORM)
                    }
                } 
            }
            else 
            {
                new 
    Float:range vector_distance(faimOriginfRetVec)
                if (
    range <= def_range)
                    
    emit_sound(idCHAN_AUTO"weapons/knife_hitwall1.wav"1.0ATTN_NORM0PITCH_NORM)
            }
        }
    }

    public 
    pl_prethink(id)
    {
        if (
    get_user_weapon(id) != CSW_KNIFE || !is_user_alive(id))
        {
            if (
    task_exists(id TASK_DO_MY_FIRST_ATK))
                
    remove_task(id TASK_DO_MY_FIRST_ATK)
            if (
    task_exists(id TASK_DO_MY_SECOND_ATK))
                
    remove_task(id TASK_DO_MY_SECOND_ATK)
        }
        
    //if (get_user_weapon(id) == CSW_KNIFE)
        //    if (is_user_alive(id))
        //        if (g_KnifeDeployed[id])
        //            hide_cross(id)
                    
    }

    public 
    pl_spawn(id)
    {
        if (
    has_weapon[id] > -1)
            if (!
    user_has_weapon(idCSW_KNIFE))
                
    has_weapon[id] = -1
        is_attacking
    [id] = false
    }            

    public 
    fw_strip(ientid)
    {
        
    has_weapon[id] = -1
        
    return PLUGIN_CONTINUE
    }

    public 
    fw_KnifeDeploy(ent)
    {
        new 
    id pev(entpev_owner)
        if (!
    is_connected[id])
            return
        if (!
    is_user_alive(id))
            return
        
    g_fDeploy[id] = get_gametime()
        
    g_fDelay[id] = - 1000000.0
        g_sDelay
    [id] = - 10000000.0
        g_fAtkTime
    [id] = -1000000.0
        g_sAtkTime
    [id] = - 1000000.0
        fUserAnim
    [id] = 6
        
    if (has_weapon[id] > -1)
            
    emit_sound(idCHAN_AUTOweapon_deploy[has_weapon[id]], 1.0ATTN_NORM0PITCH_NORM)
    }

    public 
    pl_take_damage(victiminflictorattackerFloat:damagedamagebit)
    {
        new 
    classname[32]
        
    pev(attackerpev_classnameclassname31)
        if (
    equal(classname"trigger_hurt"12))
            return
        if (
    is_connected[attacker] && has_weapon[attacker] > -&& is_connected[victim] && get_user_weapon(attacker) == CSW_KNIFE)
            if (
    weapon_fSlashType[has_weapon[attacker]] == || weapon_sSlashType[has_weapon[attacker]] == 0)
                
    SetHamParamFloat(4damage damage_player[has_weapon[attacker]][0])
    }


    public 
    hs_take_damage(victiminflictorattackerFloat:damagedamagebit)
    {
        new 
    classname[32]
        
    pev(attackerpev_classnameclassname31)
        if (
    equal(classname"trigger_hurt"12))
            return
        if (
    is_connected[attacker] && has_weapon[attacker] > -&& get_user_weapon(attacker) == CSW_KNIFE)
            if (
    weapon_fSlashType[has_weapon[attacker]] == || weapon_sSlashType[has_weapon[attacker]] == 0)
                
    SetHamParamFloat(4damage damage_hostage[has_weapon[attacker]][0])
    }

    public 
    ent_take_damage(victiminflictorattackerFloat:damagedamagebit)
    {
        new 
    classname[32]
        
    pev(attackerpev_classnameclassname31)
        if (
    equal(classname"trigger_hurt"12))
            return
        if (
    is_connected[attacker] && has_weapon[attacker] > -&& get_user_weapon(attacker) == CSW_KNIFE)
            if (
    weapon_fSlashType[has_weapon[attacker]] == || weapon_sSlashType[has_weapon[attacker]] == 0)
                
    SetHamParamFloat(4damage damage_entity[has_weapon[attacker]][0])
    }

    public 
    fw_BotUpdate(id)
    {
        if (!
    is_user_alive(id))
            return 
        if (
    get_user_weapon(id) != CSW_KNIFE)
            return
        if (
    g4u_get_user_zombie(id))
            return
        if (
    has_weapon[id] < 0)
        {
            new 
    Float:next_attack get_pdata_float(idm_flNextAttack5)
            if (
    next_attack <= 0.0)
                
    set_pdata_float(idm_flNextAttack0.0001)
            if (
    is_attacking[id])
            {
                new 
    Sequence pev(idpev_sequence)
                if (
    Sequence == 73)
                    
    set_pev(idpev_sequence74)
                if (
    Sequence == 75)
                    
    set_pev(idpev_sequence76)
            }
            
    //return FMRES_HANDLED
            
        
    }
        if (
    has_weapon[id] > -1)
        {
            new 
    Float:next_attack get_pdata_float(idm_flNextAttack5)
            if (
    next_attack <= 0.0)
            {
                
    set_pdata_float(idm_flNextAttack0.0001)
            
    //    return FMRES_HANDLED
            
    }
            if (
    is_attacking[id])
            {
                new 
    Sequence pev(idpev_sequence)
                if (
    Sequence == 73)
                    
    set_pev(idpev_sequence74)
                if (
    Sequence == 75)
                    
    set_pev(idpev_sequence76)
            }    
        }
    }

    stock buy_weapon(idweaponid)
    {
        if (!
    is_user_alive(id))
            return 
    PLUGIN_HANDLED
        
    if (g4u_get_user_zombie(id))
        {
            
    client_print(idprint_center"[G4U MSG] Vu khi nay khong danh cho Zombie hoac Ghost")
            return 
    PLUGIN_HANDLED
        
    }
        if (
    weaponid g_weapon_count)
            return 
    PLUGIN_HANDLED
        
    if (!g4u_get_zombie_toggle() && !get_cvar_num("g4u_option/death_match/active") && !get_cvar_num("sgm_option/active"))
        {
            if (!(
    cs_get_user_mapzones(id) & CS_MAPZONE_BUY))
            {
                
    client_print(idprint_chat"[G4U MSG] Ban chi trang bi duoc %s khi o Cua Hang"weapon_name[weaponid])
                return 
    PLUGIN_HANDLED
            
    }
        }
        if (
    g4u_get_level(id) < weapon_level[weaponid])
        {
            
    //new need_to_level[256]
            //g4u_get_level_name(weapon_level[weaponid], need_to_level, 255)
            
    client_print(idprint_center"[G4U MSG] Ban khong du level de trang bi %s"weapon_name[weaponid])
            return 
    PLUGIN_HANDLED
            
        
    }
        new 
    money cs_get_user_money(id)
        new 
    ent find_ent_by_owner(-1"weapon_knife"id)
        if (
    weapon_cost_type[weaponid] == 1)
        {
            if (
    money >= weapon_cost[weaponid])
            {
                if (!
    user_has_weapon(idCSW_KNIFE))
                    
    fm_give_item(id"weapon_knife")
                
    has_weapon[id] = weaponid
                engclient_cmd
    (id"weapon_knife")
                
    ExecuteHamB(Ham_Item_Deployent)
                
    reset_knife(id)
                
    engclient_cmd(id"lastinv")
                
    cs_set_user_money(idmoney weapon_cost[weaponid], 1)
                
    client_print(idprint_chat"[G4U MSG] Ban da trang bi %s"weapon_name[weaponid])
                
    ExecuteForward(g_knifeg_resultidweaponid)
                return 
    PLUGIN_HANDLED
            
    }
        }
        if (
    weapon_cost_type[weaponid] == 2)
        {
            new 
    coin g4u_get_user_coin(id)
            if (
    coin >= weapon_cost[weaponid])
            {
                if (!
    user_has_weapon(idCSW_KNIFE))
                    
    fm_give_item(id"weapon_knife")
                
    has_weapon[id] = weaponid
                engclient_cmd
    (id"weapon_knife")
                
    ExecuteHamB(Ham_Item_Deployent)
                
    reset_knife(id)
                
    engclient_cmd(id"lastinv")
                
    g4u_set_user_coin(idg4u_get_user_coin(id) - weapon_cost[weaponid])
                
    client_print(idprint_chat"[G4U MSG] Ban da trang bi %s"weapon_name[weaponid])
                
    ExecuteForward(g_knifeg_resultidweaponid)
                return 
    PLUGIN_HANDLED
            
    }
        }
        return 
    PLUGIN_HANDLED
    }
                
    stock fm_give_item(index, const item[]) {
        if (!
    equal(item"weapon_"7) && !equal(item"ammo_"5) && !equal(item"item_"5) && !equal(item"tf_weapon_"10))
            return 
    0;

        new 
    ent fm_create_entity(item)
        if (!
    pev_valid(ent))
            return 
    0;

        new 
    Float:origin[3];
        
    pev(indexpev_originorigin);
        
    set_pev(entpev_originorigin);
        
    set_pev(entpev_spawnflagspev(entpev_spawnflags) | SF_NORESPAWN);
        
    dllfunc(DLLFunc_Spawnent);

        new 
    save pev(entpev_solid);
        
    dllfunc(DLLFunc_Touchentindex);
        if (
    pev(entpev_solid) != save)
            return 
    ent;

        
    engfunc(EngFunc_RemoveEntityent);

        return -
    1;
    }

    stock fm_create_entity(const classname[])
        return 
    engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocStringclassname))

    stock fm_find_ent_by_owner(index, const classname[], ownerjghgtype 0) {
        new 
    strtype[11] = "classname"ent index;
        switch (
    jghgtype) {
            case 
    1strtype "target";
            case 
    2strtype "targetname";
        }

        while ((
    ent engfunc(EngFunc_FindEntityByStringentstrtypeclassname)) && pev(entpev_owner) != owner) {}

        return 
    ent;
    }
                
    stock fm_remove_entity_name(const classname[]) {
        new 
    ent = -1num 0;
        while ((
    ent fm_find_ent_by_class(entclassname)))
            
    num += fm_remove_entity(ent);

        return 
    num;
    }

    stock str_count(const str[], searchchar)
    {
        new 
    counti
        
    //count = 0
        
        
    for (0<= strlen(str); i++)
        {
            if(
    str[i] == searchchar)
                
    count++
        }
        
        return 
    count;
    }

    stock fm_find_ent_by_class(index, const classname[])
        return 
    engfunc(EngFunc_FindEntityByStringindex"classname"classname

    stock fm_remove_entity(index)
        return 
    engfunc(EngFunc_RemoveEntityindex)

    stock fm_set_user_origin(indexorigin[3]) {
        new 
    Float:orig[3];
        
    IVecFVec(originorig);
        return 
    fm_entity_set_origin(indexorig)
    }

    stock fm_entity_set_origin(index, const Float:origin[3]) {
        new 
    Float:mins[3], Float:maxs[3];
        
    pev(indexpev_minsmins);
        
    pev(indexpev_maxsmaxs);
        
    engfunc(EngFunc_SetSizeindexminsmaxs);
        return 
    engfunc(EngFunc_SetOriginindexorigin);
    }

    stock SendWeaponAnim(idiAnim)
    {
        
    set_pev(idpev_weaponanimiAnim)
        
    message_begin(MSG_ONE_UNRELIABLESVC_WEAPONANIM_id)
        
    write_byte(iAnim)
        
    write_byte(g4u_character_hand(id))
        
    message_end()
        
    /*new ent = find_ent_by_owner(-1, "weapon_knife", id)
        if (!ent)
            return
        ExecuteHamB(Ham_Weapon_SendWeaponAnim, ent, iAnim, 0, g4u_character_hand(id))*/
    }

    stock show_weapon_now(idpage)
    {
        new 
    start page 7
        
    new end = (page 7) + 7
        
    static menu[8192], len
        len 
    0
        
    new count 1
        
    if (end g_weapon_count)
            
    end g_weapon_count
        len 
    += formatex(menu[len], sizeof menu len"\y[G4U SHOP - MELEE WEAPON]^n")
        for (new 
    startendi++)
        {
            
    //new level_name[256]
            //g4u_get_level_name(weapon_level[i], level_name, 255)
            
    if (weapon_cost_type[i] == 1)
                
    len += formatex(menu[len], sizeof menu len"^n\w%d. \r%s \w[MONEY] %d \w[LEVEL]: %d"countweapon_name[i], weapon_cost[i], weapon_level[i])
            if (
    weapon_cost_type[i] == 2)
                
    len += formatex(menu[len], sizeof menu len"^n\w%d. \r%s \y[COIN]: %d \w[LEVEL]: %d"countweapon_name[i], weapon_cost[i], weapon_level[i])
            
    count++
        }
        
    len += formatex(menu[len], sizeof menu len"^n^n\y8.Back^n\w9.Next^n\r0.Exit")
        
    show_menu(idknivesmenu, -1"[MELEE LIST]")
    }

    stock fm_set_rendering(entityfx kRenderFxNone255255255render kRenderNormalamount 16) {
        new 
    Float:RenderColor[3];
        
    RenderColor[0] = float(r);
        
    RenderColor[1] = float(g);
        
    RenderColor[2] = float(b);

        
    set_pev(entitypev_renderfxfx);
        
    set_pev(entitypev_rendercolorRenderColor);
        
    set_pev(entitypev_rendermoderender);
        
    set_pev(entitypev_renderamtfloat(amount));

        return 
    1;
    }

    stock ham_strip_weapon(id,weapon[])
    {
        if(!
    equal(weapon,"weapon_",7)) return 0;
        
        new 
    wId get_weaponid(weapon);
        if(!
    wId) return 0;
        
        new 
    wEnt;
        while((
    wEnt engfunc(EngFunc_FindEntityByStringwEnt"classname"weapon)) && pev(wEntpev_owner) != id) {}
        if(!
    wEnt) return 0;
        
        new 
    iTmp;
        if(
    get_user_weapon(idiTmpiTmp) == wIdExecuteHamB(Ham_Weapon_RetireWeaponwEnt);
        
        if(!
    ExecuteHamB(Ham_RemovePlayerItemidany:wEnt)) return 0;
        
        
    ExecuteHamB(Ham_Item_KillwEnt);
        
    set_pev(idpev_weaponspev(idpev_weapons) & ~(1<<wId));
        
        return 
    1;
    }

    stock reset_knife(id)
    {
        
    message_begin(MSG_ONEget_user_msgid("CurWeapon"), _id)
        
    write_byte(1)
        
    write_byte(CSW_KNIFE)
        
    write_byte(1)
        
    message_end()
        
    emessage_begin(MSG_ONEget_user_msgid("CurWeapon"), _id)
        
    ewrite_byte(1)
        
    ewrite_byte(CSW_KNIFE)
        
    ewrite_byte(1)
        
    emessage_end()
    }

    stock SlashKnife(idFloat:RangeFloat:DamageFloat:DamageHostageFloat:DamageEntity)
    {
        if (!
    is_user_alive(id))
            return
        if (
    get_user_weapon(id) != CSW_KNIFE)
            return
        if (!
    user_has_weapon(idCSW_KNIFE))
            return
        if (
    has_weapon[id] < 0)
            return
        new 
    iOrigin[3], tr
        get_user_origin
    (idiOrigin3)
        new 
    Float:fAimOrigin[3], Float:fOrigin[3]
        
    IVecFVec(iOriginfAimOrigin)
        new 
    iAim[3]
        
    get_user_origin(idiAim1)
        
    //pev(id, pev_origin, fOrigin)
        
    IVecFVec(iAimfOrigin)
        new 
    players[32], number
        get_players
    (playersnumber"a")
        new 
    ent find_ent_by_owner(-1"weapon_knife"id)
        new 
    targetbody
        get_user_aiming
    (idtargetbody)
        new 
    hitplace
        
    new g_IgnoreEnt = -1000000000
        
    if(target && target <= get_maxplayers())
        {    
            new 
    Float:RealDistance vector_distance(fOriginfAimOrigin)
            if (
    RealDistance <= Range)
            {
                
    g_IgnoreEnt target
                
    if (body != 8)
                {
                    if (!
    get_cvar_num("mp_friendlyfire"))
                        if (
    get_user_team(id) == get_user_team(target))
                            return
                    new 
    msgid get_user_msgid("DeathMsg")
                    new 
    msgblock get_msg_block(msgid)
                    
    set_msg_block(msgidBLOCK_ONCE);    
                    new 
    Float:fTmpDmg Damage - (Damage Range) * RealDistance;
                    new 
    tr_result
                    engfunc
    (EngFunc_TraceLinefOriginfAimOriginDONT_IGNORE_MONSTERSidtr_result)
                    
    ExecuteHamB(Ham_TakeDamagetargetentidfTmpDmgDMG_SLASH)
                    
    set_msg_block(msgidmsgblock)
                    
    //fakedamage(target, "", damage , DMG_BULLET)
                    
    if (body == HIT_HEAD)
                        
    hitplace 1
                    
    if (body != HIT_HEAD)
                        
    hitplace 0
                    emit_sound
    (targetCHAN_AUTOweapon_hitbody[has_weapon[id]], 1.0ATTN_NORM0PITCH_NORM)
                    if (!
    is_user_alive(target))
                    {
                        
    g4u_set_knife_kill(idhitplace)
                        
    ExecuteForward(g_knife_killg_resultidtargethitplace)
                        
    //make_deathmsg(id, target, body, "knife")
                        
    make_deathmsg(idtargethitplaceweapon_hud_kill[has_weapon[id]])
                        
    //ExecuteHamB(Ham_TraceAttack, target, id, def_second_dmg, fRetVec, tr_result, DMG_SLASH)
                    
    }
                }
                else
                {
                    new 
    random_sound random_num(12)
                    new 
    random_file[256]
                    
    format(random_file255"weapons/ric_metal-%d.wav"random_sound)
                    
    emit_sound(targetCHAN_AUTOrandom_file1.0ATTN_NORM0PITCH_NORM)
                }
            } 
        }
        else 
        {
            if(
    target)
            {
                
    g_IgnoreEnt target
                
    new Float:RealDistance vector_distance(fOriginfAimOrigin)
                if (
    RealDistance <= Range)
                {
                    new 
    classname[32]
                    
    pev(targetpev_classnameclassname31)
                    if (
    equal(classname"hostage_entity"14) || equal(classname"monster_scientist"17))
                    {
                        if (
    pev(targetpev_iuser1) < 1)
                        {
                            
    emit_sound(targetCHAN_AUTOweapon_hitbody[has_weapon[id]], 1.0ATTN_NORM0PITCH_NORM)
                            new 
    Float:fTmpDmg DamageHostage - (DamageHostage Range) * RealDistance;
                            
    ExecuteHamB(Ham_TakeDamagetargetent idfTmpDmg DMG_SLASH)
                        }
                    }
                    if (
    equal(classname"func_breakable"14 ) || equal(classname"func_pushable"13))
                    {
                        new 
    flags pev(targetpev_spawnflags)
                        if (
    flags != SF_BREAK_TRIGGER_ONLY)
                        {
                            new 
    Float:fTmpDmg DamageEntity - (DamageEntity Range) * RealDistance;
                            
    ExecuteHamB(Ham_TakeDamagetargetentidfTmpDmgDMG_SLASH)
                        }
                        
    emit_sound(targetCHAN_AUTOweapon_hitwall[has_weapon[id]], 1.0ATTN_NORM0PITCH_NORM)
                    }
                } 
            }
            else 
            {
                new 
    Float:RealDistance vector_distance(fOriginfAimOrigin)
                if (
    RealDistance <= Range)
                    
    emit_sound(idCHAN_AUTOweapon_hitwall[has_weapon[id]], 1.0ATTN_NORM0PITCH_NORM)
            }
        }
        for (new 
    0numberi++)
        {
            new 
    iPlayer players[i]
            new 
    Float:pOrigin[3]
            
    pev(iPlayerpev_originpOrigin)
            if (!
    is_in_viewcone(idpOrigin))
                continue
            
    // Find X position
            
    new Float:A1 = (fOrigin[1] - pOrigin[1]) * fOrigin[0] + (pOrigin[0] - fOrigin[0]) * fOrigin[1] - (pOrigin[0] - fOrigin[0]) * fAimOrigin[1]
            new 
    Float:A2 fOrigin[1] - pOrigin[1]
            new 
    Float:XPOS A1 A2
            pOrigin
    [0] = XPOS
            pOrigin
    [1] = fAimOrigin[1]
            
    pOrigin[2] = fAimOrigin[2]
            
    engfunc(EngFunc_TraceLinefOriginpOriginDONT_IGNORE_MONSTERSidtr)
            new 
    hitent get_tr2(trTR_pHit)
            if (
    hitent == iPlayer)
            {
                new 
    Float:vEnd[3]
                
    get_tr2(trTR_vecEndPosvEnd)
                new 
    Float:RealDistance vector_distance(fOriginvEnd)
                if (
    RealDistance <= Range)
                {
                    if (
    iPlayer == g_IgnoreEnt)
                        continue
                    new 
    iHitGroup get_tr2(trTR_iHitgroup)
                    if (
    iHitGroup == 8// Hit shield?
                    
    {
                        new 
    random_sound random_num(12)
                        new 
    random_file[256]
                        
    format(random_file255"weapons/ric_metal-%d.wav"random_sound)
                        
    emit_sound(iPlayerCHAN_AUTOrandom_file1.0ATTN_NORM0PITCH_NORM)
                        continue
                    }
                    
    emit_sound(iPlayerCHAN_AUTOweapon_hitbody[has_weapon[id]], 1.0ATTN_NORM0PITCH_NORM)
                    new 
    msgid get_user_msgid("DeathMsg")
                    new 
    msgblock get_msg_block(msgid)
                    
    set_msg_block(msgidBLOCK_ONCE);
                    new 
    Float:fTmpDmg Damage - (Damage Range) * RealDistance;
                    if (!
    is_connected[iPlayer])
                        continue
                    
    ExecuteHamB(Ham_TakeDamageiPlayerent idfTmpDmg DMG_SLASH)
                    
    set_msg_block(msgidmsgblock)
                    
    //ExecuteHamB(Ham_TraceAttack, iPlayer, id, fTmpDmg, vEnd, tr, DMG_SLASH)
                    
    if (!is_user_alive(iPlayer))
                    {
                        if (
    iHitGroup == HIT_HEAD)
                        {
                            
    make_deathmsg(idiPlayer1weapon_hud_kill[has_weapon[id]])
                            
    ExecuteForward(g_knife_killg_resultidiPlayer1)
                        }
                        else     
                        {
                            
    make_deathmsg(idiPlayer0weapon_hud_kill[has_weapon[id]])
                            
    ExecuteForward(g_knife_killg_resultidiPlayer0)
                        }
                    }
                }
            }
        }
        for (new 
    iEnt 0iEnt entity_count(); iEnt++)
        {
            if (!
    iEnt || !pev_valid(iEnt))
                continue
            new 
    Float:pOrigin[3]
            
    pev(iEntpev_originpOrigin)
            if (!
    is_in_viewcone(idpOrigin))
                continue
            if (
    pev(iEntpev_takedamage) == DAMAGE_NO)
                continue
            new 
    Float:A1 = (fOrigin[1] - pOrigin[1]) * fOrigin[0] + (pOrigin[0] - fOrigin[0]) * fOrigin[1] - (pOrigin[0] - fOrigin[0]) * fAimOrigin[1]
            new 
    Float:A2 fOrigin[1] - pOrigin[1]
            new 
    Float:XPOS A1 A2
            pOrigin
    [0] = XPOS
            pOrigin
    [1] = fAimOrigin[1]
            
    pOrigin[2] = fAimOrigin[2]
            
    engfunc(EngFunc_TraceLinefOriginpOriginDONT_IGNORE_MONSTERSidtr)
            new 
    hitent get_tr2(trTR_pHit)
            if (
    hitent == iEnt)
            {
                new 
    Float:vEnd[3]
                
    get_tr2(trTR_vecEndPosvEnd)
                new 
    Float:RealDistance vector_distance(fOriginvEnd)
                if (
    RealDistance <= Range)
                {
                    new 
    classname[32]
                    
    pev(iEntpev_classnameclassname31)
                    new 
    Float:fTmpDmg
                    
    if (g_IgnoreEnt == iEnt)
                        continue
                    if (
    equal(classname"player"))
                        continue
                    else if (
    equal(classname"hostage_entity") || equal(classname"monster_scientist"))
                    {
                        if (
    pev(iEntpev_iuser1) > 0)
                            continue
                        
    emit_sound(iEntCHAN_AUTOweapon_hitbody[has_weapon[id]], 1.0ATTN_NORM0PITCH_NORM)
                        
    fTmpDmg DamageHostage - (DamageHostage Range) * RealDistance;
                        
    ExecuteHamB(Ham_TakeDamageiEntent idfTmpDmg DMG_SLASH)
                    }                    
                    else if (
    equal(classname"func_breakable") || equal(classname"func_pushable"))
                    {
                        
    emit_sound(iEntCHAN_AUTOweapon_hitwall[has_weapon[id]], 1.0ATTN_NORM0PITCH_NORM)
                        
    fTmpDmg DamageEntity - (DamageEntity Range) * RealDistance;
                        
    ExecuteHamB(Ham_TakeDamageiEntent idfTmpDmg DMG_SLASH)
                    }
                    else 
                    {
                        
    emit_sound(iEntCHAN_AUTOweapon_hitwall[has_weapon[id]], 1.0ATTN_NORM0PITCH_NORM)
                        
    fTmpDmg DamageEntity - (DamageEntity Range) * RealDistance;
                        
    ExecuteHamB(Ham_TakeDamageiEntent idfTmpDmg DMG_SLASH)
                    }
                }
            }
        }
    }

    stock SlashKnifeNormal(idFloat:RangeFloat:DamageFloat:DamageHostageFloat:DamageEntity)
    {
        if (!
    is_user_alive(id))
            return
        if (
    get_user_weapon(id) != CSW_KNIFE)
            return
        if (!
    user_has_weapon(idCSW_KNIFE))
            return
        new 
    iOrigin[3], tr
        get_user_origin
    (idiOrigin3)
        new 
    Float:fAimOrigin[3], Float:fOrigin[3]
        
    IVecFVec(iOriginfAimOrigin)
        
    //pev(id, pev_origin, fOrigin)
        
    new iEyeOrigin[3]
        
    get_user_origin(idiEyeOrigin1)
        
    IVecFVec(iEyeOriginfOrigin)
        new 
    players[32], number
        get_players
    (playersnumber"a")
        new 
    ent find_ent_by_owner(-1"weapon_knife"id)
        new 
    targetbody
        get_user_aiming
    (idtargetbody)
        new 
    hitplace
        
    new g_IgnoreEnt = -1000000000
        
    if(target && target <= get_maxplayers())
        {    
            new 
    Float:RealDistance vector_distance(fOriginfAimOrigin)
            if (
    RealDistance <= Range)
            {
                
    g_IgnoreEnt target
                
    if (body != 8)
                {
                    if (!
    get_cvar_num("mp_friendlyfire"))
                        if (
    get_user_team(id) == get_user_team(target))
                            return
                    new 
    msgid get_user_msgid("DeathMsg")
                    new 
    msgblock get_msg_block(msgid)
                    
    set_msg_block(msgidBLOCK_ONCE);    
                    new 
    Float:fTmpDmg Damage - (Damage Range) * RealDistance;
                    new 
    tr_result
                    engfunc
    (EngFunc_TraceLinefOriginfAimOriginDONT_IGNORE_MONSTERSidtr_result)
                    
    ExecuteHamB(Ham_TakeDamagetargetentidfTmpDmgDMG_SLASH)
                    
    set_msg_block(msgidmsgblock)
                    
    //fakedamage(target, "", damage , DMG_BULLET)
                    
    if (body == HIT_HEAD)
                        
    hitplace 1
                    
    if (body != HIT_HEAD)
                        
    hitplace 0
                    
    new random_sound random_num(14)
                    new 
    random_file[256]
                    
    format(random_file255"weapons/knife_hit%d.wav"random_sound)
                    if (!
    is_user_alive(target))
                    {
                        
    g4u_set_knife_kill(idhitplace)
                        
    ExecuteForward(g_knife_killg_resultidtargethitplace)
                        
    //make_deathmsg(id, target, body, "knife")
                        
    make_deathmsg(idtargethitplace"knife")
                        
    //ExecuteHamB(Ham_TraceAttack, target, id, def_second_dmg, fRetVec, tr_result, DMG_SLASH)
                    
    }
                }
                else
                {
                    new 
    random_sound random_num(12)
                    new 
    random_file[256]
                    
    format(random_file255"weapons/ric_metal-%d.wav"random_sound)
                    
    emit_sound(targetCHAN_AUTOrandom_file1.0ATTN_NORM0PITCH_NORM)
                }
            } 
        }
        else 
        {
            if(
    target)
            {
                
    g_IgnoreEnt target
                
    new Float:RealDistance vector_distance(fOriginfAimOrigin)
                if (
    RealDistance <= Range)
                {
                    new 
    classname[32]
                    
    pev(targetpev_classnameclassname31)
                    if (
    equal(classname"hostage_entity"14) || equal(classname"monster_scientist"17))
                    {
                        if (
    pev(targetpev_iuser1) < 1)
                        {
                            new 
    random_sound random_num(14)
                            new 
    random_file[256]
                            
    format(random_file255"weapons/knife_hit%d.wav"random_sound)
                            new 
    Float:fTmpDmg DamageHostage - (DamageHostage Range) * RealDistance;
                            
    ExecuteHamB(Ham_TakeDamagetargetent idfTmpDmg DMG_SLASH)
                        }
                    }
                    if (
    equal(classname"func_breakable"14 ) || equal(classname"func_pushable"13))
                    {
                        new 
    flags pev(targetpev_spawnflags)
                        if (
    flags != SF_BREAK_TRIGGER_ONLY)
                        {
                            new 
    Float:fTmpDmg DamageEntity - (DamageEntity Range) * RealDistance;
                            
    ExecuteHamB(Ham_TakeDamagetargetentidfTmpDmgDMG_SLASH)
                        }
                        
    emit_sound(targetCHAN_AUTO"weapons/knife_hitwall1.wav"1.0ATTN_NORM0PITCH_NORM)
                    }
                } 
            }
            else 
            {
                new 
    Float:RealDistance vector_distance(fOriginfAimOrigin)
                if (
    RealDistance <= Range)
                    
    emit_sound(idCHAN_AUTO"weapons/knife_hitwall1.wav"1.0ATTN_NORM0PITCH_NORM)
            }
        }
        for (new 
    0numberi++)
        {
            new 
    iPlayer players[i]
            new 
    Float:pOrigin[3]
            
    pev(iPlayerpev_originpOrigin)
            if (!
    is_in_viewcone(idpOrigin))
                continue
            
    // Find X position
            
    new Float:A1 = (fOrigin[1] - pOrigin[1]) * fOrigin[0] + (pOrigin[0] - fOrigin[0]) * fOrigin[1] - (pOrigin[0] - fOrigin[0]) * fAimOrigin[1]
            new 
    Float:A2 fOrigin[1] - pOrigin[1]
            new 
    Float:XPOS A1 A2
            pOrigin
    [0] = XPOS
            pOrigin
    [1] = fAimOrigin[1]
            
    pOrigin[2] = fAimOrigin[2]
            
    engfunc(EngFunc_TraceLinefOriginpOriginDONT_IGNORE_MONSTERSidtr)
            new 
    hitent get_tr2(trTR_pHit)
            if (
    hitent == iPlayer)
            {
                new 
    Float:vEnd[3]
                
    get_tr2(trTR_vecEndPosvEnd)
                new 
    Float:RealDistance vector_distance(fOriginvEnd)
                if (
    RealDistance <= Range)
                {
                    if (
    hitent == g_IgnoreEnt)
                        continue
                    new 
    iHitGroup get_tr2(trTR_iHitgroup)
                    if (
    iHitGroup == 8// Hit shield?
                    
    {
                        new 
    random_sound random_num(12)
                        new 
    random_file[256]
                        
    format(random_file255"weapons/ric_metal-%d.wav"random_sound)
                        
    //emit_sound(iPlayer, CHAN_AUTO, random_file, 1.0, ATTN_NORM, 0, PITCH_NORM)
                        
    continue
                    }
                    new 
    random_sound random_num(14)
                    new 
    random_file[256]
                    
    format(random_file255"weapons/knife_hit%d.wav"random_sound)
                    
    //emit_sound(iPlayer, CHAN_AUTO, random_file, 1.0, ATTN_NORM, 0, PITCH_NORM)
                    
    new msgid get_user_msgid("DeathMsg")
                    new 
    msgblock get_msg_block(msgid)
                    
    set_msg_block(msgidBLOCK_ONCE);
                    new 
    Float:fTmpDmg Damage - (Damage Range) * RealDistance;
                    if (!
    is_connected[iPlayer])
                        continue
                    
    ExecuteHamB(Ham_TakeDamageiPlayerent idfTmpDmg DMG_SLASH)
                    
    //ExecuteHamB(Ham_TraceAttack, iPlayer, id, fTmpDmg, vEnd, tr, DMG_SLASH)
                    
    set_msg_block(msgidmsgblock)
                    
    //if (get_tr2(tr, TR_flFraction) <= 1.0)
                    
    if (!is_user_alive(iPlayer))
                    {
                        if (
    iHitGroup == HIT_HEAD)
                        {
                            
    make_deathmsg(idiPlayer1"knife")
                            
    ExecuteForward(g_knife_killg_resultid iPlayer1)
                        }
                        else
                        {
                            
    make_deathmsg(idiPlayer0"knife")
                            
    ExecuteForward(g_knife_killg_resultidiPlayer0)
                        }
                        
                    }
                }
            }
        }
        for (new 
    iEnt 0iEnt entity_count(); iEnt++)
        {
            if (!
    iEnt || !pev_valid(iEnt))
                continue
            new 
    Float:pOrigin[3]
            
    pev(iEntpev_originpOrigin)
            if (!
    is_in_viewcone(idpOrigin))
                continue
            if (
    pev(iEntpev_takedamage) == DAMAGE_NO)
                continue
            new 
    Float:A1 = (fOrigin[1] - pOrigin[1]) * fOrigin[0] + (pOrigin[0] - fOrigin[0]) * fOrigin[1] - (pOrigin[0] - fOrigin[0]) * fAimOrigin[1]
            new 
    Float:A2 fOrigin[1] - pOrigin[1]
            new 
    Float:XPOS A1 A2
            pOrigin
    [0] = XPOS
            pOrigin
    [1] = fAimOrigin[1]
            
    pOrigin[2] = fAimOrigin[2]
            
    engfunc(EngFunc_TraceLinefOriginpOriginDONT_IGNORE_MONSTERSidtr)
            new 
    hitent get_tr2(trTR_pHit)
            if (
    hitent == iEnt)
            {
                new 
    Float:vEnd[3]
                
    get_tr2(trTR_vecEndPosvEnd)
                new 
    Float:RealDistance vector_distance(fOriginvEnd)
                if (
    RealDistance <= Range)
                {
                    new 
    classname[32]
                    
    pev(iEntpev_classnameclassname31)
                    new 
    Float:fTmpDmg
                    
    if (g_IgnoreEnt == hitent)
                        continue
                    if (
    equal(classname"player"))
                        continue
                    else if (
    equal(classname"hostage_entity") || equal(classname"monster_scientist"))
                    {
                        if (
    pev(iEntpev_iuser1) > 0)
                            continue
                        new 
    random_sound random_num(14)
                        new 
    random_file[256]
                        
    format(random_file255"weapons/knife_hit%d.wav"random_sound)
                        
    emit_sound(iEntCHAN_AUTOrandom_file1.0ATTN_NORM0PITCH_NORM)
                        
    fTmpDmg DamageHostage - (DamageHostage Range) * RealDistance;
                        
    ExecuteHamB(Ham_TakeDamageiEntent idfTmpDmg DMG_SLASH)
                    }                    
                    else if (
    equal(classname"func_breakable") || equal(classname"func_pushable"))
                    {
                        
    emit_sound(iEntCHAN_AUTO"weapons/knife_hitwall1.wav"1.0ATTN_NORM0PITCH_NORM)
                        
    fTmpDmg DamageEntity - (DamageEntity Range) * RealDistance;
                        
    ExecuteHamB(Ham_TakeDamageiEntent idfTmpDmg DMG_SLASH)
                    }
                    else 
                    {
                        
    emit_sound(iEntCHAN_AUTO"weapons/knife_hitwall1.wav"1.0ATTN_NORM0PITCH_NORM)
                        
    fTmpDmg DamageEntity - (DamageEntity Range) * RealDistance;
                        
    ExecuteHamB(Ham_TakeDamageiEntent idfTmpDmg DMG_SLASH)
                    }
                }
            }
        }
    [/spoil]

    Để vào trong thẻ php để người khác thấy cho dễ, đôi khi hỏi mà không có câu trả lời cũng có thể là không ai biết trả lời như thế nào :|
     
  9. dias

    dias Mega Man

    Tham gia ngày:
    17/1/10
    Bài viết:
    3,226
    Nơi ở:
    SEOUL
    @buiduchuy:
    - set_hudmessage ( red=200, green=100, blue=0, Float:x=-1.0, Float:y=0.35, effects=0, Float:fxtime=6.0, Float:holdtime=12.0, Float:fadeintime=0.1, Float:fadeouttime=0.2, channel=4 )
     
  10. legiondark

    legiondark Donkey Kong

    Tham gia ngày:
    2/5/11
    Bài viết:
    357
    Nơi ở:
    Skynet !
    Code Đây :|:
    PHP:
    /* Plugin generated by AMXX-Studio */

    #include <amxmodx>
    #include <amxmisc>
    #include <cstrike>
    #include <fakemeta>
    #include <hamsandwich>
    #include <xs>
    #include <csx>
    #include <engine>
    #include <g4u>
    #include <zombie_mod>
    #include <ghost>
    #include <character>
    #define max_wpn 255
    #define task_register_function 52301616
    #define PLUGIN "G4U Knife"
    #define VERSION "1.0"
    #define AUTHOR "Nguyen Duy Linh"
    #define knives (1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<7)|(1<<8)|(1<<9) // Keys: 1234567890
    #define key_menu (1<<9) // Keys: 0
    #define task_execute_my_damage 25251325
    #define TASK_DO_MY_FIRST_ATK 2592
    #define TASK_DO_MY_SECOND_ATK 100000
    #define TASK_CAN_ATK 200300400
    new weapon_name[max_wpn][64]
    new 
    weapon_hud_kill[max_wpn][100]
    new 
    Float:damage_player[max_wpn][2]
    new 
    Float:damage_entity[max_wpn][2], weapon_cost[max_wpn]
    new 
    Float:damage_hostage[max_wpn][2]
    new 
    weapon_level[max_wpn], weapon_cost_type[max_wpn]
    new 
    weapon_v_model[max_wpn][256], weapon_p_model[max_wpn][256]
    new 
    has_weapon[33], weapon_deploy[max_wpn][256], weapon_slash[max_wpn][256]
    new 
    weapon_hitbody[max_wpn][256], weapon_stab[max_wpn][256], weapon_hitwall[max_wpn][256]
    new 
    weapon_fSlashType[max_wpn], weapon_sSlashType[max_wpn]
    new 
    Float:weapon_fRange[max_wpn], Float:weapon_sRange[max_wpn]
    new 
    Float:weapon_deploy_time[max_wpn], Float:weapon_fSlashTime[max_wpn], Float:weapon_sSlashTime[max_wpn]
    new 
    Float:weapon_fDmgDelay[max_wpn], Float:weapon_sDmgDelay[max_wpn]
    new 
    g_weapon_count 0
    new g_page[32], menuid
    new g_knifeg_result
    new bool:ham_cz
    new g_normal_selectedg_new_selected
    new g_KnifefAtkg_KnifesAtk
    new weapon_files[max_wpn][256]
    const 
    Float:def_first_attack 1.0
    const Float:def_second_attack 1.2
    const Float:def_range 67.0
    const Float:def_first_dmg_delay 0.25
    const Float:def_second_dmg_delay 0.5
    const Float:def_second_dmg 100.0
    const Float:def_deploy_time 1.5
    new bool:is_attacking[33]
    new 
    Float:g_fDelay[33]
    new 
    g_knife_kill
    const m_pPlayer            41
    const m_iId                43
    const m_fKnown                44
    const m_flNextPrimaryAttack    46
    const m_flNextSecondaryAttack    47
    const m_flTimeWeaponIdle        48
    const m_iPrimaryAmmoType        49
    const m_iClip                51
    const m_fInReload            54
    const m_fInSpecialReload        55
    const m_fSilent            74
    const m_flNextAttack        83
    const m_rgAmmo_player_Slot0    376
    enum
    {
        
    ANIM_IDLE,
        
    ANIM_SLASH1,
        
    ANIM_SLASH2,
        
    ANIM_DRAW,
        
    ANIM_STAB,
        
    ANIM_STAB_MISS,
        
    ANIM_MIDSLASH1,
        
    ANIM_MIDSLASH2
    }

    new 
    Float:g_fDeploy[33], Float:g_fAtkTime[33], Float:g_sAtkTime[33]
    new 
    fUserAnim[64]
    new 
    bool:is_connected[33]
    new 
    weapon_model_index[max_wpn]
    new 
    Float:g_sDelay[33]
    new 
    Float:weapon_weight[max_wpn], Float:weapon_dspeed[max_wpn]
    public 
    plugin_natives()
    {
        
    register_native("g4u_equip_knife""_equip_player"1)
        
    register_native("g4u_get_knife_hud""_get_hud"1)
        
    register_native("g4u_force_user_buy_knife""_force_buy"1)
        
    register_native("g4u_user_has_knife""_get_knife"1)
        
    register_native("g4u_get_knife_name""_get_name"1)
        
    register_native("g4u_strip_user_knife""_strip_knife"1)
        
    register_native("g4u_get_knife_amount""_get_amount"1)
        
    register_native("g4u_knifeid_by_model""_knifeid_by_model"1)
        
    register_native("g4u_equip_knife_level""_knife_level"1)
        
    register_native("g4u_get_knife_cost""_knife_cost"1)
        
    register_native("g4u_get_knife_cost_type""_knife_cost_type"1)
        
    register_native("g4u_get_knife_weight""_get_knife_weight"1)
        
    register_native("g4u_get_knife_dspeed""_get_knife_dspeed"1)
    }

    public 
    Float:_get_knife_weight(wid)
    {
        if (
    wid || wid g_weapon_count 1)
            return 
    0.0
        
    return weapon_weight[wid]
    }

    public 
    Float:_get_knife_dspeed(wid)
    {
        if (
    wid || wid g_weapon_count 1)
            return 
    0.0
        
    return weapon_dspeed[wid]
    }

    public 
    _knife_cost(wid)
    {
        if (
    wid || wid g_weapon_count 1)
            return -
    1
        
    return weapon_cost[wid]
    }

    public 
    _knife_cost_type(wid)
    {
        if (
    wid || wid g_weapon_count 1)
            return -
    1
        
    return weapon_cost_type[wid]
    }

    public 
    plugin_init() 
    {
        
    register_plugin(PLUGINVERSIONAUTHOR)
        
    register_clcmd("g4u_knife""cmdbuy")
        
    register_clcmd("g4u_kmenu""cmdmenu")
        
    register_event("CurWeapon","checkWeapon","b","1=1")
        
    register_event("35""event_weapon_anim""b")
        
    register_message(get_user_msgid("DeathMsg"), "func_death")
        
    register_message(get_user_msgid("WeapPickup"),"message_weappickup")
        
    //register_message(get_user_msgid("HideWeapon"), "message_hideweapon")
        
    menuid register_menuid("[MELEE LIST]")
        
    g_knife CreateMultiForward("g4u_player_equip_knife"ET_IGNOREFP_CELLFP_CELL)
        
    g_knife_kill CreateMultiForward("g4u_knife_hit"ET_IGNOREFP_CELLFP_CELLFP_CELL)
        
    g_normal_selected CreateMultiForward("g4u_normal_knife_selected"ET_IGNOREFP_CELL)
        
    g_new_selected CreateMultiForward("g4u_new_knife_selected"ET_IGNOREFP_CELLFP_CELLFP_STRINGFP_STRINGFP_STRING)
        
    g_KnifefAtk CreateMultiForward("g4u_knife_first_atk"ET_IGNOREFP_CELL)
        
    g_KnifesAtk CreateMultiForward("g4u_knife_second_atk"ET_IGNOREFP_CELL)
        
    register_menucmd(menuidknives"show_weapon")
        
    register_forward(FM_EmitSound"fw_emitsound")
        
    register_forward(FM_CmdStart"fw_cmdstart")
        
    register_forward(FM_UpdateClientData"fm_update_data"1)
        
    RegisterHam(Ham_Player_PreThink"player""pl_prethink")
        
    RegisterHam(Ham_Spawn"player""pl_spawn"1)
        
    RegisterHam(Ham_Use"player_weaponstrip""fw_strip")
        
    RegisterHam(Ham_Item_Deploy"weapon_knife""fw_KnifeDeploy")
        
    RegisterHam(Ham_TakeDamage"player""pl_take_damage")
        
    RegisterHam(Ham_TakeDamage"hostage_entity""hs_take_damage")
        
    RegisterHam(Ham_TakeDamage"monster_scientist""hs_take_damage")
        
    RegisterHam(Ham_TakeDamage"func_breakable""ent_take_damage")
        
    RegisterHam(Ham_TakeDamage"func_pushable""ent_take_damage")

    }

    public 
    plugin_precache()
    {
        new 
    con_dir[256], trashmapname[32]
        
    get_mapname(mapname31)
        
    ham_cz false
        get_configsdir
    (con_dir255)
        new 
    manager[256]
        
    format(manager255"%s/g4u_weapon/knife/weapon_config/manager.cfg"con_dir)
        if (
    file_exists(manager))
        {
            for (new 
    0file_size(manager1); i++)
            {
                if (
    max_wpn)
                {
                    new 
    con_file[256], txt[256], len
                    read_file
    (manageritxt255len)
                    
    format(con_file255"%s/g4u_weapon/knife/weapon_config/%s.ini"con_dirtxt)
                    if (
    file_exists(con_file))
                    {
                        new 
    text[256]
                        
    read_file(con_file0text255trash)
                        
    replace(text255"[name]""")
                        
    format(weapon_name[g_weapon_count], 255"%s"text)
                        
    read_file(con_file1text255trash)
                        
    replace(text255"[first-type]""")
                        
    weapon_fSlashType[g_weapon_count] = str_to_num(text)
                        
    read_file(con_file2text255trash)
                        
    replace(text255"[second-type]""")
                        
    weapon_sSlashType[g_weapon_count] = str_to_num(text)
                        new 
    fArg[32], sArg[32]
                        
    read_file(con_file3text255trash)
                        
    replace(text255"[range]""")
                        
    parse(textfArg31sArg31)
                        
    weapon_fRange[g_weapon_count] = str_to_float(fArg)
                        
    weapon_sRange[g_weapon_count] = str_to_float(sArg)
                        
    read_file(con_file4text255trash)
                        
    replace(text255"[atk-time]""")
                        
    parse(textfArg31sArg31)
                        
    weapon_fSlashTime[g_weapon_count] = str_to_float(fArg)
                        
    weapon_sSlashTime[g_weapon_count] = str_to_float(sArg)
                        
    read_file(con_file5text255trash)
                        
    replace(text255"[dmg-delay]""")
                        
    parse(textfArg31sArg31)
                        
    weapon_fDmgDelay[g_weapon_count] = str_to_float(fArg)
                        
    weapon_sDmgDelay[g_weapon_count] = str_to_float(sArg)
                        
    read_file(con_file6text255trash)
                        
    replace(text255"[hud_kill]""")
                        
    format(weapon_hud_kill[g_weapon_count], 255"%s"text)
                        
    read_file(con_file7text255trash)
                        
    replace(text255"[damage_player]""")
                        
    parse(textfArg31sArg31)
                        
    damage_player[g_weapon_count][0] = str_to_float(fArg)
                        
    damage_player[g_weapon_count][1] = str_to_float(sArg)
                        
    read_file(con_file8text255trash)
                        
    replace(text255"[damage_entity]""")
                        
    parse(textfArg31sArg31)
                        
    damage_entity[g_weapon_count][0] = str_to_float(fArg)
                        
    damage_entity[g_weapon_count][1] = str_to_float(sArg)
                        
    read_file(con_file9text255trash)
                        
    replace(text255"[damage_hostage]""")
                        
    parse(textfArg31sArg31)
                        
    damage_hostage[g_weapon_count][0] = str_to_float(fArg)
                        
    damage_hostage[g_weapon_count][1] = str_to_float(sArg)
                        
    read_file(con_file10text255trash)
                        
    replace(text255"[cost_type]""")
                        
    weapon_cost_type[g_weapon_count] = str_to_num(text)
                        if (
    weapon_cost_type[g_weapon_count] != && weapon_cost_type[g_weapon_count] != 2)
                            
    weapon_cost_type[g_weapon_count] = 1
                        read_file
    (con_file11text255trash)
                        
    replace(text255"[cost]""")
                        
    weapon_cost[g_weapon_count] = str_to_num(text)
                        if (
    weapon_cost[g_weapon_count] < 0)
                            
    weapon_cost[g_weapon_count] = 10
                        read_file
    (con_file12text255trash)
                        
    replace(text255"[model]""")
                        
    format(weapon_p_model[g_weapon_count], 255"models/g4u_wpn/%s/p_%s.mdl"texttext)
                        
    format(weapon_v_model[g_weapon_count], 255"models/g4u_wpn/%s/v_%s.mdl"texttext)
                        
    weapon_model_index[g_weapon_count] = precache_model(weapon_v_model[g_weapon_count])
                        
    precache_model(weapon_p_model[g_weapon_count])
                        
    read_file(con_file13text255trash)
                        
    replace(text255"[level]""")
                        
    weapon_level[g_weapon_count] = str_to_num(text)
                        if (
    weapon_level[g_weapon_count] > g4u_get_max_level())
                            
    weapon_level[g_weapon_count] = g4u_get_max_level()
                        
    read_file(con_file14text255trash)
                        
    replace(text255"[deploy-sound]""")
                        
    format(weapon_deploy[g_weapon_count], 255"weapons/g4u_wpn/%s.wav"text)
                        
    read_file(con_file15text255trash)
                        
    replace(text255"[slash-sound]""")
                        
    format(weapon_slash[g_weapon_count], 255"weapons/g4u_wpn/%s.wav"text)
                        
    read_file(con_file16text255trash)
                        
    replace(text255"[hitbody-sound]""")
                        
    format(weapon_hitbody[g_weapon_count], 255"weapons/g4u_wpn/%s.wav"text)
                        
    read_file(con_file17text255trash)
                        
    replace(text255"[stab-sound]""")
                        
    format(weapon_stab[g_weapon_count], 255"weapons/g4u_wpn/%s.wav"text)
                        
    read_file(con_file18text255trash)
                        
    replace(text255"[hitwall-sound]""")
                        
    format(weapon_hitwall[g_weapon_count], 255"weapons/g4u_wpn/%s.wav"text)
                        
    precache_sound(weapon_deploy[g_weapon_count])
                        
    precache_sound(weapon_slash[g_weapon_count])
                        
    precache_sound(weapon_hitbody[g_weapon_count])
                        
    precache_sound(weapon_stab[g_weapon_count])
                        
    precache_sound(weapon_hitwall[g_weapon_count])
                        
    read_file(con_file19text255trash)
                        
    replace(text255"[deploy-time]""")
                        
    weapon_deploy_time[g_weapon_count] = str_to_float(text)
                        
    format(weapon_files[g_weapon_count], 255"%s/g4u_weapon/knife/weapon_config/%s"con_dirtxt)
                        
    read_file(con_file20text255trash)
                        
    replace(text255"[weight]""")
                        
    weapon_weight[g_weapon_count] = str_to_float(text)
                        
    read_file(con_file21text255trash)
                        
    replace(text255"[dspeed""")
                        
    weapon_dspeed[g_weapon_count] = str_to_float(text)
                        
    g_weapon_count++
                    }
                }
            }
        }
    }

    public 
    _equip_player(idweaponidshow_message)
    {
        if (
    weaponid g_weapon_count)
            return
        if (
    weaponid 0)
            return
        if (!
    pev_valid(id))
            return
        if (
    g4u_get_user_zombie(id))
            return
        
    has_weapon[id] = weaponid
        
    if (!user_has_weapon(idCSW_KNIFE))
            
    fm_give_item(id"weapon_knife")
        
    engclient_cmd(id"weapon_knife")
        
    reset_knife(id)
        
    }

    public 
    _get_hud(weaponidhud[], len)
    {
        
    param_convert(2)
        if (
    weaponid || weaponid g_weapon_count)
            
    format(hudlen"NULL")
        
    format(hudlenweapon_hud_kill[weaponid])
    }

    public 
    _force_buy(idweaponid)
        
    buy_weapon(idweaponid)

    public 
    _get_knife(id)
        return 
    has_weapon[id]
        
    public 
    _get_name(wpnidwpnname[], len)
    {
        
    param_convert(2)
        if (
    wpnid g_weapon_count || wpnid 0)
            
    format(wpnnamelen"NULL")
        else 
    format(wpnnamelen"%s"weapon_name[wpnid])
    }

    public 
    _strip_knife(id)
    {
        
    ham_strip_weapon(id"weapon_knife")
        
    has_weapon[id] = -1
    }    

    public 
    _get_amount()
        return 
    g_weapon_count

    public _knifeid_by_model(const model[], len)
    {
        
    param_convert(1)
        for (new 
    0g_weapon_counti++)
            if (
    equal(modelweapon_v_model[i], len))
                return 
    i
        
    return -1
    }
    stock get_knifeid_by_model(const model[], len)
    {
        
    param_convert(1)
        for (new 
    0g_weapon_counti++)
            if (
    equal(modelweapon_v_model[i], len))
                return 
    i
        
    return -1
    }
    public 
    _knife_level(idmodel[], len)
    {
        
    param_convert(2)
        new 
    weaponid get_knifeid_by_model(modellen)
        if (!
    is_user_alive(id))
            return -
    1
        
    if (g4u_get_user_zombie(id))
        {
            
    client_print(idprint_center"[G4U MSG] Vu khi nay khong danh cho Zombie")
            return -
    1
        
    }
        if (
    weaponid g_weapon_count || weaponid 0)
            return -
    1
        
    if (g4u_get_level(id) < weapon_level[weaponid])
        {
            new 
    need_to_level[256]
            
    g4u_get_level_name(weapon_level[weaponid], need_to_level255)
            
    client_print(idprint_center"[G4U MSG] Ban phai dat %s de trang bi vu khi nay"need_to_level)
            return -
    1
            
        
    }
        
    ham_strip_weapon(id"weapon_knife")
        
    has_weapon[id] = -1
        
    //if (!user_has_weapon(id, CSW_KNIFE))
        //    fm_give_item(id, "weapon_knife")
        //engclient_cmd(id, "weapon_knife")
        //engclient_cmd(id, "weapon_knife")
        //reset_knife(id)
        //set_pev(id, pev_viewmodel2, weapon_v_model[has_weapon[id]])
        //set_pev(id, pev_viewmodel, weapon_v_model[has_weapon[id]])
        //set_pev(id, pev_weaponmodel2, weapon_p_model[has_weapon[id]])
        //set_pev(id, pev_weaponmodel, weapon_p_model[has_weapon[id]])
        // client_print(id, print_chat, "[G4U MSG] Ban da trang bi %s", weapon_name[weaponid])
        
    has_weapon[id] = weaponid
        
    //_equip_player(id, weaponid, 0)
        
    ExecuteForward(g_knifeg_resultidweaponid)
        return 
    1
    }

    public 
    client_connect(id)
    {
        
    has_weapon[id] = -1
    }

    public 
    client_putinserver(id)
    {
        if (
    is_user_bot(id))
            
    set_task(0.1"register_bot_function"id task_register_function)
        
    is_connected[id] = true
    }
                
    public 
    register_bot_function(taskid)
    {
        new 
    id taskid task_register_function
        
    if (pev_valid(id) && !ham_cz && get_cvar_num("bot_quota"))
        {
            
    RegisterHamFromEntity(Ham_Spawnid"pl_spawn"1)
            
    RegisterHamFromEntity(Ham_TakeDamageid"pl_take_damage")
            
    //RegisterHamFromEntity(Ham_Killed, id , "pl_death", 1)
            
    RegisterHamFromEntity(Ham_Player_UpdateClientDataid"fw_BotUpdate")
            
    ham_cz true
        
    }
    }

    public 
    client_death(killervictim)
    {
        if (
    pev_valid(victim))
        {
            
    has_weapon[victim] = -1
            
    new menuindexkeys
            get_user_menu
    (victimmenuindexkeys)
            if (
    menuindex == menuid)
                
    client_cmd(victim"slot10")
        }
        
    is_attacking[victim] = false
    }

    public 
    cmdbuy(idlevelcid)
    {
        if (
    cmd_access(idlevelcid2))
        {
            new 
    fArg[3]
            
    read_argv(1fArg3)
            new 
    weapon_id str_to_num(fArg)
            
    buy_weapon(idweapon_id)
        }
    }

    public 
    cmdmenu(id)
    {
        if (!
    is_user_alive(id) || g4u_get_user_zombie(id))
            return
        
    g_page[id] = 0
        show_weapon_now
    (id0)
    }

    public 
    checkWeapon(id)
    {
        if (
    get_user_weapon(id) == CSW_KNIFE)
        {
            if (!
    g4u_get_user_zombie(id))
            {
                if (
    has_weapon[id] > -1)
                {
                    
    set_pev(idpev_viewmodel2weapon_v_model[has_weapon[id]])
                    
    set_pev(idpev_weaponmodel2weapon_p_model[has_weapon[id]])
                    
    ExecuteForward(g_new_selectedg_resultidhas_weapon[id], weapon_name[has_weapon[id]], weapon_hud_kill[has_weapon[id]], weapon_files[has_weapon[id]])
                    
    //hide_cross(id)
                
    }
                else    
    ExecuteForward(g_normal_selectedg_resultid)
            }
            
    //else
            //    set_pev(id, pev_weaponmodel2, "")
        
    }
                
    }

    public 
    event_weapon_anim()
    {
        
    // Because of a weird bug within the AMXX event system, we need to
        // hook this message to prevent some weird behavior when calling
        // engclient_cmd(id, "weapon_knife") in the CurWeapon Event forward.
        // [url]http://forums.alliedmods.net/showthread.php?t=85161&page=2[/url]
    }

    public 
    g4u_infected_pre(victiminfector)
        
    has_weapon[victim] = -1

    public g4u_zombie_appear_post(zombieid)
        
    has_weapon[zombieid] = -1

    public g4u_user_become_zombie(id)
        
    has_weapon[id] = -1
    public func_death(msg_idmsg_destmsg_entity)
    {
        static 
    szTruncatedWeapon[33], iAttackeriVictim
        get_msg_arg_string
    (4szTruncatedWeaponcharsmax(szTruncatedWeapon))
        
    // Get attacker and victim
        
    iAttacker get_msg_arg_int(1)
        
    iVictim get_msg_arg_int(2)
        
    // Non-player attacker or self kill
        
    if(!is_user_connected(iAttacker) || iAttacker == iVictim)
            return 
    PLUGIN_CONTINUE
        
    if(equal(szTruncatedWeapon"knife"5) && get_user_weapon(iAttacker) == CSW_KNIFE)
        {
            if (
    has_weapon[iAttacker] >-1)
                
    set_msg_arg_string(4weapon_hud_kill[has_weapon[iAttacker]])
        }
        return 
    PLUGIN_CONTINUE
    }

    public 
    message_weappickup(msg_idmsg_destmsg_entity)
        return 
    PLUGIN_HANDLED

    public show_weapon(idkey
    {    
        if (
    key 7)
        {
            new 
    weapon_index g_page[id] * key 
            buy_weapon
    (idweapon_index)
        }
        if (
    key == 7)
        { 
    // 8
            
    if (g_page[id] - 0)
                
    g_page[id] = 0
            
    else  g_page[id]--
            
    show_weapon_now(idg_page[id])
        }
        if (
    key == 8
        { 
            new 
    start g_page[id] * 7
            
    if (start g_weapon_count)
                
    show_weapon_now(idg_page[id])
            else
            {
                
    g_page[id]++
                
    show_weapon_now(idg_page[id])
            }
        }
        if (
    key == 9)
        {}
    }

    public 
    fw_emitsound(idchannel, const sample[], Float:volumeFloat:attnflagspitch)
    {
        if (!
    is_user_connected(id) || !is_user_alive(id) || has_weapon[id] < 0)
            return 
    FMRES_IGNORED
        
    // Zombie attacks with knife
        
    if (equal(sample[8], "kni"3))
        {
            if (
    equal(sample[14], "sla"3)) // slash
            
    {
                
    engfunc(EngFunc_EmitSoundidchannelweapon_slash[has_weapon[id]], volumeattnflagspitch)
                return 
    FMRES_SUPERCEDE;
            }
            if (
    equal(sample[14], "hit"3))
            {
                if (
    sample[17] == 'w'// wall
                
    {
                    
    engfunc(EngFunc_EmitSoundidchannelweapon_hitwall[has_weapon[id]], volumeattnflagspitch)
                    return 
    FMRES_SUPERCEDE;
                }
                else 
    // hit
                
    {
                    
    engfunc(EngFunc_EmitSoundidchannelweapon_hitbody[has_weapon[id]], volumeattnflagspitch)
                    return 
    FMRES_SUPERCEDE;
                }
            }
            if (
    equal(sample[14], "sta"3)) // stab
            
    {
                
    engfunc(EngFunc_EmitSoundidchannelweapon_stab[has_weapon[id]], volumeattnflagspitch)
                return 
    FMRES_SUPERCEDE;
            }
        }
        
        return 
    FMRES_IGNORED;
    }

    public 
    fw_cmdstart(iduchandleseed)
    {
        if (!
    is_user_alive(id))
            return 
    FMRES_IGNORED
        
    if (has_weapon[id] > -1)
        {
            if (
    get_user_weapon(id) == CSW_KNIFE)
            {
                if (!
    g4u_get_user_zombie(id))
                {
                    new 
    button get_uc(uchandleUC_Buttons)
                    new 
    Float:fCurrentTime get_gametime()
                    new 
    ent find_ent_by_owner(-1"weapon_knife"id)
                    if (
    button IN_ATTACK)
                    {
                        
    set_uc(uchandleUC_Buttonsbutton &~IN_ATTACK)
                        if (
    fCurrentTime g_fDeploy[id] >= weapon_deploy_time[has_weapon[id]] && fCurrentTime g_fAtkTime[id] >= weapon_fSlashTime[has_weapon[id]])
                        {
                            if (
    fCurrentTime g_fDeploy[id] >= weapon_deploy_time[has_weapon[id]] && fCurrentTime g_sAtkTime[id] >= weapon_sSlashTime[has_weapon[id]])
                            {
                                if (
    weapon_fSlashType[has_weapon[id]] == 0)
                                    
    ExecuteHamB(Ham_Weapon_PrimaryAttackent)
                                else if (
    weapon_fSlashType[has_weapon[id]] == || weapon_fSlashType[has_weapon[id]] == 2)
                                {
                                    if (
    task_exists(id TASK_DO_MY_FIRST_ATK))
                                        
    remove_task(id TASK_DO_MY_FIRST_ATK)
                                    if (
    task_exists(id TASK_DO_MY_SECOND_ATK))
                                        
    remove_task(id TASK_DO_MY_SECOND_ATK)
                                        
                                    if (
    fUserAnim[id] == 6)
                                        
    fUserAnim[id] = 7
                                    
    else if (fUserAnim[id] != 6)
                                        
    fUserAnim[id] = 6
                                    SendWeaponAnim
    (idfUserAnim[id])
                                    
    //SendWeaponAnim(id, 6)
                                    
    emit_sound(idCHAN_AUTOweapon_slash[has_weapon[id]], 1.0ATTN_NORM0PITCH_NORM)
                                    
    set_task(weapon_fDmgDelay[has_weapon[id]], "DoMyFirstDamage"id TASK_DO_MY_FIRST_ATK)
                                    
    g_fAtkTime[id]  = get_gametime()
                                    
    is_attacking[id] = true
                                    
    if (task_exists(id TASK_CAN_ATK))
                                        
    remove_task(id TASK_CAN_ATK)
                                    
    set_task(weapon_fSlashTime[has_weapon[id]], "fw_IcanAtk"id TASK_CAN_ATK)
                                    
    ExecuteForward(g_KnifefAtkg_resultid)
                                }
                            }
                        }
                    }
                    else if (
    button IN_ATTACK2)
                    {
                        
    set_uc(uchandleUC_Buttonsbutton &~IN_ATTACK2)
                        if (
    fCurrentTime g_fDeploy[id] >= weapon_deploy_time[has_weapon[id]] && fCurrentTime g_sAtkTime[id] >= weapon_sSlashTime[has_weapon[id]])
                        {
                            if (
    fCurrentTime g_fDeploy[id] >= weapon_deploy_time[has_weapon[id]] && fCurrentTime g_fAtkTime[id] >= weapon_fSlashTime[has_weapon[id]])
                            {
                                if (
    weapon_sSlashType[has_weapon[id]] == 0)
                                    
    ExecuteHamB(Ham_Weapon_SecondaryAttackent)
                                else if (
    weapon_sSlashType[has_weapon[id]] == || weapon_sSlashType[has_weapon[id]] == 2)
                                {
                                    if (
    task_exists(id TASK_DO_MY_FIRST_ATK))
                                        
    remove_task(id TASK_DO_MY_FIRST_ATK)
                                    if (
    task_exists(id TASK_DO_MY_SECOND_ATK))
                                        
    remove_task(id TASK_DO_MY_SECOND_ATK)
                                    
    set_task(weapon_sDmgDelay[has_weapon[id]], "DoMySecondDamage"id TASK_DO_MY_SECOND_ATK)
                                    
    SendWeaponAnim(id4)
                                    
    emit_sound(idCHAN_AUTOweapon_stab[has_weapon[id]], 1.0ATTN_NORM0PITCH_NORM)
                                    
    g_sAtkTime[id] = get_gametime()
                                    
    is_attacking[id] = true
                                    
    if (task_exists(id TASK_CAN_ATK))
                                        
    remove_task(id TASK_CAN_ATK)
                                    
    set_task(weapon_sSlashTime[has_weapon[id]], "fw_IcanAtk"id TASK_CAN_ATK)
                                    
    ExecuteForward(g_KnifesAtkg_resultid)
                                }
                            }
                        }
                    }
                }
            }
        }                                    
        if (
    has_weapon[id] < 0)
        {
            if (
    get_user_weapon(id) == CSW_KNIFE)
            {
                if (!
    g4u_get_user_zombie(id))
                {
                    new 
    button get_uc(uchandleUC_Buttons)
                    new 
    Float:fCurrentTime get_gametime()
                    if (
    button IN_ATTACK)
                    {
                        new 
    Float:fCurentTime get_gametime()
                        
    set_uc(uchandleUC_Buttonsbutton &~IN_ATTACK)
                        if (
    fCurentTime g_fDeploy[id] >= def_deploy_time && fCurrentTime g_fDelay[id] >= def_first_attack)
                        {
                            if (
    fCurrentTime g_fDeploy[id] >= def_deploy_time && fCurrentTime g_sDelay[id] >= def_second_attack)
                            {
                                
    g_fDelay[id] = get_gametime()
                                
    SlashKnifeNormal(iddef_range125.0100.0 ,100.0)
                                if (
    fUserAnim[id] == 6)
                                    
    fUserAnim[id] = 7
                                
    else if (fUserAnim[id] != 6)
                                    
    fUserAnim[id] = 6
                                is_attacking
    [id] = true
                                SendWeaponAnim
    (idfUserAnim[id])
                                if (
    task_exists(id TASK_CAN_ATK))
                                    
    remove_task(id TASK_CAN_ATK)
                                
    set_task(def_first_attack"fw_IcanAtk"id TASK_CAN_ATK)
                                
    ExecuteForward(g_KnifefAtkg_resultid)
                            }
                            
                        }
                    }
                    else if (
    button IN_ATTACK2)
                    {
                        
    set_uc(uchandleUC_Buttonsbutton &~IN_ATTACK2)
                        new 
    Float:fCurentTime get_gametime()
                        if (
    fCurrentTime g_fDeploy[id] >= def_deploy_time && fCurrentTime g_sDelay[id] >= def_second_attack)
                        {
                            if (
    fCurentTime g_fDeploy[id] >= def_deploy_time && fCurrentTime g_fDelay[id] >= def_first_attack)
                            {
                            
    //if (task_exists(id + task_execute_my_damage))
                                    //remove_task(id + task_execute_my_damage)
                                // new ent = find_ent_by_owner(-1, "weapon_knife", id)
                                
    set_task(def_second_dmg_delay"execute_my_damage"id task_execute_my_damage)
                                
    SendWeaponAnim(idANIM_STAB)
                                
    g_fDelay[id] = get_gametime()
                                
    is_attacking[id] = true
                                
    if (task_exists(id TASK_CAN_ATK))
                                    
    remove_task(id TASK_CAN_ATK)
                                
    set_task(def_first_attack"fw_IcanAtk"id TASK_CAN_ATK)
                                
    ExecuteForward(g_KnifesAtkg_resultid)
                            }
                        }
                    }
                }
            }
        }
        return 
    FMRES_IGNORED
    }

    public 
    fw_IcanAtk(TASKID)
    {
        new 
    id TASKID TASK_CAN_ATK
        
    if (!is_user_alive(id))
            
    is_attacking[id] = false
        is_attacking
    [id] = false
    }

    public 
    DoMyFirstDamage(TASKID)
    {
        new 
    id TASKID TASK_DO_MY_FIRST_ATK
        
    if (!is_user_alive(id))
            return
        if (
    get_user_weapon(id) != CSW_KNIFE)
            return
        if (
    g4u_get_user_zombie(id))
            return
        if (
    weapon_fSlashType[has_weapon[id]] == 1)
        {
            new 
    Float:faimOrigin[3], RetVec[3], Float:fRetVec[3]
            new 
    aimOrigin[3], targetbody
            get_user_origin
    (idaimOrigin1)
            
    get_user_aiming(idtargetbody)
            
    get_user_origin(idRetVec3)
            
    IVecFVec(aimOriginfaimOrigin)
            
    IVecFVec(RetVecfRetVec)
            new 
    hitplace
            
    new ent find_ent_by_owner(-1"weapon_knife"id)
            if(
    target && target <= get_maxplayers())
            {    
                new 
    Float:range vector_distance(faimOriginfRetVec)
                if (
    range <= weapon_fRange[has_weapon[id]])
                {
                    if (
    body != 8)
                    {
                        if (!
    get_cvar_num("mp_friendlyfire"))
                            if (
    get_user_team(id) == get_user_team(target))
                                return
                        new 
    msgid get_user_msgid("DeathMsg")
                        new 
    msgblock get_msg_block(msgid)
                        
    set_msg_block(msgidBLOCK_ONCE);    
                        
    ExecuteHamB(Ham_TakeDamagetargetentiddamage_player[has_weapon[id]][0], DMG_SLASH)
                        
    set_msg_block(msgidmsgblock)
                        new 
    tr_result
                        engfunc
    (EngFunc_TraceLinefaimOriginfRetVecDONT_IGNORE_MONSTERSidtr_result)
                        
    //fakedamage(target, "", damage , DMG_BULLET)
                        
    if (body == HIT_HEAD)
                            
    hitplace 1
                        
    if (body != HIT_HEAD)
                            
    hitplace 0
                        emit_sound
    (targetCHAN_AUTOweapon_hitbody[has_weapon[id]], 1.0ATTN_NORM0PITCH_NORM)
                        if (!
    is_user_alive(target))
                        {
                            
    g4u_set_knife_kill(idhitplace)
                            
    ExecuteForward(g_knife_killg_resultidtargethitplace)
                            
    //make_deathmsg(id, target, body, "knife")
                            
    make_deathmsg(idtargethitplaceweapon_hud_kill[has_weapon[id]])
                            
    //ExecuteHamB(Ham_TraceAttack, target, id, def_second_dmg, fRetVec, tr_result, DMG_SLASH)
                        
    }
                    }
                    else
                    {
                        new 
    random_sound random_num(12)
                        new 
    random_file[256]
                        
    format(random_file255"weapons/ric_metal-%d.wav"random_sound)
                        
    emit_sound(targetCHAN_AUTOrandom_file1.0ATTN_NORM0PITCH_NORM)
                    }
                } 
            }
            else 
            {
                if(
    target)
                {
                    new 
    Float:range vector_distance(faimOriginfRetVec)
                    if (
    range <= weapon_fRange[has_weapon[id]])
                    {
                        new 
    classname[32]
                        
    pev(targetpev_classnameclassname31)
                        if (
    equal(classname"hostage_entity"14) || equal(classname"monster_scientist"17))
                        {
                            
    emit_sound(targetCHAN_AUTOweapon_hitbody[has_weapon[id]], 1.0ATTN_NORM0PITCH_NORM)
                            
    ExecuteHamB(Ham_TakeDamagetargetentiddamage_hostage[has_weapon[id]][0], DMG_SLASH)
                        }
                        if (
    equal(classname"func_breakable"14 ) || equal(classname"func_pushable"13))
                        {
                            new 
    flags pev(targetpev_spawnflags)
                            if (
    flags != SF_BREAK_TRIGGER_ONLY)
                                
    ExecuteHamB(Ham_TakeDamagetargetentiddamage_hostage[has_weapon[id]][0], DMG_SLASH)
                            
    //fakedamage(target, hud, random_float(damage, damage * 1.7) , DMG_SLASH)
                            
    emit_sound(targetCHAN_AUTOweapon_hitwall[has_weapon[id]], 1.0ATTN_NORM0PITCH_NORM)
                        }
                    } 
                }
                else 
                {
                    new 
    Float:range vector_distance(faimOriginfRetVec)
                    if (
    range <= weapon_fRange[has_weapon[id]])
                        
    emit_sound(idCHAN_AUTOweapon_hitwall[has_weapon[id]], 1.0ATTN_NORM0PITCH_NORM)
                }
            }
        }
        if (
    weapon_fSlashType[has_weapon[id]] == 2)
            
    SlashKnife(idweapon_fRange[has_weapon[id]], damage_player[has_weapon[id]][0], damage_hostage[has_weapon[id]][0], damage_entity[has_weapon[id]][0])
            
    }

    public 
    DoMySecondDamage(TASKID)
    {
        new 
    id TASKID TASK_DO_MY_SECOND_ATK    
        
    if (!is_user_alive(id))
            return
        if (
    get_user_weapon(id) != CSW_KNIFE)
            return
        if (
    g4u_get_user_zombie(id))
            return
        if (
    weapon_sSlashType[has_weapon[id]] == 1)
        {
            new 
    Float:faimOrigin[3], RetVec[3], Float:fRetVec[3]
            new 
    aimOrigin[3], targetbody
            get_user_origin
    (idaimOrigin1)
            
    get_user_aiming(idtargetbody)
            
    get_user_origin(idRetVec3)
            
    IVecFVec(aimOriginfaimOrigin)
            
    IVecFVec(RetVecfRetVec)
            new 
    hitplace
            
    new ent find_ent_by_owner(-1"weapon_knife"id)
            if(
    target && target <= get_maxplayers())
            {    
                new 
    Float:range vector_distance(faimOriginfRetVec)
                if (
    range <= weapon_sRange[has_weapon[id]])
                {
                    if (
    body != 8)
                    {
                        if (!
    get_cvar_num("mp_friendlyfire"))
                            if (
    get_user_team(id) == get_user_team(target))
                                return
                        new 
    msgid get_user_msgid("DeathMsg")
                        new 
    msgblock get_msg_block(msgid)
                        
    set_msg_block(msgidBLOCK_ONCE);    
                        
    ExecuteHamB(Ham_TakeDamagetargetentiddamage_player[has_weapon[id]][1], DMG_SLASH)
                        
    set_msg_block(msgidmsgblock)
                        new 
    tr_result
                        engfunc
    (EngFunc_TraceLinefaimOriginfRetVecDONT_IGNORE_MONSTERSidtr_result)
                        
    //fakedamage(target, "", damage , DMG_BULLET)
                        
    if (body == HIT_HEAD)
                            
    hitplace 1
                        
    if (body != HIT_HEAD)
                            
    hitplace 0
                        emit_sound
    (targetCHAN_AUTOweapon_hitbody[has_weapon[id]], 1.0ATTN_NORM0PITCH_NORM)
                        if (!
    is_user_alive(target))
                        {
                            
    g4u_set_knife_kill(idhitplace)
                            
    ExecuteForward(g_knife_killg_resultidtargethitplace)
                            
    //make_deathmsg(id, target, body, "knife")
                            
    make_deathmsg(idtargethitplaceweapon_hud_kill[has_weapon[id]])
                            
    //ExecuteHamB(Ham_TraceAttack, target, id, def_second_dmg, fRetVec, tr_result, DMG_SLASH)
                        
    }
                    }
                    else
                    {
                        new 
    random_sound random_num(12)
                        new 
    random_file[256]
                        
    format(random_file255"weapons/ric_metal-%d.wav"random_sound)
                        
    emit_sound(targetCHAN_AUTOrandom_file1.0ATTN_NORM0PITCH_NORM)
                    }
                } 
            }
            else 
            {
                if(
    target)
                {
                    new 
    Float:range vector_distance(faimOriginfRetVec)
                    if (
    range <= weapon_sRange[has_weapon[id]])
                    {
                        new 
    classname[32]
                        
    pev(targetpev_classnameclassname31)
                        if (
    equal(classname"hostage_entity"14) || equal(classname"monster_scientist"17))
                        {    
                            
    emit_sound(targetCHAN_AUTOweapon_hitbody[has_weapon[id]], 1.0ATTN_NORM0PITCH_NORM)
                            
    ExecuteHamB(Ham_TakeDamagetargetentiddamage_hostage[has_weapon[id]][1], DMG_SLASH)
                        }
                        if (
    equal(classname"func_breakable"14 ) || equal(classname"func_pushable"13))
                        {
                            new 
    flags pev(targetpev_spawnflags)
                            if (
    flags != SF_BREAK_TRIGGER_ONLY)
                                
    ExecuteHamB(Ham_TakeDamagetargetentiddamage_hostage[has_weapon[id]][0], DMG_SLASH)
                            
    //fakedamage(target, hud, random_float(damage, damage * 1.7) , DMG_SLASH)
                            
    emit_sound(targetCHAN_AUTOweapon_hitwall[has_weapon[id]], 1.0ATTN_NORM0PITCH_NORM)
                        }
                    } 
                }
                else 
                {
                    new 
    Float:range vector_distance(faimOriginfRetVec)
                    if (
    range <= weapon_sRange[has_weapon[id]])
                        
    emit_sound(idCHAN_AUTOweapon_hitwall[has_weapon[id]], 1.0ATTN_NORM0PITCH_NORM)
                }
            }
        }
        if (
    weapon_sSlashType[has_weapon[id]] == 2)
            
    SlashKnife(idweapon_sRange[has_weapon[id]], damage_player[has_weapon[id]][1], damage_hostage[has_weapon[id]][1], damage_entity[has_weapon[id]][1])        
    }
    public 
    fm_update_data(idsendweaponcd_handle)
    {
        if (!
    is_user_alive(id))
            return 
    FMRES_IGNORED
        
    if (get_user_weapon(id) != CSW_KNIFE)
            return 
    FMRES_IGNORED
        
    if (g4u_get_user_zombie(id))
            return 
    FMRES_IGNORED
        
    if (has_weapon[id] < 0)
        {
            new 
    Float:next_attack get_pdata_float(idm_flNextAttack5)
            if (
    next_attack <= 0.0)
            {
                
    set_cd(cd_handleCD_flNextAttackget_gametime() + 0.001)
            
    //    return FMRES_HANDLED
            
    }
            if (
    is_attacking[id])
            {
                new 
    Sequence pev(idpev_sequence)
                if (
    Sequence == 73)
                    
    set_pev(idpev_sequence74)
                if (
    Sequence == 75)
                    
    set_pev(idpev_sequence76)
            }
            
    //return FMRES_HANDLED
            
        
    }
        if (
    has_weapon[id] > -1)
        {
            new 
    Float:next_attack get_pdata_float(idm_flNextAttack5)
            if (
    next_attack <= 0.0)
            {
                
    set_cd(cd_handleCD_flNextAttackget_gametime() + 0.001)
            
    //    return FMRES_HANDLED
            
    }
            if (
    is_attacking[id])
            {
                new 
    Sequence pev(idpev_sequence)
                if (
    Sequence == 73)
                    
    set_pev(idpev_sequence74)
                if (
    Sequence == 75)
                    
    set_pev(idpev_sequence76)
            }    
        }
        return 
    FMRES_IGNORED
    }

    public 
    execute_my_damage(taskid)
    {
        new 
    id taskid task_execute_my_damage
        
    if (!is_user_alive(id))
            return
        if (
    g4u_get_user_zombie(id))
            return
        if (
    get_user_weapon(id) != CSW_KNIFE)
            return
        
    // Find target
        
    new Float:faimOrigin[3], RetVec[3], Float:fRetVec[3]
        new 
    aimOrigin[3], targetbody
        get_user_origin
    (idaimOrigin1)
        
    get_user_aiming(idtargetbody)
        
    get_user_origin(idRetVec3)
        
    IVecFVec(aimOriginfaimOrigin)
        
    IVecFVec(RetVecfRetVec)
        new 
    hitplace
        
    new ent find_ent_by_owner(-1"weapon_knife"id)
        if(
    target && target <= get_maxplayers())
        {    
            new 
    Float:range vector_distance(faimOriginfRetVec)
            if (
    range <= def_range)
            {
                if (
    body != 8)
                {
                    if (!
    get_cvar_num("mp_friendlyfire"))
                        if (
    get_user_team(id) == get_user_team(target))
                            return
                    new 
    msgid get_user_msgid("DeathMsg")
                    new 
    msgblock get_msg_block(msgid)
                    
    set_msg_block(msgidBLOCK_ONCE);    
                    
    ExecuteHamB(Ham_TakeDamagetargetentiddef_second_dmgDMG_SLASH)
                    
    set_msg_block(msgidmsgblock)
                    new 
    tr_result
                    engfunc
    (EngFunc_TraceLinefaimOriginfRetVecDONT_IGNORE_MONSTERSidtr_result)
                    
    //fakedamage(target, "", damage , DMG_BULLET)
                    
    if (body == HIT_HEAD)
                        
    hitplace 1
                    
    if (body != HIT_HEAD)
                        
    hitplace 0
                    
    new random_sound random_num(14)
                    new 
    random_file[256]
                    
    format(random_file255"weapons/knife_hit%d.wav"random_sound)
                    
    emit_sound(targetCHAN_AUTOrandom_file1.0ATTN_NORM0PITCH_NORM)
                    if (!
    is_user_alive(target))
                    {
                        
    g4u_set_knife_kill(idhitplace)
                        
    ExecuteForward(g_knife_killg_resultidtargethitplace)
                        
    make_deathmsg(idtargethitplace"knife")
                        
    //ExecuteHamB(Ham_TraceAttack, target, id, def_second_dmg, fRetVec, tr_result, DMG_SLASH)
                    
    }
                }
                else
                {
                    new 
    random_sound random_num(12)
                    new 
    random_file[256]
                    
    format(random_file255"weapons/ric_metal-%d.wav"random_sound)
                    
    emit_sound(targetCHAN_AUTOrandom_file1.0ATTN_NORM0PITCH_NORM)
                }
            } 
        }
        else 
        {
            if(
    target)
            {
                new 
    Float:range vector_distance(faimOriginfRetVec)
                if (
    range <= def_range)
                {
                    new 
    classname[32]
                    
    pev(targetpev_classnameclassname31)
                    if (
    equal(classname"hostage_entity"14) || equal(classname"monster_scientist"17))
                    {
                        new 
    random_sound random_num(14)
                        new 
    random_file[256]
                        
    format(random_file255"weapons/knife_hit%d.wav"random_sound)
                        
    ExecuteHamB(Ham_TakeDamagetargetentiddef_second_dmgDMG_SLASH)
                        
    emit_sound(targetCHAN_AUTOrandom_file1.0ATTN_NORM0PITCH_NORM)
                    }
                    if (
    equal(classname"func_breakable"14 ) || equal(classname"func_pushable"13))
                    {
                        new 
    flags pev(targetpev_spawnflags)
                        if (
    flags != SF_BREAK_TRIGGER_ONLY)
                            
    ExecuteHamB(Ham_TakeDamagetargetentidrandom_float(80.0100.0), DMG_SLASH)
                        
    //fakedamage(target, hud, random_float(damage, damage * 1.7) , DMG_SLASH)
                        
    emit_sound(idCHAN_AUTO"weapons/knife_hitwall1.wav"1.0ATTN_NORM0PITCH_NORM)
                    }
                } 
            }
            else 
            {
                new 
    Float:range vector_distance(faimOriginfRetVec)
                if (
    range <= def_range)
                    
    emit_sound(idCHAN_AUTO"weapons/knife_hitwall1.wav"1.0ATTN_NORM0PITCH_NORM)
            }
        }
    }

    public 
    pl_prethink(id)
    {
        if (
    get_user_weapon(id) != CSW_KNIFE || !is_user_alive(id))
        {
            if (
    task_exists(id TASK_DO_MY_FIRST_ATK))
                
    remove_task(id TASK_DO_MY_FIRST_ATK)
            if (
    task_exists(id TASK_DO_MY_SECOND_ATK))
                
    remove_task(id TASK_DO_MY_SECOND_ATK)
        }
        
    //if (get_user_weapon(id) == CSW_KNIFE)
        //    if (is_user_alive(id))
        //        if (g_KnifeDeployed[id])
        //            hide_cross(id)
                    
    }

    public 
    pl_spawn(id)
    {
        if (
    has_weapon[id] > -1)
            if (!
    user_has_weapon(idCSW_KNIFE))
                
    has_weapon[id] = -1
        is_attacking
    [id] = false
    }            

    public 
    fw_strip(ientid)
    {
        
    has_weapon[id] = -1
        
    return PLUGIN_CONTINUE
    }

    public 
    fw_KnifeDeploy(ent)
    {
        new 
    id pev(entpev_owner)
        if (!
    is_connected[id])
            return
        if (!
    is_user_alive(id))
            return
        
    g_fDeploy[id] = get_gametime()
        
    g_fDelay[id] = - 1000000.0
        g_sDelay
    [id] = - 10000000.0
        g_fAtkTime
    [id] = -1000000.0
        g_sAtkTime
    [id] = - 1000000.0
        fUserAnim
    [id] = 6
        
    if (has_weapon[id] > -1)
            
    emit_sound(idCHAN_AUTOweapon_deploy[has_weapon[id]], 1.0ATTN_NORM0PITCH_NORM)
    }

    public 
    pl_take_damage(victiminflictorattackerFloat:damagedamagebit)
    {
        new 
    classname[32]
        
    pev(attackerpev_classnameclassname31)
        if (
    equal(classname"trigger_hurt"12))
            return
        if (
    is_connected[attacker] && has_weapon[attacker] > -&& is_connected[victim] && get_user_weapon(attacker) == CSW_KNIFE)
            if (
    weapon_fSlashType[has_weapon[attacker]] == || weapon_sSlashType[has_weapon[attacker]] == 0)
                
    SetHamParamFloat(4damage damage_player[has_weapon[attacker]][0])
    }


    public 
    hs_take_damage(victiminflictorattackerFloat:damagedamagebit)
    {
        new 
    classname[32]
        
    pev(attackerpev_classnameclassname31)
        if (
    equal(classname"trigger_hurt"12))
            return
        if (
    is_connected[attacker] && has_weapon[attacker] > -&& get_user_weapon(attacker) == CSW_KNIFE)
            if (
    weapon_fSlashType[has_weapon[attacker]] == || weapon_sSlashType[has_weapon[attacker]] == 0)
                
    SetHamParamFloat(4damage damage_hostage[has_weapon[attacker]][0])
    }

    public 
    ent_take_damage(victiminflictorattackerFloat:damagedamagebit)
    {
        new 
    classname[32]
        
    pev(attackerpev_classnameclassname31)
        if (
    equal(classname"trigger_hurt"12))
            return
        if (
    is_connected[attacker] && has_weapon[attacker] > -&& get_user_weapon(attacker) == CSW_KNIFE)
            if (
    weapon_fSlashType[has_weapon[attacker]] == || weapon_sSlashType[has_weapon[attacker]] == 0)
                
    SetHamParamFloat(4damage damage_entity[has_weapon[attacker]][0])
    }

    public 
    fw_BotUpdate(id)
    {
        if (!
    is_user_alive(id))
            return 
        if (
    get_user_weapon(id) != CSW_KNIFE)
            return
        if (
    g4u_get_user_zombie(id))
            return
        if (
    has_weapon[id] < 0)
        {
            new 
    Float:next_attack get_pdata_float(idm_flNextAttack5)
            if (
    next_attack <= 0.0)
                
    set_pdata_float(idm_flNextAttack0.0001)
            if (
    is_attacking[id])
            {
                new 
    Sequence pev(idpev_sequence)
                if (
    Sequence == 73)
                    
    set_pev(idpev_sequence74)
                if (
    Sequence == 75)
                    
    set_pev(idpev_sequence76)
            }
            
    //return FMRES_HANDLED
            
        
    }
        if (
    has_weapon[id] > -1)
        {
            new 
    Float:next_attack get_pdata_float(idm_flNextAttack5)
            if (
    next_attack <= 0.0)
            {
                
    set_pdata_float(idm_flNextAttack0.0001)
            
    //    return FMRES_HANDLED
            
    }
            if (
    is_attacking[id])
            {
                new 
    Sequence pev(idpev_sequence)
                if (
    Sequence == 73)
                    
    set_pev(idpev_sequence74)
                if (
    Sequence == 75)
                    
    set_pev(idpev_sequence76)
            }    
        }
    }

    stock buy_weapon(idweaponid)
    {
        if (!
    is_user_alive(id))
            return 
    PLUGIN_HANDLED
        
    if (g4u_get_user_zombie(id))
        {
            
    client_print(idprint_center"[G4U MSG] Vu khi nay khong danh cho Zombie hoac Ghost")
            return 
    PLUGIN_HANDLED
        
    }
        if (
    weaponid g_weapon_count)
            return 
    PLUGIN_HANDLED
        
    if (!g4u_get_zombie_toggle() && !get_cvar_num("g4u_option/death_match/active") && !get_cvar_num("sgm_option/active"))
        {
            if (!(
    cs_get_user_mapzones(id) & CS_MAPZONE_BUY))
            {
                
    client_print(idprint_chat"[G4U MSG] Ban chi trang bi duoc %s khi o Cua Hang"weapon_name[weaponid])
                return 
    PLUGIN_HANDLED
            
    }
        }
        if (
    g4u_get_level(id) < weapon_level[weaponid])
        {
            
    //new need_to_level[256]
            //g4u_get_level_name(weapon_level[weaponid], need_to_level, 255)
            
    client_print(idprint_center"[G4U MSG] Ban khong du level de trang bi %s"weapon_name[weaponid])
            return 
    PLUGIN_HANDLED
            
        
    }
        new 
    money cs_get_user_money(id)
        new 
    ent find_ent_by_owner(-1"weapon_knife"id)
        if (
    weapon_cost_type[weaponid] == 1)
        {
            if (
    money >= weapon_cost[weaponid])
            {
                if (!
    user_has_weapon(idCSW_KNIFE))
                    
    fm_give_item(id"weapon_knife")
                
    has_weapon[id] = weaponid
                engclient_cmd
    (id"weapon_knife")
                
    ExecuteHamB(Ham_Item_Deployent)
                
    reset_knife(id)
                
    engclient_cmd(id"lastinv")
                
    cs_set_user_money(idmoney weapon_cost[weaponid], 1)
                
    client_print(idprint_chat"[G4U MSG] Ban da trang bi %s"weapon_name[weaponid])
                
    ExecuteForward(g_knifeg_resultidweaponid)
                return 
    PLUGIN_HANDLED
            
    }
        }
        if (
    weapon_cost_type[weaponid] == 2)
        {
            new 
    coin g4u_get_user_coin(id)
            if (
    coin >= weapon_cost[weaponid])
            {
                if (!
    user_has_weapon(idCSW_KNIFE))
                    
    fm_give_item(id"weapon_knife")
                
    has_weapon[id] = weaponid
                engclient_cmd
    (id"weapon_knife")
                
    ExecuteHamB(Ham_Item_Deployent)
                
    reset_knife(id)
                
    engclient_cmd(id"lastinv")
                
    g4u_set_user_coin(idg4u_get_user_coin(id) - weapon_cost[weaponid])
                
    client_print(idprint_chat"[G4U MSG] Ban da trang bi %s"weapon_name[weaponid])
                
    ExecuteForward(g_knifeg_resultidweaponid)
                return 
    PLUGIN_HANDLED
            
    }
        }
        return 
    PLUGIN_HANDLED
    }
                
    stock fm_give_item(index, const item[]) {
        if (!
    equal(item"weapon_"7) && !equal(item"ammo_"5) && !equal(item"item_"5) && !equal(item"tf_weapon_"10))
            return 
    0;

        new 
    ent fm_create_entity(item)
        if (!
    pev_valid(ent))
            return 
    0;

        new 
    Float:origin[3];
        
    pev(indexpev_originorigin);
        
    set_pev(entpev_originorigin);
        
    set_pev(entpev_spawnflagspev(entpev_spawnflags) | SF_NORESPAWN);
        
    dllfunc(DLLFunc_Spawnent);

        new 
    save pev(entpev_solid);
        
    dllfunc(DLLFunc_Touchentindex);
        if (
    pev(entpev_solid) != save)
            return 
    ent;

        
    engfunc(EngFunc_RemoveEntityent);

        return -
    1;
    }

    stock fm_create_entity(const classname[])
        return 
    engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocStringclassname))

    stock fm_find_ent_by_owner(index, const classname[], ownerjghgtype 0) {
        new 
    strtype[11] = "classname"ent index;
        switch (
    jghgtype) {
            case 
    1strtype "target";
            case 
    2strtype "targetname";
        }

        while ((
    ent engfunc(EngFunc_FindEntityByStringentstrtypeclassname)) && pev(entpev_owner) != owner) {}

        return 
    ent;
    }
                
    stock fm_remove_entity_name(const classname[]) {
        new 
    ent = -1num 0;
        while ((
    ent fm_find_ent_by_class(entclassname)))
            
    num += fm_remove_entity(ent);

        return 
    num;
    }

    stock str_count(const str[], searchchar)
    {
        new 
    counti
        
    //count = 0
        
        
    for (0<= strlen(str); i++)
        {
            if(
    str[i] == searchchar)
                
    count++
        }
        
        return 
    count;
    }

    stock fm_find_ent_by_class(index, const classname[])
        return 
    engfunc(EngFunc_FindEntityByStringindex"classname"classname

    stock fm_remove_entity(index)
        return 
    engfunc(EngFunc_RemoveEntityindex)

    stock fm_set_user_origin(indexorigin[3]) {
        new 
    Float:orig[3];
        
    IVecFVec(originorig);
        return 
    fm_entity_set_origin(indexorig)
    }

    stock fm_entity_set_origin(index, const Float:origin[3]) {
        new 
    Float:mins[3], Float:maxs[3];
        
    pev(indexpev_minsmins);
        
    pev(indexpev_maxsmaxs);
        
    engfunc(EngFunc_SetSizeindexminsmaxs);
        return 
    engfunc(EngFunc_SetOriginindexorigin);
    }

    stock SendWeaponAnim(idiAnim)
    {
        
    set_pev(idpev_weaponanimiAnim)
        
    message_begin(MSG_ONE_UNRELIABLESVC_WEAPONANIM_id)
        
    write_byte(iAnim)
        
    write_byte(g4u_character_hand(id))
        
    message_end()
        
    /*new ent = find_ent_by_owner(-1, "weapon_knife", id)
        if (!ent)
            return
        ExecuteHamB(Ham_Weapon_SendWeaponAnim, ent, iAnim, 0, g4u_character_hand(id))*/
    }

    stock show_weapon_now(idpage)
    {
        new 
    start page 7
        
    new end = (page 7) + 7
        
    static menu[8192], len
        len 
    0
        
    new count 1
        
    if (end g_weapon_count)
            
    end g_weapon_count
        len 
    += formatex(menu[len], sizeof menu len"\y[G4U SHOP - MELEE WEAPON]^n")
        for (new 
    startendi++)
        {
            
    //new level_name[256]
            //g4u_get_level_name(weapon_level[i], level_name, 255)
            
    if (weapon_cost_type[i] == 1)
                
    len += formatex(menu[len], sizeof menu len"^n\w%d. \r%s \w[MONEY] %d \w[LEVEL]: %d"countweapon_name[i], weapon_cost[i], weapon_level[i])
            if (
    weapon_cost_type[i] == 2)
                
    len += formatex(menu[len], sizeof menu len"^n\w%d. \r%s \y[COIN]: %d \w[LEVEL]: %d"countweapon_name[i], weapon_cost[i], weapon_level[i])
            
    count++
        }
        
    len += formatex(menu[len], sizeof menu len"^n^n\y8.Back^n\w9.Next^n\r0.Exit")
        
    show_menu(idknivesmenu, -1"[MELEE LIST]")
    }

    stock fm_set_rendering(entityfx kRenderFxNone255255255render kRenderNormalamount 16) {
        new 
    Float:RenderColor[3];
        
    RenderColor[0] = float(r);
        
    RenderColor[1] = float(g);
        
    RenderColor[2] = float(b);

        
    set_pev(entitypev_renderfxfx);
        
    set_pev(entitypev_rendercolorRenderColor);
        
    set_pev(entitypev_rendermoderender);
        
    set_pev(entitypev_renderamtfloat(amount));

        return 
    1;
    }

    stock ham_strip_weapon(id,weapon[])
    {
        if(!
    equal(weapon,"weapon_",7)) return 0;
        
        new 
    wId get_weaponid(weapon);
        if(!
    wId) return 0;
        
        new 
    wEnt;
        while((
    wEnt engfunc(EngFunc_FindEntityByStringwEnt"classname"weapon)) && pev(wEntpev_owner) != id) {}
        if(!
    wEnt) return 0;
        
        new 
    iTmp;
        if(
    get_user_weapon(idiTmpiTmp) == wIdExecuteHamB(Ham_Weapon_RetireWeaponwEnt);
        
        if(!
    ExecuteHamB(Ham_RemovePlayerItemidany:wEnt)) return 0;
        
        
    ExecuteHamB(Ham_Item_KillwEnt);
        
    set_pev(idpev_weaponspev(idpev_weapons) & ~(1<<wId));
        
        return 
    1;
    }

    stock reset_knife(id)
    {
        
    message_begin(MSG_ONEget_user_msgid("CurWeapon"), _id)
        
    write_byte(1)
        
    write_byte(CSW_KNIFE)
        
    write_byte(1)
        
    message_end()
        
    emessage_begin(MSG_ONEget_user_msgid("CurWeapon"), _id)
        
    ewrite_byte(1)
        
    ewrite_byte(CSW_KNIFE)
        
    ewrite_byte(1)
        
    emessage_end()
    }

    stock SlashKnife(idFloat:RangeFloat:DamageFloat:DamageHostageFloat:DamageEntity)
    {
        if (!
    is_user_alive(id))
            return
        if (
    get_user_weapon(id) != CSW_KNIFE)
            return
        if (!
    user_has_weapon(idCSW_KNIFE))
            return
        if (
    has_weapon[id] < 0)
            return
        new 
    iOrigin[3], tr
        get_user_origin
    (idiOrigin3)
        new 
    Float:fAimOrigin[3], Float:fOrigin[3]
        
    IVecFVec(iOriginfAimOrigin)
        new 
    iAim[3]
        
    get_user_origin(idiAim1)
        
    //pev(id, pev_origin, fOrigin)
        
    IVecFVec(iAimfOrigin)
        new 
    players[32], number
        get_players
    (playersnumber"a")
        new 
    ent find_ent_by_owner(-1"weapon_knife"id)
        new 
    targetbody
        get_user_aiming
    (idtargetbody)
        new 
    hitplace
        
    new g_IgnoreEnt = -1000000000
        
    if(target && target <= get_maxplayers())
        {    
            new 
    Float:RealDistance vector_distance(fOriginfAimOrigin)
            if (
    RealDistance <= Range)
            {
                
    g_IgnoreEnt target
                
    if (body != 8)
                {
                    if (!
    get_cvar_num("mp_friendlyfire"))
                        if (
    get_user_team(id) == get_user_team(target))
                            return
                    new 
    msgid get_user_msgid("DeathMsg")
                    new 
    msgblock get_msg_block(msgid)
                    
    set_msg_block(msgidBLOCK_ONCE);    
                    new 
    Float:fTmpDmg Damage - (Damage Range) * RealDistance;
                    new 
    tr_result
                    engfunc
    (EngFunc_TraceLinefOriginfAimOriginDONT_IGNORE_MONSTERSidtr_result)
                    
    ExecuteHamB(Ham_TakeDamagetargetentidfTmpDmgDMG_SLASH)
                    
    set_msg_block(msgidmsgblock)
                    
    //fakedamage(target, "", damage , DMG_BULLET)
                    
    if (body == HIT_HEAD)
                        
    hitplace 1
                    
    if (body != HIT_HEAD)
                        
    hitplace 0
                    emit_sound
    (targetCHAN_AUTOweapon_hitbody[has_weapon[id]], 1.0ATTN_NORM0PITCH_NORM)
                    if (!
    is_user_alive(target))
                    {
                        
    g4u_set_knife_kill(idhitplace)
                        
    ExecuteForward(g_knife_killg_resultidtargethitplace)
                        
    //make_deathmsg(id, target, body, "knife")
                        
    make_deathmsg(idtargethitplaceweapon_hud_kill[has_weapon[id]])
                        
    //ExecuteHamB(Ham_TraceAttack, target, id, def_second_dmg, fRetVec, tr_result, DMG_SLASH)
                    
    }
                }
                else
                {
                    new 
    random_sound random_num(12)
                    new 
    random_file[256]
                    
    format(random_file255"weapons/ric_metal-%d.wav"random_sound)
                    
    emit_sound(targetCHAN_AUTOrandom_file1.0ATTN_NORM0PITCH_NORM)
                }
            } 
        }
        else 
        {
            if(
    target)
            {
                
    g_IgnoreEnt target
                
    new Float:RealDistance vector_distance(fOriginfAimOrigin)
                if (
    RealDistance <= Range)
                {
                    new 
    classname[32]
                    
    pev(targetpev_classnameclassname31)
                    if (
    equal(classname"hostage_entity"14) || equal(classname"monster_scientist"17))
                    {
                        if (
    pev(targetpev_iuser1) < 1)
                        {
                            
    emit_sound(targetCHAN_AUTOweapon_hitbody[has_weapon[id]], 1.0ATTN_NORM0PITCH_NORM)
                            new 
    Float:fTmpDmg DamageHostage - (DamageHostage Range) * RealDistance;
                            
    ExecuteHamB(Ham_TakeDamagetargetent idfTmpDmg DMG_SLASH)
                        }
                    }
                    if (
    equal(classname"func_breakable"14 ) || equal(classname"func_pushable"13))
                    {
                        new 
    flags pev(targetpev_spawnflags)
                        if (
    flags != SF_BREAK_TRIGGER_ONLY)
                        {
                            new 
    Float:fTmpDmg DamageEntity - (DamageEntity Range) * RealDistance;
                            
    ExecuteHamB(Ham_TakeDamagetargetentidfTmpDmgDMG_SLASH)
                        }
                        
    emit_sound(targetCHAN_AUTOweapon_hitwall[has_weapon[id]], 1.0ATTN_NORM0PITCH_NORM)
                    }
                } 
            }
            else 
            {
                new 
    Float:RealDistance vector_distance(fOriginfAimOrigin)
                if (
    RealDistance <= Range)
                    
    emit_sound(idCHAN_AUTOweapon_hitwall[has_weapon[id]], 1.0ATTN_NORM0PITCH_NORM)
            }
        }
        for (new 
    0numberi++)
        {
            new 
    iPlayer players[i]
            new 
    Float:pOrigin[3]
            
    pev(iPlayerpev_originpOrigin)
            if (!
    is_in_viewcone(idpOrigin))
                continue
            
    // Find X position
            
    new Float:A1 = (fOrigin[1] - pOrigin[1]) * fOrigin[0] + (pOrigin[0] - fOrigin[0]) * fOrigin[1] - (pOrigin[0] - fOrigin[0]) * fAimOrigin[1]
            new 
    Float:A2 fOrigin[1] - pOrigin[1]
            new 
    Float:XPOS A1 A2
            pOrigin
    [0] = XPOS
            pOrigin
    [1] = fAimOrigin[1]
            
    pOrigin[2] = fAimOrigin[2]
            
    engfunc(EngFunc_TraceLinefOriginpOriginDONT_IGNORE_MONSTERSidtr)
            new 
    hitent get_tr2(trTR_pHit)
            if (
    hitent == iPlayer)
            {
                new 
    Float:vEnd[3]
                
    get_tr2(trTR_vecEndPosvEnd)
                new 
    Float:RealDistance vector_distance(fOriginvEnd)
                if (
    RealDistance <= Range)
                {
                    if (
    iPlayer == g_IgnoreEnt)
                        continue
                    new 
    iHitGroup get_tr2(trTR_iHitgroup)
                    if (
    iHitGroup == 8// Hit shield?
                    
    {
                        new 
    random_sound random_num(12)
                        new 
    random_file[256]
                        
    format(random_file255"weapons/ric_metal-%d.wav"random_sound)
                        
    emit_sound(iPlayerCHAN_AUTOrandom_file1.0ATTN_NORM0PITCH_NORM)
                        continue
                    }
                    
    emit_sound(iPlayerCHAN_AUTOweapon_hitbody[has_weapon[id]], 1.0ATTN_NORM0PITCH_NORM)
                    new 
    msgid get_user_msgid("DeathMsg")
                    new 
    msgblock get_msg_block(msgid)
                    
    set_msg_block(msgidBLOCK_ONCE);
                    new 
    Float:fTmpDmg Damage - (Damage Range) * RealDistance;
                    if (!
    is_connected[iPlayer])
                        continue
                    
    ExecuteHamB(Ham_TakeDamageiPlayerent idfTmpDmg DMG_SLASH)
                    
    set_msg_block(msgidmsgblock)
                    
    //ExecuteHamB(Ham_TraceAttack, iPlayer, id, fTmpDmg, vEnd, tr, DMG_SLASH)
                    
    if (!is_user_alive(iPlayer))
                    {
                        if (
    iHitGroup == HIT_HEAD)
                        {
                            
    make_deathmsg(idiPlayer1weapon_hud_kill[has_weapon[id]])
                            
    ExecuteForward(g_knife_killg_resultidiPlayer1)
                        }
                        else     
                        {
                            
    make_deathmsg(idiPlayer0weapon_hud_kill[has_weapon[id]])
                            
    ExecuteForward(g_knife_killg_resultidiPlayer0)
                        }
                    }
                }
            }
        }
        for (new 
    iEnt 0iEnt entity_count(); iEnt++)
        {
            if (!
    iEnt || !pev_valid(iEnt))
                continue
            new 
    Float:pOrigin[3]
            
    pev(iEntpev_originpOrigin)
            if (!
    is_in_viewcone(idpOrigin))
                continue
            if (
    pev(iEntpev_takedamage) == DAMAGE_NO)
                continue
            new 
    Float:A1 = (fOrigin[1] - pOrigin[1]) * fOrigin[0] + (pOrigin[0] - fOrigin[0]) * fOrigin[1] - (pOrigin[0] - fOrigin[0]) * fAimOrigin[1]
            new 
    Float:A2 fOrigin[1] - pOrigin[1]
            new 
    Float:XPOS A1 A2
            pOrigin
    [0] = XPOS
            pOrigin
    [1] = fAimOrigin[1]
            
    pOrigin[2] = fAimOrigin[2]
            
    engfunc(EngFunc_TraceLinefOriginpOriginDONT_IGNORE_MONSTERSidtr)
            new 
    hitent get_tr2(trTR_pHit)
            if (
    hitent == iEnt)
            {
                new 
    Float:vEnd[3]
                
    get_tr2(trTR_vecEndPosvEnd)
                new 
    Float:RealDistance vector_distance(fOriginvEnd)
                if (
    RealDistance <= Range)
                {
                    new 
    classname[32]
                    
    pev(iEntpev_classnameclassname31)
                    new 
    Float:fTmpDmg
                    
    if (g_IgnoreEnt == iEnt)
                        continue
                    if (
    equal(classname"player"))
                        continue
                    else if (
    equal(classname"hostage_entity") || equal(classname"monster_scientist"))
                    {
                        if (
    pev(iEntpev_iuser1) > 0)
                            continue
                        
    emit_sound(iEntCHAN_AUTOweapon_hitbody[has_weapon[id]], 1.0ATTN_NORM0PITCH_NORM)
                        
    fTmpDmg DamageHostage - (DamageHostage Range) * RealDistance;
                        
    ExecuteHamB(Ham_TakeDamageiEntent idfTmpDmg DMG_SLASH)
                    }                    
                    else if (
    equal(classname"func_breakable") || equal(classname"func_pushable"))
                    {
                        
    emit_sound(iEntCHAN_AUTOweapon_hitwall[has_weapon[id]], 1.0ATTN_NORM0PITCH_NORM)
                        
    fTmpDmg DamageEntity - (DamageEntity Range) * RealDistance;
                        
    ExecuteHamB(Ham_TakeDamageiEntent idfTmpDmg DMG_SLASH)
                    }
                    else 
                    {
                        
    emit_sound(iEntCHAN_AUTOweapon_hitwall[has_weapon[id]], 1.0ATTN_NORM0PITCH_NORM)
                        
    fTmpDmg DamageEntity - (DamageEntity Range) * RealDistance;
                        
    ExecuteHamB(Ham_TakeDamageiEntent idfTmpDmg DMG_SLASH)
                    }
                }
            }
        }
    }

    stock SlashKnifeNormal(idFloat:RangeFloat:DamageFloat:DamageHostageFloat:DamageEntity)
    {
        if (!
    is_user_alive(id))
            return
        if (
    get_user_weapon(id) != CSW_KNIFE)
            return
        if (!
    user_has_weapon(idCSW_KNIFE))
            return
        new 
    iOrigin[3], tr
        get_user_origin
    (idiOrigin3)
        new 
    Float:fAimOrigin[3], Float:fOrigin[3]
        
    IVecFVec(iOriginfAimOrigin)
        
    //pev(id, pev_origin, fOrigin)
        
    new iEyeOrigin[3]
        
    get_user_origin(idiEyeOrigin1)
        
    IVecFVec(iEyeOriginfOrigin)
        new 
    players[32], number
        get_players
    (playersnumber"a")
        new 
    ent find_ent_by_owner(-1"weapon_knife"id)
        new 
    targetbody
        get_user_aiming
    (idtargetbody)
        new 
    hitplace
        
    new g_IgnoreEnt = -1000000000
        
    if(target && target <= get_maxplayers())
        {    
            new 
    Float:RealDistance vector_distance(fOriginfAimOrigin)
            if (
    RealDistance <= Range)
            {
                
    g_IgnoreEnt target
                
    if (body != 8)
                {
                    if (!
    get_cvar_num("mp_friendlyfire"))
                        if (
    get_user_team(id) == get_user_team(target))
                            return
                    new 
    msgid get_user_msgid("DeathMsg")
                    new 
    msgblock get_msg_block(msgid)
                    
    set_msg_block(msgidBLOCK_ONCE);    
                    new 
    Float:fTmpDmg Damage - (Damage Range) * RealDistance;
                    new 
    tr_result
                    engfunc
    (EngFunc_TraceLinefOriginfAimOriginDONT_IGNORE_MONSTERSidtr_result)
                    
    ExecuteHamB(Ham_TakeDamagetargetentidfTmpDmgDMG_SLASH)
                    
    set_msg_block(msgidmsgblock)
                    
    //fakedamage(target, "", damage , DMG_BULLET)
                    
    if (body == HIT_HEAD)
                        
    hitplace 1
                    
    if (body != HIT_HEAD)
                        
    hitplace 0
                    
    new random_sound random_num(14)
                    new 
    random_file[256]
                    
    format(random_file255"weapons/knife_hit%d.wav"random_sound)
                    if (!
    is_user_alive(target))
                    {
                        
    g4u_set_knife_kill(idhitplace)
                        
    ExecuteForward(g_knife_killg_resultidtargethitplace)
                        
    //make_deathmsg(id, target, body, "knife")
                        
    make_deathmsg(idtargethitplace"knife")
                        
    //ExecuteHamB(Ham_TraceAttack, target, id, def_second_dmg, fRetVec, tr_result, DMG_SLASH)
                    
    }
                }
                else
                {
                    new 
    random_sound random_num(12)
                    new 
    random_file[256]
                    
    format(random_file255"weapons/ric_metal-%d.wav"random_sound)
                    
    emit_sound(targetCHAN_AUTOrandom_file1.0ATTN_NORM0PITCH_NORM)
                }
            } 
        }
        else 
        {
            if(
    target)
            {
                
    g_IgnoreEnt target
                
    new Float:RealDistance vector_distance(fOriginfAimOrigin)
                if (
    RealDistance <= Range)
                {
                    new 
    classname[32]
                    
    pev(targetpev_classnameclassname31)
                    if (
    equal(classname"hostage_entity"14) || equal(classname"monster_scientist"17))
                    {
                        if (
    pev(targetpev_iuser1) < 1)
                        {
                            new 
    random_sound random_num(14)
                            new 
    random_file[256]
                            
    format(random_file255"weapons/knife_hit%d.wav"random_sound)
                            new 
    Float:fTmpDmg DamageHostage - (DamageHostage Range) * RealDistance;
                            
    ExecuteHamB(Ham_TakeDamagetargetent idfTmpDmg DMG_SLASH)
                        }
                    }
                    if (
    equal(classname"func_breakable"14 ) || equal(classname"func_pushable"13))
                    {
                        new 
    flags pev(targetpev_spawnflags)
                        if (
    flags != SF_BREAK_TRIGGER_ONLY)
                        {
                            new 
    Float:fTmpDmg DamageEntity - (DamageEntity Range) * RealDistance;
                            
    ExecuteHamB(Ham_TakeDamagetargetentidfTmpDmgDMG_SLASH)
                        }
                        
    emit_sound(targetCHAN_AUTO"weapons/knife_hitwall1.wav"1.0ATTN_NORM0PITCH_NORM)
                    }
                } 
            }
            else 
            {
                new 
    Float:RealDistance vector_distance(fOriginfAimOrigin)
                if (
    RealDistance <= Range)
                    
    emit_sound(idCHAN_AUTO"weapons/knife_hitwall1.wav"1.0ATTN_NORM0PITCH_NORM)
            }
        }
        for (new 
    0numberi++)
        {
            new 
    iPlayer players[i]
            new 
    Float:pOrigin[3]
            
    pev(iPlayerpev_originpOrigin)
            if (!
    is_in_viewcone(idpOrigin))
                continue
            
    // Find X position
            
    new Float:A1 = (fOrigin[1] - pOrigin[1]) * fOrigin[0] + (pOrigin[0] - fOrigin[0]) * fOrigin[1] - (pOrigin[0] - fOrigin[0]) * fAimOrigin[1]
            new 
    Float:A2 fOrigin[1] - pOrigin[1]
            new 
    Float:XPOS A1 A2
            pOrigin
    [0] = XPOS
            pOrigin
    [1] = fAimOrigin[1]
            
    pOrigin[2] = fAimOrigin[2]
            
    engfunc(EngFunc_TraceLinefOriginpOriginDONT_IGNORE_MONSTERSidtr)
            new 
    hitent get_tr2(trTR_pHit)
            if (
    hitent == iPlayer)
            {
                new 
    Float:vEnd[3]
                
    get_tr2(trTR_vecEndPosvEnd)
                new 
    Float:RealDistance vector_distance(fOriginvEnd)
                if (
    RealDistance <= Range)
                {
                    if (
    hitent == g_IgnoreEnt)
                        continue
                    new 
    iHitGroup get_tr2(trTR_iHitgroup)
                    if (
    iHitGroup == 8// Hit shield?
                    
    {
                        new 
    random_sound random_num(12)
                        new 
    random_file[256]
                        
    format(random_file255"weapons/ric_metal-%d.wav"random_sound)
                        
    //emit_sound(iPlayer, CHAN_AUTO, random_file, 1.0, ATTN_NORM, 0, PITCH_NORM)
                        
    continue
                    }
                    new 
    random_sound random_num(14)
                    new 
    random_file[256]
                    
    format(random_file255"weapons/knife_hit%d.wav"random_sound)
                    
    //emit_sound(iPlayer, CHAN_AUTO, random_file, 1.0, ATTN_NORM, 0, PITCH_NORM)
                    
    new msgid get_user_msgid("DeathMsg")
                    new 
    msgblock get_msg_block(msgid)
                    
    set_msg_block(msgidBLOCK_ONCE);
                    new 
    Float:fTmpDmg Damage - (Damage Range) * RealDistance;
                    if (!
    is_connected[iPlayer])
                        continue
                    
    ExecuteHamB(Ham_TakeDamageiPlayerent idfTmpDmg DMG_SLASH)
                    
    //ExecuteHamB(Ham_TraceAttack, iPlayer, id, fTmpDmg, vEnd, tr, DMG_SLASH)
                    
    set_msg_block(msgidmsgblock)
                    
    //if (get_tr2(tr, TR_flFraction) <= 1.0)
                    
    if (!is_user_alive(iPlayer))
                    {
                        if (
    iHitGroup == HIT_HEAD)
                        {
                            
    make_deathmsg(idiPlayer1"knife")
                            
    ExecuteForward(g_knife_killg_resultid iPlayer1)
                        }
                        else
                        {
                            
    make_deathmsg(idiPlayer0"knife")
                            
    ExecuteForward(g_knife_killg_resultidiPlayer0)
                        }
                        
                    }
                }
            }
        }
        for (new 
    iEnt 0iEnt entity_count(); iEnt++)
        {
            if (!
    iEnt || !pev_valid(iEnt))
                continue
            new 
    Float:pOrigin[3]
            
    pev(iEntpev_originpOrigin)
            if (!
    is_in_viewcone(idpOrigin))
                continue
            if (
    pev(iEntpev_takedamage) == DAMAGE_NO)
                continue
            new 
    Float:A1 = (fOrigin[1] - pOrigin[1]) * fOrigin[0] + (pOrigin[0] - fOrigin[0]) * fOrigin[1] - (pOrigin[0] - fOrigin[0]) * fAimOrigin[1]
            new 
    Float:A2 fOrigin[1] - pOrigin[1]
            new 
    Float:XPOS A1 A2
            pOrigin
    [0] = XPOS
            pOrigin
    [1] = fAimOrigin[1]
            
    pOrigin[2] = fAimOrigin[2]
            
    engfunc(EngFunc_TraceLinefOriginpOriginDONT_IGNORE_MONSTERSidtr)
            new 
    hitent get_tr2(trTR_pHit)
            if (
    hitent == iEnt)
            {
                new 
    Float:vEnd[3]
                
    get_tr2(trTR_vecEndPosvEnd)
                new 
    Float:RealDistance vector_distance(fOriginvEnd)
                if (
    RealDistance <= Range)
                {
                    new 
    classname[32]
                    
    pev(iEntpev_classnameclassname31)
                    new 
    Float:fTmpDmg
                    
    if (g_IgnoreEnt == hitent)
                        continue
                    if (
    equal(classname"player"))
                        continue
                    else if (
    equal(classname"hostage_entity") || equal(classname"monster_scientist"))
                    {
                        if (
    pev(iEntpev_iuser1) > 0)
                            continue
                        new 
    random_sound random_num(14)
                        new 
    random_file[256]
                        
    format(random_file255"weapons/knife_hit%d.wav"random_sound)
                        
    emit_sound(iEntCHAN_AUTOrandom_file1.0ATTN_NORM0PITCH_NORM)
                        
    fTmpDmg DamageHostage - (DamageHostage Range) * RealDistance;
                        
    ExecuteHamB(Ham_TakeDamageiEntent idfTmpDmg DMG_SLASH)
                    }                    
                    else if (
    equal(classname"func_breakable") || equal(classname"func_pushable"))
                    {
                        
    emit_sound(iEntCHAN_AUTO"weapons/knife_hitwall1.wav"1.0ATTN_NORM0PITCH_NORM)
                        
    fTmpDmg DamageEntity - (DamageEntity Range) * RealDistance;
                        
    ExecuteHamB(Ham_TakeDamageiEntent idfTmpDmg DMG_SLASH)
                    }
                    else 
                    {
                        
    emit_sound(iEntCHAN_AUTO"weapons/knife_hitwall1.wav"1.0ATTN_NORM0PITCH_NORM)
                        
    fTmpDmg DamageEntity - (DamageEntity Range) * RealDistance;
                        
    ExecuteHamB(Ham_TakeDamageiEntent idfTmpDmg DMG_SLASH)
                    }
                }
            }
        }
    Php lại cho bác, em nhìn thấy hơi sốc
     
    Chỉnh sửa cuối: 25/7/11
  11. teobrvt1995

    teobrvt1995 T.E.T.Я.I.S

    Tham gia ngày:
    19/9/10
    Bài viết:
    691
    mọi người cho hỏi tí
    PHP:
    const extra_name = {"SVDex"}
    zp_force_buy_extra_item(idzp_get_extra_item_id(extra_name),1)
    cái zp_get_extra_item_id như vậy đúng ko?
     
  12. dias

    dias Mega Man

    Tham gia ngày:
    17/1/10
    Bài viết:
    3,226
    Nơi ở:
    SEOUL
    ^
    - khi register extra item thế nào thì trong này viết vậy
    -
    PHP:
    const extra_name = {"SVDex"
    zp_force_buy_extra_item(idzp_get_extra_item_id(extra_name),1)  
    =>
    PHP:
    zp_force_buy_extra_item(idzp_get_extra_item_id("Name"),1)  
    viết vào luôn đi const làm gì nữa
     
  13. teobrvt1995

    teobrvt1995 T.E.T.Я.I.S

    Tham gia ngày:
    19/9/10
    Bài viết:
    691
    cho hỏi cái name nó có phân biệt in thường và in hoa ko nhỉ?
     
  14. legiondark

    legiondark Donkey Kong

    Tham gia ngày:
    2/5/11
    Bài viết:
    357
    Nơi ở:
    Skynet !
    Hình như là có .
     
  15. dias

    dias Mega Man

    Tham gia ngày:
    17/1/10
    Bài viết:
    3,226
    Nơi ở:
    SEOUL
    ^
    ^
    - Phân biệt từng chữ cái,...................
     
  16. chichchick59

    chichchick59 Mr & Ms Pac-Man

    Tham gia ngày:
    13/7/11
    Bài viết:
    111
    Nơi ở:
    Hà Nội
    anh nào có plugin HE Mod giống CSO NST legend editon beta 2 không ;)
    anh nào có cho em xin nhé :X :X
     
  17. dias

    dias Mega Man

    Tham gia ngày:
    17/1/10
    Bài viết:
    3,226
    Nơi ở:
    SEOUL
    Phải miêu tả nó như thế nào. Nói thế ai hiểu...
     
  18. MrKaii

    MrKaii The Warrior of Light

    Tham gia ngày:
    14/6/11
    Bài viết:
    2,208
    Nơi ở:
    Hà Nội
    Biết làm nhưng cũng ko chỉ, vì nếu mình chỉ thì có khác rì mình tự ôm rác vào người :|. Nếu thích chơi bomb thì làm như sau, vào game mở console và gõ code này vào "bot_allow_hegraned 1"
     
  19. chichchick59

    chichchick59 Mr & Ms Pac-Man

    Tham gia ngày:
    13/7/11
    Bài viết:
    111
    Nơi ở:
    Hà Nội
    nhưng em muốn host chơi garena thì sao :| với cả em muốn nó có bom liên tục + hông có vk khác ý :D giúp em đi :-w
    Edit : plugin em cần nó như thế này : mới vào ai cũng cầm bom ( có mỗi bom nổ thôi He Mod mà >"< ) và không có dao , khi ném bom ra thì quả bom mới xuất hiện luôn .... cứ như thế
    tiện thể bác nào có plugin respawn share em luôn nhé
     
    Chỉnh sửa cuối: 25/7/11
  20. MrKaii

    MrKaii The Warrior of Light

    Tham gia ngày:
    14/6/11
    Bài viết:
    2,208
    Nơi ở:
    Hà Nội
    Thế thì down bản đấy về mà chơi, tôi nói thực có down về rồi tống lên gg rồi cũng chả có cái host nào đâu :)
     

Chia sẻ trang này