Advertisement
Guest User

zp_extra_plasmagun (InsaNe)

a guest
Aug 12th, 2020
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.65 KB | None | 0 0
  1. /*================================================================================
  2.  
  3. ---------------------------
  4. [ZP] Extra Item: Plasma Gun
  5. ---------------------------
  6.  
  7. Plasma Gun
  8. Copyright (C) 2017 by Crazy
  9.  
  10. -------------------
  11. -*- Description -*-
  12. -------------------
  13.  
  14. This plugin add a new weapon into your zombie plague mod with
  15. the name of Plasma Gun. That weapon launch powerfull green lasers!
  16. When the bullet of this weapon hit any object, a nice effect appers!
  17.  
  18. ----------------
  19. -*- Commands -*-
  20. ----------------
  21.  
  22. * zp_give_plasma_gun <target> - Give the item to target.
  23.  
  24. -------------
  25. -*- Cvars -*-
  26. -------------
  27.  
  28. * zp_plasma_gun_ammo <number> - Ammo amout.
  29. * zp_plasma_gun_clip <number> - Clip amout. (Max: 100)
  30. * zp_plasma_gun_one_round <0/1> - Only one round.
  31. * zp_plasma_gun_damage <number> - Damage multiplier.
  32. * zp_plasma_gun_unlimited <0/1> - Unlimited ammunition.
  33.  
  34. ------------------
  35. -*- Change Log -*-
  36. ------------------
  37.  
  38. * v0.1: (Mar 2017)
  39. - First release;
  40.  
  41. ---------------
  42. -*- Credits -*-
  43. ---------------
  44.  
  45. * MeRcyLeZZ: for the nice zombie plague mod.
  46. * Crazy: created the extra item code.
  47. * deanamx: for the nice weapon model.
  48. * And all zombie-mod players that use this weapon.
  49.  
  50.  
  51. =================================================================================*/
  52.  
  53. #include <amxmodx>
  54. #include <amxmisc>
  55. #include <engine>
  56. #include <cstrike>
  57. #include <fakemeta>
  58. #include <hamsandwich>
  59. #include <zombieplague>
  60. #include <cs_ham_bots_api>
  61.  
  62. /*================================================================================
  63. [Plugin Customization]
  64. =================================================================================*/
  65.  
  66. // Item Name
  67. #define ITEM_NAME "Plasma Gun"
  68.  
  69. // Item Cost
  70. #define ITEM_COST 70
  71.  
  72. /*================================================================================
  73. Customization ends here! Yes, that's it. Editing anything beyond
  74. here is not officially supported. Proceed at your own risk...
  75. =================================================================================*/
  76.  
  77. new const PLUGIN_VERSION[] = "v0.1";
  78.  
  79. new const V_PLASMAGUN_MDL[64] = "models/zombie_plague/v_plasma_gun.mdl";
  80. new const P_PLASMAGUN_MDL[64] = "models/zombie_plague/p_plasma_gun.mdl";
  81. new const W_PLASMAGUN_MDL[64] = "models/zombie_plague/w_plasma_gun.mdl";
  82.  
  83. new const PLASMAGUN_SOUNDS[][] = { "weapons/plasmagun_aug-1.wav", "weapons/plasmagun_aug-2.wav", "weapons/plasmagun_clipin1.wav", "weapons/plasmagun_clipin2.wav", "weapons/plasmagun_clipout.wav", "weapons/plasmagun_draw.wav", "weapons/plasmagun_exp.wav", "weapons/plasmagun_idle.wav" };
  84.  
  85. new g_has_plasmagun[33], g_plasmagun, g_msgWeaponList, g_plasmabomb, g_xenobeam, g_event_plasmagun, g_playername[33][32], g_maxplayers, g_primary_attack, g_plasmagun_reload_clip[33], cvar_plasmagun_clip, cvar_plasmagun_ammo, cvar_plasmagun_damage, cvar_plasmagun_oneround, cvar_plasgun_infinit;
  86.  
  87. new const GUNSHOT_DECALS[] = { 41, 42, 43, 44, 45 };
  88.  
  89. const m_iClip = 51;
  90. const m_flNextAttack = 83;
  91. const m_fInReload = 54;
  92.  
  93. const OFFSET_WEAPON_OWNER = 41;
  94. const OFFSET_LINUX_WEAPONS = 4;
  95. const OFFSET_LINUX = 5;
  96. const OFFSET_ACTIVE_ITEM = 373;
  97.  
  98. const PLASMAGUN_KEY = 054687;
  99.  
  100. const WEAPON_BITSUM = ((1<<CSW_SCOUT) | (1<<CSW_XM1014) | (1<<CSW_MAC10) | (1<<CSW_AUG) | (1<<CSW_UMP45) | (1<<CSW_SG550) | (1<<CSW_P90) | (1<<CSW_FAMAS) | (1<<CSW_AWP) | (1<<CSW_MP5NAVY) | (1<<CSW_M249) | (1<<CSW_M3) | (1<<CSW_M4A1) | (1<<CSW_TMP) | (1<<CSW_G3SG1) | (1<<CSW_SG552) | (1<<CSW_AK47) | (1<<CSW_GALIL));
  101.  
  102. enum
  103. {
  104. idle = 0,
  105. reload,
  106. draw,
  107. shoot1,
  108. shoot2,
  109. shoot3
  110. }
  111.  
  112. public plugin_init()
  113. {
  114. /* Plugin register */
  115. register_plugin("[ZP] Extra Item: Plasma Gun", PLUGIN_VERSION, "Crazy");
  116.  
  117. /* Item register */
  118. g_plasmagun = zp_register_extra_item(ITEM_NAME, ITEM_COST, ZP_TEAM_HUMAN);
  119.  
  120. /* Events */
  121. register_event("HLTV", "event_round_start", "a", "1=0", "2=0");
  122.  
  123. /* Messages */
  124. register_message(get_user_msgid("CurWeapon"), "message_cur_weapon");
  125.  
  126. /* Admin command */
  127. register_concmd("zp_give_plasmagun", "cmd_give_plasmagun", 0);
  128. register_clcmd("say /plasmagun", "buy_plasmagun", ADMIN_LEVEL_H)
  129. register_clcmd("say_team /plasmagun", "buy_plasmagun", ADMIN_LEVEL_H)
  130.  
  131. /* Forwards */
  132. register_forward(FM_UpdateClientData, "fw_UpdateData_Post", 1);
  133. register_forward(FM_SetModel, "fw_SetModel");
  134. register_forward(FM_PlaybackEvent, "fw_PlaybackEvent");
  135.  
  136. /* Ham Forwards */
  137. RegisterHam(Ham_TraceAttack, "worldspawn", "fw_TraceAttack_Post", 1);
  138. RegisterHam(Ham_TraceAttack, "func_breakable", "fw_TraceAttack_Post", 1);
  139. RegisterHam(Ham_TraceAttack, "func_wall", "fw_TraceAttack_Post", 1);
  140. RegisterHam(Ham_TraceAttack, "func_door", "fw_TraceAttack_Post", 1);
  141. RegisterHam(Ham_TraceAttack, "func_door_rotating", "fw_TraceAttack_Post", 1);
  142. RegisterHam(Ham_TraceAttack, "func_plat", "fw_TraceAttack_Post", 1);
  143. RegisterHam(Ham_TraceAttack, "func_rotating", "fw_TraceAttack_Post", 1);
  144. RegisterHam(Ham_Item_Deploy, "weapon_aug", "fw_Item_Deploy_Post", 1);
  145. RegisterHam(Ham_Item_AddToPlayer, "weapon_aug", "fw_Item_AddToPlayer_Post", 1);
  146. RegisterHam(Ham_Item_PostFrame, "weapon_aug", "fw_Item_PostFrame");
  147. RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_aug", "fw_PrimaryAttack");
  148. RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_aug", "fw_PrimaryAttack_Post", 1);
  149. RegisterHam(Ham_Weapon_Reload, "weapon_aug", "fw_Reload");
  150. RegisterHam(Ham_Weapon_Reload, "weapon_aug", "fw_Reload_Post", 1);
  151. RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage");
  152. RegisterHamBots(Ham_TakeDamage, "fw_TakeDamage");
  153.  
  154. /* Cvars */
  155. cvar_plasmagun_clip = register_cvar("zp_plasma_gun_clip", "30");
  156. cvar_plasmagun_ammo = register_cvar("zp_plasma_gun_ammo", "200");
  157. cvar_plasmagun_damage = register_cvar("zp_plasma_gun_damage", "2.5");
  158. cvar_plasmagun_oneround = register_cvar("zp_plasma_gun_one_round", "0");
  159. cvar_plasgun_infinit = register_cvar("zp_plasma_gun_unlimited", "0");
  160.  
  161. /* Max Players */
  162. g_maxplayers = get_maxplayers()
  163.  
  164. /* Message hook */
  165. g_msgWeaponList = get_user_msgid("WeaponList");
  166. }
  167.  
  168. public plugin_precache()
  169. {
  170. engfunc(EngFunc_PrecacheModel, V_PLASMAGUN_MDL);
  171. engfunc(EngFunc_PrecacheModel, P_PLASMAGUN_MDL);
  172. engfunc(EngFunc_PrecacheModel, W_PLASMAGUN_MDL);
  173.  
  174. engfunc(EngFunc_PrecacheGeneric, "sprites/weapon_plasmagun.txt");
  175. engfunc(EngFunc_PrecacheGeneric, "sprites/640hud3_plasma.spr");
  176. engfunc(EngFunc_PrecacheGeneric, "sprites/640hud91_plasma.spr");
  177.  
  178. g_plasmabomb = engfunc(EngFunc_PrecacheModel, "sprites/plasmabomb.spr");
  179. g_xenobeam = engfunc(EngFunc_PrecacheModel, "sprites/xenobeam.spr");
  180.  
  181. for (new i = 0; i < sizeof PLASMAGUN_SOUNDS; i++)
  182. engfunc(EngFunc_PrecacheSound, PLASMAGUN_SOUNDS[i]);
  183.  
  184. register_forward(FM_PrecacheEvent, "fw_PrecacheEvent_Post", 1);
  185. register_clcmd("weapon_plasmagun", "cmd_plasma_selected");
  186. }
  187.  
  188. public zp_user_infected_post(id)
  189. {
  190. g_has_plasmagun[id] = false;
  191. }
  192.  
  193. public zp_user_humanized_post(id)
  194. {
  195. g_has_plasmagun[id] = false;
  196. }
  197.  
  198. public client_putinserver(id)
  199. {
  200. g_has_plasmagun[id] = false;
  201.  
  202. get_user_name(id, g_playername[id], charsmax(g_playername[]));
  203. }
  204.  
  205. public event_round_start()
  206. {
  207. for (new id = 0; id <= g_maxplayers; id++)
  208. {
  209. if (get_pcvar_num(cvar_plasmagun_oneround))
  210. g_has_plasmagun[id] = false;
  211. }
  212. }
  213.  
  214. public cmd_give_plasmagun(id, level, cid)
  215. {
  216. if ((get_user_flags(id) & level) != level)
  217. return PLUGIN_HANDLED;
  218.  
  219. static arg[32], player;
  220. read_argv(1, arg, charsmax(arg));
  221. player = cmd_target(id, arg, (CMDTARGET_ONLY_ALIVE | CMDTARGET_ALLOW_SELF));
  222.  
  223. if (!player)
  224. return PLUGIN_HANDLED;
  225.  
  226. if (g_has_plasmagun[player])
  227. {
  228. client_print(id, print_chat, "[ZP] The %s already have the %s.", g_playername[player], ITEM_NAME);
  229. return PLUGIN_HANDLED;
  230. }
  231.  
  232. give_plasmagun(player);
  233.  
  234. client_print(player, print_chat, "[ZP] You won a %s from %s!", ITEM_NAME, g_playername[id]);
  235.  
  236. return PLUGIN_HANDLED;
  237. }
  238.  
  239. public cmd_plasma_selected(client)
  240. {
  241. engclient_cmd(client, "weapon_aug");
  242. return PLUGIN_HANDLED;
  243. }
  244.  
  245. public message_cur_weapon(msg_id, msg_dest, msg_entity)
  246. {
  247. if (!is_user_alive(msg_entity))
  248. return;
  249.  
  250. if (!g_has_plasmagun[msg_entity])
  251. return;
  252.  
  253. if (get_user_weapon(msg_entity) != CSW_AUG)
  254. return;
  255.  
  256. if (get_msg_arg_int(1) != 1)
  257. return;
  258.  
  259. if (get_pcvar_num(cvar_plasgun_infinit))
  260. {
  261. static ent;
  262. ent = fm_cs_get_current_weapon_ent(msg_entity);
  263.  
  264. if (!pev_valid(ent))
  265. return;
  266.  
  267. cs_set_weapon_ammo(ent, get_pcvar_num(cvar_plasmagun_clip));
  268. set_msg_arg_int(3, get_msg_argtype(3), get_pcvar_num(cvar_plasmagun_clip));
  269. }
  270. }
  271.  
  272. public zp_extra_item_selected(id, itemid)
  273. {
  274. if (itemid != g_plasmagun)
  275. return;
  276.  
  277. if (g_has_plasmagun[id])
  278. {
  279. client_print(id, print_chat, "[ZP] You already have the %s.", ITEM_NAME);
  280. return;
  281. }
  282.  
  283. give_plasmagun(id);
  284.  
  285. client_print(id, print_chat, "[ZP] You bought the %s.", ITEM_NAME);
  286. }
  287.  
  288. public fw_UpdateData_Post(id, sendweapons, cd_handle)
  289. {
  290. if (!is_user_alive(id))
  291. return FMRES_IGNORED;
  292.  
  293. if (!g_has_plasmagun[id])
  294. return FMRES_IGNORED;
  295.  
  296. if (get_user_weapon(id) != CSW_AUG)
  297. return FMRES_IGNORED;
  298.  
  299. set_cd(cd_handle, CD_flNextAttack, halflife_time() + 0.001);
  300.  
  301. return FMRES_IGNORED;
  302. }
  303.  
  304. public fw_SetModel(ent, const model[])
  305. {
  306. if (!pev_valid(ent))
  307. return FMRES_IGNORED;
  308.  
  309. if (!equal(model, "models/w_aug.mdl"))
  310. return HAM_IGNORED;
  311.  
  312. static class_name[33];
  313. pev(ent, pev_classname, class_name, charsmax(class_name));
  314.  
  315. if (!equal(class_name, "weaponbox"))
  316. return FMRES_IGNORED;
  317.  
  318. static owner, weapon;
  319. owner = pev(ent, pev_owner);
  320. weapon = find_ent_by_owner(-1, "weapon_aug", ent);
  321.  
  322. if (!g_has_plasmagun[owner] || !pev_valid(weapon))
  323. return FMRES_IGNORED;
  324.  
  325. g_has_plasmagun[owner] = false;
  326.  
  327. set_pev(weapon, pev_impulse, PLASMAGUN_KEY);
  328.  
  329. engfunc(EngFunc_SetModel, ent, W_PLASMAGUN_MDL);
  330.  
  331. return FMRES_SUPERCEDE;
  332. }
  333.  
  334. public fw_PlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
  335. {
  336. if ((eventid != g_event_plasmagun) || !g_primary_attack)
  337. return FMRES_IGNORED;
  338.  
  339. if (!(1 <= invoker <= g_maxplayers))
  340. return FMRES_IGNORED;
  341.  
  342. playback_event(flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2);
  343.  
  344. return FMRES_SUPERCEDE;
  345. }
  346.  
  347. public fw_PrecacheEvent_Post(type, const name[])
  348. {
  349. if (!equal("events/aug.sc", name))
  350. return HAM_IGNORED;
  351.  
  352. g_event_plasmagun = get_orig_retval()
  353.  
  354. return FMRES_HANDLED;
  355. }
  356.  
  357. public fw_Item_Deploy_Post(ent)
  358. {
  359. if (!pev_valid(ent))
  360. return HAM_IGNORED;
  361.  
  362. new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
  363.  
  364. if (!is_user_alive(id))
  365. return HAM_IGNORED;
  366.  
  367. if (!g_has_plasmagun[id])
  368. return HAM_IGNORED;
  369.  
  370. set_pev(id, pev_viewmodel2, V_PLASMAGUN_MDL);
  371. set_pev(id, pev_weaponmodel2, P_PLASMAGUN_MDL);
  372.  
  373. play_weapon_anim(id, draw);
  374.  
  375. return HAM_IGNORED;
  376. }
  377.  
  378. public fw_Item_AddToPlayer_Post(ent, id)
  379. {
  380. if (!pev_valid(ent))
  381. return HAM_IGNORED;
  382.  
  383. if (!is_user_connected(id))
  384. return HAM_IGNORED;
  385.  
  386. if (pev(ent, pev_impulse) == PLASMAGUN_KEY)
  387. {
  388. g_has_plasmagun[id] = true;
  389. set_pev(ent, pev_impulse, 0);
  390. }
  391.  
  392. message_begin(MSG_ONE, g_msgWeaponList, _, id)
  393. write_string((g_has_plasmagun[id] ? "weapon_plasmagun" : "weapon_aug"))
  394. write_byte(4)
  395. write_byte(90)
  396. write_byte(-1)
  397. write_byte(-1)
  398. write_byte(0)
  399. write_byte(14)
  400. write_byte(CSW_AUG)
  401. write_byte(0)
  402. message_end()
  403.  
  404. return HAM_IGNORED;
  405. }
  406.  
  407. public fw_Item_PostFrame(ent)
  408. {
  409. if (!pev_valid(ent))
  410. return HAM_IGNORED;
  411.  
  412. new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
  413.  
  414. if (!is_user_alive(id))
  415. return HAM_IGNORED;
  416.  
  417. if (!g_has_plasmagun[id])
  418. return HAM_IGNORED;
  419.  
  420. static cvar_clip; cvar_clip = get_pcvar_num(cvar_plasmagun_clip);
  421.  
  422. new clip = get_pdata_int(ent, m_iClip, OFFSET_LINUX_WEAPONS);
  423. new bpammo = cs_get_user_bpammo(id, CSW_AUG);
  424.  
  425. new Float:flNextAttack = get_pdata_float(id, m_flNextAttack, OFFSET_LINUX);
  426. new fInReload = get_pdata_int(ent, m_fInReload, OFFSET_LINUX_WEAPONS);
  427.  
  428. if (fInReload && flNextAttack <= 0.0)
  429. {
  430. new temp_clip = min(cvar_clip - clip, bpammo);
  431.  
  432. set_pdata_int(ent, m_iClip, clip + temp_clip, OFFSET_LINUX_WEAPONS);
  433.  
  434. cs_set_user_bpammo(id, CSW_AUG, bpammo-temp_clip);
  435.  
  436. set_pdata_int(ent, m_fInReload, 0, OFFSET_LINUX_WEAPONS);
  437.  
  438. fInReload = 0;
  439. }
  440.  
  441. return HAM_IGNORED;
  442. }
  443.  
  444. public fw_PrimaryAttack(ent)
  445. {
  446. if (!pev_valid(ent))
  447. return HAM_IGNORED;
  448.  
  449. new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
  450.  
  451. if (!is_user_alive(id))
  452. return HAM_IGNORED;
  453.  
  454. if (!g_has_plasmagun[id])
  455. return HAM_IGNORED;
  456.  
  457. if (!cs_get_weapon_ammo(ent))
  458. return HAM_IGNORED;
  459.  
  460. g_primary_attack = true;
  461.  
  462. return HAM_IGNORED;
  463. }
  464.  
  465. public fw_PrimaryAttack_Post(ent)
  466. {
  467. if (!pev_valid(ent))
  468. return HAM_IGNORED;
  469.  
  470. new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
  471.  
  472. if (!is_user_alive(id))
  473. return HAM_IGNORED;
  474.  
  475. if (!g_has_plasmagun[id])
  476. return HAM_IGNORED;
  477.  
  478. if (!cs_get_weapon_ammo(ent))
  479. return HAM_IGNORED;
  480.  
  481. g_primary_attack = false;
  482.  
  483. play_weapon_anim(id, random_num(shoot1, shoot2));
  484.  
  485. emit_sound(id, CHAN_WEAPON, PLASMAGUN_SOUNDS[random_num(0, 1)], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
  486.  
  487. make_xenobeam(id);
  488.  
  489. return HAM_IGNORED;
  490. }
  491.  
  492. public fw_Reload(ent)
  493. {
  494. if (!pev_valid(ent))
  495. return HAM_IGNORED;
  496.  
  497. new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
  498.  
  499. if (!is_user_alive(id))
  500. return HAM_IGNORED;
  501.  
  502. if (!g_has_plasmagun[id])
  503. return HAM_IGNORED;
  504.  
  505. g_plasmagun_reload_clip[id] = -1;
  506.  
  507. static cvar_clip; cvar_clip = get_pcvar_num(cvar_plasmagun_clip);
  508.  
  509. new clip = get_pdata_int(ent, m_iClip, OFFSET_LINUX_WEAPONS);
  510. new bpammo = cs_get_user_bpammo(id, CSW_AUG);
  511.  
  512. if (bpammo <= 0)
  513. return HAM_SUPERCEDE;
  514.  
  515. if (clip >= cvar_clip)
  516. return HAM_SUPERCEDE;
  517.  
  518. g_plasmagun_reload_clip[id] = clip;
  519.  
  520. return HAM_IGNORED;
  521. }
  522.  
  523. public fw_Reload_Post(ent)
  524. {
  525. if (!pev_valid(ent))
  526. return HAM_IGNORED;
  527.  
  528. new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
  529.  
  530. if (!is_user_alive(id))
  531. return HAM_IGNORED;
  532.  
  533. if (!g_has_plasmagun[id])
  534. return HAM_IGNORED;
  535.  
  536. if (g_plasmagun_reload_clip[id] == -1)
  537. return HAM_IGNORED;
  538.  
  539. set_pdata_int(ent, m_iClip, g_plasmagun_reload_clip[id], OFFSET_LINUX_WEAPONS);
  540. set_pdata_int(ent, m_fInReload, 1, OFFSET_LINUX_WEAPONS);
  541.  
  542. play_weapon_anim(id, reload);
  543.  
  544. return HAM_IGNORED;
  545. }
  546.  
  547. public fw_TakeDamage(victim, inflictor, attacker, Float:damage, dmg_bits)
  548. {
  549. if (!is_user_alive(attacker))
  550. return HAM_IGNORED;
  551.  
  552. if (!g_has_plasmagun[attacker])
  553. return HAM_IGNORED;
  554.  
  555. if (get_user_weapon(attacker) != CSW_AUG)
  556. return HAM_IGNORED;
  557.  
  558. SetHamParamFloat(OFFSET_LINUX_WEAPONS, damage * get_pcvar_float(cvar_plasmagun_damage));
  559.  
  560. return HAM_IGNORED;
  561. }
  562.  
  563. public fw_TraceAttack_Post(ent, attacker, Float:damage, Float:dir[3], ptr, dmg_bits)
  564. {
  565. if (!is_user_alive(attacker))
  566. return HAM_IGNORED;
  567.  
  568. if (get_user_weapon(attacker) != CSW_AUG)
  569. return HAM_IGNORED;
  570.  
  571. if (!g_has_plasmagun[attacker])
  572. return HAM_IGNORED;
  573.  
  574. static Float:end[3];
  575. get_tr2(ptr, TR_vecEndPos, end);
  576.  
  577. if(ent)
  578. {
  579. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  580. write_byte(TE_DECAL)
  581. engfunc(EngFunc_WriteCoord, end[0])
  582. engfunc(EngFunc_WriteCoord, end[1])
  583. engfunc(EngFunc_WriteCoord, end[2])
  584. write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
  585. write_short(ent)
  586. message_end()
  587. }
  588. else
  589. {
  590. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  591. write_byte(TE_SPRITE)
  592. engfunc(EngFunc_WriteCoord, end[0])
  593. engfunc(EngFunc_WriteCoord, end[1])
  594. engfunc(EngFunc_WriteCoord, end[2])
  595. write_short(g_plasmabomb)
  596. write_byte(10)
  597. write_byte(200)
  598. message_end()
  599. }
  600.  
  601. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  602. write_byte(TE_GUNSHOTDECAL)
  603. engfunc(EngFunc_WriteCoord, end[0])
  604. engfunc(EngFunc_WriteCoord, end[1])
  605. engfunc(EngFunc_WriteCoord, end[2])
  606. write_short(attacker)
  607. write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
  608. message_end()
  609.  
  610. return HAM_IGNORED;
  611. }
  612.  
  613. give_plasmagun(id)
  614. {
  615. drop_primary(id);
  616.  
  617. g_has_plasmagun[id] = true;
  618.  
  619. new weapon = fm_give_item(id, "weapon_aug");
  620.  
  621. cs_set_weapon_ammo(weapon, get_pcvar_num(cvar_plasmagun_clip));
  622. cs_set_user_bpammo(id, CSW_AUG, get_pcvar_num(cvar_plasmagun_ammo));
  623. }
  624.  
  625. public buy_plasmagun(id)
  626. {
  627. if (g_has_plasmagun[id])
  628. {
  629. client_print(id, print_chat, "[ZP] You already have the %s.", ITEM_NAME)
  630. return;
  631. }
  632.  
  633. if(cs_get_user_money(id) < 10000)
  634. {
  635. client_print(id, print_chat, "[ZP] You don't have enough money to buy the %s.", ITEM_NAME)
  636. }
  637.  
  638. drop_primary(id)
  639.  
  640. g_has_plasmagun[id] = true;
  641.  
  642. new weapon = fm_give_item(id, "weapon_aug")
  643.  
  644. cs_set_weapon_ammo(weapon, get_pcvar_num(cvar_plasmagun_clip))
  645. cs_set_user_bpammo(id, CSW_AUG, get_pcvar_num(cvar_plasmagun_ammo))
  646. cs_set_user_money(id, cs_get_user_money(id) - 10000)
  647. }
  648.  
  649. play_weapon_anim(id, frame)
  650. {
  651. set_pev(id, pev_weaponanim, frame);
  652.  
  653. message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = id)
  654. write_byte(frame)
  655. write_byte(pev(id, pev_body))
  656. message_end()
  657. }
  658.  
  659. drop_primary(id)
  660. {
  661. static weapons[32], num;
  662. get_user_weapons(id, weapons, num);
  663.  
  664. for (new i = 0; i < num; i++)
  665. {
  666. if (WEAPON_BITSUM & (1<<weapons[i]))
  667. {
  668. static wname[32];
  669. get_weaponname(weapons[i], wname, sizeof wname - 1);
  670.  
  671. engclient_cmd(id, "drop", wname);
  672. }
  673. }
  674. }
  675.  
  676. make_xenobeam(id)
  677. {
  678. static originF[3];
  679. get_user_origin(id, originF, 3);
  680.  
  681. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  682. write_byte(TE_BEAMENTPOINT)
  683. write_short(id | 0x1000)
  684. write_coord(originF[0])
  685. write_coord(originF[1])
  686. write_coord(originF[2])
  687. write_short(g_xenobeam)
  688. write_byte(0)
  689. write_byte(0)
  690. write_byte(1)
  691. write_byte(20)
  692. write_byte(0)
  693. write_byte(110)
  694. write_byte(251)
  695. write_byte(110)
  696. write_byte(200)
  697. write_byte(5)
  698. message_end()
  699. }
  700.  
  701. stock fm_give_item(index, const item[])
  702. {
  703. if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5) && !equal(item, "item_", 5) && !equal(item, "tf_weapon_", 10))
  704. return 0;
  705.  
  706. new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, item));
  707. if (!pev_valid(ent))
  708. return 0;
  709.  
  710. new Float:origin[3];
  711. pev(index, pev_origin, origin);
  712. set_pev(ent, pev_origin, origin);
  713. set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN);
  714. dllfunc(DLLFunc_Spawn, ent);
  715.  
  716. new save = pev(ent, pev_solid);
  717. dllfunc(DLLFunc_Touch, ent, index);
  718. if (pev(ent, pev_solid) != save)
  719. return ent;
  720.  
  721. engfunc(EngFunc_RemoveEntity, ent);
  722.  
  723. return -1;
  724. }
  725.  
  726. stock fm_cs_get_current_weapon_ent(id)
  727. {
  728. if (pev_valid(id) != 2)
  729. return -1;
  730.  
  731. return get_pdata_cbase(id, OFFSET_ACTIVE_ITEM, OFFSET_LINUX);
  732. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement