Guest User

Untitled

a guest
Aug 30th, 2020
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 35.66 KB | None | 0 0
  1. /*
  2. ================================================
  3. Counter-Strike Weapons System Mod v1.4.3 [CSWS1]
  4. ================================================
  5. 2017
  6.  
  7. This source code falls under the GNU General Public License.
  8. (https://www.gnu.org/licenses/gpl-3.0.en.html)
  9.  
  10. Additionally, you are allowed to modify, improve or build
  11. upon the code but under NO circumstances are you allowed to
  12. sell, trade, or receive any compensation for the source code
  13. whatsoever and should freely share said code to anyone,
  14. modified or otherwise.
  15.  
  16. Description:
  17. ============
  18. The CSWS script is built upon the endeavor
  19. of adding an extra weapon that behaves like
  20. a real CS 1.6 weapon in every way while
  21. providing optimum performance. If you want
  22. to improve the code feel free to do so and
  23. share it with everyone.
  24.  
  25. Credits:
  26. ========
  27. Sneaky.amxx - original weapons code
  28. dias - original weapons code
  29. MeRcyLeZZ - price mechanic
  30. Arkshine - HUD sprites replacement
  31. Numb - full-auto fire code
  32. HamletEagle - optimization
  33. edon1337 - optimization
  34. */
  35.  
  36. #include <amxmodx>
  37. #include <cstrike>
  38. #include <engine>
  39. #include <fakemeta>
  40. #include <fun>
  41. #include <hamsandwich>
  42. #include <xs>
  43.  
  44. #define DAMAGE 30
  45. #define CLIP 12
  46. #define BPAMMO 24
  47. #define RATEOFIRE 0.08
  48. #define RECOIL 1.5
  49. #define WALKSPEED 240.0 // Devre disi
  50. #define PRICE 500
  51. #define TEAM 0
  52. #define BASEWPN_PRICE 400
  53. #define BOT_BUY_CHANCE 1
  54.  
  55. #define BASEWPN_CLIP 20
  56. #define BASEWPN_AMMO 12
  57. #define AMMOID 10
  58. #define ACOST 20
  59. #define AUNITS 30
  60.  
  61. #define BODY_NUM 0
  62. #define WEAPON_SECRETCODE 326751
  63. #define WEAPONSTATE_BURST_MODE (1<<1)
  64.  
  65. // MACROS
  66. #define Get_BitVar(%1,%2) (%1 & (1 << (%2 & 31)))
  67. #define Set_BitVar(%1,%2) %1 |= (1 << (%2 & 31))
  68. #define UnSet_BitVar(%1,%2) %1 &= ~(1 << (%2 & 31))
  69.  
  70. new const PLUGIN[] = "CS:GO CZ75";
  71. new const VERSION[] = "2.4.4";
  72. new const CSWS_VER[] = "1.4.3";
  73. new const DATE[] = "1 December 2017";
  74.  
  75. new const P_MODEL[] = "models/csgo_ports/cz75/p_cz75.mdl";
  76. new const W_MODEL[] = "models/csgo_ports/cz75/w_cz75.mdl";
  77. new const V_MODEL[] = "models/csgo_ports/cz75/v_cz75.mdl";
  78. new const V_MODEL_ALT[] = "models/csgo_ports/cz75/v_cz75.mdl";
  79.  
  80. new const IDLE_ANIM[] = {0, 1};
  81. new const DRAW_ANIM[] = {2, 3};
  82. new const SHOOT_ANIM[] = {4, 5};
  83. new const RELOAD_ANIM[] = {8, 9};
  84. new const INSPECT_ANIM[] = {10, 11};
  85.  
  86. new Float:RELOAD_TIME[] = {2.2, 2.7};
  87. new Float:RELOAD_POINT[] = {1.23, 1.0};
  88.  
  89. new const CSW_NEWPN = CSW_GLOCK18;
  90. new const weapon_newpn[] = "weapon_glock18";
  91. new const WEAPON_EVENT[] = "events/glock18.sc";
  92. new const BASE_W_MODEL[] = "models/w_glock18.mdl";
  93. new const FIRE_SOUND[] = "weapons/csgo_ports/cz75/cz75-1.wav";
  94.  
  95. new const NEWPN_NAME[] = "weapon_cz75";
  96. new const PRI_AMMO_ID = 10;
  97. new const SLOT_ID = 1;
  98. new const NUM_IN_SLOT = 2;
  99. new const ITEM_FLAGS = 0;
  100.  
  101. new const newpn_shortname[] = "cz75";
  102. new const basewpn_shortname[] = "glock18";
  103. new const basewpn_buynames[][] = {"glock", "9x19mm"};
  104.  
  105. new const secondary_weapon_classnames[][] =
  106. {
  107. "weapon_usp",
  108. "weapon_glock18",
  109. "weapon_deagle",
  110. "weapon_p228",
  111. "weapon_fiveseven",
  112. "weapon_elite"
  113. }
  114.  
  115. new const weapon_sprites[][] =
  116. {
  117. "sprites/weapon_cz75.txt",
  118. "sprites/640csws03.spr",
  119. "sprites/640csws03_s.spr"
  120. }
  121.  
  122. new Float:g_idletime[] =
  123. {
  124. 1.18, // 0 draw0
  125. 1.1, // 1 draw1
  126. 2.2, // 2 reload0
  127. 2.7, // 3 reload1
  128. 0.33, // 4 shoot
  129. 5.16, // 5 inspect0
  130. }
  131.  
  132. const m_pPlayer = 41;
  133. const m_flNextPrimaryAttack = 46;
  134. const m_flNextSecondaryAttack = 47;
  135. const m_flTimeWeaponIdle = 48;
  136. const m_iClip = 51;
  137. const m_fInReload = 54;
  138. const m_flGlock18Shoot = 69;
  139. const m_iGlock18ShotsFired = 70;
  140. const m_fWeaponState = 74;
  141. const m_flNextAttack = 83;
  142. const m_pActiveItem = 373;
  143.  
  144. // Weapon bitsums
  145. const WEAPONS_BIT_SUM = (1<<CSW_P228)|(1<<CSW_ELITE)|(1<<CSW_FIVESEVEN)|(1<<CSW_USP)|(1<<CSW_GLOCK18)|(1<<CSW_DEAGLE);
  146.  
  147. new g_hambot, g_has_weapon, g_weapon_event, g_buytime_expire, g_rebuy[32], g_newrnd_bypass, g_wpn_mode[33];
  148. new Float:g_recoil[33][3], g_clip[33], g_prev_weapon[33], g_restart_round, shell_model, smoke_sprite;
  149. new cvar_bot_allow_wpns, cvar_freezetime, cvar_buytime, cvar_decals, cvar_alteam;
  150. new msg_Money, msg_BlinkAcct, msg_WeaponList;
  151. new g_on_idle[33];
  152.  
  153. new HamHook:HandleWeaponIdle,cz75Enabled;
  154. new TASKID_BUYTIME = 100000;
  155.  
  156. public plugin_init()
  157. {
  158. register_plugin(PLUGIN, VERSION, "Sneaky.amxx, dias, MeRcyLeZZ, Arkshine, hellmonja");
  159.  
  160. register_event("TextMsg", "Game_Commencing", "a", "2=#Game_Commencing", "2=#Game_will_restart_in");
  161. register_event("HLTV", "Event_New_Round", "a", "1=0", "2=0");
  162. register_event("CurWeapon", "Event_CurWeapon", "be", "1=1");
  163. register_message(get_user_msgid("DeathMsg"), "Message_DeathMsg");
  164.  
  165. register_forward(FM_UpdateClientData, "Fw_UpdateClientData_Post", 1);
  166. register_forward(FM_PlaybackEvent, "Fw_PlaybackEvent");
  167. register_forward(FM_SetModel, "Fw_SetModel");
  168. register_forward(FM_CmdStart, "Fw_CmdStart");
  169.  
  170. RegisterHam(Ham_AddPlayerItem, "player", "Fw_AddItem");
  171. RegisterHam(Ham_RemovePlayerItem, "player", "Fw_RemoveItem");
  172. RegisterHam(Ham_Killed, "player", "Fw_Player_Death");
  173. RegisterHam(Ham_TraceAttack, "player", "Fw_TraceAttack_Player");
  174. RegisterHam(Ham_TraceAttack, "worldspawn", "Fw_TraceAttack_World");
  175. RegisterHam(Ham_TraceAttack, "func_breakable", "Fw_TraceAttack_World");
  176. RegisterHam(Ham_TraceAttack, "func_wall", "Fw_TraceAttack_World");
  177. RegisterHam(Ham_TraceAttack, "func_door", "Fw_TraceAttack_World");
  178. RegisterHam(Ham_TraceAttack, "func_door_rotating", "Fw_TraceAttack_World");
  179. RegisterHam(Ham_TraceAttack, "func_plat", "Fw_TraceAttack_World");
  180. RegisterHam(Ham_TraceAttack, "func_rotating", "Fw_TraceAttack_World");
  181. RegisterHam(Ham_Item_Deploy, weapon_newpn, "Fw_ItemDeployPre");
  182. RegisterHam(Ham_Item_Deploy, weapon_newpn, "Fw_ItemDeployPost", 1);
  183. RegisterHam(Ham_Weapon_PrimaryAttack, weapon_newpn, "Ham_Attack_FullAuto_Post", 1);
  184. RegisterHam(Ham_Weapon_PrimaryAttack, weapon_newpn, "Fw_Weapon_PrimaryAttack");
  185. RegisterHam(Ham_Weapon_PrimaryAttack, weapon_newpn, "Fw_Weapon_PrimaryAttack_Post", 1);
  186. RegisterHam(Ham_Item_AddToPlayer, weapon_newpn, "Fw_Item_AddToPlayer_Post", 1);
  187. RegisterHam(Ham_Item_PostFrame, weapon_newpn, "Fw_Item_PostFrame");
  188. RegisterHam(Ham_Weapon_Reload, weapon_newpn, "Fw_Weapon_Reload");
  189. RegisterHam(Ham_Weapon_Reload, weapon_newpn, "Fw_Weapon_Reload_Post", 1);
  190. //RegisterHam(Ham_CS_Item_GetMaxSpeed, weapon_newpn, "Player_Weapon_Walkspeed");
  191. RegisterHam(Ham_Touch, "weapon_shield", "Fw_Block_Sheild_Pickup");
  192.  
  193. bind_pcvar_num(create_cvar("csgo_cz75_enabled", "1"), cz75Enabled);
  194.  
  195. HandleWeaponIdle = RegisterHam(Ham_Weapon_WeaponIdle, weapon_newpn,"Fw_Weapon_On_Idle");
  196. DisableHamForward(HandleWeaponIdle);
  197.  
  198. msg_WeaponList = get_user_msgid("WeaponList");
  199. msg_Money = get_user_msgid("Money");
  200. msg_BlinkAcct = get_user_msgid("BlinkAcct");
  201.  
  202. new clcmd[24]; formatex(clcmd, 25, "say %s", newpn_shortname);
  203. for(new i = 0; i < sizeof basewpn_buynames - 1; i++)
  204. register_clcmd(basewpn_buynames[i], "ClientCommand_BuyBaseWpn");
  205.  
  206. register_clcmd(clcmd, "Get_Weapon");
  207. register_clcmd(NEWPN_NAME, "ClientCommand_SelectWeapon");
  208. register_clcmd("buyammo2", "ClientCommand_BuyAmmo");
  209. register_clcmd("secammo", "ClientCommand_BuySecAmmo");
  210. register_clcmd("shield", "ClientCommand_BuyShield");
  211. register_clcmd("inspect", "Inspect_Weapon");
  212. register_concmd("inspect", "Inspect_Weapon");
  213. register_concmd("repurchase", "ClientCommand_RePurchase");
  214. register_concmd(newpn_shortname, "Get_Weapon");
  215. register_concmd("ver_cz75", "Code_Version");
  216.  
  217. //CVARS
  218. cvar_freezetime = get_cvar_pointer("mp_freezetime");
  219. cvar_buytime = get_cvar_pointer("mp_buytime");
  220. cvar_bot_allow_wpns = get_cvar_pointer("bot_allow_pistols");
  221. cvar_alteam = register_cvar("armsw_team", "1");
  222. cvar_decals = register_cvar("csws_decals", "0");
  223. }
  224.  
  225. public plugin_precache()
  226. {
  227. for(new i = 1; i < sizeof weapon_sprites; i++)
  228. precache_generic(weapon_sprites[i]);
  229.  
  230. precache_model(P_MODEL);
  231. precache_model(W_MODEL);
  232. precache_model(V_MODEL);
  233. precache_model(V_MODEL_ALT);
  234. precache_sound(FIRE_SOUND);
  235.  
  236. smoke_sprite = engfunc(EngFunc_PrecacheModel, "sprites/gunsmoke.spr");
  237. shell_model = engfunc(EngFunc_PrecacheModel, "models/pshell.mdl")
  238.  
  239. register_forward(FM_PrecacheEvent, "Fw_PrecacheEvent_Post", 1);
  240. }
  241.  
  242. public Code_Version(id)
  243. {
  244. console_print(id, "==============================");
  245. console_print(id, "%s v%s", PLUGIN, VERSION);
  246. console_print(id, "Counter-Strike Weapons System v%s", CSWS_VER);
  247. console_print(id, "%s", DATE);
  248. console_print(id, "==============================");
  249. }
  250.  
  251. public Fw_PrecacheEvent_Post(type, const name[])
  252. {
  253. if(equal(WEAPON_EVENT, name))
  254. g_weapon_event = get_orig_retval();
  255. }
  256.  
  257. public client_putinserver(id)
  258. {
  259. if(!g_hambot && is_user_bot(id))
  260. {
  261. g_hambot = 1
  262. set_task(0.1, "Do_RegisterHam", id)
  263. }
  264. }
  265.  
  266. public Do_RegisterHam(id)
  267. {
  268. RegisterHamFromEntity(Ham_TraceAttack, id, "Fw_TraceAttack_Player");
  269. RegisterHamFromEntity(Ham_AddPlayerItem, id, "Fw_AddItem", 1);
  270. RegisterHamFromEntity(Ham_RemovePlayerItem, id, "Fw_RemoveItem", 1);
  271. RegisterHamFromEntity(Ham_Killed, id, "Fw_Player_Death");
  272. }
  273.  
  274. public Game_Commencing()
  275. {
  276. g_restart_round = 1;
  277. }
  278.  
  279. public Event_New_Round()
  280. {
  281. new freezetime = get_pcvar_num(cvar_freezetime);
  282. new buytime = floatround((get_pcvar_float(cvar_buytime) * 60));
  283. new Float:t;
  284.  
  285. g_buytime_expire = 0;
  286. g_newrnd_bypass = 0;
  287.  
  288. if(g_restart_round)
  289. {
  290. Remove_Weapon(0, 1);
  291. g_restart_round = 0;
  292. }
  293.  
  294. check_weapon_usage()
  295.  
  296. set_task(0.1, "Bypass_NewRound_Items");
  297. set_task(0.1, "Reset_Wpn_Mode");
  298. remove_task(TASKID_BUYTIME);
  299.  
  300. if(get_pcvar_num(cvar_bot_allow_wpns) && g_buytime_expire == 0)
  301. set_task(1.5, "Bot_Weapon");
  302.  
  303. if(buytime < freezetime)
  304. t = float(buytime);
  305. else
  306. t = float(buytime+freezetime);
  307.  
  308. set_task(t, "Buytime_Expired", TASKID_BUYTIME);
  309. }
  310.  
  311. public Buytime_Expired()
  312. {
  313. g_buytime_expire = 1;
  314. }
  315.  
  316. public Reset_Wpn_Mode()
  317. {
  318. new players[32], pnum;
  319. get_players(players, pnum);
  320.  
  321. for(new i = 1; i <= pnum; i++)
  322. if(Get_BitVar(g_has_weapon, i))
  323. {
  324. new c, a;
  325. get_user_ammo(i, CSW_NEWPN, c, a);
  326.  
  327. if(a >= BPAMMO)
  328. g_wpn_mode[i] = 0;
  329. }
  330. }
  331.  
  332. public Bot_Weapon()
  333. {
  334. new players[32], pnum;
  335.  
  336. switch(TEAM)
  337. {
  338. case 0: get_players(players, pnum, "ad");
  339. case 1: get_players(players, pnum, "ade", "TERRORIST");
  340. case 2: get_players(players, pnum, "ade", "CT");
  341. }
  342.  
  343. for(new i = 0; i < pnum; i++)
  344. if(random_num(1,100) <= BOT_BUY_CHANCE && get_user_armor(players[i]) != 99 && !Get_BitVar(g_has_weapon, players[i]))
  345. {
  346. Get_Weapon(players[i]);
  347. cs_set_user_armor(players[i], 99, CS_ARMOR_VESTHELM);
  348. }
  349. }
  350.  
  351. public ClientCommand_BuyBaseWpn(id)
  352. {
  353. if(!cz75Enabled)
  354. return
  355.  
  356. if(purchase_check(id, BASEWPN_PRICE) && Get_BitVar(g_has_weapon, id))
  357. {
  358. drop_weapons(id);
  359. UnSet_BitVar(g_has_weapon,id);
  360. g_rebuy[id] = 0;
  361. }
  362. }
  363.  
  364. public ClientCommand_RePurchase(id)
  365. {
  366. if(is_plugin_loaded("Weapon Price Editor", false) <= 0)
  367. client_cmd(id, "rebuy");
  368.  
  369. if(g_rebuy[id] == 1 && !Get_BitVar(g_has_weapon, id))
  370. Get_Weapon(id);
  371. }
  372.  
  373. public ClientCommand_BuyAmmo(id)
  374. {
  375. if(!is_user_alive(id))
  376. return PLUGIN_HANDLED
  377.  
  378. if(!cs_get_user_buyzone(id))
  379. return PLUGIN_HANDLED
  380.  
  381. if(!Get_BitVar(g_has_weapon, id))
  382. return PLUGIN_CONTINUE
  383.  
  384. new wpns[32], wnum;
  385. get_user_weapons(id, wpns, wnum);
  386.  
  387. for (new i; i < wnum; i++)
  388. if(wpns[i] == CSW_NEWPN)
  389. {
  390. new i_bpammo = cs_get_user_bpammo(id, CSW_NEWPN);
  391.  
  392. if(i_bpammo >= BPAMMO)
  393. return PLUGIN_HANDLED
  394.  
  395. if(i_bpammo < BPAMMO)
  396. {
  397. if(i_bpammo > BPAMMO-AUNITS)
  398. {
  399. new i_ammo = BPAMMO - i_bpammo;
  400. give_ammo(id, i_ammo, AMMOID, ACOST);
  401. }
  402. else
  403. give_ammo(id, AUNITS, AMMOID, ACOST);
  404. }
  405.  
  406. return PLUGIN_HANDLED
  407. }
  408.  
  409. return PLUGIN_CONTINUE
  410. }
  411.  
  412. public ClientCommand_BuySecAmmo(id)
  413. {
  414. if(!is_user_alive(id))
  415. return PLUGIN_HANDLED
  416.  
  417. if(!cs_get_user_buyzone(id))
  418. return PLUGIN_HANDLED
  419.  
  420. if(!Get_BitVar(g_has_weapon, id))
  421. return PLUGIN_CONTINUE
  422.  
  423. new i_bpammo = cs_get_user_bpammo(id, CSW_NEWPN);
  424.  
  425. if(i_bpammo < BPAMMO)
  426. {
  427. new i_ammo = BPAMMO - i_bpammo;
  428. give_ammo(id, i_ammo, AMMOID, ACOST);
  429. }
  430.  
  431. return PLUGIN_HANDLED
  432. }
  433.  
  434. public ClientCommand_BuyShield(id)
  435. {
  436. if(!is_user_alive(id))
  437. return PLUGIN_HANDLED
  438.  
  439. if(!cs_get_user_buyzone(id))
  440. return PLUGIN_HANDLED
  441.  
  442. if(!purchase_check(id, 2200))
  443. return PLUGIN_HANDLED
  444.  
  445. if(Get_BitVar(g_has_weapon, id))
  446. drop_weapons(id);
  447.  
  448. return PLUGIN_CONTINUE
  449. }
  450.  
  451. public Get_Weapon(id)
  452. {
  453. if(!is_user_alive(id) || !is_user_connected(id) || !cz75Enabled)
  454. return
  455.  
  456. // Player tries to buy the same gun
  457. if(Get_BitVar(g_has_weapon, id))
  458. {
  459. client_print(id, print_center, "#Cstrike_Already_Own_Weapon");
  460. return
  461. }
  462.  
  463. if(TEAM > 0 && get_user_team(id) != TEAM)
  464. {
  465. client_print(id, print_center, "CZ75 bu takimda satin alinamiyor!");
  466. return
  467. }
  468.  
  469. if(purchase_check(id, PRICE))
  470. {
  471. if(cs_get_user_shield(id))
  472. {
  473. engclient_cmd(id, "slot1");
  474. engclient_cmd(id, "drop");
  475. }
  476.  
  477. drop_weapons(id);
  478. Set_BitVar(g_has_weapon, id);
  479. g_rebuy[id] = 1;
  480. g_wpn_mode[id] = 0;
  481. new weapon = give_item(id, weapon_newpn);
  482. cs_set_weapon_burst(weapon, 1);
  483. client_print(id, print_center, " ");
  484.  
  485. EnableHamForward(HandleWeaponIdle);
  486.  
  487. // Set Ammo
  488. cs_set_weapon_ammo(weapon, CLIP);
  489.  
  490. new ammo = cs_get_user_bpammo(id, CSW_NEWPN);
  491. if(ammo > BPAMMO && !has_9mm_weapons(id))
  492. cs_set_user_bpammo(id, CSW_NEWPN, ammo);
  493.  
  494. // Calculate new money amount
  495. static newmoney;
  496. newmoney = cs_get_user_money(id) - PRICE;
  497.  
  498. // Update money offset
  499. cs_set_user_money(id, newmoney);
  500.  
  501. // Update money on HUD
  502. message_begin(MSG_ONE, msg_Money, _, id);
  503. write_long(newmoney); // amount
  504. write_byte(1); // flash
  505. message_end();
  506. }
  507. }
  508.  
  509. public ClientCommand_SelectWeapon(id)
  510. {
  511. engclient_cmd(id, weapon_newpn);
  512. return PLUGIN_HANDLED
  513. }
  514.  
  515. public Fw_CmdStart(id, uc_handle, seed)
  516. {
  517. if(!is_user_alive(id))
  518. return
  519.  
  520. if(!Get_BitVar(g_has_weapon, id))
  521. return
  522.  
  523. if(get_user_weapon(id) != CSW_NEWPN)
  524. return
  525.  
  526. static new_button;
  527. new_button = get_uc(uc_handle, UC_Buttons);
  528.  
  529. if(new_button & IN_ATTACK2)
  530. set_uc(uc_handle, UC_Buttons, new_button &= ~IN_ATTACK2)
  531. }
  532.  
  533. public Event_CurWeapon(id)
  534. {
  535. if(!is_user_alive(id))
  536. return
  537.  
  538. static CSW_ID; CSW_ID = read_data(2);
  539.  
  540. if((CSW_ID == CSW_NEWPN && g_prev_weapon[id] == CSW_NEWPN))
  541. {
  542. static weapon;
  543. weapon= find_ent_by_owner(-1, weapon_newpn, id);
  544.  
  545. if(Get_BitVar(g_has_weapon, id))
  546. {
  547. if(!pev_valid(weapon))
  548. {
  549. g_prev_weapon[id] = get_user_weapon(id)
  550. return
  551. }
  552.  
  553. if(cs_get_user_bpammo(id, CSW_NEWPN) > BPAMMO)
  554. cs_set_user_bpammo(id, CSW_NEWPN, BPAMMO);
  555. }
  556. }
  557. else if((CSW_ID != CSW_NEWPN && g_prev_weapon[id] == CSW_NEWPN) && Get_BitVar(g_has_weapon, id))
  558. draw_new_weapon(id, get_user_weapon(id));
  559.  
  560. g_prev_weapon[id] = get_user_weapon(id);
  561. }
  562.  
  563. public Fw_ItemDeployPre(weapon)
  564. {
  565. static id;
  566. id = get_pdata_cbase(weapon, m_pPlayer, 4);
  567.  
  568. if(!is_user_alive(id))
  569. return
  570.  
  571. if(!Get_BitVar(g_has_weapon, id))
  572. return
  573. }
  574.  
  575. public Fw_ItemDeployPost(weapon)
  576. {
  577. static id;
  578. id = get_pdata_cbase(weapon, m_pPlayer, 4);
  579.  
  580. if(!is_user_alive(id))
  581. return
  582.  
  583. if(!Get_BitVar(g_has_weapon, id))
  584. return
  585.  
  586. arm_switch(id);
  587.  
  588. new ammo = cs_get_user_bpammo(id, CSW_NEWPN);
  589. if(ammo > BPAMMO && !has_9mm_weapons(id))
  590. cs_set_user_bpammo(id, CSW_NEWPN, BPAMMO);
  591.  
  592. if(cs_get_user_shield(id))
  593. {
  594. engclient_cmd(id, "slot1");
  595. engclient_cmd(id, "drop");
  596. }
  597. }
  598.  
  599. public Fw_AddItem(id, weapon)
  600. {
  601. static classname[24];
  602. pev(weapon, pev_classname, classname, charsmax(classname));
  603.  
  604. if(!Get_BitVar(g_has_weapon,id) && g_rebuy[id] == 1)
  605. {
  606. for(new i = 0; i < sizeof secondary_weapon_classnames; i++)
  607. if(equali(classname, secondary_weapon_classnames[i]) && g_newrnd_bypass == 1)
  608. {
  609. g_rebuy[id] = 0;
  610. return
  611. }
  612. }
  613. else if(equali(classname, weapon_newpn) && Get_BitVar(g_has_weapon,id))
  614. {
  615. g_rebuy[id] = 1;
  616. EnableHamForward(HandleWeaponIdle);
  617. }
  618. }
  619.  
  620. public Fw_RemoveItem(id)
  621. {
  622. set_task(0.01, "Fw_AddItem", id);
  623. }
  624.  
  625. public Fw_Block_Sheild_Pickup(ent, id)
  626. {
  627. if(!is_user_connected(id) || !is_user_alive(id))
  628. return HAM_IGNORED
  629.  
  630. if(Get_BitVar(g_has_weapon, id))
  631. return HAM_SUPERCEDE
  632.  
  633. return HAM_IGNORED
  634. }
  635.  
  636. public Fw_UpdateClientData_Post(id, sendweapons, cd_handle)
  637. {
  638. if(!is_user_alive(id))
  639. return FMRES_IGNORED
  640.  
  641. if(get_user_weapon(id) == CSW_NEWPN && Get_BitVar(g_has_weapon, id))
  642. set_cd(cd_handle, CD_flNextAttack, get_gametime() + 0.001)
  643.  
  644. return FMRES_HANDLED
  645. }
  646.  
  647. public Fw_PlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
  648. {
  649. if (!is_user_connected(invoker))
  650. return FMRES_IGNORED
  651.  
  652. if(get_user_weapon(invoker) != CSW_NEWPN || !Get_BitVar(g_has_weapon, invoker))
  653. return FMRES_IGNORED
  654.  
  655. if(eventid != g_weapon_event)
  656. return FMRES_IGNORED
  657.  
  658. engfunc(EngFunc_PlaybackEvent, flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2);
  659. set_weapon_anim(invoker, SHOOT_ANIM[g_wpn_mode[invoker]]);
  660. emit_sound(invoker, CHAN_WEAPON, FIRE_SOUND, VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
  661. make_shell(invoker);
  662.  
  663. return FMRES_SUPERCEDE
  664. }
  665.  
  666. public Fw_SetModel(wpn_ent, model[])
  667. {
  668. if(!pev_valid(wpn_ent))
  669. return FMRES_IGNORED
  670.  
  671. static classname[32];
  672. pev(wpn_ent, pev_classname, classname, sizeof classname);
  673.  
  674. if(!equal(classname, "weaponbox"))
  675. return FMRES_IGNORED
  676.  
  677. static id;
  678. id= pev(wpn_ent, pev_owner);
  679.  
  680. if(equal(model, BASE_W_MODEL))
  681. {
  682. static weapon;
  683. weapon = find_ent_by_owner(-1, weapon_newpn, wpn_ent);
  684.  
  685. if(!pev_valid(weapon))
  686. return FMRES_IGNORED;
  687.  
  688. if(Get_BitVar(g_has_weapon, id))
  689. {
  690. UnSet_BitVar(g_has_weapon,id)
  691.  
  692. set_pev(weapon, pev_impulse, WEAPON_SECRETCODE)
  693. engfunc(EngFunc_SetModel, wpn_ent, W_MODEL)
  694. set_pev(wpn_ent, pev_body, BODY_NUM)
  695.  
  696. return FMRES_SUPERCEDE
  697. }
  698. }
  699.  
  700. return FMRES_IGNORED;
  701. }
  702.  
  703. public Fw_TraceAttack_World(victim, attacker, Float:damage, Float:direction[3], prt, damage_bits)
  704. {
  705. if(!is_user_connected(attacker))
  706. return HAM_IGNORED
  707.  
  708. if(get_user_weapon(attacker) != CSW_NEWPN || !Get_BitVar(g_has_weapon, attacker))
  709. return HAM_IGNORED
  710.  
  711. static Float:origin[3], Float:vecPlane[3];
  712.  
  713. get_tr2(prt, TR_vecEndPos, origin);
  714. get_tr2(prt, TR_vecPlaneNormal, vecPlane);
  715.  
  716. make_bullet_hole(victim, attacker, origin);
  717. make_bullet_smoke(attacker, prt);
  718.  
  719. SetHamParamFloat(3, float(DAMAGE));
  720.  
  721. return HAM_IGNORED
  722. }
  723.  
  724. public Fw_TraceAttack_Player(victim, attacker, Float:damage, Float:direction[3], ptr, damage_bits)
  725. {
  726. if(!is_user_connected(attacker))
  727. return HAM_IGNORED
  728.  
  729. if(get_user_weapon(attacker) != CSW_NEWPN || !Get_BitVar(g_has_weapon, attacker))
  730. return HAM_IGNORED
  731.  
  732. SetHamParamFloat (3, float(DAMAGE));
  733.  
  734. return HAM_IGNORED
  735. }
  736.  
  737. public Fw_Weapon_On_Idle(weapon, uc_handle)
  738. {
  739. static id;
  740. id = get_pdata_cbase(weapon, m_pPlayer, 4);
  741.  
  742. if(!is_user_alive(id))
  743. return
  744.  
  745. if(!g_on_idle[id])
  746. return
  747.  
  748. if(Get_BitVar(g_has_weapon, id))
  749. {
  750. set_pev(id, pev_weaponanim, IDLE_ANIM[g_wpn_mode[id]]);
  751.  
  752. message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, {0, 0, 0}, id);
  753. write_byte(IDLE_ANIM[g_wpn_mode[id]]);
  754. write_byte(pev(id, pev_body));
  755. message_end();
  756. }
  757. }
  758.  
  759. public Ham_Attack_FullAuto_Post(iEnt)
  760. {
  761. static id
  762. id = pev(iEnt, pev_owner);
  763.  
  764. if(!Get_BitVar(g_has_weapon, id))
  765. return HAM_HANDLED
  766.  
  767. if(get_pdata_int(iEnt, m_fWeaponState, 4)&WEAPONSTATE_BURST_MODE )
  768. {
  769. if( get_pdata_int(iEnt, m_iGlock18ShotsFired, 4)!=0 ) // || get_pdata_float(iEnt, m_flGlock18Shoot, 4)==(get_gametime()+0.1) )
  770. {
  771. set_pdata_int(iEnt, m_iGlock18ShotsFired, 0, 4);
  772. set_pdata_float(iEnt, m_flGlock18Shoot, 0.0, 4);
  773.  
  774. #if defined USE_REAL_FIRE_RATE_GLOCK
  775. set_pdata_float(iEnt, m_flNextPrimaryAttack, RATEOFIRE, 4);
  776. set_pdata_float(iEnt, m_flNextSecondaryAttack, RATEOFIRE, 4);
  777. #else // cs/valve intended fire rate is 0.1sec, but it's messed up in the code to be next frame (you see how in full-auto that wont work)
  778. set_pdata_float(iEnt, m_flNextPrimaryAttack, RATEOFIRE, 4);
  779. set_pdata_float(iEnt, m_flNextSecondaryAttack, RATEOFIRE, 4);
  780. #endif
  781. static s_iPlrId, Float:s_fPunchAngle[3];
  782. s_iPlrId = get_pdata_cbase(iEnt, m_pPlayer, 4);
  783.  
  784. pev(s_iPlrId, pev_punchangle, s_fPunchAngle);
  785.  
  786. /*if( is_wbm_glock_recoil_enabled() ) // -1.8
  787. s_fPunchAngle[0] += 0.5;
  788. else if( s_fPunchAngle[0]>-8.5 )
  789. s_fPunchAngle[0] -= 1.3;*/
  790.  
  791. s_fPunchAngle[0] += RECOIL;
  792.  
  793. static Float:s_fVerticalPunch; // new method making first 3-4 bullets to have a lower recoil
  794. s_fVerticalPunch = floatmin(0.3, (floatclamp(s_fPunchAngle[0], -8.5, -0.1)/-4.25));
  795. s_fPunchAngle[0] -= (1.0+s_fVerticalPunch);
  796.  
  797. if( s_fPunchAngle[0]<-8.5 )
  798. s_fPunchAngle[0] = -8.5;
  799.  
  800. set_pev(s_iPlrId, pev_punchangle, s_fPunchAngle);
  801. }
  802. }
  803.  
  804. return HAM_IGNORED
  805. }
  806.  
  807. public Fw_Weapon_PrimaryAttack(weapon)
  808. {
  809. static id;
  810. id = pev(weapon, pev_owner);
  811. pev(id, pev_punchangle, g_recoil[id]);
  812.  
  813. return HAM_IGNORED
  814. }
  815.  
  816. public Fw_Weapon_PrimaryAttack_Post(weapon)
  817. {
  818. static id;
  819. id = pev(weapon, pev_owner);
  820.  
  821. if(Get_BitVar(g_has_weapon, id))
  822. {
  823. static Float:Push[3]
  824. pev(id, pev_punchangle, Push);
  825. xs_vec_sub(Push, g_recoil[id], Push);
  826.  
  827. xs_vec_mul_scalar(Push, RECOIL, Push);
  828. xs_vec_add(Push, g_recoil[id], Push);
  829. set_pev(id, pev_punchangle, Push);
  830.  
  831. remove_task(10100+id);
  832. g_on_idle[id] = 0;
  833. set_task(g_idletime[4], "Enable_Ham_Weapon_Idle", 10100+id);
  834. }
  835. }
  836.  
  837. public Fw_Item_AddToPlayer_Post(weapon, id)
  838. {
  839. if(!pev_valid(weapon))
  840. return HAM_IGNORED
  841.  
  842. if(pev(weapon, pev_impulse) == WEAPON_SECRETCODE)
  843. {
  844. Set_BitVar(g_has_weapon, id);
  845. set_pev(weapon, pev_impulse, 0);
  846. g_rebuy[id] = 1;
  847. }
  848.  
  849. if(Get_BitVar(g_has_weapon,id))
  850. {
  851. message_begin(MSG_ONE, msg_WeaponList, .player = id);
  852. write_string(NEWPN_NAME); // WeaponName
  853. write_byte(PRI_AMMO_ID); // PrimaryAmmoID
  854. write_byte(BPAMMO); // PrimaryAmmoMaxAmount
  855. write_byte(-1); // SecondaryAmmoID
  856. write_byte(-1); // SecondaryAmmoMaxAmount
  857. write_byte(SLOT_ID); // SlotID (0...N)
  858. write_byte(NUM_IN_SLOT); // NumberInSlot (1...N)
  859. write_byte(CSW_NEWPN); // WeaponID
  860. write_byte(ITEM_FLAGS); // Flags
  861. message_end();
  862. } else {
  863. message_begin(MSG_ONE, msg_WeaponList, .player = id);
  864. write_string(weapon_newpn); // WeaponName
  865. write_byte(PRI_AMMO_ID); // PrimaryAmmoID
  866. write_byte(BPAMMO); // PrimaryAmmoMaxAmount
  867. write_byte(-1); // SecondaryAmmoID
  868. write_byte(-1); // SecondaryAmmoMaxAmount
  869. write_byte(SLOT_ID); // SlotID (0...N)
  870. write_byte(NUM_IN_SLOT); // NumberInSlot (1...N)
  871. write_byte(CSW_NEWPN); // WeaponID
  872. write_byte(ITEM_FLAGS); // Flags
  873. message_end();
  874. }
  875.  
  876. return HAM_HANDLED
  877. }
  878.  
  879. public Fw_Item_PostFrame(weapon)
  880. {
  881. if(!pev_valid(weapon))
  882. return HAM_IGNORED
  883.  
  884. static id
  885. id = pev(weapon, pev_owner)
  886.  
  887. if(is_user_alive(id) && Get_BitVar(g_has_weapon, id))
  888. {
  889. static Float:flNextAttack; flNextAttack = get_pdata_float(id, m_flNextAttack, 5);
  890. static bpammo; bpammo = cs_get_user_bpammo(id, CSW_NEWPN);
  891. static i_clip; i_clip = get_pdata_int(weapon, m_iClip, 4);
  892. static fInReload; fInReload = get_pdata_int(weapon, m_fInReload, 4);
  893.  
  894. if(fInReload && flNextAttack <= 0.0)
  895. {
  896. static temp1; temp1 = min(CLIP - i_clip, bpammo);
  897.  
  898. set_pdata_int(weapon, m_iClip, i_clip + temp1, 4);
  899. cs_set_user_bpammo(id, CSW_NEWPN, bpammo - temp1);
  900.  
  901. set_pdata_int(weapon, m_fInReload, 0, 4);
  902.  
  903. fInReload = 0;
  904.  
  905. set_pdata_float(weapon, m_flNextPrimaryAttack, RELOAD_TIME[g_wpn_mode[id]] - RELOAD_POINT[g_wpn_mode[id]], 4);
  906. }
  907. }
  908.  
  909. return HAM_IGNORED
  910. }
  911.  
  912. public Fw_Weapon_Reload(weapon)
  913. {
  914. static id; id = pev(weapon, pev_owner);
  915.  
  916. if(!is_user_alive(id))
  917. return HAM_IGNORED
  918.  
  919. if(!Get_BitVar(g_has_weapon, id))
  920. return HAM_IGNORED
  921.  
  922. g_clip[id] = -1;
  923.  
  924. static bpammo; bpammo = cs_get_user_bpammo(id, CSW_NEWPN);
  925. static i_clip; i_clip = get_pdata_int(weapon, m_iClip, 4);
  926.  
  927. if(bpammo <= 0)
  928. return HAM_SUPERCEDE
  929.  
  930. if(i_clip >= CLIP)
  931. return HAM_SUPERCEDE
  932.  
  933. g_clip[id] = i_clip;
  934.  
  935. return HAM_HANDLED
  936. }
  937.  
  938. public Fw_Weapon_Reload_Post(weapon)
  939. {
  940. static id;
  941. id = pev(weapon, pev_owner);
  942.  
  943. if(!is_user_alive(id))
  944. return HAM_IGNORED
  945.  
  946. if(!Get_BitVar(g_has_weapon, id))
  947. return HAM_IGNORED
  948.  
  949. if (g_clip[id] == -1)
  950. return HAM_IGNORED
  951.  
  952. set_pdata_int(weapon, m_iClip, g_clip[id], 4);
  953. set_pdata_int(weapon, m_fInReload, 1, 4);
  954.  
  955. set_weapon_anim(id, RELOAD_ANIM[g_wpn_mode[id]]);
  956. set_pdata_float(id, m_flNextAttack, RELOAD_POINT[g_wpn_mode[id]], 5);
  957.  
  958. g_wpn_mode[id] = 1;
  959.  
  960. return HAM_HANDLED
  961. }
  962.  
  963. public Fw_Player_Death(id)
  964. {
  965. if(!is_user_connected(id))
  966. return HAM_IGNORED
  967.  
  968. if(Get_BitVar(g_has_weapon, id))
  969. {
  970. set_task(0.1, "Remove_Weapon", id);
  971. g_rebuy[id] = 1;
  972. }
  973.  
  974. return HAM_HANDLED
  975. }
  976.  
  977. public Message_DeathMsg(msg_id, msg_dest, id)
  978. {
  979. static attacker, weapon[33];
  980.  
  981. attacker = get_msg_arg_int(1);
  982. get_msg_arg_string(4, weapon, charsmax(weapon))
  983.  
  984. if(!is_user_connected(attacker))
  985. return PLUGIN_CONTINUE
  986.  
  987. if(equal(weapon, basewpn_shortname) && Get_BitVar(g_has_weapon, attacker))
  988. set_msg_arg_string(4, newpn_shortname);
  989.  
  990. return PLUGIN_CONTINUE
  991. }
  992.  
  993. public Player_Weapon_Walkspeed(weapon)
  994. {
  995. new id = get_pdata_cbase(weapon, m_pPlayer, 4);
  996.  
  997. if(!is_user_alive(id))
  998. return HAM_IGNORED
  999.  
  1000. if(Get_BitVar(g_has_weapon, id))
  1001. SetHamReturnFloat(WALKSPEED);
  1002. else
  1003. return HAM_IGNORED
  1004.  
  1005. return HAM_SUPERCEDE
  1006. }
  1007.  
  1008. public Inspect_Weapon(id)
  1009. {
  1010. if(!is_user_alive(id))
  1011. return
  1012.  
  1013. if(!Get_BitVar(g_has_weapon, id))
  1014. return
  1015.  
  1016. if(get_user_weapon(id) != CSW_NEWPN)
  1017. return
  1018.  
  1019. static weapon; weapon = get_pdata_cbase(id, m_pActiveItem);
  1020. new current_anim = pev(get_pdata_cbase(weapon, m_pPlayer, 4), pev_weaponanim);
  1021.  
  1022. if(!current_anim || current_anim == 1)
  1023. set_weapon_anim(id, INSPECT_ANIM[g_wpn_mode[id]]);
  1024. }
  1025.  
  1026. public Remove_Weapon(id, all)
  1027. {
  1028. switch(all)
  1029. {
  1030. case 1:
  1031. {
  1032. new players[32], pnum;
  1033. get_players(players, pnum, "a");
  1034.  
  1035. for(new i = 0; i <= pnum; i++)
  1036. UnSet_BitVar(g_has_weapon, players[i]);
  1037. }
  1038. default:
  1039. UnSet_BitVar(g_has_weapon, id);
  1040. }
  1041.  
  1042. check_weapon_usage()
  1043. }
  1044.  
  1045. public Bypass_NewRound_Items()
  1046. {
  1047. g_newrnd_bypass = 1;
  1048. }
  1049.  
  1050. bool:purchase_check(id, cost)
  1051. {
  1052. if (!cs_get_user_buyzone(id))
  1053. return false
  1054.  
  1055. // Check for buy time
  1056. if(g_buytime_expire == 1)
  1057. {
  1058. client_print(id, print_center, "%d seconds have passed.^n You can't buy anything now!",floatround(get_cvar_float("mp_buytime") * 60));
  1059. return false
  1060. }
  1061.  
  1062. // Check if player has enough money
  1063. if (cs_get_user_money(id) < cost)
  1064. {
  1065. client_print(id, print_center, "#Cstrike_TitlesTXT_Not_Enough_Money");
  1066.  
  1067. // Blink money
  1068. message_begin(MSG_ONE_UNRELIABLE, msg_BlinkAcct, _, id);
  1069. write_byte(2); // times
  1070. message_end();
  1071. return false
  1072. }
  1073. return true
  1074. }
  1075.  
  1076. bool:has_9mm_weapons(id)
  1077. {
  1078. new wpns[32], num = 0;
  1079. get_user_weapons(id, wpns, num );
  1080.  
  1081. for(new i = 0; i < num; i++)
  1082. if(wpns[i] == CSW_MP5NAVY || wpns[i] == CSW_TMP)
  1083. return true
  1084.  
  1085. return false
  1086. }
  1087.  
  1088. check_weapon_usage() //If no one is using the CZ75, turn off Weapon Idle
  1089. {
  1090. new players[32], pnum, cz75_in_use = 0;
  1091. get_players(players, pnum, "a");
  1092.  
  1093. for(new i = 0; i <= pnum; i++)
  1094. if(Get_BitVar(g_has_weapon,i))
  1095. cz75_in_use = 1;
  1096.  
  1097. if(!cz75_in_use)
  1098. DisableHamForward(HandleWeaponIdle);
  1099. }
  1100. draw_new_weapon(id, CSW_ID)
  1101. {
  1102. static weapon;
  1103. weapon = find_ent_by_owner(-1, weapon_newpn, id);
  1104.  
  1105. if(CSW_ID == CSW_NEWPN)
  1106. {
  1107. if(pev_valid(weapon) && Get_BitVar(g_has_weapon, id))
  1108. {
  1109. set_pev(weapon, pev_effects, pev(weapon, pev_effects) &~ EF_NODRAW);
  1110. engfunc(EngFunc_SetModel, weapon, P_MODEL);
  1111. set_pev(weapon, pev_body, BODY_NUM);
  1112. }
  1113. }
  1114. else
  1115. if(pev_valid(weapon))
  1116. set_pev(weapon, pev_effects, pev(weapon, pev_effects) | EF_NODRAW);
  1117. }
  1118.  
  1119. make_bullet_smoke(id, TrResult)
  1120. {
  1121. static Float:vecSrc[3], Float:vecEnd[3], TE_FLAG;
  1122.  
  1123. get_weapon_attachment(id, vecSrc);
  1124. global_get(glb_v_forward, vecEnd);
  1125.  
  1126. xs_vec_mul_scalar(vecEnd, 8192.0, vecEnd);
  1127. xs_vec_add(vecSrc, vecEnd, vecEnd);
  1128.  
  1129. get_tr2(TrResult, TR_vecEndPos, vecSrc);
  1130. get_tr2(TrResult, TR_vecPlaneNormal, vecEnd);
  1131.  
  1132. xs_vec_mul_scalar(vecEnd, 2.5, vecEnd);
  1133. xs_vec_add(vecSrc, vecEnd, vecEnd);
  1134.  
  1135. TE_FLAG |= TE_EXPLFLAG_NODLIGHTS;
  1136. TE_FLAG |= TE_EXPLFLAG_NOSOUND;
  1137. TE_FLAG |= TE_EXPLFLAG_NOPARTICLES;
  1138.  
  1139. engfunc(EngFunc_MessageBegin, MSG_PAS, SVC_TEMPENTITY, vecEnd, 0);
  1140. write_byte(TE_EXPLOSION);
  1141. engfunc(EngFunc_WriteCoord, vecEnd[0]);
  1142. engfunc(EngFunc_WriteCoord, vecEnd[1]);
  1143. engfunc(EngFunc_WriteCoord, vecEnd[2] - 10.0);
  1144. write_short(smoke_sprite);
  1145. write_byte(5);
  1146. write_byte(50);
  1147. write_byte(TE_FLAG);
  1148. message_end();
  1149. }
  1150.  
  1151. make_bullet_hole(victim, attacker, Float:origin[3])
  1152. {
  1153. static decal;
  1154.  
  1155. if(!get_pcvar_num(cvar_decals))
  1156. decal = random_num(41, 43);
  1157. else
  1158. decal = random_num(52, 55);
  1159.  
  1160. if(victim)
  1161. {
  1162. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  1163. write_byte(TE_DECAL)
  1164. engfunc(EngFunc_WriteCoord, origin[0])
  1165. engfunc(EngFunc_WriteCoord, origin[1])
  1166. engfunc(EngFunc_WriteCoord, origin[2])
  1167. write_byte(decal)
  1168. write_short(victim)
  1169. message_end()
  1170. }
  1171. else
  1172. {
  1173. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  1174. write_byte(TE_WORLDDECAL)
  1175. engfunc(EngFunc_WriteCoord, origin[0])
  1176. engfunc(EngFunc_WriteCoord, origin[1])
  1177. engfunc(EngFunc_WriteCoord, origin[2])
  1178. write_byte(decal)
  1179. message_end()
  1180. }
  1181. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  1182. write_byte(TE_GUNSHOTDECAL)
  1183. engfunc(EngFunc_WriteCoord, origin[0])
  1184. engfunc(EngFunc_WriteCoord, origin[1])
  1185. engfunc(EngFunc_WriteCoord, origin[2])
  1186. write_short(attacker)
  1187. write_byte(decal)
  1188. message_end()
  1189. }
  1190.  
  1191. make_shell(id)
  1192. {
  1193. static Float:player_origin[3], Float:origin[3], Float:origin2[3], Float:gunorigin[3], Float:oldangles[3], Float:v_forward[3], Float:v_forward2[3], Float:v_up[3], Float:v_up2[3], Float:v_right[3], Float:v_right2[3], Float:viewoffsets[3];
  1194.  
  1195. pev(id,pev_v_angle, oldangles); pev(id,pev_origin,player_origin); pev(id, pev_view_ofs, viewoffsets);
  1196.  
  1197. engfunc(EngFunc_MakeVectors, oldangles)
  1198.  
  1199. global_get(glb_v_forward, v_forward); global_get(glb_v_up, v_up); global_get(glb_v_right, v_right);
  1200. global_get(glb_v_forward, v_forward2); global_get(glb_v_up, v_up2); global_get(glb_v_right, v_right2);
  1201.  
  1202. xs_vec_add(player_origin, viewoffsets, gunorigin);
  1203.  
  1204. xs_vec_mul_scalar(v_forward, 10.3, v_forward); xs_vec_mul_scalar(v_right, 2.9, v_right);
  1205. xs_vec_mul_scalar(v_up, -3.7, v_up);
  1206. xs_vec_mul_scalar(v_forward2, 10.0, v_forward2); xs_vec_mul_scalar(v_right2, 3.0, v_right2);
  1207. xs_vec_mul_scalar(v_up2, -4.0, v_up2);
  1208.  
  1209. xs_vec_add(gunorigin, v_forward, origin);
  1210. xs_vec_add(gunorigin, v_forward2, origin2);
  1211. xs_vec_add(origin, v_right, origin);
  1212. xs_vec_add(origin2, v_right2, origin2);
  1213. xs_vec_add(origin, v_up, origin);
  1214. xs_vec_add(origin2, v_up2, origin2);
  1215.  
  1216. static Float:velocity[3]
  1217. get_speed_vector(origin2, origin, random_float(140.0, 160.0), velocity)
  1218.  
  1219. static angle; angle = random_num(0, 360)
  1220.  
  1221. message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, _, id)
  1222. write_byte(TE_MODEL)
  1223. engfunc(EngFunc_WriteCoord, origin[0])
  1224. engfunc(EngFunc_WriteCoord,origin[1])
  1225. engfunc(EngFunc_WriteCoord,origin[2])
  1226. engfunc(EngFunc_WriteCoord,velocity[0])
  1227. engfunc(EngFunc_WriteCoord,velocity[1])
  1228. engfunc(EngFunc_WriteCoord,velocity[2])
  1229. write_angle(angle)
  1230. write_short(shell_model)
  1231. write_byte(1)
  1232. write_byte(20)
  1233. message_end()
  1234. }
  1235.  
  1236. get_speed_vector(const Float:origin1[3],const Float:origin2[3],Float:speed, Float:new_velocity[3])
  1237. {
  1238. new_velocity[0] = origin2[0] - origin1[0]
  1239. new_velocity[1] = origin2[1] - origin1[1]
  1240. new_velocity[2] = origin2[2] - origin1[2]
  1241. new Float:num = floatsqroot(speed*speed / (new_velocity[0]*new_velocity[0] + new_velocity[1]*new_velocity[1] + new_velocity[2]*new_velocity[2]))
  1242. new_velocity[0] *= num
  1243. new_velocity[1] *= num
  1244. new_velocity[2] *= num
  1245.  
  1246. return 1;
  1247. }
  1248.  
  1249. get_weapon_attachment(id, Float:output[3], Float:fDis = 40.0)
  1250. {
  1251. static Float:vfEnd[3], viEnd[3] ;
  1252. get_user_origin(id, viEnd, 3);
  1253. IVecFVec(viEnd, vfEnd);
  1254.  
  1255. static Float:fOrigin[3], Float:fAngle[3];
  1256.  
  1257. pev(id, pev_origin, fOrigin);
  1258. pev(id, pev_view_ofs, fAngle);
  1259.  
  1260. xs_vec_add(fOrigin, fAngle, fOrigin);
  1261.  
  1262. static Float:fAttack[3];
  1263.  
  1264. xs_vec_sub(vfEnd, fOrigin, fAttack);
  1265. xs_vec_sub(vfEnd, fOrigin, fAttack);
  1266.  
  1267. static Float:fRate;
  1268.  
  1269. fRate = fDis / vector_length(fAttack);
  1270. xs_vec_mul_scalar(fAttack, fRate, fAttack);
  1271.  
  1272. xs_vec_add(fOrigin, fAttack, output);
  1273. }
  1274.  
  1275. set_weapon_anim(id, anim)
  1276. {
  1277. if(!is_user_alive(id))
  1278. return
  1279.  
  1280. set_pev(id, pev_weaponanim, anim);
  1281.  
  1282. message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, {0, 0, 0}, id);
  1283. write_byte(anim);
  1284. write_byte(pev(id, pev_body));
  1285. message_end();
  1286.  
  1287. static weapon;
  1288. weapon = find_ent_by_owner(-1, weapon_newpn, id);
  1289.  
  1290. if(!weapon)
  1291. return
  1292.  
  1293. switch(anim)
  1294. {
  1295. case 2, 3: //Draw 0 & 1
  1296. {
  1297. remove_task(10100+id);
  1298. g_on_idle[id] = 0;
  1299. set_task(g_idletime[g_wpn_mode[id]], "Enable_Ham_Weapon_Idle", 10100+id);
  1300. set_pdata_float(weapon, m_flTimeWeaponIdle, g_idletime[g_wpn_mode[id]], 4);
  1301. }
  1302. case 8, 9: //Reload 0 & 1
  1303. {
  1304. remove_task(10100+id);
  1305. g_on_idle[id] = 0;
  1306. set_task(RELOAD_TIME[g_wpn_mode[id]], "Enable_Ham_Weapon_Idle", 10100+id);
  1307. set_pdata_float(weapon, m_flTimeWeaponIdle, RELOAD_TIME[g_wpn_mode[id]], 4);
  1308. }
  1309. case 10, 11: //Inspect 0 & 1
  1310. {
  1311. remove_task(10100+id);
  1312. g_on_idle[id] = 0;
  1313. set_task(g_idletime[5], "Enable_Ham_Weapon_Idle", 10100+id);
  1314. set_pdata_float(weapon, m_flTimeWeaponIdle, g_idletime[5], 4);
  1315. }
  1316. }
  1317. }
  1318.  
  1319. public Enable_Ham_Weapon_Idle(task_id)
  1320. {
  1321. new id = task_id - 10100;
  1322. g_on_idle[id] = 1;
  1323. }
  1324.  
  1325. // Drop primary/secondary weapons
  1326. drop_weapons(id)
  1327. {
  1328. // Get user weapons
  1329. static weapons[32], num, i, wpn_id;
  1330. num = 0; // reset passed weapons count (bugfix)
  1331. get_user_weapons(id, weapons, num);
  1332.  
  1333. // Loop through them and drop primaries or secondaries
  1334. for (i = 0; i < num; i++)
  1335. {
  1336. // Prevent re-indexing the array
  1337. wpn_id = weapons[i];
  1338.  
  1339. if(1<<wpn_id & WEAPONS_BIT_SUM)
  1340. {
  1341. // Get weapon entity
  1342. static wname[32];
  1343. get_weaponname(wpn_id, wname, charsmax(wname));
  1344.  
  1345. // Player drops the weapon
  1346. engclient_cmd(id, "drop", wname);
  1347. }
  1348. }
  1349. }
  1350.  
  1351. arm_switch(id)
  1352. {
  1353. if(get_user_team(id) == get_pcvar_num(cvar_alteam))
  1354. set_pev(id, pev_viewmodel2, V_MODEL_ALT);
  1355. else
  1356. set_pev(id, pev_viewmodel2, V_MODEL);
  1357.  
  1358. set_pev(id, pev_weaponmodel2, P_MODEL)
  1359. set_weapon_anim(id, DRAW_ANIM[g_wpn_mode[id]])
  1360. draw_new_weapon(id, CSW_NEWPN)
  1361. }
  1362.  
  1363. give_ammo(id, ammo, ammo_id, cost)
  1364. {
  1365. if (cs_get_user_money(id) < cost)
  1366. {
  1367. client_print(id, print_center, "#Cstrike_TitlesTXT_Not_Enough_Money");
  1368.  
  1369. // Blink money
  1370. message_begin(MSG_ONE_UNRELIABLE, msg_BlinkAcct, _, id);
  1371. write_byte(2); // times
  1372. message_end();
  1373. return PLUGIN_HANDLED
  1374. }
  1375.  
  1376. new newammo = cs_get_user_bpammo(id, CSW_NEWPN) + ammo;
  1377. cs_set_user_bpammo(id, CSW_NEWPN, newammo);
  1378.  
  1379. message_begin(MSG_ONE,get_user_msgid("AmmoPickup"),_, id );
  1380. write_byte(ammo_id);
  1381. write_byte(ammo);
  1382. message_end();
  1383.  
  1384. emit_sound(id, CHAN_ITEM, "items/9mmclip1.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
  1385.  
  1386. // Calculate new money amount
  1387. static newmoney;
  1388. newmoney = cs_get_user_money(id) - cost;
  1389.  
  1390. // Update money offset
  1391. cs_set_user_money(id, newmoney, 1);
  1392.  
  1393. new c, a;
  1394. get_user_ammo(id, CSW_NEWPN, c, a);
  1395.  
  1396. if(g_wpn_mode[id] == 1 && c)
  1397. {
  1398. g_wpn_mode[id] = 0;
  1399.  
  1400. if(get_user_weapon(id) == CSW_NEWPN)
  1401. {
  1402. set_weapon_anim(id, DRAW_ANIM[0]);
  1403. draw_new_weapon(id, get_user_weapon(id));
  1404. }
  1405. }
  1406.  
  1407. return PLUGIN_CONTINUE
  1408. }
  1409.  
Add Comment
Please, Sign In to add comment