HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #pragma semicolon 1
  2.  
  3. #include <sourcemod>
  4. #include <sdktools>
  5. #undef REQUIRE_PLUGIN
  6. #include <adminmenu>
  7.  
  8. new Handle:hTopMenu = INVALID_HANDLE;
  9.  
  10. new bool:HasUnlimitedHE[MAXPLAYERS+1] = false;
  11. new bool:HasUnlimitedFlash[MAXPLAYERS+1] = false;
  12. new bool:HasUnlimitedSmoke[MAXPLAYERS+1] = false;
  13.  
  14.  
  15. public Plugin:myinfo =
  16. {
  17. name = "Unlmited Grenades",
  18. author = "Fredd",
  19. description = "lets you give players unlmited grenades",
  20. version = "2.0",
  21. url = "http://www.sourcemod.net/"
  22. };
  23. public OnPluginStart()
  24. {
  25. CreateConVar("un_version", "2.0", "Unlimited Grenades Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
  26.  
  27. HookEvent("hegrenade_detonate", GrenadeDetonate);
  28. HookEvent("flashbang_detonate", GrenadeDetonate);
  29. HookEvent("smokegrenade_detonate", GrenadeDetonate);
  30.  
  31. RegAdminCmd("sm_unnades", Command_UnlimitedGrenades, ADMFLAG_KICK, "Give client unlmited grenades");
  32.  
  33. new Handle:topmenu;
  34. if (LibraryExists("adminmenu") && ((topmenu = GetAdminTopMenu()) != INVALID_HANDLE))
  35. OnAdminMenuReady(topmenu);
  36. }
  37. public OnAdminMenuReady(Handle:topmenu)
  38. {
  39. if (topmenu == hTopMenu)
  40. return;
  41.  
  42. hTopMenu = topmenu;
  43.  
  44. new TopMenuObject:player_commands = FindTopMenuCategory(hTopMenu, ADMINMENU_PLAYERCOMMANDS);
  45.  
  46. if (player_commands != INVALID_TOPMENUOBJECT)
  47. {
  48. AddToTopMenu(hTopMenu,
  49. "Végtelen gránát [BE])",
  50. TopMenuObject_Item,
  51. AdminMenu_EnableHE,
  52. player_commands,
  53. "",
  54. ADMFLAG_KICK);
  55.  
  56. AddToTopMenu(hTopMenu,
  57. "Végtelen gránát [KI]",
  58. TopMenuObject_Item,
  59. AdminMenu_DisableHE,
  60. player_commands,
  61. "",
  62. ADMFLAG_KICK);
  63.  
  64. AddToTopMenu(hTopMenu,
  65. "Végtelen Flash [BE]",
  66. TopMenuObject_Item,
  67. AdminMenu_EnableFlash,
  68. player_commands,
  69. "",
  70. ADMFLAG_KICK);
  71.  
  72. AddToTopMenu(hTopMenu,
  73. "Végtelen Flash [KI]",
  74. TopMenuObject_Item,
  75. AdminMenu_DisableFlash,
  76. player_commands,
  77. "",
  78. ADMFLAG_KICK);
  79.  
  80. AddToTopMenu(hTopMenu,
  81. "Végtelen füst [BE]",
  82. TopMenuObject_Item,
  83. AdminMenu_EnableSmoke,
  84. player_commands,
  85. "",
  86. ADMFLAG_KICK);
  87.  
  88. AddToTopMenu(hTopMenu,
  89. "Végtelen füst [KI]",
  90. TopMenuObject_Item,
  91. AdminMenu_DisableSmoke,
  92. player_commands,
  93. "",
  94. ADMFLAG_KICK);
  95. }
  96. }
  97. public AdminMenu_EnableHE(Handle:topmenu,TopMenuAction:action,TopMenuObject:object_id,param,String:buffer[],maxlength)
  98. {
  99. if (action == TopMenuAction_DisplayOption)
  100. Format(buffer, maxlength, "Végtelen gránát [BE]", param);
  101.  
  102. else if (action == TopMenuAction_SelectOption)
  103. DisplayEnableHEMenu(param);
  104.  
  105. }
  106. public AdminMenu_DisableHE(Handle:topmenu,TopMenuAction:action,TopMenuObject:object_id,param,String:buffer[],maxlength)
  107. {
  108. if (action == TopMenuAction_DisplayOption)
  109. Format(buffer, maxlength, "Végtelen gránát [KI]", param);
  110.  
  111. else if (action == TopMenuAction_SelectOption)
  112. DisplayDisableHEMenu(param);
  113.  
  114. }
  115. public AdminMenu_EnableFlash(Handle:topmenu,TopMenuAction:action,TopMenuObject:object_id,param,String:buffer[],maxlength)
  116. {
  117. if (action == TopMenuAction_DisplayOption)
  118. Format(buffer, maxlength, "Végtelen Flash [BE]", param);
  119.  
  120. else if (action == TopMenuAction_SelectOption)
  121. DisplayEnableFlashMenu(param);
  122.  
  123. }
  124. public AdminMenu_DisableFlash(Handle:topmenu,TopMenuAction:action,TopMenuObject:object_id,param,String:buffer[],maxlength)
  125. {
  126. if (action == TopMenuAction_DisplayOption)
  127. Format(buffer, maxlength, "Végtelen Flash [KI]", param);
  128.  
  129. else if (action == TopMenuAction_SelectOption)
  130. DisplayDisableFlashMenu(param);
  131.  
  132. }
  133. public AdminMenu_EnableSmoke(Handle:topmenu,TopMenuAction:action,TopMenuObject:object_id,param,String:buffer[],maxlength)
  134. {
  135. if (action == TopMenuAction_DisplayOption)
  136. Format(buffer, maxlength, "Végtelen Füst [BE]", param);
  137.  
  138. else if (action == TopMenuAction_SelectOption)
  139. DisplayEnableSmokehMenu(param);
  140.  
  141. }
  142. public AdminMenu_DisableSmoke(Handle:topmenu,TopMenuAction:action,TopMenuObject:object_id,param,String:buffer[],maxlength)
  143. {
  144. if (action == TopMenuAction_DisplayOption)
  145. Format(buffer, maxlength, "Végtelen Füst [KI]", param);
  146.  
  147. else if (action == TopMenuAction_SelectOption)
  148. DisplayDisableSmokeMenu(param);
  149.  
  150. }
  151. DisplayEnableHEMenu(client)
  152. {
  153. new Handle:menu = CreateMenu(MenuHandler_EnableHE);
  154.  
  155. SetMenuTitle(menu, "Végtelen Gránát [BE]");
  156. SetMenuExitBackButton(menu, true);
  157.  
  158. AddTargetsToMenu(menu, client, true, true);
  159.  
  160. DisplayMenu(menu, client, MENU_TIME_FOREVER);
  161. }
  162. DisplayDisableHEMenu(client)
  163. {
  164. new Handle:menu = CreateMenu(MenuHandler_DisableHE);
  165.  
  166. SetMenuTitle(menu, "Végtelen Gránát [KI]");
  167. SetMenuExitBackButton(menu, true);
  168.  
  169. AddTargetsToMenu(menu, client, true, true);
  170.  
  171. DisplayMenu(menu, client, MENU_TIME_FOREVER);
  172. }
  173.  
  174. DisplayEnableFlashMenu(client)
  175. {
  176. new Handle:menu = CreateMenu(MenuHandler_EnableFlash);
  177.  
  178. SetMenuTitle(menu, "Végtelen Flash (ON)");
  179. SetMenuExitBackButton(menu, true);
  180.  
  181. AddTargetsToMenu(menu, client, true, true);
  182.  
  183. DisplayMenu(menu, client, MENU_TIME_FOREVER);
  184. }
  185.  
  186. DisplayDisableFlashMenu(client)
  187. {
  188. new Handle:menu = CreateMenu(MenuHandler_DisableFlash);
  189.  
  190. SetMenuTitle(menu, "Végtelen Flash (OFF)");
  191. SetMenuExitBackButton(menu, true);
  192.  
  193. AddTargetsToMenu(menu, client, true, true);
  194.  
  195. DisplayMenu(menu, client, MENU_TIME_FOREVER);
  196. }
  197.  
  198. DisplayEnableSmokehMenu(client)
  199. {
  200. new Handle:menu = CreateMenu(MenuHandler_EnableSmoke);
  201.  
  202. SetMenuTitle(menu, "Végtelen Smoke (ON)");
  203. SetMenuExitBackButton(menu, true);
  204.  
  205. AddTargetsToMenu(menu, client, true, true);
  206.  
  207. DisplayMenu(menu, client, MENU_TIME_FOREVER);
  208. }
  209.  
  210. DisplayDisableSmokeMenu(client)
  211. {
  212. new Handle:menu = CreateMenu(MenuHandler_DisableSmoke);
  213.  
  214. SetMenuTitle(menu, "Végtelen Smoke (OFF)");
  215. SetMenuExitBackButton(menu, true);
  216.  
  217. AddTargetsToMenu(menu, client, true, true);
  218.  
  219. DisplayMenu(menu, client, MENU_TIME_FOREVER);
  220. }
  221. public MenuHandler_EnableHE(Handle:menu, MenuAction:action, param1, param2)
  222. {
  223. if (action == MenuAction_End)
  224. {
  225. CloseHandle(menu);
  226. }
  227. else if (action == MenuAction_Cancel)
  228. {
  229. if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
  230. {
  231. DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
  232. }
  233. }
  234. else if (action == MenuAction_Select)
  235. {
  236. decl String:info[32];
  237. new userid, target;
  238.  
  239. GetMenuItem(menu, param2, info, sizeof(info));
  240. userid = StringToInt(info);
  241.  
  242. if ((target = GetClientOfUserId(userid)) == 0)
  243. {
  244. PrintToChat(param1, "[SM] Játékos nem elérhető");
  245. }
  246. else if (!CanUserTarget(param1, target))
  247. {
  248. PrintToChat(param1, "[SM] A célpont nem található");
  249. }
  250. else
  251. {
  252. GiveNades(param1, target, "he", 1);
  253. }
  254. if (IsClientInGame(param1) && !IsClientInKickQueue(param1))
  255. {
  256. DisplayEnableFlashMenu(param1);
  257. }
  258. }
  259. }
  260. public MenuHandler_DisableHE(Handle:menu, MenuAction:action, param1, param2)
  261. {
  262. if (action == MenuAction_End)
  263. {
  264. CloseHandle(menu);
  265. }
  266. else if (action == MenuAction_Cancel)
  267. {
  268. if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
  269. {
  270. DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
  271. }
  272. }
  273. else if (action == MenuAction_Select)
  274. {
  275. decl String:info[32];
  276. new userid, target;
  277.  
  278. GetMenuItem(menu, param2, info, sizeof(info));
  279. userid = StringToInt(info);
  280.  
  281. if ((target = GetClientOfUserId(userid)) == 0)
  282. {
  283. PrintToChat(param1, "[SM] Játékos nem található");
  284. }
  285. else if (!CanUserTarget(param1, target))
  286. {
  287. PrintToChat(param1, "[SM] Célpont nem található");
  288. }
  289. else
  290. {
  291. GiveNades(param1, target, "he", 0);
  292. }
  293. if (IsClientInGame(param1) && !IsClientInKickQueue(param1))
  294. {
  295. DisplayDisableHEMenu(param1);
  296. }
  297. }
  298. }
  299. public MenuHandler_EnableFlash(Handle:menu, MenuAction:action, param1, param2)
  300. {
  301. if (action == MenuAction_End)
  302. {
  303. CloseHandle(menu);
  304. }
  305. else if (action == MenuAction_Cancel)
  306. {
  307. if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
  308. {
  309. DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
  310. }
  311. }
  312. else if (action == MenuAction_Select)
  313. {
  314. decl String:info[32];
  315. new userid, target;
  316.  
  317. GetMenuItem(menu, param2, info, sizeof(info));
  318. userid = StringToInt(info);
  319.  
  320. if ((target = GetClientOfUserId(userid)) == 0)
  321. {
  322. PrintToChat(param1, "[SM] Játékos nem található");
  323. }
  324. else if (!CanUserTarget(param1, target))
  325. {
  326. PrintToChat(param1, "[SM] Célpont nem található");
  327. }
  328. else
  329. {
  330. GiveNades(param1, target, "flash", 1);
  331. }
  332. if (IsClientInGame(param1) && !IsClientInKickQueue(param1))
  333. {
  334. DisplayEnableFlashMenu(param1);
  335. }
  336. }
  337. }
  338. public MenuHandler_DisableFlash(Handle:menu, MenuAction:action, param1, param2)
  339. {
  340. if (action == MenuAction_End)
  341. {
  342. CloseHandle(menu);
  343. }
  344. else if (action == MenuAction_Cancel)
  345. {
  346. if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
  347. {
  348. DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
  349. }
  350. }
  351. else if (action == MenuAction_Select)
  352. {
  353. decl String:info[32];
  354. new userid, target;
  355.  
  356. GetMenuItem(menu, param2, info, sizeof(info));
  357. userid = StringToInt(info);
  358.  
  359. if ((target = GetClientOfUserId(userid)) == 0)
  360. {
  361. PrintToChat(param1, "[SM] Játékos nem elérhető");
  362. }
  363. else if (!CanUserTarget(param1, target))
  364. {
  365. PrintToChat(param1, "[SM] Célpont nem található");
  366. }
  367. else
  368. {
  369. GiveNades(param1, target, "flash", 0);
  370. }
  371. if (IsClientInGame(param1) && !IsClientInKickQueue(param1))
  372. {
  373. DisplayDisableFlashMenu(param1);
  374. }
  375. }
  376. }
  377. public MenuHandler_EnableSmoke(Handle:menu, MenuAction:action, param1, param2)
  378. {
  379. if (action == MenuAction_End)
  380. {
  381. CloseHandle(menu);
  382. }
  383. else if (action == MenuAction_Cancel)
  384. {
  385. if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
  386. {
  387. DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
  388. }
  389. }
  390. else if (action == MenuAction_Select)
  391. {
  392. decl String.info[32];
  393. new userid, target;
  394.  
  395. GetMenuItem(menu, param2, info, sizeof(info));
  396. userid = StringToInt(info);
  397.  
  398. if ((target = GetClientOfUserId(userid)) == 0)
  399. {
  400. PrintToChat(param1, "[SM] Játékos nem elérhető");
  401. }
  402. else if (!CanUserTarget(param1, target))
  403. {
  404. PrintToChat(param1, "[SM] A celpont nem található");
  405. }
  406. else
  407. {
  408. GiveNades(param1, target, "smoke", 1);
  409. }
  410. if (IsClientInGame(param1) && !IsClientInKickQueue(param1))
  411. {
  412. DisplayEnableSmokehMenu(param1);
  413. }
  414. }
  415. }
  416. public MenuHandler_DisableSmoke(Handle:menu, MenuAction:action, param1, param2)
  417. {
  418. if (action == MenuAction_End)
  419. {
  420. CloseHandle(menu);
  421. }
  422. else if (action == MenuAction_Cancel)
  423. {
  424. if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
  425. {
  426. DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
  427. }
  428. }
  429. else if (action == MenuAction_Select)
  430. {
  431. decl String:info[32];
  432. new userid, target;
  433.  
  434. GetMenuItem(menu, param2, info, sizeof(info));
  435. userid = StringToInt(info);
  436.  
  437. if ((target = GetClientOfUserId(userid)) == 0)
  438. {
  439. PrintToChat(param1, "[SM] Játékos nem elérhető");
  440. }
  441. else if (!CanUserTarget(param1, target))
  442. {
  443. PrintToChat(param1, "[SM] A celpont nem található");
  444. }
  445. else
  446. {
  447. GiveNades(param1, target, "smoke", 0);
  448. }
  449. if (IsClientInGame(param1) && !IsClientInKickQueue(param1))
  450. {
  451. DisplayDisableSmokeMenu(param1);
  452. }
  453. }
  454. }
  455. public Action:GrenadeDetonate(Handle:event, const String:name[], bool:dontBroadcast)
  456. {
  457. new client = GetClientOfUserId(GetEventInt(event, "userid"));
  458.  
  459. if(StrEqual(name, "hegrenade_detonate"))
  460. {
  461. if(HasUnlimitedHE[client] == true)
  462. GivePlayerItem(client, "weapon_hegrenade");
  463.  
  464. return Plugin_Handled;
  465. } else if(StrEqual(name, "flashbang_detonate"))
  466. {
  467. if(HasUnlimitedFlash[client] == true)
  468. GivePlayerItem(client, "weapon_flashbang");
  469.  
  470. return Plugin_Handled;
  471. } else if(StrEqual(name, "smokegrenade_detonate"))
  472. {
  473. if(HasUnlimitedSmoke[client] == true)
  474. GivePlayerItem(client, "weapon_smokegrenade");
  475.  
  476. return Plugin_Handled;
  477. }
  478. return Plugin_Handled;
  479. }
  480. public Action:Command_UnlimitedGrenades(client, args)
  481. {
  482. if (args != 3)
  483. {
  484. ReplyToCommand(client, "[SM] Használat: sm_unades <#userid|name> <grenade> [0/1]");
  485. return Plugin_Handled;
  486. }
  487.  
  488. decl String:User[65], String:Grenade[21], String:OnOff[2];
  489.  
  490. GetCmdArg(1, User, sizeof(User));
  491. GetCmdArg(2, Grenade, sizeof(Grenade));
  492. GetCmdArg(3, OnOff, sizeof(OnOff));
  493.  
  494. if(!StrEqual(Grenade, "he") && !StrEqual(Grenade, "flash") && !StrEqual(Grenade, "smoke"))
  495. {
  496. ReplyToCommand(client, "[SM] %t", "Nem jó a gránát típus HASZNÁLAT: 'he','flash' vagy 'smoke'");
  497.  
  498. return Plugin_Handled;
  499. }
  500.  
  501. decl String:target_name[MAX_TARGET_LENGTH];
  502. decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
  503.  
  504. if ((target_count = ProcessTargetString(User, client, target_list, MAXPLAYERS, COMMAND_FILTER_ALIVE, target_name, sizeof(target_name), tn_is_ml)) <= 0)
  505. {
  506. ReplyToTargetError(client, target_count);
  507. return Plugin_Handled;
  508. }
  509.  
  510. for (new i = 0; i < target_count; i++)
  511. {
  512. GiveNades(client, target_list[i], Grenade, StringToInt(OnOff));
  513. }
  514. return Plugin_Handled;
  515. }
  516. GiveNades(clint, taget, String:Grenade[], toggle)
  517. {
  518. new String:TargetName[MAX_NAME_LENGTH+1];
  519. GetClientName(target, TargetName, sizeof(TargetName));
  520.  
  521. switch (toggle)
  522. {
  523. case 0:
  524. {
  525. if(StrEqual(Grenade, "he"))
  526. {
  527. if(HasUnlimitedHE[target] == true)
  528. {
  529. HasUnlimitedHE[target] = false;
  530.  
  531. PrintToChat(target, "\x04[SM] \x01A végtelen gránátod, KIKAPCSOLVA");
  532. ReplyToCommand(client,"[SM] %s A végtelen gránátod, KIKAPCSOLVA", TargetName);
  533.  
  534. } else if(HasUnlimitedHE[target] == false)
  535. {
  536. ReplyToCommand(client, "[SM] %s Már van végtelen HE gránátod", TargetName);
  537. }
  538. }
  539. if(StrEqual(Grenade, "flash"))
  540. {
  541. if(HasUnlimitedFlash[target] == true)
  542. {
  543. HasUnlimitedFlash[target] = false;
  544. PrintToChat(target, "\x04[SM] \x01A végtelen Flash gránátod, KIKAPCSOLVA");
  545. ReplyToCommand(client,"[SM] %s A végtelen Flash gránátod, KIKAPCSOLVA", TargetName);
  546.  
  547. } else if(HasUnlimitedFlash[target] == false)
  548. {
  549. ReplyToCommand(client, "[SM]%s Már van végtelen Flash gránátod", TargetName);
  550. }
  551. }
  552. if(StrEqual(Grenade, "smoke"))
  553. {
  554. if(HasUnlimitedSmoke[target] == true)
  555. {
  556. HasUnlimitedSmoke[target] = false;
  557. PrintToChat(target, "\x04[SM] \x01A végtelen SMOKE gránátod, KIKAPCSOLVA");
  558. ReplyToCommand(client,"[SM] %s A végtelen SMOKE gránátod, KIKAPCSOLVA", TargetName);
  559.  
  560. } else if(HasUnlimitedSmoke[target] == false)
  561. {
  562. ReplyToCommand(client, "[SM] %s Már van végtelen Smoke gránátod", TargetName);
  563. }
  564. }
  565.  
  566. }
  567. case 1:
  568. {
  569. if(StrEqual(Grenade, "he"))
  570. {
  571. if(HasUnlimitedHE[target] == false)
  572. {
  573. HasUnlimitedHE[target] = true;
  574. PrintToChat(target, "\x04[SM] \x01Te kaptál \x04Végtelen HE Gránátot");
  575. ReplyToCommand(client,"[SM] %s Te kaptál végtelen HE Gránátot", TargetName);
  576. GivePlayerItem(client, "weapon_hegrenade");
  577.  
  578. } else if(HasUnlimitedHE[target] == true)
  579. {
  580. ReplyToCommand(client, "[SM] %s Már van végtelen HE gránátod", TargetName);
  581. }
  582. }
  583. if(StrEqual(Grenade, "flash"))
  584. {
  585. if(HasUnlimitedFlash[target] == false)
  586. {
  587. HasUnlimitedFlash[target] = true;
  588. PrintToChat(target, "\x04[SM] \x01Te kaptál \x04Végtelen Flash Gránátot");
  589. ReplyToCommand(client,"[SM] %s Kapott végtelen gránátot", TargetName);
  590. GivePlayerItem(client, "weapon_flashbang");
  591.  
  592. } else if(HasUnlimitedFlash[target] == true)
  593. {
  594. ReplyToCommand(client, "[SM] %s Már van végtelen Flash gránátod", TargetName);
  595. }
  596. }
  597. if(StrEqual(Grenade, "smoke"))
  598. {
  599. if(HasUnlimitedSmoke[target] == false)
  600. {
  601. HasUnlimitedSmoke[target] = true;
  602. PrintToChat(target, "\x04[SM] \x01Te kaptál \x04Végtelen SMOKE gránátot");
  603. ReplyToCommand(client,"[SM] %s Te kaptál Végtelen SMOKE gránátot", TargetName);
  604. GivePlayerItem(client, "weapon_smokegrenade");
  605.  
  606. } else if(HasUnlimitedSmoke[target] == true)
  607. {
  608. ReplyToCommand(client, "[SM] %s Már van végtelen Smoke gránátod", TargetName);
  609. }
  610. }
  611. }
  612. }
  613. return;
  614. }
  615.