Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * MyJailbreak - Request - zoner Module.
- * by: shanapu
- * https://github.com/shanapu/MyJailbreak/
- *
- * This file is part of the MyJailbreak SourceMod Plugin.
- *
- * This program is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License, version 3.0, as published by the
- * Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program. If not, see <http://www.gnu.org/licenses/>.
- */
- /******************************************************************************
- STARTUP
- ******************************************************************************/
- //Includes
- #include <sourcemod>
- #include <sdktools>
- #include <sdkhooks>
- #include <cstrike>
- #include <colors>
- #include <autoexecconfig>
- #include <warden>
- #include <mystocks>
- //Compiler Options
- #pragma semicolon 1
- #pragma newdecls required
- //Console Variables
- ConVar gc_fzoneTime;
- ConVar gc_bzone;
- ConVar gc_bWardenAllowzone;
- ConVar gc_izoneLimit;
- ConVar gc_izoneColorRed;
- ConVar gc_izoneColorGreen;
- ConVar gc_izoneColorBlue;
- ConVar gc_sSoundzonePath;
- ConVar gc_sSoundzoneStopPath;
- ConVar gc_sCustomCommandzone;
- ConVar gc_sAdminFlagzone;
- //Booleans
- bool g_bzoned[MAXPLAYERS+1];
- bool g_bAllowzone;
- //Integers
- int g_izoneCounter[MAXPLAYERS+1];
- //Handles
- Handle zoneTimer[MAXPLAYERS+1];
- Handle zonePanel;
- Handle AllowzoneTimer;
- //Strings
- char g_sSoundzonePath[256];
- char g_sSoundzoneStopPath[256];
- char g_sAdminFlagzone[32];
- //Start
- public void zone_OnPluginStart()
- {
- //Client commands
- RegConsoleCmd("sm_zone", Command_zone, "Allows the Warden start refusing time and Terrorist to zone a game");
- //AutoExecConfig
- gc_bzone = AutoExecConfig_CreateConVar("sm_zone_enable", "1", "0 - disabled, 1 - enable zone");
- 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))");
- gc_bWardenAllowzone = AutoExecConfig_CreateConVar("sm_zone_allow", "0", "0 - disabled, 1 - Warden must allow !zone before T can use it");
- gc_izoneLimit = AutoExecConfig_CreateConVar("sm_zone_limit", "1", "Сount how many times you can use the command");
- gc_fzoneTime = AutoExecConfig_CreateConVar("sm_zone_time", "5.0", "Time the player gets to zone after warden open zone with !zone / colortime");
- 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);
- 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);
- 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);
- gc_sSoundzonePath = AutoExecConfig_CreateConVar("sm_zone_sound", "music/MyJailbreak/refuse.mp3", "Path to the soundfile which should be played for a refusing.");
- gc_sSoundzoneStopPath = AutoExecConfig_CreateConVar("sm_zone_stop_sound", "music/MyJailbreak/stop.mp3", "Path to the soundfile which should be played after a refusing.");
- 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!");
- //Hooks
- HookEvent("round_start", zone_Event_RoundStart);
- HookConVarChange(gc_sSoundzonePath, zone_OnSettingChanged);
- HookConVarChange(gc_sSoundzoneStopPath, zone_OnSettingChanged);
- HookConVarChange(gc_sAdminFlagzone, zone_OnSettingChanged);
- //FindConVar
- gc_sSoundzonePath.GetString(g_sSoundzonePath, sizeof(g_sSoundzonePath));
- gc_sSoundzoneStopPath.GetString(g_sSoundzoneStopPath, sizeof(g_sSoundzoneStopPath));
- gc_sAdminFlagzone.GetString(g_sAdminFlagzone , sizeof(g_sAdminFlagzone));
- }
- public int zone_OnSettingChanged(Handle convar, const char[] oldValue, const char[] newValue)
- {
- if (convar == gc_sSoundzonePath)
- {
- strcopy(g_sSoundzonePath, sizeof(g_sSoundzonePath), newValue);
- if (gc_bSounds.BoolValue) PrecacheSoundAnyDownload(g_sSoundzonePath);
- }
- else if (convar == gc_sSoundzoneStopPath)
- {
- strcopy(g_sSoundzoneStopPath, sizeof(g_sSoundzoneStopPath), newValue);
- if (gc_bSounds.BoolValue) PrecacheSoundAnyDownload(g_sSoundzoneStopPath);
- }
- else if (convar == gc_sAdminFlagzone)
- {
- strcopy(g_sAdminFlagzone, sizeof(g_sAdminFlagzone), newValue);
- }
- }
- /******************************************************************************
- COMMANDS
- ******************************************************************************/
- public Action Command_zone(int client, int args)
- {
- if (gc_bPlugin.BoolValue)
- {
- if (gc_bzone.BoolValue)
- {
- if (warden_iswarden(client) && gc_bWardenAllowzone.BoolValue)
- {
- if (!g_bAllowzone)
- {
- g_bAllowzone = true;
- AllowzoneTimer = CreateTimer(1.0, Timer_NoAllowzone, _, TIMER_REPEAT);
- CPrintToChatAll("%t %t", "request_tag", "request_openzone");
- }
- }
- if (!warden_iswarden(client))
- {
- if (GetClientTeam(client) == CS_TEAM_CT && IsPlayerAlive(client))
- {
- if (zoneTimer[client] == null)
- {
- if (g_bAllowzone || !gc_bWardenAllowzone.BoolValue)
- {
- if (g_izoneCounter[client] < gc_izoneLimit.IntValue)
- {
- g_izoneCounter[client]++;
- g_bzoned[client] = true;
- SetEntityRenderColor(client, gc_izoneColorRed.IntValue, gc_izoneColorGreen.IntValue, gc_izoneColorBlue.IntValue, 255);
- CPrintToChatAll("%t %t", "request_tag", "request_zoneing", client);
- g_iCountStopTime = gc_fzoneTime.IntValue;
- zoneTimer[client] = CreateTimer(gc_fzoneTime.FloatValue, Timer_ResetColorzone, client);
- if (warden_exist()) LoopClients(i) zoneMenu(i);
- if (gc_bSounds.BoolValue)EmitSoundToAllAny(g_sSoundzonePath);
- }
- else CReplyToCommand(client, "%t %t", "request_tag", "request_zonedtimes", gc_izoneLimit.IntValue);
- }
- else CReplyToCommand(client, "%t %t", "request_tag", "request_zoneallow");
- }
- else CReplyToCommand(client, "%t %t", "request_tag", "request_alreadyzoned");
- }
- else CReplyToCommand(client, "%t %t", "request_tag", "request_notalivect");
- }
- }
- }
- return Plugin_Handled;
- }
- /******************************************************************************
- EVENTS
- ******************************************************************************/
- public void zone_Event_RoundStart(Event event, char [] name, bool dontBroadcast)
- {
- LoopClients(client)
- {
- delete zoneTimer[client];
- delete AllowzoneTimer;
- g_izoneCounter[client] = 0;
- g_bzoned[client] = false;
- g_bAllowzone = false;
- if (CheckVipFlag(client, g_sAdminFlagzone)) g_izoneCounter[client] = -1;
- }
- g_iCountStopTime = gc_fzoneTime.IntValue;
- }
- /******************************************************************************
- FORWARDS LISTENING
- ******************************************************************************/
- public void zone_OnMapStart()
- {
- if (gc_bSounds.BoolValue) PrecacheSoundAnyDownload(g_sSoundzonePath);
- if (gc_bSounds.BoolValue) PrecacheSoundAnyDownload(g_sSoundzoneStopPath);
- }
- public void zone_OnConfigsExecuted()
- {
- g_iCountStopTime = gc_fzoneTime.IntValue;
- //Set custom Commands
- int iCount = 0;
- char sCommands[128], sCommandsL[12][32], sCommand[32];
- //zone Game
- gc_sCustomCommandzone.GetString(sCommands, sizeof(sCommands));
- ReplaceString(sCommands, sizeof(sCommands), " ", "");
- iCount = ExplodeString(sCommands, ",", sCommandsL, sizeof(sCommandsL), sizeof(sCommandsL[]));
- for (int i = 0; i < iCount; i++)
- {
- Format(sCommand, sizeof(sCommand), "sm_%s", sCommandsL[i]);
- if (GetCommandFlags(sCommand) == INVALID_FCVAR_FLAGS) //if command not already exist
- RegConsoleCmd(sCommand, Command_zone, "Allows the Warden start refusing time and Terrorist to zone a game");
- }
- }
- public void zone_OnClientPutInServer(int client)
- {
- g_izoneCounter[client] = 0;
- if (CheckVipFlag(client, g_sAdminFlagzone)) g_izoneCounter[client] = -1;
- g_bzoned[client] = false;
- }
- public void zone_OnClientDisconnect(int client)
- {
- delete zoneTimer[client];
- }
- /******************************************************************************
- MENUS
- ******************************************************************************/
- public Action zoneMenu(int warden)
- {
- if (warden_iswarden(warden) || warden_deputy_isdeputy(warden))
- {
- char info1[255];
- zonePanel = CreatePanel();
- Format(info1, sizeof(info1), "%T", "request_zoner", warden);
- SetPanelTitle(zonePanel, info1);
- DrawPanelText(zonePanel, "-----------------------------------");
- DrawPanelText(zonePanel, " ");
- LoopValidClients(i, true, false)
- {
- if (g_bzoned[i])
- {
- char userid[11];
- char username[MAX_NAME_LENGTH];
- IntToString(GetClientUserId(i), userid, sizeof(userid));
- Format(username, sizeof(username), "%N", i);
- DrawPanelText(zonePanel, username);
- }
- }
- DrawPanelText(zonePanel, " ");
- DrawPanelText(zonePanel, "-----------------------------------");
- Format(info1, sizeof(info1), "%T", "request_close", warden);
- DrawPanelItem(zonePanel, info1);
- SendPanelToClient(zonePanel, warden, Handler_NullCancel, 23);
- }
- }
- /******************************************************************************
- TIMER
- ******************************************************************************/
- public Action Timer_ResetColorzone(Handle timer, any client)
- {
- if (IsValidClient(client,true,false))
- {
- SetEntityRenderColor(client, 255, 255, 255, 255);
- }
- zoneTimer[client] = null;
- g_bzoned[client] = false;
- }
- public Action Timer_NoAllowzone(Handle timer)
- {
- if (g_iCountStopTime > 0)
- {
- if (g_iCountStopTime < 4)
- {
- LoopValidClients(client, false, true)
- {
- PrintCenterText(client, "%t", "request_stopcountdown_nc", g_iCountStopTime);
- }
- CPrintToChatAll("%t %t", "request_tag" , "request_stopcountdown", g_iCountStopTime);
- }
- g_iCountStopTime--;
- return Plugin_Continue;
- }
- if (g_iCountStopTime == 0)
- {
- LoopValidClients(client, false, true)
- {
- PrintCenterText(client, "%t", "request_countdownstop_nc");
- if (gc_bSounds.BoolValue)
- {
- EmitSoundToAllAny(g_sSoundzoneStopPath);
- }
- g_bAllowzone = false;
- AllowzoneTimer = null;
- g_iCountStopTime = gc_fzoneTime.IntValue;
- return Plugin_Stop;
- }
- CPrintToChatAll("%t %t", "request_tag" , "request_countdownstop");
- }
- return Plugin_Continue;
- }
Add Comment
Please, Sign In to add comment