hlmod.hu

Magyar Half-Life Mód közösség!
Pontos idő: 2024.05.23. 11:57



Jelenlévő felhasználók

Jelenleg 212 felhasználó van jelen :: 1 regisztrált, 0 rejtett és 211 vendég

A legtöbb felhasználó (1565 fő) 2020.11.21. 11:26-kor tartózkodott itt.

Regisztrált felhasználók: Bing [Bot] az elmúlt 5 percben aktív felhasználók alapján

Utoljára aktív
Ahhoz hogy lásd ki volt utoljára aktív, be kell jelentkezned.



Az oldal teljeskörű
használatához regisztrálj.

Regisztráció

Kereső


Új téma nyitása  Hozzászólás a témához  [ 3 hozzászólás ] 
Szerző Üzenet
 Hozzászólás témája: AWP LIMIT
HozzászólásElküldve: 2014.01.25. 19:48 
Offline
Nagyúr
Avatar

Csatlakozott: 2013.03.28. 20:32
Hozzászólások: 561
Megköszönt másnak: 59 alkalommal
Megköszönték neki: 56 alkalommal
Hello! Ezt valaki lefordítaná nekem?

SMA Forráskód: [ Mindet kijelol ]
  1.  
  2. * CVARS:
  3. *
  4. * max_awps <xx> - Maximum Awps Allowed
  5. * max_autos <xx> - Maximum Autos Allowed
  6. * winspread_awp <xx> - When This Many Rounds Ahead, No Awps Allowed
  7. * winspread_auto <xx> - When This Many Rounds Ahead, No Autos Allowed
  8. * min_players <xx> - Below this amount of players in team, awp/auto are completly restricted (no matter of max_awps and max_autos)
  9. * autolimit <1/0> - 1 = Restrict Auto, 0 = Don't
  10. * awplimit <1/0> - 1 = Restrict Awp, 0 = Don't
  11. * checkrebuy <1/0> - 1 = Prevent Rebuy Command, 0 = Don't
  12.  
  13. #include <amxmodx>
  14. #include <fakemeta>
  15.  
  16. #pragma dynamic 8192
  17.  
  18. new const PLUGINNAME[] = "AWP/AUTO Limit (Team/Win)"
  19. new const VERSION[] = "1.60"
  20. new const AUTHOR[] = "SD/MG/DS/KWo"
  21.  
  22. new plist[33] = { 0, ... } // 0 = no awp; 1 = carrying awp
  23. new plist2[33] = {0, ... } // 0 = no auto; 1 = carrying auto
  24. new awp_count[3] // 1 = T; 2 = CT
  25. new auto_count[3] // 1 = T; 2 = CT
  26. new ctscore = 0
  27. new tscore = 0
  28. new gl_maxplayers
  29.  
  30. /* PCvars */
  31. new pv_awplimit
  32. new pv_max_awps
  33. new pv_winspread_awp
  34. new pv_autolimit
  35. new pv_max_autos
  36. new pv_winspread_auto
  37. new pv_checkrebuy
  38. new pv_minplayers
  39.  
  40. /* handles restricting the menu */
  41. public menu_awp(id,key)
  42. {
  43. if (get_pcvar_num(pv_awplimit) != 1) return PLUGIN_CONTINUE
  44.  
  45. new team = get_user_team(id)
  46. new winspread_awp = get_pcvar_num(pv_winspread_awp)
  47. new min_players = get_pcvar_num(pv_minplayers)
  48. new team1_num, team2_num, score_dif
  49. new players[32]
  50.  
  51. get_players(players,team1_num,"e","TERRORIST")
  52. get_players(players,team2_num,"e","CT")
  53.  
  54. if ((team1_num < min_players) || (team2_num < min_players))
  55. {
  56. engclient_cmd(id,"menuselect","10")
  57. client_print(id,print_center,"Not enough people in one team to allow AWP's (Ts:%d, CTs:%d, MIN:%d).", team1_num, team2_num, min_players)
  58. return PLUGIN_HANDLED
  59. }
  60.  
  61. if (winspread_awp)
  62. {
  63. if (team == 2)
  64. score_dif = ctscore - tscore
  65. else if (team == 1)
  66. score_dif = tscore - ctscore
  67.  
  68. if (score_dif >= winspread_awp)
  69. {
  70. engclient_cmd(id,"menuselect","10")
  71. client_print(id,print_center,"You are on the winning team and cannot use AWP's (ScDif:%d, WsAWP:%d).", score_dif, winspread_awp)
  72. return PLUGIN_HANDLED
  73. }
  74. }
  75.  
  76. if (awp_count[team] >= get_pcvar_num(pv_max_awps))
  77. {
  78. engclient_cmd(id,"menuselect","10")
  79. client_print(id,print_center,"Too many people on your team have AWP's (%d/%d).", awp_count[team], get_pcvar_num(pv_max_awps))
  80. return PLUGIN_HANDLED
  81. }
  82.  
  83. return PLUGIN_CONTINUE
  84. }
  85.  
  86. /* handles restricting the menu */
  87. public menu_auto(id,key)
  88. {
  89. if (get_pcvar_num(pv_autolimit) != 1) return PLUGIN_CONTINUE
  90.  
  91. new team = get_user_team(id)
  92. new winspread_auto = get_pcvar_num(pv_winspread_auto)
  93. new min_players = get_pcvar_num(pv_minplayers)
  94. new team1_num, team2_num, score_dif
  95. new players[32]
  96.  
  97. get_players(players,team1_num,"e","TERRORIST")
  98. get_players(players,team2_num,"e","CT")
  99.  
  100. if ((team1_num < min_players) || (team2_num < min_players))
  101. {
  102. engclient_cmd(id,"menuselect","10")
  103. client_print(id,print_center,"Not enough people in one team to allow AUTO's (Ts:%d, CTs:%d, MIN:%d).", team1_num, team2_num, min_players)
  104. return PLUGIN_HANDLED
  105. }
  106.  
  107. if (winspread_auto)
  108. {
  109. if (team == 2)
  110. score_dif = ctscore - tscore
  111. else if (team == 1)
  112. score_dif = tscore - ctscore
  113.  
  114. if (score_dif >= winspread_auto)
  115. {
  116. engclient_cmd(id,"menuselect","10")
  117. client_print(id,print_center,"You are on the winning team and cannot use AUTO's (ScDif:%d, WsAuto:%d).", score_dif, winspread_auto)
  118. return PLUGIN_HANDLED
  119. }
  120. }
  121.  
  122. if (auto_count[team] >= get_pcvar_num(pv_max_autos))
  123. {
  124. engclient_cmd(id,"menuselect","10")
  125. client_print(id,print_center,"Too many people on your team have AUTO's (%d/%d).", auto_count[team], get_pcvar_num(pv_max_autos))
  126. return PLUGIN_HANDLED
  127. }
  128.  
  129. return PLUGIN_CONTINUE
  130. }
  131.  
  132. /* handles if they script the AWP buy*/
  133. public cmdawp(id)
  134. {
  135. if (get_pcvar_num(pv_awplimit) != 1) return PLUGIN_CONTINUE
  136.  
  137. new team = get_user_team(id)
  138.  
  139. if ((team < 1) || (team > 2)) return PLUGIN_CONTINUE
  140.  
  141. new winspread_awp = get_pcvar_num(pv_winspread_awp)
  142. new name[32]
  143. get_user_name(id,name,31)
  144. new min_players = get_pcvar_num(pv_minplayers)
  145. new team1_num, team2_num, score_dif
  146. new players[32]
  147.  
  148. get_players(players,team1_num,"e","TERRORIST")
  149. get_players(players,team2_num,"e","CT")
  150.  
  151. if ((team1_num < min_players) || (team2_num < min_players))
  152. {
  153. client_print(id,print_center,"Not enough people in one team to allow AWP's (Ts:%d, CTs:%d, MIN:%d).", team1_num, team2_num, min_players)
  154. return PLUGIN_HANDLED
  155. }
  156.  
  157. if (winspread_awp)
  158. {
  159. if (team == 2)
  160. score_dif = ctscore - tscore
  161. else if (team == 1)
  162. score_dif = tscore - ctscore
  163.  
  164. if (score_dif >= winspread_awp)
  165. {
  166. client_print(id,print_center,"You are on the winning team and cannot use AWP's (ScDif:%d, WsAWP:%d).", score_dif, winspread_awp)
  167. return PLUGIN_HANDLED
  168. }
  169. }
  170.  
  171. if (awp_count[team] >= get_pcvar_num(pv_max_awps))
  172. {
  173. client_print(id,print_center,"Too many people on your team have AWP's (%d/%d).", awp_count[team], get_pcvar_num(pv_max_awps))
  174. return PLUGIN_HANDLED
  175. }
  176.  
  177. return PLUGIN_CONTINUE
  178. }
  179.  
  180. /* handles if they script the AUTO buy*/
  181. public cmdauto(id)
  182. {
  183. if (get_pcvar_num(pv_autolimit) != 1) return PLUGIN_CONTINUE
  184.  
  185. new team = get_user_team(id)
  186. new winspread_auto = get_pcvar_num(pv_winspread_auto)
  187. new min_players = get_pcvar_num(pv_minplayers)
  188. new team1_num, team2_num, score_dif
  189. new players[32]
  190.  
  191. get_players(players,team1_num,"e","TERRORIST")
  192. get_players(players,team2_num,"e","CT")
  193.  
  194. if ((team1_num < min_players) || (team2_num < min_players))
  195. {
  196. client_print(id,print_center,"Not enough people in one team to allow AUTO's (Ts:%d, CTs:%d, MIN:%d).", team1_num, team2_num, min_players)
  197. return PLUGIN_HANDLED
  198. }
  199.  
  200. if (winspread_auto)
  201. {
  202. if (team == 2)
  203. score_dif = ctscore - tscore
  204. else if (team == 1)
  205. score_dif = tscore - ctscore
  206.  
  207. if (score_dif >= winspread_auto)
  208. {
  209. client_print(id,print_center,"You are on the winning team and cannot use AUTO's (ScDif:%d, WsAuto:%d).", score_dif, winspread_auto)
  210. return PLUGIN_HANDLED
  211. }
  212. }
  213.  
  214. if (auto_count[team] >= get_pcvar_num(pv_max_autos))
  215. {
  216. client_print(id,print_center,"Too many people on your team have AUTO's (%d/%d).", auto_count[team], get_pcvar_num(pv_max_autos))
  217. return PLUGIN_HANDLED
  218. }
  219. return PLUGIN_CONTINUE
  220. }
  221.  
  222.  
  223. /* handles when a player drops his weapon */
  224. public handle_drop_weapon(id)
  225. {
  226. if (!is_user_connected(id))
  227. return PLUGIN_CONTINUE
  228.  
  229. new tmp1,tmp2
  230. new curweapon = get_user_weapon(id,tmp1,tmp2)
  231. new team = get_user_team(id)
  232.  
  233. /* handles when a player drops their awp */
  234. if (curweapon == CSW_AWP)
  235. {
  236. if ((plist[id]==1) && (awp_count[team] > 0))
  237. awp_count[team]--
  238. plist[id] = 0
  239. return PLUGIN_CONTINUE
  240. }
  241. /* handles when a player drops his auto */
  242. else if ((curweapon == CSW_SG550) || (curweapon == CSW_G3SG1))
  243. {
  244. if ((plist2[id]==1) && (auto_count[team] > 0))
  245. auto_count[team]--
  246. plist2[id] = 0
  247. return PLUGIN_CONTINUE
  248. }
  249. return PLUGIN_CONTINUE
  250. }
  251.  
  252. public handle_pickup_weapon(id)
  253. {
  254. if (!is_user_connected(id) || !pev_valid(id))
  255. return PLUGIN_CONTINUE
  256.  
  257. new team = get_user_team(id)
  258. new wpflags = pev(id, pev_weapons)
  259.  
  260. new bool:awp_exists = false
  261. new bool:auto1_exists = false
  262. new bool:auto2_exists = false
  263.  
  264. if (wpflags & (1 << CSW_AWP))
  265. awp_exists = true
  266. if (wpflags & (1 << CSW_SG550))
  267. auto1_exists = true
  268. if (wpflags & (1 << CSW_G3SG1))
  269. auto2_exists = true
  270.  
  271. if ((!awp_exists) && (plist[id] == 1))
  272. {
  273. plist[id] = 0
  274. if (awp_count[team] > 0)
  275. awp_count[team]--
  276. }
  277. else if ((awp_exists) && (plist[id] != 1))
  278. {
  279. handle_pickup_awp(id)
  280. }
  281.  
  282. if ((!auto1_exists) && (!auto2_exists) && (plist2[id] == 1))
  283. {
  284. plist2[id] = 0
  285. if (auto_count[team] > 0)
  286. auto_count[team]--
  287. }
  288. else if ((auto1_exists) && (plist2[id] != 1))
  289. {
  290. handle_pickup_sg550(id)
  291. }
  292. else if ((auto2_exists) && (plist2[id] != 1))
  293. {
  294. handle_pickup_g3sg1(id)
  295. }
  296.  
  297. return PLUGIN_CONTINUE
  298. }
  299.  
  300. /* handles when a player picks up an awp */
  301. public handle_pickup_awp(id)
  302. {
  303. new team = get_user_team(id)
  304. new winspread_awp = get_pcvar_num(pv_winspread_awp)
  305. new name[32]
  306. get_user_name(id,name,31)
  307. new min_players = get_pcvar_num(pv_minplayers)
  308. new team1_num, team2_num, score_dif
  309. new players[32]
  310.  
  311. get_players(players,team1_num,"e","TERRORIST")
  312. get_players(players,team2_num,"e","CT")
  313.  
  314. if (get_pcvar_num(pv_awplimit) == 1)
  315. {
  316. if ((team1_num < min_players) || (team2_num < min_players))
  317. {
  318. set_task(0.5, "drop_awp", id)
  319. client_print(id,print_center,"Not enough people in one team to allow AWP's (Ts:%d, CTs:%d, MIN:%d).", team1_num, team2_num, min_players)
  320. return
  321. }
  322.  
  323. if (winspread_awp)
  324. {
  325. if (team == 2)
  326. score_dif = ctscore - tscore
  327. else if (team == 1)
  328. score_dif = tscore - ctscore
  329.  
  330. if (score_dif >= winspread_awp)
  331. {
  332. client_print(id,print_center,"You are on the winning team and cannot use AWP's (ScDif:%d, WsAWP:%d).", score_dif, winspread_awp)
  333. set_task(0.5, "drop_awp", id)
  334. return
  335. }
  336. }
  337.  
  338. if (awp_count[team] >= get_pcvar_num(pv_max_awps))
  339. {
  340. client_print(id,print_center,"Too many people on your team have AWP's (%d/%d).", awp_count[team], get_pcvar_num(pv_max_awps))
  341. set_task(0.5, "drop_awp", id)
  342. return
  343. }
  344. }
  345.  
  346. if (plist[id] != 1)
  347. {
  348. plist[id] = 1
  349. awp_count[team]++
  350. // client_print(id,print_chat,"You have bought or picked-up an awp. There is %d awps in Your team.", awp_count[team])
  351. // log_message("The player %s bought or picked-up an awp. There is %d awps in his team %d.", name, awp_count[team], team)
  352. }
  353. }
  354.  
  355. public drop_awp(id)
  356. {
  357. new team, wpflags
  358. if (is_user_alive(id))
  359. {
  360. wpflags = pev(id, pev_weapons)
  361. if (wpflags & (1 << CSW_AWP))
  362. {
  363. engclient_cmd(id, "drop", "weapon_awp")
  364.  
  365. if (plist[id] == 1)
  366. {
  367. team = get_user_team(id)
  368. if (awp_count[team] > 0)
  369. awp_count[team]--
  370. plist[id] = 0
  371. }
  372. }
  373. }
  374. }
  375.  
  376. /* handles when a player picks up a g3sg1 */
  377. public handle_pickup_g3sg1(id)
  378. {
  379. new team = get_user_team(id)
  380. new winspread_auto = get_pcvar_num(pv_winspread_auto)
  381. new min_players = get_pcvar_num(pv_minplayers)
  382. new team1_num, team2_num, score_dif
  383. new players[32]
  384.  
  385. get_players(players,team1_num,"e","TERRORIST")
  386. get_players(players,team2_num,"e","CT")
  387.  
  388. if (get_pcvar_num(pv_autolimit) == 1)
  389. {
  390. if ((team1_num < min_players) || (team2_num < min_players))
  391. {
  392. client_print(id,print_center,"Not enough people in one team to allow AUTO's (Ts:%d, CTs:%d, MIN:%d).", team1_num, team2_num, min_players)
  393. set_task(0.5, "drop_g3sg1", id)
  394. return
  395. }
  396.  
  397. if (winspread_auto)
  398. {
  399. if (team == 2)
  400. score_dif = ctscore - tscore
  401. else if (team == 1)
  402. score_dif = tscore - ctscore
  403.  
  404. if (score_dif >= winspread_auto)
  405. {
  406. client_print(id,print_center,"You are on the winning team and cannot use AUTO's (ScDif:%d, WsAuto:%d).", score_dif, winspread_auto)
  407. set_task(0.5, "drop_g3sg1", id)
  408. return
  409. }
  410. }
  411.  
  412. if (auto_count[team] >= get_pcvar_num(pv_max_autos))
  413. {
  414. client_print(id,print_center,"Too many people on your team have AUTO's (%d/%d).", auto_count[team], get_pcvar_num(pv_max_autos))
  415. set_task(0.5, "drop_g3sg1", id)
  416. return
  417. }
  418. }
  419.  
  420. if (plist2[id] != 1)
  421. {
  422. plist2[id] = 1
  423. auto_count[team]++
  424. }
  425. }
  426.  
  427. public drop_g3sg1(id)
  428. {
  429. new team, wpflags
  430. if (is_user_alive(id))
  431. {
  432. wpflags = pev(id, pev_weapons)
  433. if (wpflags & (1 << CSW_G3SG1))
  434. {
  435. engclient_cmd(id, "drop", "weapon_g3sg1")
  436.  
  437. if (plist2[id] == 1)
  438. {
  439. team = get_user_team(id)
  440. if (auto_count[team] > 0)
  441. auto_count[team]--
  442. plist2[id] = 0
  443. }
  444. }
  445. }
  446. }
  447.  
  448. /* handles when a player picks up a sg550 */
  449. public handle_pickup_sg550(id)
  450. {
  451. new team = get_user_team(id)
  452. new winspread_auto = get_pcvar_num(pv_winspread_auto)
  453. new min_players = get_pcvar_num(pv_minplayers)
  454. new team1_num, team2_num, score_dif
  455. new players[32]
  456.  
  457. get_players(players,team1_num,"e","TERRORIST")
  458. get_players(players,team2_num,"e","CT")
  459.  
  460. if (get_pcvar_num(pv_autolimit) == 1)
  461. {
  462. if ((team1_num < min_players) || (team2_num < min_players))
  463. {
  464. client_print(id,print_center,"Not enough people in one team to allow AUTO's (Ts:%d, CTs:%d, MIN:%d).", team1_num, team2_num, min_players)
  465. set_task(0.5, "drop_sg550", id)
  466. return
  467. }
  468.  
  469. if (winspread_auto)
  470. {
  471. if (team == 2)
  472. score_dif = ctscore - tscore
  473. else if (team == 1)
  474. score_dif = tscore - ctscore
  475.  
  476. if (score_dif >= winspread_auto)
  477. {
  478. client_print(id,print_center,"You are on the winning team and cannot use AUTO's (ScDif:%d, WsAuto:%d).", score_dif, winspread_auto)
  479. set_task(0.5, "drop_sg550", id)
  480. return
  481. }
  482. }
  483.  
  484.  
  485. if (auto_count[team] >= get_pcvar_num(pv_max_autos))
  486. {
  487. client_print(id,print_center,"Too many people on your team have AUTO's (%d/%d).", auto_count[team], get_pcvar_num(pv_max_autos))
  488. set_task(0.5, "drop_sg550", id)
  489. return
  490. }
  491. }
  492.  
  493. if (plist2[id] != 1)
  494. {
  495. plist2[id] = 1
  496. auto_count[team]++
  497. }
  498. }
  499.  
  500. public drop_sg550(id)
  501. {
  502. new team, wpflags
  503. if (is_user_alive(id))
  504. {
  505. wpflags = pev(id, pev_weapons)
  506. if (wpflags & (1 << CSW_SG550))
  507. {
  508. engclient_cmd(id, "drop", "weapon_sg550")
  509.  
  510. if (plist2[id] == 1)
  511. {
  512. team = get_user_team(id)
  513. if (auto_count[team] > 0)
  514. auto_count[team]--
  515. plist2[id] = 0
  516. }
  517. }
  518. }
  519. }
  520.  
  521. /* removes awp and auto when player dies */
  522. public handle_death()
  523. {
  524. if ((get_pcvar_num(pv_awplimit) != 1) && (get_pcvar_num(pv_autolimit) != 1))
  525. return PLUGIN_CONTINUE
  526.  
  527. new idx = read_data(2)
  528. if ((idx < 1) || (idx > gl_maxplayers))
  529. return PLUGIN_CONTINUE
  530.  
  531. if (plist[idx] == 1)
  532. {
  533. new team = get_user_team(idx)
  534. if (awp_count[team] > 0)
  535. awp_count[team]--
  536. plist[idx] = 0
  537. }
  538.  
  539. if (plist2[idx] == 1)
  540. {
  541. new team = get_user_team(idx)
  542. if (auto_count[team] > 0)
  543. auto_count[team]--
  544. plist2[idx] = 0
  545. }
  546.  
  547. return PLUGIN_CONTINUE
  548. }
  549.  
  550. /* clear vars when player connects */
  551. public client_connect(id)
  552. {
  553. if ((id > 0) && (id <= gl_maxplayers))
  554. {
  555. plist[id] = 0
  556. plist2[id] = 0
  557. }
  558. return PLUGIN_CONTINUE
  559. }
  560.  
  561. /* clear vars when player disconnects */
  562. public client_disconnect(id)
  563. {
  564. new team
  565. if ((id > 0) && (id <= gl_maxplayers))
  566. {
  567. if (plist[id] == 1)
  568. {
  569. team = get_user_team(id)
  570. if (awp_count[team] > 0)
  571. awp_count[team]--
  572. }
  573. if (plist2[id] == 1)
  574. {
  575. team = get_user_team(id)
  576. if (auto_count[team] > 0)
  577. auto_count[team]--
  578. }
  579. plist[id] = 0
  580. plist2[id] = 0
  581. }
  582. return PLUGIN_CONTINUE
  583. }
  584.  
  585. public team_score()
  586. {
  587. if ((get_pcvar_num(pv_awplimit) != 1) && (get_pcvar_num(pv_autolimit) != 1))
  588. return PLUGIN_CONTINUE
  589.  
  590. new team[32]
  591. read_data(1,team,32)
  592.  
  593. if (equal(team,"CT"))
  594. {
  595. ctscore = read_data(2)
  596. }
  597. else if (equal(team,"TERRORIST"))
  598. {
  599. tscore = read_data(2)
  600. }
  601. return PLUGIN_CONTINUE
  602. }
  603.  
  604. public check_winning_team(id)
  605. {
  606. if ((get_pcvar_num(pv_awplimit) != 1) && (get_pcvar_num(pv_autolimit) != 1)) return PLUGIN_CONTINUE
  607. if ((id < 1) || (id > gl_maxplayers)) return PLUGIN_CONTINUE
  608. if (!is_user_alive(id)) return PLUGIN_CONTINUE
  609.  
  610. new team = get_user_team(id)
  611. new winspread_awp = get_pcvar_num(pv_winspread_awp)
  612. new winspread_auto = get_pcvar_num(pv_winspread_auto)
  613. new wpflags, score_dif
  614.  
  615. if (plist[id] == 1)
  616. {
  617. if (winspread_awp)
  618. {
  619. if (team == 2)
  620. score_dif = ctscore - tscore
  621. else if (team == 1)
  622. score_dif = tscore - ctscore
  623.  
  624. if (score_dif >= winspread_awp)
  625. {
  626. client_print(id,print_center,"You are on the winning team and cannot use AWP's (ScDif:%d, WsAWP:%d).", score_dif, winspread_awp)
  627.  
  628. engclient_cmd(id, "drop", "weapon_awp")
  629. plist[id] = 0
  630. if (awp_count[team] > 0)
  631. awp_count[team]--
  632. }
  633. }
  634. }
  635. if (plist2[id] == 1)
  636. {
  637. if (winspread_auto)
  638. {
  639. if (team == 2)
  640. score_dif = ctscore - tscore
  641. else if (team == 1)
  642. score_dif = tscore - ctscore
  643.  
  644. if (score_dif >= winspread_auto)
  645. {
  646. client_print(id,print_center,"You are on the winning team and cannot use AUTO's (ScDif:%d, WsAuto:%d).", score_dif, winspread_auto)
  647. wpflags = pev(id, pev_weapons)
  648. if (wpflags & (1 << CSW_SG550))
  649. {
  650. engclient_cmd(id, "drop", "weapon_sg550")
  651. plist2[id] = 0
  652. if (auto_count[team] > 0)
  653. auto_count[team]--
  654. }
  655. if (wpflags & (1 << CSW_G3SG1))
  656. {
  657. engclient_cmd(id, "drop", "weapon_g3sg1")
  658. plist2[id] = 0
  659. if (auto_count[team] > 0)
  660. auto_count[team]--
  661. }
  662. }
  663. }
  664. }
  665. return PLUGIN_CONTINUE
  666. }
  667.  
  668. /*
  669. * 1 = T's: AWP Key 4, AUTOSNIPER Key 5
  670. * 2 = CT's: AWP Key 5, AUTOSNIPER Key 4
  671. */
  672. public via_me(id,key)
  673. {
  674. new team = get_user_team(id)
  675.  
  676. if ((team==1 && key==5) || (team==2 && key==4))
  677. menu_auto(id, key)
  678. if ((team==1 && key==4) || (team==2 && key==5))
  679. menu_awp(id, key)
  680.  
  681. return PLUGIN_CONTINUE
  682. }
  683.  
  684. public check_rebuy(id)
  685. {
  686. if (get_pcvar_num(pv_checkrebuy) != 1) return PLUGIN_CONTINUE
  687. client_print(id,print_center,"Sorry Rebuy command is blocked on this server")
  688.  
  689. return PLUGIN_HANDLED
  690. }
  691.  
  692. public total_snipers()
  693. {
  694. new players[32], numPlayerCount, idxPlayer, id, wpflags
  695.  
  696. // 1 = T; 2 = CT
  697. awp_count[1] = 0
  698. auto_count[1] = 0
  699.  
  700. get_players(players, numPlayerCount,"he","TERRORIST")
  701. for(idxPlayer = 0; idxPlayer < numPlayerCount; idxPlayer++)
  702. {
  703. id = players[idxPlayer]
  704.  
  705. if (!is_user_alive(id)) continue
  706. if (!pev_valid(id)) continue
  707.  
  708. wpflags = pev(id, pev_weapons)
  709.  
  710. plist[id] = 0
  711. plist2[id] = 0
  712.  
  713. if (wpflags & (1 << CSW_AWP))
  714. {
  715. plist[id] = 1
  716. awp_count[1]++
  717. }
  718. if ((wpflags & (1 << CSW_SG550)) || (wpflags & (1 << CSW_G3SG1)))
  719. {
  720. plist2[id] = 1
  721. auto_count[1]++
  722. }
  723. }
  724.  
  725. awp_count[2] = 0
  726. auto_count[2] = 0
  727.  
  728. get_players(players, numPlayerCount,"he","CT")
  729. for(idxPlayer = 0; idxPlayer < numPlayerCount; idxPlayer++)
  730. {
  731. id = players[idxPlayer]
  732.  
  733. if (!is_user_alive(id)) continue
  734. if (!pev_valid(id)) continue
  735.  
  736. plist[id] = 0
  737. plist2[id] = 0
  738.  
  739. if (wpflags & (1 << CSW_AWP))
  740. {
  741. plist[id] = 1
  742. awp_count[2]++
  743. }
  744. if ((wpflags & (1 << CSW_SG550)) || (wpflags & (1 << CSW_G3SG1)))
  745. {
  746. plist2[id] = 1
  747. auto_count[2]++
  748. }
  749. }
  750. }
  751.  
  752. public round_start()
  753. {
  754. total_snipers()
  755. }
  756.  
  757. public hook_touch(ptr, ptd)
  758. {
  759. static ptrClass[32]
  760. static ptdClass[32]
  761. static ptrModel[128]
  762. static team
  763. static min_players
  764. static team1_num, team2_num, score_dif
  765. static players[32]
  766. static winspread_awp
  767. static winspread_auto
  768. static wpflags
  769.  
  770. if ((get_pcvar_num(pv_awplimit) != 1) && (get_pcvar_num(pv_autolimit) != 1))
  771. return PLUGIN_CONTINUE
  772.  
  773. if (ptd > gl_maxplayers || ptd < 1 || ptr < 1 )
  774. return PLUGIN_CONTINUE
  775.  
  776. if ( (!pev_valid(ptr)) || (!pev_valid(ptd)) )
  777. return PLUGIN_CONTINUE
  778.  
  779. if (!is_user_connected(ptd))
  780. return PLUGIN_CONTINUE
  781.  
  782. pev(ptr, pev_classname, ptrClass, 31)
  783. pev(ptr, pev_model, ptrModel, 127)
  784. pev(ptd, pev_classname, ptdClass, 31)
  785.  
  786. if ((!equal(ptrClass, "weaponbox")) && (!equal(ptrClass, "armoury_entity"))
  787. && (!equal(ptrClass, "csdmw_",6)))
  788. return PLUGIN_CONTINUE
  789.  
  790. if (equal(ptdClass, "player"))
  791. {
  792. team = get_user_team(ptd)
  793. min_players = get_pcvar_num(pv_minplayers)
  794. get_players(players,team1_num,"e","TERRORIST")
  795. get_players(players,team2_num,"e","CT")
  796. wpflags = pev(ptd, pev_weapons)
  797.  
  798. if ((equal(ptrModel, "models/w_awp.mdl")) && (get_pcvar_num(pv_awplimit) == 1))
  799. {
  800. if (!(wpflags & (1 << CSW_AWP)))
  801. {
  802. if ((team1_num < min_players) || (team2_num < min_players))
  803. {
  804. client_print(ptd,print_center,"Not enough people in one team to allow AWP's (Ts:%d, CTs:%d, MIN:%d).", team1_num, team2_num, min_players)
  805. return FMRES_SUPERCEDE
  806. }
  807.  
  808. if (awp_count[team] >= get_pcvar_num(pv_max_awps))
  809. {
  810. client_print(ptd,print_center,"Too many people on your team have AWP's (%d/%d).", awp_count[team], get_pcvar_num(pv_max_awps))
  811. return FMRES_SUPERCEDE
  812. }
  813.  
  814. winspread_awp = get_pcvar_num(pv_winspread_awp)
  815. if (winspread_awp)
  816. {
  817. score_dif = 0
  818. if (team == 2)
  819. score_dif = ctscore - tscore
  820. else if (team == 1)
  821. score_dif = tscore - ctscore
  822.  
  823. if (score_dif >= winspread_awp)
  824. {
  825. client_print(ptd,print_center,"You are on the winning team and cannot use AWP's (ScDif:%d, WsAWP:%d).", score_dif, winspread_awp)
  826. return FMRES_SUPERCEDE
  827. }
  828. }
  829. }
  830. return PLUGIN_CONTINUE
  831. }
  832.  
  833. if (((equal(ptrModel, "models/w_g3sg1.mdl")) || (equal(ptrModel, "models/w_sg550.mdl")))
  834. && (get_pcvar_num(pv_autolimit) == 1))
  835. {
  836. if (!(wpflags & (1 << CSW_SG550)) && !(wpflags & (1 << CSW_SG550)))
  837. {
  838. if ((team1_num < min_players) || (team2_num < min_players))
  839. {
  840. client_print(ptd,print_center,"Not enough people in one team to allow AUTO's (Ts:%d, CTs:%d, MIN:%d).", team1_num, team2_num, min_players)
  841. return FMRES_SUPERCEDE
  842. }
  843.  
  844. if (auto_count[team] >= get_pcvar_num(pv_max_autos))
  845. {
  846. client_print(ptd,print_center,"Too many people on your team have AUTO's (%d/%d).", auto_count[team], get_pcvar_num(pv_max_autos))
  847. return FMRES_SUPERCEDE
  848. }
  849.  
  850. winspread_auto = get_pcvar_num(pv_winspread_auto)
  851. if (winspread_auto)
  852. {
  853. score_dif = 0
  854. if (team == 2)
  855. score_dif = ctscore - tscore
  856. else if (team == 1)
  857. score_dif = tscore - ctscore
  858.  
  859. if (score_dif >= winspread_auto)
  860. {
  861. client_print(ptd,print_center,"You are on the winning team and cannot use AUTO's (ScDif:%d, WsAuto:%d).", score_dif, winspread_auto)
  862. return FMRES_SUPERCEDE
  863. }
  864. }
  865. }
  866. return PLUGIN_CONTINUE
  867. }
  868. }
  869. return PLUGIN_CONTINUE
  870. }
  871.  
  872. public team_assign()
  873. {
  874. new id = read_data(1)
  875. if ((id < 1) || (id > gl_maxplayers))
  876. return PLUGIN_CONTINUE
  877. if (!is_user_connected(id) || !is_user_alive(id) || (!plist[id] && !plist2[id]))
  878. return PLUGIN_CONTINUE
  879.  
  880. total_snipers()
  881.  
  882. return PLUGIN_CONTINUE
  883. }
  884.  
  885. public plugin_init()
  886. {
  887. register_plugin(PLUGINNAME,VERSION,AUTHOR)
  888. register_menucmd(-31,(1<<4),"via_me" ) // T: AWP, CT: Sig SG-550 Sniper - VGUI
  889. register_menucmd(-31,(1<<5),"via_me" ) // CT: AWP, T: H&K G3SG-1 Sniper Rifle - VGUI
  890. register_menucmd(register_menuid("BuyRifle",1),(1<<4),"via_me" ) // T: AWP, CT: Sig SG-550 Sniper - STANDARD
  891. register_menucmd(register_menuid("BuyRifle",1),(1<<5),"via_me" ) // CT: AWP, T: H&K G3SG-1 Sniper Rifle - STANDARD
  892. register_clcmd("drop","handle_drop_weapon")
  893.  
  894. register_clcmd("awp","cmdawp")
  895. register_clcmd("magnum","cmdawp")
  896. register_clcmd("g3sg1","cmdauto")
  897. register_clcmd("d3au1","cmdauto")
  898. register_clcmd("sg550","cmdauto")
  899. register_clcmd("krieg550","cmdauto")
  900. register_clcmd("rebuy","check_rebuy")
  901.  
  902. pv_awplimit = register_cvar("awplimit","1")
  903. pv_autolimit = register_cvar("autolimit","1")
  904. pv_checkrebuy = register_cvar("checkrebuy","1")
  905. pv_max_awps = register_cvar("max_awps","2")
  906. pv_max_autos = register_cvar("max_autos","1")
  907. pv_minplayers = register_cvar("min_players","5")
  908. pv_winspread_awp = register_cvar("winspread_awp","3")
  909. pv_winspread_auto = register_cvar("winspread_auto","2")
  910.  
  911. register_event("TeamScore", "team_score", "a")
  912. register_event("TeamInfo","team_assign","a")
  913. register_event("WeapPickup","handle_pickup_weapon","b")
  914. register_event("DeathMsg","handle_death","a")
  915.  
  916. register_event("ResetHUD","check_winning_team","be")
  917.  
  918. register_logevent("round_start", 2, "1=Round_Start")
  919. register_forward(FM_Touch, "hook_touch")
  920. gl_maxplayers = get_maxplayers()
  921. }

