HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. /* AMX Mod X script.
  2. * *******************************************
  3. * Fordítás:
  4. * Bence98007
  5. *
  6. * http://www.amxmodx.crys.hu/
  7. *
  8. **********************************************
  9. * Drop AWP with Team Limit and Win limit v1.5 (CS & CS:CZ)
  10. * By SuicideDog & MattOG
  11. *
  12. * Modded orignal from JustinHoMi
  13. *
  14. *Up-To Version 0.5: ASpiRin
  15. *******************************************
  16. *
  17. *
  18. * VERSION: 1.0: MattOG
  19. **********************
  20. *
  21. * Combined all 3 plugins (g3sg1/sg550/awp limit) into one.
  22. * Added seperate commands to control Auto's and Awps. (different limits/rounds)
  23. * Fixed bug with old-style menu's still being able to buy guns. (Credit to bAnTAi, I used his Y.A.S.C. plugin to help with the code).
  24. *
  25. * I didn't make it stop bots:
  26. * 1. All bots come with built in weapon restrictions.
  27. * 2. Bots tend not to be AWP whores ;)
  28. *
  29. *
  30. * VERSION 1.1: MattOG
  31. *********************
  32. * Changed Maxawps/autos and winspreads to cvars to enable on-the-fly changing, and to allow changes to be set in server/amxx/map configs.
  33. *
  34. *
  35. * VERSION: 1.2: MattOG
  36. **********************
  37. *
  38. * Minor bug fix where old style menu's couldn't buy at all. (Thanks to Olie for pointing it out).
  39. *
  40. *
  41. * VERSION: 1.3: SuicideDog/DaSoul
  42. **********************
  43. *
  44. * Added DaSoul's code to allow it to work with PTB correctly
  45. *
  46. * VERSION: 1.4: KWo
  47. **********************
  48. *
  49. * Little bug fixes causing Run Time Errors etc...
  50. * Blocking pickup limited weapon
  51. * Bots are affected by this plugin, too but it doesn't prevent them from buying (they drop limited weapons after buying)
  52. * Optimized usage of cvars by using pcvar functions.
  53. *
  54. **********************
  55. *
  56. * VERSION: 1.5: KWo
  57. *
  58. * Added support for team balancing (if someone has an awp or auto sniper and get switched alive to the opposite team)
  59. *
  60. **********************
  61. *
  62. * VERSION: 1.52: KWo
  63. *
  64. * Added min_players setting (cvar) to allow awps/autos if at least min_players amount in each team is reached
  65. *
  66. **********************
  67. * CVARS:
  68. ***********
  69. *
  70. * max_awps <xx> - Maximum Awps Allowed
  71. * max_autos <xx> - Maximum Autos Allowed
  72. * winspread_awp <xx> - When This Many Rounds Ahead, No Awps Allowed
  73. * winspread_auto <xx> - When This Many Rounds Ahead, No Autos Allowed
  74. * min_players <xx> - Below this amount of players in team, awp/auto are completly restricted (no matter of max_awps and max_autos)
  75. * autolimit <1/0> - 1 = Restrict Auto, 0 = Don't
  76. * awplimit <1/0> - 1 = Restrict Awp, 0 = Don't
  77. * checkrebuy <1/0> - 1 = Prevent Rebuy Command, 0 = Don't
  78. *
  79. * TIPS:
  80. * To ALWAYS restrict to X number of awps/autos set winspread_awp/auto to 0 and max_awps/autos to however many awps/autos
  81. * To ONLY restrict after X number of rounds ahead, set max_awps/autos to 20 and winspread_awp/autos to however many rounds
  82. *
  83. * KNOWN BUG/ISSUES:
  84. ************
  85. * Updating the CVARS in game will only take effect after the following round has finished.
  86. * Bots can buy limitted weapon, but they drop it immediatelly after buying. They cannot pickup dropped limited weapons
  87. * (like human players), so it's not a big issue.
  88. *
  89. * TO DO:
  90. ********
  91. * Dunno, you tell me ;) Possibly will look at that following round thing, though it isn't too much hassle so I may not bother. You Decide.
  92. *
  93. */
  94.  
  95. #include <amxmodx>
  96. #include <fakemeta>
  97.  
  98. new plist[33] = { 0, ... } // 0 = no awp; 1 = carrying awp
  99. new plist2[33] = {0, ... } // 0 = no auto; 1 = carrying auto
  100. new awp_count[3] // 1 = T; 2 = CT
  101. new auto_count[3] // 1 = T; 2 = CT
  102. new ctscore = 0
  103. new tscore = 0
  104. new pl_team[33]
  105.  
  106. /* PCvars */
  107. new pv_awplimit
  108. new pv_max_awps
  109. new pv_winspread_awp
  110. new pv_autolimit
  111. new pv_max_autos
  112. new pv_winspread_auto
  113. new pv_checkrebuy
  114. new pv_minplayers
  115.  
  116. /* handles restricting the menu */
  117. public menu_awp(id,key)
  118. {
  119. if (get_pcvar_num(pv_awplimit) != 1) return PLUGIN_CONTINUE
  120.  
  121. new team = get_user_team(id)
  122. new winspread_awp = get_pcvar_num(pv_winspread_awp)
  123. new min_players = get_pcvar_num(pv_minplayers)
  124. new team1_num, team2_num
  125. new players[32]
  126.  
  127. get_players(players,team1_num,"e","TERRORIST")
  128. get_players(players,team2_num,"e","CT")
  129.  
  130. if ((team1_num < min_players) || (team2_num < min_players))
  131. {
  132. engclient_cmd(id,"menuselect","10")
  133. client_print(id,print_center,"Nincs eleg ember az egyik csapatban, nem tudod hasznalni az AWP-t!")
  134. return PLUGIN_HANDLED
  135. }
  136.  
  137. if (((team == 2 && ctscore-tscore >= winspread_awp) || (team == 1 && tscore-ctscore >= winspread_awp))
  138. && winspread_awp)
  139. {
  140. engclient_cmd(id,"menuselect","10")
  141. client_print(id,print_center,"Te a nyertes csapatban vagy, nem tudod hasznalni az AWP-t!")
  142. return PLUGIN_HANDLED
  143. }
  144.  
  145. if (awp_count[team] >= get_pcvar_num(pv_max_awps))
  146. {
  147. engclient_cmd(id,"menuselect","10")
  148. client_print(id,print_center,"A csapatodban tul sok AWP van!")
  149. return PLUGIN_HANDLED
  150. }
  151.  
  152. return PLUGIN_CONTINUE
  153. }
  154.  
  155. /* handles restricting the menu */
  156. public menu_auto(id,key)
  157. {
  158. if (get_pcvar_num(pv_autolimit) != 1) return PLUGIN_CONTINUE
  159.  
  160. new team = get_user_team(id)
  161. new winspread_auto = get_pcvar_num(pv_winspread_auto)
  162. new min_players = get_pcvar_num(pv_minplayers)
  163. new team1_num, team2_num
  164. new players[32]
  165.  
  166. get_players(players,team1_num,"e","TERRORIST")
  167. get_players(players,team2_num,"e","CT")
  168.  
  169. if ((team1_num < min_players) || (team2_num < min_players))
  170. {
  171. engclient_cmd(id,"menuselect","10")
  172. client_print(id,print_center,"Nincs eleg ember az egyik csapatban, nem tudod hasznalni a Magozot!")
  173. return PLUGIN_HANDLED
  174. }
  175.  
  176. if (((team == 2 && ctscore-tscore >= winspread_auto) || (team == 1 && tscore-ctscore >= winspread_auto))
  177. && winspread_auto)
  178. {
  179. engclient_cmd(id,"menuselect","10")
  180. client_print(id,print_center,"Te a nyertes csapatban vagy, nem tudod hasznalni a Magozot!")
  181. return PLUGIN_HANDLED
  182. }
  183.  
  184. if (auto_count[team] >= get_pcvar_num(pv_max_autos))
  185. {
  186. engclient_cmd(id,"menuselect","10")
  187. client_print(id,print_center,"A csapatodban tul sok Magozo van!")
  188. return PLUGIN_HANDLED
  189. }
  190.  
  191. return PLUGIN_CONTINUE
  192. }
  193.  
  194. /* handles if they script the AWP buy*/
  195. public cmdawp(id)
  196. {
  197. if (get_pcvar_num(pv_awplimit) != 1) return PLUGIN_CONTINUE
  198.  
  199. new team = get_user_team(id)
  200.  
  201. if ((team < 1) || (team > 2)) return PLUGIN_CONTINUE
  202.  
  203. new winspread_awp = get_pcvar_num(pv_winspread_awp)
  204. new name[32]
  205. get_user_name(id,name,31)
  206. new min_players = get_pcvar_num(pv_minplayers)
  207. new team1_num, team2_num
  208. new players[32]
  209.  
  210. get_players(players,team1_num,"e","TERRORIST")
  211. get_players(players,team2_num,"e","CT")
  212.  
  213. if ((team1_num < min_players) || (team2_num < min_players))
  214. {
  215. engclient_cmd(id,"menuselect","10")
  216. client_print(id,print_center,"Nincs eleg ember az egyik csapatban, nem tudod hasznalni az AWP-t!")
  217. return PLUGIN_HANDLED
  218. }
  219.  
  220. if (((team == 2 && ctscore-tscore >= winspread_awp) || (team == 1 && tscore-ctscore >= winspread_awp))
  221. && winspread_awp)
  222. {
  223. client_print(id,print_center,"Te a nyertes csapatban vagy, nem tudod hasznalni az AWP-t!")
  224. return PLUGIN_HANDLED
  225. }
  226.  
  227. if (awp_count[team] >= get_pcvar_num(pv_max_awps))
  228. {
  229. client_print(id,print_center,"A csapatodban tul sok AWP van!")
  230. // client_print(id,print_chat,"You are about to buy an awp. There was currently %d awps in Your team %d - too many to buy.", awp_count[team], team)
  231. // log_message("The player %s was about to buy an awp. There was %d awps in his team %d - too many to buy.", name, awp_count[team], team)
  232. return PLUGIN_HANDLED
  233. }
  234. // client_print(id,print_chat,"You are about to buy an awp. There was currently %d awps in Your team before You bought it.", awp_count[team])
  235. // log_message("The player %s is about to buy an awp. There was %d awps in his team %d before he bought it.", name, awp_count[team], team)
  236.  
  237. return PLUGIN_CONTINUE
  238. }
  239.  
  240. /* handles if they script the AUTO buy*/
  241. public cmdauto(id)
  242. {
  243. if (get_pcvar_num(pv_autolimit) != 1) return PLUGIN_CONTINUE
  244.  
  245. new team = get_user_team(id)
  246. new winspread_auto = get_pcvar_num(pv_winspread_auto)
  247. new min_players = get_pcvar_num(pv_minplayers)
  248. new team1_num, team2_num
  249. new players[32]
  250.  
  251. get_players(players,team1_num,"e","TERRORIST")
  252. get_players(players,team2_num,"e","CT")
  253.  
  254. if ((team1_num < min_players) || (team2_num < min_players))
  255. {
  256. engclient_cmd(id,"menuselect","10")
  257. client_print(id,print_center,"Nincs eleg ember az egyik csapatban, nem tudod hasznalni a Magozot!")
  258. return PLUGIN_HANDLED
  259. }
  260.  
  261. if (((team == 2 && ctscore-tscore >= winspread_auto) || (team == 1 && tscore-ctscore >= winspread_auto))
  262. && winspread_auto)
  263. {
  264. client_print(id,print_center,"Te a nyertes csapatban vagy, nem tudod hasznalni a Magozot!")
  265. return PLUGIN_HANDLED
  266. }
  267.  
  268. if (auto_count[team] >= get_pcvar_num(pv_max_autos))
  269. {
  270. client_print(id,print_center,"A csapatodban tul sok Magozo van!")
  271. return PLUGIN_HANDLED
  272. }
  273. return PLUGIN_CONTINUE
  274. }
  275.  
  276. /* handles when a player drops his weapon */
  277. public handle_drop_weapon(id)
  278. {
  279. new tmp1,tmp2
  280. new curweapon = get_user_weapon(id,tmp1,tmp2)
  281. new team = get_user_team(id)
  282.  
  283. /* handles when a player drops their awp */
  284. if (curweapon == CSW_AWP)
  285. {
  286. if (get_pcvar_num(pv_awplimit) != 1)
  287. return PLUGIN_CONTINUE
  288.  
  289. if ((plist[id]==1) && (awp_count[team] > 0))
  290. awp_count[team]--
  291. plist[id] = 0
  292. return PLUGIN_CONTINUE
  293. }
  294. /* handles when a player drops his auto */
  295. else if ((curweapon == CSW_SG550) || (curweapon == CSW_G3SG1))
  296. {
  297. if (get_pcvar_num(pv_autolimit) != 1)
  298. return PLUGIN_CONTINUE
  299.  
  300. if ((plist2[id]==1) && (auto_count[team] > 0))
  301. auto_count[team]--
  302. plist2[id] = 0
  303. return PLUGIN_CONTINUE
  304. }
  305. return PLUGIN_CONTINUE
  306. }
  307.  
  308.  
  309. /* handles when a player picks up an awp */
  310. public handle_pickup_awp(id)
  311. {
  312. if (get_pcvar_num(pv_awplimit) != 1) return PLUGIN_CONTINUE
  313.  
  314. new team = get_user_team(id)
  315. new winspread_awp = get_pcvar_num(pv_winspread_awp)
  316. new name[32]
  317. get_user_name(id,name,31)
  318. new min_players = get_pcvar_num(pv_minplayers)
  319. new team1_num, team2_num
  320. new players[32]
  321.  
  322. get_players(players,team1_num,"e","TERRORIST")
  323. get_players(players,team2_num,"e","CT")
  324.  
  325. if ((team1_num < min_players) || (team2_num < min_players))
  326. {
  327. set_task(0.5, "drop_awp", id)
  328. client_print(id,print_center,"Nincs eleg ember az egyik csapatban, nem tudod hasznalni az AWP-t!")
  329. return PLUGIN_CONTINUE
  330. }
  331.  
  332. if (((team == 2 && ctscore-tscore >= winspread_awp) || (team == 1 && tscore-ctscore >= winspread_awp))
  333. && winspread_awp)
  334. {
  335. client_print(id,print_center,"Te a nyertes csapatban vagy, nem tudod hasznalni az AWP-t!")
  336. set_task(0.5, "drop_awp", id)
  337. return PLUGIN_CONTINUE
  338. }
  339.  
  340. if (awp_count[team] >= get_pcvar_num(pv_max_awps))
  341. {
  342. client_print(id,print_center,"A csapatodban tul sok AWP van!")
  343. // log_message("The player %s bought or picked-up an awp. There is %d awps in his %d team. He should drop it.", name, awp_count[team], team)
  344. set_task(0.5, "drop_awp", id)
  345. // engclient_cmd(id, "drop", "weapon_awp")
  346. // client_cmd(id,"weapon_awp;wait;wait;wait;drop")
  347. return PLUGIN_CONTINUE
  348. }
  349. else
  350. {
  351. plist[id] = 1
  352. awp_count[team]++
  353. // client_print(id,print_chat,"You have bought or picked-up an awp. There is %d awps in Your team.", awp_count[team])
  354. // log_message("The player %s bought or picked-up an awp. There is %d awps in his team %d.", name, awp_count[team], team)
  355. }
  356. return PLUGIN_CONTINUE
  357. }
  358.  
  359. public drop_awp(id)
  360. {
  361. new team
  362.  
  363. if (!is_user_connected(id)) return
  364.  
  365. engclient_cmd(id, "drop", "weapon_awp")
  366.  
  367. if (is_user_bot(id)) // we cannot hook when the bot drops his weapon
  368. {
  369. team = get_user_team(id)
  370. plist[id] = 0
  371. if (awp_count[team] > 0)
  372. awp_count[team]--
  373. }
  374. }
  375.  
  376. /* handles when a player picks up a g3sg1 */
  377. public handle_pickup_g3sg1(id)
  378. {
  379. if (get_pcvar_num(pv_autolimit) != 1) return PLUGIN_CONTINUE
  380.  
  381. new team = get_user_team(id)
  382. new winspread_auto = get_pcvar_num(pv_winspread_auto)
  383. new min_players = get_pcvar_num(pv_minplayers)
  384. new team1_num, team2_num
  385. new players[32]
  386.  
  387. get_players(players,team1_num,"e","TERRORIST")
  388. get_players(players,team2_num,"e","CT")
  389.  
  390. if ((team1_num < min_players) || (team2_num < min_players))
  391. {
  392. client_print(id,print_center,"Nincs eleg ember az egyik csapatban, nem tudod hasznalni a Magozot!")
  393. set_task(0.5, "drop_g3sg1", id)
  394. return PLUGIN_CONTINUE
  395. }
  396.  
  397. if (((team == 2 && ctscore-tscore >= winspread_auto) || (team == 1 && tscore-ctscore >= winspread_auto))
  398. && winspread_auto)
  399. {
  400. client_print(id,print_center,"Te a nyertes csapatban vagy, nem tudod hasznalni a Magozot!")
  401. set_task(0.5, "drop_g3sg1", id)
  402. return PLUGIN_CONTINUE
  403. }
  404.  
  405. if (auto_count[team] >= get_pcvar_num(pv_max_autos))
  406. {
  407. client_print(id,print_center,"A csapatodban tul sok Magozo van!")
  408. set_task(0.5, "drop_g3sg1", id)
  409. return PLUGIN_CONTINUE
  410. }
  411. else
  412. {
  413. plist2[id] = 1
  414. auto_count[team]++
  415. }
  416. return PLUGIN_CONTINUE
  417. }
  418.  
  419. public drop_g3sg1(id)
  420. {
  421. new team
  422.  
  423. if (!is_user_connected(id)) return
  424.  
  425. engclient_cmd(id, "drop", "weapon_g3sg1")
  426.  
  427. if (is_user_bot(id)) // we cannot hook when the bot drops his weapon
  428. {
  429. team = get_user_team(id)
  430. plist2[id] = 0
  431. if (auto_count[team] > 0)
  432. auto_count[team]--
  433. }
  434. }
  435.  
  436. /* handles when a player picks up a sg550 */
  437. public handle_pickup_sg550(id)
  438. {
  439. if (get_pcvar_num(pv_autolimit) != 1) return PLUGIN_CONTINUE
  440.  
  441. new team = get_user_team(id)
  442. new winspread_auto = get_pcvar_num(pv_winspread_auto)
  443. new min_players = get_pcvar_num(pv_minplayers)
  444. new team1_num, team2_num
  445. new players[32]
  446.  
  447. get_players(players,team1_num,"e","TERRORIST")
  448. get_players(players,team2_num,"e","CT")
  449.  
  450. if ((team1_num < min_players) || (team2_num < min_players))
  451. {
  452. client_print(id,print_center,"Nincs eleg ember az egyik csapatban, nem tudod hasznalni a Magozot!")
  453. set_task(0.5, "drop_sg550", id)
  454. return PLUGIN_CONTINUE
  455. }
  456.  
  457. if (((team == 2 && ctscore-tscore >= winspread_auto) || (team == 1 && tscore-ctscore >= winspread_auto))
  458. && winspread_auto)
  459. {
  460. client_print(id,print_center,"Te a nyertes csapatban vagy, nem tudod hasznalni a Magozot!")
  461. set_task(0.5, "drop_sg550", id)
  462. return PLUGIN_CONTINUE
  463. }
  464.  
  465. if (auto_count[team] >= get_pcvar_num(pv_max_autos))
  466. {
  467. client_print(id,print_center,"A csapatodban tul sok Magozo van!")
  468. set_task(0.5, "drop_sg550", id)
  469. return PLUGIN_CONTINUE
  470. }
  471. else
  472. {
  473. plist2[id] = 1
  474. auto_count[team]++
  475. }
  476. return PLUGIN_CONTINUE
  477. }
  478.  
  479. public drop_sg550(id)
  480. {
  481. new team
  482.  
  483. if (!is_user_connected(id)) return
  484.  
  485. engclient_cmd(id, "drop", "weapon_sg550")
  486.  
  487. if (is_user_bot(id)) // we cannot hook when the bot drops his weapon
  488. {
  489. team = get_user_team(id)
  490. plist2[id] = 0
  491. if (auto_count[team] > 0)
  492. auto_count[team]--
  493. }
  494. }
  495.  
  496. /* removes awp and auto when player dies */
  497. public handle_death()
  498. {
  499. if ((get_pcvar_num(pv_awplimit) != 1) && (get_pcvar_num(pv_autolimit) != 1))
  500. return PLUGIN_CONTINUE
  501.  
  502. new idx = read_data(2)
  503.  
  504. if (plist[idx] == 1)
  505. {
  506. new team = get_user_team(idx)
  507. if (awp_count[team] > 0)
  508. awp_count[team]--
  509. plist[idx] = 0
  510. }
  511. if (plist2[idx] == 1)
  512. {
  513. new team = get_user_team(idx)
  514. if (auto_count[team] > 0)
  515. auto_count[team]--
  516. plist2[idx] = 0
  517. }
  518. return PLUGIN_CONTINUE
  519. }
  520.  
  521. /* clear vars when player connects */
  522. public client_connect(id)
  523. {
  524. plist[id] = 0
  525. plist2[id] = 0
  526. return PLUGIN_CONTINUE
  527. }
  528.  
  529. /* clear vars when player disconnects */
  530. public client_disconnect(id)
  531. {
  532. if (plist[id] == 1)
  533. {
  534. new team = get_user_team(id)
  535. if (awp_count[team] > 0)
  536. awp_count[team]--
  537. }
  538. if (plist2[id] == 1)
  539. {
  540. new team = get_user_team(id)
  541. if (auto_count[team] > 0)
  542. auto_count[team]--
  543. }
  544. plist[id] = 0
  545. plist2[id] = 0
  546.  
  547. return PLUGIN_CONTINUE
  548. }
  549.  
  550. public team_score()
  551. {
  552. if ((get_pcvar_num(pv_awplimit) != 1) && (get_pcvar_num(pv_autolimit) != 1))
  553. return PLUGIN_CONTINUE
  554.  
  555. new team[32]
  556. read_data(1,team,32)
  557.  
  558. if (equal(team,"CT"))
  559. {
  560. ctscore = read_data(2)
  561. }
  562. else if (equal(team,"TERRORIST"))
  563. {
  564. tscore = read_data(2)
  565. }
  566. return PLUGIN_CONTINUE
  567. }
  568.  
  569. public check_winning_team(id)
  570. {
  571. if ((get_pcvar_num(pv_awplimit) != 1) && (get_pcvar_num(pv_autolimit) != 1)) return PLUGIN_CONTINUE
  572. if (!id || id > get_maxplayers()) return PLUGIN_CONTINUE
  573.  
  574. new team = get_user_team(id)
  575. if (plist[id] == 1)
  576. {
  577. new winspread_awp = get_pcvar_num(pv_winspread_awp)
  578. if (((team == 2 && ctscore-tscore >= winspread_awp) || (team == 1 && tscore-ctscore >= winspread_awp))
  579. && winspread_awp)
  580. {
  581. client_print(id,print_center,"Te a nyertes csapatban vagy, nem tudod hasznalni az AWP-t!")
  582. engclient_cmd(id, "drop", "weapon_awp")
  583. return PLUGIN_CONTINUE
  584. }
  585. return PLUGIN_CONTINUE
  586. }
  587. if (plist2[id] == 1)
  588. {
  589. new winspread_auto = get_pcvar_num(pv_winspread_auto)
  590. if (((team == 2 && ctscore-tscore >= winspread_auto) || (team == 1 && tscore-ctscore >= winspread_auto))
  591. && winspread_auto)
  592. {
  593. client_print(id,print_center,"Te a nyertes csapatban vagy, nem tudod hasznalni a Magozot!")
  594. new iwpn, iwpns[32], nwpn[32]
  595. get_user_weapons(id, iwpns, iwpn)
  596. for (new a = 0; a < iwpn; ++a)
  597. {
  598. get_weaponname(iwpns[a], nwpn, 31)
  599. if (equali(nwpn,"weapon_g3sg1") || equali(nwpn,"weapon_sg550"))
  600. engclient_cmd(id, "drop", nwpn)
  601. }
  602. return PLUGIN_CONTINUE
  603. }
  604. return PLUGIN_CONTINUE
  605. }
  606. return PLUGIN_CONTINUE
  607. }
  608.  
  609.  
  610. /*
  611. * 1 = T's: AWP Key 4, AUTOSNIPER Key 5
  612. * 2 = CT's: AWP Key 5, AUTOSNIPER Key 4
  613. */
  614. public via_me(id,key)
  615. {
  616. new team = get_user_team(id)
  617.  
  618. if ((team==1 && key==5) || (team==2 && key==4))
  619. menu_auto(id, key)
  620. if ((team==1 && key==4) || (team==2 && key==5))
  621. menu_awp(id, key)
  622.  
  623. return PLUGIN_CONTINUE
  624. }
  625.  
  626. public check_rebuy(id)
  627. {
  628. if (get_pcvar_num(pv_checkrebuy) != 1) return PLUGIN_CONTINUE
  629. client_print(id,print_center,"Ujravasarlas tiltva van ezen a szerveren!")
  630.  
  631. return PLUGIN_HANDLED
  632. }
  633.  
  634. public total_snipers()
  635. {
  636. new players[32], numPlayerCount, idxPlayer
  637.  
  638. // 1 = T; 2 = CT
  639. awp_count[1] = 0
  640. auto_count[1] = 0
  641.  
  642. get_players(players, numPlayerCount,"he","TERRORIST")
  643. for(idxPlayer = 0; idxPlayer < numPlayerCount; idxPlayer++)
  644. {
  645. new Weapons[32]
  646. new numWeapons, i
  647. get_user_weapons(players[idxPlayer], Weapons, numWeapons)
  648. plist[players[idxPlayer]] = 0
  649. plist2[players[idxPlayer]] = 0
  650. for (i=0; i<numWeapons; i++)
  651. {
  652. if (Weapons[i] == CSW_AWP)
  653. {
  654. plist[players[idxPlayer]] = 1
  655. awp_count[1]++
  656. }
  657. if ((Weapons[i] == CSW_G3SG1) || (Weapons[i] == CSW_SG550))
  658. {
  659. plist2[players[idxPlayer]] = 1
  660. auto_count[1]++
  661. }
  662. }
  663. }
  664.  
  665. awp_count[2] = 0
  666. auto_count[2] = 0
  667.  
  668. get_players(players, numPlayerCount,"he","CT")
  669. for(idxPlayer = 0; idxPlayer < numPlayerCount; idxPlayer++)
  670. {
  671. new Weapons[32]
  672. new numWeapons, i
  673. get_user_weapons(players[idxPlayer], Weapons, numWeapons)
  674. plist[players[idxPlayer]] = 0
  675. plist2[players[idxPlayer]] = 0
  676. for (i=0; i<numWeapons; i++)
  677. {
  678. if (Weapons[i] == CSW_AWP)
  679. {
  680. plist[players[idxPlayer]] = 1
  681. awp_count[2]++
  682. }
  683. if ((Weapons[i] == CSW_G3SG1) || (Weapons[i] == CSW_SG550))
  684. {
  685. plist2[players[idxPlayer]] = 1
  686. auto_count[2]++
  687. }
  688. }
  689. }
  690. }
  691.  
  692. public round_start()
  693. {
  694. total_snipers()
  695. return PLUGIN_CONTINUE
  696. }
  697.  
  698. public hook_touch(ptr, ptd)
  699. {
  700. static ptrClass[32]
  701. static ptdClass[32]
  702. static ptrModel[128]
  703. static team
  704. static min_players
  705. static team1_num, team2_num
  706. static players[32]
  707. static winspread_auto
  708.  
  709. if ((get_pcvar_num(pv_awplimit) != 1) && (get_pcvar_num(pv_autolimit) != 1))
  710. return PLUGIN_CONTINUE
  711.  
  712. if (ptd > get_maxplayers() || ptd < 1 || ptr < 1 )
  713. return PLUGIN_CONTINUE
  714.  
  715. if ( (!pev_valid(ptr)) || (!pev_valid(ptd)) )
  716. return PLUGIN_CONTINUE
  717.  
  718. if (!is_user_connected(ptd))
  719. return PLUGIN_CONTINUE
  720.  
  721. pev(ptr, pev_classname, ptrClass, 31)
  722. pev(ptr, pev_model, ptrModel, 127)
  723. pev(ptd, pev_classname, ptdClass, 31)
  724.  
  725. if (!equal(ptrClass, "weaponbox"))
  726. return PLUGIN_CONTINUE
  727.  
  728. if (equal(ptdClass, "player"))
  729. {
  730. team = get_user_team(ptd)
  731. min_players = get_pcvar_num(pv_minplayers)
  732. get_players(players,team1_num,"e","TERRORIST")
  733. get_players(players,team2_num,"e","CT")
  734.  
  735. if (equal(ptrModel, "models/w_awp.mdl"))
  736. {
  737. if ((team1_num < min_players) || (team2_num < min_players))
  738. {
  739. client_print(ptd,print_center,"Nincs eleg ember az egyik csapatban, nem tudod hasznalni az AWP-t!")
  740. return FMRES_SUPERCEDE
  741. }
  742.  
  743. if (awp_count[team] >= get_pcvar_num(pv_max_awps))
  744. {
  745. client_print(ptd,print_center,"A csapatodban tul sok AWP van!")
  746. return FMRES_SUPERCEDE
  747. }
  748.  
  749. new winspread_awp = get_pcvar_num(pv_winspread_awp)
  750. if (((team == 2 && ctscore-tscore >= winspread_awp) || (team == 1 && tscore-ctscore >= winspread_awp))
  751. && winspread_awp)
  752. {
  753. client_print(ptd,print_center,"Te a nyertes csapatban vagy, nem tudod hasznalni az AWP-t!")
  754. return FMRES_SUPERCEDE
  755. }
  756.  
  757. return PLUGIN_CONTINUE
  758. }
  759. if ((equal(ptrModel, "models/w_g3sg1.mdl")) || (equal(ptrModel, "models/w_sg550.mdl")))
  760. {
  761. if ((team1_num < min_players) || (team2_num < min_players))
  762. {
  763. client_print(ptd,print_center,"Nincs eleg ember az egyik csapatban, nem tudod hasznalni a Magozot!")
  764. return FMRES_SUPERCEDE
  765. }
  766.  
  767. if (auto_count[team] >= get_pcvar_num(pv_max_autos))
  768. {
  769. client_print(ptd,print_center,"A csapatodban tul sok Magozo van!")
  770. return FMRES_SUPERCEDE
  771. }
  772.  
  773. winspread_auto = get_pcvar_num(pv_winspread_auto)
  774. if (((team == 2 && ctscore-tscore >= winspread_auto) || (team == 1 && tscore-ctscore >= winspread_auto))
  775. && winspread_auto)
  776. {
  777. client_print(ptd,print_center,"Te a nyertes csapatban vagy, nem tudod hasznalni a Magozot!")
  778. return FMRES_SUPERCEDE
  779. }
  780. return PLUGIN_CONTINUE
  781. }
  782. }
  783. return PLUGIN_CONTINUE
  784. }
  785.  
  786. public team_assign()
  787. {
  788. new arg[2], team
  789. new id = read_data(1)
  790. read_data(2,arg,1)
  791. if ( arg[0] == 'C' )
  792. team = 2
  793. else if ( arg[0] == 'T' )
  794. team = 1
  795. else
  796. team = 0
  797.  
  798. if (!is_user_connected(id) || !is_user_alive(id) || (!plist[id] && !plist2[id])
  799. || (pl_team[id] == team))
  800. {
  801. pl_team[id] = team
  802. return PLUGIN_CONTINUE
  803. }
  804. pl_team[id] = team
  805. total_snipers()
  806. new name[32]
  807. get_user_name(id,name,31)
  808. /*
  809. if (plist[id])
  810.   {
  811. client_print(id,print_center,"You had an awp and got transferred alive to the new team.")
  812. log_message("The player %s with an awp changed the team alive. There is now %d awps for team 1 and %d for team 2.",
  813. name, awp_count[1], awp_count[2])
  814. }
  815. */
  816. return PLUGIN_CONTINUE
  817. }
  818.  
  819.  
  820. public plugin_init()
  821. {
  822. register_plugin("AWP/AUTO Limit Team/Win","1.52","SuicideDog/MattOG/DaSoul")
  823. register_menucmd(-31,(1<<4),"via_me" ) // T: AWP, CT: Sig SG-550 Sniper - VGUI
  824. register_menucmd(-31,(1<<5),"via_me" ) // CT: AWP, T: H&K G3SG-1 Sniper Rifle - VGUI
  825. register_menucmd(register_menuid("BuyRifle",1),(1<<4),"via_me" ) // T: AWP, CT: Sig SG-550 Sniper - STANDARD
  826. register_menucmd(register_menuid("BuyRifle",1),(1<<5),"via_me" ) // CT: AWP, T: H&K G3SG-1 Sniper Rifle - STANDARD
  827. register_clcmd("drop","handle_drop_weapon")
  828.  
  829. register_clcmd("awp","cmdawp")
  830. register_clcmd("magnum","cmdawp")
  831. register_clcmd("g3sg1","cmdauto")
  832. register_clcmd("d3au1","cmdauto")
  833. register_clcmd("sg550","cmdauto")
  834. register_clcmd("krieg550","cmdauto")
  835. register_clcmd("rebuy","check_rebuy")
  836.  
  837. pv_awplimit = register_cvar("awplimit","1")
  838. pv_autolimit = register_cvar("autolimit","1")
  839. pv_checkrebuy = register_cvar("checkrebuy","1")
  840. pv_max_awps = register_cvar("max_awps","2")
  841. pv_max_autos = register_cvar("max_autos","1")
  842. pv_minplayers = register_cvar("min_players","5")
  843. pv_winspread_awp = register_cvar("winspread_awp","3")
  844. pv_winspread_auto = register_cvar("winspread_auto","2")
  845.  
  846. register_event("TeamScore", "team_score", "a")
  847. register_event("TeamInfo","team_assign","a")
  848. register_event("WeapPickup","handle_pickup_awp","b","1=18")
  849. register_event("WeapPickup","handle_pickup_sg550","b","1=13")
  850. register_event("WeapPickup","handle_pickup_g3sg1","b","1=24")
  851. register_event("DeathMsg","handle_death","a")
  852.  
  853. register_event("ResetHUD","check_winning_team","b")
  854.  
  855. register_logevent("round_start", 2, "1=Round_Start")
  856. register_forward(FM_Touch, "hook_touch")
  857. }
  858. /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
  859. *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1046\\ f0\\ fs16 \n\\ par }
  860. */
  861.