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 = 4
- 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_sprites_exp[MAX_WPN][100]
- new g_wpn_sound_exp[MAX_WPN][100]
- 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 crWeapon[33]
- // 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_cost_name[MAX_WPN][64]
- new cvar_time_sound_name[MAX_WPN][64]
- new cvar_dmgmultiplier[MAX_WPN]
- new cvar_cost[MAX_WPN]
- new cvar_time_sound[MAX_WPN]
- new cvar_buy
- // Sprites
- new gSpriteIndex[MAX_WPN]
- new ent_user[500][2]
- #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_Think,"fw_think")
- register_forward(FM_SetModel, "fw_SetModel")
- // Reg Cmd
- register_clcmd("nst_wpn_4", "menu_wpn")
- register_clcmd("nst_wpn_4_rebuy", "rebuy_wpn")
- cvar_buy = register_cvar("nst_buy_model4", "nst")
- register_clcmd("nst_buy_wpn4", "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++
- }
- }
- 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], cost[32], time_sound[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, "[time_sound]", " ")
- replace(row, 199, "[damage]", " ")
- replace(row, 199, "[cost]", " ")
- replace(row, 199, "[wpn_change]", " ")
- 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(cost, 31, "%s", left)
- strbreak(row,left,63,right,63)
- format(row, 199, "%s", right)
- format(time_sound, 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_cost_name[idwpn], 63, "nst_%s_cost", model)
- format(cvar_time_sound_name[idwpn], 63, "nst_%s_time_sound", model)
- cvar_dmgmultiplier[idwpn] = register_cvar(cvar_dmg_name[idwpn], damage)
- cvar_cost[idwpn] = register_cvar(cvar_cost_name[idwpn], cost)
- cvar_time_sound[idwpn] = register_cvar(cvar_time_sound_name[idwpn], time_sound)
- // 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)
- format(g_wpn_sprites_exp[idwpn], 99, "sprites/nst_wpn/%s_explode.spr", model)
- format(g_wpn_sound_exp[idwpn], 99, "weapons/nst_wpn/%s_explode.wav", model)
- precache_model(P_MODEL[idwpn])
- precache_model(V_MODEL[idwpn])
- precache_model(W_MODEL[idwpn])
- if(!equal(time_sound, "-1")) precache_sound(g_wpn_sound_exp[idwpn])
- gSpriteIndex[idwpn] = engfunc(EngFunc_PrecacheModel,g_wpn_sprites_exp[idwpn])
- idwpn++
- }
- }
- }
- }
- }
- // Human Death
- public zp_user_infected_post(id)
- {
- if (zp_get_user_zombie(id) && HAS_WEAPON[id])
- {
- create_w_class(id, 0)
- HAS_WEAPON[id] = 0
- }
- }
- public Death()
- {
- new id = read_data(2)
- if(HAS_WEAPON[id])
- {
- create_w_class(id, 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 He Smoke:", "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
- // Change Sprites Explode
- public fw_think(ent)
- {
- if(!pev_valid(ent))
- return FMRES_IGNORED;
- if(!pev(ent,pev_bInDuck))
- return FMRES_IGNORED;
- new class[32];
- pev(ent,pev_classname,class,31);
- if(equali(class,"fake_hegren"))
- return FMRES_SUPERCEDE;
- return FMRES_IGNORED;
- }
- public grenade_throw(id,iGren,wid)
- {
- new CURENT_WEAPON = HAS_WEAPON[id]
- new CHANGE_WEAPON = g_wpn_change[CURENT_WEAPON]
- // check if grenade isn't a HeGrenade
- if(wid != CHANGE_WEAPON)
- return PLUGIN_CONTINUE;
- // check if Grenade entity isn't a valid entity
- if(!pev_valid(iGren))
- return PLUGIN_CONTINUE;
- if (HAS_WEAPON[id])
- {
- new id_ent
- if (iGren < sizeof ent_user) id_ent = iGren
- else id_ent = 0
- ent_user[id_ent][0] = id
- ent_user[id_ent][1] = gSpriteIndex[CURENT_WEAPON]
- // set a new classname to HeGrenade
- set_pev(iGren,pev_classname,"fake_hegren")
- // Make it to explode after 1.6 seconds
- set_task(1.6, "gre_explode", iGren)
- set_task(get_pcvar_float(cvar_time_sound[CURENT_WEAPON]),"sound_explode", iGren)
- }
- return PLUGIN_CONTINUE;
- }
- public sound_explode(ent)
- {
- new id_ent
- if (ent < sizeof ent_user) id_ent = ent
- else id_ent = 0
- new id = ent_user[id_ent][0]
- client_cmd(id, "spk %s", g_wpn_sound_exp[HAS_WEAPON[id]])
- HAS_WEAPON[id] = 0
- }
- public gre_explode(ent)
- {
- new id_ent
- if (ent < sizeof ent_user) id_ent = ent
- else id_ent = 0
- new sprites = ent_user[id_ent][1]
- // check if entity isn't valid
- if(!pev_valid(ent))
- return;
- // new variable for origin and get origin of entity
- static Float:origin[3];
- pev(ent,pev_origin,origin);
- message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
- write_byte(TE_EXPLOSION); // TE_EXPLOSION
- write_coord(floatround(origin[0])); // origin x
- write_coord(floatround(origin[1])); // origin y
- write_coord(floatround(origin[2])); // origin z
- write_short(sprites); // sprites
- write_byte(40); // scale in 0.1's
- write_byte(30); // framerate
- write_byte(TE_EXPLFLAG_NONE); // flags
- message_end(); // message end
- //client_print(0, print_chat, "[%i]", ent)
- }
- // End Change Sprites Explode
- // 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])
- 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)
- {
- client_print(id, print_chat, "[NST Wpn] Ban da co %s roi", g_wpn_name[idwpn])
- }
- else
- {
- if (HAS_WEAPON[id]) create_w_class(id, 1)
- current_select[id] = idwpn
- HAS_WEAPON[id] = idwpn
- give_weapon(id, 1)
- cs_set_user_money(id, user_money-wp_cost)
- checkModel(id)
- client_print(id, print_chat, "[NST Wpn] Ban da mua %s", g_wpn_name[idwpn])
- }
- }
- }
- // End Buy Weapon
- // Set W Model
- public fw_SetModel(entity)
- {
- new id = pev(entity,pev_owner)
- new CURENT_WEAPON = HAS_WEAPON[id]
- new CHANGE_WEAPON = g_wpn_change[CURENT_WEAPON]
- if ( crWeapon[id] == CHANGE_WEAPON && HAS_WEAPON[id])
- {
- engfunc(EngFunc_SetModel, entity, W_MODEL[CURENT_WEAPON])
- return FMRES_SUPERCEDE
- }
- return FMRES_IGNORED
- }
- // End Set W Model
- // 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 plrClip, plrAmmo, plrWeapId
- plrWeapId = get_user_weapon(id, plrClip , plrAmmo)
- if ( plrWeapId == 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)
- }
- crWeapon[id] = plrWeapId
- return PLUGIN_HANDLED
- }
- // End Check Weapon
- //Give wpn
- public give_weapon(id, 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)
- 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 create_w_class(id, 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_iuser2, 1)
- 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, 1)
- 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
- /* 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