MegastoRM

pmod

Jul 20th, 2012
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 32.52 KB | None | 0 0
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <cstrike>
  4. #include <engine>
  5. #include <zombieplague>
  6. #include <fun>
  7.  
  8. #define PLUGIN "Purchase Mod"
  9. #define VERSION "1.4.1"
  10. #define AUTHOR "Dizzy"
  11.  
  12. #define FL_WATERJUMP (1<<11)
  13. #define FL_ONGROUND (1<<9)
  14.  
  15. #define CVAR_PLUGIN "amx_pmod"
  16. #define CVAR_MULTI "amx_pmod_multi"
  17. #define CVAR_STAYOPEN "amx_pmod_menu"
  18. #define CVAR_ROUNDS "amx_pmod_rounds"
  19. #define CVAR_DROPALLOW "amx_pmod_dropallow"
  20. #define CVAR_DROPRATE "amx_pmod_droprate"
  21.  
  22. #define CVAR_GRAVITY "amx_pmod_gravity"
  23. #define CVAR_SPEED "amx_pmod_speed"
  24. #define CVAR_STEALTH "amx_pmod_stealth"
  25. #define CVAR_GLASSES "amx_pmod_glasses"
  26. #define CVAR_MULTIJUMP "amx_pmod_multijump"
  27. #define CVAR_BUNNYHOP "amx_pmod_bunnyhop"
  28. #define CVAR_HEALTH "amx_pmod_health"
  29.  
  30. #define GRAVITYCOST "amx_pmod_gravityCost"
  31. #define SPEEDCOST "amx_pmod_speedCost"
  32. #define STEALTHCOST "amx_pmod_stealthCost"
  33. #define GLASSESCOST "amx_pmod_glassesCost"
  34. #define MULTIJUMPCOST "amx_pmod_multijumpCost"
  35. #define BUNNYHOPCOST "amx_pmod_bunnyhopCost"
  36. #define HEALTHCOST "amx_pmod_healthCost"
  37.  
  38. #define PLAYERSPEED "amx_pmod_playerspeed"
  39. #define PLAYERGRAVITY "amx_pmod_playergravity"
  40. #define PLAYERHEALTH "amx_pmod_playerhealth"
  41. #define PLAYERARMOR "amx_pmod_playerarmor"
  42.  
  43.  
  44. #define MULTIJUMPNUMBER "amx_pmod_multijumpnumber"
  45.  
  46. new const g_szAbilities[][] =
  47. {
  48. "Gravity",
  49. "Speed",
  50. "Stealth",
  51. "Anti-flash glasses",
  52. "Multi jump",
  53. "Bunny hop",
  54. "Health and Armor"
  55. }
  56.  
  57. new g_haveability[33] = 0;
  58.  
  59. new g_havegravity[33] = 0;
  60. new g_havespeed[33] = 0;
  61. new g_havestealth[33] = 0;
  62. new g_haveglasses[33] = 0;
  63. new g_havemultijump[33] = 0;
  64. new g_havebunnyhop[33] = 0;
  65. new g_havehealth[33] = 0;
  66.  
  67. new g_roundsgravity[33];
  68. new g_roundsspeed[33];
  69. new g_roundsstealth[33];
  70. new g_roundsglasses[33];
  71. new g_roundsmultijump[33];
  72. new g_roundsbunnyhop[33];
  73. new g_roundshealth[33];
  74.  
  75. new g_jumpnum[33]
  76. new bool:g_dojump[33];
  77.  
  78.  
  79. new g_msgscreenfade;
  80.  
  81. public client_connect(id)
  82. {
  83. g_haveability[id] = 0;
  84.  
  85. g_havegravity[id] = 0;
  86. g_havespeed[id] = 0;
  87. g_havestealth[id] = 0;
  88. g_haveglasses[id] = 0;
  89. g_havemultijump[id] = 0;
  90. g_havebunnyhop[id] = 0;
  91. g_havehealth[id] = 0;
  92. }
  93.  
  94. public client_disconnect(id)
  95. {
  96. g_haveability[id] = 0;
  97.  
  98. g_havegravity[id] = 0;
  99. g_havespeed[id] = 0;
  100. g_havestealth[id] = 0;
  101. g_haveglasses[id] = 0;
  102. g_havemultijump[id] = 0;
  103. g_havebunnyhop[id] = 0;
  104. g_havehealth[id] = 0;
  105. }
  106.  
  107. public plugin_init()
  108. {
  109. register_plugin(PLUGIN, VERSION, AUTHOR);
  110.  
  111. register_cvar(CVAR_PLUGIN, "1");
  112. register_cvar(CVAR_MULTI, "0");
  113. register_cvar(CVAR_STAYOPEN, "0");
  114. register_cvar(CVAR_ROUNDS, "1");
  115. register_cvar(CVAR_DROPALLOW, "1");
  116.  
  117. register_cvar(GRAVITYCOST, "7");
  118. register_cvar(SPEEDCOST, "7");
  119. register_cvar(STEALTHCOST, "7");
  120. register_cvar(GLASSESCOST, "7");
  121. register_cvar(MULTIJUMPCOST, "10");
  122. register_cvar(BUNNYHOPCOST, "12");
  123. register_cvar(HEALTHCOST, "15");
  124.  
  125. register_cvar(CVAR_GRAVITY, "1");
  126. register_cvar(CVAR_SPEED, "1");
  127. register_cvar(CVAR_STEALTH, "1");
  128. register_cvar(CVAR_GLASSES, "1");
  129. register_cvar(CVAR_MULTIJUMP, "1");
  130. register_cvar(CVAR_BUNNYHOP, "1");
  131. register_cvar(CVAR_HEALTH, "1");
  132.  
  133. register_cvar(PLAYERSPEED, "320");
  134. register_cvar(PLAYERGRAVITY, "200");
  135. register_cvar(PLAYERHEALTH, "200");
  136. register_cvar(PLAYERARMOR, "200");
  137. register_cvar(CVAR_DROPRATE, "25");
  138.  
  139. register_cvar(MULTIJUMPNUMBER, "3");
  140.  
  141. register_clcmd("say pmodmenu","startpage");
  142.  
  143. register_clcmd("say_team pmodmenu","startpage");
  144.  
  145. register_clcmd("pmodmenu","startpage");
  146.  
  147. register_concmd("pmodmenu","startpage");
  148.  
  149. register_event("ResetHUD","roundchange","b");
  150. register_event("CurWeapon","speedb","be","1=1");
  151. register_event("ScreenFade","event_blinded","be","4=255","5=255","6=255","7>199");
  152. register_event("DeathMsg","death_event","a");
  153.  
  154. g_msgscreenfade = get_user_msgid("ScreenFade");
  155. }
  156.  
  157. public plugin_precache()
  158. {
  159. precache_sound("purchasemod/buy.wav");
  160. precache_sound("purchasemod/drain.wav");
  161. precache_sound("purchasemod/sorry.wav");
  162. }
  163.  
  164. public client_putinserver(id)
  165. {
  166. if (is_user_bot(id))
  167. return;
  168.  
  169. set_task(25.0, "inform", id);
  170. }
  171.  
  172. public inform(id)
  173. {
  174. new gMsgSayText;
  175.  
  176. gMsgSayText = get_user_msgid("SayText");
  177. new printMsg[191];
  178.  
  179. client_print(id, print_chat, "[Purchase Mod]: This server is running Purchase Mod v%s -- By: %s", VERSION, AUTHOR);
  180. format(printMsg,191, "^x01[Purchase Mod]: Type ^x03pmodmenu ^x01to start!");
  181.  
  182. message_begin(MSG_ONE,gMsgSayText,{0,0,0},id);
  183. write_byte(id);
  184. write_string(printMsg);
  185. message_end();
  186.  
  187. return PLUGIN_HANDLED;
  188. }
  189.  
  190. public startpage(id)
  191. {
  192. new menu = menu_create("\wPurchase Mod: \rMain Menu", "start_handler")
  193.  
  194. if (!get_cvar_num(CVAR_PLUGIN) || !is_user_alive(id))
  195. menu_additem(menu, "\dPurchase Ability", "1", 0);
  196. else
  197. menu_additem(menu, "\wPurchase Ability", "1", 0);
  198. if (!get_cvar_num(CVAR_PLUGIN) || !is_user_alive(id) || !get_cvar_num(CVAR_DROPALLOW))
  199. menu_additem(menu, "\dDrop Ability", "2", 0);
  200. else
  201. menu_additem(menu, "\wDrop Ability", "2", 0);
  202.  
  203. menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);
  204. menu_display(id, menu, 0);
  205. }
  206.  
  207. public start_handler(id, menu, item)
  208. {
  209. if (item == MENU_EXIT)
  210. {
  211. menu_destroy(menu);
  212. return PLUGIN_HANDLED;
  213. }
  214.  
  215. new data[6], iName[64];
  216. new access, callback;
  217. menu_item_getinfo(menu, item, access, data, 5, iName, 63, callback);
  218.  
  219. new key = str_to_num(data);
  220.  
  221. switch(key)
  222. {
  223. case 1:
  224. {
  225. if (!get_cvar_num(CVAR_PLUGIN))
  226. {
  227. client_print(id, print_chat, "[Purchase Mod]: Sorry, the plugin is off!");
  228. client_cmd(id,"spk purchasemod/sorry");
  229. if (get_cvar_num(CVAR_STAYOPEN))
  230. startpage(id);
  231. }
  232. if (!is_user_alive(id))
  233. {
  234. client_print(id, print_chat, "[Purchase Mod]: You must be alive to purchase items!");
  235. client_cmd(id,"spk purchasemod/sorry");
  236. if (get_cvar_num(CVAR_STAYOPEN))
  237. startpage(id);
  238. }
  239. else if (get_cvar_num(CVAR_PLUGIN) && is_user_alive(id))
  240. {
  241. buypage(id);
  242. }
  243. }
  244. case 2:
  245. {
  246. if (!get_cvar_num(CVAR_PLUGIN))
  247. {
  248. client_print(id, print_chat, "[Purchase Mod]: Sorry, the plugin is off!");
  249. client_cmd(id,"spk purchasemod/sorry");
  250. if (get_cvar_num(CVAR_STAYOPEN))
  251. startpage(id);
  252. }
  253. if (!is_user_alive(id))
  254. {
  255. client_print(id, print_chat, "[Purchase Mod]: You must be alive to purchase items!");
  256. client_cmd(id,"spk purchasemod/sorry");
  257. if (get_cvar_num(CVAR_STAYOPEN))
  258. startpage(id);
  259. }
  260. if (!get_cvar_num(CVAR_DROPALLOW))
  261. {
  262. client_print(id, print_chat, "[Purchase Mod]: Sorry, dropping abilities is not allowed!");
  263. client_cmd(id,"spk purchasemod/sorry");
  264. if (get_cvar_num(CVAR_STAYOPEN))
  265. startpage(id);
  266. }
  267. else if (get_cvar_num(CVAR_PLUGIN) && is_user_alive(id) && get_cvar_num(CVAR_DROPALLOW))
  268. {
  269. droppage(id);
  270. }
  271. }
  272. }
  273. menu_destroy(menu);
  274.  
  275. return PLUGIN_HANDLED;
  276. }
  277.  
  278. public buypage(id)
  279. {
  280. new menu = menu_create("\wPurchase Mod: \rBuy Menu", "buy_handler")
  281. new userMoney = zp_get_user_ammo_packs(id)
  282.  
  283. if (!get_cvar_num(CVAR_GRAVITY) || (get_cvar_num(GRAVITYCOST) > userMoney) || (!get_cvar_num(CVAR_MULTI) && g_haveability[id]))
  284. menu_additem(menu, "\dGravity", "1", 0);
  285. else
  286. menu_additem(menu, "\wGravity", "1", 0);
  287. if (!get_cvar_num(CVAR_SPEED) || (get_cvar_num(SPEEDCOST) > userMoney) || (!get_cvar_num(CVAR_MULTI) && g_haveability[id]))
  288. menu_additem(menu, "\dSpeed", "2", 0);
  289. else
  290. menu_additem(menu, "\wSpeed", "2", 0);
  291. if (!get_cvar_num(CVAR_STEALTH) || (get_cvar_num(STEALTHCOST) > userMoney) || (!get_cvar_num(CVAR_MULTI) && g_haveability[id]))
  292. menu_additem(menu, "\dStealth", "3", 0);
  293. else
  294. menu_additem(menu, "\wStealth", "3", 0);
  295. if (!get_cvar_num(CVAR_GLASSES) || (get_cvar_num(GLASSESCOST) > userMoney) || (!get_cvar_num(CVAR_MULTI) && g_haveability[id]))
  296. menu_additem(menu, "\dAnti-flash glasses", "4", 0);
  297. else
  298. menu_additem(menu, "\wAnti-flash glasses", "4", 0);
  299. if (!get_cvar_num(CVAR_MULTIJUMP) || (get_cvar_num(MULTIJUMPCOST) > userMoney) || (!get_cvar_num(CVAR_MULTI) && g_haveability[id]))
  300. menu_additem(menu, "\dMulti jump", "5", 0);
  301. else
  302. menu_additem(menu, "\wMulti jump", "5", 0);
  303. if (!get_cvar_num(CVAR_BUNNYHOP) || (get_cvar_num(BUNNYHOPCOST) > userMoney) || (!get_cvar_num(CVAR_MULTI) && g_haveability[id]))
  304. menu_additem(menu, "\dBunny hop", "6", 0);
  305. else
  306. menu_additem(menu, "\wBunny hop", "6", 0);
  307. if (!get_cvar_num(CVAR_HEALTH) || (get_cvar_num(HEALTHCOST) > userMoney) || (!get_cvar_num(CVAR_MULTI) && g_haveability[id]))
  308. menu_additem(menu, "\dHealth and Armor", "7", 0);
  309. else
  310. menu_additem(menu, "\wHealth and Armor", "7", 0);
  311.  
  312. menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);
  313. menu_display(id, menu, 0);
  314. }
  315.  
  316. public buy_handler(id, menu, item)
  317. {
  318. if (item == MENU_EXIT)
  319. {
  320. menu_destroy(menu);
  321. startpage(id);
  322.  
  323. return PLUGIN_HANDLED;
  324. }
  325.  
  326. new data[6], iName[64];
  327. new access, callback;
  328. menu_item_getinfo(menu, item, access, data, 5, iName, 63, callback);
  329.  
  330. new key = str_to_num(data);
  331.  
  332. switch(key)
  333. {
  334. case 1:
  335. {
  336. if (!get_cvar_num(CVAR_GRAVITY))
  337. {
  338. client_print(id, print_chat, "[Purchase Mod]: Sorry, %s is not allowed!", g_szAbilities[0]);
  339. client_cmd(id,"spk purchasemod/sorry");
  340. if (get_cvar_num(CVAR_STAYOPEN))
  341. buypage(id);
  342. return PLUGIN_CONTINUE;
  343. }
  344. if (g_havegravity[id])
  345. {
  346. client_print(id, print_chat, "[Purchase Mod]: You already purchased %s!", g_szAbilities[0]);
  347. client_cmd(id,"spk purchasemod/sorry");
  348. if (get_cvar_num(CVAR_STAYOPEN))
  349. buypage(id);
  350. return PLUGIN_CONTINUE;
  351. }
  352. if (!get_cvar_num(CVAR_MULTI) && g_haveability[id])
  353. {
  354. client_print(id, print_chat, "[Purchase Mod]: You already purchased a different skill!");
  355. client_cmd(id,"spk purchasemod/sorry");
  356. if (get_cvar_num(CVAR_STAYOPEN))
  357. buypage(id);
  358. return PLUGIN_CONTINUE;
  359. }
  360. new userMoney = zp_get_user_ammo_packs(id);
  361. if(get_cvar_num(GRAVITYCOST) > userMoney)
  362. {
  363. client_print(id, print_chat, "[Purchase Mod]: You have insufficient funds!");
  364. client_cmd(id,"spk purchasemod/sorry");
  365. if (get_cvar_num(CVAR_STAYOPEN))
  366. buypage(id);
  367. return PLUGIN_CONTINUE;
  368. }
  369. else
  370.  
  371. zp_set_user_ammo_packs(id, (userMoney - get_cvar_num(GRAVITYCOST)));
  372. client_cmd(id,"spk purchasemod/buy");
  373. client_print(id, print_chat, "[Purchase Mod]: You purchased %s for $%d!", g_szAbilities[0], get_cvar_num(GRAVITYCOST));
  374. g_havegravity[id] = 1;
  375. g_haveability[id] = 1;
  376. g_roundsgravity[id] = get_cvar_num(CVAR_ROUNDS) - 1;
  377. set_user_gravity(id, get_cvar_float(PLAYERGRAVITY)/800);
  378. if (get_cvar_num(CVAR_STAYOPEN))
  379. buypage(id);
  380. }
  381. case 2:
  382. {
  383. if (!get_cvar_num(CVAR_SPEED))
  384. {
  385. client_print(id, print_chat, "[Purchase Mod]: Sorry, %s is not allowed!", g_szAbilities[1]);
  386. client_cmd(id,"spk purchasemod/sorry");
  387. if (get_cvar_num(CVAR_STAYOPEN))
  388. buypage(id);
  389. return PLUGIN_CONTINUE;
  390. }
  391. if (g_havespeed[id])
  392. {
  393. client_print(id, print_chat, "[Purchase Mod]: You already purchased %s!", g_szAbilities[1]);
  394. client_cmd(id,"spk purchasemod/sorry");
  395. if (get_cvar_num(CVAR_STAYOPEN))
  396. buypage(id);
  397. return PLUGIN_CONTINUE;
  398. }
  399. if (!get_cvar_num(CVAR_MULTI) && g_haveability[id])
  400. {
  401. client_print(id, print_chat, "[Purchase Mod]: You already purchased a different skill!");
  402. client_cmd(id,"spk purchasemod/sorry");
  403. if (get_cvar_num(CVAR_STAYOPEN))
  404. buypage(id);
  405. return PLUGIN_CONTINUE;
  406. }
  407. new userMoney = zp_get_user_ammo_packs(id);
  408. if(get_cvar_num(SPEEDCOST) > userMoney)
  409. {
  410. client_print(id, print_chat, "[Purchase Mod]: You have insufficient funds!");
  411. client_cmd(id,"spk purchasemod/sorry");
  412. if (get_cvar_num(CVAR_STAYOPEN))
  413. buypage(id);
  414. return PLUGIN_CONTINUE;
  415. }
  416. else
  417. {
  418. zp_set_user_ammo_packs(id, (userMoney - get_cvar_num(SPEEDCOST)));
  419. client_cmd(id,"spk purchasemod/buy");
  420. client_print(id, print_chat, "[Purchase Mod]: You purchased %s for $%d!", g_szAbilities[1], get_cvar_num(SPEEDCOST));
  421. g_havespeed[id] = 1;
  422. g_haveability[id] = 1;
  423. g_roundsspeed[id] = get_cvar_num(CVAR_ROUNDS) - 1;
  424. set_user_maxspeed(id, get_cvar_float(PLAYERSPEED));
  425. if (get_cvar_num(CVAR_STAYOPEN))
  426. buypage(id);
  427. }
  428. }
  429. case 3:
  430. {
  431. if (!get_cvar_num(CVAR_STEALTH))
  432. {
  433. client_print(id, print_chat, "[Purchase Mod]: Sorry, %s is not allowed!", g_szAbilities[2]);
  434. client_cmd(id,"spk purchasemod/sorry");
  435. if (get_cvar_num(CVAR_STAYOPEN))
  436. buypage(id);
  437. return PLUGIN_CONTINUE;
  438. }
  439. if (g_havestealth[id])
  440. {
  441. client_print(id, print_chat, "[Purchase Mod]: You already purchased %s!", g_szAbilities[2]);
  442. client_cmd(id,"spk purchasemod/sorry");
  443. if (get_cvar_num(CVAR_STAYOPEN))
  444. buypage(id);
  445. return PLUGIN_CONTINUE;
  446. }
  447. if (!get_cvar_num(CVAR_MULTI) && g_haveability[id])
  448. {
  449. client_print(id, print_chat, "[Purchase Mod]: You already purchased a different skill!");
  450. client_cmd(id,"spk purchasemod/sorry");
  451. if (get_cvar_num(CVAR_STAYOPEN))
  452. buypage(id);
  453. return PLUGIN_CONTINUE;
  454. }
  455. new userMoney = zp_get_user_ammo_packs(id);
  456. if(get_cvar_num(STEALTHCOST) > userMoney)
  457. {
  458. client_print(id, print_chat, "[Purchase Mod]: You have insufficient funds!");
  459. client_cmd(id,"spk purchasemod/sorry");
  460. if (get_cvar_num(CVAR_STAYOPEN))
  461. buypage(id);
  462. return PLUGIN_CONTINUE;
  463. }
  464. else
  465. {
  466. zp_set_user_ammo_packs(id, (userMoney - get_cvar_num(STEALTHCOST)));
  467. client_cmd(id,"spk purchasemod/buy");
  468. client_print(id, print_chat, "[Purchase Mod]: You purchased %s for $%d!", g_szAbilities[2], get_cvar_num(STEALTHCOST));
  469. g_havestealth[id] = 1;
  470. g_haveability[id] = 1;
  471. g_roundsstealth[id] = get_cvar_num(CVAR_ROUNDS) - 1;
  472. set_user_rendering(id, kRenderFxNone, 50, 50, 50, kRenderTransAdd, 50);
  473. set_user_footsteps(id, 1);
  474. if (get_cvar_num(CVAR_STAYOPEN))
  475. buypage(id);
  476. }
  477. }
  478. case 4:
  479. {
  480. if (!get_cvar_num(CVAR_GLASSES))
  481. {
  482. client_print(id, print_chat, "[Purchase Mod]: Sorry, %s is not allowed!", g_szAbilities[3]);
  483. client_cmd(id,"spk purchasemod/sorry");
  484. if (get_cvar_num(CVAR_STAYOPEN))
  485. buypage(id);
  486. return PLUGIN_CONTINUE;
  487. }
  488. if (g_haveglasses[id])
  489. {
  490. client_print(id, print_chat, "[Purchase Mod]: You already purchased %s!", g_szAbilities[3]);
  491. client_cmd(id,"spk purchasemod/sorry");
  492. if (get_cvar_num(CVAR_STAYOPEN))
  493. buypage(id);
  494. return PLUGIN_CONTINUE;
  495. }
  496. if (!get_cvar_num(CVAR_MULTI) && g_haveability[id])
  497. {
  498. client_print(id, print_chat, "[Purchase Mod]: You already purchased a different skill!");
  499. client_cmd(id,"spk purchasemod/sorry");
  500. if (get_cvar_num(CVAR_STAYOPEN))
  501. buypage(id);
  502. return PLUGIN_CONTINUE;
  503. }
  504. new userMoney = zp_get_user_ammo_packs(id);
  505. if(get_cvar_num(GLASSESCOST) > userMoney)
  506. {
  507. client_print(id, print_chat, "[Purchase Mod]: You have insufficient funds!");
  508. client_cmd(id,"spk purchasemod/sorry");
  509. if (get_cvar_num(CVAR_STAYOPEN))
  510. buypage(id);
  511. return PLUGIN_CONTINUE;
  512. }
  513. else
  514. {
  515. zp_set_user_ammo_packs(id, (userMoney - get_cvar_num(GLASSESCOST)));
  516. client_cmd(id,"spk purchasemod/buy");
  517. client_print(id, print_chat, "[Purchase Mod]: You purchased %s for $%d!", g_szAbilities[3], get_cvar_num(GLASSESCOST));
  518. g_haveglasses[id] = 1;
  519. g_haveability[id] = 1;
  520. g_roundsglasses[id] = get_cvar_num(CVAR_ROUNDS) - 1;
  521. event_blinded(id);
  522. if (get_cvar_num(CVAR_STAYOPEN))
  523. buypage(id);
  524. }
  525. }
  526. case 5:
  527. {
  528. if (!get_cvar_num(CVAR_MULTIJUMP))
  529. {
  530. client_print(id, print_chat, "[Purchase Mod]: Sorry, %s is not allowed!", g_szAbilities[4]);
  531. client_cmd(id,"spk purchasemod/sorry");
  532. if (get_cvar_num(CVAR_STAYOPEN))
  533. buypage(id);
  534. return PLUGIN_CONTINUE;
  535. }
  536. if (g_havemultijump[id])
  537. {
  538. client_print(id, print_chat, "[Purchase Mod]: You already purchased %s!", g_szAbilities[4]);
  539. client_cmd(id,"spk purchasemod/sorry");
  540. if (get_cvar_num(CVAR_STAYOPEN))
  541. buypage(id);
  542. return PLUGIN_CONTINUE;
  543. }
  544. if (!get_cvar_num(CVAR_MULTI) && g_haveability[id])
  545. {
  546. client_print(id, print_chat, "[Purchase Mod]: You already purchased a different skill!");
  547. client_cmd(id,"spk purchasemod/sorry");
  548. if (get_cvar_num(CVAR_STAYOPEN))
  549. buypage(id);
  550. return PLUGIN_CONTINUE;
  551. }
  552. new userMoney = zp_get_user_ammo_packs(id);
  553. if(get_cvar_num(MULTIJUMPCOST) > userMoney)
  554. {
  555. client_print(id, print_chat, "[Purchase Mod]: You have insufficient funds!");
  556. client_cmd(id,"spk purchasemod/sorry");
  557. if (get_cvar_num(CVAR_STAYOPEN))
  558. buypage(id);
  559. return PLUGIN_CONTINUE;
  560. }
  561. else
  562. {
  563. zp_set_user_ammo_packs(id, (userMoney - get_cvar_num(MULTIJUMPCOST)));
  564. client_cmd(id,"spk purchasemod/buy");
  565. client_print(id, print_chat, "[Purchase Mod]: You purchased %s for $%d!", g_szAbilities[4], get_cvar_num(MULTIJUMPCOST));
  566. g_havemultijump[id] = 1;
  567. g_haveability[id] = 1;
  568. g_roundsmultijump[id] = get_cvar_num(CVAR_ROUNDS) - 1;
  569. if (get_cvar_num(CVAR_STAYOPEN))
  570. buypage(id);
  571. }
  572. }
  573. case 6:
  574. {
  575. if (!get_cvar_num(CVAR_BUNNYHOP))
  576. {
  577. client_print(id, print_chat, "[Purchase Mod]: Sorry, %s is not allowed!", g_szAbilities[5]);
  578. client_cmd(id,"spk purchasemod/sorry");
  579. if (get_cvar_num(CVAR_STAYOPEN))
  580. buypage(id);
  581. return PLUGIN_CONTINUE;
  582. }
  583. if (g_havebunnyhop[id])
  584. {
  585. client_print(id, print_chat, "[Purchase Mod]: You already purchased %s!", g_szAbilities[5]);
  586. client_cmd(id,"spk purchasemod/sorry");
  587. if (get_cvar_num(CVAR_STAYOPEN))
  588. buypage(id);
  589. return PLUGIN_CONTINUE;
  590. }
  591. if (!get_cvar_num(CVAR_MULTI) && g_haveability[id])
  592. {
  593. client_print(id, print_chat, "[Purchase Mod]: You already purchased a different skill!");
  594. client_cmd(id,"spk purchasemod/sorry");
  595. if (get_cvar_num(CVAR_STAYOPEN))
  596. buypage(id);
  597. return PLUGIN_CONTINUE;
  598. }
  599. new userMoney = zp_get_user_ammo_packs(id);
  600. if(get_cvar_num(BUNNYHOPCOST) > userMoney)
  601. {
  602. client_print(id, print_chat, "[Purchase Mod]: You have insufficient funds!");
  603. client_cmd(id,"spk purchasemod/sorry");
  604. if (get_cvar_num(CVAR_STAYOPEN))
  605. buypage(id);
  606. return PLUGIN_CONTINUE;
  607. }
  608. else
  609. {
  610. zp_set_user_ammo_packs(id, (userMoney - get_cvar_num(BUNNYHOPCOST)));
  611. client_cmd(id,"spk purchasemod/buy");
  612. client_print(id, print_chat, "[Purchase Mod]: You purchased %s for $%d!", g_szAbilities[5], get_cvar_num(BUNNYHOPCOST));
  613. g_havebunnyhop[id] = 1;
  614. g_haveability[id] = 1;
  615. g_roundsbunnyhop[id] = get_cvar_num(CVAR_ROUNDS) - 1;
  616. if (get_cvar_num(CVAR_STAYOPEN))
  617. buypage(id);
  618. }
  619. }
  620. case 7:
  621. {
  622. if (!get_cvar_num(CVAR_HEALTH))
  623. {
  624. client_print(id, print_chat, "[Purchase Mod]: Sorry, %s is not allowed!", g_szAbilities[6]);
  625. client_cmd(id,"spk purchasemod/sorry");
  626. if (get_cvar_num(CVAR_STAYOPEN))
  627. buypage(id);
  628. return PLUGIN_CONTINUE;
  629. }
  630. if (g_havehealth[id])
  631. {
  632. client_print(id, print_chat, "[Purchase Mod]: You already purchased %s!", g_szAbilities[6]);
  633. client_cmd(id,"spk purchasemod/sorry");
  634. if (get_cvar_num(CVAR_STAYOPEN))
  635. buypage(id);
  636. return PLUGIN_CONTINUE;
  637. }
  638. if (!get_cvar_num(CVAR_MULTI) && g_haveability[id])
  639. {
  640. client_print(id, print_chat, "[Purchase Mod]: You already purchased a different skill!");
  641. client_cmd(id,"spk purchasemod/sorry");
  642. if (get_cvar_num(CVAR_STAYOPEN))
  643. buypage(id);
  644. return PLUGIN_CONTINUE;
  645. }
  646. new userMoney = zp_get_user_ammo_packs(id);
  647. if(get_cvar_num(HEALTHCOST) > userMoney)
  648. {
  649. client_print(id, print_chat, "[Purchase Mod]: You have insufficient funds!");
  650. client_cmd(id,"spk purchasemod/sorry");
  651. if (get_cvar_num(CVAR_STAYOPEN))
  652. buypage(id);
  653. return PLUGIN_CONTINUE;
  654. }
  655. else
  656. {
  657. zp_set_user_ammo_packs(id, (userMoney - get_cvar_num(HEALTHCOST)));
  658. client_cmd(id,"spk purchasemod/buy");
  659. client_print(id, print_chat, "[Purchase Mod]: You purchased %s for $%d!", g_szAbilities[6], get_cvar_num(HEALTHCOST));
  660. g_havehealth[id] = 1;
  661. g_haveability[id] = 1;
  662. g_roundshealth[id] = get_cvar_num(CVAR_ROUNDS) - 1;
  663. new health = get_cvar_num(PLAYERHEALTH);
  664. set_user_health(id, get_user_health(id) + health);
  665. set_user_armor(id, get_cvar_num(PLAYERARMOR));
  666. if (get_cvar_num(CVAR_STAYOPEN))
  667. buypage(id);
  668. }
  669. }
  670. }
  671. menu_destroy(menu);
  672.  
  673. return PLUGIN_HANDLED;
  674. }
  675.  
  676. public droppage(id)
  677. {
  678. new ratephrase[60]
  679. format(ratephrase, 59, "\wPurchase Mod: \rDrop Menu (%d percent)", get_cvar_num(CVAR_DROPRATE))
  680. new menu = menu_create(ratephrase, "drop_handler")
  681.  
  682. if (!g_havegravity[id])
  683. menu_additem(menu, "\dGravity", "1", 0);
  684. else
  685. menu_additem(menu, "\wGravity", "1", 0);
  686. if (!g_havespeed[id])
  687. menu_additem(menu, "\dSpeed", "2", 0);
  688. else
  689. menu_additem(menu, "\wSpeed", "2", 0);
  690. if (!g_havestealth[id])
  691. menu_additem(menu, "\dStealth", "3", 0);
  692. else
  693. menu_additem(menu, "\wStealth", "3", 0);
  694. if (!g_haveglasses[id])
  695. menu_additem(menu, "\dAnti-flash glasses", "4", 0);
  696. else
  697. menu_additem(menu, "\wAnti-flash glasses", "4", 0);
  698. if (!g_havemultijump[id])
  699. menu_additem(menu, "\dMulti jump", "5", 0);
  700. else
  701. menu_additem(menu, "\wMulti jump", "5", 0);
  702. if (!g_havebunnyhop[id])
  703. menu_additem(menu, "\dBunny hop", "6", 0);
  704. else
  705. menu_additem(menu, "\wBunny hop", "6", 0);
  706. if (!g_havehealth[id])
  707. menu_additem(menu, "\dHealth and Armor", "7", 0);
  708. else
  709. menu_additem(menu, "\wHealth and Armor", "7", 0);
  710.  
  711. menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);
  712. menu_display(id, menu, 0);
  713. }
  714.  
  715. public drop_handler(id, menu, item)
  716. {
  717. new gravity_drop = (get_cvar_num(GRAVITYCOST) * get_cvar_num(CVAR_DROPRATE) / 100);
  718. new speed_drop = (get_cvar_num(SPEEDCOST) * get_cvar_num(CVAR_DROPRATE) / 100);
  719. new stealth_drop = (get_cvar_num(STEALTHCOST) * get_cvar_num(CVAR_DROPRATE) / 100);
  720. new glasses_drop = (get_cvar_num(GLASSESCOST) * get_cvar_num(CVAR_DROPRATE) / 100);
  721. new multijump_drop = (get_cvar_num(MULTIJUMPCOST) * get_cvar_num(CVAR_DROPRATE) / 100);
  722. new bunnyhop_drop = (get_cvar_num(BUNNYHOPCOST) * get_cvar_num(CVAR_DROPRATE) / 100);
  723. new health_drop = (get_cvar_num(HEALTHCOST) * get_cvar_num(CVAR_DROPRATE) / 100);
  724.  
  725. if (item == MENU_EXIT)
  726. {
  727. menu_destroy(menu);
  728. startpage(id);
  729.  
  730. return PLUGIN_HANDLED;
  731. }
  732.  
  733. new data[6], iName[64];
  734. new access, callback;
  735. menu_item_getinfo(menu, item, access, data, 5, iName, 63, callback);
  736.  
  737. new key = str_to_num(data);
  738.  
  739. switch(key)
  740. {
  741. case 1:
  742. {
  743. if (!g_havegravity[id])
  744. {
  745. client_print(id, print_chat, "[Purchase Mod]: You don't have %s!", g_szAbilities[0]);
  746. client_cmd(id,"spk purchasemod/sorry");
  747. }
  748. else
  749. {
  750. new userMoney = zp_get_user_ammo_packs(id);
  751. zp_set_user_ammo_packs(id, (userMoney + gravity_drop));
  752. client_cmd(id,"spk purchasemod/drain");
  753. client_print(id, print_chat, "[Purchase Mod]: You dropped %s for $%d!", g_szAbilities[0], gravity_drop);
  754. g_havegravity[id] = 0;
  755. g_roundsgravity[id] = 0;
  756. set_user_gravity(id, 1.0);
  757. abilitycheck(id);
  758. }
  759. }
  760. case 2:
  761. {
  762. if (!g_havespeed[id])
  763. {
  764. client_print(id, print_chat, "[Purchase Mod]: You don't have %s!", g_szAbilities[1]);
  765. client_cmd(id,"spk purchasemod/sorry");
  766. }
  767. else
  768. {
  769. new userMoney = zp_get_user_ammo_packs(id);
  770. zp_set_user_ammo_packs(id, (userMoney + speed_drop));
  771. client_cmd(id,"spk purchasemod/drain");
  772. client_print(id, print_chat, "[Purchase Mod]: You dropped %s for $%d!", g_szAbilities[1], speed_drop);
  773. g_havespeed[id] = 0;
  774. g_roundsspeed[id] = 0;
  775. set_user_maxspeed(id, 250.0);
  776. abilitycheck(id);
  777. }
  778. }
  779. case 3:
  780. {
  781. if(!g_havestealth[id])
  782. {
  783. client_print(id, print_chat, "[Purchase Mod]: You don't have %s!", g_szAbilities[2]);
  784. client_cmd(id,"spk purchasemod/sorry");
  785. }
  786. else
  787. {
  788. new userMoney = zp_get_user_ammo_packs(id);
  789. zp_set_user_ammo_packs(id, (userMoney + stealth_drop));
  790. client_cmd(id,"spk purchasemod/drain");
  791. client_print(id, print_chat, "[Purchase Mod]: You dropped %s for $%d!", g_szAbilities[2], stealth_drop);
  792. g_havestealth[id] = 0;
  793. g_roundsstealth[id] = 0;
  794. set_user_rendering(id,kRenderFxNone,255,255,255, kRenderNormal,16);
  795. set_user_footsteps(id,0);
  796. abilitycheck(id);
  797. }
  798. }
  799. case 4:
  800. {
  801. if(!g_haveglasses[id])
  802. {
  803. client_print(id, print_chat, "[Purchase Mod]: You don't have %s!", g_szAbilities[3]);
  804. client_cmd(id,"spk purchasemod/sorry");
  805. }
  806. else
  807. {
  808. new userMoney = zp_get_user_ammo_packs(id);
  809. zp_set_user_ammo_packs(id, (userMoney + glasses_drop));
  810. client_cmd(id,"spk purchasemod/drain");
  811. client_print(id, print_chat, "[Purchase Mod]: You dropped %s for $%d!", g_szAbilities[3], glasses_drop);
  812. g_haveglasses[id] = 0;
  813. g_roundsglasses[id] = 0;
  814. event_blinded(id);
  815. abilitycheck(id);
  816. }
  817. }
  818. case 5:
  819. {
  820. if(!g_havemultijump[id])
  821. {
  822. client_print(id, print_chat, "[Purchase Mod]: You don't have %s!", g_szAbilities[4]);
  823. client_cmd(id,"spk purchasemod/sorry");
  824. }
  825. else
  826. {
  827. new userMoney = zp_get_user_ammo_packs(id);
  828. zp_set_user_ammo_packs(id, (userMoney + multijump_drop));
  829. client_cmd(id,"spk purchasemod/drain");
  830. client_print(id, print_chat, "[Purchase Mod]: You dropped %s for $%d!", g_szAbilities[4], multijump_drop);
  831. g_havemultijump[id] = 0;
  832. g_roundsmultijump[id] = 0;
  833. abilitycheck(id);
  834. }
  835. }
  836. case 6:
  837. {
  838. if(!g_havebunnyhop[id])
  839. {
  840. client_print(id, print_chat, "[Purchase Mod]: You don't have %s!", g_szAbilities[5]);
  841. client_cmd(id,"spk purchasemod/sorry");
  842. }
  843. else
  844. {
  845. new userMoney = zp_get_user_ammo_packs(id);
  846. zp_set_user_ammo_packs(id, (userMoney + bunnyhop_drop));
  847. client_cmd(id,"spk purchasemod/drain");
  848. client_print(id, print_chat, "[Purchase Mod]: You dropped %s for $%d!", g_szAbilities[5], bunnyhop_drop);
  849. g_havebunnyhop[id] = 0;
  850. g_roundsbunnyhop[id] = 0;
  851. abilitycheck(id);
  852. }
  853. }
  854. case 7:
  855. {
  856. if(!g_havehealth[id])
  857. {
  858. client_print(id, print_chat, "[Purchase Mod]: You don't have %s!", g_szAbilities[6]);
  859. client_cmd(id,"spk purchasemod/sorry");
  860. }
  861. else
  862. {
  863. new userMoney = zp_get_user_ammo_packs(id);
  864. zp_set_user_ammo_packs(id, (userMoney + health_drop));
  865. client_cmd(id,"spk purchasemod/drain");
  866. client_print(id, print_chat, "[Purchase Mod]: You dropped %s for $%d!", g_szAbilities[6], health_drop);
  867. g_havehealth[id] = 0;
  868. g_roundshealth[id] = 0;
  869. if (get_user_health(id) > 100)
  870. set_user_health(id, 100);
  871. if (get_user_armor(id) > 100)
  872. set_user_armor(id, 100);
  873. abilitycheck(id);
  874. }
  875. }
  876. }
  877. menu_destroy(menu);
  878.  
  879. if (get_cvar_num(CVAR_STAYOPEN))
  880. droppage(id);
  881. return PLUGIN_HANDLED;
  882. }
  883.  
  884. public client_PreThink(id)
  885. {
  886. if(g_havemultijump[id])
  887. {
  888. new nbut = get_user_button(id);
  889. new obut = get_user_oldbutton(id);
  890. if((nbut & IN_JUMP) && !(get_entity_flags(id) & FL_ONGROUND) && !(obut & IN_JUMP))
  891. {
  892. if(g_jumpnum[id] < get_cvar_num(MULTIJUMPNUMBER))
  893. {
  894. g_dojump[id] = true;
  895. g_jumpnum[id]++;
  896. return PLUGIN_CONTINUE;
  897. }
  898. }
  899. if((nbut & IN_JUMP) && (get_entity_flags(id) & FL_ONGROUND))
  900. g_jumpnum[id] = 0;
  901.  
  902. return PLUGIN_CONTINUE;
  903. }
  904. if(g_havebunnyhop[id])
  905. {
  906. entity_set_float(id, EV_FL_fuser2, 0.0);
  907.  
  908. if (entity_get_int(id, EV_INT_button) & 2)
  909. {
  910. new flags = entity_get_int(id, EV_INT_flags);
  911.  
  912. if (flags & FL_WATERJUMP)
  913. {
  914. return PLUGIN_CONTINUE;
  915. }
  916. if (entity_get_int(id, EV_INT_waterlevel) >= 2)
  917. {
  918. return PLUGIN_CONTINUE;
  919. }
  920. if(!(flags & FL_ONGROUND))
  921. {
  922. return PLUGIN_CONTINUE;
  923. }
  924.  
  925. new Float:velocity[3];
  926. entity_get_vector(id, EV_VEC_velocity, velocity);
  927. velocity[2] += 250.0;
  928. entity_set_vector(id, EV_VEC_velocity, velocity);
  929.  
  930. entity_set_int(id, EV_INT_gaitsequence, 6);
  931. }
  932. return PLUGIN_CONTINUE;
  933. }
  934. return PLUGIN_HANDLED;
  935. }
  936.  
  937. public client_PostThink(id)
  938. {
  939. if(g_dojump[id] == true && g_havemultijump[id])
  940. {
  941. new Float:velocity[3];
  942. entity_get_vector(id,EV_VEC_velocity,velocity);
  943. velocity[2] = random_float(265.0,285.0);
  944. entity_set_vector(id,EV_VEC_velocity,velocity);
  945. g_dojump[id] = false;
  946. return PLUGIN_CONTINUE;
  947. }
  948. return PLUGIN_CONTINUE;
  949. }
  950.  
  951. public speedb(id)
  952. {
  953. if(g_havespeed[id])
  954. set_user_maxspeed(id, get_cvar_float(PLAYERSPEED));
  955. return PLUGIN_HANDLED;
  956. }
  957.  
  958. public event_blinded(id)
  959. {
  960. if(g_haveglasses[id])
  961. {
  962. message_begin(MSG_ONE,g_msgscreenfade,{0,0,0},id);
  963. write_short(~0);
  964. write_short(0);
  965. write_short(1<<12);
  966. write_byte(0);
  967. write_byte(0);
  968. write_byte(0);
  969. write_byte(100);
  970. message_end();
  971. set_task(0.0,"event_blinded",id)
  972. }
  973. return PLUGIN_HANDLED;
  974. }
  975.  
  976. public roundchange(id)
  977. {
  978. if(g_haveability[id])
  979. strip(id);
  980.  
  981. return PLUGIN_HANDLED;
  982. }
  983.  
  984. public abilitycheck(id)
  985. {
  986. if(!g_havegravity[id] && !g_havespeed[id] && !g_havestealth[id] && !g_haveglasses[id] && !g_havemultijump[id] && !g_havebunnyhop[id] && !g_havehealth[id])
  987. g_haveability[id] = 0;
  988.  
  989. return PLUGIN_CONTINUE;
  990. }
  991. public strip(id)
  992. {
  993. new arg[32], name[32];
  994. read_argv(1, arg,31);
  995. new player = cmd_target(id,arg,4);
  996. get_user_name(player,name,31);
  997. if(g_havegravity[id])
  998. {
  999. if (!g_roundsgravity[id])
  1000. {
  1001. set_user_gravity(id, 1.0);
  1002. client_cmd(id,"spk purchasemod/drain");
  1003. client_print(id, print_chat, "[Purchase Mod]: Gravity set back to normal!");
  1004. g_havegravity[id] = 0;
  1005. }
  1006. if (g_roundsgravity[id] > 0)
  1007. {
  1008. client_print(id, print_chat, "[Purchase Mod]: %d round(s) left with %s", g_roundsgravity[id], g_szAbilities[0]);
  1009. g_roundsgravity[id]--;
  1010. set_user_gravity(id, get_cvar_float(PLAYERGRAVITY)/800);
  1011. }
  1012. }
  1013. if(g_havespeed[id])
  1014. {
  1015. if (!g_roundsspeed[id])
  1016. {
  1017. set_user_maxspeed(id, 250.0);
  1018. client_cmd(id,"spk purchasemod/drain");
  1019. client_print(id, print_chat, "[Purchase Mod]: Speed set back to normal!");
  1020. g_havespeed[id] = 0;
  1021. }
  1022. if (g_roundsspeed[id] > 0)
  1023. {
  1024. client_print(id, print_chat, "[Purchase Mod]: %d round(s) left with %s", g_roundsspeed[id], g_szAbilities[1]);
  1025. g_roundsspeed[id]--;
  1026. }
  1027. }
  1028. if(g_havestealth[id])
  1029. {
  1030. if (!g_roundsstealth[id])
  1031. {
  1032. set_user_rendering(id,kRenderFxNone,255,255,255, kRenderNormal,16);
  1033. set_user_footsteps(id,0);
  1034. client_cmd(id,"spk purchasemod/drain");
  1035. client_print(id, print_chat, "[Purchase Mod]: Stealth set to normal!");
  1036. g_havestealth[id] = 0;
  1037. }
  1038. if (g_roundsstealth[id] > 0)
  1039. {
  1040. client_print(id, print_chat, "[Purchase Mod]: %d round(s) left with %s", g_roundsstealth[id], g_szAbilities[2]);
  1041. g_roundsstealth[id]--;
  1042. }
  1043. }
  1044. if(g_haveglasses[id])
  1045. {
  1046. if (!g_roundsglasses[id])
  1047. {
  1048. client_print(id, print_chat, "[Purchase Mod]: Flash glasses broke!");
  1049. client_cmd(id,"spk purchasemod/drain");
  1050. g_haveglasses[id] = 0;
  1051. }
  1052. if (g_roundsglasses[id] > 0)
  1053. {
  1054. client_print(id, print_chat, "[Purchase Mod]: %d round(s) left with %s", g_roundsglasses[id], g_szAbilities[3]);
  1055. g_roundsglasses[id]--;
  1056. }
  1057. }
  1058. if(g_havemultijump[id])
  1059. {
  1060. if (!g_roundsmultijump[id])
  1061. {
  1062. client_print(id, print_chat, "[Purchase Mod]: Multi-Jump ran out!");
  1063. client_cmd(id,"spk purchasemod/drain");
  1064. g_havemultijump[id] = 0;
  1065. }
  1066. if (g_roundsmultijump[id] > 0)
  1067. {
  1068. client_print(id, print_chat, "[Purchase Mod]: %d round(s) left with %s", g_roundsmultijump[id], g_szAbilities[4]);
  1069. g_roundsmultijump[id]--;
  1070. }
  1071. }
  1072. if(g_havebunnyhop[id])
  1073. {
  1074. if (!g_roundsbunnyhop[id])
  1075. {
  1076. client_print(id, print_chat, "[Purchase Mod]: Bunny Hop ran out!");
  1077. client_cmd(id,"spk purchasemod/drain");
  1078. g_havebunnyhop[id] = 0;
  1079. }
  1080. if (g_roundsbunnyhop[id] > 0)
  1081. {
  1082. client_print(id, print_chat, "[Purchase Mod]: %d round(s) left with %s", g_roundsbunnyhop[id], g_szAbilities[5]);
  1083. g_roundsbunnyhop[id]--;
  1084. }
  1085. }
  1086. if(g_havehealth[id])
  1087. {
  1088. if (!g_roundshealth[id])
  1089. {
  1090. client_cmd(id,"spk purchasemod/drain");
  1091. set_user_health(id, 100);
  1092. if (get_user_armor(id) <= 100)
  1093. return PLUGIN_CONTINUE;
  1094. set_user_armor(id, 100);
  1095. g_havehealth[id] = 0;
  1096. }
  1097. if (g_roundshealth[id] > 0)
  1098. {
  1099. new health = get_cvar_num(PLAYERHEALTH);
  1100. client_print(id, print_chat, "[Purchase Mod]: %d round(s) left with extra %s", g_roundshealth[id], g_szAbilities[6]);
  1101. set_user_health(id, get_user_health(id) + health);
  1102. set_user_armor(id, get_cvar_num(PLAYERARMOR));
  1103. g_roundshealth[id]--;
  1104. }
  1105. }
  1106. abilitycheck(id);
  1107.  
  1108. return PLUGIN_HANDLED;
  1109. }
Advertisement
Add Comment
Please, Sign In to add comment