Guest User

Untitled

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