Advertisement
Guest User

Untitled

a guest
Feb 27th, 2018
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 48.87 KB | None | 0 0
  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. *
  17. * Modification from ReCSDM Team (C) 2016
  18. * http://www.dedicated-server.ru/
  19. *
  20. */
  21.  
  22. #include <amxmodx>
  23. #include <amxmisc>
  24. #include <cstrike>
  25. #include <csdm>
  26. #include <fakemeta>
  27. #include <hamsandwich>
  28. #include <CromChat>
  29.  
  30. #pragma semicolon 1
  31.  
  32. #if AMXX_VERSION_NUM < 183
  33. #define client_disconnected client_disconnect
  34. #endif
  35.  
  36. //Tampering with the author and name lines can violate the copyright
  37. new const PLUGINNAME[] = "ReCSDM Equip";
  38. new const VERSION[] = CSDM_VERSION;
  39. new const AUTHORS[] = "ReCSDM Team";
  40.  
  41. #define EQUIP_PRI (1<<0)
  42. #define EQUIP_SEC (1<<1)
  43. #define EQUIP_ARMOR (1<<2)
  44. #define EQUIP_GREN (1<<3)
  45. #define EQUIP_ITEMS (1<<4)
  46. #define EQUIP_ALL (EQUIP_PRI|EQUIP_SEC|EQUIP_ARMOR|EQUIP_GREN|EQUIP_ITEMS)
  47.  
  48. #define ITEMTYPES_NUM 42
  49.  
  50. new szPrefix[ ] = "BetterPlay";
  51.  
  52. new g_MaxPlayers;
  53.  
  54. new bool:IsRestricted[ITEMTYPES_NUM] = {false, ...}; // Contains if an item is restricted or not
  55. new RestrictWps[ITEMTYPES_NUM] = {32, ...};
  56. new UsedWpsT[ITEMTYPES_NUM] = {0, ...};
  57. new UsedWpsCT[ITEMTYPES_NUM] = {0, ...};
  58.  
  59. //Menus
  60. new const g_SecMenu[] = "Pistols Menu"; // Menu Name
  61. new g_SecMenuID = -1; // Menu ID
  62. new g_cSecondary; // Menu Callback
  63. new bool:g_mSecStatus = true; // Menu Available?
  64.  
  65. new const g_PrimMenu[] = "Weapons Menu";
  66. new g_PrimMenuID = -1;
  67. new g_cPrimary;
  68. new bool:g_mPrimStatus = true;
  69.  
  70. new const g_ArmorMenu[] = "Armour";
  71. new g_ArmorMenuID = -1;
  72. new bool:g_mArmorStatus = true;
  73.  
  74. new const g_NadeMenu[] = "Grenades";
  75. new g_NadeMenuID = -1;
  76. new bool:g_mNadeStatus = true;
  77.  
  78. new const g_EquipMenu[] = "BetterPlay Equip Menu";
  79. new g_EquipMenuID = -1;
  80. new g_cEquip;
  81.  
  82. new bool:g_mShowuser[CSDM_MAXPLAYERS + 1] = true;
  83.  
  84. new g_Teamuser[CSDM_MAXPLAYERS + 1];
  85.  
  86. new bool:g_mAutoNades = false;
  87. new bool:g_mAutoArmor = false;
  88. new bool:g_AlwaysAllowGunMenu = false;
  89. new bool:g_AmmoRefill = false;
  90. new g_WeaponStayTime = 0;
  91.  
  92. //Weapon Selections
  93. new g_SecWeapons[CSDM_MAXPLAYERS + 1][18];
  94. new g_PrimWeapons[CSDM_MAXPLAYERS + 1][18];
  95. new bool:g_mNades[CSDM_MAXPLAYERS + 1];
  96. new bool:g_mArmor[CSDM_MAXPLAYERS + 1];
  97.  
  98. //Config weapon storage holders
  99. new g_BotPrim[MAX_WEAPONS][18];
  100. new g_iNumBotPrim;
  101.  
  102. new g_BotSec[MAX_WEAPONS][18];
  103. new g_iNumBotSec;
  104.  
  105. new g_Secondary[MAX_SECONDARY][18];
  106. new bool:g_DisabledSec[MAX_WEAPONS];
  107. new g_iNumSec;
  108. new g_iNumUsedSec = 0;
  109.  
  110. new g_Primary[MAX_PRIMARY][18];
  111. new bool:g_DisabledPrim[MAX_WEAPONS];
  112. new g_iNumPrim;
  113. new g_iNumUsedPrim = 0;
  114.  
  115. new pv_csdm_additems;
  116.  
  117. #define SILENCED_M4A1 0
  118. #define SILENCED_USP 1
  119. new bool:g_Silenced[CSDM_MAXPLAYERS + 1][2];
  120.  
  121. //Misc
  122. new g_Armor = 0;
  123. new fnadesnum = 0;
  124. new bool:g_Flash = false;
  125. new bool:g_Nade = false;
  126. new bool:g_Smoke = false;
  127. new bool:g_NightVision = false;
  128. new bool:g_DefuseKit = false;
  129. new PcvarAWPmoney;
  130. new PcvarSG550money;
  131. new PcvarG3SG1money;
  132.  
  133. // page info for settings in CSDM Setting Menu
  134. new g_SettingsMenu = 0;
  135. new g_EquipSettMenu = 0;
  136. new g_ItemsInMenuNr = 0;
  137. new g_PageSettMenu = 0;
  138.  
  139. //Quick Fix for menu pages
  140. new g_MenuState[CSDM_MAXPLAYERS + 1] = {0};
  141.  
  142. new Float:g_maxdelmenutime = 30.0;
  143.  
  144. #define PDATA_SAFE 2
  145. #define OFFSET_LINUX_WEAPONS 4
  146. #define m_pPlayer 41
  147. #define m_iId 43
  148.  
  149. public csdm_Init(const version[])
  150. {
  151. if (version[0] == 0) {
  152. set_fail_state("ReCSDM failed to load.");
  153. return;
  154. }
  155.  
  156. // Menus and callbacks
  157. g_SecMenuID = menu_create(g_SecMenu, "m_SecHandler", 0);
  158. g_PrimMenuID = menu_create(g_PrimMenu, "m_PrimHandler", 0);
  159. g_ArmorMenuID = menu_create(g_ArmorMenu, "m_ArmorHandler", 0);
  160. g_NadeMenuID = menu_create(g_NadeMenu, "m_NadeHandler", 0);
  161. g_EquipMenuID = menu_create(g_EquipMenu, "m_EquipHandler", 0);
  162.  
  163. menu_setprop(g_PrimMenuID, MPROP_EXIT, MEXIT_NEVER);
  164. menu_setprop(g_SecMenuID, MPROP_EXIT, MEXIT_NEVER);
  165.  
  166. g_cSecondary = menu_makecallback("c_Secondary");
  167. g_cPrimary = menu_makecallback("c_Primary");
  168. g_cEquip = menu_makecallback("c_Equip");
  169. }
  170.  
  171. public csdm_CfgInit()
  172. {
  173. csdm_reg_cfg("settings", "cfgMainSettings");
  174. csdm_reg_cfg("misc", "cfgMiscSettings");
  175.  
  176. // Config reader
  177. csdm_reg_cfg("equip", "cfgSetting");
  178.  
  179. // In order for weapon menu
  180. csdm_reg_cfg("secondary", "cfgSecondary");
  181. csdm_reg_cfg("primary", "cfgPrimary");
  182. csdm_reg_cfg("botprimary", "cfgBotPrim");
  183. csdm_reg_cfg("botsecondary", "cfgBotSec");
  184. csdm_reg_cfg("item_restrictions", "cfgrestricts");
  185.  
  186. set_task(2.0, "check_cvar_pointers", 790);
  187. }
  188.  
  189. public check_cvar_pointers()
  190. {
  191. pv_csdm_additems = get_cvar_pointer("csdm_add_items");
  192. }
  193.  
  194. public plugin_init()
  195. {
  196. register_plugin(PLUGINNAME, VERSION, AUTHORS);
  197.  
  198. buildMenu(); // Build Armor/Nade/Equip Menu's
  199.  
  200. register_clcmd("say guns", "enableMenu");
  201. register_clcmd("say /guns", "enableMenu");
  202. register_clcmd("say menu", "enableMenu");
  203. register_clcmd("say enablemenu", "enableMenu");
  204. register_clcmd("say enable_menu", "enableMenu");
  205. register_clcmd("csdm_equip_sett_menu", "csdm_equip_sett_menu", ADMIN_MAP, "CSDM Equip Settings Menu");
  206. register_event("TextMsg","eRestart","a","2&#Game_C","2&#Game_w");
  207.  
  208. RegisterHam(Ham_Weapon_SecondaryAttack, "weapon_usp", "Weapon_SecondaryAttack_usp_Post", true);
  209. RegisterHam(Ham_Weapon_SecondaryAttack, "weapon_m4a1", "SecondaryAttack_m4a1_Post", true);
  210.  
  211. new main_plugin = module_exists("csdm_main") ? true : false;
  212.  
  213. PcvarAWPmoney = register_cvar("csdm_eq_AWPcost", "3000");
  214. PcvarSG550money = register_cvar("csdm_eq_SG550cost", 5000");
  215. PcvarG3SG1money = register_cvar("csdm_eq_G3SG1cost", "6000");
  216.  
  217. if(main_plugin)
  218. {
  219. g_SettingsMenu = csdm_settings_menu();
  220. g_ItemsInMenuNr = menu_items(g_SettingsMenu);
  221. g_PageSettMenu = g_ItemsInMenuNr / 7;
  222.  
  223. g_EquipSettMenu = menu_create("Меню настроек экипировки", "use_csdm_equip_menu");
  224.  
  225. menu_additem(g_SettingsMenu, "Настройки экипировки", "csdm_equip_sett_menu", ADMIN_MAP);
  226.  
  227. if(g_EquipSettMenu)
  228. {
  229. new callback = menu_makecallback("hook_equip_sett_display");
  230.  
  231. menu_additem(g_EquipSettMenu, "Меню первичной экипировки [вкл/выкл]", "1", ADMIN_MAP, callback);
  232. menu_additem(g_EquipSettMenu, "Меню вторичной экипировки [вкл/выкл]", "2", ADMIN_MAP, callback);
  233. menu_additem(g_EquipSettMenu, "Меню брони [вкл/выкл]", "3", ADMIN_MAP, callback);
  234. menu_additem(g_EquipSettMenu, "Меню гранат [вкл/выкл]", "4", ADMIN_MAP, callback);
  235. menu_additem(g_EquipSettMenu, "Автоматическая выдача брони [вкл/выкл]", "5", ADMIN_MAP, callback);
  236. menu_additem(g_EquipSettMenu, "Автоматическая выдача шлема [вкл/выкл]", "6", ADMIN_MAP, callback);
  237. menu_additem(g_EquipSettMenu, "Автоматическая выдача гранат [вкл/выкл]", "7", ADMIN_MAP, callback);
  238. menu_additem(g_EquipSettMenu, "Автоматическая выдача щипцов [вкл/выкл]", "8", ADMIN_MAP, callback);
  239. menu_additem(g_EquipSettMenu, "Автоматическая выдача ночного виденья [вкл/выкл]", "9", ADMIN_MAP, callback);
  240. menu_additem(g_EquipSettMenu, "Световые гранаты [вкл/выкл]", "10", ADMIN_MAP, callback);
  241. menu_additem(g_EquipSettMenu, "Дымовые гранаты [вкл/выкл]", "11", ADMIN_MAP, callback);
  242. menu_additem(g_EquipSettMenu, "Разрывные гранаты [вкл/выкл]", "12", ADMIN_MAP, callback);
  243. menu_additem(g_EquipSettMenu, "Разрешить всегда использовать меню оружия [Вкл/Выкл]", "13", ADMIN_MAP, callback);
  244. menu_additem(g_EquipSettMenu, "Назад", "14", 0, -1);
  245. }
  246. } else {
  247. log_amx("CSDM - csdm_equip - no main plugin loaded");
  248. }
  249.  
  250. if(g_iNumUsedSec == 0)
  251. g_mSecStatus = false;
  252.  
  253. if(g_iNumUsedPrim == 0)
  254. g_mPrimStatus = false;
  255.  
  256. g_MaxPlayers = get_maxplayers();
  257. }
  258.  
  259. public eRestart()
  260. {
  261. arrayset(UsedWpsT, 0, ITEMTYPES_NUM);
  262. arrayset(UsedWpsCT, 0, ITEMTYPES_NUM);
  263.  
  264. return PLUGIN_CONTINUE;
  265. }
  266.  
  267. public client_connect(id)
  268. {
  269. g_mShowuser[id] = true;
  270. g_mNades[id] = false;
  271. g_mArmor[id] = false;
  272. g_Silenced[id][SILENCED_M4A1] = false;
  273. g_Silenced[id][SILENCED_USP] = false;
  274.  
  275. return PLUGIN_CONTINUE;
  276. }
  277.  
  278. public client_disconnected(id)
  279. {
  280. g_mShowuser[id] = false;
  281. g_mNades[id] = false;
  282. g_mArmor[id] = false;
  283.  
  284. new weapons[MAX_WEAPONS], num, weapid;
  285.  
  286. get_user_weapons(id, weapons, num);
  287.  
  288. for (new i = 0; i < num; i++)
  289. {
  290. weapid = weapons[i];
  291.  
  292. if(IsRestricted[weapid] && UsedWpsT[weapid] > 0 && g_Teamuser[id] == _TEAM_T) {
  293. UsedWpsT[weapid]--;
  294. }
  295.  
  296. if(IsRestricted[weapid] && UsedWpsCT[weapid] > 0 && g_Teamuser[id] == _TEAM_CT) {
  297. UsedWpsCT[weapid]--;
  298. }
  299. }
  300.  
  301. return PLUGIN_CONTINUE;
  302. }
  303.  
  304. public csdm_RemoveWeapon(owner, entity_id, boxed_id)
  305. {
  306. if(!pev_valid(entity_id))
  307. return PLUGIN_HANDLED;
  308.  
  309. new szClassname[32], weapon, team;
  310.  
  311. pev(entity_id, pev_classname, szClassname, charsmax(szClassname));
  312.  
  313. weapon = get_weaponid(szClassname);
  314.  
  315. if(owner && weapon)
  316. {
  317. team = _:cs_get_user_team(owner);
  318.  
  319. if(IsRestricted[weapon] && UsedWpsT[weapon] > 0 && team == _TEAM_T) {
  320. UsedWpsT[weapon]--;
  321. // log_amx("[DEBUG] CSDM - restricted weapon %s removed. Currently there is %d such weapons on the map.", szClassname, UsedWpsT[weapon])
  322. }
  323.  
  324. if(IsRestricted[weapon] && UsedWpsCT[weapon] > 0 && team == _TEAM_CT) {
  325. UsedWpsCT[weapon]--;
  326. //log_amx("[DEBUG] CSDM - restricted weapon %s removed. Currently there is %d such weapons on the map.", szClassname, UsedWpsCT[weapon])
  327. }
  328. }
  329.  
  330. return PLUGIN_CONTINUE;
  331. }
  332.  
  333. public csdm_PostDeath(killer, victim, headshot, const weapon[])
  334. {
  335. /* Clean up any defusal kits we might have made! */
  336. if(!g_DefuseKit) return;
  337.  
  338. g_Teamuser[victim] = _:cs_get_user_team(victim);
  339.  
  340. /* This might have a race condition for team switches... */
  341. if(g_Teamuser[victim] == _TEAM_CT)
  342. cs_set_user_defuse(victim, 0);
  343. }
  344.  
  345. public Weapon_SecondaryAttack_usp_Post(Ent)
  346. {
  347. if(pev_valid(Ent) != PDATA_SAFE)
  348. return HAM_IGNORED;
  349.  
  350. new id = get_pdata_cbase(Ent, m_pPlayer, OFFSET_LINUX_WEAPONS);
  351.  
  352. if(id < 1 || id > g_MaxPlayers)
  353. return HAM_IGNORED;
  354.  
  355. g_Silenced[id][SILENCED_USP] = cs_get_weapon_silen(Ent) ? true : false;
  356.  
  357. return HAM_IGNORED;
  358. }
  359.  
  360. public SecondaryAttack_m4a1_Post(Ent)
  361. {
  362. if(pev_valid(Ent) != PDATA_SAFE)
  363. return HAM_IGNORED;
  364.  
  365. new id = get_pdata_cbase(Ent, m_pPlayer, OFFSET_LINUX_WEAPONS);
  366.  
  367. if(id < 1 || id > g_MaxPlayers)
  368. return HAM_IGNORED;
  369.  
  370. g_Silenced[id][SILENCED_M4A1] = cs_get_weapon_silen(Ent) ? true : false;
  371.  
  372. return HAM_IGNORED;
  373. }
  374.  
  375. public cfgSecondary(readAction, line[], section[])
  376. {
  377. if(readAction == CFG_READ)
  378. {
  379. if (g_iNumSec >= MAX_SECONDARY)
  380. return PLUGIN_HANDLED;
  381.  
  382. new wep[16], display[48], dis[4], cmd[6];
  383.  
  384. parse(line, wep, charsmax(wep), display, charsmax(display), dis, charsmax(dis));
  385.  
  386. new disabled = str_to_num(dis);
  387.  
  388. //Copy weapon into array
  389. formatex(g_Secondary[g_iNumSec], charsmax(g_Secondary[]), "weapon_%s", wep);
  390.  
  391. g_DisabledSec[g_iNumSec] = disabled ? false : true;
  392.  
  393. formatex(cmd, 5, "%d ", g_iNumSec);
  394.  
  395. g_iNumSec++;
  396.  
  397. if(disabled > 0)
  398. g_iNumUsedSec++;
  399.  
  400. //TODO: Add menu_destroy_items to remake menu on cfg reload
  401. menu_additem(g_SecMenuID, display, cmd, 0, g_cSecondary);
  402.  
  403. } else if (readAction == CFG_RELOAD) {
  404. g_SecMenuID = menu_create(g_SecMenu, "m_SecHandler", 0);
  405. g_iNumSec = 0;
  406. g_iNumUsedSec = 0;
  407.  
  408. } else if(readAction == CFG_DONE) {
  409. //Nothing for now
  410. return PLUGIN_HANDLED;
  411. }
  412.  
  413. return PLUGIN_HANDLED;
  414. }
  415.  
  416. public cfgPrimary(readAction, line[], section[])
  417. {
  418. if(readAction == CFG_READ)
  419. {
  420. if(g_iNumPrim >= MAX_PRIMARY)
  421. return PLUGIN_HANDLED;
  422.  
  423. new wep[16], display[48], dis[4], cmd[6];
  424.  
  425. parse(line, wep, charsmax(wep), display, charsmax(display), dis, charsmax(dis));
  426.  
  427. new disabled = str_to_num(dis);
  428.  
  429. //Copy weapon into array
  430. formatex(g_Primary[g_iNumPrim], charsmax(g_Secondary[]), "weapon_%s", wep);
  431.  
  432. g_DisabledPrim[g_iNumPrim] = disabled ? false : true;
  433.  
  434. formatex(cmd, charsmax(cmd), "%d", g_iNumPrim);
  435.  
  436. g_iNumPrim++;
  437.  
  438. if(disabled > 0)
  439. g_iNumUsedPrim++;
  440.  
  441. //TODO: Add menu_destroy_items to remake menu on cfg reload
  442. menu_additem(g_PrimMenuID, display, cmd, 0, g_cPrimary);
  443.  
  444. } else if(readAction == CFG_RELOAD) {
  445. g_PrimMenuID = menu_create(g_PrimMenu, "m_PrimHandler", 0);
  446. g_iNumPrim = 0;
  447. g_iNumUsedPrim = 0;
  448.  
  449. } else if(readAction == CFG_DONE) {
  450. //Nothing for now
  451. return PLUGIN_HANDLED;
  452. }
  453.  
  454. return PLUGIN_HANDLED;
  455. }
  456.  
  457. public cfgBotPrim(readAction, line[], section[])
  458. {
  459. if(readAction == CFG_READ)
  460. {
  461. new wep[16], display[32];
  462.  
  463. parse(line, wep, charsmax(wep), display, charsmax(display));
  464.  
  465. //Copy weapon into array
  466. formatex(g_BotPrim[g_iNumBotPrim], charsmax(g_BotPrim[]), "weapon_%s", wep);
  467.  
  468. g_iNumBotPrim++;
  469.  
  470. } else if(readAction == CFG_RELOAD) {
  471. g_iNumBotPrim = 0;
  472.  
  473. } else if(readAction == CFG_DONE) {
  474. //Nothing for now
  475. return PLUGIN_HANDLED;
  476. }
  477.  
  478. return PLUGIN_HANDLED;
  479. }
  480.  
  481. public cfgBotSec(readAction, line[], section[])
  482. {
  483. if(readAction == CFG_READ)
  484. {
  485. new wep[16], display[32];
  486.  
  487. parse(line, wep, charsmax(wep), display, charsmax(display));
  488.  
  489. //Copy weapon into array
  490. formatex(g_BotSec[g_iNumBotSec], charsmax(g_BotPrim[]), "weapon_%s", wep);
  491.  
  492. g_iNumBotSec++;
  493.  
  494. } else if(readAction == CFG_RELOAD) {
  495. g_iNumBotSec = 0;
  496.  
  497. } else if(readAction == CFG_DONE) {
  498. //Nothing for now
  499. return PLUGIN_HANDLED;
  500. }
  501.  
  502. return PLUGIN_HANDLED;
  503. }
  504.  
  505. public cfgSetting(readAction, line[], section[])
  506. {
  507. if(readAction == CFG_READ)
  508. {
  509. new setting[24], sign[3], value[6];
  510.  
  511. parse(line, setting, charsmax(setting), sign, charsmax(sign), value, charsmax(value));
  512.  
  513. // Menus settings
  514. if(contain(setting,"menus") != -1)
  515. {
  516. if(containi(value, "p") != -1)
  517. g_mPrimStatus = true;
  518.  
  519. if(containi(value, "s") != -1)
  520. g_mSecStatus = true;
  521.  
  522. if(containi(value, "a") != -1)
  523. g_mArmorStatus = true;
  524.  
  525. if(containi(value, "g") != -1)
  526. g_mNadeStatus = true;
  527.  
  528. return PLUGIN_HANDLED;
  529.  
  530. } else if(contain(setting, "autoitems") != -1) {
  531.  
  532. if(containi(value, "a") != -1) {
  533. //Disable Armor Menu
  534. g_mArmorStatus = false;
  535. g_mAutoArmor = true;
  536. g_Armor = 1;
  537. }
  538.  
  539. if(containi(value, "h") != -1) {
  540. //Disable Armor Menu
  541. g_mArmorStatus = false;
  542. g_mAutoArmor = true;
  543. g_Armor = 2;
  544. }
  545.  
  546. if(containi(value, "g") != -1) {
  547. //Disable Grenade Menu
  548. g_mNadeStatus = false;
  549. g_mAutoNades = true;
  550. }
  551.  
  552. if(containi(value, "d") != -1)
  553. g_DefuseKit = true;
  554.  
  555. if(containi(value, "n") != -1)
  556. g_NightVision = true;
  557.  
  558. return PLUGIN_HANDLED;
  559.  
  560. } else if(contain(setting, "grenades") != -1) {
  561.  
  562. if(containi(value, "f") != -1)
  563. g_Flash = true;
  564.  
  565. if(containi(value, "h") != -1)
  566. g_Nade = true;
  567.  
  568. if (containi(value, "s") != -1)
  569. g_Smoke = true;
  570.  
  571. } else if(contain(setting, "fnadesnum") != -1) {
  572. fnadesnum = str_to_num(value);
  573.  
  574. } else if(contain(setting, "always_allow_gunmenu") != -1) {
  575. g_AlwaysAllowGunMenu = str_to_num(value)? true : false;
  576. }
  577.  
  578. return PLUGIN_HANDLED;
  579.  
  580. } else if(readAction == CFG_RELOAD) {
  581. g_mArmorStatus = false;
  582. g_mNadeStatus = false;
  583. g_Flash = false;
  584. g_Nade = false;
  585. g_Smoke = false;
  586. g_Armor = 0;
  587. g_mSecStatus = false;
  588. g_mPrimStatus = false;
  589. g_mAutoNades = false;
  590. g_DefuseKit = false;
  591. g_NightVision = false;
  592. fnadesnum = 1;
  593.  
  594. } else if(readAction == CFG_DONE) {
  595. //Nothing for now
  596. return PLUGIN_HANDLED;
  597. }
  598.  
  599. return PLUGIN_HANDLED;
  600. }
  601.  
  602. public cfgrestricts(readAction, line[], section[])
  603. {
  604. if(readAction == CFG_READ)
  605. {
  606. new itemname[24], value[32], limit;
  607. parse(line, itemname, charsmax(itemname), value, charsmax(value));
  608.  
  609. limit = 0;
  610.  
  611. if(value[0] != '0')
  612. limit = str_to_num(value);
  613.  
  614. new weapname[24], weaptype;
  615.  
  616. formatex(weapname, charsmax(weapname), "weapon_%s", itemname);
  617.  
  618. weaptype = getWeapId(weapname);
  619.  
  620. // weaptype = get_weaponid(weapname) // why this crap doesn't work here but works correctly during the game ?!?
  621. // log_amx("[DEBUG] CSDM - reading restrictions, weapon %s (weaptype = %d).", itemname, weaptype)
  622.  
  623. if(weaptype != 0) {
  624. IsRestricted[weaptype] = true;
  625. RestrictWps[weaptype] = limit;
  626. }
  627.  
  628. // log_amx("[DEBUG] CSDM - reading restrictions, restricted %s (weaptype = %d) = %d", itemname, weaptype, limit)
  629. }
  630. else if(readAction == CFG_RELOAD)
  631. {
  632. // Reset all restrictions
  633. arrayset(IsRestricted, false, ITEMTYPES_NUM);
  634. arrayset(RestrictWps, 32, ITEMTYPES_NUM);
  635. return PLUGIN_HANDLED;
  636. }
  637. else if(readAction == CFG_DONE)
  638. {
  639. //Nothing for now
  640. return PLUGIN_HANDLED;
  641. }
  642.  
  643. return PLUGIN_HANDLED;
  644. }
  645.  
  646. public cfgMainSettings(readAction, line[], section[])
  647. {
  648. if(readAction == CFG_READ)
  649. {
  650. new setting[24], sign[3], value[32];
  651.  
  652. parse(line, setting, charsmax(setting), sign, charsmax(sign), value, charsmax(value));
  653.  
  654. if(equali(setting, "weapons_stay")) {
  655. g_WeaponStayTime = str_to_num(value);
  656. }
  657. }
  658. }
  659.  
  660. public cfgMiscSettings(readAction, line[], section[])
  661. {
  662. if(readAction == CFG_READ)
  663. {
  664. new setting[24], sign[3], value[32];
  665.  
  666. parse(line, setting, charsmax(setting), sign, charsmax(sign), value, charsmax(value));
  667.  
  668. if(equali(setting, "ammo_refill")) {
  669. g_AmmoRefill = str_to_num(value) ? true : false;
  670. }
  671.  
  672. } else if(readAction == CFG_RELOAD) {
  673. g_AmmoRefill = true;
  674. }
  675. }
  676.  
  677. //Equipment Menu callback
  678. public c_Equip(id, menu, item)
  679. {
  680. if(item < 0)
  681. return PLUGIN_CONTINUE;
  682.  
  683. new cmd[6], iName[64], access, callback;
  684.  
  685. menu_item_getinfo(menu, item, access, cmd, charsmax(cmd), iName, charsmax(iName), callback);
  686.  
  687. new weapon_s, weapon_p;
  688. weapon_s = get_weaponid(g_SecWeapons[id]);
  689. weapon_p = get_weaponid(g_PrimWeapons[id]);
  690.  
  691. if(weapon_s == 0 && g_mSecStatus
  692. || weapon_p == 0 && g_mPrimStatus
  693. || IsRestricted[weapon_s]
  694. || IsRestricted[weapon_p]) {
  695. return ITEM_DISABLED;
  696. }
  697.  
  698. return ITEM_ENABLED;
  699. }
  700.  
  701. //Secondary Weapon Callback
  702. public c_Secondary(id, menu, item)
  703. {
  704. if(item < 0)
  705. return PLUGIN_CONTINUE;
  706.  
  707. new cmd[6], iName[64], access, callback;
  708.  
  709. menu_item_getinfo(menu, item, access, cmd, charsmax(cmd), iName, charsmax(iName), callback);
  710.  
  711. new dis = str_to_num(cmd);
  712. new team = _:cs_get_user_team(id);
  713. new weaptype = get_weaponid(g_Secondary[dis]);
  714.  
  715. //Check to see if item is disabled
  716. if(g_DisabledSec[dis]) {
  717. return ITEM_DISABLED;
  718.  
  719. } else if(!IsRestricted[weaptype]) {
  720. return ITEM_ENABLED;
  721.  
  722. } else if(UsedWpsT[weaptype] < RestrictWps[weaptype] && team == _TEAM_T
  723. || UsedWpsCT[weaptype] < RestrictWps[weaptype] && team == _TEAM_CT) {
  724. return ITEM_ENABLED;
  725. }
  726.  
  727. return ITEM_DISABLED;
  728. }
  729.  
  730. //Primary Weapon Callback
  731. public c_Primary(id, menu, item)
  732. {
  733. if(item < 0)
  734. return PLUGIN_CONTINUE;
  735.  
  736. // Get item info
  737. new cmd[6], iName[64], access, callback;
  738.  
  739. menu_item_getinfo(menu, item, access, cmd, charsmax(cmd), iName, charsmax(iName), callback);
  740.  
  741. new dis = str_to_num(cmd);
  742. new team = _:cs_get_user_team(id);
  743. new weaptype = get_weaponid(g_Primary[dis]);
  744.  
  745. //Check to see if item is disabled
  746. if(g_DisabledPrim[dis]) {
  747. return ITEM_DISABLED;
  748.  
  749. } else if(!IsRestricted[weaptype]) {
  750. return ITEM_ENABLED;
  751.  
  752. } else if(UsedWpsT[weaptype] < RestrictWps[weaptype] && team == _TEAM_T
  753. || UsedWpsCT[weaptype] < RestrictWps[weaptype] && team == _TEAM_CT) {
  754. return ITEM_ENABLED;
  755. }
  756.  
  757. return ITEM_DISABLED;
  758. }
  759.  
  760. //Equipment Menu handler
  761. public m_EquipHandler(id, menu, item)
  762. {
  763. if(item < 0)
  764. return PLUGIN_CONTINUE;
  765.  
  766. // Get item info
  767. new cmd[2], iName[64], access, callback;
  768.  
  769. menu_item_getinfo(menu, item, access, cmd, charsmax(cmd), iName, charsmax(iName), callback);
  770.  
  771. switch(str_to_num(cmd))
  772. {
  773. case 1:
  774. {
  775. if(g_mSecStatus)
  776. menu_display(id, g_SecMenuID, 0);
  777.  
  778. else if(g_mPrimStatus)
  779. menu_display(id, g_PrimMenuID, 0);
  780.  
  781. else if(g_mArmorStatus)
  782. menu_display(id, g_ArmorMenuID, 0);
  783.  
  784. else if(g_mNadeStatus)
  785. {
  786. if(g_mAutoArmor)
  787. equipUser(id, EQUIP_ARMOR);
  788.  
  789. menu_display(id, g_NadeMenuID, 0);
  790.  
  791. } else {
  792. if(g_mAutoArmor)
  793. equipUser(id, EQUIP_ARMOR);
  794.  
  795. if(g_mAutoNades)
  796. equipUser(id, EQUIP_GREN);
  797.  
  798. equipUser(id, EQUIP_ITEMS);
  799. }
  800. }
  801. case 2:
  802. {
  803. // Equip person with last settings
  804. equipUser(id, EQUIP_ALL);
  805. }
  806. case 3:
  807. {
  808. g_mShowuser[id] = false;
  809. client_print(id, print_chat, "");
  810. equipUser(id, EQUIP_ALL);
  811. }
  812. }
  813.  
  814. return PLUGIN_HANDLED;
  815. }
  816.  
  817. //Secondary Weapon Menu handler
  818. public m_SecHandler(id, menu, item)
  819. {
  820. if(!is_user_connected(id))
  821. return PLUGIN_HANDLED;
  822.  
  823. // Get item info
  824. new cmd[6], iName[64], access, callback;
  825.  
  826. menu_item_getinfo(menu, item, access, cmd, charsmax(cmd), iName, charsmax(iName), callback);
  827.  
  828. new wep = str_to_num(cmd);
  829.  
  830. new team = _:cs_get_user_team(id);
  831. new weaptype = get_weaponid(g_Secondary[wep]);
  832.  
  833. if((UsedWpsT[weaptype] < RestrictWps[weaptype] && team == _TEAM_T
  834. || UsedWpsCT[weaptype] < RestrictWps[weaptype] && team == _TEAM_CT)
  835. && !g_DisabledSec[wep])
  836. {
  837. copy(g_SecWeapons[id],17,g_Secondary[wep]);
  838. equipUser(id, EQUIP_SEC);
  839.  
  840. } else if(g_mSecStatus) {
  841. menu_display(id, g_SecMenuID, 0);
  842. return PLUGIN_HANDLED;
  843. }
  844.  
  845. // Show next menu here
  846.  
  847. if(g_mPrimStatus)
  848. menu_display(id, g_PrimMenuID, 0);
  849.  
  850. else if(g_mArmorStatus)
  851. menu_display(id, g_ArmorMenuID, 0);
  852.  
  853. else if(g_mNadeStatus)
  854. {
  855. if (g_mAutoArmor)
  856. equipUser(id, EQUIP_ARMOR);
  857.  
  858. menu_display(id, g_NadeMenuID, 0);
  859.  
  860. } else {
  861. if (g_mAutoArmor)
  862. equipUser(id, EQUIP_ARMOR);
  863.  
  864. if (g_mAutoNades)
  865. equipUser(id, EQUIP_GREN);
  866.  
  867. equipUser(id, EQUIP_ITEMS);
  868. }
  869.  
  870. return PLUGIN_HANDLED;
  871. }
  872.  
  873. //Primary Weapon Menu handler
  874. public m_PrimHandler(id, menu, item)
  875. {
  876. if (item < 0)
  877. return PLUGIN_HANDLED;
  878.  
  879. // Get item info
  880. new cmd[6], iName[64], access, callback;
  881.  
  882. if(menu_item_getinfo(menu, item, access, cmd, charsmax(cmd), iName, charsmax(iName), callback))
  883. {
  884. new wep = str_to_num(cmd);
  885. new team = _:cs_get_user_team(id);
  886. new weaptype = get_weaponid(g_Primary[wep]);
  887.  
  888. if((UsedWpsT[weaptype] < RestrictWps[weaptype] && team == _TEAM_T
  889. || UsedWpsCT[weaptype] < RestrictWps[weaptype] && team == _TEAM_CT)
  890. && !g_DisabledPrim[wep])
  891. {
  892. copy(g_PrimWeapons[id], charsmax(g_PrimWeapons[]), g_Primary[wep]);
  893. equipUser(id, EQUIP_PRI);
  894.  
  895. } else if (g_mPrimStatus) {
  896. menu_display(id, g_PrimMenuID, 0);
  897. return PLUGIN_HANDLED;
  898. }
  899. }
  900.  
  901. // Show next menu here
  902. if(g_mArmorStatus) {
  903. menu_display(id, g_ArmorMenuID, 0);
  904. }
  905. else if(g_mNadeStatus)
  906. {
  907. if(g_mAutoArmor)
  908. equipUser(id, EQUIP_ARMOR);
  909.  
  910. menu_display(id, g_NadeMenuID, 0);
  911.  
  912. } else {
  913. if (g_mAutoArmor)
  914. equipUser(id, EQUIP_ARMOR);
  915.  
  916. if (g_mAutoNades)
  917. equipUser(id, EQUIP_GREN);
  918.  
  919. equipUser(id, EQUIP_ITEMS);
  920. }
  921.  
  922. return PLUGIN_HANDLED;
  923. }
  924.  
  925. //Armor Menu handler
  926. public m_ArmorHandler(id, menu, item)
  927. {
  928. if(item < 0)
  929. return PLUGIN_CONTINUE;
  930.  
  931. // Get item info
  932. new cmd[6], iName[64], access, callback;
  933.  
  934. menu_item_getinfo(menu, item, access, cmd, charsmax(cmd), iName, charsmax(iName), callback);
  935.  
  936. new choice = str_to_num(cmd);
  937.  
  938. if(choice == 1) {
  939. g_mArmor[id] = true;
  940. } else if (choice == 2) {
  941. g_mArmor[id] = false;
  942. }
  943.  
  944. equipUser(id, EQUIP_ARMOR);
  945.  
  946. // Show next menu here
  947.  
  948. if(g_mNadeStatus) {
  949. menu_display(id, g_NadeMenuID, 0);
  950. } else {
  951. if (g_mAutoNades)
  952. equipUser(id, EQUIP_GREN);
  953.  
  954. equipUser(id, EQUIP_ITEMS);
  955. }
  956.  
  957. return PLUGIN_HANDLED;
  958. }
  959.  
  960. //Nade Menu handler
  961. public m_NadeHandler(id, menu, item)
  962. {
  963. if (item < 0)
  964. return PLUGIN_CONTINUE;
  965.  
  966. new cmd[6], iName[64], access, callback;
  967.  
  968. menu_item_getinfo(menu, item, access, cmd, charsmax(cmd), iName, charsmax(iName), callback);
  969.  
  970. new choice = str_to_num(cmd);
  971.  
  972. if (choice == 1) {
  973. g_mNades[id] = true;
  974. } else if (choice == 2) {
  975. g_mNades[id] = false;
  976. }
  977.  
  978. equipUser(id, EQUIP_GREN);
  979. equipUser(id, EQUIP_ITEMS);
  980.  
  981. return PLUGIN_HANDLED;
  982. }
  983.  
  984. buildMenu()
  985. {
  986. //Equip Menu
  987. menu_additem(g_EquipMenuID, "New Weapons", "1", 0, -1);
  988. menu_additem(g_EquipMenuID, "Previous Weapons", "2", 0, g_cEquip);
  989. menu_additem(g_EquipMenuID, "2+Don't show menu again", "3", 0, g_cEquip);
  990. menu_setprop(g_EquipMenuID, MPROP_EXIT, MEXIT_NEVER);
  991.  
  992. //Armor Menu
  993. menu_additem(g_ArmorMenuID, "With Armour", "1", 0, -1);
  994. menu_additem(g_ArmorMenuID, "Without Armour", "2", 0, -1);
  995. menu_setprop(g_ArmorMenuID, MPROP_EXIT, MEXIT_NEVER);
  996.  
  997. //Nade Menu
  998. menu_additem(g_NadeMenuID, "All Grenades", "1", 0, -1);
  999. menu_additem(g_NadeMenuID, "Without Grenades", "2", 0, -1);
  1000. menu_setprop(g_NadeMenuID, MPROP_EXIT, MEXIT_NEVER);
  1001.  
  1002. return PLUGIN_HANDLED;
  1003. }
  1004.  
  1005. equipUser(id, to)
  1006. {
  1007. if(!is_user_alive(id)) return;
  1008.  
  1009. new weaptype;
  1010. new team = _:cs_get_user_team(id);
  1011.  
  1012. if((to & EQUIP_SEC) && get_weaponid(g_SecWeapons[id])) {
  1013.  
  1014. //Give Secondary
  1015. GiveUserFullWeapon(id, g_SecWeapons[id]);
  1016. }
  1017.  
  1018. if((to & EQUIP_PRI) && get_weaponid(g_PrimWeapons[id])) {
  1019.  
  1020. //Give Primary
  1021. GiveUserFullWeapon(id, g_PrimWeapons[id]);
  1022. }
  1023.  
  1024. if(to & EQUIP_ARMOR)
  1025. {
  1026. //Give Armor
  1027. if(g_mAutoArmor || g_mArmor[id]) {
  1028. new armor = g_mArmor[id] ? 2 : g_Armor;
  1029. cs_set_user_armor(id, DEFAULT_ARMOR, CsArmorType:armor);
  1030. }
  1031. }
  1032.  
  1033. if(to & EQUIP_GREN)
  1034. {
  1035. //Give Nades
  1036. if(g_mNades[id] || g_mAutoNades)
  1037. {
  1038. if(g_Nade)
  1039. {
  1040.  
  1041. weaptype = get_weaponid("weapon_hegrenade");
  1042.  
  1043. if(IsRestricted[weaptype])
  1044. {
  1045.  
  1046. if(UsedWpsT[weaptype] < RestrictWps[weaptype] && team == _TEAM_T) {
  1047. UsedWpsT[weaptype]++;
  1048. GiveUserFullWeapon(id,"weapon_hegrenade");
  1049. }
  1050.  
  1051. if(UsedWpsCT[weaptype] < RestrictWps[weaptype] && team == _TEAM_CT) {
  1052. UsedWpsCT[weaptype]++;
  1053. GiveUserFullWeapon(id,"weapon_hegrenade");
  1054. }
  1055.  
  1056. } else {
  1057. GiveUserFullWeapon(id,"weapon_hegrenade");
  1058. }
  1059. }
  1060.  
  1061. if(g_Smoke)
  1062. {
  1063. weaptype = get_weaponid("weapon_smokegrenade");
  1064.  
  1065. if(IsRestricted[weaptype])
  1066. {
  1067.  
  1068. if(UsedWpsT[weaptype] < RestrictWps[weaptype] && team == _TEAM_T) {
  1069. UsedWpsT[weaptype]++;
  1070. GiveUserFullWeapon(id,"weapon_smokegrenade");
  1071. }
  1072.  
  1073. if(UsedWpsCT[weaptype] < RestrictWps[weaptype] && team == _TEAM_CT) {
  1074. UsedWpsCT[weaptype]++;
  1075. GiveUserFullWeapon(id,"weapon_smokegrenade");
  1076. }
  1077.  
  1078. } else {
  1079. GiveUserFullWeapon(id, "weapon_smokegrenade");
  1080. }
  1081. }
  1082.  
  1083. if(g_Flash && fnadesnum)
  1084. {
  1085.  
  1086. weaptype = get_weaponid("weapon_flashbang");
  1087.  
  1088. if(IsRestricted[weaptype])
  1089. {
  1090.  
  1091. if(UsedWpsT[weaptype] < RestrictWps[weaptype] && team == _TEAM_T) {
  1092. UsedWpsT[weaptype]++;
  1093. GiveUserFullWeapon(id, "weapon_flashbang");
  1094. }
  1095.  
  1096. if(UsedWpsCT[weaptype] < RestrictWps[weaptype] && team == _TEAM_CT) {
  1097. UsedWpsCT[weaptype]++;
  1098. GiveUserFullWeapon(id, "weapon_flashbang");
  1099. }
  1100.  
  1101. } else {
  1102. GiveUserFullWeapon(id, "weapon_flashbang");
  1103. }
  1104.  
  1105. if(fnadesnum == 2)
  1106. {
  1107. if(IsRestricted[weaptype])
  1108. {
  1109.  
  1110. if((UsedWpsT[weaptype] < RestrictWps[weaptype]) && (team == _TEAM_T)) {
  1111. UsedWpsT[weaptype]++;
  1112. GiveUserFullWeapon(id, "weapon_flashbang");
  1113. }
  1114.  
  1115. if((UsedWpsCT[weaptype] < RestrictWps[weaptype]) && (team == _TEAM_CT)) {
  1116. UsedWpsCT[weaptype]++;
  1117. GiveUserFullWeapon(id, "weapon_flashbang");
  1118. }
  1119.  
  1120. } else {
  1121. GiveUserFullWeapon(id, "weapon_flashbang");
  1122. }
  1123.  
  1124. }
  1125. }
  1126. }
  1127. }
  1128.  
  1129. if (to & EQUIP_ITEMS)
  1130. {
  1131. if (g_DefuseKit && (_:cs_get_user_team(id) == _TEAM_CT)) {
  1132. cs_set_user_defuse(id, 1);
  1133. }
  1134.  
  1135. if (g_NightVision) {
  1136. cs_set_user_nvg(id, 1);
  1137. }
  1138. }
  1139. }
  1140.  
  1141. GiveUserFullWeapon(id, const wp[])
  1142. {
  1143. if(!is_user_connected(id)) return;
  1144.  
  1145. /** First check to make sure the user does not have a weapon in this slot */
  1146. new wpnid = get_weaponid(wp);
  1147. new weapons[MAX_WEAPONS], num, name[24], weap, slot;
  1148. new team = _:cs_get_user_team(id);
  1149. new money = cs_get_user_money(id), AWPcost = get_pcvar_num(PcvarAWPmoney), SG550cost = get_pcvar_num(PcvarSG550money), G3SG1cost = get_pcvar_num(PcvarG3SG1money);
  1150.  
  1151. if(wpnid == CSW_AWP)
  1152. {
  1153. g_mShowuser[id] = true;
  1154. if( money >= AWPcost )
  1155. cs_set_user_money(id, money-AWPcost);
  1156. else {
  1157. menu_display(id, g_PrimMenuID, 0);
  1158. CC_SendMessage(id, "&x01[&x04%s&x01] Your don't have enough money to buy &x04AWP&x01!", szPrefix);
  1159. return;
  1160. }
  1161. }
  1162.  
  1163. if(wpnid == CSW_SG550)
  1164. {
  1165. g_mShowuser[id] = true;
  1166. if( money >= SG550cost )
  1167. cs_set_user_money(id, money-SG550cost);
  1168. else {
  1169. menu_display(id, g_PrimMenuID, 0);
  1170. CC_SendMessage(id, "&x01[&x04%s&x01] Your don't have enough money to buy &x04SG550&x01!", szPrefix);
  1171. return;
  1172. }
  1173. }
  1174.  
  1175. if(wpnid == CSW_G3SG1)
  1176. {
  1177. g_mShowuser[id] = true;
  1178. if( money >= G3SG1cost )
  1179. cs_set_user_money(id, money-G3SG1cost);
  1180. else {
  1181. menu_display(id, g_PrimMenuID, 0);
  1182. CC_SendMessage(id, "&x01[&x04%s&x01] Your don't have enough money to buy &x04G3SG1&x01!", szPrefix);
  1183. return;
  1184. }
  1185. }
  1186.  
  1187. if(wpnid == 0)
  1188. {
  1189. if(equal(wp, "weapon_shield")) {
  1190. slot = SLOT_PRIMARY;
  1191. wpnid = -1;
  1192. }
  1193.  
  1194. } else {
  1195. slot = g_WeaponSlots[wpnid];
  1196. }
  1197.  
  1198. if((slot == SLOT_SECONDARY || slot == SLOT_PRIMARY) && wpnid > 0)
  1199. {
  1200. get_user_weapons(id, weapons, num);
  1201.  
  1202. for (new i = 0; i < num; i++)
  1203. {
  1204. weap = weapons[i];
  1205.  
  1206. if(weap == wpnid)
  1207. continue;
  1208.  
  1209. if(g_WeaponSlots[weap] == slot)
  1210. {
  1211. if(slot == SLOT_SECONDARY && cs_get_user_shield(id)) {
  1212. //temporary fix!
  1213. drop_with_shield(id, weap);
  1214.  
  1215. } else {
  1216. get_weaponname(weap, name, charsmax(name));
  1217. csdm_force_drop(id, name);
  1218. }
  1219. }
  1220. }
  1221.  
  1222. } else if(slot == SLOT_PRIMARY && wpnid == -1 && cs_get_user_shield(id)) {
  1223. return;
  1224. }
  1225.  
  1226. if(slot == SLOT_PRIMARY && cs_get_user_shield(id) && wpnid > 0) {
  1227. csdm_fwd_drop(id, -1, "weapon_shield");
  1228. }
  1229.  
  1230. new item_id = csdm_give_item(id, wp);
  1231.  
  1232. if(item_id > 0)
  1233. {
  1234. if (wpnid == CSW_M4A1) {
  1235. cs_set_weapon_silen(item_id, g_Silenced[id][SILENCED_M4A1], 1);
  1236. } else if (wpnid == CSW_USP) {
  1237. cs_set_weapon_silen(item_id, g_Silenced[id][SILENCED_USP], 1);
  1238. }
  1239. }
  1240.  
  1241. if(wpnid > 0)
  1242. {
  1243. new bpammo = g_MaxBPAmmo[wpnid];
  1244.  
  1245. if(bpammo)
  1246. cs_set_user_bpammo(id, wpnid, bpammo);
  1247.  
  1248. if (IsRestricted[wpnid])
  1249. {
  1250. if ((UsedWpsT[wpnid] < RestrictWps[wpnid]) && (team == _TEAM_T)) {
  1251. UsedWpsT[wpnid]++;
  1252. }
  1253.  
  1254. if ((UsedWpsCT[wpnid] < RestrictWps[wpnid]) && (team == _TEAM_CT)) {
  1255. UsedWpsCT[wpnid]++;
  1256. }
  1257. }
  1258. }
  1259. }
  1260.  
  1261. // MAIN FUNCTION OF THE PLUGIN
  1262. public csdm_PostSpawn(player)
  1263. {
  1264. if(pv_csdm_additems)
  1265. {
  1266. if(get_pcvar_num(pv_csdm_additems)) {
  1267. return PLUGIN_CONTINUE;
  1268. }
  1269. }
  1270.  
  1271. g_Teamuser[player] = _:cs_get_user_team(player);
  1272.  
  1273. if(is_user_bot(player))
  1274. {
  1275. new i, weapon_p, weapon_s;
  1276. new randPrim = random_num(0, g_iNumBotPrim-1);
  1277. new randSec = random_num(0, g_iNumBotSec-1);
  1278.  
  1279. weapon_p = get_weaponid(g_BotPrim[randPrim]);
  1280.  
  1281. i = 0;
  1282.  
  1283. while(i < 10 && IsRestricted[weapon_p]
  1284. && (UsedWpsT[weapon_p] >= RestrictWps[weapon_p] && g_Teamuser[player] == _TEAM_T
  1285. || UsedWpsCT[weapon_p] >= RestrictWps[weapon_p] && g_Teamuser[player] == _TEAM_CT))
  1286. {
  1287. randPrim++;
  1288.  
  1289. if(randPrim >= g_iNumBotPrim)
  1290. randPrim = 0;
  1291.  
  1292. weapon_p = get_weaponid(g_BotPrim[randPrim]);
  1293.  
  1294. i++;
  1295. }
  1296.  
  1297. weapon_s = get_weaponid(g_BotSec[randSec]);
  1298.  
  1299. i = 0;
  1300.  
  1301. while(i < 10 && IsRestricted[weapon_s]
  1302. && (UsedWpsT[weapon_s] >= RestrictWps[weapon_s] && g_Teamuser[player] == _TEAM_T
  1303. || UsedWpsCT[weapon_s] >= RestrictWps[weapon_s] && g_Teamuser[player] == _TEAM_CT))
  1304. {
  1305. randSec++;
  1306.  
  1307. if(randSec >= g_iNumBotSec)
  1308. randSec = 0;
  1309.  
  1310. weapon_s = get_weaponid(g_BotSec[randSec]);
  1311.  
  1312. i++;
  1313. }
  1314.  
  1315. new randArm = random_num(0, 2);
  1316. new randGre = random_num(0, 2);
  1317.  
  1318. if(g_mPrimStatus)
  1319. GiveUserFullWeapon(player, g_BotPrim[randPrim]);
  1320.  
  1321. if(g_mSecStatus)
  1322. GiveUserFullWeapon(player, g_BotSec[randSec]);
  1323.  
  1324. g_mArmor[player] = (g_mArmorStatus && randArm);
  1325. g_mNades[player] = (g_mNadeStatus && randGre);
  1326.  
  1327. if(g_mAutoArmor || g_mArmor[player])
  1328. equipUser(player, EQUIP_ARMOR);
  1329.  
  1330. if(g_mAutoNades || g_mNades[player])
  1331. equipUser(player, EQUIP_GREN);
  1332.  
  1333. if (g_DefuseKit)
  1334. equipUser(player, EQUIP_ITEMS);
  1335.  
  1336. } else {
  1337.  
  1338. if(g_mShowuser[player])
  1339. {
  1340. new oldmenuid, newmenuid;
  1341. new bool:bEquipMenuDisp = false;
  1342.  
  1343. player_menu_info(player, oldmenuid, newmenuid); // main thing to prevent overwrite some menu by gun menu
  1344.  
  1345. if(newmenuid != -1 && (newmenuid == g_SecMenuID || newmenuid == g_PrimMenuID
  1346. || newmenuid == g_ArmorMenuID || newmenuid == g_EquipMenuID))
  1347. {
  1348. bEquipMenuDisp = true;
  1349. }
  1350.  
  1351. if(bEquipMenuDisp || oldmenuid <= 0 || g_maxdelmenutime == 0)
  1352. {
  1353. g_MenuState[player] = 1;
  1354. menu_display(player, g_EquipMenuID, 0);
  1355.  
  1356. } else {
  1357.  
  1358. new param[1];
  1359. param[0] = player;
  1360.  
  1361. if(g_maxdelmenutime > 0)
  1362. set_task(1.0, "checkmenu", 850 + player, param, 1, "b");
  1363.  
  1364. set_task(g_maxdelmenutime, "menu_delayed", 700 + player, param, 1);
  1365. }
  1366.  
  1367. } else {
  1368. g_MenuState[player] = 0;
  1369. set_task(0.2, "delay_equip", player);
  1370. // equipUser(player, EQUIP_ALL)
  1371. }
  1372. }
  1373.  
  1374. return PLUGIN_CONTINUE;
  1375. }
  1376.  
  1377. public delay_equip(id)
  1378. {
  1379. if(is_user_connected(id))
  1380. equipUser(id, EQUIP_ALL);
  1381. }
  1382.  
  1383. public enableMenu(id)
  1384. {
  1385. if(!csdm_active())
  1386. return PLUGIN_CONTINUE;
  1387.  
  1388. if(!g_mShowuser[id])
  1389. {
  1390. g_mShowuser[id] = true;
  1391. CC_SendMessage(id, "&x01[&x04%s&x01] Equip menu has been &x03activated&x01.", szPrefix);
  1392.  
  1393. if(!g_MenuState[id]) {
  1394. g_MenuState[id] = 1;
  1395. menu_display(id, g_EquipMenuID, 0);
  1396. }
  1397.  
  1398. } else if(!g_AlwaysAllowGunMenu || !g_AmmoRefill || (g_WeaponStayTime > 5)) {
  1399.  
  1400. if(!g_AlwaysAllowGunMenu)
  1401. CC_SendMessage(id, "&x01[&x04%s&x01] Equip menu is already &x03activated&x01.", szPrefix);
  1402.  
  1403. else if(!g_AmmoRefill)
  1404. CC_SendMessage(id, "&x01[&x04%s&x01] You cannot use the equip menu!", szPrefix);
  1405.  
  1406. else if(g_WeaponStayTime > 5)
  1407. CC_SendMessage(id, "&x01[&x04%s&x01] You cannot use the equip menu!", szPrefix);
  1408.  
  1409. } else {
  1410. g_MenuState[id] = 1;
  1411. menu_display(id, g_EquipMenuID, 0);
  1412. }
  1413.  
  1414. return PLUGIN_HANDLED;
  1415. }
  1416.  
  1417. public checkmenu(param[])
  1418. {
  1419. new id = param[0];
  1420.  
  1421. if(!id)
  1422. {
  1423. if(task_exists(850 + id)) {
  1424. remove_task(850 + id);
  1425. }
  1426.  
  1427. return PLUGIN_CONTINUE;
  1428. }
  1429.  
  1430. if(!is_user_connected(id))
  1431. {
  1432. if (task_exists(850 + id)) {
  1433. remove_task(850 + id);
  1434. }
  1435.  
  1436. return PLUGIN_CONTINUE;
  1437. }
  1438.  
  1439. new oldmenuid, newmenuid;
  1440. new bool:bEquipMenuDisp = false;
  1441.  
  1442. player_menu_info(id, oldmenuid, newmenuid);
  1443.  
  1444. if(newmenuid != -1 && (newmenuid == g_SecMenuID || newmenuid == g_PrimMenuID
  1445. || newmenuid == g_ArmorMenuID || newmenuid == g_EquipMenuID))
  1446. {
  1447. bEquipMenuDisp = true;
  1448. }
  1449.  
  1450. if((oldmenuid <= 0) || (bEquipMenuDisp))
  1451. {
  1452. g_MenuState[id] = 1;
  1453. menu_display(id, g_EquipMenuID, 0);
  1454.  
  1455. if (task_exists(850+id))
  1456. remove_task(850+id);
  1457.  
  1458. if (task_exists(700+id))
  1459. remove_task(700+id);
  1460. }
  1461.  
  1462. return PLUGIN_CONTINUE;
  1463. }
  1464.  
  1465. public menu_delayed(param[])
  1466. {
  1467. new id = param[0];
  1468.  
  1469. if (!id)
  1470. {
  1471. if (task_exists(700 + id)) {
  1472. remove_task(700 + id);
  1473. }
  1474.  
  1475. return PLUGIN_HANDLED;
  1476. }
  1477.  
  1478. if(!is_user_connected(id))
  1479. {
  1480.  
  1481. if (task_exists(850 + id)) {
  1482. remove_task(850 + id);
  1483. }
  1484.  
  1485. return PLUGIN_HANDLED;
  1486. }
  1487.  
  1488. g_MenuState[id] = 1;
  1489. menu_display(id, g_EquipMenuID, 0);
  1490.  
  1491. if (task_exists(700 + id))
  1492. remove_task(700 + id);
  1493.  
  1494. if (task_exists(850 + id))
  1495. remove_task(850 + id);
  1496.  
  1497. return PLUGIN_CONTINUE;
  1498. }
  1499.  
  1500. stock getWeapId(wp[]) // this one is used, because get_weaponid doesn't work when csdm_CfgInit is called (something wrong with core intitialisation?
  1501. {
  1502. if(equal(wp, "weapon_p228")) return CSW_P228;
  1503. else if(equal(wp, "weapon_scout")) return CSW_SCOUT;
  1504. else if(equal(wp, "weapon_hegrenade")) return CSW_HEGRENADE;
  1505. else if(equal(wp, "weapon_xm1014")) return CSW_XM1014;
  1506. else if(equal(wp, "weapon_c4")) return CSW_C4;
  1507. else if(equal(wp, "weapon_mac10")) return CSW_MAC10;
  1508. else if(equal(wp, "weapon_aug")) return CSW_AUG;
  1509. else if(equal(wp, "weapon_smokegrenade")) return CSW_SMOKEGRENADE;
  1510. else if(equal(wp, "weapon_elite")) return CSW_ELITE;
  1511. else if(equal(wp, "weapon_fiveseven")) return CSW_FIVESEVEN;
  1512. else if(equal(wp, "weapon_ump45")) return CSW_UMP45;
  1513. else if(equal(wp, "weapon_sg550")) return CSW_SG550;
  1514. else if(equal(wp, "weapon_galil")) return CSW_GALIL;
  1515. else if(equal(wp, "weapon_famas")) return CSW_FAMAS;
  1516. else if(equal(wp, "weapon_usp")) return CSW_USP;
  1517. else if(equal(wp, "weapon_glock18")) return CSW_GLOCK18;
  1518. else if(equal(wp, "weapon_awp")) return CSW_AWP;
  1519. else if(equal(wp, "weapon_mp5navy")) return CSW_MP5NAVY;
  1520. else if(equal(wp, "weapon_m249")) return CSW_M249;
  1521. else if(equal(wp, "weapon_m3")) return CSW_M3;
  1522. else if(equal(wp, "weapon_m4a1")) return CSW_M4A1;
  1523. else if(equal(wp, "weapon_tmp")) return CSW_TMP;
  1524. else if(equal(wp, "weapon_g3sg1")) return CSW_G3SG1;
  1525. else if(equal(wp, "weapon_flashbang")) return CSW_FLASHBANG;
  1526. else if(equal(wp, "weapon_deagle")) return CSW_DEAGLE;
  1527. else if(equal(wp, "weapon_sg552")) return CSW_SG552;
  1528. else if(equal(wp, "weapon_ak47")) return CSW_AK47;
  1529. else if(equal(wp, "weapon_knife")) return CSW_KNIFE;
  1530. else if(equal(wp, "weapon_p90")) return CSW_P90;
  1531.  
  1532. return PLUGIN_CONTINUE;
  1533. }
  1534.  
  1535. // stuff for settings menu - START
  1536. public csdm_equip_sett_menu(id, level, cid)
  1537. {
  1538. if(!cmd_access(id, level, cid, 1))
  1539. return PLUGIN_HANDLED;
  1540.  
  1541. menu_display(id, g_EquipSettMenu, 0);
  1542.  
  1543. return PLUGIN_HANDLED;
  1544. }
  1545.  
  1546. public use_csdm_equip_menu(id, menu, item)
  1547. {
  1548. if(item < 0)
  1549. return PLUGIN_CONTINUE;
  1550.  
  1551. new command[6], paccess, call;
  1552.  
  1553. if(!menu_item_getinfo(g_EquipSettMenu, item, paccess, command, charsmax(command), _, _, call)) {
  1554. log_amx("Error: csdm_menu_item() failed (menu %d) (page %d) (item %d)", g_EquipSettMenu, 0, item);
  1555. return PLUGIN_HANDLED;
  1556. }
  1557.  
  1558. if(paccess && !(get_user_flags(id) & paccess)) {
  1559. CC_SendMessage(id, "&x01[&x04%s&x01] You do not have &x04access &x01to this menu option.", szPrefix);
  1560. return PLUGIN_HANDLED;
  1561. }
  1562.  
  1563. new iChoice = str_to_num(command);
  1564.  
  1565. switch(iChoice)
  1566. {
  1567. case 1:
  1568. {
  1569. g_mPrimStatus = g_mPrimStatus? false : true;
  1570.  
  1571. CC_SendMessage(id, "&x01[&x04%s&x01] Show primary guns menu %s.", szPrefix, g_mPrimStatus ? "Включено" : "Выключено");
  1572. log_amx("CSDM displaying primary gun menu %s.", g_mPrimStatus ? "enabled" : "disabled");
  1573.  
  1574. menu_display(id, g_EquipSettMenu, 0);
  1575. write_menus_settings(id);
  1576.  
  1577. return PLUGIN_HANDLED;
  1578. }
  1579. case 2:
  1580. {
  1581. g_mSecStatus = g_mSecStatus? false : true;
  1582.  
  1583. CC_SendMessage(id, "&x01[&x04%s&x01] Show second guns menu %s.", szPrefix, g_mSecStatus ? "Включено" : "Выключено");
  1584. log_amx("CSDM displaying secondary gun menu %s.", g_mSecStatus ? "enabled" : "disabled");
  1585.  
  1586. menu_display(id, g_EquipSettMenu, 0);
  1587. write_menus_settings(id);
  1588.  
  1589. return PLUGIN_HANDLED;
  1590. }
  1591. case 3:
  1592. {
  1593. g_mArmorStatus = g_mArmorStatus? false : true;
  1594.  
  1595. if(g_mArmorStatus)
  1596. g_mAutoArmor = false;
  1597.  
  1598. CC_SendMessage(id, "&x01[&x04%s&x01] Show armour menu %s.", szPrefix, g_mArmorStatus ? "Включено" : "Выключено");
  1599. log_amx("CSDM displaying armor menu %s.", g_mArmorStatus ? "enabled" : "disabled");
  1600.  
  1601. menu_display(id, g_EquipSettMenu, 0);
  1602. write_menus_settings(id);
  1603.  
  1604. return PLUGIN_HANDLED;
  1605. }
  1606. case 4:
  1607. {
  1608. g_mNadeStatus = g_mNadeStatus? false : true;
  1609.  
  1610. if(g_mNadeStatus)
  1611. g_mAutoNades = false;
  1612.  
  1613. CC_SendMessage(id, "&x01[&x04%s&x01] Show granades menu %s.", szPrefix, g_mNadeStatus ? "Включено" : "Выключено");
  1614. log_amx("CSDM displaying nades menu %s.", g_mNadeStatus ? "enabled" : "disabled");
  1615.  
  1616. menu_display(id, g_EquipSettMenu, 0);
  1617. write_menus_settings(id);
  1618.  
  1619. return PLUGIN_HANDLED;
  1620. }
  1621. case 5:
  1622. {
  1623. if(g_Armor == 1 || g_Armor == 2) {
  1624. g_Armor = 0;
  1625. g_mAutoArmor = false;
  1626. }
  1627. else if(g_Armor == 0) {
  1628. g_Armor = 1;
  1629. g_mAutoArmor = true;
  1630. g_mArmorStatus = false;
  1631. }
  1632.  
  1633. client_print(id, print_chat, "Авто выдача брони %s.", g_mAutoArmor ? "Включена" : "Выключена");
  1634. log_amx("CSDM auto equiping players with armor %s.", g_mAutoArmor ? "enabled" : "disabled");
  1635.  
  1636. menu_display(id, g_EquipSettMenu, 0);
  1637. write_autoequip_settings(id);
  1638.  
  1639. return PLUGIN_HANDLED;
  1640. }
  1641. case 6:
  1642. {
  1643. if(g_Armor == 0 || g_Armor == 1) {
  1644. g_Armor = 2;
  1645. g_mAutoArmor = true;
  1646. g_mArmorStatus = false;
  1647. }
  1648. else if(g_Armor == 2) {
  1649. g_Armor = 1;
  1650. g_mAutoArmor = true;
  1651. g_mArmorStatus = false;
  1652. }
  1653.  
  1654. client_print(id, print_chat, "Авто выдача шлема %s.", (g_Armor == 2) ? "Включена" : "Выключена");
  1655. log_amx("CSDM auto equiping players with helmet %s.", (g_Armor == 2) ? "enabled" : "disabled");
  1656.  
  1657. menu_display(id, g_EquipSettMenu, 0);
  1658. write_autoequip_settings(id);
  1659.  
  1660. return PLUGIN_HANDLED;
  1661. }
  1662. case 7:
  1663. {
  1664. g_mAutoNades = g_mAutoNades? false : true;
  1665.  
  1666. if(g_mAutoNades)
  1667. g_mNadeStatus = false;
  1668.  
  1669. client_print(id, print_chat, "Авто выдача гранат %s.", g_mAutoNades ? "Включена" : "Выключена");
  1670. log_amx("CSDM auto equiping players with grenades %s.", g_mAutoNades ? "enabled" : "disabled");
  1671.  
  1672. menu_display(id, g_EquipSettMenu, 0);
  1673. write_autoequip_settings(id);
  1674.  
  1675. return PLUGIN_HANDLED;
  1676. }
  1677. case 8:
  1678. {
  1679. g_DefuseKit = g_DefuseKit? false : true;
  1680.  
  1681. client_print(id, print_chat, "Авто выдача щипцов (только спецназ) %s.", g_DefuseKit ? "Включена" : "Выключена");
  1682. log_amx("CSDM auto equiping players with defuser (CTs) %s.", g_DefuseKit ? "enabled" : "disabled");
  1683.  
  1684. menu_display(id, g_EquipSettMenu, 1);
  1685. write_autoequip_settings(id);
  1686.  
  1687. return PLUGIN_HANDLED;
  1688. }
  1689. case 9:
  1690. {
  1691. g_NightVision = g_NightVision? false : true;
  1692.  
  1693. client_print(id, print_chat, "Авто выдача ночного выденья %s.", g_NightVision ? "Включена" : "Выключена");
  1694. log_amx("CSDM auto equiping players with nightvision %s.", g_NightVision ? "enabled" : "disabled");
  1695.  
  1696. menu_display(id, g_EquipSettMenu, 1);
  1697. write_autoequip_settings(id);
  1698.  
  1699. return PLUGIN_HANDLED;
  1700. }
  1701. case 10:
  1702. {
  1703. g_Flash = g_Flash? false : true;
  1704.  
  1705. client_print(id, print_chat, "Использование световых гранат %s.", g_Flash ? "Включено" : "Выключено");
  1706. log_amx("CSDM usage of flashbangs is %s.", g_Flash ? "enabled" : "disabled");
  1707.  
  1708. menu_display(id, g_EquipSettMenu, 1);
  1709. write_nades_settings(id);
  1710.  
  1711. return PLUGIN_HANDLED;
  1712. }
  1713. case 11:
  1714. {
  1715. g_Smoke = g_Smoke? false : true;
  1716.  
  1717. client_print(id, print_chat, "Использование дымовых гранат %s.", g_Smoke ? "Включено" : "Выключено");
  1718. log_amx("CSDM usage of smoke grenades is %s.", g_Smoke ? "enabled" : "disabled");
  1719.  
  1720. menu_display(id, g_EquipSettMenu, 1);
  1721. write_nades_settings(id);
  1722.  
  1723. return PLUGIN_HANDLED;
  1724. }
  1725. case 12:
  1726. {
  1727. g_Nade = g_Nade? false : true;
  1728.  
  1729. client_print(id, print_chat, "Использование всех гранат %s.", g_Nade ? "Включено" : "Выключено");
  1730. log_amx("CSDM usage of he nades is %s.", g_Nade ? "enabled" : "disabled");
  1731.  
  1732. menu_display(id, g_EquipSettMenu, 1);
  1733. write_nades_settings(id);
  1734.  
  1735. return PLUGIN_HANDLED;
  1736. }
  1737. case 13:
  1738. {
  1739. g_AlwaysAllowGunMenu = g_AlwaysAllowGunMenu? false : true;
  1740.  
  1741. client_print(id, print_chat, "Использование меню экипировки всегда %s.", g_AlwaysAllowGunMenu ? "Включено" : "Выключено");
  1742. log_amx("CSDM Always Allow Gun Menu is %s.", g_AlwaysAllowGunMenu ? "enabled" : "disabled");
  1743.  
  1744. menu_display(id, g_EquipSettMenu, 1);
  1745. csdm_write_cfg(id, "equip", "always_allow_gunmenu", g_AlwaysAllowGunMenu ? "1" : "0");
  1746.  
  1747. return PLUGIN_HANDLED;
  1748. }
  1749. case 14:
  1750. {
  1751. menu_display(id, g_SettingsMenu, g_PageSettMenu);
  1752.  
  1753. return PLUGIN_HANDLED;
  1754. }
  1755. }
  1756.  
  1757. return PLUGIN_HANDLED;
  1758. }
  1759.  
  1760. public hook_equip_sett_display(player, menu, item)
  1761. {
  1762. new paccess, command[24], call;
  1763.  
  1764. menu_item_getinfo(menu, item, paccess, command, charsmax(command), _, _, call);
  1765.  
  1766. if (equali(command, "1")) {
  1767. if (g_mPrimStatus) menu_item_setname(menu, item, "Меню первичного оружия включено");
  1768. else menu_item_setname(menu, item, "Меню первичного оружия выключено");
  1769. } else if (equali(command, "2")) {
  1770. if (g_mSecStatus) menu_item_setname(menu, item, "Меню вторичного оружия включено");
  1771. else menu_item_setname(menu, item, "Меню вторичного оружия выключено");
  1772. } else if (equali(command, "3")) {
  1773. if (g_mArmorStatus) menu_item_setname(menu, item, "Меню брони включено");
  1774. else menu_item_setname(menu, item, "Меню брони выключено");
  1775. } else if (equali(command, "4")) {
  1776. if (g_mNadeStatus) menu_item_setname(menu, item, "Equip Menu Grenades Enabled");
  1777. else menu_item_setname(menu, item, "Equip Menu Grenades Disabled");
  1778. } else if (equali(command, "5")) {
  1779. if (g_mAutoArmor) menu_item_setname(menu, item, "Авто экипировка броней включена");
  1780. else menu_item_setname(menu, item, "Авто экипировка броней выключена");
  1781. } else if (equali(command, "6")) {
  1782. if (g_mAutoArmor && g_Armor == 2) menu_item_setname(menu, item, "Авто экипировка шлемом включена");
  1783. else menu_item_setname(menu, item, "Авто экипировка шлемом выключена");
  1784. } else if (equali(command, "7")) {
  1785. if (g_mAutoNades) menu_item_setname(menu, item, "Авто экипировка гранатами включена");
  1786. else menu_item_setname(menu, item, "Авто экипировка гранатами включена");
  1787. } else if (equali(command, "8")) {
  1788. if (g_DefuseKit) menu_item_setname(menu, item, "Авто экипировка щипцами включена");
  1789. else menu_item_setname(menu, item, "Авто экипировка щипцами включена");
  1790. } else if (equali(command, "9")) {
  1791. if (g_NightVision) menu_item_setname(menu, item, "Авто экипировка ночным виденьем включена");
  1792. else menu_item_setname(menu, item, "Авто экипировка ночным виденьем включена");
  1793. } else if (equali(command, "10")) {
  1794. if (g_Flash) menu_item_setname(menu, item, "Световые гранаты включены");
  1795. else menu_item_setname(menu, item, "Световые гранаты выключены");
  1796. } else if (equali(command, "11")) {
  1797. if (g_Smoke) menu_item_setname(menu, item, "Дымовые гранаты включены");
  1798. else menu_item_setname(menu, item, "Дымовые гранаты выключены");
  1799. } else if (equali(command, "12")) {
  1800. if (g_Nade) menu_item_setname(menu, item, "Разрывные гранаты включены");
  1801. else menu_item_setname(menu, item, "Разрывные гранаты выключены");
  1802. } else if (equali(command, "13")) {
  1803. if (g_AlwaysAllowGunMenu) menu_item_setname(menu, item, "Использование меню экипировки всегда, включено");
  1804. else menu_item_setname(menu, item, "Использование меню экипировки всегда, выключено");
  1805. }
  1806. }
  1807.  
  1808. public write_menus_settings(id)
  1809. {
  1810. new flags[5] = "";
  1811. new menu_flags = 0;
  1812.  
  1813. if(g_mPrimStatus)
  1814. menu_flags |= (1<<0);
  1815. if(g_mSecStatus)
  1816. menu_flags |= (1<<1);
  1817. if(g_mArmorStatus)
  1818. menu_flags |= (1<<2);
  1819. if(g_mNadeStatus)
  1820. menu_flags |= (1<<3);
  1821.  
  1822. get_flags(menu_flags, flags, charsmax(flags));
  1823.  
  1824. replace(flags, charsmax(flags), "a", "p");
  1825. replace(flags, charsmax(flags), "b", "s");
  1826. replace(flags, charsmax(flags), "c", "a");
  1827. replace(flags, charsmax(flags), "d", "g");
  1828.  
  1829. csdm_write_cfg(id, "equip", "menus", flags);
  1830. }
  1831.  
  1832. public write_autoequip_settings(id)
  1833. {
  1834. new flags[6] = "";
  1835. new auto_flags = 0;
  1836.  
  1837. if(g_mAutoArmor)
  1838. auto_flags |= (1<<0);
  1839. if(g_mAutoArmor && g_Armor == 2)
  1840. auto_flags |= (1<<1);
  1841. if(g_mAutoNades)
  1842. auto_flags |= (1<<2);
  1843. if(g_DefuseKit)
  1844. auto_flags |= (1<<3);
  1845. if(g_NightVision)
  1846. auto_flags |= (1<<4);
  1847.  
  1848. get_flags(auto_flags, flags, charsmax(flags));
  1849.  
  1850. // replace(flags, charsmax(flags), "a", "a");
  1851. replace(flags, charsmax(flags), "b", "h");
  1852. replace(flags, charsmax(flags), "c", "g");
  1853. // replace(flags, charsmax(flags), "d", "d");
  1854. replace(flags, charsmax(flags), "e", "n");
  1855.  
  1856. csdm_write_cfg(id, "equip", "autoitems", flags);
  1857. }
  1858.  
  1859. public write_nades_settings(id)
  1860. {
  1861. new flags[4] = "";
  1862. new nade_flags = 0;
  1863.  
  1864. if(g_Flash)
  1865. nade_flags |= (1<<0);
  1866. if(g_Nade)
  1867. nade_flags |= (1<<1);
  1868. if(g_Smoke)
  1869. nade_flags |= (1<<2);
  1870.  
  1871. get_flags(nade_flags, flags, charsmax(flags));
  1872.  
  1873. replace(flags, charsmax(flags), "a", "f");
  1874. replace(flags, charsmax(flags), "b", "h");
  1875. replace(flags, charsmax(flags), "c", "s");
  1876.  
  1877. csdm_write_cfg(id, "equip", "grenades", flags);
  1878. }
  1879. // stuff for settings menu - END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement