Guest User

pistols

a guest
Apr 25th, 2017
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.62 KB | None | 0 0
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <fakemeta>
  4. #include <fakemeta_util>
  5. #include <fun>
  6. #include <hamsandwich>
  7. #include <cstrike>
  8. #include <engine>
  9. #include <nst_wpn>
  10.  
  11. #include <zombieplague>
  12.  
  13. #define PLUGIN "NST Wpn Mod"
  14. #define VERSION "1.0"
  15. #define AUTHOR "NST"
  16.  
  17.  
  18. // Var main
  19. const TYPE_WPN = 2
  20. const MAX_WPN = 40
  21. new HAS_WEAPON[33]
  22. new g_wpn_name[MAX_WPN][32]
  23. new g_wpn_model[MAX_WPN][32]
  24. new g_wpn_change[MAX_WPN]
  25. new g_wpn_cmdbuy[MAX_WPN][32]
  26. new name_class_weapon[MAX_WPN][32]
  27. new Name_WpnChange[MAX_WPN][32]
  28.  
  29. new current_select[33]
  30. new user_clip[33][MAX_WPN], user_ammo[33][MAX_WPN]
  31. new g_hasZoom[33]
  32. new cost_by_ammo = 60
  33. new Float:cl_pushangle[33][3]
  34.  
  35. // Models
  36. new P_MODEL[MAX_WPN][64]
  37. new V_MODEL[MAX_WPN][64]
  38. new W_MODEL[MAX_WPN][64]
  39.  
  40.  
  41. // Cvar
  42. new cvar_dmg_name[MAX_WPN][64]
  43. new cvar_uclip_name[MAX_WPN][64]
  44. new cvar_speed_name[MAX_WPN][64]
  45. new cvar_zoom_name[MAX_WPN][64]
  46. new cvar_clip_name[MAX_WPN][64]
  47. new cvar_ammo_name[MAX_WPN][64]
  48. new cvar_recoil_name[MAX_WPN][64]
  49. new cvar_cost_name[MAX_WPN][64]
  50.  
  51. new cvar_dmgmultiplier[MAX_WPN]
  52. new cvar_uclip[MAX_WPN]
  53. new cvar_speed[MAX_WPN]
  54. new cvar_zoom[MAX_WPN]
  55. new cvar_clip[MAX_WPN]
  56. new cvar_ammo[MAX_WPN]
  57. new cvar_recoil[MAX_WPN]
  58. new cvar_cost[MAX_WPN]
  59. new cvar_buy
  60.  
  61. // Cvar of Public Set Ammo
  62. const SILENT_BS = ((1<<CSW_USP)|(1<<CSW_M4A1))
  63. const m_pPlayer = 41
  64. const m_iId = 43
  65. const m_fKnown = 44
  66. const m_flNextPrimaryAttack = 46
  67. const m_flNextSecondaryAttack = 47
  68. const m_flTimeWeaponIdle = 48
  69. const m_iPrimaryAmmoType = 49
  70. const m_iClip = 51
  71. const m_fInReload = 54
  72. const m_fInSpecialReload = 55
  73. const m_fSilent = 74
  74. const m_flNextAttack = 83
  75. const m_rgAmmo_player_Slot0 = 376
  76. stock const g_iDftMaxClip[CSW_P90+1] = {
  77. -1, 13, -1, 10, 1, 7, 1, 30, 30, 1, 30,
  78. 20, 25, 30, 35, 25, 12, 20, 10, 30, 100,
  79. 8 , 30, 30, 20, 2, 7, 30, 30, -1, 50}
  80.  
  81. stock const g_iReloadAnims[CSW_P90+1] = {
  82. -1, 5, -1, 3, -1, 6, -1, 1, 1, -1, 14,
  83. 4, 2, 3, 1, 1, 13, 7, 4, 1, 3,
  84. 6, 11, 1, 3, -1, 4, 1, 1, -1, 1}
  85.  
  86. stock const Float:g_fDelay[CSW_P90+1] = {
  87. 0.00, 2.70, 0.00, 2.00, 0.00, 0.55, 0.00, 3.15, 3.30, 0.00, 4.50,
  88. 2.70, 3.50, 3.35, 2.45, 3.30, 2.70, 2.20, 2.50, 2.63, 4.70,
  89. 0.55, 3.05, 2.12, 3.50, 0.00, 2.20, 3.00, 2.45, 0.00, 3.40
  90. }
  91. new const AMMOID[] = { -1, 9, -1, 2, 12, 5, 14, 6, 4, 13, 10, 7, 6, 4, 4, 4, 6, 10,
  92. 1, 10, 3, 5, 4, 10, 2, 11, 8, 4, 2, -1, 7}
  93.  
  94. #define is_valid_player(%1) (1 <= %1 <= 32)
  95.  
  96.  
  97.  
  98. public plugin_init() {
  99. register_plugin(PLUGIN, VERSION, AUTHOR)
  100.  
  101. // Reg Public
  102. register_event("CurWeapon","checkWeapon","be","1=1")
  103. register_event("DeathMsg", "Death", "a")
  104. register_event("HLTV", "event_start_freezetime", "a", "1=0", "2=0")
  105. RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
  106. register_forward( FM_CmdStart, "fw_CmdStart" )
  107.  
  108. // Reg Cmd
  109. register_clcmd("drop","cmd_drop")
  110. register_clcmd("buyammo1","buy_ammo")
  111. register_clcmd("primammo","buy_ammo")
  112. register_clcmd("nst_wpn_2", "menu_wpn")
  113. register_clcmd("nst_wpn_2_rebuy", "rebuy_wpn")
  114. cvar_buy = register_cvar("nst_buy_model2", "nst")
  115. register_clcmd("nst_buy_wpn2", "buy_weapon_cvar")
  116.  
  117. new i = 1, check_value = 1
  118. while(check_value && i<MAX_WPN)
  119. {
  120. if (g_wpn_change[i] <= 0) check_value = 0
  121. if (check_value)
  122. {
  123. new szWpnName[32]
  124. get_weaponname(g_wpn_change[i], szWpnName, 31)
  125. format(Name_WpnChange[i], 31, "%s", szWpnName)
  126. RegisterHam(Ham_Item_PostFrame, Name_WpnChange[i], "Item_PostFrame")
  127. RegisterHam(Ham_Weapon_PrimaryAttack, Name_WpnChange[i], "fw_primary_attack")
  128. RegisterHam(Ham_Weapon_PrimaryAttack, Name_WpnChange[i], "fw_primary_attack_post",1)
  129. register_clcmd(g_wpn_cmdbuy[i],"buy_weapon", i)
  130. }
  131. i++
  132. }
  133. }
  134.  
  135. public plugin_precache()
  136. {
  137. new configfile[200]
  138. get_configsdir(configfile,199)
  139. format(configfile,199,"%s/nst_wpn.ini",configfile)
  140. if(file_exists(configfile))
  141. {
  142. new row[200], left[64], trash, right[64], idwpn = 1
  143. new size=file_size(configfile,1)
  144. for(new i=0;i<size;i++)
  145. {
  146.  
  147. new name[64], model[64], wpn_change, damage[32], uclip[32], speed[32], zoom[32], clip[32], ammo[32], recoil[32], cost[32]
  148. read_file(configfile,i,row,200,trash)
  149. if( (contain(row,";")!=0) && strlen(row) && idwpn<MAX_WPN)
  150. {
  151.  
  152. // Create Value
  153. replace(row, 199, " ", "_")
  154. replace(row, 199, "[name]", "")
  155. replace(row, 199, "[model]", " ")
  156. replace(row, 199, "[wpn_change]", " ")
  157. replace(row, 199, "[damage]", " ")
  158. replace(row, 199, "[uclip]", " ")
  159. replace(row, 199, "[speed]", " ")
  160. replace(row, 199, "[zoom]", " ")
  161. replace(row, 199, "[clip]", " ")
  162. replace(row, 199, "[ammo]", " ")
  163. replace(row, 199, "[recoil]", " ")
  164. replace(row, 199, "[cost]", " ")
  165.  
  166. strbreak(row,left,63,right,63)
  167. format(row, 199, "%s", right)
  168. format(name, 63, "%s", left)
  169. replace(name, 63, "_", " ")
  170.  
  171. strbreak(row,left,63,right,63)
  172. format(row, 199, "%s", right)
  173. format(model, 63, "%s", left)
  174.  
  175. strbreak(row,left,63,right,63)
  176. format(row, 199, "%s", right)
  177. wpn_change = str_to_num(left)
  178.  
  179. strbreak(row,left,63,right,63)
  180. format(row, 199, "%s", right)
  181. format(damage, 31, "%s", left)
  182.  
  183. strbreak(row,left,63,right,63)
  184. format(row, 199, "%s", right)
  185. format(uclip, 31, "%s", left)
  186.  
  187. strbreak(row,left,63,right,63)
  188. format(row, 199, "%s", right)
  189. format(speed, 31, "%s", left)
  190.  
  191. strbreak(row,left,63,right,63)
  192. format(row, 199, "%s", right)
  193. format(zoom, 31, "%s", left)
  194.  
  195. strbreak(row,left,63,right,63)
  196. format(row, 199, "%s", right)
  197. format(clip, 31, "%s", left)
  198.  
  199. strbreak(row,left,63,right,63)
  200. format(row, 199, "%s", right)
  201. format(ammo, 31, "%s", left)
  202.  
  203. strbreak(row,left,63,right,63)
  204. format(row, 199, "%s", right)
  205. format(recoil, 31, "%s", left)
  206.  
  207. strbreak(row,left,63,right,63)
  208. format(row, 199, "%s", right)
  209. format(cost, 31, "%s", left)
  210.  
  211. if (nst_get_weapon_type(wpn_change) == TYPE_WPN)
  212. {
  213. // Set Value
  214. format(g_wpn_name[idwpn], 31, "%s", name)
  215. format(g_wpn_model[idwpn], 31, "%s", model)
  216. format(g_wpn_cmdbuy[idwpn], 31, "nst_buywpn %s", model)
  217. format(name_class_weapon[idwpn], 31, "nst_%s", model)
  218. g_wpn_change[idwpn] = wpn_change
  219.  
  220.  
  221. // Create Vvar
  222. format(cvar_dmg_name[idwpn], 63, "nst_%s_dmg", model)
  223. format(cvar_uclip_name[idwpn], 63, "nst_%s_uclip", model)
  224. format(cvar_speed_name[idwpn], 63, "nst_%s_speed", model)
  225. format(cvar_zoom_name[idwpn], 63, "nst_%s_zoom", model)
  226. format(cvar_clip_name[idwpn], 63, "nst_%s_clip", model)
  227. format(cvar_ammo_name[idwpn], 63, "nst_%s_ammo", model)
  228. format(cvar_recoil_name[idwpn], 63, "nst_%s_recoil", model)
  229. format(cvar_cost_name[idwpn], 63, "nst_%s_cost", model)
  230. cvar_dmgmultiplier[idwpn] = register_cvar(cvar_dmg_name[idwpn], damage)
  231. cvar_uclip[idwpn] = register_cvar(cvar_uclip_name[idwpn], uclip)
  232. cvar_speed[idwpn] = register_cvar(cvar_speed_name[idwpn], speed)
  233. cvar_zoom[idwpn] = register_cvar(cvar_zoom_name[idwpn], zoom)
  234. cvar_clip[idwpn] = register_cvar(cvar_clip_name[idwpn], clip)
  235. cvar_ammo[idwpn] = register_cvar(cvar_ammo_name[idwpn], ammo)
  236. cvar_recoil[idwpn] = register_cvar(cvar_recoil_name[idwpn], recoil)
  237. cvar_cost[idwpn] = register_cvar(cvar_cost_name[idwpn], cost)
  238.  
  239.  
  240. // Create Models
  241. format(P_MODEL[idwpn], 63, "models/nst_wpn/p_%s.mdl", model)
  242. format(V_MODEL[idwpn], 63, "models/nst_wpn/v_%s.mdl", model)
  243. format(W_MODEL[idwpn], 63, "models/nst_wpn/w_%s.mdl", model)
  244. precache_model(P_MODEL[idwpn])
  245. precache_model(V_MODEL[idwpn])
  246. precache_model(W_MODEL[idwpn])
  247.  
  248. idwpn++
  249. }
  250. }
  251. }
  252.  
  253. }
  254.  
  255. }
  256.  
  257. // Human Death
  258. public zp_user_infected_post(id)
  259. {
  260. if (zp_get_user_zombie(id) && HAS_WEAPON[id])
  261. {
  262. new CURENT_WEAPON = HAS_WEAPON[id]
  263. create_w_class(id, user_clip[id][CURENT_WEAPON], user_ammo[id][CURENT_WEAPON], 0)
  264. HAS_WEAPON[id] = 0
  265. }
  266. }
  267. public Death()
  268. {
  269. new id = read_data(2)
  270. new CURENT_WEAPON = HAS_WEAPON[id]
  271. if(HAS_WEAPON[id])
  272. {
  273. create_w_class(id, user_clip[id][CURENT_WEAPON], user_ammo[id][CURENT_WEAPON], 0)
  274. HAS_WEAPON[id] = 0
  275. return PLUGIN_HANDLED
  276. }
  277.  
  278. return PLUGIN_CONTINUE
  279. }
  280. // End Human Death
  281.  
  282.  
  283. // Menu Wpn
  284. public menu_wpn(id)
  285. {
  286. if (!g_wpn_change[1]) return PLUGIN_HANDLED
  287.  
  288.  
  289. new mHandleID = menu_create("[NST Wpn] Menu Weapon:", "menu_wpn_handler")
  290. new i = 1, check_value = 1
  291. while(check_value && i<MAX_WPN)
  292. {
  293. if (g_wpn_change[i] <= 0) check_value = 0
  294. if (check_value)
  295. {
  296. new wpn_cost = get_pcvar_num(cvar_cost[i])
  297. new item_name[150], idwpn[32]
  298. format(item_name, 149, "%s: %i$", g_wpn_name[i], wpn_cost)
  299. format(idwpn, 31, "%i", i)
  300.  
  301. new check_money[33], user_money = cs_get_user_money(id)
  302. if(user_money < wpn_cost) check_money[id] = 1
  303. else check_money[id] = 0
  304.  
  305. menu_additem(mHandleID, item_name, idwpn, check_money[id])
  306. }
  307. i++
  308. }
  309.  
  310. menu_addblank(mHandleID, 1) // add blank got problem
  311. menu_setprop(mHandleID, MPROP_PERPAGE, 7)
  312. menu_display(id, mHandleID, 0)
  313.  
  314.  
  315. return PLUGIN_HANDLED
  316. }
  317. public menu_wpn_handler(id, menu, item)
  318. {
  319. if (item == MENU_EXIT)
  320. {
  321. menu_destroy(menu)
  322. return PLUGIN_HANDLED
  323. }
  324. new idwpn[32], name[32], access
  325. menu_item_getinfo(menu, item, access, idwpn, 31, name, 31, access)
  326. //client_print(id, print_chat, "item: %i - id: %s", item, idwpn);
  327.  
  328. new idweapon = str_to_num(idwpn)
  329. buy_weapon(id, idweapon)
  330. //client_cmd(id, g_wpn_cmdbuy[idweapon])
  331.  
  332.  
  333. menu_destroy(menu)
  334. return PLUGIN_HANDLED
  335. }
  336. public rebuy_wpn(id)
  337. {
  338. new idwpn = current_select[id]
  339. if (idwpn>0) buy_weapon(id, idwpn)
  340.  
  341. return PLUGIN_HANDLED
  342. }
  343. // End Menu Wpn
  344.  
  345.  
  346. // Control Damage
  347. public fw_TakeDamage(victim, inflictor, attacker, Float:damage)
  348. {
  349. new CURENT_WEAPON = HAS_WEAPON[attacker]
  350. new CHANGE_WEAPON = g_wpn_change[CURENT_WEAPON]
  351.  
  352. if ( is_valid_player( attacker ) && get_user_weapon(attacker) == CHANGE_WEAPON && HAS_WEAPON[attacker] )
  353. {
  354. SetHamParamFloat(4, damage * get_pcvar_float( cvar_dmgmultiplier[CURENT_WEAPON] ) )
  355. }
  356. }
  357. // End Control Damage
  358.  
  359.  
  360. // Buy Weapon
  361. public buy_weapon_cvar(id)
  362. {
  363. new models[62]
  364. get_pcvar_string(cvar_buy, models, 61)
  365.  
  366. for(new i=1; i<MAX_WPN; i++)
  367. {
  368. if (g_wpn_change[i] > 0)
  369. {
  370. if (equali(g_wpn_model[i],models))
  371. {
  372. buy_weapon(id, i)
  373. return PLUGIN_HANDLED
  374. }
  375. }
  376. }
  377. return PLUGIN_HANDLED
  378. }
  379. public buy_weapon(id, idwpn)
  380. {
  381. //client_print(id, print_chat, "Mua %i", idwpn)
  382.  
  383. new buyzone = cs_get_user_buyzone(id)
  384. new mod_runing = nst_get_mod_runing()
  385. if (mod_runing == 1 || mod_runing == 2 || mod_runing == 3) buyzone = 1
  386.  
  387. if (buyzone == 0) client_print(id, print_chat, "[NST Wpn] Ban khong the mua Vu khi o vi tri nay")
  388. else
  389. {
  390. new plrClip, plrAmmo
  391. get_user_weapon(id, plrClip , plrAmmo)
  392.  
  393. new user_money = cs_get_user_money(id)
  394. new wp_cost = get_pcvar_num(cvar_cost[idwpn])
  395. new clip_max = get_pcvar_num(cvar_clip[idwpn])
  396. new ammo_max = get_pcvar_num(cvar_ammo[idwpn])
  397.  
  398. if (zp_get_user_zombie(id))
  399. {
  400. client_print(id, print_chat, "[NST Wpn] Ban dang la Zombie nen khong the mua %s", g_wpn_name[idwpn])
  401. }
  402. else if(!is_user_alive(id))
  403. {
  404. client_print(id, print_chat, "[NST Wpn] Ban chi co the mua duoc %s khi con song", g_wpn_name[idwpn]);
  405. }
  406. else if(user_money < wp_cost)
  407. {
  408. client_print(id, print_chat, "[NST Wpn] Ban khong du tien de mua");
  409. }
  410. else if(HAS_WEAPON[id] == idwpn)
  411. {
  412. new CURENT_WEAPON = HAS_WEAPON[id]
  413. if (user_ammo[id][CURENT_WEAPON] != ammo_max && user_money >= cost_by_ammo) buy_ammo(id)
  414. else client_print(id, print_chat, "[NST Wpn] Ban da co %s roi", g_wpn_name[idwpn])
  415. }
  416. else
  417. {
  418. current_select[id] = idwpn
  419. drop_prim(id)
  420. HAS_WEAPON[id] = idwpn
  421. show_hud_ammo(id, ammo_max)
  422. give_weapon(id, clip_max, ammo_max)
  423. cs_set_user_money(id, user_money-wp_cost)
  424. client_print(id, print_chat, "[NST Wpn] Ban da mua %s", g_wpn_name[idwpn])
  425. }
  426. }
  427.  
  428. }
  429. // End Buy Weapon
  430.  
  431. // Buy Ammo
  432. public buy_ammo(id)
  433. {
  434. new buyzone = cs_get_user_buyzone(id)
  435. new mod_runing = nst_get_mod_runing()
  436. if (mod_runing == 1 || mod_runing == 2 || mod_runing == 3) buyzone = 1
  437.  
  438. if (buyzone == 0) client_print(id, print_chat, "[NST Wpn] Ban khong the mua dan o vi tri nay")
  439. else
  440. {
  441. new CURENT_WEAPON = HAS_WEAPON[id]
  442. new CHANGE_WEAPON = g_wpn_change[CURENT_WEAPON]
  443.  
  444. new plrClip, plrAmmo, plrWeapId
  445. plrWeapId = get_user_weapon(id, plrClip , plrAmmo)
  446. new ammo_max = get_cvar_num(cvar_ammo_name[CURENT_WEAPON])
  447. new curent_ammo = user_ammo[id][CURENT_WEAPON]
  448. new ammo_show = ammo_max - curent_ammo
  449. new user_money = cs_get_user_money(id)
  450.  
  451. if (zp_get_user_zombie(id))
  452. {
  453. client_print(id, print_chat, "[NST Wpn] Ban dang la Zombie nen khong the dan", g_wpn_name[CURENT_WEAPON])
  454. }
  455. else if(plrWeapId == CHANGE_WEAPON && HAS_WEAPON[id] && user_money >= cost_by_ammo && curent_ammo != ammo_max)
  456. {
  457. user_ammo[id][CURENT_WEAPON] = ammo_max
  458. show_hud_ammo(id, ammo_show)
  459. cs_set_user_money(id, user_money-cost_by_ammo)
  460. give_weapon(id, user_clip[id][CURENT_WEAPON], ammo_max)
  461. }
  462. }
  463. }
  464. // End Buy Ammo
  465.  
  466.  
  467. // Show Hud Ammo
  468. public show_hud_ammo(id,ammo)
  469. {
  470. new CURENT_WEAPON = HAS_WEAPON[id]
  471.  
  472. new clip_max = get_pcvar_num(cvar_clip[CURENT_WEAPON])
  473. if (ammo<=clip_max) fun_show_ammo(id, ammo)
  474. else
  475. {
  476. new ammo_a = ammo % clip_max
  477. new num_for = (ammo-ammo_a)/clip_max
  478. for (new i = 1; i <= num_for; i++)
  479. {
  480. fun_show_ammo(id, clip_max)
  481. }
  482. if (ammo_a>0) fun_show_ammo(id, ammo_a)
  483. }
  484.  
  485. return PLUGIN_HANDLED
  486. }
  487. fun_show_ammo(id, ammo)
  488. {
  489. new CURENT_WEAPON = HAS_WEAPON[id]
  490. new CHANGE_WEAPON = g_wpn_change[CURENT_WEAPON]
  491.  
  492. message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("AmmoPickup"), _, id)
  493. write_byte(AMMOID[CHANGE_WEAPON]) // ammo id
  494. write_byte(ammo) // ammo amount
  495. message_end()
  496. }
  497. // End Show Hud Ammo
  498.  
  499.  
  500. // Check Weapon
  501. public checkModel(id)
  502. {
  503. if (zp_get_user_zombie(id)) return PLUGIN_HANDLED
  504.  
  505.  
  506. new CURENT_WEAPON = HAS_WEAPON[id]
  507. new CHANGE_WEAPON = g_wpn_change[CURENT_WEAPON]
  508.  
  509. new szWeapID = read_data(2)
  510. if ( szWeapID == CHANGE_WEAPON && HAS_WEAPON[id])
  511. {
  512. set_pev(id, pev_viewmodel2, V_MODEL[CURENT_WEAPON])
  513. set_pev(id, pev_weaponmodel2, P_MODEL[CURENT_WEAPON])
  514. }
  515. return PLUGIN_HANDLED
  516. }
  517.  
  518. public checkWeapon(id)
  519. {
  520. new CURENT_WEAPON = HAS_WEAPON[id]
  521. new CHANGE_WEAPON = g_wpn_change[CURENT_WEAPON]
  522.  
  523. new plrClip, plrAmmo, plrWeapId
  524. plrWeapId = get_user_weapon(id, plrClip , plrAmmo)
  525.  
  526. if (plrWeapId == CHANGE_WEAPON && HAS_WEAPON[id])
  527. {
  528. checkModel(id)
  529.  
  530. // Speed
  531. new Ent = get_weapon_ent(id,plrWeapId)
  532. new Float:N_Speed
  533. if(Ent)
  534. {
  535. N_Speed = get_pcvar_float(cvar_speed[CURENT_WEAPON])
  536. new Float:Delay = get_pdata_float( Ent, 46, 4) * N_Speed
  537. if (Delay > 0.0) {
  538. set_pdata_float( Ent, 46, Delay, 4)
  539. }
  540. }
  541.  
  542. // Update Clip Ammo
  543. user_clip[id][CURENT_WEAPON] = plrClip
  544. user_ammo[id][CURENT_WEAPON] = plrAmmo
  545. }
  546. //client_print(id, print_chat, "[%i]", HAS_WEAPON[id])
  547.  
  548. return PLUGIN_HANDLED
  549. }
  550. // End Check Weapon
  551.  
  552.  
  553. // Zoom Wepaon
  554. public fw_CmdStart( id, uc_handle, seed )
  555. {
  556. if( !is_user_alive( id ) )
  557. {
  558. g_hasZoom[id] = false
  559. cs_set_user_zoom( id, CS_RESET_ZOOM, 0 )
  560. return PLUGIN_HANDLED
  561. }
  562.  
  563.  
  564. new CURENT_WEAPON = HAS_WEAPON[id]
  565. new CHANGE_WEAPON = g_wpn_change[CURENT_WEAPON]
  566.  
  567. new szClip, szAmmo
  568. new szWeapID = get_user_weapon( id, szClip, szAmmo )
  569.  
  570. if(szWeapID == CHANGE_WEAPON && HAS_WEAPON[id])
  571. {
  572. // Zoom Weapon
  573. if (get_pcvar_num(cvar_zoom[CURENT_WEAPON]))
  574. {
  575. if( ( get_uc( uc_handle, UC_Buttons ) & IN_ATTACK2 ) && !( pev( id, pev_oldbuttons ) & IN_ATTACK2 ) )
  576. {
  577. if(!g_hasZoom[id] == true)
  578. {
  579. g_hasZoom[id] = true
  580. cs_set_user_zoom( id, CS_SET_AUGSG552_ZOOM, 0 )
  581. client_cmd(id,"spk weapons/zoom")
  582. }
  583. else if (g_hasZoom[id])
  584. {
  585. g_hasZoom[ id ] = false
  586. cs_set_user_zoom( id, CS_RESET_ZOOM, 0 )
  587. }
  588. }
  589. }
  590. // UClip
  591. if (get_pcvar_num(cvar_uclip[CURENT_WEAPON]) == 1)
  592. {
  593. new ent = get_weapon_ent(id,CHANGE_WEAPON)
  594. cs_set_weapon_ammo(ent, get_pcvar_num(cvar_clip[CURENT_WEAPON]))
  595. }
  596. // Update Ammo
  597. cs_set_user_bpammo(id, CHANGE_WEAPON, user_ammo[id][CURENT_WEAPON])
  598.  
  599. //client_print(id, print_chat, "[%i] [%i]", get_pcvar_num(cvar_uclip[CURENT_WEAPON]), get_pcvar_num(cvar_zoom[CURENT_WEAPON]))
  600.  
  601. }
  602.  
  603.  
  604. if ( (g_hasZoom[ id ] && (pev(id, pev_button) & IN_RELOAD)) || (g_hasZoom[id] && szWeapID != CHANGE_WEAPON) )
  605. {
  606. g_hasZoom[id] = false
  607. cs_set_user_zoom( id, CS_RESET_ZOOM, 0 )
  608. }
  609.  
  610.  
  611. return PLUGIN_HANDLED
  612. }
  613. // End Zoom Wepaon
  614.  
  615.  
  616. //Give wpn
  617. public give_weapon(id, clip, ammo)
  618. {
  619. if (zp_get_user_zombie(id)) return PLUGIN_HANDLED
  620.  
  621. new CURENT_WEAPON = HAS_WEAPON[id]
  622. new CHANGE_WEAPON = g_wpn_change[CURENT_WEAPON]
  623.  
  624. give_item(id,Name_WpnChange[CURENT_WEAPON])
  625. cs_set_user_bpammo(id, CHANGE_WEAPON, ammo)
  626. new ent = get_weapon_ent(id,CHANGE_WEAPON)
  627. cs_set_weapon_ammo(ent, clip)
  628.  
  629. return PLUGIN_HANDLED
  630. }
  631.  
  632.  
  633.  
  634. // Other Public
  635. public client_connect(id)
  636. {
  637. HAS_WEAPON[id] = 0
  638. }
  639. public client_disconnect(id)
  640. {
  641. HAS_WEAPON[id] = 0
  642. }
  643. public event_start_freezetime()
  644. {
  645. remove_class_wpn()
  646. }
  647. // End Other Public
  648.  
  649.  
  650.  
  651. // Drop Weapon
  652. public cmd_drop(id)
  653. {
  654. new CURENT_WEAPON = HAS_WEAPON[id]
  655. new CHANGE_WEAPON = g_wpn_change[CURENT_WEAPON]
  656.  
  657. new plrClip, plrAmmo
  658. new plrWeapId
  659. plrWeapId = get_user_weapon(id, plrClip , plrAmmo)
  660.  
  661. if(plrWeapId == CHANGE_WEAPON && HAS_WEAPON[id] && is_user_alive(id)) {
  662. create_w_class(id, plrClip, plrAmmo, 1)
  663. HAS_WEAPON[id] = 0
  664. return PLUGIN_HANDLED
  665. }
  666. return PLUGIN_CONTINUE
  667. }
  668.  
  669. public create_w_class(id, clip, ammo, type)
  670. {
  671. new CURENT_WEAPON = HAS_WEAPON[id]
  672. //new CHANGE_WEAPON = g_wpn_change[CURENT_WEAPON]
  673.  
  674. new Float:Aim[3],Float:origin[3]
  675. VelocityByAim(id, 64, Aim)
  676. entity_get_vector(id,EV_VEC_origin,origin)
  677.  
  678. if (type == 1) {
  679. origin[0] += 2*Aim[0]
  680. origin[1] += 2*Aim[1]
  681. }
  682.  
  683. new nst_cre_class = create_entity("info_target")
  684. entity_set_string(nst_cre_class,EV_SZ_classname,name_class_weapon[CURENT_WEAPON])
  685. entity_set_model(nst_cre_class,W_MODEL[CURENT_WEAPON])
  686.  
  687. entity_set_size(nst_cre_class,Float:{-2.0,-2.0,-2.0},Float:{5.0,5.0,5.0})
  688. entity_set_int(nst_cre_class,EV_INT_solid,1)
  689.  
  690. entity_set_int(nst_cre_class,EV_INT_movetype,6)
  691. entity_set_int(nst_cre_class, EV_INT_iuser1, clip)
  692. entity_set_int(nst_cre_class, EV_INT_iuser2, ammo)
  693. entity_set_vector(nst_cre_class,EV_VEC_origin,origin)
  694. remowegun(id)
  695. }
  696. public remowegun(id)
  697. {
  698. new CURENT_WEAPON = HAS_WEAPON[id]
  699. new CHANGE_WEAPON = g_wpn_change[CURENT_WEAPON]
  700. new wpnList[32]
  701. new number
  702. get_user_weapons(id,wpnList,number)
  703. for (new i = 0;i < number ;i++) {
  704. if (wpnList[i] == CHANGE_WEAPON) {
  705. fm_strip_user_gun(id, wpnList[i])
  706. }
  707. }
  708. }
  709. // End Drop Weapon
  710.  
  711.  
  712. // Remove Class Wepaons in new round
  713. public remove_class_wpn()
  714. {
  715. new i = 1, check_value = 1
  716. while(check_value && i<MAX_WPN)
  717. {
  718. if (g_wpn_change[i] <= 0) check_value = 0
  719. new nextitem = find_ent_by_class(-1,name_class_weapon[i])
  720. while(nextitem)
  721. {
  722. remove_entity(nextitem)
  723. nextitem = find_ent_by_class(-1,name_class_weapon[i])
  724. }
  725. i++
  726. }
  727. return PLUGIN_CONTINUE
  728. }
  729. // End Remove Class Wepaons in new round
  730.  
  731.  
  732. // Weapon Pickup
  733. public pfn_touch(ptr, ptd) {
  734.  
  735. new i = 1, check_value = 1
  736. while(check_value && i<MAX_WPN)
  737. {
  738. if (g_wpn_change[i] <= 0) check_value = 0
  739. if(is_valid_ent(ptr)) {
  740. new classname[32]
  741. entity_get_string(ptr,EV_SZ_classname,classname,31)
  742. if(equal(classname, name_class_weapon[i])) {
  743. if(is_valid_ent(ptd)) {
  744. new id = ptd
  745. if(id > 0 && id < 34) {
  746. if (!check_has_wpn(id) && is_user_alive(id) && !(zp_get_user_zombie(id))) {
  747. HAS_WEAPON[id] = i
  748. give_weapon(id,entity_get_int(ptr, EV_INT_iuser1), entity_get_int(ptr, EV_INT_iuser2))
  749. remove_entity(ptr)
  750. }
  751. }
  752. }
  753. }
  754. }
  755. i++
  756. }
  757. }
  758.  
  759. check_has_wpn(id)
  760. {
  761. new weapons[32], num, has_wpn = 0
  762. get_user_weapons(id, weapons, num)
  763. new type_wpn_cr = TYPE_WPN
  764.  
  765. for (new i = 0; i < num; i++)
  766. {
  767. new type_wpn = nst_get_weapon_type(weapons[i])
  768. if (type_wpn == type_wpn_cr) has_wpn = 1
  769.  
  770. }
  771.  
  772. return has_wpn
  773. }
  774. // End Weapon Pickup
  775.  
  776.  
  777.  
  778. // Recoil of Weapon
  779. public fw_primary_attack(ent)
  780. {
  781. new id = pev(ent,pev_owner)
  782. pev(id,pev_punchangle,cl_pushangle[id])
  783.  
  784. return HAM_IGNORED
  785. }
  786. public fw_primary_attack_post(ent)
  787. {
  788. new id = pev(ent,pev_owner)
  789. new CURENT_WEAPON = HAS_WEAPON[id]
  790. new CHANGE_WEAPON = g_wpn_change[CURENT_WEAPON]
  791. new szClip, szAmmo
  792. new szWeapID = get_user_weapon( id, szClip, szAmmo )
  793.  
  794. if( szWeapID == CHANGE_WEAPON && HAS_WEAPON[id])
  795. {
  796. new Float:push[3]
  797. pev(id,pev_punchangle,push)
  798. xs_vec_sub(push,cl_pushangle[id],push)
  799.  
  800. xs_vec_mul_scalar(push,get_pcvar_float(cvar_recoil[CURENT_WEAPON]),push)
  801. xs_vec_add(push,cl_pushangle[id],push)
  802. set_pev(id,pev_punchangle,push)
  803. }
  804.  
  805. return HAM_IGNORED
  806. }
  807. // End Recoil of Weapon
  808.  
  809.  
  810.  
  811. // Give Ammo Clip
  812. public Item_PostFrame(iEnt)
  813. {
  814. static id ; id = get_pdata_cbase(iEnt, m_pPlayer, 4)
  815. new CURENT_WEAPON = HAS_WEAPON[id]
  816. new CHANGE_WEAPON = g_wpn_change[CURENT_WEAPON]
  817. new plrClip, plrAmmo, plrWeapId
  818. plrWeapId = get_user_weapon(id, plrClip , plrAmmo)
  819.  
  820. if (plrWeapId == CHANGE_WEAPON && HAS_WEAPON[id])
  821. {
  822.  
  823. static iId ; iId = get_pdata_int(iEnt, m_iId, 4)
  824. static iMaxClip ; iMaxClip = get_pcvar_num(cvar_clip[CURENT_WEAPON])
  825. static fInReload ; fInReload = get_pdata_int(iEnt, m_fInReload, 4)
  826. static Float:flNextAttack ; flNextAttack = get_pdata_float(id, m_flNextAttack, 5)
  827.  
  828. static iAmmoType ; iAmmoType = m_rgAmmo_player_Slot0 + get_pdata_int(iEnt, m_iPrimaryAmmoType, 4)
  829. static iBpAmmo ; iBpAmmo = get_pdata_int(id, iAmmoType, 5)
  830. static iClip ; iClip = get_pdata_int(iEnt, m_iClip, 4)
  831.  
  832.  
  833. if( fInReload && flNextAttack <= 0.0 )
  834. {
  835. new j = min(iMaxClip - iClip, iBpAmmo)
  836. set_pdata_int(iEnt, m_iClip, iClip + j, 4)
  837. set_pdata_int(id, iAmmoType, iBpAmmo-j, 5)
  838. set_pdata_int(iEnt, m_fInReload, 0, 4)
  839. user_ammo[id][CURENT_WEAPON] = iBpAmmo-j
  840. fInReload = 0
  841. }
  842.  
  843. static iButton ; iButton = pev(id, pev_button)
  844. if( (iButton & IN_ATTACK2 && get_pdata_float(iEnt, m_flNextSecondaryAttack, 4) <= 0.0)
  845. || (iButton & IN_ATTACK && get_pdata_float(iEnt, m_flNextPrimaryAttack, 4) <= 0.0) )
  846. {
  847. return
  848. }
  849.  
  850. if( iButton & IN_RELOAD && !fInReload )
  851. {
  852. if( iClip >= iMaxClip )
  853. {
  854. set_pev(id, pev_button, iButton & ~IN_RELOAD)
  855. if( SILENT_BS & (1<<iId) && !get_pdata_int(iEnt, m_fSilent, 4) )
  856. {
  857. SendWeaponAnim( id, iId == CSW_USP ? 8 : 7 )
  858. }
  859. else
  860. {
  861. SendWeaponAnim(id, 0)
  862. }
  863. }
  864. else if( iClip == g_iDftMaxClip[iId] )
  865. {
  866. if( iBpAmmo )
  867. {
  868. set_pdata_float(id, m_flNextAttack, g_fDelay[iId], 5)
  869.  
  870. if( SILENT_BS & (1<<iId) && get_pdata_int(iEnt, m_fSilent, 4) )
  871. {
  872. SendWeaponAnim( id, iId == CSW_USP ? 5 : 4 )
  873. }
  874. else
  875. {
  876. SendWeaponAnim(id, g_iReloadAnims[iId])
  877. }
  878. set_pdata_int(iEnt, m_fInReload, 1, 4)
  879.  
  880. set_pdata_float(iEnt, m_flTimeWeaponIdle, g_fDelay[iId] + 0.5, 4)
  881. }
  882. }
  883. }
  884. }
  885. }
  886. SendWeaponAnim(id, iAnim)
  887. {
  888. set_pev(id, pev_weaponanim, iAnim)
  889.  
  890. message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, _, id)
  891. write_byte(iAnim)
  892. write_byte(pev(id,pev_body))
  893. message_end()
  894. }
  895. // End Give Ammo Clip
  896.  
  897. // Stock
  898. stock drop_prim(id)
  899. {
  900. //new CURENT_WEAPON = HAS_WEAPON[id]
  901. ///new CHANGE_WEAPON = g_wpn_change[CURENT_WEAPON]
  902.  
  903. new weapons[32], num
  904. get_user_weapons(id, weapons, num)
  905. for (new i = 0; i < num; i++)
  906. {
  907. new type_wpn = nst_get_weapon_type(weapons[i])
  908. new type_wpn_cr = TYPE_WPN
  909. if (type_wpn == type_wpn_cr)
  910. {
  911. if (!HAS_WEAPON[id])
  912. {
  913. static wname[32]
  914. get_weaponname(weapons[i], wname, sizeof wname - 1)
  915. engclient_cmd(id, "drop", wname)
  916. }
  917. else
  918. {
  919. new CURENT_WEAPON = HAS_WEAPON[id]
  920. remowegun(id)
  921. create_w_class(id, user_clip[id][CURENT_WEAPON], user_ammo[id][CURENT_WEAPON], 1)
  922. HAS_WEAPON[id] = 0
  923. }
  924. }
  925. }
  926. }
  927. //get weapon id
  928. stock get_weapon_ent(id,wpnid=0,wpnName[]="")
  929. {
  930. // who knows what wpnName will be
  931. static newName[24];
  932.  
  933. // need to find the name
  934. if(wpnid) get_weaponname(wpnid,newName,23);
  935.  
  936. // go with what we were told
  937. else formatex(newName,23,"%s",wpnName);
  938.  
  939. // prefix it if we need to
  940. if(!equal(newName,"weapon_",7))
  941. format(newName,23,"weapon_%s",newName);
  942.  
  943. return fm_find_ent_by_owner(get_maxplayers(),newName,id);
  944. }
  945. /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
  946. *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1034\\ f0\\ fs16 \n\\ par }
  947. */
Add Comment
Please, Sign In to add comment