Guest User

Untitled

a guest
Feb 8th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.05 KB | None | 0 0
  1. /*
  2. * MyJailbreak - Request - zoner Module.
  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 <colors>
  33. #include <autoexecconfig>
  34. #include <warden>
  35. #include <mystocks>
  36.  
  37.  
  38. //Compiler Options
  39. #pragma semicolon 1
  40. #pragma newdecls required
  41.  
  42.  
  43. //Console Variables
  44. ConVar gc_fzoneTime;
  45. ConVar gc_bzone;
  46. ConVar gc_bWardenAllowzone;
  47. ConVar gc_izoneLimit;
  48. ConVar gc_izoneColorRed;
  49. ConVar gc_izoneColorGreen;
  50. ConVar gc_izoneColorBlue;
  51. ConVar gc_sSoundzonePath;
  52. ConVar gc_sSoundzoneStopPath;
  53. ConVar gc_sCustomCommandzone;
  54. ConVar gc_sAdminFlagzone;
  55.  
  56.  
  57. //Booleans
  58. bool g_bzoned[MAXPLAYERS+1];
  59. bool g_bAllowzone;
  60.  
  61.  
  62. //Integers
  63. int g_izoneCounter[MAXPLAYERS+1];
  64.  
  65.  
  66.  
  67. //Handles
  68. Handle zoneTimer[MAXPLAYERS+1];
  69. Handle zonePanel;
  70. Handle AllowzoneTimer;
  71.  
  72.  
  73. //Strings
  74. char g_sSoundzonePath[256];
  75. char g_sSoundzoneStopPath[256];
  76. char g_sAdminFlagzone[32];
  77.  
  78.  
  79. //Start
  80. public void zone_OnPluginStart()
  81. {
  82. //Client commands
  83. RegConsoleCmd("sm_zone", Command_zone, "Allows the Warden start refusing time and Terrorist to zone a game");
  84.  
  85.  
  86. //AutoExecConfig
  87. gc_bzone = AutoExecConfig_CreateConVar("sm_zone_enable", "1", "0 - disabled, 1 - enable zone");
  88. gc_sCustomCommandzone = AutoExecConfig_CreateConVar("sm_zone_cmds", "zoner, zone", "Set your custom chat commands for zone(!zone (no 'sm_'/'!')(seperate with comma ', ')(max. 12 commands))");
  89. gc_bWardenAllowzone = AutoExecConfig_CreateConVar("sm_zone_allow", "0", "0 - disabled, 1 - Warden must allow !zone before T can use it");
  90. gc_izoneLimit = AutoExecConfig_CreateConVar("sm_zone_limit", "1", "Сount how many times you can use the command");
  91. gc_fzoneTime = AutoExecConfig_CreateConVar("sm_zone_time", "5.0", "Time the player gets to zone after warden open zone with !zone / colortime");
  92. gc_izoneColorRed = AutoExecConfig_CreateConVar("sm_zone_color_red", "205", "What color to turn the refusing Terror into (set R, G and B values to 255 to disable) (Rgb): x - red value", _, true, 0.0, true, 255.0);
  93. gc_izoneColorGreen = AutoExecConfig_CreateConVar("sm_zone_color_green", "205", "What color to turn the refusing Terror into (rGb): x - green value", _, true, 0.0, true, 255.0);
  94. gc_izoneColorBlue = AutoExecConfig_CreateConVar("sm_zone_color_blue", "0", "What color to turn the refusing Terror into (rgB): x - blue value", _, true, 0.0, true, 255.0);
  95. gc_sSoundzonePath = AutoExecConfig_CreateConVar("sm_zone_sound", "music/MyJailbreak/refuse.mp3", "Path to the soundfile which should be played for a refusing.");
  96. gc_sSoundzoneStopPath = AutoExecConfig_CreateConVar("sm_zone_stop_sound", "music/MyJailbreak/stop.mp3", "Path to the soundfile which should be played after a refusing.");
  97. gc_sAdminFlagzone = AutoExecConfig_CreateConVar("sm_zone_flag", "a", "Set flag for admin/vip to get one more zone. No flag = feature is available for all players!");
  98.  
  99.  
  100. //Hooks
  101. HookEvent("round_start", zone_Event_RoundStart);
  102. HookConVarChange(gc_sSoundzonePath, zone_OnSettingChanged);
  103. HookConVarChange(gc_sSoundzoneStopPath, zone_OnSettingChanged);
  104. HookConVarChange(gc_sAdminFlagzone, zone_OnSettingChanged);
  105.  
  106.  
  107. //FindConVar
  108. gc_sSoundzonePath.GetString(g_sSoundzonePath, sizeof(g_sSoundzonePath));
  109. gc_sSoundzoneStopPath.GetString(g_sSoundzoneStopPath, sizeof(g_sSoundzoneStopPath));
  110. gc_sAdminFlagzone.GetString(g_sAdminFlagzone , sizeof(g_sAdminFlagzone));
  111. }
  112.  
  113.  
  114. public int zone_OnSettingChanged(Handle convar, const char[] oldValue, const char[] newValue)
  115. {
  116. if (convar == gc_sSoundzonePath)
  117. {
  118. strcopy(g_sSoundzonePath, sizeof(g_sSoundzonePath), newValue);
  119. if (gc_bSounds.BoolValue) PrecacheSoundAnyDownload(g_sSoundzonePath);
  120. }
  121. else if (convar == gc_sSoundzoneStopPath)
  122. {
  123. strcopy(g_sSoundzoneStopPath, sizeof(g_sSoundzoneStopPath), newValue);
  124. if (gc_bSounds.BoolValue) PrecacheSoundAnyDownload(g_sSoundzoneStopPath);
  125. }
  126. else if (convar == gc_sAdminFlagzone)
  127. {
  128. strcopy(g_sAdminFlagzone, sizeof(g_sAdminFlagzone), newValue);
  129. }
  130. }
  131.  
  132.  
  133. /******************************************************************************
  134. COMMANDS
  135. ******************************************************************************/
  136.  
  137.  
  138. public Action Command_zone(int client, int args)
  139. {
  140. if (gc_bPlugin.BoolValue)
  141. {
  142. if (gc_bzone.BoolValue)
  143. {
  144. if (warden_iswarden(client) && gc_bWardenAllowzone.BoolValue)
  145. {
  146. if (!g_bAllowzone)
  147. {
  148. g_bAllowzone = true;
  149. AllowzoneTimer = CreateTimer(1.0, Timer_NoAllowzone, _, TIMER_REPEAT);
  150. CPrintToChatAll("%t %t", "request_tag", "request_openzone");
  151. }
  152. }
  153. if (!warden_iswarden(client))
  154. {
  155. if (GetClientTeam(client) == CS_TEAM_CT && IsPlayerAlive(client))
  156. {
  157. if (zoneTimer[client] == null)
  158. {
  159. if (g_bAllowzone || !gc_bWardenAllowzone.BoolValue)
  160. {
  161. if (g_izoneCounter[client] < gc_izoneLimit.IntValue)
  162. {
  163. g_izoneCounter[client]++;
  164. g_bzoned[client] = true;
  165. SetEntityRenderColor(client, gc_izoneColorRed.IntValue, gc_izoneColorGreen.IntValue, gc_izoneColorBlue.IntValue, 255);
  166. CPrintToChatAll("%t %t", "request_tag", "request_zoneing", client);
  167. g_iCountStopTime = gc_fzoneTime.IntValue;
  168. zoneTimer[client] = CreateTimer(gc_fzoneTime.FloatValue, Timer_ResetColorzone, client);
  169. if (warden_exist()) LoopClients(i) zoneMenu(i);
  170. if (gc_bSounds.BoolValue)EmitSoundToAllAny(g_sSoundzonePath);
  171. }
  172. else CReplyToCommand(client, "%t %t", "request_tag", "request_zonedtimes", gc_izoneLimit.IntValue);
  173. }
  174. else CReplyToCommand(client, "%t %t", "request_tag", "request_zoneallow");
  175. }
  176. else CReplyToCommand(client, "%t %t", "request_tag", "request_alreadyzoned");
  177. }
  178. else CReplyToCommand(client, "%t %t", "request_tag", "request_notalivect");
  179. }
  180. }
  181. }
  182. return Plugin_Handled;
  183. }
  184.  
  185.  
  186. /******************************************************************************
  187. EVENTS
  188. ******************************************************************************/
  189.  
  190.  
  191. public void zone_Event_RoundStart(Event event, char [] name, bool dontBroadcast)
  192. {
  193. LoopClients(client)
  194. {
  195. delete zoneTimer[client];
  196. delete AllowzoneTimer;
  197.  
  198. g_izoneCounter[client] = 0;
  199. g_bzoned[client] = false;
  200. g_bAllowzone = false;
  201. if (CheckVipFlag(client, g_sAdminFlagzone)) g_izoneCounter[client] = -1;
  202. }
  203.  
  204. g_iCountStopTime = gc_fzoneTime.IntValue;
  205. }
  206.  
  207.  
  208. /******************************************************************************
  209. FORWARDS LISTENING
  210. ******************************************************************************/
  211.  
  212.  
  213. public void zone_OnMapStart()
  214. {
  215. if (gc_bSounds.BoolValue) PrecacheSoundAnyDownload(g_sSoundzonePath);
  216. if (gc_bSounds.BoolValue) PrecacheSoundAnyDownload(g_sSoundzoneStopPath);
  217. }
  218.  
  219.  
  220. public void zone_OnConfigsExecuted()
  221. {
  222. g_iCountStopTime = gc_fzoneTime.IntValue;
  223.  
  224. //Set custom Commands
  225. int iCount = 0;
  226. char sCommands[128], sCommandsL[12][32], sCommand[32];
  227.  
  228. //zone Game
  229. gc_sCustomCommandzone.GetString(sCommands, sizeof(sCommands));
  230. ReplaceString(sCommands, sizeof(sCommands), " ", "");
  231. iCount = ExplodeString(sCommands, ",", sCommandsL, sizeof(sCommandsL), sizeof(sCommandsL[]));
  232.  
  233. for (int i = 0; i < iCount; i++)
  234. {
  235. Format(sCommand, sizeof(sCommand), "sm_%s", sCommandsL[i]);
  236. if (GetCommandFlags(sCommand) == INVALID_FCVAR_FLAGS) //if command not already exist
  237. RegConsoleCmd(sCommand, Command_zone, "Allows the Warden start refusing time and Terrorist to zone a game");
  238. }
  239. }
  240.  
  241. public void zone_OnClientPutInServer(int client)
  242. {
  243. g_izoneCounter[client] = 0;
  244. if (CheckVipFlag(client, g_sAdminFlagzone)) g_izoneCounter[client] = -1;
  245. g_bzoned[client] = false;
  246. }
  247.  
  248. public void zone_OnClientDisconnect(int client)
  249. {
  250. delete zoneTimer[client];
  251. }
  252.  
  253.  
  254. /******************************************************************************
  255. MENUS
  256. ******************************************************************************/
  257.  
  258.  
  259. public Action zoneMenu(int warden)
  260. {
  261. if (warden_iswarden(warden) || warden_deputy_isdeputy(warden))
  262. {
  263. char info1[255];
  264. zonePanel = CreatePanel();
  265. Format(info1, sizeof(info1), "%T", "request_zoner", warden);
  266. SetPanelTitle(zonePanel, info1);
  267. DrawPanelText(zonePanel, "-----------------------------------");
  268. DrawPanelText(zonePanel, " ");
  269. LoopValidClients(i, true, false)
  270. {
  271. if (g_bzoned[i])
  272. {
  273. char userid[11];
  274. char username[MAX_NAME_LENGTH];
  275. IntToString(GetClientUserId(i), userid, sizeof(userid));
  276. Format(username, sizeof(username), "%N", i);
  277. DrawPanelText(zonePanel, username);
  278. }
  279. }
  280. DrawPanelText(zonePanel, " ");
  281. DrawPanelText(zonePanel, "-----------------------------------");
  282. Format(info1, sizeof(info1), "%T", "request_close", warden);
  283. DrawPanelItem(zonePanel, info1);
  284. SendPanelToClient(zonePanel, warden, Handler_NullCancel, 23);
  285.  
  286. }
  287. }
  288.  
  289.  
  290. /******************************************************************************
  291. TIMER
  292. ******************************************************************************/
  293.  
  294.  
  295. public Action Timer_ResetColorzone(Handle timer, any client)
  296. {
  297. if (IsValidClient(client,true,false))
  298. {
  299. SetEntityRenderColor(client, 255, 255, 255, 255);
  300. }
  301. zoneTimer[client] = null;
  302. g_bzoned[client] = false;
  303. }
  304.  
  305.  
  306. public Action Timer_NoAllowzone(Handle timer)
  307. {
  308. if (g_iCountStopTime > 0)
  309. {
  310. if (g_iCountStopTime < 4)
  311. {
  312. LoopValidClients(client, false, true)
  313. {
  314. PrintCenterText(client, "%t", "request_stopcountdown_nc", g_iCountStopTime);
  315. }
  316. CPrintToChatAll("%t %t", "request_tag" , "request_stopcountdown", g_iCountStopTime);
  317. }
  318. g_iCountStopTime--;
  319. return Plugin_Continue;
  320. }
  321. if (g_iCountStopTime == 0)
  322. {
  323. LoopValidClients(client, false, true)
  324. {
  325. PrintCenterText(client, "%t", "request_countdownstop_nc");
  326. if (gc_bSounds.BoolValue)
  327. {
  328. EmitSoundToAllAny(g_sSoundzoneStopPath);
  329. }
  330. g_bAllowzone = false;
  331. AllowzoneTimer = null;
  332. g_iCountStopTime = gc_fzoneTime.IntValue;
  333. return Plugin_Stop;
  334. }
  335. CPrintToChatAll("%t %t", "request_tag" , "request_countdownstop");
  336. }
  337. return Plugin_Continue;
  338. }
Add Comment
Please, Sign In to add comment