_________________
Kép

[steam]alfaaaa[/steam]


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: AWP LIMIT
HozzászólásElküldve: 2014.01.29. 15:16 
Offline
Tud valamit

Csatlakozott: 2012.04.16. 22:32
Hozzászólások: 104
Megköszönt másnak: 14 alkalommal
Megköszönték neki: 10 alkalommal
Csak a cvarokat?

_________________
Ha segítettem: Kép

Kép


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: AWP LIMIT
HozzászólásElküldve: 2014.01.29. 18:20 
Offline
Tiszteletbeli
Avatar

Csatlakozott: 2011.08.15. 14:42
Hozzászólások: 1345
Megköszönt másnak: 10 alkalommal
Megköszönték neki: 277 alkalommal
Itt van: viewsma.php?f=13787-sniperlimit.sma

_________________
Üdvözlettel: BBk
[AmxModX] Általam fordított pluginok
Death of Legend Fun Server History
NetMozi.com - Filmes fórum Badboy.killer
foximaxi


Hozzászólás jelentése
Vissza a tetejére
   
Hozzászólások megjelenítése:  Rendezés  
Új téma nyitása  Hozzászólás a témához  [ 3 hozzászólás ] 


Ki van itt

Jelenlévő fórumozók: nincs regisztrált felhasználó valamint 6 vendég


Nyithatsz új témákat ebben a fórumban.
Válaszolhatsz egy témára ebben a fórumban.
Nem szerkesztheted a hozzászólásaidat ebben a fórumban.
Nem törölheted a hozzászólásaidat ebben a fórumban.
Nem küldhetsz csatolmányokat ebben a fórumban.

Keresés:
Ugrás:  
Powered by phpBB® Forum Software © phpBB Limited
Magyar fordítás © Magyar phpBB Közösség
Portal: Kiss Portal Extension © Michael O'Toole