Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <amxmodx>
- #include <amxmisc>
- #include <fakemeta>
- #include <fakemeta_util>
- #include <fun>
- #include <hamsandwich>
- #include <cstrike>
- #include <engine>
- #include <nst_wpn>
- #include <zombieplague>
- #define PLUGIN "NST Wpn Mod"
- #define VERSION "1.0"
- #define AUTHOR "NST"
- // Var main
- const TYPE_WPN = 1
- const MAX_WPN = 40
- new HAS_WEAPON[33]
- new g_wpn_name[MAX_WPN][32]
- new g_wpn_model[MAX_WPN][32]
- new g_wpn_change[MAX_WPN]
- new g_wpn_cmdbuy[MAX_WPN][32]
- new name_class_weapon[MAX_WPN][32]
- new Name_WpnChange[MAX_WPN][32]
- new current_select[33]
- new user_clip[33][MAX_WPN], user_ammo[33][MAX_WPN]
- new g_hasZoom[33]
- new cost_by_ammo = 60
- new Float:cl_pushangle[33][3]
- // Models
- new P_MODEL[MAX_WPN][64]
- new V_MODEL[MAX_WPN][64]
- new W_MODEL[MAX_WPN][64]
- // Cvar
- new cvar_dmg_name[MAX_WPN][64]
- new cvar_uclip_name[MAX_WPN][64]
- new cvar_speed_name[MAX_WPN][64]
- new cvar_zoom_name[MAX_WPN][64]
- new cvar_clip_name[MAX_WPN][64]
- new cvar_ammo_name[MAX_WPN][64]
- new cvar_recoil_name[MAX_WPN][64]
- new cvar_cost_name[MAX_WPN][64]
- new cvar_dmgmultiplier[MAX_WPN]
- new cvar_uclip[MAX_WPN]
- new cvar_speed[MAX_WPN]
- new cvar_zoom[MAX_WPN]
- new cvar_clip[MAX_WPN]
- new cvar_ammo[MAX_WPN]
- new cvar_recoil[MAX_WPN]
- new cvar_cost[MAX_WPN]
- new cvar_buy
- // Cvar of Public Set Ammo
- enum {
- idle,
- shoot1,
- shoot2,
- insert,
- after_reload,
- start_reload,
- draw
- }
- enum {
- m3,
- xm1014
- }
- const NOCLIP_WPN_BS = ((1<<2)|(1<<CSW_HEGRENADE)|(1<<CSW_SMOKEGRENADE)|(1<<CSW_FLASHBANG)|(1<<CSW_KNIFE)|(1<<CSW_C4))
- const SHOTGUNS_BS = ((1<<CSW_M3)|(1<<CSW_XM1014))
- const SILENT_BS = ((1<<CSW_USP)|(1<<CSW_M4A1))
- 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
- new HamHook:g_iHhPostFrame[CSW_P90+1]
- new HamHook:g_iHhWeapon_WeaponIdle[2]
- stock const g_iDftMaxClip[CSW_P90+1] = {
- -1, 13, -1, 10, 1, 7, 1, 30, 30, 1, 30,
- 20, 25, 30, 35, 25, 12, 20, 10, 30, 100,
- 8 , 30, 30, 20, 2, 7, 30, 30, -1, 50}
- stock const g_iReloadAnims[CSW_P90+1] = {
- -1, 5, -1, 3, -1, 6, -1, 1, 1, -1, 14,
- 4, 2, 3, 1, 1, 13, 7, 4, 1, 3,
- 6, 11, 1, 3, -1, 4, 1, 1, -1, 1}
- stock const Float:g_fDelay[CSW_P90+1] = {
- 0.00, 2.70, 0.00, 2.00, 0.00, 0.55, 0.00, 3.15, 3.30, 0.00, 4.50,
- 2.70, 3.50, 3.35, 2.45, 3.30, 2.70, 2.20, 2.50, 2.63, 4.70,
- 0.55, 3.05, 2.12, 3.50, 0.00, 2.20, 3.00, 2.45, 0.00, 3.40
- }
- new const AMMOID[] = { -1, 9, -1, 2, 12, 5, 14, 6, 4, 13, 10, 7, 6, 4, 4, 4, 6, 10,
- 1, 10, 3, 5, 4, 10, 2, 11, 8, 4, 2, -1, 7}
- #define is_valid_player(%1) (1 <= %1 <= 32)
- public plugin_init() {
- register_plugin(PLUGIN, VERSION, AUTHOR)
- // Reg Public
- register_event("CurWeapon","checkWeapon","be","1=1")
- register_event("DeathMsg", "Death", "a")
- register_event("HLTV", "event_start_freezetime", "a", "1=0", "2=0")
- RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
- register_forward( FM_CmdStart, "fw_CmdStart" )
- // Reg Cmd
- register_clcmd("drop","cmd_drop")
- register_clcmd("buyammo1","buy_ammo")
- register_clcmd("primammo","buy_ammo")
- register_clcmd("nst_wpn_1", "menu_wpn")
- register_clcmd("nst_wpn_1_rebuy", "rebuy_wpn")
- cvar_buy = register_cvar("nst_buy_model1", "nst")
- register_clcmd("nst_buy_wpn1", "buy_weapon_cvar")
- new i = 1, check_value = 1
- while(check_value && i<MAX_WPN)
- {
- if (g_wpn_change[i] <= 0) check_value = 0
- if (check_value)
- {
- new szWpnName[32]
- get_weaponname(g_wpn_change[i], szWpnName, 31)
- format(Name_WpnChange[i], 31, "%s", szWpnName)
- register_clcmd(g_wpn_cmdbuy[i],"buy_weapon", i)
- }
- i++
- }
- // Ammo Clip
- new szWeapon[17]
- for(new i=1; i<=CSW_P90; i++)
- {
- if( !(NOCLIP_WPN_BS & (1<<i)) && get_weaponname(i, szWeapon, charsmax(szWeapon)) )
- {
- RegisterHam(Ham_Weapon_PrimaryAttack, szWeapon, "fw_primary_attack")
- RegisterHam(Ham_Weapon_PrimaryAttack, szWeapon, "fw_primary_attack_post",1)
- if( SHOTGUNS_BS & (1<<i) )
- {
- g_iHhWeapon_WeaponIdle[ i == CSW_M3 ? m3 : xm1014 ] =
- RegisterHam(Ham_Weapon_WeaponIdle, szWeapon, "Shotgun_WeaponIdle")
- g_iHhPostFrame[i] = RegisterHam(Ham_Item_PostFrame, szWeapon, "Shotgun_PostFrame")
- }
- else
- {
- g_iHhPostFrame[i] = RegisterHam(Ham_Item_PostFrame, szWeapon, "Item_PostFrame")
- }
- }
- }
- }
- public plugin_precache()
- {
- new configfile[200]
- get_configsdir(configfile,199)
- format(configfile,199,"%s/nst_wpn.ini",configfile)
- if(file_exists(configfile))
- {
- new row[200], left[64], trash, right[64], idwpn = 1
- new size=file_size(configfile,1)
- for(new i=0;i<size;i++)
- {
- new name[64], model[64], wpn_change, damage[32], uclip[32], speed[32], zoom[32], clip[32], ammo[32], recoil[32], cost[32]
- read_file(configfile,i,row,200,trash)
- if( (contain(row,";")!=0) && strlen(row) && idwpn<MAX_WPN)
- {
- // Create Value
- replace(row, 199, " ", "_")
- replace(row, 199, "[name]", "")
- replace(row, 199, "[model]", " ")
- replace(row, 199, "[wpn_change]", " ")
- replace(row, 199, "[damage]", " ")
- replace(row, 199, "[uclip]", " ")
- replace(row, 199, "[speed]", " ")
- replace(row, 199, "[zoom]", " ")
- replace(row, 199, "[clip]", " ")
- replace(row, 199, "[ammo]", " ")
- replace(row, 199, "[recoil]", " ")
- replace(row, 199, "[cost]", " ")
- strbreak(row,left,63,right,63)
- format(row, 199, "%s", right)
- format(name, 63, "%s", left)
- replace(name, 63, "_", " ")
- strbreak(row,left,63,right,63)
- format(row, 199, "%s", right)
- format(model, 63, "%s", left)
- strbreak(row,left,63,right,63)
- format(row, 199, "%s", right)
- wpn_change = str_to_num(left)
- strbreak(row,left,63,right,63)
- format(row, 199, "%s", right)
- format(damage, 31, "%s", left)
- strbreak(row,left,63,right,63)
- format(row, 199, "%s", right)
- format(uclip, 31, "%s", left)
- strbreak(row,left,63,right,63)
- format(row, 199, "%s", right)
- format(speed, 31, "%s", left)
- strbreak(row,left,63,right,63)
- format(row, 199, "%s", right)
- format(zoom, 31, "%s", left)
- strbreak(row,left,63,right,63)
- format(row, 199, "%s", right)
- format(clip, 31, "%s", left)
- strbreak(row,left,63,right,63)
- format(row, 199, "%s", right)
- format(ammo, 31, "%s", left)
- strbreak(row,left,63,right,63)
- format(row, 199, "%s", right)
- format(recoil, 31, "%s", left)
- strbreak(row,left,63,right,63)
- format(row, 199, "%s", right)
- format(cost, 31, "%s", left)
- if (nst_get_weapon_type(wpn_change) == TYPE_WPN)
- {
- // Set Value
- format(g_wpn_name[idwpn], 31, "%s", name)
- format(g_wpn_model[idwpn], 31, "%s", model)
- format(g_wpn_cmdbuy[idwpn], 31, "nst_buywpn %s", model)
- format(name_class_weapon[idwpn], 31, "nst_%s", model)
- g_wpn_change[idwpn] = wpn_change
- // Create Vvar
- format(cvar_dmg_name[idwpn], 63, "nst_%s_dmg", model)
- format(cvar_uclip_name[idwpn], 63, "nst_%s_uclip", model)
- format(cvar_speed_name[idwpn], 63, "nst_%s_speed", model)
- format(cvar_zoom_name[idwpn], 63, "nst_%s_zoom", model)
- format(cvar_clip_name[idwpn], 63, "nst_%s_clip", model)
- format(cvar_ammo_name[idwpn], 63, "nst_%s_ammo", model)
- format(cvar_recoil_name[idwpn], 63, "nst_%s_recoil", model)
- format(cvar_cost_name[idwpn], 63, "nst_%s_cost", model)
- cvar_dmgmultiplier[idwpn] = register_cvar(cvar_dmg_name[idwpn], damage)
- cvar_uclip[idwpn] = register_cvar(cvar_uclip_name[idwpn], uclip)
- cvar_speed[idwpn] = register_cvar(cvar_speed_name[idwpn], speed)
- cvar_zoom[idwpn] = register_cvar(cvar_zoom_name[idwpn], zoom)
- cvar_clip[idwpn] = register_cvar(cvar_clip_name[idwpn], clip)
- cvar_ammo[idwpn] = register_cvar(cvar_ammo_name[idwpn], ammo)
- cvar_recoil[idwpn] = register_cvar(cvar_recoil_name[idwpn], recoil)
- cvar_cost[idwpn] = register_cvar(cvar_cost_name[idwpn], cost)
- // Create Models
- format(P_MODEL[idwpn], 63, "models/nst_wpn/p_%s.mdl", model)
- format(V_MODEL[idwpn], 63, "models/nst_wpn/v_%s.mdl", model)
- format(W_MODEL[idwpn], 63, "models/nst_wpn/w_%s.mdl", model)
- precache_model(P_MODEL[idwpn])
- precache_model(V_MODEL[idwpn])
- precache_model(W_MODEL[idwpn])
- idwpn++
- }
- }
- }
- }
- }
- // Human Death
- public zp_user_infected_post(id)
- {
- if (zp_get_user_zombie(id) && HAS_WEAPON[id])
- {
- new CURENT_WEAPON = HAS_WEAPON[id]
- create_w_class(id, user_clip[id][CURENT_WEAPON], user_ammo[id][CURENT_WEAPON], 0)
- HAS_WEAPON[id] = 0
- }
- }
- public Death()
- {
- new id = read_data(2)
- new CURENT_WEAPON = HAS_WEAPON[id]
- if(HAS_WEAPON[id])
- {
- create_w_class(id, user_clip[id][CURENT_WEAPON], user_ammo[id][CURENT_WEAPON], 0)
- HAS_WEAPON[id] = 0
- return PLUGIN_HANDLED
- }
- return PLUGIN_CONTINUE
- }
- // End Human Death
- // Menu Wpn
- public menu_wpn(id)
- {
- if (!g_wpn_change[1]) return PLUGIN_HANDLED
- new mHandleID = menu_create("[NST Wpn] Menu Weapon:", "menu_wpn_handler")
- new i = 1, check_value = 1
- while(check_value && i<MAX_WPN)
- {
- if (g_wpn_change[i] <= 0) check_value = 0
- if (check_value)
- {
- new wpn_cost = get_pcvar_num(cvar_cost[i])
- new item_name[150], idwpn[32]
- format(item_name, 149, "%s: %i$", g_wpn_name[i], wpn_cost)
- format(idwpn, 31, "%i", i)
- new check_money[33], user_money = cs_get_user_money(id)
- if(user_money < wpn_cost) check_money[id] = 1
- else check_money[id] = 0
- menu_additem(mHandleID, item_name, idwpn, check_money[id])
- }
- i++
- }
- menu_addblank(mHandleID, 1) // add blank got problem
- menu_setprop(mHandleID, MPROP_PERPAGE, 7)
- menu_display(id, mHandleID, 0)
- return PLUGIN_HANDLED
- }
- public menu_wpn_handler(id, menu, item)
- {
- if (item == MENU_EXIT)
- {
- menu_destroy(menu)
- return PLUGIN_HANDLED
- }
- new idwpn[32], name[32], access
- menu_item_getinfo(menu, item, access, idwpn, 31, name, 31, access)
- //client_print(id, print_chat, "item: %i - id: %s", item, idwpn);
- new idweapon = str_to_num(idwpn)
- buy_weapon(id, idweapon)
- //client_cmd(id, g_wpn_cmdbuy[idweapon])
- menu_destroy(menu)
- return PLUGIN_HANDLED
- }
- public rebuy_wpn(id)
- {
- new idwpn = current_select[id]
- if (idwpn>0) buy_weapon(id, idwpn)
- return PLUGIN_HANDLED
- }
- // End Menu Wpn
- // Control Damage
- public fw_TakeDamage(victim, inflictor, attacker, Float:damage)
- {
- new CURENT_WEAPON = HAS_WEAPON[attacker]
- new CHANGE_WEAPON = g_wpn_change[CURENT_WEAPON]
- if ( is_valid_player( attacker ) && get_user_weapon(attacker) == CHANGE_WEAPON && HAS_WEAPON[attacker] )
- {
- SetHamParamFloat(4, damage * get_pcvar_float( cvar_dmgmultiplier[CURENT_WEAPON] ) )
- }
- }
- // End Control Damage
- // Buy Weapon
- public buy_weapon_cvar(id)
- {
- new models[62]
- get_pcvar_string(cvar_buy, models, 61)
- for(new i=1; i<MAX_WPN; i++)
- {
- if (g_wpn_change[i] > 0)
- {
- if (equali(g_wpn_model[i],models))
- {
- buy_weapon(id, i)
- return PLUGIN_HANDLED
- }
- }
- }
- return PLUGIN_HANDLED
- }
- public buy_weapon(id, idwpn)
- {
- //client_print(id, print_chat, "Mua %i", idwpn)
- new buyzone = cs_get_user_buyzone(id)
- new mod_runing = nst_get_mod_runing()
- if (mod_runing == 1 || mod_runing == 2 || mod_runing == 3) buyzone = 1
- if (buyzone == 0) client_print(id, print_chat, "[NST Wpn] Ban khong the mua Vu khi o vi tri nay")
- else
- {
- new plrClip, plrAmmo
- get_user_weapon(id, plrClip , plrAmmo)
- new user_money = cs_get_user_money(id)
- new wp_cost = get_pcvar_num(cvar_cost[idwpn])
- new clip_max = get_pcvar_num(cvar_clip[idwpn])
- new ammo_max = get_pcvar_num(cvar_ammo[idwpn])
- if (zp_get_user_zombie(id))
- {
- client_print(id, print_chat, "[NST Wpn] Ban dang la Zombie nen khong the mua %s", g_wpn_name[idwpn])
- }
- else if(!is_user_alive(id))
- {
- client_print(id, print_chat, "[NST Wpn] Ban chi co the mua duoc %s khi con song", g_wpn_name[idwpn]);
- }
- else if(user_money < wp_cost)
- {
- client_print(id, print_chat, "[NST Wpn] Ban khong du tien de mua");
- }
- else if(HAS_WEAPON[id] == idwpn)
- {
- new CURENT_WEAPON = HAS_WEAPON[id]
- if (user_ammo[id][CURENT_WEAPON] != ammo_max && user_money >= cost_by_ammo) buy_ammo(id)
- else client_print(id, print_chat, "[NST Wpn] Ban da co %s roi", g_wpn_name[idwpn])
- }
- else
- {
- current_select[id] = idwpn
- drop_prim(id)
- HAS_WEAPON[id] = idwpn
- show_hud_ammo(id, ammo_max)
- give_weapon(id, clip_max, ammo_max)
- cs_set_user_money(id, user_money-wp_cost)
- client_print(id, print_chat, "[NST Wpn] Ban da mua %s", g_wpn_name[idwpn])
- }
- }
- }
- // End Buy Weapon
- // Buy Ammo
- public buy_ammo(id)
- {
- new buyzone = cs_get_user_buyzone(id)
- new mod_runing = nst_get_mod_runing()
- if (mod_runing == 1 || mod_runing == 2 || mod_runing == 3) buyzone = 1
- if (buyzone == 0) client_print(id, print_chat, "[NST Wpn] Ban khong the mua dan o vi tri nay")
- else
- {
- new CURENT_WEAPON = HAS_WEAPON[id]
- new CHANGE_WEAPON = g_wpn_change[CURENT_WEAPON]
- new plrClip, plrAmmo, plrWeapId
- plrWeapId = get_user_weapon(id, plrClip , plrAmmo)
- new ammo_max = get_cvar_num(cvar_ammo_name[CURENT_WEAPON])
- new curent_ammo = user_ammo[id][CURENT_WEAPON]
- new ammo_show = ammo_max - curent_ammo
- new user_money = cs_get_user_money(id)
- if (zp_get_user_zombie(id))
- {
- client_print(id, print_chat, "[NST Wpn] Ban dang la Zombie nen khong the dan", g_wpn_name[CURENT_WEAPON])
- }
- else if(plrWeapId == CHANGE_WEAPON && HAS_WEAPON[id] && user_money >= cost_by_ammo && curent_ammo != ammo_max)
- {
- user_ammo[id][CURENT_WEAPON] = ammo_max
- show_hud_ammo(id, ammo_show)
- cs_set_user_money(id, user_money-cost_by_ammo)
- give_weapon(id, user_clip[id][CURENT_WEAPON], ammo_max)
- }
- }
- }
- // End Buy Ammo
- // Show Hud Ammo
- public show_hud_ammo(id,ammo)
- {
- new CURENT_WEAPON = HAS_WEAPON[id]
- new clip_max = get_pcvar_num(cvar_clip[CURENT_WEAPON])
- if (ammo<=clip_max) fun_show_ammo(id, ammo)
- else
- {
- new ammo_a = ammo % clip_max
- new num_for = (ammo-ammo_a)/clip_max
- for (new i = 1; i <= num_for; i++)
- {
- fun_show_ammo(id, clip_max)
- }
- if (ammo_a>0) fun_show_ammo(id, ammo_a)
- }
- return PLUGIN_HANDLED
- }
- fun_show_ammo(id, ammo)
- {
- new CURENT_WEAPON = HAS_WEAPON[id]
- new CHANGE_WEAPON = g_wpn_change[CURENT_WEAPON]
- message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("AmmoPickup"), _, id)
- write_byte(AMMOID[CHANGE_WEAPON]) // ammo id
- write_byte(ammo) // ammo amount
- message_end()
- }
- // End Show Hud Ammo
- // Check Weapon
- public checkModel(id)
- {
- if (zp_get_user_zombie(id)) return PLUGIN_HANDLED
- new CURENT_WEAPON = HAS_WEAPON[id]
- new CHANGE_WEAPON = g_wpn_change[CURENT_WEAPON]
- new szWeapID = read_data(2)
- if ( szWeapID == CHANGE_WEAPON && HAS_WEAPON[id])
- {
- set_pev(id, pev_viewmodel2, V_MODEL[CURENT_WEAPON])
- set_pev(id, pev_weaponmodel2, P_MODEL[CURENT_WEAPON])
- }
- return PLUGIN_HANDLED
- }
- public checkWeapon(id)
- {
- new CURENT_WEAPON = HAS_WEAPON[id]
- new CHANGE_WEAPON = g_wpn_change[CURENT_WEAPON]
- new plrClip, plrAmmo, plrWeapId
- plrWeapId = get_user_weapon(id, plrClip , plrAmmo)
- if (plrWeapId == CHANGE_WEAPON && HAS_WEAPON[id])
- {
- checkModel(id)
- // Speed
- new Ent = get_weapon_ent(id,plrWeapId)
- new Float:N_Speed
- if(Ent)
- {
- N_Speed = get_pcvar_float(cvar_speed[CURENT_WEAPON])
- new Float:Delay = get_pdata_float( Ent, 46, 4) * N_Speed
- if (Delay > 0.0) {
- set_pdata_float( Ent, 46, Delay, 4)
- }
- }
- // Update Clip Ammo
- user_clip[id][CURENT_WEAPON] = plrClip
- user_ammo[id][CURENT_WEAPON] = plrAmmo
- }
- //client_print(id, print_chat, "[%i]", HAS_WEAPON[id])
- return PLUGIN_HANDLED
- }
- // End Check Weapon
- // Zoom Wepaon
- public fw_CmdStart( id, uc_handle, seed )
- {
- if( !is_user_alive( id ) )
- {
- g_hasZoom[id] = false
- cs_set_user_zoom( id, CS_RESET_ZOOM, 0 )
- return PLUGIN_HANDLED
- }
- new CURENT_WEAPON = HAS_WEAPON[id]
- new CHANGE_WEAPON = g_wpn_change[CURENT_WEAPON]
- new szClip, szAmmo
- new szWeapID = get_user_weapon( id, szClip, szAmmo )
- if(szWeapID == CHANGE_WEAPON && HAS_WEAPON[id])
- {
- // Zoom Weapon
- if (get_pcvar_num(cvar_zoom[CURENT_WEAPON]))
- {
- if( ( get_uc( uc_handle, UC_Buttons ) & IN_ATTACK2 ) && !( pev( id, pev_oldbuttons ) & IN_ATTACK2 ) )
- {
- if(!g_hasZoom[id] == true)
- {
- g_hasZoom[id] = true
- cs_set_user_zoom( id, CS_SET_AUGSG552_ZOOM, 0 )
- client_cmd(id,"spk weapons/zoom")
- }
- else if (g_hasZoom[id])
- {
- g_hasZoom[ id ] = false
- cs_set_user_zoom( id, CS_RESET_ZOOM, 0 )
- }
- }
- }
- // UClip
- if (get_pcvar_num(cvar_uclip[CURENT_WEAPON]) == 1)
- {
- new ent = get_weapon_ent(id,CHANGE_WEAPON)
- cs_set_weapon_ammo(ent, get_pcvar_num(cvar_clip[CURENT_WEAPON]))
- }
- // Update Ammo
- if( !(SHOTGUNS_BS & (1<<CHANGE_WEAPON)) ) cs_set_user_bpammo(id, CHANGE_WEAPON, user_ammo[id][CURENT_WEAPON])
- //client_print(id, print_chat, "[%i] [%i]", get_pcvar_num(cvar_uclip[CURENT_WEAPON]), get_pcvar_num(cvar_zoom[CURENT_WEAPON]))
- }
- if ( (g_hasZoom[ id ] && (pev(id, pev_button) & IN_RELOAD)) || (g_hasZoom[id] && szWeapID != CHANGE_WEAPON) )
- {
- g_hasZoom[id] = false
- cs_set_user_zoom( id, CS_RESET_ZOOM, 0 )
- }
- return PLUGIN_HANDLED
- }
- // End Zoom Wepaon
- //Give wpn
- public give_weapon(id, clip, ammo)
- {
- if (zp_get_user_zombie(id)) return PLUGIN_HANDLED
- new CURENT_WEAPON = HAS_WEAPON[id]
- new CHANGE_WEAPON = g_wpn_change[CURENT_WEAPON]
- give_item(id,Name_WpnChange[CURENT_WEAPON])
- cs_set_user_bpammo(id, CHANGE_WEAPON, ammo)
- new ent = get_weapon_ent(id,CHANGE_WEAPON)
- cs_set_weapon_ammo(ent, clip)
- return PLUGIN_HANDLED
- }
- // Other Public
- public client_connect(id)
- {
- HAS_WEAPON[id] = 0
- }
- public client_disconnect(id)
- {
- HAS_WEAPON[id] = 0
- }
- public event_start_freezetime()
- {
- remove_class_wpn()
- }
- // End Other Public
- // Drop Weapon
- public cmd_drop(id)
- {
- new CURENT_WEAPON = HAS_WEAPON[id]
- new CHANGE_WEAPON = g_wpn_change[CURENT_WEAPON]
- new plrClip, plrAmmo
- new plrWeapId
- plrWeapId = get_user_weapon(id, plrClip , plrAmmo)
- if(plrWeapId == CHANGE_WEAPON && HAS_WEAPON[id] && is_user_alive(id)) {
- create_w_class(id, plrClip, plrAmmo, 1)
- HAS_WEAPON[id] = 0
- return PLUGIN_HANDLED
- }
- return PLUGIN_CONTINUE
- }
- public create_w_class(id, clip, ammo, type)
- {
- new CURENT_WEAPON = HAS_WEAPON[id]
- //new CHANGE_WEAPON = g_wpn_change[CURENT_WEAPON]
- new Float:Aim[3],Float:origin[3]
- VelocityByAim(id, 64, Aim)
- entity_get_vector(id,EV_VEC_origin,origin)
- if (type == 1) {
- origin[0] += 2*Aim[0]
- origin[1] += 2*Aim[1]
- }
- new nst_cre_class = create_entity("info_target")
- entity_set_string(nst_cre_class,EV_SZ_classname,name_class_weapon[CURENT_WEAPON])
- entity_set_model(nst_cre_class,W_MODEL[CURENT_WEAPON])
- entity_set_size(nst_cre_class,Float:{-2.0,-2.0,-2.0},Float:{5.0,5.0,5.0})
- entity_set_int(nst_cre_class,EV_INT_solid,1)
- entity_set_int(nst_cre_class,EV_INT_movetype,6)
- entity_set_int(nst_cre_class, EV_INT_iuser1, clip)
- entity_set_int(nst_cre_class, EV_INT_iuser2, ammo)
- entity_set_vector(nst_cre_class,EV_VEC_origin,origin)
- remowegun(id)
- }
- public remowegun(id)
- {
- new CURENT_WEAPON = HAS_WEAPON[id]
- new CHANGE_WEAPON = g_wpn_change[CURENT_WEAPON]
- new wpnList[32]
- new number
- get_user_weapons(id,wpnList,number)
- for (new i = 0;i < number ;i++) {
- if (wpnList[i] == CHANGE_WEAPON) {
- fm_strip_user_gun(id, wpnList[i])
- }
- }
- }
- // End Drop Weapon
- // Remove Class Wepaons in new round
- public remove_class_wpn()
- {
- new i = 1, check_value = 1
- while(check_value && i<MAX_WPN)
- {
- if (g_wpn_change[i] <= 0) check_value = 0
- new nextitem = find_ent_by_class(-1,name_class_weapon[i])
- while(nextitem)
- {
- remove_entity(nextitem)
- nextitem = find_ent_by_class(-1,name_class_weapon[i])
- }
- i++
- }
- return PLUGIN_CONTINUE
- }
- // End Remove Class Wepaons in new round
- // Weapon Pickup
- public pfn_touch(ptr, ptd) {
- new i = 1, check_value = 1
- while(check_value && i<MAX_WPN)
- {
- if (g_wpn_change[i] <= 0) check_value = 0
- if(is_valid_ent(ptr)) {
- new classname[32]
- entity_get_string(ptr,EV_SZ_classname,classname,31)
- if(equal(classname, name_class_weapon[i])) {
- if(is_valid_ent(ptd)) {
- new id = ptd
- if(id > 0 && id < 34) {
- if (!check_has_wpn(id) && is_user_alive(id) && !(zp_get_user_zombie(id))) {
- HAS_WEAPON[id] = i
- give_weapon(id,entity_get_int(ptr, EV_INT_iuser1), entity_get_int(ptr, EV_INT_iuser2))
- remove_entity(ptr)
- }
- }
- }
- }
- }
- i++
- }
- }
- check_has_wpn(id)
- {
- new weapons[32], num, has_wpn = 0
- get_user_weapons(id, weapons, num)
- new type_wpn_cr = TYPE_WPN
- for (new i = 0; i < num; i++)
- {
- new type_wpn = nst_get_weapon_type(weapons[i])
- if (type_wpn == type_wpn_cr) has_wpn = 1
- }
- return has_wpn
- }
- // End Weapon Pickup
- // Recoil of Weapon
- public fw_primary_attack(ent)
- {
- new id = pev(ent,pev_owner)
- pev(id,pev_punchangle,cl_pushangle[id])
- return HAM_IGNORED
- }
- public fw_primary_attack_post(ent)
- {
- new id = pev(ent,pev_owner)
- new CURENT_WEAPON = HAS_WEAPON[id]
- new CHANGE_WEAPON = g_wpn_change[CURENT_WEAPON]
- new szClip, szAmmo
- new szWeapID = get_user_weapon( id, szClip, szAmmo )
- if( szWeapID == CHANGE_WEAPON && HAS_WEAPON[id])
- {
- new Float:push[3]
- pev(id,pev_punchangle,push)
- xs_vec_sub(push,cl_pushangle[id],push)
- xs_vec_mul_scalar(push,get_pcvar_float(cvar_recoil[CURENT_WEAPON]),push)
- xs_vec_add(push,cl_pushangle[id],push)
- set_pev(id,pev_punchangle,push)
- }
- return HAM_IGNORED
- }
- // End Recoil of Weapon
- // Give Ammo Clip
- public Item_PostFrame(iEnt)
- {
- static id ; id = get_pdata_cbase(iEnt, m_pPlayer, 4)
- new CURENT_WEAPON = HAS_WEAPON[id]
- new CHANGE_WEAPON = g_wpn_change[CURENT_WEAPON]
- new plrClip, plrAmmo, plrWeapId
- plrWeapId = get_user_weapon(id, plrClip , plrAmmo)
- if (plrWeapId == CHANGE_WEAPON && HAS_WEAPON[id])
- {
- static iId ; iId = get_pdata_int(iEnt, m_iId, 4)
- static iMaxClip ; iMaxClip = get_pcvar_num(cvar_clip[CURENT_WEAPON])
- static fInReload ; fInReload = get_pdata_int(iEnt, m_fInReload, 4)
- static Float:flNextAttack ; flNextAttack = get_pdata_float(id, m_flNextAttack, 5)
- static iAmmoType ; iAmmoType = m_rgAmmo_player_Slot0 + get_pdata_int(iEnt, m_iPrimaryAmmoType, 4)
- static iBpAmmo ; iBpAmmo = get_pdata_int(id, iAmmoType, 5)
- static iClip ; iClip = get_pdata_int(iEnt, m_iClip, 4)
- if( fInReload && flNextAttack <= 0.0 )
- {
- new j = min(iMaxClip - iClip, iBpAmmo)
- set_pdata_int(iEnt, m_iClip, iClip + j, 4)
- set_pdata_int(id, iAmmoType, iBpAmmo-j, 5)
- set_pdata_int(iEnt, m_fInReload, 0, 4)
- user_ammo[id][CURENT_WEAPON] = iBpAmmo-j
- fInReload = 0
- }
- static iButton ; iButton = pev(id, pev_button)
- if( (iButton & IN_ATTACK2 && get_pdata_float(iEnt, m_flNextSecondaryAttack, 4) <= 0.0)
- || (iButton & IN_ATTACK && get_pdata_float(iEnt, m_flNextPrimaryAttack, 4) <= 0.0) )
- {
- return
- }
- if( iButton & IN_RELOAD && !fInReload )
- {
- if( iClip >= iMaxClip )
- {
- set_pev(id, pev_button, iButton & ~IN_RELOAD)
- if( SILENT_BS & (1<<iId) && !get_pdata_int(iEnt, m_fSilent, 4) )
- {
- SendWeaponAnim( id, iId == CSW_USP ? 8 : 7 )
- }
- else
- {
- SendWeaponAnim(id, 0)
- }
- }
- else if( iClip == g_iDftMaxClip[iId] )
- {
- if( iBpAmmo )
- {
- set_pdata_float(id, m_flNextAttack, g_fDelay[iId], 5)
- if( SILENT_BS & (1<<iId) && get_pdata_int(iEnt, m_fSilent, 4) )
- {
- SendWeaponAnim( id, iId == CSW_USP ? 5 : 4 )
- }
- else
- {
- SendWeaponAnim(id, g_iReloadAnims[iId])
- }
- set_pdata_int(iEnt, m_fInReload, 1, 4)
- set_pdata_float(iEnt, m_flTimeWeaponIdle, g_fDelay[iId] + 0.5, 4)
- }
- }
- }
- }
- }
- SendWeaponAnim(id, iAnim)
- {
- set_pev(id, pev_weaponanim, iAnim)
- message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, _, id)
- write_byte(iAnim)
- write_byte(pev(id,pev_body))
- message_end()
- }
- public Shotgun_WeaponIdle( iEnt )
- {
- if( get_pdata_float(iEnt, m_flTimeWeaponIdle, 4) > 0.0 )
- {
- return
- }
- static id ; id = get_pdata_cbase(iEnt, m_pPlayer, 4)
- new CURENT_WEAPON = HAS_WEAPON[id]
- new CHANGE_WEAPON = g_wpn_change[CURENT_WEAPON]
- new plrClip, plrAmmo, plrWeapId
- plrWeapId = get_user_weapon(id, plrClip , plrAmmo)
- if (plrWeapId == CHANGE_WEAPON && HAS_WEAPON[id])
- {
- static iId ; iId = get_pdata_int(iEnt, m_iId, 4)
- static iMaxClip ; iMaxClip = get_pcvar_num(cvar_clip[CURENT_WEAPON])
- static iClip ; iClip = get_pdata_int(iEnt, m_iClip, 4)
- static fInSpecialReload ; fInSpecialReload = get_pdata_int(iEnt, m_fInSpecialReload, 4)
- if( !iClip && !fInSpecialReload )
- {
- return
- }
- if( fInSpecialReload )
- {
- static id ; id = get_pdata_cbase(iEnt, m_pPlayer, 4)
- static iBpAmmo ; iBpAmmo = get_pdata_int(id, 381, 5)
- static iDftMaxClip ; iDftMaxClip = g_iDftMaxClip[iId]
- if( iClip < iMaxClip && iClip == iDftMaxClip && iBpAmmo )
- {
- Shotgun_Reload(iEnt, iId, iMaxClip, iClip, iBpAmmo, id)
- return
- }
- else if( iClip == iMaxClip && iClip != iDftMaxClip )
- {
- SendWeaponAnim( id, after_reload )
- set_pdata_int(iEnt, m_fInSpecialReload, 0, 4)
- set_pdata_float(iEnt, m_flTimeWeaponIdle, 1.5, 4)
- }
- }
- return
- }
- }
- public Shotgun_PostFrame( iEnt )
- {
- static id ; id = get_pdata_cbase(iEnt, m_pPlayer, 4)
- new CURENT_WEAPON = HAS_WEAPON[id]
- new CHANGE_WEAPON = g_wpn_change[CURENT_WEAPON]
- new plrClip, plrAmmo, plrWeapId
- plrWeapId = get_user_weapon(id, plrClip , plrAmmo)
- if (plrWeapId == CHANGE_WEAPON && HAS_WEAPON[id])
- {
- static iBpAmmo ; iBpAmmo = get_pdata_int(id, 381, 5)
- static iClip ; iClip = get_pdata_int(iEnt, m_iClip, 4)
- static iId ; iId = get_pdata_int(iEnt, m_iId, 4)
- static iMaxClip ; iMaxClip = get_pcvar_num(cvar_clip[CURENT_WEAPON])
- // Support for instant reload (used for example in my plugin "Reloaded Weapons On New Round")
- if( get_pdata_int(iEnt, m_fInReload, 4) && get_pdata_float(id, m_flNextAttack, 5) <= 0.0 )
- {
- new j = min(iMaxClip - iClip, iBpAmmo)
- set_pdata_int(iEnt, m_iClip, iClip + j, 4)
- set_pdata_int(id, 381, iBpAmmo-j, 5)
- set_pdata_int(iEnt, m_fInReload, 0, 4)
- user_ammo[id][CURENT_WEAPON] = iBpAmmo-j
- return
- }
- static iButton ; iButton = pev(id, pev_button)
- if( iButton & IN_ATTACK && get_pdata_float(iEnt, m_flNextPrimaryAttack, 4) <= 0.0 )
- {
- return
- }
- if( iButton & IN_RELOAD )
- {
- if( iClip >= iMaxClip )
- {
- set_pev(id, pev_button, iButton & ~IN_RELOAD) // still this fucking animation
- set_pdata_float(iEnt, m_flNextPrimaryAttack, 0.5, 4) // Tip ?
- }
- else if( iClip == g_iDftMaxClip[iId] )
- {
- if( iBpAmmo )
- {
- Shotgun_Reload(iEnt, iId, iMaxClip, iClip, iBpAmmo, id)
- }
- }
- }
- }
- }
- Shotgun_Reload(iEnt, iId, iMaxClip, iClip, iBpAmmo, id)
- {
- static id ; id = get_pdata_cbase(iEnt, m_pPlayer, 4)
- new CURENT_WEAPON = HAS_WEAPON[id]
- new CHANGE_WEAPON = g_wpn_change[CURENT_WEAPON]
- new plrClip, plrAmmo, plrWeapId
- plrWeapId = get_user_weapon(id, plrClip , plrAmmo)
- if (plrWeapId == CHANGE_WEAPON && HAS_WEAPON[id])
- {
- if(iBpAmmo <= 0 || iClip == iMaxClip)
- return
- if(get_pdata_int(iEnt, m_flNextPrimaryAttack, 4) > 0.0)
- return
- switch( get_pdata_int(iEnt, m_fInSpecialReload, 4) )
- {
- case 0:
- {
- SendWeaponAnim( id , start_reload )
- set_pdata_int(iEnt, m_fInSpecialReload, 1, 4)
- set_pdata_float(id, m_flNextAttack, 0.55, 4)
- set_pdata_float(iEnt, m_flTimeWeaponIdle, 0.55, 4)
- set_pdata_float(iEnt, m_flNextPrimaryAttack, 0.55, 4)
- set_pdata_float(iEnt, m_flNextSecondaryAttack, 0.55, 4)
- return
- }
- case 1:
- {
- if( get_pdata_float(iEnt, m_flTimeWeaponIdle, 4) > 0.0 )
- {
- return
- }
- set_pdata_int(iEnt, m_fInSpecialReload, 2, 4)
- emit_sound(id, CHAN_ITEM, random_num(0,1) ? "weapons/reload1.wav" : "weapons/reload3.wav", 1.0, ATTN_NORM, 0, 85 + random_num(0,0x1f))
- SendWeaponAnim( id, insert )
- set_pdata_float(iEnt, m_flTimeWeaponIdle, iId == CSW_XM1014 ? 0.30 : 0.45, 4)
- }
- default:
- {
- set_pdata_int(iEnt, m_iClip, iClip + 1, 4)
- set_pdata_int(id, 381, iBpAmmo-1, 5)
- set_pdata_int(iEnt, m_fInSpecialReload, 1, 4)
- user_ammo[id][CURENT_WEAPON] = iBpAmmo-1
- }
- }
- }
- }
- // End Give Ammo Clip
- // Stock
- stock drop_prim(id)
- {
- //new CURENT_WEAPON = HAS_WEAPON[id]
- ///new CHANGE_WEAPON = g_wpn_change[CURENT_WEAPON]
- new weapons[32], num
- get_user_weapons(id, weapons, num)
- for (new i = 0; i < num; i++)
- {
- new type_wpn = nst_get_weapon_type(weapons[i])
- new type_wpn_cr = TYPE_WPN
- if (type_wpn == type_wpn_cr)
- {
- if (!HAS_WEAPON[id])
- {
- static wname[32]
- get_weaponname(weapons[i], wname, sizeof wname - 1)
- engclient_cmd(id, "drop", wname)
- }
- else
- {
- new CURENT_WEAPON = HAS_WEAPON[id]
- remowegun(id)
- create_w_class(id, user_clip[id][CURENT_WEAPON], user_ammo[id][CURENT_WEAPON], 1)
- HAS_WEAPON[id] = 0
- }
- }
- }
- }
- //get weapon id
- stock get_weapon_ent(id,wpnid=0,wpnName[]="")
- {
- // who knows what wpnName will be
- static newName[24];
- // need to find the name
- if(wpnid) get_weaponname(wpnid,newName,23);
- // go with what we were told
- else formatex(newName,23,"%s",wpnName);
- // prefix it if we need to
- if(!equal(newName,"weapon_",7))
- format(newName,23,"weapon_%s",newName);
- return fm_find_ent_by_owner(get_maxplayers(),newName,id);
- }
- /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
- *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1034\\ f0\\ fs16 \n\\ par }
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement