Guest User

Untitled

a guest
Feb 8th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.43 KB | None | 0 0
  1. /*
  2. * MyJailbreak - Request Plugin.
  3. * by: shanapu
  4. * https://github.com/shanapu/MyJailbreak/
  5. *
  6. * This file is part of the MyJailbreak SourceMod Plugin.
  7. *
  8. * This program is free software; you can redistribute it and/or modify it under
  9. * the terms of the GNU General Public License, version 3.0, as published by the
  10. * Free Software Foundation.
  11. *
  12. * This program is distributed in the hope that it will be useful, but WITHOUT
  13. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  14. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  15. * details.
  16. *
  17. * You should have received a copy of the GNU General Public License along with
  18. * this program. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20.  
  21.  
  22. /******************************************************************************
  23. STARTUP
  24. ******************************************************************************/
  25.  
  26.  
  27. //Includes
  28. #include <sourcemod>
  29. #include <sdktools>
  30. #include <sdkhooks>
  31. #include <cstrike>
  32. #include <emitsoundany>
  33. #include <colors>
  34. #include <autoexecconfig>
  35. #include <mystocks>
  36.  
  37. //Optional Plugins
  38. #undef REQUIRE_PLUGIN
  39. #include <myjailbreak>
  40. #include <smartjaildoors>
  41. #define REQUIRE_PLUGIN
  42.  
  43. #include <hosties>
  44. #include <lastrequest>
  45. #include <warden>
  46.  
  47.  
  48. //Compiler Options
  49. #pragma semicolon 1
  50. #pragma newdecls required
  51.  
  52.  
  53. //Console Variables
  54. ConVar gc_bPlugin;
  55. ConVar gc_bSounds;
  56. ConVar gc_sCustomCommandRequest;
  57.  
  58.  
  59. //Booleans
  60. bool IsRequest;
  61. bool IsLR;
  62. bool gp_bMyJailBreak = false;
  63. bool gp_bSmartJailDoors = false;
  64.  
  65.  
  66. //Integers
  67. int g_iKilledBy[MAXPLAYERS+1];
  68. int g_iHasKilled[MAXPLAYERS+1];
  69.  
  70.  
  71. //Handles
  72. Handle RequestTimer;
  73.  
  74.  
  75. //Float
  76. float DeathOrigin[MAXPLAYERS+1][3];
  77.  
  78.  
  79. //Modules
  80. #include "MyJailbreak/Modules/Request/refuse.sp"
  81. #include "MyJailbreak/Modules/Request/capitulation.sp"
  82. #include "MyJailbreak/Modules/Request/heal.sp"
  83. #include "MyJailbreak/Modules/Request/repeat.sp"
  84. #include "MyJailbreak/Modules/Request/freekill.sp"
  85. #include "MyJailbreak/Modules/Request/killreason.sp"
  86. //#include "MyJailbreak/Modules/Request/freedays.sp"
  87. #include "MyJailbreak/Modules/Request/zoner.sp"
  88.  
  89.  
  90. //Info
  91. public Plugin myinfo =
  92. {
  93. name = "MyJailbreak - Request",
  94. author = "shanapu",
  95. description = "Requests - refuse, capitulation/pardon, heal",
  96. version = MYJB_VERSION,
  97. url = MYJB_URL_LINK
  98. }
  99.  
  100.  
  101. //Start
  102. public void OnPluginStart()
  103. {
  104. // Translation
  105. LoadTranslations("MyJailbreak.Request.phrases");
  106. LoadTranslations("MyJailbreak.Warden.phrases");
  107.  
  108.  
  109. //Client Commands
  110. RegConsoleCmd("sm_request", Command_RequestMenu, "Open the requests menu");
  111.  
  112.  
  113. //AutoExecConfig
  114. AutoExecConfig_SetFile("Request", "MyJailbreak");
  115. AutoExecConfig_SetCreateFile(true);
  116.  
  117. AutoExecConfig_CreateConVar("sm_request_version", MYJB_VERSION, "The version of this MyJailbreak SourceMod plugin", FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD);
  118. gc_bPlugin = AutoExecConfig_CreateConVar("sm_request_enable", "1", "0 - disabled, 1 - enable Request Plugin");
  119. gc_bSounds = AutoExecConfig_CreateConVar("sm_request_sounds_enable", "1", "0 - disabled, 1 - enable sounds ", _, true, 0.0, true, 1.0);
  120. gc_sCustomCommandRequest = AutoExecConfig_CreateConVar("sm_request_cmds", "req, requestmenu", "Set your custom chat command for requestmenu (!request (no 'sm_'/'!')(seperate with comma ', ')(max. 12 commands))");
  121.  
  122.  
  123. Refuse_OnPluginStart();
  124. Repeat_OnPluginStart();
  125. Heal_OnPluginStart();
  126. Capitulation_OnPluginStart();
  127. Freekill_OnPluginStart();
  128. KillReason_OnPluginStart();
  129. zone_OnPluginStart();
  130. //Freedays_OnPluginStart();
  131.  
  132.  
  133. AutoExecConfig_ExecuteFile();
  134. AutoExecConfig_CleanFile();
  135.  
  136.  
  137. //Hooks
  138. HookEvent("round_start", Event_RoundStart);
  139. HookEvent("round_end", Event_RoundEnd);
  140. HookEvent("player_death", Event_PlayerDeath);
  141. }
  142.  
  143.  
  144.  
  145. public void OnAllPluginsLoaded()
  146. {
  147. gp_bMyJailBreak = LibraryExists("myjailbreak");
  148. gp_bSmartJailDoors = LibraryExists("smartjaildoors");
  149. }
  150.  
  151.  
  152. public void OnLibraryRemoved(const char[] name)
  153. {
  154. if (StrEqual(name, "myjailbreak"))
  155. gp_bMyJailBreak = false;
  156. if (StrEqual(name, "smartjaildoors"))
  157. gp_bSmartJailDoors = false;
  158. }
  159.  
  160.  
  161. public void OnLibraryAdded(const char[] name)
  162. {
  163. if (StrEqual(name, "myjailbreak"))
  164. gp_bMyJailBreak = true;
  165. if (StrEqual(name, "smartjaildoors"))
  166. gp_bSmartJailDoors = true;
  167. }
  168.  
  169.  
  170.  
  171. /******************************************************************************
  172. COMMANDS
  173. ******************************************************************************/
  174.  
  175.  
  176. public Action Command_RequestMenu(int client, int args)
  177. {
  178. if (gc_bPlugin.BoolValue)
  179. {
  180. if (GetClientTeam(client) == CS_TEAM_T && IsValidClient(client, false, true))
  181. {
  182. Menu reqmenu = new Menu(Command_RequestMenuHandler);
  183.  
  184. char menuinfo19[255], menuinfo20[255], menuinfo21[255], menuinfo22[255], menuinfo29[255];
  185.  
  186. Format(menuinfo29, sizeof(menuinfo29), "%T", "request_menu_title", client);
  187. reqmenu.SetTitle(menuinfo29);
  188.  
  189. if (gc_bFreeKill.BoolValue && (!IsPlayerAlive(client)))
  190. {
  191. Format(menuinfo19, sizeof(menuinfo19), "%T", "request_menu_freekill", client);
  192. reqmenu.AddItem("freekill", menuinfo19);
  193. }
  194. if (gc_bRefuse.BoolValue && (IsPlayerAlive(client)))
  195. {
  196. Format(menuinfo19, sizeof(menuinfo19), "%T", "request_menu_refuse", client);
  197. reqmenu.AddItem("refuse", menuinfo19);
  198. }
  199. if (gc_bCapitulation.BoolValue && (IsPlayerAlive(client)))
  200. {
  201. Format(menuinfo20, sizeof(menuinfo20), "%T", "request_menu_capitulation", client);
  202. reqmenu.AddItem("capitulation", menuinfo20);
  203. }
  204. if (gc_bRepeat.BoolValue && (IsPlayerAlive(client)))
  205. {
  206. Format(menuinfo21, sizeof(menuinfo21), "%T", "request_menu_repeat", client);
  207. reqmenu.AddItem("repeat", menuinfo21);
  208. }
  209. if (gc_bHeal.BoolValue && (IsPlayerAlive(client)))
  210. {
  211. Format(menuinfo22, sizeof(menuinfo22), "%T", "request_menu_heal", client);
  212. reqmenu.AddItem("heal", menuinfo22);
  213. }
  214. reqmenu.ExitButton = true;
  215. reqmenu.ExitBackButton = true;
  216. reqmenu.Display(client, MENU_TIME_FOREVER);
  217. }
  218.  
  219. else CReplyToCommand(client, "%t %t", "request_tag", "request_notalivect");
  220. if (GetClientTeam(client) == CS_TEAM_CT && IsValidClient(client, false, true))
  221. {
  222. Menu reqmenu = new Menu(Command_RequestMenuHandler);
  223.  
  224. char menuinfo54[255], menuinfo29[255];
  225.  
  226. Format(menuinfo29, sizeof(menuinfo29), "%T", "request_menu_title", client);
  227. reqmenu.SetTitle(menuinfo29);
  228.  
  229. if (gc_bzone.BoolValue && (!IsPlayerAlive(client)))
  230. {
  231. Format(menuinfo54, sizeof(menuinfo54), "%T", "request_menu_zone", client);
  232. reqmenu.AddItem("zoner", menuinfo54);
  233. }
  234. reqmenu.ExitButton = true;
  235. reqmenu.ExitBackButton = true;
  236. reqmenu.Display(client, MENU_TIME_FOREVER);
  237. }
  238.  
  239.  
  240.  
  241. }
  242. return Plugin_Handled;
  243. }
  244.  
  245.  
  246. /******************************************************************************
  247. EVENTS
  248. ******************************************************************************/
  249.  
  250.  
  251. public void Event_RoundStart(Event event, char [] name, bool dontBroadcast)
  252. {
  253. delete RequestTimer;
  254.  
  255. IsRequest = false;
  256.  
  257. IsLR = false;
  258.  
  259. LoopClients(client)
  260. {
  261. g_iKilledBy[client] = 0;
  262. g_iHasKilled[client] = 0;
  263. }
  264. }
  265.  
  266.  
  267. //Round End
  268. public void Event_RoundEnd(Event event, char[] name, bool dontBroadcast)
  269. {
  270. IsLR = false;
  271. }
  272.  
  273.  
  274. public void Event_PlayerDeath(Event event, const char[] name, bool dontBroadcast)
  275. {
  276. int victimID = event.GetInt("userid"); // Get the dead user id
  277. int victim = GetClientOfUserId(victimID); // Get the dead clients id
  278. int attackerID = event.GetInt("attacker"); // Get the user clients id
  279. int attacker = GetClientOfUserId(attackerID); // Get the attacker clients id
  280.  
  281.  
  282. if (IsValidClient(attacker, true, false) && (attacker != victim))
  283. {
  284. g_iKilledBy[victim] = attackerID;
  285. g_iHasKilled[attacker] = victimID;
  286. }
  287. }
  288.  
  289.  
  290. /******************************************************************************
  291. FORWARDS LISTENING
  292. ******************************************************************************/
  293.  
  294.  
  295. public void OnMapStart()
  296. {
  297. Refuse_OnMapStart();
  298. Capitulation_OnMapStart();
  299. Repeat_OnMapStart();
  300. zone_OnMapStart();
  301.  
  302. //Freedays_OnMapStart();
  303.  
  304. IsLR = false;
  305. }
  306.  
  307.  
  308. public void OnConfigsExecuted()
  309. {
  310. Refuse_OnConfigsExecuted();
  311. Capitulation_OnConfigsExecuted();
  312. Heal_OnConfigsExecuted();
  313. Repeat_OnConfigsExecuted();
  314. zone_OnConfigsExecuted();
  315. //Freedays_OnConfigsExecuted();
  316.  
  317.  
  318. //Set custom Commands
  319. int iCount = 0;
  320. char sCommands[128], sCommandsL[12][32], sCommand[32];
  321.  
  322. //request
  323. gc_sCustomCommandRequest.GetString(sCommands, sizeof(sCommands));
  324. ReplaceString(sCommands, sizeof(sCommands), " ", "");
  325. iCount = ExplodeString(sCommands, ",", sCommandsL, sizeof(sCommandsL), sizeof(sCommandsL[]));
  326.  
  327. for (int i = 0; i < iCount; i++)
  328. {
  329. Format(sCommand, sizeof(sCommand), "sm_%s", sCommandsL[i]);
  330. if (GetCommandFlags(sCommand) == INVALID_FCVAR_FLAGS) //if command not already exist
  331. RegConsoleCmd(sCommand, Command_RequestMenu, "Open the requests menu");
  332. }
  333. }
  334.  
  335.  
  336. public void OnClientPutInServer(int client)
  337. {
  338. Refuse_OnClientPutInServer(client);
  339. Capitulation_OnClientPutInServer(client);
  340. Heal_OnClientPutInServer(client);
  341. Repeat_OnClientPutInServer(client);
  342. Freekill_OnClientPutInServer(client);
  343. zone_OnClientPutInServer(client);
  344. }
  345.  
  346.  
  347. public void OnClientDisconnect(int client)
  348. {
  349. Refuse_OnClientDisconnect(client);
  350. Heal_OnClientDisconnect(client);
  351. Repeat_OnClientDisconnect(client);
  352. zone_OnClientDisconnect(client);
  353.  
  354. }
  355.  
  356.  
  357. public int OnAvailableLR(int Announced)
  358. {
  359. Capitulation_OnAvailableLR(Announced);
  360. IsLR = true;
  361. }
  362.  
  363. /******************************************************************************
  364. MENUS
  365. ******************************************************************************/
  366.  
  367.  
  368. public int Command_RequestMenuHandler(Menu reqmenu, MenuAction action, int client, int selection)
  369. {
  370. if (GetClientTeam(client) == CS_TEAM_T)
  371. {
  372. if (action == MenuAction_Select)
  373. {
  374. char info[32];
  375.  
  376. reqmenu.GetItem(selection, info, sizeof(info));
  377.  
  378. if (strcmp(info, "refuse") == 0)
  379. {
  380. FakeClientCommand(client, "sm_refuse");
  381. }
  382. else if (strcmp(info, "freekill") == 0)
  383. {
  384. FakeClientCommand(client, "sm_freekill");
  385. }
  386. else if (strcmp(info, "repeat") == 0)
  387. {
  388. FakeClientCommand(client, "sm_repeat");
  389. }
  390. else if (strcmp(info, "capitulation") == 0)
  391. {
  392. FakeClientCommand(client, "sm_capitulation");
  393. }
  394. else if (strcmp(info, "heal") == 0 )
  395. {
  396. FakeClientCommand(client, "sm_heal");
  397. }
  398. }
  399. }
  400. if (GetClientTeam(client) == CS_TEAM_CT)
  401. {
  402. if (action == MenuAction_Select)
  403. {
  404. char info[32];
  405.  
  406. reqmenu.GetItem(selection, info, sizeof(info));
  407. if (strcmp(info, "zone") ==0)
  408. {
  409. FakeClientCommand(client,"sm_zone");
  410. }
  411. }
  412. }
  413. else if (action == MenuAction_Cancel)
  414. {
  415. if (selection == MenuCancel_ExitBack)
  416. {
  417. FakeClientCommand(client, "sm_menu");
  418. }
  419. }
  420. else if (action == MenuAction_End)
  421. {
  422. delete reqmenu;
  423. }
  424. }
  425.  
  426.  
  427. /******************************************************************************
  428. TIMER
  429. ******************************************************************************/
  430.  
  431.  
  432. public Action Timer_IsRequest(Handle timer, any client)
  433. {
  434. IsRequest = false;
  435. RequestTimer = null;
  436. LoopClients(i) if (g_bFreeKilled[i]) g_bFreeKilled[i] = false;
  437. }
Add Comment
Please, Sign In to add comment