HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. /**
  2.  * csdm_equip.sma
  3.  * Allows for Counter-Strike to be played as DeathMatch.
  4.  *
  5.  * CSDM Equipment Menu
  6.  *
  7.  * By Freecode and BAILOPAN
  8.  * (C)2003-2006 David "BAILOPAN" Anderson
  9.  *
  10.  * Give credit where due.
  11.  * Share the source - it sets you free
  12.  * http://www.opensource.org/
  13.  * http://www.gnu.org/
  14.  */
  15.  
  16. #include <amxmodx>
  17. #include <amxmisc>
  18. #include <cstrike>
  19. #include <csdm>
  20. #include <fakemeta>
  21.  
  22. //Tampering with the author and name lines can violate the copyright
  23. new PLUGINNAME[] = "CSDM Equip"
  24. new VERSION[] = CSDM_VERSION
  25. new AUTHORS[] = "CSDM Team"
  26.  
  27. #define EQUIP_PRI (1<<0)
  28. #define EQUIP_SEC (1<<1)
  29. #define EQUIP_ARMOR (1<<2)
  30. #define EQUIP_GREN (1<<3)
  31. #define EQUIP_ITEMS (1<<4)
  32. #define EQUIP_ALL (EQUIP_PRI|EQUIP_SEC|EQUIP_ARMOR|EQUIP_GREN|EQUIP_ITEMS)
  33.  
  34. //Menus
  35. new g_SecMenu[] = "CSDM: Másodlagos fegyverek" // Menu Name
  36. new g_SecMenuID = -1 // Menu ID
  37. new g_cSecondary // Menu Callback
  38. new bool:g_mSecStatus = true // Menu Available?
  39.  
  40. new g_PrimMenu[] = "CSDM: Elsõdleges fegyverek"
  41. new g_PrimMenuID = -1
  42. new g_cPrimary
  43. new bool:g_mPrimStatus = true
  44.  
  45. new g_ArmorMenu[] = "CSDM: Pajzs"
  46. new g_ArmorMenuID = -1
  47. new bool:g_mArmorStatus = true
  48.  
  49. new g_NadeMenu[] = "CSDM: Gránátok"
  50. new g_NadeMenuID = -1
  51. new bool:g_mNadeStatus = true
  52.  
  53. new g_EquipMenu[] = "CSDM: Felszerelés"
  54. new g_EquipMenuID = -1
  55.  
  56. new bool:g_mShowuser[33] = true
  57.  
  58. new bool:g_mAutoNades = false
  59. new bool:g_mAutoArmor = false
  60.  
  61. //Weapon Selections
  62. new g_SecWeapons[33][18]
  63. new g_PrimWeapons[33][18]
  64. new bool:g_mNades[33]
  65. new bool:g_mArmor[33]
  66.  
  67. //Config weapon storage holders
  68. new g_BotPrim[MAX_WEAPONS][18]
  69. new g_iNumBotPrim
  70.  
  71. new g_BotSec[MAX_WEAPONS][18]
  72. new g_iNumBotSec
  73.  
  74. new g_Secondary[MAX_SECONDARY][18]
  75. new bool:g_DisabledSec[MAX_WEAPONS]
  76. new g_iNumSec
  77.  
  78. new g_Primary[MAX_PRIMARY][18]
  79. new bool:g_DisabledPrim[MAX_WEAPONS]
  80. new g_iNumPrim
  81.  
  82. #define SILENCED_M4A1 0
  83. #define SILENCED_USP 1
  84. new bool:g_Silenced[33][2]
  85.  
  86. //Misc
  87. new g_Armor = 0
  88. new fnadesnum = 0
  89. new bool:g_Flash = false
  90. new bool:g_Nade = false
  91. new bool:g_Smoke = false
  92. new bool:g_NightVision = false
  93. new bool:g_DefuseKit = false
  94.  
  95. //Quick Fix for menu pages
  96. new g_MenuState[33] = {0}
  97.  
  98. public csdm_Init(const version[])
  99. {
  100. if (version[0] == 0)
  101. {
  102. set_fail_state("CSDM failed to load.")
  103. return
  104. }
  105.  
  106. // Menus and callbacks
  107. g_SecMenuID = menu_create(g_SecMenu, "m_SecHandler", 0)
  108. g_PrimMenuID = menu_create(g_PrimMenu, "m_PrimHandler", 0)
  109. g_ArmorMenuID = menu_create(g_ArmorMenu, "m_ArmorHandler", 0)
  110. g_NadeMenuID = menu_create(g_NadeMenu, "m_NadeHandler", 0)
  111. g_EquipMenuID = menu_create(g_EquipMenu, "m_EquipHandler", 0)
  112.  
  113. menu_setprop(g_PrimMenuID, MPROP_EXIT, MEXIT_NEVER)
  114. menu_setprop(g_SecMenuID, MPROP_EXIT, MEXIT_NEVER)
  115.  
  116. g_cSecondary = menu_makecallback("c_Secondary")
  117. g_cPrimary = menu_makecallback("c_Primary")
  118. }
  119.  
  120. public csdm_CfgInit()
  121. {
  122. // Config reader
  123. csdm_reg_cfg("equip", "cfgSetting")
  124. // In order for weapon menu
  125. csdm_reg_cfg("secondary", "cfgSecondary")
  126. csdm_reg_cfg("primary", "cfgPrimary")
  127. csdm_reg_cfg("botprimary", "cfgBotPrim")
  128. csdm_reg_cfg("botsecondary", "cfgBotSec")
  129. }
  130.  
  131. public plugin_init()
  132. {
  133. register_plugin(PLUGINNAME, VERSION, AUTHORS)
  134.  
  135. // Build Armor/Nade/Equip Menu's
  136. buildMenu()
  137.  
  138. register_clcmd("say guns", "enableMenu")
  139. register_clcmd("say /guns", "enableMenu")
  140. register_clcmd("say menu", "enableMenu")
  141. register_clcmd("say enablemenu", "enableMenu")
  142. register_clcmd("say enable_menu", "enableMenu")
  143. }
  144.  
  145. public client_connect(id)
  146. {
  147. g_mShowuser[id] = true
  148. g_mNades[id] = false
  149. g_mArmor[id] = false
  150. g_Silenced[id][SILENCED_M4A1] = false
  151. g_Silenced[id][SILENCED_USP] = false
  152.  
  153. return PLUGIN_CONTINUE
  154. }
  155.  
  156. public client_disconnect(id)
  157. {
  158. g_mShowuser[id] = true
  159. g_mNades[id] = false
  160. g_mArmor[id] = false
  161.  
  162. return PLUGIN_CONTINUE
  163. }
  164.  
  165. public csdm_RemoveWeapon(owner, entity_id, boxed_id)
  166. {
  167. new classname[32], weapon
  168. pev(entity_id, pev_classname, classname, 31)
  169. weapon = get_weaponid(classname)
  170. if (weapon == CSW_M4A1)
  171. {
  172. g_Silenced[owner][SILENCED_M4A1] = cs_get_weapon_silen(entity_id) ? true : false
  173. } else if (weapon == CSW_USP) {
  174. g_Silenced[owner][SILENCED_USP] = cs_get_weapon_silen(entity_id) ? true : false
  175. }
  176.  
  177. return PLUGIN_CONTINUE
  178. }
  179.  
  180. public csdm_PostDeath(killer, victim, headshot, const weapon[])
  181. {
  182. /* Clean up any defusal kits we might have made! */
  183. if (!g_DefuseKit)
  184. {
  185. return
  186. }
  187.  
  188. /* This might have a race condition for team switches... */
  189. if (cs_get_user_team(victim) == CS_TEAM_CT)
  190. {
  191. cs_set_user_defuse(victim, 0)
  192. }
  193. }
  194.  
  195. public cfgSecondary(readAction, line[], section[])
  196. {
  197. if (readAction == CFG_READ)
  198. {
  199. if (g_iNumSec >= MAX_SECONDARY)
  200. return PLUGIN_HANDLED
  201.  
  202. new wep[16], display[48], dis[4]
  203. new cmd[6]
  204.  
  205. parse(line, wep, 15, display, 47, dis, 3)
  206.  
  207. new disabled = str_to_num(dis)
  208.  
  209. //Copy weapon into array
  210. format(g_Secondary[g_iNumSec], 17, "weapon_%s", wep)
  211.  
  212. g_DisabledSec[g_iNumSec] = disabled ? false : true
  213.  
  214. format(cmd,5,"%d ",g_iNumSec)
  215. g_iNumSec++
  216.  
  217. //TODO: Add menu_destroy_items to remake menu on cfg reload
  218. menu_additem(g_SecMenuID, display, cmd, 0, g_cSecondary)
  219. }
  220. else if (readAction == CFG_RELOAD)
  221. {
  222. g_SecMenuID = menu_create(g_SecMenu, "m_SecHandler", 0)
  223. g_iNumSec = 0
  224. }
  225. else if (readAction == CFG_DONE)
  226. {
  227. //Nothing for now
  228. return PLUGIN_HANDLED
  229. }
  230.  
  231. return PLUGIN_HANDLED
  232. }
  233.  
  234. public cfgPrimary(readAction, line[], section[])
  235. {
  236. if (readAction == CFG_READ)
  237. {
  238. if (g_iNumPrim >= MAX_PRIMARY)
  239. return PLUGIN_HANDLED
  240.  
  241. new wep[16], display[48], dis[4]
  242. new cmd[6]
  243.  
  244. parse(line, wep, 15, display, 47, dis, 3)
  245.  
  246. new disabled = str_to_num(dis)
  247.  
  248. //Copy weapon into array
  249. format(g_Primary[g_iNumPrim], 17, "weapon_%s", wep)
  250. g_DisabledPrim[g_iNumPrim] = disabled ? false : true
  251.  
  252. format(cmd, 5, "%d", g_iNumPrim)
  253. g_iNumPrim++
  254.  
  255. //TODO: Add menu_destroy_items to remake menu on cfg reload
  256. menu_additem(g_PrimMenuID, display, cmd, 0, g_cPrimary)
  257. } else if (readAction == CFG_RELOAD) {
  258. g_PrimMenuID = menu_create(g_PrimMenu, "m_PrimHandler", 0)
  259. g_iNumPrim = 0
  260. } else if (readAction == CFG_DONE) {
  261. //Nothing for now
  262. return PLUGIN_HANDLED
  263. }
  264.  
  265. return PLUGIN_HANDLED
  266. }
  267.  
  268.  
  269. public cfgBotPrim(readAction, line[], section[])
  270. {
  271. if (readAction == CFG_READ)
  272. {
  273.  
  274. new wep[16], display[32]
  275.  
  276. parse(line, wep, 15, display, 31)
  277.  
  278. //Copy weapon into array
  279. format(g_BotPrim[g_iNumBotPrim], 17, "weapon_%s", wep)
  280. g_iNumBotPrim++
  281. } else if (readAction == CFG_RELOAD) {
  282. g_iNumBotPrim = 0
  283. } else if (readAction == CFG_DONE) {
  284. //Nothing for now
  285. return PLUGIN_HANDLED
  286. }
  287.  
  288. return PLUGIN_HANDLED
  289. }
  290.  
  291. public cfgBotSec(readAction, line[], section[])
  292. {
  293. if (readAction == CFG_READ)
  294. {
  295.  
  296. new wep[16], display[32]
  297.  
  298. parse(line, wep, 15, display, 31)
  299.  
  300. //Copy weapon into array
  301. format(g_BotSec[g_iNumBotSec], 17, "weapon_%s", wep)
  302. g_iNumBotSec++
  303. } else if (readAction == CFG_RELOAD) {
  304. g_iNumBotSec = 0
  305. } else if (readAction == CFG_DONE) {
  306. //Nothing for now
  307. return PLUGIN_HANDLED
  308. }
  309.  
  310. return PLUGIN_HANDLED
  311. }
  312.  
  313. public cfgSetting(readAction, line[], section[])
  314. {
  315. if (readAction == CFG_READ)
  316. {
  317.  
  318. new setting[16], sign[3], value[6]
  319.  
  320. parse(line, setting, 15, sign, 2, value, 5)
  321.  
  322. // Menus settings
  323. if (contain(setting,"menus") != -1)
  324. {
  325. if (containi(value, "p") != -1)
  326. {
  327. g_mPrimStatus = true
  328. }
  329.  
  330. if (containi(value, "s") != -1)
  331. {
  332. g_mSecStatus = true
  333. }
  334.  
  335. if (containi(value, "a") != -1)
  336. {
  337. g_mArmorStatus = true
  338. }
  339.  
  340. if (containi(value, "g") != -1)
  341. {
  342. g_mNadeStatus = true
  343. }
  344.  
  345. return PLUGIN_HANDLED
  346. } else if (contain(setting, "autoitems") != -1) {
  347.  
  348. if (containi(value, "a") != -1)
  349. {
  350. //Disable Armor Menu
  351. g_mArmorStatus = false
  352. g_mAutoArmor = true
  353.  
  354. g_Armor = 1
  355. }
  356.  
  357. if (containi(value, "h") != -1)
  358. {
  359. //Disable Armor Menu
  360. g_mArmorStatus = false
  361. g_mAutoArmor = true
  362. g_Armor = 2
  363. }
  364.  
  365. if (containi(value, "g") != -1)
  366. {
  367. //Disable Grenade Menu
  368. g_mNadeStatus = false
  369. g_mAutoNades = true
  370. }
  371.  
  372. if (containi(value, "d") != -1)
  373. {
  374. g_DefuseKit = true
  375. }
  376.  
  377. if (containi(value, "n") != -1)
  378. {
  379. g_NightVision = true
  380. }
  381.  
  382. return PLUGIN_HANDLED
  383. } else if (contain(setting, "grenades") != -1) {
  384. if (containi(value, "f") != -1)
  385. {
  386. g_Flash = true
  387. }
  388.  
  389. if (containi(value, "h") != -1)
  390. {
  391. g_Nade = true
  392. }
  393.  
  394. if (containi(value, "s") != -1)
  395. {
  396. g_Smoke = true
  397. }
  398. } else if (contain(setting, "fnadesnum") != -1) {
  399. fnadesnum = str_to_num(value)
  400. }
  401.  
  402. return PLUGIN_HANDLED
  403. } else if (readAction == CFG_RELOAD) {
  404. g_mArmorStatus = false
  405. g_mNadeStatus = false
  406. g_Flash = false
  407. g_Nade = false
  408. g_Smoke = false
  409. g_Armor = 0
  410. g_mSecStatus = false
  411. g_mPrimStatus = false
  412. g_mAutoNades = false
  413. g_DefuseKit = false
  414. g_NightVision = false
  415. fnadesnum = 1
  416. } else if (readAction == CFG_DONE) {
  417. //Nothing for now
  418. return PLUGIN_HANDLED
  419. }
  420.  
  421. return PLUGIN_HANDLED
  422. }
  423.  
  424. //Secondary Weapon Callback
  425. public c_Secondary(id, menu, item)
  426. {
  427.  
  428. if( item < 0 ) return PLUGIN_CONTINUE
  429.  
  430. new cmd[6], iName[64]
  431. new access, callback
  432.  
  433. menu_item_getinfo(menu, item, access, cmd,5, iName, 63, callback)
  434.  
  435. new dis = str_to_num(cmd)
  436.  
  437. //Check to see if item is disabled
  438. if (g_DisabledSec[dis])
  439. {
  440. return ITEM_DISABLED
  441. }
  442. else
  443. {
  444. return ITEM_ENABLED
  445. }
  446.  
  447. return PLUGIN_HANDLED
  448. }
  449.  
  450. //Primary Weapon Callback
  451. public c_Primary(id, menu, item)
  452. {
  453.  
  454. if (item < 0)
  455. return PLUGIN_CONTINUE
  456.  
  457. // Get item info
  458. new cmd[6], iName[64]
  459. new access, callback
  460.  
  461. menu_item_getinfo(menu, item, access, cmd,5, iName, 63, callback)
  462.  
  463. new dis = str_to_num(cmd)
  464.  
  465. //Check to see if item is disabled
  466. if (g_DisabledPrim[dis])
  467. {
  468. return ITEM_DISABLED
  469. }
  470. else
  471. {
  472. return ITEM_ENABLED
  473. }
  474.  
  475. return PLUGIN_HANDLED
  476. }
  477.  
  478. //Equipment Menu handler
  479. public m_EquipHandler(id, menu, item)
  480. {
  481. if (item < 0)
  482. {
  483. return PLUGIN_CONTINUE
  484. }
  485.  
  486. // Get item info
  487. new cmd[2], iName[64]
  488. new access, callback
  489.  
  490. menu_item_getinfo(menu, item, access, cmd, 1, iName, 63, callback)
  491.  
  492. new choice = str_to_num(cmd)
  493.  
  494. switch(choice)
  495. {
  496. case 1:
  497. {
  498. if (g_mSecStatus)
  499. {
  500. menu_display(id, g_SecMenuID, 0)
  501. }
  502. else if (g_mPrimStatus)
  503. {
  504. menu_display(id, g_PrimMenuID, 0)
  505. }
  506. else if (g_mArmorStatus)
  507. {
  508. menu_display(id, g_ArmorMenuID, 0)
  509. }
  510. else if (g_mNadeStatus)
  511. {
  512. if (g_mAutoArmor)
  513. {
  514. equipUser(id, EQUIP_ARMOR)
  515. }
  516. menu_display(id, g_NadeMenuID, 0)
  517. } else {
  518. if (g_mAutoArmor)
  519. {
  520. equipUser(id, EQUIP_ARMOR)
  521. }
  522. if (g_mAutoNades)
  523. {
  524. equipUser(id, EQUIP_GREN)
  525. }
  526. equipUser(id, EQUIP_ITEMS)
  527. }
  528. }
  529. case 2:
  530. {
  531. // Equip person with last settings
  532. equipUser(id, EQUIP_ALL)
  533. }
  534. case 3:
  535. {
  536. g_mShowuser[id] = false
  537. client_print(id, print_chat, "[CSDM] Írj ^"guns^" , hogy megnyisd a fegyvermenüt.")
  538. equipUser(id, EQUIP_ALL)
  539. }
  540. }
  541.  
  542. return PLUGIN_HANDLED
  543. }
  544.  
  545. //Secondary Wep Menu handler
  546. public m_SecHandler(id, menu, item)
  547. {
  548. // Get item info
  549. new cmd[6], iName[64]
  550. new access, callback
  551.  
  552. menu_item_getinfo(menu, item, access, cmd,5, iName, 63, callback)
  553.  
  554. new wep = str_to_num(cmd)
  555.  
  556. copy(g_SecWeapons[id],17,g_Secondary[wep])
  557. equipUser(id, EQUIP_SEC)
  558.  
  559. // Show next menu here
  560.  
  561. if (g_mPrimStatus)
  562. {
  563. menu_display(id, g_PrimMenuID, 0)
  564. }
  565. else if (g_mArmorStatus)
  566. {
  567. menu_display(id, g_ArmorMenuID, 0)
  568. }
  569. else if (g_mNadeStatus)
  570. {
  571. if (g_mAutoArmor)
  572. {
  573. equipUser(id, EQUIP_ARMOR)
  574. }
  575. menu_display(id, g_NadeMenuID, 0)
  576. }
  577. else
  578. {
  579. if (g_mAutoArmor)
  580. {
  581. equipUser(id, EQUIP_ARMOR)
  582. }
  583. if (g_mAutoNades)
  584. {
  585. equipUser(id, EQUIP_GREN)
  586. }
  587. equipUser(id, EQUIP_ITEMS)
  588. }
  589.  
  590. return PLUGIN_HANDLED
  591. }
  592.  
  593. //Primary Wep Menu handler
  594. public m_PrimHandler(id, menu, item)
  595. {
  596. if (item < 0) return PLUGIN_HANDLED
  597.  
  598. // Get item info
  599. new cmd[6], iName[64]
  600. new access, callback
  601.  
  602. if (menu_item_getinfo(menu, item, access, cmd,5, iName, 63, callback))
  603. {
  604. new wep = str_to_num(cmd)
  605.  
  606. copy(g_PrimWeapons[id], 17, g_Primary[wep])
  607. equipUser(id, EQUIP_PRI)
  608. }
  609.  
  610. // Show next menu here
  611.  
  612. if (g_mArmorStatus)
  613. {
  614. menu_display(id, g_ArmorMenuID, 0)
  615. }
  616. else if (g_mNadeStatus)
  617. {
  618. if (g_mAutoArmor)
  619. {
  620. equipUser(id, EQUIP_ARMOR)
  621. }
  622. menu_display(id, g_NadeMenuID, 0)
  623. } else {
  624. if (g_mAutoArmor)
  625. {
  626. equipUser(id, EQUIP_ARMOR)
  627. }
  628. if (g_mAutoNades)
  629. {
  630. equipUser(id, EQUIP_GREN)
  631. }
  632. equipUser(id, EQUIP_ITEMS)
  633. }
  634.  
  635. return PLUGIN_HANDLED
  636. }
  637.  
  638. //Armor Menu handler
  639. public m_ArmorHandler(id, menu, item)
  640. {
  641. if (item < 0) return PLUGIN_CONTINUE
  642.  
  643. // Get item info
  644. new cmd[6], iName[64]
  645. new access, callback
  646.  
  647. menu_item_getinfo(menu, item, access, cmd,5, iName, 63, callback)
  648.  
  649. new choice = str_to_num(cmd)
  650.  
  651. if (choice == 1)
  652. {
  653. g_mArmor[id] = true
  654. }
  655. else if (choice == 2)
  656. {
  657. g_mArmor[id] = false
  658. }
  659. equipUser(id, EQUIP_ARMOR)
  660.  
  661. // Show next menu here
  662.  
  663. if (g_mNadeStatus)
  664. {
  665. menu_display(id, g_NadeMenuID, 0)
  666. } else {
  667. if (g_mAutoNades)
  668. {
  669. equipUser(id, EQUIP_GREN)
  670. }
  671. equipUser(id, EQUIP_ITEMS)
  672. }
  673.  
  674. return PLUGIN_HANDLED
  675. }
  676.  
  677. //Nade Menu handler
  678. public m_NadeHandler(id, menu, item)
  679. {
  680. if (item < 0) return PLUGIN_CONTINUE
  681.  
  682. new cmd[6], iName[64]
  683. new access, callback
  684.  
  685. menu_item_getinfo(menu, item, access, cmd, 5, iName, 63, callback)
  686.  
  687. new choice = str_to_num(cmd)
  688.  
  689. if (choice == 1)
  690. {
  691. g_mNades[id] = true
  692. }
  693. else if (choice == 2)
  694. {
  695. g_mNades[id] = false
  696. }
  697.  
  698. equipUser(id, EQUIP_GREN)
  699. equipUser(id, EQUIP_ITEMS)
  700.  
  701. return PLUGIN_HANDLED
  702. }
  703.  
  704. buildMenu()
  705. {
  706. //Equip Menu
  707. menu_additem(g_EquipMenuID, "Új fegyverek", "1", 0, -1)
  708. menu_additem(g_EquipMenuID, "Elõzõ fegyverek", "2", 0, -1)
  709. menu_additem(g_EquipMenuID, "Ne mutassa újra a menüt", "3", 0, -1)
  710. menu_setprop(g_EquipMenuID, MPROP_EXIT, MEXIT_NEVER)
  711.  
  712. //Armor Menu
  713. menu_additem(g_ArmorMenuID, "Igen, kell pajzs", "1", 0, -1)
  714. menu_additem(g_ArmorMenuID, "Nem kell pajzs", "2", 0, -1)
  715. menu_setprop(g_ArmorMenuID, MPROP_EXIT, MEXIT_NEVER)
  716.  
  717. //Nade Menu
  718. menu_additem(g_NadeMenuID, "Összes Gránát", "1", 0, -1)
  719. menu_additem(g_NadeMenuID, "Nem kell gránát", "2", 0, -1)
  720. menu_setprop(g_NadeMenuID, MPROP_EXIT, MEXIT_NEVER)
  721.  
  722. return PLUGIN_HANDLED
  723. }
  724.  
  725. equipUser(id, to)
  726. {
  727. if (!is_user_alive(id) )
  728. return
  729.  
  730. if (to & EQUIP_SEC)
  731. {
  732. //Give Secondary
  733. GiveUserFullWeapon(id, g_SecWeapons[id])
  734. }
  735.  
  736. if (to & EQUIP_PRI)
  737. {
  738. //Give Primary
  739. GiveUserFullWeapon(id, g_PrimWeapons[id])
  740. }
  741.  
  742. if (to & EQUIP_ARMOR)
  743. {
  744. //Give Armor
  745. if (g_mAutoArmor || g_mArmor[id])
  746. {
  747. new armor = g_mArmor[id] ? 2 : g_Armor
  748. cs_set_user_armor(id, DEFAULT_ARMOR, CsArmorType:armor)
  749. }
  750. }
  751.  
  752. if (to & EQUIP_GREN)
  753. {
  754. //Give Nades
  755. if (g_mNades[id] || g_mAutoNades)
  756. {
  757.  
  758. if (g_Nade)
  759. {
  760. GiveUserFullWeapon(id,"weapon_hegrenade")
  761. }
  762.  
  763. if (g_Smoke)
  764. {
  765. GiveUserFullWeapon(id, "weapon_smokegrenade")
  766. }
  767.  
  768. if (g_Flash && fnadesnum)
  769. {
  770. GiveUserFullWeapon(id, "weapon_flashbang")
  771. if (fnadesnum == 2)
  772. {
  773. GiveUserFullWeapon(id, "weapon_flashbang")
  774. }
  775. }
  776.  
  777. }
  778. }
  779.  
  780. if (to & EQUIP_ITEMS)
  781. {
  782. if (g_DefuseKit && (cs_get_user_team(id) == CS_TEAM_CT))
  783. {
  784. cs_set_user_defuse(id, 1)
  785. }
  786. if (g_NightVision)
  787. {
  788. cs_set_user_nvg(id, 1)
  789. }
  790. }
  791. }
  792.  
  793. GiveUserFullWeapon(id, const wp[])
  794. {
  795. /** First check to make sure the user does not have a weapon in this slot */
  796. new wpnid = get_weaponid(wp)
  797. new weapons[MAX_WEAPONS], num
  798. new name[24], weap
  799. new slot
  800. if (wpnid == 0)
  801. {
  802. if (equal(wp, "weapon_shield"))
  803. {
  804. slot = SLOT_PRIMARY
  805. wpnid = -1
  806. }
  807. } else {
  808. slot = g_WeaponSlots[wpnid]
  809. }
  810. if ((slot == SLOT_SECONDARY || slot == SLOT_PRIMARY)
  811. && wpnid > 0)
  812. {
  813. get_user_weapons(id, weapons, num)
  814. for (new i=0; i<num; i++)
  815. {
  816. weap = weapons[i]
  817. if (weap == wpnid)
  818. {
  819. continue
  820. }
  821. if (g_WeaponSlots[weap] == slot)
  822. {
  823. if (slot == SLOT_SECONDARY && cs_get_user_shield(id))
  824. {
  825. //temporary fix!
  826. drop_with_shield(id, weap)
  827. } else {
  828. get_weaponname(weap, name, 23)
  829. csdm_force_drop(id, name)
  830. }
  831. }
  832. }
  833. } else if (slot == SLOT_PRIMARY && wpnid == -1 && cs_get_user_shield(id)) {
  834. return
  835. }
  836.  
  837. if (slot == SLOT_PRIMARY && cs_get_user_shield(id) && wpnid > 0)
  838. {
  839. csdm_fwd_drop(id, -1, "weapon_shield")
  840. }
  841.  
  842. new item_id = csdm_give_item(id, wp)
  843. if (item_id > 0)
  844. {
  845. if (wpnid == CSW_M4A1)
  846. {
  847. cs_set_weapon_silen(item_id, g_Silenced[id][SILENCED_M4A1], 1)
  848. } else if (wpnid == CSW_USP) {
  849. cs_set_weapon_silen(item_id, g_Silenced[id][SILENCED_USP], 1)
  850. }
  851. }
  852.  
  853. if (wpnid > 0)
  854. {
  855. new bpammo = g_MaxBPAmmo[wpnid]
  856. if (bpammo)
  857. {
  858. cs_set_user_bpammo(id, wpnid, bpammo)
  859. }
  860. }
  861. }
  862.  
  863. // MAIN FUNCTION OF THE PLUGIN
  864. public csdm_PostSpawn(player)
  865. {
  866. if (is_user_bot(player))
  867. {
  868. new randPrim = random_num(0, g_iNumBotPrim-1)
  869. new randSec = random_num(0, g_iNumBotSec-1)
  870.  
  871. // By our lMOSTeast favorite guy KWo RIP - 02.11.2005.
  872. new randArm = random_num(0, 2)
  873. new randGre = random_num(0, 2)
  874.  
  875. GiveUserFullWeapon(player, g_BotPrim[randPrim])
  876. GiveUserFullWeapon(player, g_BotSec[randSec])
  877.  
  878. g_mArmor[player] = (g_mArmorStatus && randArm)
  879. g_mNades[player] = (g_mNadeStatus && randGre)
  880.  
  881. if (g_mAutoArmor || g_mArmor[player])
  882. {
  883. equipUser(player, EQUIP_ARMOR)
  884. }
  885.  
  886. if (g_mAutoNades || g_mNades[player])
  887. {
  888. equipUser(player, EQUIP_GREN)
  889. }
  890. if (g_DefuseKit)
  891. {
  892. equipUser(player, EQUIP_ITEMS)
  893. }
  894. } else {
  895. if (g_mShowuser[player])
  896. {
  897. g_MenuState[player] = 1
  898. menu_display(player, g_EquipMenuID, 0)
  899. } else {
  900. g_MenuState[player] = 0
  901. equipUser(player, EQUIP_ALL)
  902. }
  903. }
  904.  
  905. return PLUGIN_CONTINUE
  906. }
  907.  
  908. public enableMenu(id)
  909. {
  910. if (!csdm_active())
  911. return PLUGIN_CONTINUE
  912.  
  913. if (!g_mShowuser[id])
  914. {
  915. g_mShowuser[id] = true
  916. client_print(id, print_chat, "[CSDM] Funkció már engedélyezve van.")
  917. if (!g_MenuState[id])
  918. {
  919. g_MenuState[id] = 1
  920. menu_display(id, g_EquipMenuID, 0)
  921. }
  922. } else {
  923. client_print(id, print_chat, "[CSDM] Neked már engedélyezve van a menü.")
  924. }
  925.  
  926. return PLUGIN_HANDLED
  927. }