diff --git a/Simple AllTalk Manager/addons/sourcemod/configs/simple-chatcolors.cfg b/Simple AllTalk Manager/addons/sourcemod/configs/simple-chatcolors.cfg deleted file mode 100644 index 14b98c6..0000000 --- a/Simple AllTalk Manager/addons/sourcemod/configs/simple-chatcolors.cfg +++ /dev/null @@ -1,15 +0,0 @@ -"admin_colors" -{ - "groupname2" - { - "flag" "z" - "namecolor" "{green}" - "textcolor" "{olive}" - } - "groupname1" - { - "flag" "a" - "namecolor" "{teamcolor}" - "textcolor" "{green}" - } -} \ No newline at end of file diff --git a/Simple AllTalk Manager/addons/sourcemod/plugins/simple-alltalkmanager.smx b/Simple AllTalk Manager/addons/sourcemod/plugins/simple-alltalkmanager.smx index 6122756..2524e2f 100644 Binary files a/Simple AllTalk Manager/addons/sourcemod/plugins/simple-alltalkmanager.smx and b/Simple AllTalk Manager/addons/sourcemod/plugins/simple-alltalkmanager.smx differ diff --git a/Simple AllTalk Manager/addons/sourcemod/plugins/simple-donatorbenefits.smx b/Simple AllTalk Manager/addons/sourcemod/plugins/simple-donatorbenefits.smx deleted file mode 100644 index 821d61d..0000000 Binary files a/Simple AllTalk Manager/addons/sourcemod/plugins/simple-donatorbenefits.smx and /dev/null differ diff --git a/Simple AllTalk Manager/addons/sourcemod/plugins/simple-messagesuppression.smx b/Simple AllTalk Manager/addons/sourcemod/plugins/simple-messagesuppression.smx deleted file mode 100644 index cc20dad..0000000 Binary files a/Simple AllTalk Manager/addons/sourcemod/plugins/simple-messagesuppression.smx and /dev/null differ diff --git a/Simple AllTalk Manager/addons/sourcemod/plugins/simple-plugins.smx b/Simple AllTalk Manager/addons/sourcemod/plugins/simple-plugins.smx deleted file mode 100644 index ac307a3..0000000 Binary files a/Simple AllTalk Manager/addons/sourcemod/plugins/simple-plugins.smx and /dev/null differ diff --git a/Simple AllTalk Manager/addons/sourcemod/plugins/simple-spectate.smx b/Simple AllTalk Manager/addons/sourcemod/plugins/simple-spectate.smx deleted file mode 100644 index c6885b0..0000000 Binary files a/Simple AllTalk Manager/addons/sourcemod/plugins/simple-spectate.smx and /dev/null differ diff --git a/Simple AllTalk Manager/addons/sourcemod/plugins/simple-teambalancer.smx b/Simple AllTalk Manager/addons/sourcemod/plugins/simple-teambalancer.smx deleted file mode 100644 index 95beb01..0000000 Binary files a/Simple AllTalk Manager/addons/sourcemod/plugins/simple-teambalancer.smx and /dev/null differ diff --git a/Simple AllTalk Manager/addons/sourcemod/plugins/simple-teammanager.smx b/Simple AllTalk Manager/addons/sourcemod/plugins/simple-teammanager.smx deleted file mode 100644 index 81905ba..0000000 Binary files a/Simple AllTalk Manager/addons/sourcemod/plugins/simple-teammanager.smx and /dev/null differ diff --git a/Simple AllTalk Manager/addons/sourcemod/scripting/include/simple-plugins.inc b/Simple AllTalk Manager/addons/sourcemod/scripting/include/simple-plugins.inc deleted file mode 100644 index 8f21956..0000000 --- a/Simple AllTalk Manager/addons/sourcemod/scripting/include/simple-plugins.inc +++ /dev/null @@ -1,337 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Plugins -Description: - Included file for core plugin in the Simple Plugins project -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -*************************************************************************/ - -#if defined _simpleplugin_included - #endinput -#endif - -#define _simpleplugin_included - -#define CORE_INC_VERSION "1.1.$Rev$" - -#pragma semicolon 1 -#include -#undef REQUIRE_PLUGIN -#include -#define REQUIRE_PLUGIN -#undef REQUIRE_EXTENSIONS -#undef AUTOLOAD_EXTENSIONS -#tryinclude -#tryinclude -#tryinclude -#define AUTOLOAD_EXTENSIONS -#define REQUIRE_EXTENSIONS - -enum e_SupportedMods -{ - GameType_Unknown, - GameType_AOC, - GameType_CSS, - GameType_DOD, - GameType_FF, - GameType_HIDDEN, - GameType_HL2DM, - GameType_INS, - GameType_L4D, - GameType_NEO, - GameType_SGTLS, - GameType_TF, - GameType_ZPS -}; - -enum e_Teams -{ - Unknown, - Spectator, - Team1, - Team2 -}; - -new g_aCurrentTeams[e_Teams]; -new e_SupportedMods:g_CurrentMod; -new String:g_sGameName[e_SupportedMods][32] = { "Unknown", - "Age of Chivalry", - "Counter Strike", - "Day Of Defeat", - "Fortress Forever", - "Hidden: Source", - "Half Life 2: Deathmatch", - "Insurgency", - "Left 4 Dead", - "Neotokyo", - "Stargate TLS", - "Team Fortress 2", - "Zombie Panic: Source" - }; - -public SharedPlugin:_pl_simpleplugin = -{ - name = "simple-plugins", - file = "simple-plugins.smx", -#if defined REQUIRE_PLUGIN - required = 1 -#else - required = 0 -#endif -}; - -#if !defined REQUIRE_PLUGIN -public _pl_simpleplugin_SetNTVOptional() -{ - MarkNativeAsOptional("SM_MovePlayer"); - MarkNativeAsOptional("SM_SetForcedTeam"); - MarkNativeAsOptional("SM_GetForcedTeam"); - MarkNativeAsOptional("SM_ClearForcedTeam"); - MarkNativeAsOptional("SM_GetForcedPlayer"); - MarkNativeAsOptional("SM_AssignBuddy"); - MarkNativeAsOptional("SM_SearchBuddy"); - MarkNativeAsOptional("SM_LockBuddy"); - MarkNativeAsOptional("SM_IsBuddyLocked"); - MarkNativeAsOptional("SM_ClearBuddy"); - MarkNativeAsOptional("SM_IsValidAdmin"); - MarkNativeAsOptional("SM_IsValidTeam"); -} -#endif - -/********************************************************************** - * When a player has to moved - * - * @param plugin Plugin that initiated the move - * @param client The client index of the player that was moved - * @param team The team index the player was moved to - * @noreturn - **********************************************************************/ -forward SM_OnPlayerMoved(Handle:plugin, client, team); - -/********************************************************************** - * Move a player to the supplied team - * - * @param client The client index of the player to be moved - * @param team The team to move the player to - * @noreturn - * @error Invalid client or team index - **********************************************************************/ -native SM_MovePlayer(client, team); - -/********************************************************************** - * Move a player to the supplied team - * - * @param client The client index of the player to set - * @param team The team to move the to set - * @param override Whether or not to override another plugin - * @return True if successful, false if not - * @error Invalid client or team index - **********************************************************************/ -native SM_SetForcedTeam(client, team, bool:override = false); - -/********************************************************************** - * Gets the client's forced team index - * - * @param client The client index of the player to check - * @param plugin Optional: The plugin handle of the plugin - that set the team - * @return The team index of the forced team - Zero if no forced team - * @error Invalid client index - **********************************************************************/ -native SM_GetForcedTeam(client, &Handle:plugin = INVALID_HANDLE); - -/********************************************************************** - * Clears a client's forced team - * - * @param client The client index of the player to check - * @return True if successful, false if not - * @error Invalid client index - **********************************************************************/ -native SM_ClearForcedTeam(client); - -/********************************************************************** - * Gets a forced player on the wrong that is currently on the wrong team - * This will only return a player if the calling plugin assigned the team - * - * @param team The team index the player should be on - * @return The client index of the player - Zero if no player found - * @error Invalid client index - **********************************************************************/ -native SM_GetForcedPlayer(team); - -/********************************************************************** - * Assign a players buddy - * - * @param client The client index of the player to assign - * @param player The player index of the player to assign - * @param override Whether or not to override a player lock - * @return True if successful, false if not - * @error Invalid client or player index - **********************************************************************/ -native bool:SM_AssignBuddy(client, player, bool:override = false); - -/********************************************************************** - * Rturns the client's buddy - * - * @param client The client index of the player to assign - * @return The client index of the player's buddy - Zero if no buddy - * @error Invalid client index - **********************************************************************/ -native SM_GetClientBuddy(client); - -/********************************************************************** - * Set the buddy lock setting for a client - * - * @param client The client index of the player to assign - * @param setting Setting to set, True or False - * @return True if successful, false if not - * @error Invalid client index - **********************************************************************/ -native bool:SM_LockBuddy(client, bool:setting); - -/********************************************************************** - * Returns the buddy lock setting for a client - * - * @param client The client index of the player to assign - * @return True if locked, false if not - * @error Invalid client index - **********************************************************************/ -native bool:SM_IsBuddyLocked(client); - -/********************************************************************** - * Clear a players buddy - * - * @param client The client index of the player to clear - * @param override Whether or not to override a player lock - * @return True if successful, false if not - * @error Invalid client index - **********************************************************************/ -native bool:SM_ClearBuddy(client, bool:override = false); - -/********************************************************************** - * Determine if the player has the supplied flags - * ADMFLAG_ROOT will always return true - * - * @param client The client index of the player to assign - * @param flags The char flag(s) to check against - * @return True if valid, false if not - **********************************************************************/ -native bool:SM_IsValidAdmin(client, const String:flags[]); - - -/********************************************************************** - * Determine if the team is a valid team - * - * @param team The team index to determine if valid for - currently installed/supported mod - * @return True if valid, false if not - **********************************************************************/ -native bool:SM_IsValidTeam(team); - - -public e_SupportedMods:GetCurrentMod() -{ - new String:sGameType[64]; - GetGameFolderName(sGameType, sizeof(sGameType)); - - if (StrEqual(sGameType, "aoc", false)) - { - return GameType_AOC; - } - if (StrEqual(sGameType, "cstrike", false)) - { - return GameType_CSS; - } - if (StrEqual(sGameType, "dod", false)) - { - return GameType_DOD; - } - if (StrEqual(sGameType, "ff", false)) - { - return GameType_FF; - } - if (StrEqual(sGameType, "hidden", false)) - { - return GameType_HIDDEN; - } - if (StrEqual(sGameType, "hl2mp", false)) - { - return GameType_FF; - } - if (StrEqual(sGameType, "insurgency", false) || StrEqual(sGameType, "ins", false)) - { - return GameType_INS; - } - if (StrEqual(sGameType, "l4d", false)) - { - return GameType_L4D; - } - if (StrEqual(sGameType, "nts", false)) - { - return GameType_NEO; - } - if (StrEqual(sGameType, "sgtls", false)) - { - return GameType_SGTLS; - } - if (StrEqual(sGameType, "tf", false)) - { - return GameType_TF; - } - if (StrEqual(sGameType, "zps", false)) - { - return GameType_ZPS; - } - return GameType_Unknown; -} - -public LoadCurrentTeams() -{ - switch (g_CurrentMod) - { - case GameType_INS: - { - g_aCurrentTeams[Unknown] = 0; - g_aCurrentTeams[Spectator] = 3; - g_aCurrentTeams[Team1] = 1; - g_aCurrentTeams[Team2] = 2; - } - case default: - { - g_aCurrentTeams[Unknown] = 0; - g_aCurrentTeams[Spectator] = 1; - g_aCurrentTeams[Team1] = 2; - g_aCurrentTeams[Team2] = 3; - } - } -} diff --git a/Simple AllTalk Manager/addons/sourcemod/scripting/simple-alltalkmanager.sp b/Simple AllTalk Manager/addons/sourcemod/scripting/simple-alltalkmanager.sp index c848332..9d9ec82 100644 --- a/Simple AllTalk Manager/addons/sourcemod/scripting/simple-alltalkmanager.sp +++ b/Simple AllTalk Manager/addons/sourcemod/scripting/simple-alltalkmanager.sp @@ -97,7 +97,8 @@ public OnPluginStart() /** Remove the notify flag from all talk cvar since we do it */ - SetConVarFlags(satm_alltalk, GetConVarFlags(satm_alltalk)~FCVAR_NOTIFY); + new iCvarFlags = GetConVarFlags(satm_alltalk)^FCVAR_NOTIFY; + SetConVarFlags(satm_alltalk, iCvarFlags); /** Get the game type. We only care if it's TF2 diff --git a/Simple AllTalk Manager/addons/sourcemod/scripting/simple-autoscrambler.sp b/Simple AllTalk Manager/addons/sourcemod/scripting/simple-autoscrambler.sp deleted file mode 100644 index 6c6799e..0000000 --- a/Simple AllTalk Manager/addons/sourcemod/scripting/simple-autoscrambler.sp +++ /dev/null @@ -1,459 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple AutoScrambler -Description: - Automatically scrambles the teams based upon a number of events. -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include - -#define PLUGIN_VERSION "1.1.$Rev$" - -/** -Different scramble modes: - -1 = Full Scramble, dont restart round. -2 = Admins Immune, dont restart round. -3 = Full Scramble, restart round and reset scores. -4 = Admins Immune, restart round and reset scores. - -*/ - -/** -Different top player modes: - -1 = Divide Top 4 players on the two teams. -2 = Protect the Top 2 players on each team. - -*/ - -enum PlayerData -{ - Handle:hForcedTimer, - bool:bProtected; -}; - -/** -Cvars used for admins -*/ -new Handle: sas_admin_immunity_enabled = INVALID_HANDLE, - Handle: sas_admin_flag_scramblenow = INVALID_HANDLE, - Handle: sas_admin_flag_immunity = INVALID_HANDLE; - -/** -Cvars used for autoscramble -*/ -new Handle: sas_autoscramble_enabled = INVALID_HANDLE, - Handle: sas_autoscramble_minplayers = INVALID_HANDLE, - Handle: sas_autoscramble_mode = INVALID_HANDLE, - Handle: sas_autoscramble_winstreak = INVALID_HANDLE, - Handle: sas_autoscramble_steamroll = INVALID_HANDLE, - Handle: sas_autoscramble_frags = INVALID_HANDLE; - -/** -Cvars used for voting -*/ -new Handle: sas_vote_enabled = INVALID_HANDLE, - Handle: sas_vote_upcount = INVALID_HANDLE, - Handle: sas_vote_winpercent = INVALID_HANDLE, - Handle: sas_vote_mode = INVALID_HANDLE, - Handle: sas_vote_minplayers = INVALID_HANDLE; - -/** -Additional cvars -*/ -new Handle: sas_enabled = INVALID_HANDLE, - Handle: sas_timer_scrambledelay = INVALID_HANDLE, - Handle: TFGameModeArena = INVALID_HANDLE; - -/** -Timers -*/ -new Handle: g_hScrambleTimer = INVALID_HANDLE; - -/** - Player arrays - */ -new g_aPlayers[MAXPLAYERS + 1][PlayerData]; - -/** - Cvar variables - */ -new bool: g_bIsEnabled, - bool: g_bIsAutoScrambleEnabled, - bool: g_bIsVoteEnabled, - bool: g_bIsAdminImmunityEnabled; -new Float: g_fTimer_ScrambleDelay, - Float: g_fVote_UpCount, - Float: g_fVote_WinPercent; -new g_iAutoScramble_Minplayers, - g_iAutoScramble_Mode, - g_iAutoScramble_WinStreak, - g_iAutoScramble_SteamRoll, - g_iAutoScramble_Frags, - g_iVote_Mode, - g_iVote_MinPlayers; -new String: g_sScrambleNowFlag[5], - String: g_sAdminImmunityFlag[5]; - -/** -Other globals -*/ -new g_iMaxEntities, - g_iOwnerOffset; - -public Plugin:myinfo = -{ - name = "Simple AutoScrambler", - author = "Simple Plugins", - description = "Automatically scrambles the teams based upon a number of events.", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -}; - -public OnPluginStart() -{ - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook the game events - */ - LogAction(0, -1, "[SAS] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - switch (g_CurrentMod) - { - case GameType_TF: - { - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - } - case GameType_DOD: - { - HookEvent("dod_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_Post); - } - default: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_Post); - } - } - - /** - Create console variables - */ - CreateConVar("sas_version", PLUGIN_VERSION, "Simple AutoScrambler Version",FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - sas_enabled = CreateConVar("sas_enabled", "1", "Enable/Disable Simple AutoScrambler"); - sas_timer_scrambledelay = CreateConVar("sas_timer_scrambledelay", "5.0", "Delay used after a scramble has been started", _, true, 1.0, true, 30.0); - - /** - Cvars used for admins - */ - sas_admin_immunity_enabled = CreateConVar("sas_admin_immunity_enabled", "1", "Enable/Disable admin immunity for scrambles"); - sas_admin_flag_scramblenow = CreateConVar("sas_admin_flag_scramblenow", "z", "Admin flag to use for scramblenow function/command"); - sas_admin_flag_immunity = CreateConVar("sas_admin_flag_immunity", "z", "Admin flag to use for scramble immunity"); - - /** - Cvars used for autoscramble - */ - sas_autoscramble_enabled = CreateConVar("sas_autoscramble_enabled", "1", "Enable/Disable the autoscramble function"); - sas_autoscramble_minplayers = CreateConVar("sas_autoscramble_minplayers", "16", "Min players needed to start an autoscramble"); - sas_autoscramble_mode = CreateConVar("sas_autoscramble_mode", "1", "Scramble mode used when autoscrambling"); - sas_autoscramble_winstreak = CreateConVar("sas_autoscramble_winstreak", "5", "Max amount of wins in a row a team can achieve before an autoscramble starts"); - sas_autoscramble_steamroll = CreateConVar("sas_autoscramble_steamroll", "120", "Shortest amount of time a team can win by before an autoscramble starts (seconds)"); - sas_autoscramble_frags = CreateConVar("sas_autoscramble_frags", "1", "Min players needed to start a vote and scramble"); - - /** - Cvars used for voting - */ - sas_vote_enabled = CreateConVar("sas_vote_enabled", "1", "Enable/Disable voting for scramble"); - sas_vote_upcount = CreateConVar("sas_vote_upcount", "5", "Amount of people wanting a scramble before a vote starts. If less than 1 it will be considered a percentage. (ie 0.5 = 50% | 1 = 1 Player | 5 = 5 Players)"); - sas_vote_winpercent = CreateConVar("sas_vote_winpercent", "0.6", "Percentage of votes needed to scramble", _, true, 0.0, true, 1.0); - sas_vote_mode = CreateConVar("sas_vote_mode", "1", "Scramble mode used when a vote results in a scramble"); - sas_vote_minplayers = CreateConVar("sas_vote_minplayers", "16", "Min players needed to start a vote and scramble"); - - /** - Hook the console variables if they change - */ - HookConVarChange(sas_enabled, ConVarSettingsChanged); - HookConVarChange(sas_timer_scrambledelay, ConVarSettingsChanged); - HookConVarChange(sas_admin_immunity_enabled, ConVarSettingsChanged); - HookConVarChange(sas_admin_flag_scramblenow, ConVarSettingsChanged); - HookConVarChange(sas_admin_flag_immunity, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_enabled, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_minplayers, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_mode, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_winstreak, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_steamroll, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_frags, ConVarSettingsChanged); - HookConVarChange(sas_vote_enabled, ConVarSettingsChanged); - HookConVarChange(sas_vote_upcount, ConVarSettingsChanged); - HookConVarChange(sas_vote_winpercent, ConVarSettingsChanged); - HookConVarChange(sas_vote_mode, ConVarSettingsChanged); - HookConVarChange(sas_vote_minplayers, ConVarSettingsChanged); - - /** - Register the command - */ - RegConsoleCmd("sm_scramblenow", Command_ScrambleNow, "sm_scramblenow (mode): Scrambles the teams"); - - /** - Load translations and .cfg file - */ - LoadTranslations ("simpleautoscrambler.phrases"); - AutoExecConfig(true, "plugin.simpleautoscrambler"); - LogAction(0, -1, "[SAS] Simple AutoScrambler is loaded."); -} - -public OnAllPluginsLoaded() -{ - //something -} - -public OnLibraryRemoved(const String:name[]) -{ - //something -} - -public OnConfigsExecuted() -{ - - /** - Load up all the variable defaults - */ - LoadUpVariables(); - - /** - Log our activity - */ - if (g_bIsEnabled) - LogAction(0, -1, "Simple AutoScrambler is ENABLED"); - else - LogAction(0, -1, "Simple AutoScrambler is DISABLED"); -} - -public Action:Command_ScrambleNow(client, args) -{ - - /** - Make sure we are enabled - */ - if (!g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - Make sure the client is authorized to run this command. - */ - if (!SM_IsValidAdmin(client, g_sScrambleNowFlag)) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Make sure it's ok to scramble at this time - */ - if (!OkToScramble) - { - return Plugin_Handled; - } - - /** - Make sure it's ok to scramble at this time - */ - LogAction(0, -1, "[SAS] The scramblenow command was used"); - - /** - Scramble the teams - */ - StartAScramble(); - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public HookRoundStart(Handle:event, const String:name[], bool:dontBroadcast) -{ - -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - -} - -public Action:Timer_ScrambleTeams(Handle:timer, any:mode) -{ - - /** - Make sure it's still ok to scramble - */ - if (!OkToScramble) - { - return Plugin_Handled; - } - - - switch (mode) - { - case - - - - } - - - /** - Reset the handle because the timer is over and the callback is done - */ - g_hScrambleTimer = INVALID_HANDLE; - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - -} - -stock StartAScramble(mode) -{ - - /** - See if we are already started a scramble - */ - if (g_hScrambleTimer == INVALID_HANDLE) - { - - /** - There is a scramble in progress - */ - return; - - } - - /** - Report that a scramble is about to start - */ - PrintCenterTextAll("%T", "Scramble", LANG_SERVER); - - /** - Start a timer and log the action - */ - g_hScrambleTimer = CreateTimer(g_fTimer_ScrambleDelay, Timer_ScrambleTeams, mode, TIMER_FLAG_NO_MAPCHANGE); - LogAction(0, -1, "[SAS] A scamble timer was started"); -} - -stock bool:OkToScramble() -{ - -} - -stock LoadUpVariables() -{ - g_bIsEnabled = GetConVarBool(sas_enabled); - g_bIsAutoScrambleEnabled = GetConVarBool(sas_autoscramble_enabled); - g_bIsVoteEnabled = GetConVarBool(sas_vote_enabled); - g_bIsAdminImmunityEnabled = GetConVarBool(sas_admin_immunity_enabled); - g_iAutoScramble_Minplayers = GetConVarInt(sas_autoscramble_minplayers); - g_iAutoScramble_Mode = GetConVarInt(sas_autoscramble_mode); - g_iAutoScramble_WinStreak = GetConVarInt(sas_autoscramble_winstreak); - g_iAutoScramble_SteamRoll = GetConVarInt(sas_autoscramble_steamroll); - g_iAutoScramble_Frags = GetConVarInt(sas_autoscramble_frags); - g_iVote_Mode = GetConVarInt(sas_vote_mode); - g_iVote_MinPlayers = GetConVarInt(sas_vote_minplayers); - GetConVarString(sas_admin_flag_scramblenow, g_sScrambleNowFlag, sizeof(g_sScrambleNowFlag)); - GetConVarString(sas_admin_flag_immunity, g_sAdminImmunityFlag, sizeof(g_sAdminImmunityFlag)); - g_fTimer_ScrambleDelay = GetConVarFloat(sas_timer_scrambledelay); - g_fVote_UpCount = GetConVarFloat(sas_vote_upcount); - g_fVote_WinPercent = GetConVarFloat(sas_vote_winpercent); - g_iMaxEntities = GetMaxEntities(); - g_iOwnerOffset = FindSendPropInfo("CBaseObject", "m_hBuilder"); -} - -stock TF2_DestroyBuildings(client) -{ - - /** - We have to start a loop to check the owner of all the valid entities - */ - for (new i = MaxClients + 1; i <= g_iMaxEntities; i++) - { - if (!IsValidEntity(i)) - { - - /** - Not valid, continue to next one - */ - continue; - } - - /** - Get the name of the current entity - */ - decl String:sNetClass[32]; - GetEntityNetClass(i, sNetClass, sizeof(sNetClass)); - - /** - See if its something that an engineer would build - */ - if (strcmp(sNetClass, "CObjectSentrygun") == 0 - || strcmp(sNetClass, "CObjectTeleporter") == 0 - || strcmp(sNetClass, "CObjectDispenser") == 0) - { - - /** - It is, so lets check the owner - */ - if (GetEntDataEnt2(i, g_iOwnerOffset) == client) - { - - /** - It's the clients building, so we blow it up. - */ - SetVariantInt(9999); - AcceptEntityInput(i, "RemoveHealth"); - } - } - } -} \ No newline at end of file diff --git a/Simple AllTalk Manager/addons/sourcemod/scripting/simple-chatcolors.sp b/Simple AllTalk Manager/addons/sourcemod/scripting/simple-chatcolors.sp deleted file mode 100644 index 539d057..0000000 --- a/Simple AllTalk Manager/addons/sourcemod/scripting/simple-chatcolors.sp +++ /dev/null @@ -1,496 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Chat Colors -Description: - Changes the colors of players chat based on config file -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#pragma semicolon 1 -#include -#include - -#define PLUGIN_VERSION "0.9.0.$Rev$" - -#define CHAT_SYMBOL '@' -#define TRIGGER_SYMBOL1 '!' -#define TRIGGER_SYMBOL2 '/' -#define CHAT_MAX_MESSAGE_LENGTH 1024 - -new Handle:g_hDebugCvar = INVALID_HANDLE; -new Handle:g_aGroupNames = INVALID_HANDLE; -new Handle:g_aGroupFlag = INVALID_HANDLE; -new Handle:g_aGroupNameColor = INVALID_HANDLE; -new Handle:g_aGroupTextColor = INVALID_HANDLE; - -new bool:g_bDebug = false; - -new g_iArraySize; - -new g_aPlayerColorIndex[MAXPLAYERS + 1] = { -1, ... }; - -public Plugin:myinfo = -{ - name = "Simple Chat Colors", - author = "Simple Plugins", - description = "Changes the colors of players chat based on config file.", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -}; - -/** -Sourcemod callbacks -*/ -public OnPluginStart() -{ - - /** - Need to create all of our console variables. - */ - CreateConVar("sm_chatcolors_version", PLUGIN_VERSION, "Simple Chat Colors", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - g_hDebugCvar = CreateConVar("sm_chatcolors_debug", "1", "Enable/Disable debugging information"); - - /** - Hook console variables - */ - HookConVarChange(g_hDebugCvar, ConVarSettingsChanged); - - /** - Need to register the commands we are going to use - */ - RegConsoleCmd("say", Command_Say); - RegConsoleCmd("say_team", Command_SayTeam); - RegAdminCmd("sm_reloadcolorsconfig", Command_Reload, ADMFLAG_GENERIC, "Reloads settings from config file"); - - /** - Create the arrays - */ - g_aGroupNames = CreateArray(256, 1); - g_aGroupFlag = CreateArray(15, 1); - g_aGroupNameColor = CreateArray(15, 1); - g_aGroupTextColor = CreateArray(15, 1); - - /** - Load the admins and colors from the config - */ - LoadAdminsAndColorsFromConfig(); - g_iArraySize = GetArraySize(g_aGroupNames); -} - -public OnConfigsExecuted() -{ - g_bDebug = GetConVarBool(g_hDebugCvar); - ReloadConfigFile(); -} - -public OnClientPostAdminCheck(client) -{ - - /** - Check the client to see if they are a admin - */ - CheckAdmin(client); -} - -public OnClientDisconnect(client) -{ - g_aPlayerColorIndex[client] = -1; -} - -/** -Commands -*/ -public Action:Command_Say(client, args) -{ - - /** - Make sure we are enabled. - */ - if (client == 0 || IsChatTrigger()) - { - return Plugin_Continue; - } - - if (g_aPlayerColorIndex[client] != -1) - { - - /** - The client is, so get the chat message and strip it down. - */ - decl String:sArg[CHAT_MAX_MESSAGE_LENGTH], - String:sChatMsg[CHAT_MAX_MESSAGE_LENGTH]; - - new bool:bAlive = IsPlayerAlive(client); - - GetCmdArgString(sArg, sizeof(sArg)); - StripQuotes(sArg); - TrimString(sArg); - new startidx; - if (sArg[strlen(sArg)-1] == '"') - { - sArg[strlen(sArg)-1] = '\0'; - startidx = 1; - } - - /** - Bug out if they are using the admin chat symbol (admin chat). If we are in CSS it may not find all the triggers, so we double check. - */ - if (sArg[startidx] == CHAT_SYMBOL || sArg[startidx] == TRIGGER_SYMBOL1 || sArg[startidx] == TRIGGER_SYMBOL2) - { - return Plugin_Continue; - } - - /** - Log the message for hlstatsx and other things. - */ - new iUserID = GetClientUserId(client); - decl String:sAuthID[64]; - GetClientAuthString(client, sAuthID, sizeof(sAuthID)); - LogToGame("\"%N<%i><%s><>\" say \"%s\"", client, iUserID, sAuthID, sArg); - - /** - Format the message. - */ - FormatMessage(client, 0, bAlive, sChatMsg, sArg, g_aPlayerColorIndex[client]); - - /** - Send the message. - */ - //SayText2(0, client, sChatMsg); - CPrintToChatAll(sChatMsg); - - /** - We are done, bug out, and stop the original chat message. - */ - return Plugin_Stop; - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -public Action:Command_SayTeam(client, args) -{ - - /** - Make sure we are enabled. - */ - if (client == 0 || IsChatTrigger()) - { - return Plugin_Continue; - } - - /** - Check the client to see if they are a admin - */ - if (g_aPlayerColorIndex[client] != -1) - { - - /** - The client is, so get the chat message and strip it down. - */ - decl String:sArg[CHAT_MAX_MESSAGE_LENGTH], - String:sChatMsg[CHAT_MAX_MESSAGE_LENGTH]; - - new bool:bAlive = IsPlayerAlive(client); - new iCurrentTeam = GetClientTeam(client); - - GetCmdArgString(sArg, sizeof(sArg)); - StripQuotes(sArg); - TrimString(sArg); - new startidx; - if (sArg[strlen(sArg)-1] == '"') - { - sArg[strlen(sArg)-1] = '\0'; - startidx = 1; - } - - /** - Bug out if they are using the admin chat symbol (admin chat). - */ - if (sArg[startidx] == CHAT_SYMBOL || sArg[startidx] == TRIGGER_SYMBOL1 || sArg[startidx] == TRIGGER_SYMBOL2) - { - return Plugin_Continue; - } - - /** - Log the message for hlstatsx and other things. - */ - new iUserID = GetClientUserId(client); - decl String:sAuthID[64]; - GetClientAuthString(client, sAuthID, sizeof(sAuthID)); - LogToGame("\"%N<%i><%s><>\" say_team \"%s\"", client, iUserID, sAuthID, sArg); - - /** - Format the message. - */ - FormatMessage(client, iCurrentTeam, bAlive, sChatMsg, sArg, g_aPlayerColorIndex[client]); - - /** - Send the message to the same team - */ - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientConnected(i) && IsClientInGame(i) && GetClientTeam(i) == iCurrentTeam) - { - CPrintToChat(client, sChatMsg); - } - } - - /** - We are done, bug out, and stop the original chat message. - */ - return Plugin_Stop; - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -public Action:Command_Reload(client, args) -{ - ReloadConfigFile(); - return Plugin_Handled; -} - -/** -Stock Functions -*/ -stock LoadAdminsAndColorsFromConfig() -{ - - /** - Make sure the config file is here and load it up - */ - new String:sConfigFile[256]; - BuildPath(Path_SM, sConfigFile, sizeof(sConfigFile), "configs/simple-chatcolors.cfg"); - if (!FileExists(sConfigFile)) - { - - /** - Config file doesn't exists, stop the plugin - */ - LogError("[SCC] Simple Chat Colors is not running! Could not find file %s", sConfigFile); - SetFailState("Could not find file %s", sConfigFile); - } - - /** - Create the arrays and variables - */ - new String:sGroupName[256]; - new String:sGroupFlag[15]; - new String:sGroupNameColor[15]; - new String:sGroupTextColor[15]; - - - /** - Load config file as a KeyValues file - */ - new Handle:kvChatColors = CreateKeyValues("admin_colors"); - FileToKeyValues(kvChatColors, sConfigFile); - - if (!KvGotoFirstSubKey(kvChatColors)) - { - return; - } - - /** - Load up all the groups in the file - */ - do - { - - /** - Get the section name; should be the "group" name - */ - KvGetSectionName(kvChatColors, sGroupName, sizeof(sGroupName)); - - - /** - Get the flags and colors - */ - KvGetString(kvChatColors, "flag", sGroupFlag, sizeof(sGroupFlag)); - KvGetString(kvChatColors, "namecolor", sGroupNameColor, sizeof(sGroupNameColor)); - KvGetString(kvChatColors, "textcolor", sGroupTextColor, sizeof(sGroupTextColor)); - - if (g_bDebug) - { - LogMessage("Group Name/SteamID: %s", sGroupName); - LogMessage("Flag String: %s", sGroupFlag); - LogMessage("Color on name: %s", sGroupNameColor); - LogMessage("Color of text: %s", sGroupTextColor); - } - - /** - Push the values to the arrays - */ - PushArrayString(g_aGroupNames, sGroupName); - PushArrayString(g_aGroupFlag, sGroupFlag); - PushArrayString(g_aGroupNameColor, sGroupNameColor); - PushArrayString(g_aGroupTextColor, sGroupTextColor); - } while (KvGotoNextKey(kvChatColors)); - - /** - Close our handle - */ - CloseHandle(kvChatColors); -} - -stock ReloadConfigFile() -{ - - /** - Clear the array - */ - ClearArray(g_aGroupNames); - ClearArray(g_aGroupFlag); - ClearArray(g_aGroupNameColor); - ClearArray(g_aGroupTextColor); - - /** - Load the admins, groups, and colors from the config - */ - LoadAdminsAndColorsFromConfig(); - g_iArraySize = GetArraySize(g_aGroupNames); - - /** - Recheck all the online players for assigned colors - */ - for (new index = 1; index <= MaxClients; index++) - { - if (IsClientConnected(index) && IsClientInGame(index)) - { - CheckAdmin(index); - } - } -} - -stock CheckAdmin(client) -{ - new String:sFlags[15]; - new String:sClientSteamID[64]; - new iGroupFlags; - new iFlags; - new iIndex = -1; - - /** - Look for a steamid first - */ - GetClientAuthString(client, sClientSteamID, sizeof(sClientSteamID)); - iIndex = FindStringInArray(g_aGroupNames, sClientSteamID); - if (iIndex != -1) - { - g_aPlayerColorIndex[client] = iIndex; - } - - /** - Didn't find one, check flags - */ - else - { - /** - Search for flag in groups - */ - - iFlags = GetUserFlagBits(client); - for (iIndex = 0; iIndex < g_iArraySize; iIndex++) - { - GetArrayString(g_aGroupFlag, iIndex, sFlags, sizeof(sFlags)); - iGroupFlags = ReadFlagString(sFlags); - if (iFlags & iGroupFlags) - { - g_aPlayerColorIndex[client] = iIndex; - break; - } - } - } - - if (g_bDebug) - { - PrintToChatAll("SteamID: %s", sClientSteamID); - PrintToChatAll("Array Index: %i", iIndex); - PrintToChatAll("Flag String: %s", sFlags); - PrintToChatAll("Flag Bits of Client: %i", iFlags); - PrintToChatAll("Flag Bits of Group: %i", iGroupFlags); - } -} - -stock FormatMessage(iClient, iTeam, bool:bAlive, String:sChatMsg[], const Sting:sMessage[], iArrayIndex) -{ - decl String:sDead[10], - String:sTeam[10], - String:sClientName[64]; - - GetClientName(iClient, sClientName, sizeof(sClientName)); - - if (iTeam != 0) - { - Format(sTeam, sizeof(sTeam), "(TEAM) "); - } - else - { - Format(sTeam, sizeof(sTeam), ""); - } - if (bAlive) - { - Format(sDead, sizeof(sDead), ""); - } - else - { - Format(sDead, sizeof(sDead), "*DEAD* "); - } - - new String:sNameColor[15]; - new String:sTextColor[15]; - GetArrayString(g_aGroupNameColor, iArrayIndex, sNameColor, sizeof(sNameColor)); - GetArrayString(g_aGroupTextColor, iArrayIndex, sTextColor, sizeof(sTextColor)); - - Format(sChatMsg, CHAT_MAX_MESSAGE_LENGTH, "{default}%s%s%s%s {default}: %s%s", sDead, sTeam, sNameColor, sClientName, sTextColor, sMessage); -} - -/** -Adjust the settings if a convar was changed -*/ -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (StringToInt(newValue) == 1) - { - g_bDebug = true; - } - else - { - g_bDebug = false; - } -} \ No newline at end of file diff --git a/Simple AllTalk Manager/addons/sourcemod/scripting/simple-donatorbenefits.sp b/Simple AllTalk Manager/addons/sourcemod/scripting/simple-donatorbenefits.sp deleted file mode 100644 index e3f6845..0000000 --- a/Simple AllTalk Manager/addons/sourcemod/scripting/simple-donatorbenefits.sp +++ /dev/null @@ -1,1312 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Donator Benefits -Description: - Provides donator benefits to players -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include -#include - -#define PLUGIN_VERSION "1.1.$Rev$" - -#define CHAT_SYMBOL '@' -#define CHAT_MAX_MESSAGE_LENGTH 1024 - -enum PlayerData -{ - bool:bIsDonator, - bool:bQueue, - bool:bImmune, - iHealthCount, - iNewTeam -}; - -/** - Public convar handles - */ -new Handle:sdb_enabled = INVALID_HANDLE; -new Handle:sdb_donationflag = INVALID_HANDLE; -new Handle:sdb_soundfile = INVALID_HANDLE; -new Handle:sdb_joinsound_enabled = INVALID_HANDLE; -new Handle:sdb_joinpubmsg_enabled = INVALID_HANDLE; -new Handle:sdb_joinprivmsg_enabled = INVALID_HANDLE; -new Handle:sdb_chatcolors_enabled = INVALID_HANDLE; -new Handle:sdb_immunity_enabled = INVALID_HANDLE; -new Handle:sdb_ubercharge_enabled = INVALID_HANDLE; -new Handle:sdb_givehealth_enabled = INVALID_HANDLE; -new Handle:sdb_nofalldmg_enabled = INVALID_HANDLE; -new Handle:sdb_fastheavy_enabled = INVALID_HANDLE; -new Handle:sdb_swapteam_enabled = INVALID_HANDLE; -new Handle:sdb_chatcolor = INVALID_HANDLE; -new Handle:sdb_uberlevel = INVALID_HANDLE; -new Handle:sdb_healthcount = INVALID_HANDLE; -new Handle:sdb_healthbonus = INVALID_HANDLE; -new Handle:sdb_heavymultiplier = INVALID_HANDLE; - -/** -Create global enable/disable bools so we don't have to check the console variable on every call -*/ -new bool:g_bIsEnabled = true; -new bool:g_bIsJoinSoundEnabled = true; -new bool:g_bIsJoinPubMsgEnabled = true; -new bool:g_bIsJoinPrivMsgEnabled = true; -new bool:g_bIsChatColorsEnabled = true; -new bool:g_bIsImmuntyEnabled = true; -new bool:g_bIsUberChargeEnabled = true; -new bool:g_bIsGiveHealthEnabled = true; -new bool:g_bIsNoFallDmgEnabled = true; -new bool:g_bIsFastHeayEnabled = true; -new bool:g_bIsSwapTeamEnabled = true; - -/** - Player arrays - */ -new g_aPlayers[MAXPLAYERS + 1][PlayerData]; - - -/** -Rest of the globals -*/ -new bool:g_bRoundEnd = false; -new String:g_sCharDonatorFlag[5]; -new String:g_sSoundFile[PLATFORM_MAX_PATH]; -new String:g_sChatColor[11]; -new g_iHealthBonus; -new g_iHealthCount; -new g_iClassMaxHealth[TFClassType] = {0, 125, 125, 200, 175, 150, 300, 175, 125, 125}; -new g_fClassMaxSpeed[TFClassType] = {0, 400, 300, 240, 280, 320, 230, 300, 300, 300}; -new Float:g_fHeavyMultiplier = 0.0; -new Float:g_fUberLevel = 0.0; - -public Plugin:myinfo = -{ - name = "Simple Donation Benefits", - author = "Simple Plugins", - description = "Gives donators benefits to players", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -} - -public OnPluginStart() -{ - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook the game events - */ - LogAction(0, -1, "[SDB] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_connect", HookPlayerSpawn, EventHookMode_Pre); - HookEvent("player_spawn", HookPlayerSpawn, EventHookMode_Post); - HookEvent("player_death", HookPlayerDeath, EventHookMode_Post); - HookEvent("player_team", HookPlayerChangeTeam, EventHookMode_Post); - switch (g_CurrentMod) - { - case GameType_TF: - { - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - HookEvent("player_changeclass", HookPlayerClass, EventHookMode_Post); - } - case GameType_DOD: - { - HookEvent("dod_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_Post); - } - default: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - } - } - - /** - Create console variables - */ - CreateConVar("sdb_version", PLUGIN_VERSION, "Simple Donation Benefits", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - sdb_enabled = CreateConVar("sdb_enabled", "1", "Enable/Disable Simple Donation Benefits"); - sdb_donationflag = CreateConVar("sdb_donationflag", "a", "Flag ALREADY given to donators. Must be in char format"); - - /** - Create the enable/disable donator console variables - */ - sdb_joinsound_enabled = CreateConVar("sdb_joinsound_enabled", "1", "Enable/Disable donator join sound"); - sdb_joinpubmsg_enabled = CreateConVar("sdb_joinpubmsg_enabled", "1", "Enable/Disable public donator join message (replaces: as connected)"); - sdb_joinprivmsg_enabled = CreateConVar("sdb_joinprivmsg_enabled", "1", "Enable/Disable private donator join message (sent only to donator)"); - sdb_chatcolors_enabled = CreateConVar("sdb_chatcolors_enabled", "1", "Enable/Disable donator chat colors"); - sdb_immunity_enabled = CreateConVar("sdb_immunity_enabled", "1", "Enable/Disable donator round end immunity"); - sdb_ubercharge_enabled = CreateConVar("sdb_ubercharge_enabled", "1", "Enable/Disable donator medics starting with ubercharge"); - sdb_givehealth_enabled = CreateConVar("sdb_givehealth_enabled", "1", "Enable/Disable donator instant health bonus"); - sdb_nofalldmg_enabled = CreateConVar("sdb_nofalldmg_enabled", "1", "Enable/Disable no fall damage for donators"); - sdb_fastheavy_enabled = CreateConVar("sdb_fastheavy_enabled", "1", "Enable/Disable donator heavies moving faster while spinning"); - sdb_swapteam_enabled = CreateConVar("sdb_swampteam_enabled", "1", "Enable/Disable donator swap team ability"); - - /** - Create the donator setting console variables - */ - sdb_soundfile = CreateConVar("sdb_soundfile", "custom/donatorjoin.mp3", "The location of sound file"); - sdb_chatcolor = CreateConVar("sdb_chatcolor", "green", "Color to use for donator chat. Valid colors are green and lightgreen"); - sdb_uberlevel = CreateConVar("sdb_uberlevel", "0.5", "Uberlevel to give donator medic at spawn. 1.0 = full uber", _, true, 0.0, true, 1.0); - sdb_healthcount = CreateConVar("sdb_healthcount", "1", "Number of times a donator can use use instant health per life"); - sdb_healthbonus = CreateConVar("sdb_healthbonus", "100", "The amount of health to heal the donator"); - sdb_heavymultiplier = CreateConVar("sdb_heavyspeed", "0.5", "The speed multiplier for the fast heavy. Based on running speed. 1.0 = running speed. (Game Default is 0.20)", _, true, 0.0, true, 1.0); - - /** - Hook dukehacks calls - */ - dhAddClientHook(CHK_TakeDamage, Hacks_TakeDamageHook); - dhAddClientHook(CHK_PreThink, Hacks_PreThinkHook); - - /** - Hook the console variables if they change - */ - HookConVarChange(sdb_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_donationflag, ConVarSettingsChanged); - HookConVarChange(sdb_joinsound_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_joinpubmsg_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_joinprivmsg_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_chatcolors_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_immunity_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_ubercharge_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_givehealth_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_nofalldmg_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_swapteam_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_fastheavy_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_soundfile, ConVarSettingsChanged); - HookConVarChange(sdb_chatcolor, ConVarSettingsChanged); - HookConVarChange(sdb_uberlevel, ConVarSettingsChanged); - HookConVarChange(sdb_healthcount, ConVarSettingsChanged); - HookConVarChange(sdb_healthbonus, ConVarSettingsChanged); - HookConVarChange(sdb_heavymultiplier, ConVarSettingsChanged); - - /** - Register the commands - */ - RegConsoleCmd("sm_swapteams", Command_SwapTeam, "sm_swapteams <[0]instant/[1]queued>: Swaps your team to the other team"); - RegConsoleCmd("sm_ihealth", Command_InstantHealth, "sm_ihealth: Gives you a instant health pack"); - RegAdminCmd("sm_teaser", Command_Teaser, ADMFLAG_GENERIC,"sm_teaser <[0]add/[1]remove>: Gives temporary donator privilages to a player"); - RegConsoleCmd("say", Command_Say); - - RegConsoleCmd("sm_test", Command_TEST); - - /** - Load the translations - */ - LoadTranslations("common.phrases"); - LoadTranslations("simpledonatorbenefits.phrases"); - - /** - Load or create the config file - */ - AutoExecConfig(true, "plugin.simpledonatorbenefits"); - LogAction(0, -1, "[SDB] Simple Donator Benefits is loaded."); -} - -public OnAllPluginsLoaded() -{ - //something -} - -public OnLibraryRemoved(const String:name[]) -{ - //something -} - -public OnConfigsExecuted() -{ - /** - Load up all the variable defaults - */ - LoadUpVariables(); - - /** - If the join sound is enabled, prep the sound files - */ - if (g_bIsJoinSoundEnabled) - PrepSoundFile(); - - /** - Log our activity - */ - if (g_bIsEnabled) - LogAction(0, -1, "Simple Donation Benefits is ENABLED"); - else - LogAction(0, -1, "Simple Donation Benefits is DISABLED"); -} - -public OnClientPostAdminCheck(client) -{ - - /** - Check if the client is a donator - */ - if (SM_IsValidAdmin(client, g_sCharDonatorFlag)) - { - - /** - They are, so we set the player array to true and start a timer for the sound or add - */ - g_aPlayers[client][bIsDonator] = true; - if (g_bIsJoinSoundEnabled || g_bIsJoinPrivMsgEnabled) - { - CreateTimer(10.0, Timer_DonatorJoined, client, TIMER_FLAG_NO_MAPCHANGE); - } - } - else - { - /** - They aren't, so we set the player array to false - */ - g_aPlayers[client][bIsDonator] = false; - } -} - -public OnClientDisconnect_Post(client) -{ - - /** - Clean up the player variables - */ - CleanUpPlayer(client); -} - -public Action:Command_SwapTeam(client, args) -{ - - /** - Make sure we are enabled - */ - if (!g_bIsEnabled || !g_bIsSwapTeamEnabled) - { - return Plugin_Handled; - } - - /** - Make sure the command is not started by the server - */ - if (client == 0) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "PlayerLevelCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Make sure the player is a donator - */ - if (!g_aPlayers[client][bIsDonator]) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Lets make sure the client is one a team we can swap. - If he is we set the global array to the opposite team. - */ - new iTeam = GetClientTeam(client); - if (iTeam == g_aCurrentTeams[Team1]) - { - g_aPlayers[client][iNewTeam] = g_aCurrentTeams[Team2]; - } - else if (iTeam == g_aCurrentTeams[Team2]) - { - g_aPlayers[client][iNewTeam] = g_aCurrentTeams[Team1]; - } - else - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "InValidTeam", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check to see if we have command arguments. - */ - if (GetCmdArgs()) - { - - /** - We do, so lets get it and see if the client wants to be switched instantly or queued for death. - */ - decl String:sArg[5]; - GetCmdArg(1, sArg, sizeof(sArg)); - new iWantsQue = StringToInt(sArg); - if (iWantsQue && !g_aPlayers[client][bQueue]) - { - - /** - He wants the que and isn't already in it, set the global array. - */ - g_aPlayers[client][bQueue] = true; - ReplyToCommand(client, "\x01\x04[STM]\x01 %T", "PlayerQueue", LANG_SERVER); - } - else if (!iWantsQue) - { - - /** - He wants to be switched right now, lets call the stock function. - */ - SM_MovePlayer(client, g_aPlayers[client][iNewTeam]); - } - } - else - { - - /** - There are no command arguments so we build and display the swap menu. - */ - new Handle:hPlayerMenu = BuildSwapModeMenu(); - DisplayMenu(hPlayerMenu, client, MENU_TIME_FOREVER); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_InstantHealth(client, args) -{ - - /** - Make sure we are enabled - */ - if (!g_bIsEnabled || !g_bIsGiveHealthEnabled) - { - return Plugin_Handled; - } - - /** - Make sure the command is not started by the server - */ - if (client == 0) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "PlayerLevelCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Make sure the player is a donator - */ - if (!g_aPlayers[client][bIsDonator]) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check health count to see if the player has reached the max - */ - if (g_aPlayers[client][iHealthCount] >= g_iHealthCount) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "ReachedCount", LANG_SERVER); - return Plugin_Handled; - } - - /** - Get the class of the player and the max health for that class - */ - new iHealth = GetClientHealth(client); - new TFClassType:PlayerClass = TF2_GetPlayerClass(client); - new iMaxHealth = g_iClassMaxHealth[PlayerClass]; - - /** - Check to see if the player is at the max health of the class - */ - if (iHealth >= iMaxHealth) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "AtMaxHealth", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check the current health - */ - if (iHealth + g_iHealthBonus >= iMaxHealth) - { - - /** - Raise them to max health if the current health + bonus would go above it - */ - SetEntityHealth(client, iMaxHealth); - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "ToMaxHealth", LANG_SERVER); - } - else - { - - /** - Give them the instant health bonus - */ - SetEntityHealth(client, iHealth + g_iHealthBonus); - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "HealthBonus", LANG_SERVER); - } - - /** - Increase the count - */ - g_aPlayers[client][iHealthCount] += 1; - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_Teaser(client, args) -{ - - /** - Make sure we are enabled - */ - if (!g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - Check to see if we have command arguments. - */ - new iCmdArgs = GetCmdArgs(); - if (iCmdArgs == 0) - { - - /** - We don't so display the player menu. - */ - new Handle:hPlayerMenu = BuildPlayerMenu(); - DisplayMenu(hPlayerMenu, client, MENU_TIME_FOREVER); - return Plugin_Handled; - } - - /** - We have some arguments, see if we can find the player - */ - decl String:sPlayer[64]; - GetCmdArg(1, sPlayer, sizeof(sPlayer)); - new iTarget = FindTarget(client, sPlayer, true, true); - if (iTarget == -1 || !IsClientInGame(iTarget)) - { - - /** - We don't know who this is, so display the player menu. - */ - new Handle:hPlayerMenu = BuildPlayerMenu(); - DisplayMenu(hPlayerMenu, client, MENU_TIME_FOREVER); - } - else - { - /** - We found the player, see if we are supposed to turn it on or off. - */ - if (iCmdArgs >= 2) - { - decl String:sOn[3]; - GetCmdArg(2, sOn, sizeof(sOn)); - if (StringToInt(sOn)) - { - - /** - Turn temp benefits on. - */ - g_aPlayers[iTarget][bIsDonator] = true; - } - else - { - - /** - Turn temp benefits on. - */ - g_aPlayers[iTarget][bIsDonator] = false; - } - } - else - { - - /** - We don't know what to do, so just turn it on. - */ - g_aPlayers[iTarget][bIsDonator] = true; - } - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_Say(client, args) -{ - - /** - Make sure we are enabled. - */ - if (client == 0 || IsChatTrigger() || !g_bIsChatColorsEnabled || !g_bIsEnabled) - { - return Plugin_Continue; - } - - /** - Check the client to see if they are a donator. - */ - if (g_aPlayers[client][bIsDonator]) - { - - /** - The client is, so get the chat message and strip it down. - */ - decl String:sArg[CHAT_MAX_MESSAGE_LENGTH], - String:sChatMsg[CHAT_MAX_MESSAGE_LENGTH]; - new bool:bAlive = IsPlayerAlive(client); - GetCmdArgString(sArg, sizeof(sArg)); - StripQuotes(sArg); - TrimString(sArg); - new startidx; - if (sArg[strlen(sArg)-1] == '"') - { - sArg[strlen(sArg)-1] = '\0'; - startidx = 1; - } - - /** - Bug out if they are using the admin chat symbol (admin chat). - */ - if (sArg[startidx] == CHAT_SYMBOL) - { - return Plugin_Continue; - } - - /** - Format the message. - */ - FormatMessage(client, 0, bAlive, sChatMsg, sArg); - - /** - Send the message. - */ - SayText2(0, client, sChatMsg); - - /** - We are done, bug out, and stop the original chat message. - */ - return Plugin_Stop; - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -public Action:Hacks_TakeDamageHook(client, attacker, inflictor, Float:damage, &Float:multiplier, damagetype) -{ - - /** - Make sure we are enabled and the client is a donator. - */ - if (g_bIsEnabled && g_bIsNoFallDmgEnabled && g_aPlayers[client][bIsDonator]) - { - - /** - Check for fall damage. - */ - if (damagetype & DMG_FALL) - { - - /** - Cancel the fall damage and bug out. - */ - multiplier *= 0.0; - return Plugin_Changed; - } - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -public Action:Hacks_PreThinkHook(client) -{ - - /** - Make sure we are enabled and the client is a donator. - */ - if (!g_bIsEnabled || !g_bIsFastHeayEnabled || !g_aPlayers[client][bIsDonator]) - { - return Plugin_Continue; - } - - /** - Check the players class. We are looking for the heavy. - */ - new TFClassType:PlayerClass = TF2_GetPlayerClass(client); - if (PlayerClass == TFClass_Heavy) - { - - /** - We have a heavy, lets check the weapon. - */ - decl String:sWeaponCurrent[64]; - GetClientWeapon(client, sWeaponCurrent, sizeof(sWeaponCurrent)); - if (StrEqual(sWeaponCurrent, "tf_weapon_minigun", false)) - { - - /** - We have a minigun, check the heavies current weapon state to see if it's spinning. - */ - new iWeapon = GetPlayerWeaponSlot(client, 0); - new iWeaponState = GetEntProp(iWeapon, Prop_Send, "m_iWeaponState"); - if (iWeaponState > 0) - { - - /** - He is spinning, so lets change the heavies speed. - */ - new Float:fMaxSpeed = FloatMul(g_fHeavyMultiplier, float(g_fClassMaxSpeed[PlayerClass])); - SetEntPropFloat(client, Prop_Send, "m_flMaxspeed", fMaxSpeed); - } - } - } - - /** - We are done, bug out. - */ - // use Plugin_Continue (other options are ignored on PreThink hook) - return Plugin_Continue; -} - -public Action:HookPlayerConnect(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Make sure we are enabled. - */ - if (!g_bIsEnabled || !g_bIsJoinPubMsgEnabled || !dontBroadcast) - { - return Plugin_Continue; - } - - /** - Get our event variables and check the client. - */ - new iUserId = GetEventInt(event,"userid"); - new iClient = GetClientOfUserId(iUserId); - if (iClient != 0) - { - - /** - Get the info on the client and format the message. - */ - decl String:sClientName[255], - String:sAuthID[255], - String:sMsg[1024]; - - GetEventString(event, "name", sClientName, sizeof(sClientName)); - GetClientAuthString(iClient, sAuthID, sizeof(sAuthID)); - Format(sMsg, sizeof(sMsg), "%T", "PublicJoinMessage", LANG_SERVER, sClientName); - - /** - Print the message to the clients and do the normal functions. - */ - for (new i = 1; i <= MaxClients; i++) - { - if(IsClientConnected(i) && IsClientInGame(i)) - { - PrintToChat(i,"\x01\x05%s", sMsg); - PrintToConsole(i,"%s has connected.", sClientName); - } - } - LogToGame("\"%s<%d><%s><>\" entered the game", sClientName, iUserId, sAuthID); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public HookPlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled && g_bIsUberChargeEnabled) - { - - /** - Get the event variables and check the class for medic - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - if (TF2_GetPlayerClass(iClient) == TFClass_Medic) - { - - /** - Start a timer to get the medic the uber boost - */ - CreateTimer(0.25, Timer_PlayerUberDelay, iClient, TIMER_FLAG_NO_MAPCHANGE); - } - } -} - -public HookPlayerClass(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled && g_bIsUberChargeEnabled) - { - - /** - Get the event variables and check the class for medic - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - if (TF2_GetPlayerClass(iClient) == TFClass_Medic) - { - - /** - Start a timer to get the medic the uber boost - */ - CreateTimer(0.25, Timer_PlayerUberDelay, iClient, TIMER_FLAG_NO_MAPCHANGE); - } - } -} - -public HookPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled || g_bIsSwapTeamEnabled) - { - - /** - Get the event variables - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - new String:sWeapon[256]; - GetEventString(event, "weapon", sWeapon, sizeof(sWeapon)); - - /** - Bug out if world killed him. Means he changed team or something - */ - if (StrEqual(sWeapon, "world", false)) - { - g_aPlayers[iClient][bQueue] = false; - return; - } - - /** - If he is queued up, swap him - */ - if (g_aPlayers[iClient][bQueue]) - { - SM_MovePlayer(iClient, g_aPlayers[iClient][iNewTeam]); - } - } -} - -public HookPlayerChangeTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled || g_bIsSwapTeamEnabled) - { - - /** - Get the event variables - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - - /** - If he is queued up, clear the status - */ - if (g_aPlayers[iClient][bQueue]) - { - g_aPlayers[iClient][bQueue] = false; - } - } -} - -public HookRoundStart(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Set our variables. - */ - g_bRoundEnd = false; - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled && g_bIsImmuntyEnabled) - { - - /** - Get rid of their immunity. - */ - ProcessRoundEndImmunity(false); - } -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Set our variables. - */ - g_bRoundEnd = true; - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled && g_bIsImmuntyEnabled) - { - - /** - Give them their immunity. - */ - ProcessRoundEndImmunity(true); - } -} - -public Action:Timer_DonatorJoined(Handle:timer, any:client) -{ - - /** - Make sure sounds are enabled. - */ - if (g_bIsEnabled && g_bIsJoinSoundEnabled) - { - EmitSoundToClient(client, g_sSoundFile); - } - - /** - Make sure private messages are enabled. - */ - if (g_bIsJoinPrivMsgEnabled) - { - - /** - Send messages to the client. - */ - decl String:sMsg[1024]; - Format(sMsg, sizeof(sMsg), "%T", "PrivateJoinMessage", LANG_SERVER); - PrintToChat(client,"\x01\x05%s", sMsg); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Timer_PlayerUberDelay(Handle:timer, any:client) -{ - - /** - Make sure the client is still in game. - */ - if (IsClientInGame(client)) - { - - /** - Make sure the client is still a medic. - */ - if (TF2_GetPlayerClass(client) == TFClass_Medic) - { - - /** - Get the medgun weapon index - */ - new iIndex = GetPlayerWeaponSlot(client, 1); - if (iIndex > 0) - { - - /** - Set the uber level with the bonus. - */ - SetEntPropFloat(iIndex, Prop_Send, "m_flChargeLevel", g_fUberLevel); - } - } - } -} - -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (convar == sdb_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsEnabled = false; - } - else - { - g_bIsEnabled = true; - } - } - else if (convar == sdb_donationflag) - { - Format(g_sCharDonatorFlag, sizeof(g_sCharDonatorFlag), "%s", newValue); - } - else if (convar == sdb_soundfile) - { - Format(g_sSoundFile, sizeof(g_sSoundFile), "%s", newValue); - } - else if (convar == sdb_joinsound_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsJoinSoundEnabled = false; - } - else - { - g_bIsJoinSoundEnabled = true; - } - } - else if (convar == sdb_joinpubmsg_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsJoinPubMsgEnabled = false; - } - else - { - g_bIsJoinPubMsgEnabled = true; - } - } - else if (convar == sdb_joinprivmsg_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsJoinPrivMsgEnabled = false; - } - else - { - g_bIsJoinPrivMsgEnabled = true; - } - } - else if (convar == sdb_chatcolors_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsChatColorsEnabled = false; - } - else - { - g_bIsChatColorsEnabled = true; - } - } - else if (convar == sdb_immunity_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsImmuntyEnabled = false; - } - else - { - g_bIsImmuntyEnabled = true; - } - } - else if (convar == sdb_ubercharge_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsUberChargeEnabled = false; - } - else - { - g_bIsUberChargeEnabled = true; - } - } - else if (convar == sdb_givehealth_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsGiveHealthEnabled = false; - } - else - { - g_bIsGiveHealthEnabled = true; - } - } - else if (convar == sdb_nofalldmg_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsNoFallDmgEnabled = false; - } - else - { - g_bIsNoFallDmgEnabled = true; - } - } - else if (convar == sdb_fastheavy_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsFastHeayEnabled = false; - } - else - { - g_bIsFastHeayEnabled = true; - } - } - else if (convar == sdb_swapteam_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsSwapTeamEnabled = false; - } - else - { - g_bIsSwapTeamEnabled = true; - } - } - else if (convar == sdb_chatcolor) - { - Format(g_sChatColor, sizeof(g_sChatColor), "%s", newValue); - } - else if (convar == sdb_uberlevel) - { - g_fUberLevel = StringToFloat(newValue); - } - else if (convar == sdb_healthcount) - { - g_iHealthCount = StringToInt(newValue); - } - else if (convar == sdb_healthbonus) - { - g_iHealthBonus = StringToInt(newValue); - } - else if (convar == sdb_heavymultiplier) - { - g_fHeavyMultiplier = StringToFloat(newValue); - } -} - -stock LoadUpVariables() -{ - g_bIsEnabled = GetConVarBool(sdb_enabled); - g_bIsJoinSoundEnabled = GetConVarBool(sdb_enabled); - g_bIsJoinPubMsgEnabled = GetConVarBool(sdb_enabled); - g_bIsJoinPrivMsgEnabled = GetConVarBool(sdb_enabled); - g_bIsChatColorsEnabled = GetConVarBool(sdb_enabled); - g_bIsImmuntyEnabled = GetConVarBool(sdb_enabled); - g_bIsUberChargeEnabled = GetConVarBool(sdb_enabled); - g_bIsGiveHealthEnabled = GetConVarBool(sdb_enabled); - g_bIsNoFallDmgEnabled = GetConVarBool(sdb_enabled); - g_bIsFastHeayEnabled = GetConVarBool(sdb_enabled); - g_bIsSwapTeamEnabled = GetConVarBool(sdb_enabled); - GetConVarString(sdb_donationflag, g_sCharDonatorFlag, sizeof(g_sCharDonatorFlag)); - GetConVarString(sdb_soundfile, g_sSoundFile, sizeof(g_sSoundFile)); - GetConVarString(sdb_chatcolor, g_sChatColor, sizeof(g_sChatColor)); - g_bRoundEnd = false; - g_iHealthBonus = GetConVarInt(sdb_healthbonus); - g_iHealthCount = GetConVarInt(sdb_healthcount); - g_fHeavyMultiplier = GetConVarFloat(sdb_heavymultiplier); - g_fUberLevel = GetConVarFloat(sdb_uberlevel); -} - -stock PrepSoundFile() -{ - decl String:buffer[PLATFORM_MAX_PATH]; - PrecacheSound(g_sSoundFile, true); - Format(buffer, sizeof(buffer), "sound/%s", g_sSoundFile); - AddFileToDownloadsTable(buffer); -} - -stock CleanUpPlayer(client) -{ - g_aPlayers[client][bIsDonator] = false; - g_aPlayers[client][bQueue] = false; - g_aPlayers[client][bImmune] = false; - g_aPlayers[client][iNewTeam] = 0; - g_aPlayers[client][iHealthCount] = 0; -} - -stock ProcessRoundEndImmunity(bool:give) -{ - for (new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][bIsDonator]) - { - if (give) - { - SetEntProp(i, Prop_Data, "m_takedamage", 0, 1); - g_aPlayers[i][bImmune] = true; - } - else - { - SetEntProp(i, Prop_Data, "m_takedamage", 2, 1); - g_aPlayers[i][bImmune] = false; - } - } - } -} - -stock FormatMessage(iClient, iTeam, bool:bAlive, String:sChatMsg[], const Sting:sMessage[]) -{ - decl String:sDead[10], - String:sTeam[10], - String:sClientName[64]; - GetClientName(iClient, sClientName, sizeof(sClientName)); - if (iTeam != 0) - Format(sTeam, sizeof(sTeam), "(TEAM) "); - else - Format(sTeam, sizeof(sTeam), ""); - if (bAlive) - Format(sDead, sizeof(sDead), ""); - else - Format(sDead, sizeof(sDead), "*DEAD* "); - if (StrContains(g_sChatColor, "light", false) == -1) - Format(sChatMsg, CHAT_MAX_MESSAGE_LENGTH, "\x01%s%s\x03%s \x01: \x05%s", sDead, sTeam, sClientName, sMessage); - else - Format(sChatMsg, CHAT_MAX_MESSAGE_LENGTH, "\x01%s%s\x03%s \x01: \x04%s", sDead, sTeam, sClientName, sMessage); -} - -stock SayText2(target, author, const String:message[]) -{ - new Handle:hBf; - if (target == 0) - hBf = StartMessageAll("SayText2"); - else - hBf = StartMessageOne("SayText2", target); - if (hBf != INVALID_HANDLE) - { - BfWriteByte(hBf, author); - BfWriteByte(hBf, true); - BfWriteString(hBf, message); - EndMessage(); - } -} - -stock ProcessAdmins() -{ - for (new i = 1; i <= MaxClients; i++) - { - if (SM_IsValidAdmin(i, g_sCharDonatorFlag)) - { - g_aPlayers[i][bDonator] = true; - } - else - { - g_aPlayers[i][bDonator] = false; - } - } -} - -stock ProcessLate() -{ - if (g_bIsEnabled) - { - ProcessAdmins(); - PrepSoundFile(); - if (g_bRoundEnd && g_bIsImmuntyEnabled) - { - ProcessRoundEndImmunity(true); - } - if (!g_bIsImmuntyEnabled) - { - ProcessRoundEndImmunity(false); - } - } - else - { - ProcessRoundEndImmunity(false); - } -} - -public Menu_SwapMode(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, 64); - if (StringToInt(sSelection)) - g_aPlayers[param1][bQueue] = false; - else - g_aPlayers[param1][bQueue] = true; - if (!g_aPlayers[param1][bQueue]) - SM_MovePlayer(param1, g_aPlayers[param1][iNewTeam]); - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -public Menu_SelectPlayer(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[256]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - new iTarget = GetClientOfUserId(StringToInt(sSelection)); - if (g_aPlayers[iTarget][bIsDonator]) - g_aPlayers[iTarget][bIsDonator] = false; - else - g_aPlayers[iTarget][bIsDonator] = true; - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -stock Handle:BuildSwapModeMenu() -{ - new Handle:menu = CreateMenu(Menu_SwapMode); - SetMenuTitle(menu, "Select When to Swap:"); - AddMenuItem(menu, "0", "Instantly (Kills)"); - AddMenuItem(menu, "1", "Queue on next death"); - SetMenuExitBackButton(menu, false); - return menu; -} - -stock Handle:BuildPlayerMenu() -{ - new Handle:menu = CreateMenu(Menu_SelectPlayer); - AddTargetsToMenu(menu, 0, true, false); - SetMenuTitle(menu, "Select A Player:"); - SetMenuExitBackButton(menu, true); - return menu; -} - -public Action:Command_TEST(client, args) -{ - -} \ No newline at end of file diff --git a/Simple AllTalk Manager/addons/sourcemod/scripting/simple-messagesuppression.sp b/Simple AllTalk Manager/addons/sourcemod/scripting/simple-messagesuppression.sp deleted file mode 100644 index f7725a4..0000000 --- a/Simple AllTalk Manager/addons/sourcemod/scripting/simple-messagesuppression.sp +++ /dev/null @@ -1,227 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Message Suppression -Description: - Blocks Specific Message Outputs -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include -#include - -#define SUPPRESS_VERSION "1.1.$Rev$" - -public Plugin:myinfo = -{ - name = "Simple Message Suppression", - author = "FlyingMongoose, psychonic", - description = "Blocks Specific Message Outputs", - version = SUPPRESS_VERSION, - url = "http://www.simple-plugins.com/" -} - -new Handle:cvarBlockSpectateMessage; -new Handle:cvarBlockDisconnectMessage; -new Handle:cvarBlockConnectMessage; -new Handle:cvarAdminShowMessages; -new iSpecTeam = 1; - - -public OnPluginStart() -{ - CreateConVar("suppress_version", SUPPRESS_VERSION, _, FCVAR_PLUGIN|FCVAR_NOTIFY|FCVAR_REPLICATED|FCVAR_SPONLY|FCVAR_DONTRECORD); - cvarBlockSpectateMessage = CreateConVar("sm_blockspectatemessage", "1", "If enabled it blocks the join team message if an administrator joins spectator", FCVAR_PLUGIN, true, 0.0, true, 1.0); - cvarBlockDisconnectMessage = CreateConVar("sm_blockdisconnectmessage", "1", "Blocks the disconnect message", FCVAR_PLUGIN, true, 0.0, true, 1.0); - cvarBlockConnectMessage = CreateConVar("sm_blockconnectmessage", "1", "If enabled it blocks the player connection message.", FCVAR_PLUGIN, true, 0.0, true, 1.0); - cvarAdminShowMessages = CreateConVar("sm_adminshowmessages", "1", "Shows disconnect/connect/team join messages for admins only (if disconnect message is set to be blocked)", FCVAR_PLUGIN, true, 0.0, true, 1.0); - HookEvent("player_team", ev_PlayerTeam, EventHookMode_Pre); - HookEvent("player_disconnect", ev_PlayerDisconnect, EventHookMode_Pre); - HookEvent("player_connect", ev_PlayerConnect, EventHookMode_Pre); - - new String:game_folder[64]; - GetGameFolderName(game_folder, sizeof(game_folder)) - - if (StrContains(game_folder, "insurgency", false) != -1) - { - iSpecTeam = 3; - } - else - { - new String:game_description[64]; - GetGameDescription(game_description, sizeof(game_description), true); - if (StrContains(game_description, "Insurgency", false) != -1) - { - iSpecTeam = 3; - } - } - - AutoExecConfig(true, "suppressmessage", "sourcemod"); -} - -public Action:ev_PlayerTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - if (GetConVarBool(cvarBlockSpectateMessage)) - { - if (!dontBroadcast && !GetEventBool(event, "silent")) - { - new iUserId = GetEventInt(event, "userid"); - new iClient = GetClientOfUserId(iUserId); - new iTeam = GetEventInt(event, "team"); - - if (iTeam == iSpecTeam && GetAdminFlag(GetUserAdmin(iClient), Admin_Kick)) - { - new iOldTeam = GetEventInt(event, "oldteam"); - new bool:bDisconnect = GetEventBool(event, "disconnect"); - new bool:bAutoteam = GetEventBool(event, "autoteam"); - decl String:strName[50]; - GetEventString(event, "name", strName, sizeof(strName)); - - if (iClient != 0) - { - if (GetConVarInt(cvarAdminShowMessages) == 1) - { - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientConnected(i) && IsClientInGame(i) && GetUserAdmin(i) != INVALID_ADMIN_ID) - { - PrintToChat(i,"%N joined team Spectator.", iClient); - PrintToConsole(i,"%N joined team Spectator.", iClient); - } - } - } - } - - new Handle:hEvent = CreateEvent("player_team"); - SetEventInt(hEvent, "userid", iUserId); - SetEventInt(hEvent, "team", iTeam); - SetEventInt(hEvent, "oldteam", iOldTeam); - SetEventBool(hEvent, "disconnect", bDisconnect); - SetEventBool(hEvent, "autoteam", bAutoteam); - SetEventBool(hEvent, "silent", true); - SetEventString(hEvent, "name", strName); - - FireEvent(hEvent, true); - - return Plugin_Handled; - } - } - } - return Plugin_Continue; -} -public Action:ev_PlayerConnect(Handle:event, const String:name[], bool:dontBroadcast) -{ - if (GetConVarBool(cvarBlockConnectMessage)) - { - if (!dontBroadcast) - { - decl String:strName[50]; - GetEventString(event, "name", strName, sizeof(strName)); - new iIndex = GetEventInt(event, "index"); - new iUserId = GetEventInt(event, "userid"); - new iClient = GetClientOfUserId(iUserId); - decl String:strNetworkId[50]; - GetEventString(event, "networkid", strNetworkId, sizeof(strNetworkId)); - decl String:strAddress[50]; - GetEventString(event, "address", strAddress, sizeof(strAddress)); - - if (iClient != 0) - { - if (GetConVarInt(cvarAdminShowMessages) == 1) - { - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientConnected(i) && IsClientInGame(i) && GetUserAdmin(i) != INVALID_ADMIN_ID) - { - PrintToChat(i,"%N has connected.", iClient); - PrintToConsole(i,"%N has connected.", iClient); - } - } - } - } - - new Handle:hEvent = CreateEvent("player_connect"); - SetEventString(hEvent, "name", strName); - SetEventInt(hEvent, "index", iIndex); - SetEventInt(hEvent, "userid", iUserId); - SetEventString(hEvent, "networkid", strNetworkId); - SetEventString(hEvent, "address", strAddress); - - FireEvent(hEvent, true); - - return Plugin_Handled; - } - } - return Plugin_Continue; -} -public Action:ev_PlayerDisconnect(Handle:event, const String:name[], bool:dontBroadcast) -{ - if (GetConVarBool(cvarBlockDisconnectMessage)) - { - if (!dontBroadcast) - { - new iUserId = GetEventInt(event, "userid"); - new iClient = GetClientOfUserId(iUserId); - decl String:strReason[50]; - GetEventString(event, "reason", strReason, sizeof(strReason)); - decl String:strName[50]; - GetEventString(event, "name", strName, sizeof(strName)); - decl String:strNetworkId[50]; - GetEventString(event, "networkid", strNetworkId, sizeof(strNetworkId)); - - if (iClient != 0) - { - if (GetConVarInt(cvarAdminShowMessages) == 1) - { - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientConnected(i) && IsClientInGame(i) && GetUserAdmin(i) != INVALID_ADMIN_ID) - { - PrintToChat(i, "%N has left the server.", iClient); - PrintToConsole(i, "Dropped %N from server (Disconnect by user.)", iClient); - } - } - } - } - - new Handle:hEvent = CreateEvent("player_disconnect"); - SetEventInt(hEvent, "userid", iUserId); - SetEventString(hEvent, "reason", strReason); - SetEventString(hEvent, "name", strName); - SetEventString(hEvent, "networkid", strNetworkId); - - FireEvent(hEvent, true); - - return Plugin_Handled; - } - } - - return Plugin_Continue; -} \ No newline at end of file diff --git a/Simple AllTalk Manager/addons/sourcemod/scripting/simple-plugins.sp b/Simple AllTalk Manager/addons/sourcemod/scripting/simple-plugins.sp deleted file mode 100644 index 4462b41..0000000 --- a/Simple AllTalk Manager/addons/sourcemod/scripting/simple-plugins.sp +++ /dev/null @@ -1,785 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Plugins -Description: - Core plugin for Simple Plugins project -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#define CORE_PLUGIN_VERSION "1.1.$Rev$" - -#include - -enum e_PlayerInfo -{ - Handle:hForcedTeamPlugin = INVALID_HANDLE, - iForcedTeam = 0, - iBuddy = 0, - bool:bBuddyLocked = false -}; - -new Handle:g_fwdPlayerMoved; -new g_aPlayers[MAXPLAYERS + 1][e_PlayerInfo]; -new bool:g_bTeamsSwitched = false; - -/** -Setting our plugin information. -*/ -public Plugin:myinfo = -{ - name = "Simple Plugins Core Plugin", - author = "Simple Plugins", - description = "Core plugin for Simple Plugins", - version = CORE_PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -}; - -public bool:AskPluginLoad(Handle:myself, bool:late, String:error[], err_max) -{ - - /** - Register natives for other plugins - */ - CreateNative("SM_MovePlayer", Native_SM_MovePlayer); - CreateNative("SM_SetForcedTeam", Native_SM_SetForcedTeam); - CreateNative("SM_GetForcedTeam", Native_SM_GetForcedTeam); - CreateNative("SM_ClearForcedTeam", Native_SM_ClearForcedTeam); - CreateNative("SM_GetForcedPlayer", Native_SM_GetForcedPlayer); - CreateNative("SM_AssignBuddy", Native_SM_AssignBuddy); - CreateNative("SM_GetClientBuddy", Native_SM_GetClientBuddy); - CreateNative("SM_LockBuddy", Native_SM_LockBuddy); - CreateNative("SM_IsBuddyLocked", Native_SM_IsBuddyLocked); - CreateNative("SM_ClearBuddy", Native_SM_ClearBuddy); - CreateNative("SM_IsValidAdmin", Native_SM_IsValidAdmin); - CreateNative("SM_IsValidTeam", Native_SM_IsValidTeam); - RegPluginLibrary("simpleplugins"); - return true; -} - -public OnPluginStart() -{ - - CreateConVar("ssm_core_pl_ver", CORE_PLUGIN_VERSION, "Simple SourceMod Plugins Core Plugin Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - CreateConVar("ssm_core_inc_ver", CORE_INC_VERSION, "Simple SourceMod Plugins Core Include Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook some events to control forced players and check extensions - */ - decl String:sExtError[256]; - LogAction(0, -1, "[SSM] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_team", HookPlayerChangeTeam, EventHookMode_Pre); - switch (g_CurrentMod) - { - case GameType_CSS: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - new iExtStatus = GetExtensionFileStatus("game.cstrike.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SSM] Required extension was not found."); - LogAction(0, -1, "[SSM] Plugin FAILED TO LOAD."); - SetFailState("Required extension was not found."); - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SSM] Required extension is loaded with errors."); - LogAction(0, -1, "[SSM] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SSM] Plugin FAILED TO LOAD."); - SetFailState("Required extension is loaded with errors."); - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SSM] Required extension is loaded."); - } - } - case GameType_TF: - { - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_PostNoCopy); - HookUserMessage(GetUserMessageId("TextMsg"), UserMessageHook_Class, true); - new iExtStatus = GetExtensionFileStatus("game.tf2.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SSM] Required extension was not found."); - LogAction(0, -1, "[SSM] Plugin FAILED TO LOAD."); - SetFailState("Required extension was not found."); - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SSM] Required extension is loaded with errors."); - LogAction(0, -1, "[SSM] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SSM] Plugin FAILED TO LOAD."); - SetFailState("Required extension is loaded with errors."); - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SSM] Required extension is loaded."); - } - } - case GameType_DOD: - { - HookEvent("dod_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_PostNoCopy); - } - default: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - } - } - - /** - Load common translations - */ - LoadTranslations ("common.phrases"); - - /** - Create the global forward - */ - g_fwdPlayerMoved = CreateGlobalForward("SM_OnPlayerMoved", ET_Event, Param_Cell, Param_Cell, Param_Cell); -} - -public OnClientDisconnect(client) -{ - - /** - Cleanup clients/players buddy list - */ - if (!IsFakeClient(client)) - { - SM_ClearBuddy(client, true); - SM_LockBuddy(client, false); - } - SM_ClearForcedTeam(client); -} - -public HookRoundStart(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - See if the teams have been switched - */ - if (g_bTeamsSwitched) - { - - /** - Switch the teams the players are forced to - */ - for (new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][iForcedTeam] != 0) - { - if (g_aPlayers[i][iForcedTeam] == g_aCurrentTeams[Team1]) - { - g_aPlayers[i][iForcedTeam] = g_aCurrentTeams[Team2]; - } - else - { - g_aPlayers[i][iForcedTeam] = g_aCurrentTeams[Team1]; - } - } - } - } -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - g_bTeamsSwitched = false; -} - -public HookPlayerChangeTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get our event variables - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - new iTeam = GetEventInt(event, "team"); - - /** - See if the player is on the wrong team - */ - if (g_aPlayers[iClient][iForcedTeam] != 0 && g_aPlayers[iClient][iForcedTeam] != iTeam) - { - - /** - Move the player back to the forced team - */ - CreateTimer(1.0, Timer_ForcePlayerMove, iClient, TIMER_FLAG_NO_MAPCHANGE); - - /** - If the event was going to be broadcasted, we refire it so it is not broadcasted and stop this one - */ - if (!dontBroadcast) - { - new Handle:hEvent = CreateEvent("player_team"); - SetEventInt(hEvent, "userid", GetEventInt(event, "userid")); - SetEventInt(hEvent, "team", GetEventInt(event, "team")); - SetEventInt(hEvent, "oldteam", GetEventInt(event, "oldteam")); - SetEventBool(hEvent, "disconnect", GetEventBool(event, "disconnect")); - - if (g_CurrentMod == GameType_DOD || g_CurrentMod == GameType_L4D || g_CurrentMod == GameType_TF) - { - new String:sClientName[MAX_NAME_LENGTH + 1]; - GetClientName(client, sClientName, sizeof(sClientName)); - SetEventBool(hEvent, "autoteam", GetEventBool(event, "autoteam")); - SetEventBool(hEvent, "silent", true); - SetEventString(hEvent, "name", sClientName); - FireEvent(hEvent, true); - } - else - { - FireEvent(hEvent, true); - } - return Plugin_Handled; - } - } - return Plugin_Continue; -} - -public Action:UserMessageHook_Class(UserMsg:msg_id, Handle:bf, const players[], playersNum, bool:reliable, bool:init) -{ - new String:sMessage[120]; - BfReadString(bf, sMessage, sizeof(sMessage), true); - if (StrContains(sMessage, "#TF_TeamsSwitched", false) != -1) - { - g_bTeamsSwitched = true; - } - return Plugin_Continue; -} - -public Native_SM_MovePlayer(Handle:plugin, numParams) -{ - - /** - Get and check the client and team - */ - new iClient = GetNativeCell(1); - new iTeam = GetNativeCell(2); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (iTeam != g_aCurrentTeams[Spectator] && iTeam != g_aCurrentTeams[Team1] && iTeam != g_aCurrentTeams[Team2]) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid team %d", iTeam); - } - - MovePlayer(iClient, iTeam); - if (!IsClientObserver(iClient)) - { - RespawnPlayer(iClient); - } - - new fResult; - - Call_StartForward(g_fwdPlayerMoved); - Call_PushCell(plugin); - Call_PushCell(iClient); - Call_PushCell(iTeam); - Call_Finish(fResult); - - if (fResult != SP_ERROR_NONE) - { - return ThrowNativeError(fResult, "Forward failed"); - } - - return fResult; -} - -public Native_SM_SetForcedTeam(Handle:plugin, numParams) -{ - - /** - Get and check the client and team - */ - new iClient = GetNativeCell(1); - new iTeam = GetNativeCell(2); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (iTeam != g_aCurrentTeams[Spectator] && iTeam != g_aCurrentTeams[Team1] && iTeam != g_aCurrentTeams[Team2] && iTeam != g_aCurrentTeams[Unknown]) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid team %d", iTeam); - } - - new bool:bOverRide = GetNativeCell(3) ? true : false; - - if (!bOverRide && g_aPlayers[iClient][hForcedTeamPlugin] != INVALID_HANDLE && plugin != g_aPlayers[iClient][hForcedTeamPlugin]) - { - return false; - } - - g_aPlayers[iClient][hForcedTeamPlugin] = plugin; - g_aPlayers[iClient][iForcedTeam] = iTeam; - return true; -} - -public Native_SM_GetForcedTeam(Handle:plugin, numParams) -{ - - /** - Get and check the client - */ - new iClient = GetNativeCell(1); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - - /** - Get and set the plugin if they want it - */ - new Handle:hPlugin = GetNativeCell(2); - if (hPlugin != INVALID_HANDLE) - { - SetNativeCellRef(2, g_aPlayers[iClient][hForcedTeamPlugin]); - } - - /** - Return the forced team, this could be 0 - */ - return g_aPlayers[iClient][iForcedTeam]; -} - -public Native_SM_ClearForcedTeam(Handle:plugin, numParams) -{ - - /** - Get and check the client and team - */ - new iClient = GetNativeCell(1); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - - g_aPlayers[iClient][hForcedTeamPlugin] = INVALID_HANDLE; - g_aPlayers[iClient][iForcedTeam] = 0; - - return true; -} - -public Native_SM_GetForcedPlayer(Handle:plugin, numParams) -{ - - /** - Get and check the team - */ - new iTeam = GetNativeCell(1); - if (iTeam != g_aCurrentTeams[Spectator] && iTeam != g_aCurrentTeams[Team1] && iTeam != g_aCurrentTeams[Team2]) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid team %d", iTeam); - } - - /** - Start a loop to check for a player on the wrong team - Also make sure the plugin that set the forced team is the plugin that asked - */ - new iPlayer = 0; - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientInGame(i) - && GetClientTeam(i) != g_aPlayers[i][iForcedTeam] - && g_aPlayers[i][iForcedTeam] == iTeam - && g_aPlayers[i][hForcedTeamPlugin] == plugin) - { - iPlayer = i; - break; - } - } - - /** - Return the player we found, this could be 0 - */ - return iPlayer; -} - -public Native_SM_AssignBuddy(Handle:plugin, numParams) -{ - - /** - Get and check the client and player - */ - new iClient = GetNativeCell(1); - new iPlayer = GetNativeCell(2); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (iPlayer < 0 || iPlayer > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid player index (%d)", iPlayer); - } - if (!IsClientConnected(iPlayer)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Player %d is not connected", iPlayer); - } - if (!IsClientInGame(iPlayer)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Player %d is not in the game", iClient); - } - if (IsFakeClient(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Bots are not supported"); - } - - /** - See if we can override his setting - */ - new bool:bOverRide = GetNativeCell(3) ? true : false; - if (!bOverRide) - { - - /** - We can't override, so check if they are locked - */ - if (g_aPlayers[iClient][bBuddyLocked] || g_aPlayers[iPlayer][bBuddyLocked]) - { - - /** - We detected at least 1 lock, so we bug out - */ - return false; - } - } - - /** - Ready to set the buddies - */ - g_aPlayers[iClient][iBuddy] = iPlayer; - g_aPlayers[iPlayer][iBuddy] = iClient; - return true; -} - -public Native_SM_GetClientBuddy(Handle:plugin, numParams) -{ - - /** - Get and check the client - */ - new iClient = GetNativeCell(1); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (IsFakeClient(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Bots are not supported"); - } - - /** - Return the players buddy, this could be 0 - */ - return g_aPlayers[iClient][iBuddy]; -} - -public Native_SM_LockBuddy(Handle:plugin, numParams) -{ - - /** - Get and check the client - */ - new iClient = GetNativeCell(1); - new bool:bSetting = GetNativeCell(2) ? true : false; - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (IsFakeClient(iClient)) - { - return ThrowNativeError(SP_ERROR_NATIVE, "Bots are not supported"); - } - - g_aPlayers[iClient][bBuddyLocked] = bSetting; - return true; -} - -public Native_SM_IsBuddyLocked(Handle:plugin, numParams) -{ - - /** - Get and check the client - */ - new iClient = GetNativeCell(1); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (IsFakeClient(iClient)) - { - return ThrowNativeError(SP_ERROR_NATIVE, "Bots are not supported"); - } - - return g_aPlayers[iClient][bBuddyLocked]; -} - -public Native_SM_ClearBuddy(Handle:plugin, numParams) -{ - - /** - Get and check the client - */ - new iClient = GetNativeCell(1); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_NATIVE, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_NATIVE, "Client (%d) is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (IsFakeClient(iClient)) - { - return ThrowNativeError(SP_ERROR_NATIVE, "Bots are not supported"); - } - - /** - Get the clients buddy and see if we can override his setting - */ - new bool:bOverRide = GetNativeCell(2) ? true : false; - new iPlayer = g_aPlayers[iClient][iBuddy]; - - /** - There is no buddy, we don't care about anything else so bug out - */ - if (iPlayer == 0) - { - return true; - } - - /** - We determined he had a buddy, check the override setting - */ - if (!bOverRide) - { - - /** - We can't override, so check if they are locked - */ - if (g_aPlayers[iClient][bBuddyLocked] || g_aPlayers[iPlayer][bBuddyLocked]) - { - - /** - We detected at least 1 lock, so we bug out - */ - return false; - } - } - - /** - Ready to clear the buddies - */ - g_aPlayers[iClient][iBuddy] = 0; - g_aPlayers[iPlayer][iBuddy] = 0; - return true; -} - -public Native_SM_IsValidTeam(Handle:plugin, numParams) -{ - - /** - Get the team - */ - new iTeam = GetNativeCell(1); - - /** - Check the team - */ - if (iTeam == g_aCurrentTeams[Spectator] || iTeam == g_aCurrentTeams[Team1] || iTeam == g_aCurrentTeams[Team2]) - { - return true; - } - return false; -} - -public Native_SM_IsValidAdmin(Handle:plugin, numParams) -{ - /** - Get the client and flags - */ - new iClient = GetNativeCell(1); - decl String:sFlags[15]; - GetNativeString(2, sFlags, sizeof(sFlags)); - new ibFlags = ReadFlagString(sFlags); - - /** - Check the flags - */ - if ((GetUserFlagBits(iClient) & ibFlags) == ibFlags) - { - return true; - } - if (GetUserFlagBits(iClient) & ADMFLAG_ROOT) - { - return true; - } - return false; -} - -public Action:Timer_ForcePlayerMove(Handle:timer, any:iClient) -{ - - MovePlayer(iClient, g_aPlayers[iClient][iForcedTeam]); - - if (g_aPlayers[iClient][iForcedTeam] != g_aCurrentTeams[Spectator]) - { - RespawnPlayer(iClient); - } - - PrintToChat(iClient, "\x01\x04----------------------------------"); - PrintToChat(iClient, "\x01\x04You have been forced to this team."); - PrintToChat(iClient, "\x01\x04----------------------------------"); - - return Plugin_Handled; -} - -stock MovePlayer(iClient, iTeam) -{ - - /** - Change the client's team based on the mod - */ - switch (g_CurrentMod) - { - case GameType_CSS: - { - CS_SwitchTeam(iClient, iTeam); - } - default: - { - ChangeClientTeam(iClient, iTeam); - } - } -} - -stock RespawnPlayer(iClient) -{ - - /** - Respawn the client based on the mod - */ - switch (g_CurrentMod) - { - case GameType_CSS: - { - CS_RespawnPlayer(iClient); - } - case GameType_TF: - { - TF2_RespawnPlayer(iClient); - } - case GameType_INS: - { - FakeClientCommand(iClient, "kill"); - } - default: - { - // - } - } -} diff --git a/Simple AllTalk Manager/addons/sourcemod/scripting/simple-roundimmunity.sp b/Simple AllTalk Manager/addons/sourcemod/scripting/simple-roundimmunity.sp deleted file mode 100644 index 5f0bca3..0000000 --- a/Simple AllTalk Manager/addons/sourcemod/scripting/simple-roundimmunity.sp +++ /dev/null @@ -1,947 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Round Immunity -Description: - Gives admins immunity during certain rounds -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or any later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#pragma semicolon 1 -#include -#include -#undef REQUIRE_EXTENSIONS -#undef AUTOLOAD_EXTENSIONS -#include -#include -#define REQUIRE_EXTENSIONS -#define AUTOLOAD_EXTENSIONS - -#define PLUGIN_VERSION "1.1.$Rev$" -#define SPECTATOR 1 -#define TEAM_RED 2 -#define TEAM_BLUE 3 - -#define COLOR_GREEN 0 -#define COLOR_BLACK 1 -#define COLOR_RED 2 -#define COLOR_BLUE 3 -#define COLOR_TEAM 4 -#define COLOR_RAINBOW 5 -#define COLOR_NONE 6 - -#define PLAYERCOND_SLOWED (1<<0) //1 -#define PLAYERCOND_ZOOMED (1<<1) //2 -#define PLAYERCOND_DISGUISING (1<<2) //4 -#define PLAYERCOND_DISGUISED (1<<3) //8 -#define PLAYERCOND_SPYCLOAK (1<<4) //16 -#define PLAYERCOND_UBERED (1<<5) //32 -#define PLAYERCOND_TELEPORTTRAIL (1<<6) //64 -#define PLAYERCOND_TAUNT (1<<7) //128 -// (1<<8) //256 -// (1<<9) //512 -#define PLAYERCOND_TELEPORTFLASH (1<<10) //1024 -#define PLAYERCOND_KRUBER (1<<11) //2048 -// (1<<12) //4096 -// (1<<13) //8192 -#define PLAYERCOND_BONKED (1<<14) //16384 (blame Neph if it doesn't work) -#define PLAYERCOND_BONKEDORDRINKSLOWDOWN (1<<15) //32768 -#define PLAYERCOND_HEALING (1<<16) //65536 -#define PLAYERCOND_BURNING (1<<17) //131072 -#define PLAYERCOND_FULLYCHARGEDBYMEDIC (1<<18) //262144 - -enum e_Cookies -{ - bEnabled, - iColor, - iMode -}; - -enum e_ColorNames -{ - Green, - Black, - Red, - Blue -}; - -enum e_ColorValues -{ - iRed, - iGreen, - iBlue -}; - -enum e_PlayerData -{ - Handle:hGodModeTimer, - Handle:hColorTimer, - bool:bIsAdmin, - bool:bIsImmune, - iCycleColor -}; - -/** - Global convar handles - */ -new Handle:sri_charadminflag = INVALID_HANDLE; -new Handle:sri_enabled = INVALID_HANDLE; -new Handle:sri_cookie_enabled = INVALID_HANDLE; -new Handle:sri_cookie_color = INVALID_HANDLE; -new Handle:sri_cookie_mode = INVALID_HANDLE; - -/** - Player arrays - */ -new g_aPlayers[MAXPLAYERS + 1][e_PlayerData]; -new g_aClientCookies[MAXPLAYERS + 1][e_Cookies]; - -/** - Global bools - */ -new bool:g_bLoadedLate = false; -new bool:g_bIsEnabled = true; -new bool:g_bRoundEnd = false; -new bool:g_bUseDukehacks = false; -new bool:g_bUseClientprefs = false; - -/** - Global strings/integers/floats - */ -new String:g_sCharAdminFlag[32]; -new g_iColors[e_ColorNames][e_ColorValues]; -new g_iClassMaxHealth[TFClassType] = {0, 125, 125, 200, 175, 150, 300, 175, 125, 125}; - -public Plugin:myinfo = -{ - name = "Simple Round Immunity", - author = "Simple Plugins", - description = "Gives admins immunity during certain rounds", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -} - -bool:AskPluginLoad(Handle:myself, bool:late, String:error[], err_max) -{ - g_bLoadedLate = late; - return true; -} - -public OnPluginStart() -{ - - /** - Create console variables - */ - CreateConVar("sri_version", PLUGIN_VERSION, "Simple Round Immunity", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - sri_enabled = CreateConVar("sri_enabled", "1", "Enable/Disable Admin immunity during certain round."); - sri_charadminflag = CreateConVar("sri_charadminflag", "a", "Admin flag to use for immunity (only one). Must be a in char format."); - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook some events and check extensions - */ - decl String:sExtError[256]; - LogAction(0, -1, "[SRI] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_spawn", HookPlayerSpawn, EventHookMode_Post); - HookEvent("player_hurt", HookPlayerHurt, EventHookMode_Pre); - switch (g_CurrentMod) - { - case GameType_CSS: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - new iExtStatus = GetExtensionFileStatus("game.cstrike.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SRI] Required extension was not found."); - LogAction(0, -1, "[SRI] Plugin FAILED TO LOAD."); - SetFailState("Required extension was not found."); - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SRI] Required extension is loaded with errors."); - LogAction(0, -1, "[SRI] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SRI] Plugin FAILED TO LOAD."); - SetFailState("Required extension is loaded with errors."); - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SRI] Required css extension is loaded."); - } - } - case GameType_TF: - { - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_PostNoCopy); - HookUserMessage(GetUserMessageId("TextMsg"), UserMessageHook_Class, true); - new iExtStatus = GetExtensionFileStatus("game.tf2.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SRI] Required extension was not found."); - LogAction(0, -1, "[SRI] Plugin FAILED TO LOAD."); - SetFailState("Required extension was not found."); - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SRI] Required extension is loaded with errors."); - LogAction(0, -1, "[SRI] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SRI] Plugin FAILED TO LOAD."); - SetFailState("Required extension is loaded with errors."); - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SRI] Required tf2 extension is loaded."); - } - iExtStatus = GetExtensionFileStatus("dukehacks.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SRI] Dukehacks extension was not found."); - LogAction(0, -1, "[SRI] Plugin continued to load, but that feature will not be used."); - g_bUseDukehacks = false; - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SRI] Dukehacks extension is loaded with errors."); - LogAction(0, -1, "[SRI] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SRI] Plugin continued to load, but that feature will not be used."); - g_bUseDukehacks = false; - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SRI] Dukehacks extension is loaded and will be used."); - g_bUseDukehacks = true; - dhAddClientHook(CHK_TakeDamage, Hacks_TakeDamageHook); - } - } - case GameType_DOD: - { - HookEvent("dod_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_PostNoCopy); - } - default: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - } - } - /** - Now lets check for client prefs extension - */ - new iExtStatus = GetExtensionFileStatus("clientprefs.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SRI] Client Preferences extension was not found."); - LogAction(0, -1, "[SRI] Plugin continued to load, but that feature will not be used."); - g_bUseClientprefs = false; - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SRI] Client Preferences extension is loaded with errors."); - LogAction(0, -1, "[SRI] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SRI] Plugin continued to load, but that feature will not be used."); - g_bUseClientprefs = false; - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SRI] Client Preferences extension is loaded, checking database."); - if (!SQL_CheckConfig(clientprefs)) - { - LogAction(0, -1, "[SRI] No 'clientprefs' database found. Check your database.cfg file."); - LogAction(0, -1, "[SRI] Plugin continued to load, but Client Preferences will not be used."); - g_bUseClientprefs = false; - } - g_bUseClientprefs = true; - - /** - Deal with client cookies - */ - sri_cookie_enabled = RegClientCookie("bri_client_enabled", "Enable/Disable your immunity during the bonus round.", CookieAccess_Public); - sri_cookie_color = RegClientCookie("bri_client_color", "Color to render when immune.", CookieAccess_Public); - sri_cookie_mode = RegClientCookie("bri_client_mode", "God mode to select", CookieAccess_Public); - SetCookieMenuItem(CookieMenu_TopMenu, sri_cookie_enabled, "Bonus Round Immunity"); - } - - HookConVarChange(sri_enabled, EnabledChanged); - - RegAdminCmd("sm_immunity", Command_Immunity, ADMFLAG_ROOT, "sm_immunity: Gives you immunity"); - - LoadColors(); - - AutoExecConfig(true, "plugin.simpleroundimmunity"); -} - -public OnAllPluginsLoaded() -{ - //something - // need to deal with the unloading of dukehacks, clientprefs, and simpleplugins - // should move hooking the client prefs cookies to a function to make sure they are done post plugin start if ext is loaded late -} - -public OnLibraryRemoved(const String:name[]) -{ - //something - // need to deal with the loading of dukehacks, clientprefs, and simpleplugins -} - -public OnConfigsExecuted() -{ - GetConVarString(sri_charadminflag, g_sCharAdminFlag, sizeof(g_sCharAdminFlag)); - g_bIsEnabled = GetConVarBool(sri_enabled); - g_bRoundEnd = false; -} - -/** - Client events - */ - -public OnClientPostAdminCheck(client) -{ - if (SM_IsValidAdmin(client, g_sCharAdminFlag)) - g_aPlayers[client][bIsAdmin] = true; - else - g_aPlayers[client][bIsAdmin] = false; -} - -public OnClientCookiesCached(client) -{ - decl String:sEnabled[2], String:sColor[4], String:sMode[2]; - GetClientCookie(client, sri_cookie_enabled, sEnabled, sizeof(sEnabled)); - GetClientCookie(client, sri_cookie_color, sColor, sizeof(sColor)); - GetClientCookie(client, sri_cookie_mode, sMode, sizeof(sMode)); - g_aClientCookies[client][bEnabled] = StringToInt(sEnabled); - g_aClientCookies[client][iColor] = StringToInt(sColor); - g_aClientCookies[client][iMode] = StringToInt(sMode); -} - -public OnClientDisconnect(client) -{ - CleanUp(client); -} - -/** - Commands - */ - -public Action:Command_Immunity(client, args) -{ - if (g_aPlayers[client][IsImmune]) - { - DisableImmunity(client); - } - else - { - EnableImmunity(client); - } - return Plugin_Handled; -} - -/** - Event hooks - */ - -public Action:Hacks_TakeDamageHook(client, attacker, inflictor, Float:damage, &Float:multiplier, damagetype) -{ - if (attacker == 0 || attacker >= MaxClients) - { - return Plugin_Continue; - } - if (g_aPlayers[client][IsImmune]) - { - new TFClassType:PlayerClass = TF2_GetPlayerClass(attacker); - if (PlayerClass == TFClass_Spy) - { - multiplier *= 0.0; - return Plugin_Changed; - } - } - return Plugin_Continue; -} - -public HookRoundStart(Handle:event, const String:name[], bool:dontBroadcast) -{ - g_bRoundEnd = false; - if (g_bIsEnabled) - { - for (new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][IsImmune]) - { - DisableImmunity(i); - } - } - } -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - g_bRoundEnd = true; - if (g_bIsEnabled) - { - for (new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][bIsAdmin]) - { - EnableImmunity(i); - } - } - } -} - -public HookPlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast) -{ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - if (g_bIsEnabled && g_aPlayers[iClient][bIsAdmin] && g_bRoundEnd) - { - EnableImmunity(iClient); - } -} - -public Action:HookPlayerHurt(Handle:event, const String:name[], bool:dontBroadcast) -{ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - if (g_aPlayers[iClient][IsImmune]) - { - SetEntityHealth(iClient, 2000); - return Plugin_Continue; - } - return Plugin_Continue; -} - -/** - Cookie menus - */ - -public CookieMenu_TopMenu(client, CookieMenuAction:action, any:info, String:buffer[], maxlen) -{ - if (action == CookieMenuAction_DisplayOption) - { - //don't think we need to do anything - } - else - { - new Handle:hMenu = CreateMenu(Menu_CookieSettings); - SetMenuTitle(hMenu, "Options (Current Setting)"); - if (g_aClientCookies[client][bEnabled]) - { - AddMenuItem(hMenu, "enable", "Enabled/Disable (Enabled)"); - } - else - { - AddMenuItem(hMenu, "enable", "Enabled/Disable (Disabled)"); - } - if (g_aClientCookies[client][iMode]) - { - AddMenuItem(hMenu, "mode", "Immunity Mode Setting (God Mode)"); - } - else - { - AddMenuItem(hMenu, "mode", "Immunity Mode Setting (Health)"); - } - switch (g_aClientCookies[client][iColor]) - { - case COLOR_GREEN: - { - AddMenuItem(hMenu, "color", "Color (Green)"); - } - case COLOR_BLACK: - { - AddMenuItem(hMenu, "color", "Color (Black)"); - } - case COLOR_RED: - { - AddMenuItem(hMenu, "color", "Color (Red)"); - } - case COLOR_BLUE: - { - AddMenuItem(hMenu, "color", "Color (Blue)"); - } - case COLOR_TEAM: - { - AddMenuItem(hMenu, "color", "Color (Team)"); - } - case COLOR_RAINBOW: - { - AddMenuItem(hMenu, "color", "Color (Rainbow)"); - } - case COLOR_NONE: - { - AddMenuItem(hMenu, "color", "Color (None)"); - } - } - SetMenuExitBackButton(hMenu, true); - DisplayMenu(hMenu, client, MENU_TIME_FOREVER); - } -} - -public Menu_CookieSettings(Handle:menu, MenuAction:action, param1, param2) -{ - new client = param1; - if (action == MenuAction_Select) - { - new String:sSelection[24]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "enable", false)) - { - new Handle:hMenu = CreateMenu(Menu_CookieSettingsEnable); - SetMenuTitle(hMenu, "Enable/Disable Round End Immunity"); - - if (g_aClientCookies[client][bEnabled]) - { - AddMenuItem(hMenu, "enable", "Enable (Set)"); - AddMenuItem(hMenu, "disable", "Disable"); - } - else - { - AddMenuItem(hMenu, "enable", "Enabled"); - AddMenuItem(hMenu, "disable", "Disable (Set)"); - } - - SetMenuExitBackButton(hMenu, true); - DisplayMenu(hMenu, client, MENU_TIME_FOREVER); - } - else if (StrEqual(sSelection, "mode", false)) - { - new Handle:hMenu = CreateMenu(Menu_CookieSettingsMode); - SetMenuTitle(hMenu, "Set Immunity Mode"); - - if (g_aClientCookies[client][iMode]) - { - AddMenuItem(hMenu, "god", "God Mode (Set)"); - AddMenuItem(hMenu, "health", "Health"); - } - else - { - AddMenuItem(hMenu, "god", "God Mode"); - AddMenuItem(hMenu, "health", "Health (Set)"); - } - - SetMenuExitBackButton(hMenu, true); - DisplayMenu(hMenu, client, MENU_TIME_FOREVER); - } - else - { - new Handle:hMenu = CreateMenu(Menu_CookieSettingsColors); - SetMenuTitle(hMenu, "Select Immunity Color"); - switch (g_aClientCookies[client][iColor]) - { - case COLOR_GREEN: - { - AddMenuItem(hMenu, "Green", "Green (Set)"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_BLACK: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black (Set)"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_RED: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red (Set)"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_BLUE: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue (Set)"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_TEAM: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color (Set)"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_RAINBOW: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow (Set)"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_NONE: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None (Set)"); - } - } - SetMenuExitBackButton(hMenu, true); - DisplayMenu(hMenu, client, MENU_TIME_FOREVER); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - ShowCookieMenu(client); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } -} - -public Menu_CookieSettingsEnable(Handle:menu, MenuAction:action, param1, param2) -{ - new client = param1; - if (action == MenuAction_Select) - { - new String:sSelection[24]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "enable", false)) - { - SetClientCookie(client, sri_cookie_enabled, "1"); - g_aClientCookies[client][bEnabled] = 1; - PrintToChat(client, "[SM] Bonus Round Immunity is ENABLED"); - } - else - { - SetClientCookie(client, sri_cookie_enabled, "0"); - g_aClientCookies[client][bEnabled] = 0; - PrintToChat(client, "[SM] Bonus Round Immunity is DISABLED"); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - ShowCookieMenu(client); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } -} - -public Menu_CookieSettingsColors(Handle:menu, MenuAction:action, param1, param2) -{ - new client = param1; - if (action == MenuAction_Select) - { - new String:sSelection[24]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "Green", false)) - { - SetClientCookie(client, sri_cookie_color, "0"); - g_aClientCookies[client][iColor] = COLOR_GREEN; - PrintToChat(client, "[SM] Bonus Round Immunity color set to GREEN"); - } - else if (StrEqual(sSelection, "Black", false)) - { - SetClientCookie(client, sri_cookie_color, "1"); - g_aClientCookies[client][iColor] = COLOR_BLACK; - PrintToChat(client, "[SM] Bonus Round Immunity color set to BLACK"); - } - else if (StrEqual(sSelection, "Red", false)) - { - SetClientCookie(client, sri_cookie_color, "2"); - g_aClientCookies[client][iColor] = COLOR_RED; - PrintToChat(client, "[SM] Bonus Round Immunity color set to RED"); - } - else if (StrEqual(sSelection, "Blue", false)) - { - SetClientCookie(client, sri_cookie_color, "3"); - g_aClientCookies[client][iColor] = COLOR_BLUE; - PrintToChat(client, "[SM] Bonus Round Immunity color set to BLUE"); - } - else if (StrEqual(sSelection, "Team", false)) - { - SetClientCookie(client, sri_cookie_color, "4"); - g_aClientCookies[client][iColor] = COLOR_TEAM; - PrintToChat(client, "[SM] Bonus Round Immunity color set to TEAM COLOR"); - } - else if (StrEqual(sSelection, "Rain", false)) - { - SetClientCookie(client, sri_cookie_color, "5"); - g_aClientCookies[client][iColor] = COLOR_RAINBOW; - PrintToChat(client, "[SM] Bonus Round Immunity color set to RAINBOW"); - } - else if (StrEqual(sSelection, "None", false)) - { - SetClientCookie(client, sri_cookie_color, "6"); - g_aClientCookies[client][iColor] = COLOR_NONE; - PrintToChat(client, "[SM] Bonus Round Immunity color set to NONE"); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - ShowCookieMenu(client); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } -} - -public Menu_CookieSettingsMode(Handle:menu, MenuAction:action, param1, param2) -{ - new client = param1; - if (action == MenuAction_Select) - { - new String:sSelection[24]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "god", false)) - { - SetClientCookie(client, sri_cookie_mode, "1"); - g_aClientCookies[client][iMode] = 1; - PrintToChat(client, "[SM] Bonus Round Immunity set to GOD MODE"); - } - else - { - SetClientCookie(client, sri_cookie_mode, "0"); - g_aClientCookies[client][iMode] = 0; - PrintToChat(client, "[SM] Bonus Round Immunity set to HEALTH BONUS"); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - ShowCookieMenu(client); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } -} - -/** -Timer functions - */ - -public Action:Timer_ChangeColor(Handle:timer, any:client) -{ - if (g_aPlayers[client][CycleColor]++ == 3) - { - g_aPlayers[client][CycleColor] = 0; - } - SetEntityRenderMode(client, RENDER_TRANSCOLOR); - SetEntityRenderColor(client, g_iColors[g_aPlayers[client][CycleColor]][iRed], g_iColors[g_aPlayers[client][CycleColor]][iGreen], g_iColors[g_aPlayers[client][CycleColor]][iBlue], 255); - return Plugin_Continue; -} - -public Action:Timer_UndoGodMode(Handle:timer, any:client) -{ - if (IsClientInGame(client)) - { - SetEntProp(client, Prop_Data, "m_takedamage", 2, 1); - } - g_aPlayers[iClient][hGodModeTimer] = INVALID_HANDLE; - return Plugin_Handled; -} - -/** -Stock functions . - */ - -stock CleanUp(iClient) -{ - g_aPlayers[iClient][bIsAdmin] = false; - DisableImmunity(iClient); -} - -stock EnableImmunity(iClient) -{ - SetEntityRenderMode(iClient, RENDER_TRANSCOLOR); - switch (g_aClientCookies[iClient][iColor]) - { - case COLOR_TEAM: - { - new iTeam = GetClientTeam(iClient); - SetEntityRenderColor(iClient, g_iColors[e_ColorNames:iTeam][iRed], g_iColors[e_ColorNames:iTeam][iGreen], g_iColors[e_ColorNames:iTeam][iBlue], 255); - } - case COLOR_RAINBOW: - { - if (g_aPlayers[iClient][hColorTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[iClient][hColorTimer]); - g_aPlayers[iClient][hColorTimer] = INVALID_HANDLE; - } - g_aPlayers[iClient][hColorTimer] = CreateTimer(0.2, Timer_ChangeColor, iClient, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); - } - case COLOR_NONE: - { - //We dont have to set a color - } - default: - { - SetEntityRenderColor(iClient, g_iColors[e_ColorNames:g_aClientCookies[iClient][iColor]][iRed], g_iColors[e_ColorNames:g_aClientCookies[iClient][iColor]][iGreen], g_iColors[e_ColorNames:g_aClientCookies[iClient][iColor]][iBlue], 255); - } - } - SetEntityHealth(iClient, 2000); - SetEntProp(iClient, Prop_Data, "m_takedamage", 0, 1); - g_aPlayers[iClient][hGodModeTimer] = CreateTimer(2.0, Timer_UndoGodMode, iClient); - g_aPlayers[iClient][IsImmune] = true; -} - -stock DisableImmunity(iClient) -{ - if (g_aPlayers[iClient][hGodModeTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[iClient][hGodModeTimer]); - g_aPlayers[iClient][hGodModeTimer] = INVALID_HANDLE; - } - if (g_aPlayers[iClient][hColorTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[iClient][hColorTimer]); - g_aPlayers[iClient][hColorTimer] = INVALID_HANDLE; - } - if (IsClientInGame(iClient)) - { - SetEntityRenderMode(iClient, RENDER_TRANSCOLOR); - SetEntityRenderColor(iClient, 255, 255, 255, 255); - new TFClassType:PlayerClass = TF2_GetPlayerClass(iClient); - new iMaxHealth = g_iClassMaxHealth[PlayerClass]; - SetEntityHealth(iClient, iMaxHealth); - } - g_aPlayers[iClient][CycleColor] = 0; - g_aPlayers[iClient][IsImmune] = false; -} - -stock LoadColors() -{ - g_iColors[Green][iRed] = 0; - g_iColors[Green][iGreen] = 255; - g_iColors[Green][iBlue] = 0; - - g_iColors[Black][iRed] = 10; - g_iColors[Black][iGreen] = 10; - g_iColors[Black][iBlue] = 0; - - g_iColors[Red][iRed] = 255; - g_iColors[Red][iGreen] = 0; - g_iColors[Red][iBlue] = 0; - - g_iColors[Blue][iRed] = 0; - g_iColors[Blue][iGreen] = 0; - g_iColors[Blue][iBlue] = 255; -} - -stock TF2_AddCond(client, cond) -{ - new Handle:cvar = FindConVar("sv_cheats"), bool:enabled = GetConVarBool(cvar), flags = GetConVarFlags(cvar); - if(!enabled) - { - SetConVarFlags(cvar, flags^FCVAR_NOTIFY); - SetConVarBool(cvar, true); - } - FakeClientCommand(client, "addcond %i", cond); - if(!enabled) - { - SetConVarBool(cvar, false); - SetConVarFlags(cvar, flags); - } -} - -stock TF2_RemoveCond(client, cond) -{ - new Handle:cvar = FindConVar("sv_cheats"), bool:enabled = GetConVarBool(cvar), flags = GetConVarFlags(cvar); - if(!enabled) - { - SetConVarFlags(cvar, flags^FCVAR_NOTIFY); - SetConVarBool(cvar, true); - } - FakeClientCommand(client, "removecond %i", cond); - if(!enabled) - { - SetConVarBool(cvar, false); - SetConVarFlags(cvar, flags); - } -} - -/** -Enabled hook - */ - -public EnabledChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (StringToInt(newValue) == 0) - { - UnhookEvent("player_spawn", HookPlayerSpawn, EventHookMode_Post); - UnhookEvent("teamplay_round_start", HookRoundStart, EventHookMode_Post); - UnhookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - for (new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][bIsAdmin] && g_aPlayers[i][IsImmune]) - { - DisableImmunity(i); - } - } - g_bIsEnabled = false; - } - else - { - HookEvent("player_spawn", HookPlayerSpawn, EventHookMode_Post); - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_Post); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - g_bIsEnabled = true; - } -} diff --git a/Simple AllTalk Manager/addons/sourcemod/scripting/simple-spectate.sp b/Simple AllTalk Manager/addons/sourcemod/scripting/simple-spectate.sp deleted file mode 100644 index 4108f8f..0000000 --- a/Simple AllTalk Manager/addons/sourcemod/scripting/simple-spectate.sp +++ /dev/null @@ -1,2022 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Spectate -Description: - Spectate a player and follow them through death. -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include -#undef REQUIRE_EXTENSIONS -#undef AUTOLOAD_EXTENSIONS -#tryinclude -#define AUTOLOAD_EXTENSIONS -#define REQUIRE_EXTENSIONS - -#define PLUGIN_VERSION "1.2.1.$Rev$" - -#define SPECMODE_NONE 0 -#define SPECMODE_FIRSTPERSON 4 -#define SPECMODE_3RDPERSON 5 -#define SPECMODE_FREELOOK 6 -#define SPECMODE_CSS_FIRSTPERSON 3 -#define SPECMODE_CSS_3RDPERSON 4 -#define SPECMODE_CSS_FREELOOK 5 - -enum e_CvarHandles -{ - Handle:hHudMode, - Handle:hMenuType, - Handle:hRestrictHud, - Handle:hBan, - Handle:hBanPerm, - Handle:hBeacon, - Handle:hBlind, - Handle:hCheater, - Handle:hDrug, - Handle:hFreeze, - Handle:hFreezeBomb, - Handle:hKick, - Handle:hSlap, - Handle:hSlay, - Handle:hTimeBomb -}; - -enum e_CvarSettings -{ - bool:bHudMode, - bool:bMenuType, - bool:bRestrictHud, - bool:bBan, - bool:bBanPerm, - bool:bBeacon, - bool:bBlind, - bool:bCheater, - bool:bDrug, - bool:bFreeze, - bool:bFreezebomb, - bool:bKick, - bool:bSlap, - bool:bSlay, - bool:bTimeBomb -}; - -enum e_PluginSettings -{ - bool:bUseSteamBans, - bool:bUseSourceBans, - bool:bUseMySQLBans, - bool:bCanHUD, - bool:bUseDukehacks -}; - -enum e_Menus -{ - Handle:hSelectPlayer, - Handle:hBanTime, - Handle:hReason -}; - -enum e_Punishments -{ - Punish_None, - Punish_Ban, - Punish_Beacon, - Punish_Blind, - Punish_Cheater, - Punish_Drug, - Punish_Freeze, - Punish_FreezeBomb, - Punish_Kick, - Punish_Slap, - Punish_Slay, - Punish_TimeBomb -}; - -enum e_PlayerData -{ - bool:bIsDisplayingHud, - bool:bIsFlaggedCheater, - Handle:hHudTimer, - Handle:hTargetTimer, - iTargetIndex, - e_Punishments:TargetPunishment, - iBanTime -}; - -new Handle:sm_spectate_adminflag = INVALID_HANDLE; -new Handle:g_hAdminMenu = INVALID_HANDLE; -new Handle:g_hHud = INVALID_HANDLE; -new Handle:g_aPluginCvar[e_CvarHandles]; -new g_aPluginCvarSettings[e_CvarSettings]; -new g_aPluginSettings[e_PluginSettings]; -new g_aMenus[e_Menus]; -new g_aPlayers[MAXPLAYERS + 1][e_PlayerData]; -new String:g_sAdminFlags[16]; -new String:g_sPunishments[e_Punishments][15] = { "None", "Ban", "Beacon", "Blind", "Cheater", "Drug", "Freeze", "FreezeBomb", "Kick", "Slap", "Slay", "TimeBomb" }; - -public Plugin:myinfo = -{ - name = "Simple Spectate", - author = "Simple Plugins", - description = "Spectate a player and follow them through death.", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -}; - -/** -Sourcemod callbacks -*/ -public OnPluginStart() -{ - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook the game events - */ - LogAction(0, -1, "[SSPEC] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_team", HookPlayerChangeTeam, EventHookMode_Pre); - - /** - Need to create all of our console variables. - */ - CreateConVar("sm_spectate_version", PLUGIN_VERSION, "Sourcemod Spectate", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - g_aPluginCvar[hHudMode] = CreateConVar("sm_spectate_hudmode", "1", "Hud Mode: 0 = Hud Text | 1 = Panel/Menu (NOTE: The panel/menu will override other menus until canceled)"); - g_aPluginCvar[hMenuType] = CreateConVar("sm_spectate_menutype", "0", "Menu Mode: 0 = Panel | 1 = Menu"); - g_aPluginCvar[hRestrictHud] = CreateConVar("sm_spectate_restricthud", "0", "Restrict the hud to the admin flag provided"); - g_aPluginCvar[hBan] = CreateConVar("sm_spectate_ban", "1", "Enable/Disable ban option"); - g_aPluginCvar[hBanPerm] = CreateConVar("sm_spectate_banperm", "1", "Enable/Disable permanent ban option"); - g_aPluginCvar[hBeacon] = CreateConVar("sm_spectate_beacon", "1", "Enable/Disable beacon option"); - g_aPluginCvar[hBlind] = CreateConVar("sm_spectate_blind", "1", "Enable/Disable blind option"); - g_aPluginCvar[hCheater] = CreateConVar("sm_spectate_cheater", "1", "Enable/Disable cheater option"); - g_aPluginCvar[hDrug] = CreateConVar("sm_spectate_drug", "1", "Enable/Disable drug option"); - g_aPluginCvar[hFreeze] = CreateConVar("sm_spectate_freeze", "1", "Enable/Disable freeze option"); - g_aPluginCvar[hFreezeBomb] = CreateConVar("sm_spectate_freezebomb", "1", "Enable/Disable freezebomb option"); - g_aPluginCvar[hKick] = CreateConVar("sm_spectate_kick", "1", "Enable/Disable kick option"); - g_aPluginCvar[hSlap] = CreateConVar("sm_spectate_slap", "1", "Enable/Disable slap option"); - g_aPluginCvar[hSlay] = CreateConVar("sm_spectate_slay", "1", "Enable/Disable slay option"); - g_aPluginCvar[hTimeBomb] = CreateConVar("sm_spectate_timebomb", "1", "Enable/Disable timebomb option"); - - sm_spectate_adminflag = CreateConVar("sm_spectate_adminflag", "d", "Admin Flag to use for admin hud"); - - /** - Hook console variables - */ - new e_CvarHandles:iCvar; - for ( ; _:iCvar < sizeof(g_aPluginCvar); iCvar++) - { - HookConVarChange(g_aPluginCvar[iCvar], ConVarSettingsChanged); - } - - /** - Need to register the commands we are going to create and use. - */ - RegConsoleCmd("sm_spectate", Command_Spectate, "Spectate a player"); - RegConsoleCmd("sm_spec", Command_Spectate, "Spectate a player"); - RegConsoleCmd("sm_observe", Command_Spectate, "Spectate a player"); - RegConsoleCmd("sm_stopspec", Command_StopSpectate, "Stop Spectating a player"); - RegConsoleCmd("sm_endobserve", Command_StopSpectate, "Stop Spectating a player"); - RegConsoleCmd("sm_specinfo", Command_ToggleHud, "Toggles the hud display if in spectator"); - - /** - Now we have to deal with the admin menu. If the admin library is loaded call the function to add our items. - */ - new Handle:gTopMenu; - if (LibraryExists("adminmenu") && ((gTopMenu = GetAdminTopMenu()) != INVALID_HANDLE)) - { - OnAdminMenuReady(gTopMenu); - } - - /** - Deal with the hud - Thanks to Spray Trace plugin (http://forums.alliedmods.net/showthread.php?p=665448) - */ - new String:sHudGames[32]; - GetGameFolderName(sHudGames, sizeof(sHudGames)); - g_aPluginSettings[bCanHUD] = StrEqual(sHudGames,"tf",false) - || StrEqual(sHudGames,"hl2mp",false) - || StrEqual(sHudGames,"sourceforts",false) - || StrEqual(sHudGames,"obsidian",false) - || StrEqual(sHudGames,"left4dead",false) - || StrEqual(sHudGames,"l4d",false); - - if (g_aPluginSettings[bCanHUD]) - { - g_hHud = CreateHudSynchronizer(); - } - - /** - Load translations - */ - LoadTranslations ("common.phrases"); - LoadTranslations ("simplespectate.phrases"); - - /** - Create the config file - */ - AutoExecConfig(true); -} - -public OnConfigsExecuted() -{ - new e_CvarHandles:iCvar; - for ( ; _:iCvar < sizeof(g_aPluginCvarSettings); iCvar++) - { - g_aPluginCvarSettings[iCvar] = GetConVarBool(g_aPluginCvar[iCvar]); - } - - /* - Build the global menus - */ - g_aMenus[hSelectPlayer] = BuildSelectPlayerMenu(); - g_aMenus[hBanTime] = BuildBanTimeMenu(); - g_aMenus[hReason] = BuildReasonMenu(); - - GetConVarString(sm_spectate_adminflag, g_sAdminFlags, sizeof(g_sAdminFlags)); -} - -public OnAllPluginsLoaded() -{ - - /* - Check for steambans - */ - if (FindConVar("sbsrc_version") != INVALID_HANDLE) - { - g_aPluginSettings[bUseSteamBans] = true; - } - else - { - g_aPluginSettings[bUseSteamBans] = false; - } - - /* - Check for sourcebans - */ - if (FindConVar("sb_version") != INVALID_HANDLE) - { - g_aPluginSettings[bUseSourceBans] = true; - } - else - { - g_aPluginSettings[bUseSourceBans] = false; - } - - /* - Check for mysql bans - */ - if (FindConVar("mysql_bans_version") != INVALID_HANDLE) - { - g_aPluginSettings[bUseMySQLBans] = true; - } - else - { - g_aPluginSettings[bUseMySQLBans] = false; - } - - /* - Check for dukehacks - */ - new String:sExtError[256]; - new iExtStatus = GetExtensionFileStatus("dukehacks.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SSPEC] Dukehacks extension was not found."); - LogAction(0, -1, "[SSPEC] Plugin continued to load, but that feature will not be used."); - g_aPluginSettings[bUseDukehacks] = false; - } - else if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SSPEC] Dukehacks extension is loaded with errors."); - LogAction(0, -1, "[SSPEC] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SSPEC] Plugin continued to load, but that feature will not be used."); - g_aPluginSettings[bUseDukehacks] = false; - } - else if (iExtStatus == 1) - { - LogAction(0, -1, "[SSPEC] Dukehacks extension is loaded and will be used."); - g_aPluginSettings[bUseDukehacks] = true; - dhAddClientHook(CHK_TakeDamage, Hacks_TakeDamageHook); - } - - /* - Deal with some known plugin conflicts - */ - new Handle:hObserveClient = FindConVar("observe_version"); - if (hObserveClient != INVALID_HANDLE) - { - new String:sNewFile[PLATFORM_MAX_PATH + 1], String:sOldFile[PLATFORM_MAX_PATH + 1]; - BuildPath(Path_SM, sNewFile, sizeof(sNewFile), "plugins/disabled/observe.smx"); - BuildPath(Path_SM, sOldFile, sizeof(sOldFile), "plugins/observe.smx"); - - /** - Check if plugins/observe.smx exists, and if not, ignore - */ - if(!FileExists(sOldFile)) - { - return; - } - - /** - Check if plugins/disabled/observe.smx already exists, and if so, delete it - */ - if(FileExists(sNewFile)) - { - DeleteFile(sNewFile); - } - - /** - Unload plugins/observe.smx and move it to plugins/disabled/observe.smx - */ - LogAction(0, -1, "Detected the plugin ObserveClient"); - LogAction(0, -1, "ObserveClient plugin conflicts with Simple Spectate"); - LogAction(0, -1, "Unloading plugin and disabling ObserveClient plugin"); - ServerCommand("sm plugins unload observe"); - RenameFile(sNewFile, sOldFile); - } -} - -public OnLibraryRemoved(const String:name[]) -{ - if (StrEqual(name, "adminmenu")) - { - - /** - Looks like the admin menu was removed. Set the global. - */ - g_hAdminMenu = INVALID_HANDLE; - } - else if (StrEqual(name, "simpleplugins")) - { - //something - } -} - -public OnClientDisconnect(client) -{ - - /** - Cleanup the clients variables. - */ - ResetClient(client); - - /** - Run a loop and see if we are supposed to spectate this person (is a target) - */ - for(new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][iTargetIndex] == client) - { - - /** - Cleanup the clients variables. - */ - StopFollowingPlayer(i); - g_aPlayers[i][TargetPunishment] = Punish_None; - g_aPlayers[i][iBanTime] = 0; - } - } -} - -/** -Thirdparty callbacks -*/ -public SM_OnPlayerMoved(Handle:plugin, client, team) -{ - - /** - Make sure we called the move function - */ - if (plugin != GetMyHandle()) - { - return; - } - - //Nothing -} - -public Action:Hacks_TakeDamageHook(client, attacker, inflictor, Float:damage, &Float:multiplier, damagetype) -{ - - /** - Check for a valid client - */ - if (client > 0 && client <= MaxClients) - { - - /** - Check if the client taking damage is flagged as a cheater - */ - if (g_aPlayers[client][bIsFlaggedCheater]) - { - - /** - Check for fall damage and increase it - */ - if (damagetype & DMG_FALL) - { - multiplier *= 1000.0; - return Plugin_Changed; - } - } - } - - /** - Check for a valid attacker - */ - if (attacker > 0 && attacker <= MaxClients) - { - - /** - Check if the attacker causing the damage is flagged as a cheater - */ - if (g_aPlayers[attacker][bIsFlaggedCheater]) - { - - /** - Make sure they are not hurting themselves - */ - if (client != attacker) - { - - /** - Stop the damage - */ - multiplier *= 0.0; - return Plugin_Changed; - } - } - } - return Plugin_Continue; -} - -/** -Events -*/ -public Action:HookPlayerChangeTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get the client and team - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - new iTeam = GetEventInt(event, "team"); - - /** - Make sure it's a valid client - */ - if (iClient == 0) - { - return Plugin_Continue; - } - - /** - If it's a move to spectator start displaying the hud - */ - else if ((iTeam == g_aCurrentTeams[Spectator]) && (GetUserFlagBits(iClient) & ADMFLAG_GENERIC)) - { - StartDisplayingHud(iClient); - - /** - If the event was going to be broadcasted, we refire it so it is not broadcasted and stop this one - */ - if (!dontBroadcast) - { - new Handle:hEvent = CreateEvent("player_team"); - SetEventInt(hEvent, "userid", GetEventInt(event, "userid")); - SetEventInt(hEvent, "team", GetEventInt(event, "team")); - SetEventInt(hEvent, "oldteam", GetEventInt(event, "oldteam")); - SetEventBool(hEvent, "disconnect", GetEventBool(event, "disconnect")); - - if (g_CurrentMod == GameType_DOD || g_CurrentMod == GameType_L4D || g_CurrentMod == GameType_TF) - { - new String:sClientName[MAX_NAME_LENGTH + 1]; - GetClientName(client, sClientName, sizeof(sClientName)); - SetEventBool(hEvent, "autoteam", GetEventBool(event, "autoteam")); - SetEventBool(hEvent, "silent", true); - SetEventString(hEvent, "name", sClientName); - FireEvent(hEvent, true); - } - else - { - FireEvent(hEvent, true); - } - return Plugin_Handled; - } - } - - /** - Otherwise cleanup the client - */ - else - { - StopDisplayingHud(iClient); - StopFollowingPlayer(iClient); - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -/** -Commands -*/ -public Action:Command_Spectate(client, args) -{ - - /** - See if we already have a target (for toggling of command) - */ - if (g_aPlayers[client][iTargetIndex]) - { - - /** - We do, toggle it off - */ - StopFollowingPlayer(client); - - /** - We are done, bug out. - */ - return Plugin_Handled; - } - - /** - We don't... must want to enable it - See if we have some command arguments. - */ - new iCmdArgs = GetCmdArgs(); - if (iCmdArgs == 0) - { - - /** - We don't have any. Display the player menu. - */ - if (g_aPlayers[client][bIsDisplayingHud]) - { - StopDisplayingHud(client); - } - - DisplayMenu(BuildPlayerListMenu(), client, MENU_TIME_FOREVER); - return Plugin_Handled; - } - - /** - We have an argument. - Try to find the target. - */ - new String:sPlayer[128]; - GetCmdArg(1, sPlayer, sizeof(sPlayer)); - new iTarget = FindTarget(client, sPlayer, true, true); - if (iTarget == -1 || !IsClientInGame(iTarget)) - { - - /** - We couldn't find the target. Display the player menu. - */ - if (g_aPlayers[client][bIsDisplayingHud]) - { - StopDisplayingHud(client); - } - - DisplayMenu(BuildPlayerListMenu(), client, MENU_TIME_FOREVER); - return Plugin_Handled; - } - - /** - We found the target. - Call the stock function to spectate the target. - */ - StartFollowingPlayer(client, iTarget); - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_StopSpectate(client, args) -{ - - /** - Cleanup the clients variables. - */ - StopFollowingPlayer(client); - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_ToggleHud(client, args) -{ - - /** - Toggle the hud - */ - if (g_aPlayers[client][bIsDisplayingHud]) - { - StopDisplayingHud(client); - } - else - { - StartDisplayingHud(client); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -/** -Timers -*/ -public Action:Timer_ResetTarget(Handle:timer, any:client) -{ - - new iTargetID = GetEntPropEnt(client, Prop_Send, "m_hObserverTarget"); - - if (iTargetID != g_aPlayers[client][iTargetIndex] && IsPlayerAlive(g_aPlayers[client][iTargetIndex])) - { - - /** - Run the command to spectate the target from the clients prospectative. - */ - FakeClientCommandEx(client, "spec_player \"%N\"", g_aPlayers[client][iTargetIndex]); - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -public Action:Timer_UpdateHud(Handle:timer, any:client) -{ - - /** - Make sure the client is still in game and a spectator - */ - if (!IsClientConnected(client) || !IsClientInGame(client) || GetClientTeam(client) != g_aCurrentTeams[Spectator] || !g_aPlayers[client][bIsDisplayingHud]) - { - - /** - We are done, bug out - */ - g_aPlayers[client][hHudTimer] = INVALID_HANDLE; - g_aPlayers[client][bIsDisplayingHud] = false; - return Plugin_Stop; - } - /** - Get the target - */ - new iTarget = GetEntPropEnt(client, Prop_Send, "m_hObserverTarget"); - - /** - Check to make sure the target is valid - */ - if (iTarget <= 0 || iTarget > MaxClients) - { - return Plugin_Continue; - } - - /** - Get the spectator mode - */ - new iSpecMode = GetEntProp(client, Prop_Send, "m_iObserverMode"); - - /** - This is a double check to make sure we are in spec - If we are on a regular team, specmod would = none or zero - */ - if (iSpecMode == SPECMODE_NONE) - { - - /** - We are done, bug out - */ - g_aPlayers[client][hHudTimer] = INVALID_HANDLE; - g_aPlayers[client][bIsDisplayingHud] = false; - return Plugin_Stop; - } - - /** - Check the spectator mode - CSS has different index's so we have to check game type first - */ - if (g_CurrentMod == GameType_CSS) - { - switch (iSpecMode) - { - case SPECMODE_CSS_FIRSTPERSON: - { - //Do Nothing - } - case SPECMODE_CSS_3RDPERSON: - { - //Do Nothing - } - case SPECMODE_CSS_FREELOOK: - { - return Plugin_Continue; - } - } - } - else - { - switch (iSpecMode) - { - case SPECMODE_FIRSTPERSON: - { - //Do Nothing - } - case SPECMODE_3RDPERSON: - { - //Do Nothing - } - case SPECMODE_FREELOOK: - { - return Plugin_Continue; - } - } - } - - - /** - Display with the hud - */ - if (g_aPluginSettings[bCanHUD] && !g_aPluginCvarSettings[bHudMode]) - { - new String:sSteamID[64]; - GetClientAuthString(iTarget, sSteamID, sizeof(sSteamID)); - SetHudTextParams(0.04, 0.6, 0.5, 255, 50, 50, 255); - ShowSyncHudText(client, g_hHud, "%N [%s]", iTarget, sSteamID); - } - else if (g_aPluginCvarSettings[bHudMode]) - { - if (g_aPluginCvarSettings[bMenuType]) - { - DisplayMenu(BuildPlayerHudMenu(client, iTarget), client, 1); - } - else - { - new Handle:hPanel = BuildPlayerHudPanel(client, iTarget); - SendPanelToClient(hPanel, client, Panel_PlayerHud, 1); - CloseHandle(hPanel); - } - } - - /** - We are done, keep going! - */ - return Plugin_Continue; -} - -/** -Admin Menu Callbacks -*/ -public OnAdminMenuReady(Handle:topmenu) -{ - if (topmenu == g_hAdminMenu) - { - return; - } - g_hAdminMenu = topmenu; - new TopMenuObject:player_commands = FindTopMenuCategory(g_hAdminMenu, ADMINMENU_PLAYERCOMMANDS); - if (player_commands == INVALID_TOPMENUOBJECT) - { - return; - } - AddToTopMenu(g_hAdminMenu, - "sm_spectate", - TopMenuObject_Item, - AdminMenu_SpecPlayer, - player_commands, - "sm_spectate", - ADMFLAG_GENERIC); -} - -public AdminMenu_SpecPlayer(Handle:topmenu, TopMenuAction:action, TopMenuObject:object_id, param, String:buffer[], maxlength) -{ - if (action == TopMenuAction_DisplayOption) - { - - if (g_aPlayers[param][bIsDisplayingHud]) - { - StopDisplayingHud(param); - } - /** - See if we already have a target - */ - if (g_aPlayers[param][iTargetIndex]) - { - Format(buffer, maxlength, "Spectate(Disable)"); - } - else - { - Format(buffer, maxlength, "Spectate(Select Player)"); - } - } - else if (action == TopMenuAction_SelectOption) - { - - /** - See if we already have a target - */ - if (g_aPlayers[param][iTargetIndex]) - { - - /** - We do, toggle it off - */ - StopFollowingPlayer(param); - - /** - We are done, bug out. - */ - return; - } - else - { - DisplayMenu(BuildPlayerListMenu(), param, MENU_TIME_FOREVER); - } - } -} - -/** -Select Player Menu Callbacks -*/ -public Menu_PlayerList(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - /** - Get the selected player - */ - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - new iTarget = GetClientOfUserId(StringToInt(sSelection)); - - /** - Start following the player - */ - StartFollowingPlayer(param1, iTarget); - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_GENERIC) - { - - /** - Display the last admin menu - */ - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } - else if (param2 == MenuCancel_Exit && GetClientTeam(param1) == g_aCurrentTeams[Spectator]) - { - /** - They canceled the current menu, start the hud back up - */ - StartDisplayingHud(param1); - } - } - else if (action == MenuAction_End) - { - - /** - Not a global menu, close it - */ - CloseHandle(menu); - } -} - -public Menu_SelectPlayer(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - - /** - Get the selected player - */ - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (strcmp(sSelection, "Current", false) == 0) - { - /** - Get the current target - */ - new iTarget = GetEntPropEnt(param1, Prop_Send, "m_hObserverTarget"); - - /** - Check to make sure the target is valid - */ - if (iTarget <= 0 || iTarget > MaxClients) - { - PrintToChat(param1, "\x03[SM-SPEC]\x01 %t", "Invalid Target"); - DisplayMenu(BuildPlayerListMenu(), param1, MENU_TIME_FOREVER); - } - - /** - Start following the player - */ - StartFollowingPlayer(param1, iTarget); - } - else - { - - /** - They want to select a player, show the player list - */ - DisplayMenu(BuildPlayerListMenu(), param1, MENU_TIME_FOREVER); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - - /** - They canceled the current menu, start the hud back up - */ - StartDisplayingHud(param1); - } - } - else if (action == MenuAction_End) - { - /** - Its a global menu, leave it alive - */ - } -} - -/** -Punishment Menu Callbacks -*/ -public Menu_Punishments(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - - /** - Get the menu selection - */ - new String:sSelection[15]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - - /** - Search for the correct index - */ - new e_Punishments:Index = Punish_None; - for ( ; _:Index <= sizeof(g_sPunishments); Index++) - { - if (StrEqual(sSelection, g_sPunishments[Index])) - { - break; - } - } - - /** - Display the next menu - */ - if (Index == Punish_Ban) - { - - /** - Set the punishment index and display ban time menu - */ - g_aPlayers[param1][TargetPunishment] = Index; - DisplayMenu(g_aMenus[hBanTime], param1, MENU_TIME_FOREVER); - } - else if (Index == Punish_Cheater) - { - - /** - Ask for confirmation before we set punishment index - */ - new Handle:hPanel = BuildAdminCheaterPanel(); - SendPanelToClient(hPanel, param1, Panel_AdminCheater, MENU_TIME_FOREVER); - CloseHandle(hPanel); - } - else - { - - /** - Set the punishment index and display reason menu - */ - g_aPlayers[param1][TargetPunishment] = Index; - DisplayMenu(g_aMenus[hReason], param1, MENU_TIME_FOREVER); - } - } - else if (action == MenuAction_Cancel) - { - - /** - They canceled the current menu, start the hud back up - */ - StartDisplayingHud(param1); - } - else if (action == MenuAction_End) - { - - /** - Not a global menu, close it - */ - CloseHandle(menu); - } -} - -public Menu_BanTime(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - - /** - Get the menu selection - */ - new String:sSelection[15]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - - /** - Set the ban time global - */ - g_aPlayers[param1][iBanTime] = StringToInt(sSelection); - - /** - Display the reason menu - */ - DisplayMenu(g_aMenus[hReason], param1, MENU_TIME_FOREVER); - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - - /** - They canceled the current menu, start the hud back up - */ - StartDisplayingHud(param1); - } - } - else if (action == MenuAction_End) - { - /** - Its a global menu, leave it alive - */ - } -} - -public Menu_Reason(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - - /** - Get the menu selection - */ - new String:sSelection[15]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - - /** - Perform the punishment - */ - PerformPunishment(param1, g_aPlayers[param1][iTargetIndex], g_aPlayers[param1][TargetPunishment], sSelection, g_aPlayers[param1][iBanTime]); - - /** - Reactivate the hud if still in spectator - */ - if (GetClientTeam(param1) == g_aCurrentTeams[Spectator]) - { - StartDisplayingHud(param1); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - - /** - They canceled the current menu, start the hud back up - */ - StartDisplayingHud(param1); - } - } - else if (action == MenuAction_End) - { - /** - Its a global menu, leave it alive - */ - } -} - -public Panel_AdminCheater(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - if (param2 == 1) - { - - /** - Set the punishment index and display reason menu - */ - g_aPlayers[param1][TargetPunishment] = Punish_Cheater; - DisplayMenu(g_aMenus[hReason], param1, MENU_TIME_FOREVER); - } - else - { - - /** - Reactivate the hud if still in spectator - */ - if (GetClientTeam(param1) == g_aCurrentTeams[Spectator]) - { - StartDisplayingHud(param1); - } - } - } -} - -public Panel_PublicCheater(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - if (param2 == 1) - { - //Waiting for SB 2.0 and sb_submission to be published - } - else - { - - /** - Reactivate the hud if still in spectator - */ - if (GetClientTeam(param1) == g_aCurrentTeams[Spectator]) - { - StartDisplayingHud(param1); - } - } - } -} - -/** -Hud Menu/Panel Callbacks -*/ -public Menu_PlayerHud(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "stop", false)) - { - StopFollowingPlayer(param1); - } - else if (StrEqual(sSelection, "start", false)) - { - StopDisplayingHud(param1); - DisplayMenu(g_aMenus[hSelectPlayer], param1, MENU_TIME_FOREVER); - } - else if (StrEqual(sSelection, "removecheater", false)) - { - g_aPlayers[g_aPlayers[param1][iTargetIndex]][bIsFlaggedCheater] = false; - } - else if (StrEqual(sSelection, "punish", false)) - { - if (g_aPlayers[param1][iTargetIndex]) - { - StopDisplayingHud(param1); - DisplayMenu(BuildPunishmentMenu(param1), param1, MENU_TIME_FOREVER); - } - else - { - StopDisplayingHud(param1); - PrintToChat(param1, "\x03[SM-SPEC]\x01 %t", "Must Have Target"); - DisplayMenu(g_aMenus[hSelectPlayer], param1, MENU_TIME_FOREVER); - } - } - else if (StrEqual(sSelection, "reportcheater", false)) - { - if (g_aPlayers[param1][iTargetIndex]) - { - StopDisplayingHud(param1); - new Handle:hPanel = BuildPublicCheaterPanel(); - SendPanelToClient(hPanel, param1, Panel_PublicCheater, MENU_TIME_FOREVER); - CloseHandle(hPanel); - } - else - { - StopDisplayingHud(param1); - PrintToChat(param1, "\x03[SM-SPEC]\x01 %t", "Must Have Target"); - DisplayMenu(g_aMenus[hSelectPlayer], param1, MENU_TIME_FOREVER); - } - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_Interrupted) - { - if (GetClientMenu(param1) == MenuSource_External) - { - StopDisplayingHud(param1); - } - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } -} - -public Panel_PlayerHud(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - switch (param2) - { - case 1: - { - if (g_aPlayers[param1][iTargetIndex]) - { - StopFollowingPlayer(param1); - } - else - { - StopDisplayingHud(param1); - DisplayMenu(BuildSelectPlayerMenu(), param1, MENU_TIME_FOREVER); - } - } - case 2: - { - if (!g_aPlayers[param1][iTargetIndex]) - { - StopDisplayingHud(param1); - PrintToChat(param1, "\x03[SM-SPEC]\x01 %t", "Must Have Target"); - DisplayMenu(g_aMenus[hSelectPlayer], param1, MENU_TIME_FOREVER); - return; - } - - if ((GetUserFlagBits(param1) & ADMFLAG_GENERIC) || (GetUserFlagBits(param1) & ADMFLAG_ROOT)) - { - if (g_aPlayers[g_aPlayers[param1][iTargetIndex]][bIsFlaggedCheater] && (GetUserFlagBits(param1) & ADMFLAG_ROOT)) - { - //Remove cheater flag - g_aPlayers[g_aPlayers[param1][iTargetIndex]][bIsFlaggedCheater] = false; - } - else - { - //Punish menu - StopDisplayingHud(param1); - DisplayMenu(BuildPunishmentMenu(param1), param1, MENU_TIME_FOREVER); - } - } - else - { - //Report Cheater - new Handle:hPanel = BuildPublicCheaterPanel(); - SendPanelToClient(hPanel, param1, Panel_PublicCheater, MENU_TIME_FOREVER); - CloseHandle(hPanel); - } - } - case 3: - { - StopDisplayingHud(param1); - } - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_Interrupted) - { - if (GetClientMenu(param1) == MenuSource_External) - { - StopDisplayingHud(param1); - } - } - } -} - - -/** -Stock functions -*/ -stock StartFollowingPlayer(client, target) -{ - - /** - If we have an open timer, close it. - */ - if (g_aPlayers[client][hTargetTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[client][hTargetTimer]); - g_aPlayers[client][hTargetTimer] = INVALID_HANDLE; - } - - /** - Make sure the target is on a non spectator team, and the client != target - */ - if (client == target) - { - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Yourself"); - return; - } - new iTargetTeam = GetClientTeam(target); - if (iTargetTeam == g_aCurrentTeams[Spectator] || iTargetTeam == g_aCurrentTeams[Unknown]) - { - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Spectator"); - return; - } - - /** - Check to see if client is already a spectator - */ - if (GetClientTeam(client) != g_aCurrentTeams[Spectator]) - { - - /** - Client is not a spectator, lets move them to spec. - */ - SM_MovePlayer(client, g_aCurrentTeams[Spectator]); - } - - /** - If we are using steambans call sb_status - */ - if (g_aPluginSettings[bUseSteamBans]) - { - FakeClientCommandEx(client, "sb_status"); - } - - - /** - Set the global and start to spectate the target. - Making sure it's long enough to deal with moving the client to spec if we had to. - */ - new String:sTargetName[MAX_NAME_LENGTH + 1]; - GetClientName(target, sTargetName, sizeof(sTargetName)); - g_aPlayers[client][iTargetIndex] = target; - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Spectating", sTargetName); - g_aPlayers[client][hTargetTimer] = CreateTimer(0.5, Timer_ResetTarget, client, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); - if (!g_aPlayers[client][bIsDisplayingHud] && GetClientTeam(client) == g_aCurrentTeams[Spectator]) - { - StartDisplayingHud(client); - } -} - -stock StopFollowingPlayer(client) -{ - - /** - If we have an open timer, close it. - */ - if (g_aPlayers[client][hTargetTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[client][hTargetTimer]); - } - - /** - Tell the client we can't spec his target anymore... if they are in game. - */ - if (IsClientInGame(client) && g_aPlayers[client][iTargetIndex] != 0) - { - new String:sTargetName[MAX_NAME_LENGTH + 1]; - GetClientName(g_aPlayers[client][iTargetIndex], sTargetName, sizeof(sTargetName)); - if (!IsClientConnected(g_aPlayers[client][iTargetIndex]) || !IsClientInGame(g_aPlayers[client][iTargetIndex])) - { - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Target Left"); - } - else - { - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Stopped spectating", sTargetName); - } - } - - /** - Null the globals. - */ - g_aPlayers[client][iTargetIndex] = 0; - g_aPlayers[client][hTargetTimer] = INVALID_HANDLE; -} - -stock StartDisplayingHud(client) -{ - if (g_aPluginCvarSettings[bRestrictHud] && !SM_IsValidAdmin(client, g_sAdminFlags)) - { - return; - } - else - { - /** - Double check the hud timer - We should not have one, but if we do, lets cancel it for the current callback - */ - StopDisplayingHud(client); - - /** - Now we can safely display the hud and make sure the current stored handle is the current timer - */ - g_aPlayers[client][bIsDisplayingHud] = true; - g_aPlayers[client][hHudTimer] = CreateTimer(0.5, Timer_UpdateHud, client, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); - } -} - -stock StopDisplayingHud(client) -{ - if (g_aPlayers[client][hHudTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[client][hHudTimer]); - } - g_aPlayers[client][hHudTimer] = INVALID_HANDLE; - g_aPlayers[client][bIsDisplayingHud] = false; -} - -stock ResetClient(client) -{ - StopFollowingPlayer(client); - StopDisplayingHud(client); - - g_aPlayers[client][bIsFlaggedCheater] = false; - g_aPlayers[client][TargetPunishment] = Punish_None; - g_aPlayers[client][iBanTime] = -1; -} - -stock PerformPunishment(client, target, e_Punishments:punishment, const String:reason[], time = 300) -{ - new String:sTargetName[MAX_NAME_LENGTH + 1], - String:sTargetID[64]; - - /** - The target could have left the game by the time we get here - Check for a valid target - */ - if (!IsClientConnected(target) || !IsClientInGame(target)) - { - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Target Left"); - return; - } - - GetClientName(target, sTargetName, sizeof(sTargetName)); - GetClientAuthString(target, sTargetID, sizeof(sTargetID)); - - switch (punishment) - { - case Punish_Kick: - { - KickClient(g_aPlayers[client][iTargetIndex], "%s", reason); - } - case Punish_Ban: - { - if (g_aPluginSettings[bUseSourceBans]) - { - ClientCommand(client, "sm_ban #%d %d \"%s\"", GetClientUserId(target), time, reason); - } - else if (g_aPluginSettings[bUseMySQLBans]) - { - ClientCommand(client, "mysql_ban #%d %d \"%s\"", GetClientUserId(target), time, reason); - } - else - { - BanClient(target, time, BANFLAG_AUTHID, reason, reason); - } - } - case Punish_Cheater: - { - g_aPlayers[target][bIsFlaggedCheater] = true; - } - case Punish_Beacon: - { - ClientCommand(client, "sm_beacon \"%s\"", sTargetName); - } - case Punish_Blind: - { - ClientCommand(client, "sm_blind \"%s\"", sTargetName); - } - case Punish_Drug: - { - ClientCommand(client, "sm_drug \"%s\"", sTargetName); - } - case Punish_Freeze: - { - ClientCommand(client, "sm_freeze \"%s\"", sTargetName); - } - case Punish_FreezeBomb: - { - ClientCommand(client, "sm_freezebomb \"%s\"", sTargetName); - } - case Punish_Slap: - { - ClientCommand(client, "sm_slap \"%s\" 10", sTargetName); - } - case Punish_Slay: - { - ClientCommand(client, "sm_slay \"%s\"", sTargetName); - } - case Punish_TimeBomb: - { - ClientCommand(client, "sm_timebomb \"%s\"", sTargetName); - } - } - - if (punishment == Punish_Cheater) - { - LogAction(client, target, "[SM SPEC] %N marked %N(%s) with a %s flag for %s", client, target, sTargetID, g_sPunishments[punishment], reason); - } - else - { - ShowActivity(client, "%t", "Punished", sTargetName, g_sPunishments[punishment], reason); - LogAction(client, target, "[SM SPEC] %N punished %N(%s) with a %s for %s", client, target, sTargetID, g_sPunishments[punishment], reason); - } - - /** - Null the globals. - */ - g_aPlayers[client][TargetPunishment] = Punish_None; - g_aPlayers[client][iBanTime] = -1; -} - -/** -Build the menu of player names -*/ -stock Handle:BuildPlayerListMenu() -{ - new Handle:hMenu = CreateMenu(Menu_PlayerList); - AddTargetsToMenu(hMenu, 0, true, false); - SetMenuTitle(hMenu, "Select A Player:"); - SetMenuExitBackButton(hMenu, true); - return hMenu; -} - -/** -Build the select player menu (current or list of players) -*/ -stock Handle:BuildSelectPlayerMenu() -{ - new Handle:hMenu = CreateMenu(Menu_SelectPlayer); - SetMenuTitle(hMenu, "Select A Player:"); - AddMenuItem(hMenu, "Current", "Current Target"); - AddMenuItem(hMenu, "List", "Player List"); - SetMenuExitBackButton(hMenu, true); - return hMenu; -} - -/** -Build the punishmenu menu -*/ -stock Handle:BuildPunishmentMenu(iClient) -{ - new Handle:hMenu = CreateMenu(Menu_Punishments); - SetMenuTitle(hMenu, "Select A Punishment:"); - SetMenuExitBackButton(hMenu, true); - SetMenuExitButton(hMenu, true); - - if (g_aPluginCvarSettings[bKick] && ((GetUserFlagBits(iClient) & ADMFLAG_GENERIC) || (GetUserFlagBits(iClient) & ADMFLAG_ROOT))) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Kick], "Kick"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Kick], "Kick", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bBan] && ((GetUserFlagBits(iClient) & ADMFLAG_GENERIC) || (GetUserFlagBits(iClient) & ADMFLAG_ROOT))) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Ban], "Ban"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Ban], "Ban", ITEMDRAW_DISABLED); - } - - if (g_aPluginSettings[bUseDukehacks] && g_aPluginCvarSettings[bCheater] && (GetUserFlagBits(iClient) & ADMFLAG_ROOT)) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Cheater], "Flag As Cheater"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Cheater], "Flag As Cheater", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bBeacon]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Beacon], "Beacon"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Beacon], "Beacon", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bBlind]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Blind], "Blind"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Blind], "Blind", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bDrug]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Drug], "Drug"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Drug], "Drug", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bFreeze]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Freeze], "Freeze"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Freeze], "Freeze", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bFreezebomb]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_FreezeBomb], "Freeze Bomb"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_FreezeBomb], "Freeze Bomb", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bSlap]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Slap], "Slap"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Slap], "Slap", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bSlay]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Slay], "Slay"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Slay], "Slay", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bTimeBomb]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_TimeBomb], "Time Bomb"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_TimeBomb], "Time Bomb", ITEMDRAW_DISABLED); - } - - return hMenu; -} - -/** -Build the punishmenu menu -*/ -stock Handle:BuildBanTimeMenu() -{ - new Handle:hMenu = CreateMenu(Menu_BanTime); - SetMenuTitle(hMenu, "Select Ban Type:"); - - if (g_aPluginCvarSettings[bBanPerm]) - { - AddMenuItem(hMenu, "permban", "Permanent"); - } - else - { - AddMenuItem(hMenu, "permban", "Permanent", ITEMDRAW_DISABLED); - } - - AddMenuItem(hMenu, "10", "10 Minutes"); - AddMenuItem(hMenu, "30", "30 Minutes"); - AddMenuItem(hMenu, "60", "1 Hour"); - AddMenuItem(hMenu, "240", "4 Hours"); - AddMenuItem(hMenu, "1440", "1 Day"); - AddMenuItem(hMenu, "10080", "1 Week"); - - SetMenuExitBackButton(hMenu, true); - return hMenu; -} - -/** -Build the punishmenu menu -*/ -stock Handle:BuildReasonMenu() -{ - new Handle:hMenu = CreateMenu(Menu_Reason); - SetMenuTitle(hMenu, "Select A Reason:"); - - AddMenuItem(hMenu, "Abusive", "Abusive"); - AddMenuItem(hMenu, "Racism", "Racism"); - AddMenuItem(hMenu, "General cheating/exploits", "General cheating/exploits"); - AddMenuItem(hMenu, "Wallhack", "Wallhack"); - AddMenuItem(hMenu, "Aimbot", "Aimbot"); - AddMenuItem(hMenu, "Speedhacking", "Speedhacking"); - AddMenuItem(hMenu, "Mic spamming", "Mic spamming"); - AddMenuItem(hMenu, "Admin disrepect", "Admin disrepect"); - AddMenuItem(hMenu, "Camping", "Camping"); - AddMenuItem(hMenu, "Team killing", "Team killing"); - AddMenuItem(hMenu, "Unacceptable Spray", "Unacceptable Spray"); - AddMenuItem(hMenu, "Breaking Server Rules", "Breaking Server Rules"); - AddMenuItem(hMenu, "Other", "Other"); - - SetMenuExitBackButton(hMenu, true); - return hMenu; -} - -/** -Build the cheater displays -*/ -stock Handle:BuildAdminCheaterPanel() -{ - - /** - Create the menu and set the menu options. - */ - new Handle:hPanel = CreatePanel(); - SetPanelTitle(hPanel, "Simple Spectator:"); - - DrawPanelText(hPanel, "Are you sure you want to"); - DrawPanelText(hPanel, "flag this player as a cheater?"); - DrawPanelText(hPanel, "They will not be able to damage"); - DrawPanelText(hPanel, "anyone and die on fall damage."); - DrawPanelItem(hPanel, "Yes"); - DrawPanelItem(hPanel, "No"); - - return hPanel; -} - -stock Handle:BuildPublicCheaterPanel() -{ - - /** - Create the menu and set the menu options. - */ - new Handle:hPanel = CreatePanel(); - SetPanelTitle(hPanel, "Simple Spectator:"); - - DrawPanelText(hPanel, "Are you sure you want to"); - DrawPanelText(hPanel, "submit this player as a cheater?"); - DrawPanelItem(hPanel, "Yes (Not Implemented Yet)", ITEMDRAW_DISABLED); - DrawPanelItem(hPanel, "No"); - return hPanel; -} - -/** -Build the hud displays -*/ -stock Handle:BuildPlayerHudMenu(iClient, iTarget) -{ - - /** - Create all the string variables we will need - */ - new String:sTargetName[MAX_NAME_LENGTH + 1], - String:sTargetID[64], - String:sTargetIP[16]; - - new String:sDisplayName[MAX_NAME_LENGTH + 1], - String:sDisplayID[64], - String:sDisplayIP[64], - String:sDisplayFrags[16], - String:sDisplayDeaths[16]; - - new iTargetFrags, - iTargetDeaths; - - /** - Get the targets information - */ - GetClientName(iTarget, sTargetName, sizeof(sTargetName)); - GetClientIP(iTarget, sTargetIP, sizeof(sTargetIP)); - GetClientAuthString(iTarget, sTargetID, sizeof(sTargetID)); - iTargetFrags = GetClientFrags(iTarget); - iTargetDeaths = GetClientDeaths(iTarget); - - /** - Format the strings for the menu - */ - Format(sDisplayName, sizeof(sDisplayName), "Player: %s", sTargetName); - Format(sDisplayID, sizeof(sDisplayID), "Steam ID: %s", sTargetID); - Format(sDisplayIP, sizeof(sDisplayIP), "IP Address: %s", sTargetIP); - Format(sDisplayFrags, sizeof(sDisplayFrags), "Kills: %i", iTargetFrags); - Format(sDisplayDeaths, sizeof(sDisplayDeaths), "Deaths: %i", iTargetDeaths); - - /** - Create the menu and set the menu options. - */ - new Handle:hMenu = CreateMenu(Menu_PlayerHud); - SetMenuExitBackButton(hMenu, false); - SetMenuTitle(hMenu, "Simple Spectator"); - - AddMenuItem(hMenu, "name", sDisplayName, ITEMDRAW_DISABLED); - AddMenuItem(hMenu, "steamid", sDisplayID, ITEMDRAW_DISABLED); - - if (SM_IsValidAdmin(iClient, g_sAdminFlags)) - { - AddMenuItem(hMenu, "ip", sDisplayIP, ITEMDRAW_DISABLED); - } - - AddMenuItem(hMenu, "kills", sDisplayFrags, ITEMDRAW_DISABLED); - AddMenuItem(hMenu, "deaths", sDisplayDeaths, ITEMDRAW_DISABLED); - - if (g_aPlayers[iClient][iTargetIndex]) - { - AddMenuItem(hMenu, "stop", "Stop Following"); - } - else - { - AddMenuItem(hMenu, "start", "Follow Player"); - } - - if ((GetUserFlagBits(iClient) & ADMFLAG_GENERIC) || (GetUserFlagBits(iClient) & ADMFLAG_ROOT)) - { - if (g_aPlayers[iTarget][bIsFlaggedCheater] && (GetUserFlagBits(iClient) & ADMFLAG_ROOT)) - { - AddMenuItem(hMenu, "removecheater", "Remove Cheater Flag"); - } - else - { - if (CanUserTarget(iClient, iTarget)) - { - AddMenuItem(hMenu, "punish", "Punish Player"); - } - else - { - AddMenuItem(hMenu, "punish", "Punish Player (Immune)", ITEMDRAW_DISABLED); - } - } - } - else - { - AddMenuItem(hMenu, "reportcheater", "Report Cheater"); - } - - SetMenuPagination(hMenu, MENU_NO_PAGINATION); - SetMenuExitButton(hMenu, true); - return hMenu; -} - -stock Handle:BuildPlayerHudPanel(iClient, iTarget) -{ - - /** - Create all the string variables we will need - */ - new String:sTargetName[MAX_NAME_LENGTH + 1], - String:sTargetID[64], - String:sTargetIP[16]; - - new String:sDisplayName[MAX_NAME_LENGTH + 1], - String:sDisplayID[64], - String:sDisplayIP[64], - String:sDisplayFrags[16], - String:sDisplayDeaths[16]; - - new iTargetFrags, - iTargetDeaths; - - /** - Get the targets information - */ - GetClientName(iTarget, sTargetName, sizeof(sTargetName)); - GetClientIP(iTarget, sTargetIP, sizeof(sTargetIP)); - GetClientAuthString(iTarget, sTargetID, sizeof(sTargetID)); - iTargetFrags = GetClientFrags(iTarget); - iTargetDeaths = GetClientDeaths(iTarget); - - /** - Format the strings for the menu - */ - Format(sDisplayName, sizeof(sDisplayName), "Player: %s", sTargetName); - Format(sDisplayID, sizeof(sDisplayID), "Steam ID: %s", sTargetID); - Format(sDisplayIP, sizeof(sDisplayIP), "IP Address: %s", sTargetIP); - Format(sDisplayFrags, sizeof(sDisplayFrags), "Kills: %i", iTargetFrags); - Format(sDisplayDeaths, sizeof(sDisplayDeaths), "Deaths: %i", iTargetDeaths); - - /** - Create the menu and set the menu options. - */ - new Handle:hPanel = CreatePanel(); - SetPanelTitle(hPanel, "Simple Spectator"); - - DrawPanelText(hPanel, "Player Information:"); - DrawPanelText(hPanel, sDisplayName); - DrawPanelText(hPanel, sDisplayID); - if (SM_IsValidAdmin(iClient, g_sAdminFlags)) - { - DrawPanelText(hPanel, sDisplayIP); - } - - DrawPanelText(hPanel, sDisplayFrags); - DrawPanelText(hPanel, sDisplayDeaths); - - if (g_aPlayers[iClient][iTargetIndex]) - { - DrawPanelItem(hPanel, "Stop Following"); - } - else - { - DrawPanelItem(hPanel, "Follow Player"); - } - - if ((GetUserFlagBits(iClient) & ADMFLAG_GENERIC) || (GetUserFlagBits(iClient) & ADMFLAG_ROOT)) - { - if (g_aPlayers[iTarget][bIsFlaggedCheater] && (GetUserFlagBits(iClient) & ADMFLAG_ROOT)) - { - DrawPanelItem(hPanel, "Remove Cheater Flag"); - } - else - { - if (CanUserTarget(iClient, iTarget)) - { - DrawPanelItem(hPanel, "Punish Player"); - } - else - { - DrawPanelItem(hPanel, "Punish Player (Immune)", ITEMDRAW_DISABLED); - } - } - } - else - { - DrawPanelItem(hPanel, "Report Cheater"); - } - - DrawPanelItem(hPanel, "Close Hud Panel"); - return hPanel; -} - -/** -Adjust the settings if a convar was changed -*/ -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - for (new iCvar = 0 ; _:iCvar < sizeof(g_aPluginCvarSettings); iCvar++) - { - if (g_aPluginCvar[_:iCvar] == convar) - { - if (StringToInt(newValue) == 1) - { - g_aPluginCvarSettings[_:iCvar] = true; - } - else - { - g_aPluginCvarSettings[_:iCvar] = false; - } - } - } - - /* - ReBuild the global menu that depends on cvars - */ - g_aMenus[hBanTime] = BuildBanTimeMenu(); - - /** - Run a loop to reset the hud - */ - for(new i = 1; i <= MaxClients; i++) - { - StopDisplayingHud(i); - if (IsClientConnected(i) && IsClientInGame(i) && GetClientTeam(i) == g_aCurrentTeams[Spectator]) - { - StartDisplayingHud(i); - } - } -} diff --git a/Simple AllTalk Manager/addons/sourcemod/scripting/simple-teambalancer.sp b/Simple AllTalk Manager/addons/sourcemod/scripting/simple-teambalancer.sp deleted file mode 100644 index 3302255..0000000 --- a/Simple AllTalk Manager/addons/sourcemod/scripting/simple-teambalancer.sp +++ /dev/null @@ -1,1797 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Team Balancer -Description: - Balances teams based upon player count - Player will not be balanced more than once in 5 (default) mins - Buddy system tries to keep buddies together - Ability to prioritize players - Ability to force players to accept the new team - Admins are immune -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include -#include - -#define PLUGIN_VERSION "2.1.$Rev$" - -enum PlayerData -{ - Handle:hBalanceTimer, - Handle:hForcedTimer, - bool:bSwitched, - bool:bFlagCarrier -}; - -/** - Global convar handles - */ -new Handle:stb_enabled = INVALID_HANDLE; -new Handle:stb_buddyenabled = INVALID_HANDLE; -new Handle:stb_logactivity = INVALID_HANDLE; -new Handle:stb_logactivity2 = INVALID_HANDLE; -new Handle:stb_unbalancelimit = INVALID_HANDLE; -new Handle:stb_deadonly = INVALID_HANDLE; -new Handle:stb_priorityenabled = INVALID_HANDLE; -new Handle:stb_uberlevel = INVALID_HANDLE; -new Handle:stb_balancedelay = INVALID_HANDLE; -new Handle:stb_livingplayerswitchdelay = INVALID_HANDLE; -new Handle:stb_livingplayercheckdelay = INVALID_HANDLE; -new Handle:stb_roundstartdelay = INVALID_HANDLE; -new Handle:stb_switchbackforced = INVALID_HANDLE; -new Handle:stb_adminflag = INVALID_HANDLE; -new Handle:stb_buddyrestriction = INVALID_HANDLE; -new Handle:stb_convarcontrol = INVALID_HANDLE; - -/** - Built-in cvars handles - */ -new Handle:stb_mp_autoteambalance = INVALID_HANDLE; -new Handle:stb_mp_teams_unbalance_limit = INVALID_HANDLE; -new Handle:TFGameModeArena = INVALID_HANDLE; - -/** - Timer handles - */ -new Handle:g_hBalanceTimer = INVALID_HANDLE; -new Handle:g_hLivingPlayerCheckTimer = INVALID_HANDLE; - -/** - Player arrays - */ -new g_aPlayers[MAXPLAYERS + 1][PlayerData]; - -/** -Global bools -*/ -new bool:g_bIsEnabled = true; -new bool:g_bPriorityPlayers = true; -new bool:g_bBuddyRestriction = false; -new bool:g_bLogActivity = false; -new bool:g_bLogActivity2 = false; -new bool:g_bDeadOnly = false; -new bool:g_bConVarControl = true; -new bool:g_bBuddyEnabled = true; -new bool:g_bBalanceInProgress = false; -new bool:g_bRoundStart = false; -new bool:g_bRoundEnd = false; -new bool:g_bSuddenDeath = false; -new bool:g_bIsArenaMode = false; - -/** - Global strings/integers/floats - */ -new g_iUnbalanceLimit, g_iLivingPlayerSwitchDelay, g_iLivingPlayerCheckDelay; -new g_iRoundStartDelay, g_iSwitchBackForced, g_iBalanceDelay; -new Float:g_fUberLevel; -new g_iOwnerOffset; -new String:g_sAdminFlag[5]; - -public Plugin:myinfo = -{ - name = "Simple Team Balancer", - author = "Simple Plugins", - description = "Balances teams based upon player count.", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -} - -public OnPluginStart() -{ - - /** - Create console variables - */ - CreateConVar("stb_version", PLUGIN_VERSION, "Simple Team Balancer", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - stb_enabled = CreateConVar("stb_enabled", "1", "Enable or Disable Simple Team Balancer", _, true, 0.0, true, 1.0); - stb_priorityenabled = CreateConVar("stb_priorityenabled", "1", "Enable or Disable the prioritization of living players", _, true, 0.0, true, 1.0); - stb_buddyrestriction = CreateConVar("stb_buddyrestriction", "0", "Enable or Disable Admin Only buddy lists", _, true, 0.0, true, 1.0); - stb_logactivity = CreateConVar("stb_logactivity", "0", "Enable or Disable the disaplying of events in the log", _, true, 0.0, true, 1.0); - stb_logactivity2 = CreateConVar("stb_logactivity2", "0", "Enable or Disable the disaplying of detailed events in the log (WILL SPAM LOG)", _, true, 0.0, true, 1.0); - stb_deadonly = CreateConVar("stb_deadonly", "0", "Enable or Disable the switching of only dead players", _, true, 0.0, true, 1.0); - stb_convarcontrol = CreateConVar("stb_convarcontrol", "1", "Enable or Disable the control of builtin console variables", _, true, 0.0, true, 1.0); - stb_buddyenabled = CreateConVar("stb_buddyenabled", "1", "Enable or Disable the buddy system", _, true, 0.0, true, 1.0); - stb_unbalancelimit = CreateConVar("stb_unbalancelimit", "2", "Amount of players teams are ALLOWED to be unbalanced by", _, true, 1.0, true, 32.0); - stb_balancedelay = CreateConVar("stb_balancedelay", "10", "Delay in seconds to start an autobalance"); - stb_livingplayerswitchdelay = CreateConVar("stb_livingplayerswitchdelay", "20", "Delay in seconds to switch living players once selected"); - stb_livingplayercheckdelay = CreateConVar("stb_livingplayercheckdelay", "10", "Delay in seconds to start checking living players once teams become unbalanced"); - stb_roundstartdelay = CreateConVar("stb_roundstartdelay", "15", "Delay in seconds to start balancing teams after the start of a round"); - stb_switchbackforced = CreateConVar("stb_switchbackforced", "300", "Amount of time in seconds to not switch a player twice and force the team if enabled"); - stb_uberlevel = CreateConVar("stb_uberlevel", "1.0", "Min uber level medic must have to have priority over other living players. Setting to 0 will rarely switch a living medic", _, true, 0.0, true, 1.0); - stb_adminflag = CreateConVar("stb_adminflag", "a", "Admin flag to use for immunity. Must be a in char format."); - stb_mp_autoteambalance = FindConVar("mp_autoteambalance"); - stb_mp_teams_unbalance_limit = FindConVar("mp_teams_unbalance_limit"); - - /** - Removing the notify tags from the built in cvars. We dont want spam. - */ - if (stb_mp_autoteambalance != INVALID_HANDLE) - { - SetConVarFlags(stb_mp_autoteambalance, GetConVarFlags(stb_mp_autoteambalance)^FCVAR_NOTIFY); - } - if (stb_mp_teams_unbalance_limit != INVALID_HANDLE) - { - SetConVarFlags(stb_mp_teams_unbalance_limit, GetConVarFlags(stb_mp_teams_unbalance_limit)^FCVAR_NOTIFY); - } - - /** - Hook console variables - */ - HookConVarChange(stb_enabled, ConVarSettingsChanged); - HookConVarChange(stb_priorityenabled, ConVarSettingsChanged); - HookConVarChange(stb_buddyrestriction, ConVarSettingsChanged); - HookConVarChange(stb_logactivity, ConVarSettingsChanged); - HookConVarChange(stb_logactivity2, ConVarSettingsChanged); - HookConVarChange(stb_deadonly, ConVarSettingsChanged); - HookConVarChange(stb_convarcontrol, ConVarSettingsChanged); - HookConVarChange(stb_buddyenabled, ConVarSettingsChanged); - HookConVarChange(stb_unbalancelimit, ConVarSettingsChanged); - HookConVarChange(stb_balancedelay, ConVarSettingsChanged); - HookConVarChange(stb_livingplayerswitchdelay, ConVarSettingsChanged); - HookConVarChange(stb_livingplayercheckdelay, ConVarSettingsChanged); - HookConVarChange(stb_roundstartdelay, ConVarSettingsChanged); - HookConVarChange(stb_switchbackforced, ConVarSettingsChanged); - HookConVarChange(stb_uberlevel, ConVarSettingsChanged); - HookConVarChange(stb_mp_autoteambalance, ConVarSettingsChanged); - HookConVarChange(stb_mp_teams_unbalance_limit, ConVarSettingsChanged); - - /** - Create console commands - */ - RegConsoleCmd("sm_buddy", Command_AddBalanceBuddy, "Add a balance buddy"); - RegConsoleCmd("sm_lockbuddy", Command_LockBuddy, "Locks your balance buddy selection"); - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook the game events - */ - LogAction(0, -1, "[STB] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_death", HookPlayerDeath, EventHookMode_Post); - HookEvent("player_team", HookPlayerChangeTeam, EventHookMode_Post); - switch (g_CurrentMod) - { - case GameType_TF: - { - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - HookEvent("teamplay_suddendeath_begin", HookSuddenDeathBegin, EventHookMode_PostNoCopy); - HookEvent("teamplay_flag_event", HookFlagEvent, EventHookMode_Post); - TFGameModeArena = FindConVar("tf_gamemode_arena"); - g_iOwnerOffset = FindSendPropInfo("CBaseObject", "m_hBuilder"); - } - case GameType_DOD: - { - HookEvent("dod_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_Post); - } - default: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - } - } - - /** - Load translations and .cfg file - */ - LoadTranslations ("simpleteambalancer.phrases"); - AutoExecConfig(true, "plugin.simpleteambalancer"); - LogAction(0, -1, "[STB] Simple Team Balancer is loaded."); -} - -public OnAllPluginsLoaded() -{ - //something -} - -public OnLibraryRemoved(const String:name[]) -{ - //something -} - -public OnConfigsExecuted() -{ - - /** - Load up global variables - */ - g_bIsEnabled = GetConVarBool(stb_enabled); - g_bBuddyEnabled = GetConVarBool(stb_buddyenabled); - g_bLogActivity = GetConVarBool(stb_logactivity); - g_bLogActivity2 = GetConVarBool(stb_logactivity2); - g_bDeadOnly = GetConVarBool(stb_deadonly); - g_bPriorityPlayers = GetConVarBool(stb_priorityenabled); - g_bBuddyRestriction = GetConVarBool(stb_buddyrestriction); - g_bConVarControl = GetConVarBool(stb_convarcontrol); - g_fUberLevel = GetConVarFloat(stb_uberlevel); - g_iUnbalanceLimit = GetConVarInt(stb_unbalancelimit); - g_iBalanceDelay = GetConVarInt(stb_balancedelay); - g_iLivingPlayerSwitchDelay = GetConVarInt(stb_livingplayerswitchdelay); - g_iLivingPlayerCheckDelay = GetConVarInt(stb_livingplayercheckdelay); - g_iRoundStartDelay = GetConVarInt(stb_roundstartdelay); - g_iSwitchBackForced = GetConVarInt(stb_switchbackforced); - GetConVarString(stb_adminflag, g_sAdminFlag, sizeof(g_sAdminFlag)); - - /** - Report enabled - */ - if (g_bIsEnabled) - { - LogAction(0, -1, "[STB] Simple Team Balancer is ENABLED."); - } - else - { - LogAction(0, -1, "[STB] Simple Team Balancer is DISABLED."); - } - - - /** - Report log activity - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Log Activity ENABLED."); - } - else - { - LogAction(0, -1, "[STB] Log Activity DISABLED."); - } - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Detailed Log Activity ENABLED."); - } - else - { - LogAction(0, -1, "[STB] Detailed Log Activity DISABLED."); - } -} - -public OnMapStart() -{ - - /** - Check for arena mode - */ - if (g_CurrentMod == GameType_TF && GetConVarBool(TFGameModeArena)) - { - g_bIsArenaMode = true; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Simple Team Balancer detected arena mode and will be bypassed"); - } - } - else - { - g_bIsArenaMode = false; - } - - /** - Reset the globals - */ - g_bBalanceInProgress = false; - g_bRoundStart = false; - g_bRoundEnd = false; - g_bSuddenDeath = false; - - /** - Set the built-in convars - */ - SetGameCvars(); -} - -public OnClientPostAdminCheck(client) -{ - - /** - Make sure its a valid connected client and buddy system is enabled - */ - if (client == 0 || !g_bIsEnabled || !IsClientConnected(client) || !g_bBuddyEnabled) - { - return; - } - - /** - Make sure if its set for admins only they have the flags - */ - if (g_bBuddyRestriction && !SM_IsValidAdmin(client, g_sAdminFlag)) - { - return; - } - - /** - Start the advertisement timer - */ - CreateTimer (60.0, Timer_WelcomeAdvert, client); -} - -public OnClientDisconnect(client) -{ - - /** - Call stock function to cleaup - */ - CleanUp(client); -} - -public OnClientDisconnect_Post(client) -{ - - /** - Determine if we need a balance - */ - if (OkToBalance() && IsUnbalanced() && !g_bBalanceInProgress) - { - - /** - No balance in progress but balance is needed - */ - StartABalance(); - } -} - -public SM_OnPlayerMoved(Handle:plugin, client, team) -{ - - /** - Make sure we called the move function - */ - if (plugin != GetMyHandle()) - { - if (g_bLogActivity2) - { - LogAction(0, client, "[STB] Callback was not started with current plugin, bugging out."); - } - return; - } - - /** - Get the players name and report the event - */ - decl String:sPlayerName[64]; - GetClientName(client, sPlayerName, sizeof(sPlayerName)); - if (g_bLogActivity) - { - LogAction(0, client, "[STB] Changed %s to team %i.", sPlayerName, team); - } - - /** - If we are in TF2 fire the bult-in team balance event - */ - if(g_CurrentMod == GameType_TF) - { - new Handle:event = CreateEvent("teamplay_teambalanced_player"); - SetEventInt(event, "player", client); - SetEventInt(event, "team", team); - FireEvent(event); - } - - /** - Notify the players - */ - PrintToChatAll("[SM] %T", "BalanceMessage", LANG_SERVER, sPlayerName); - - /** - Set the players variables and start a timer - */ - g_aPlayers[client][bSwitched] = true; - g_aPlayers[client][hForcedTimer] = CreateTimer(float(g_iSwitchBackForced), Timer_ForcedExpired, client, TIMER_FLAG_NO_MAPCHANGE); - - /** - We are done, log the completion and end the balance - */ - if (g_bLogActivity) - { - LogAction(0, client, "[STB] Balance finished."); - } - g_bBalanceInProgress = false; -} - -/* HOOKED EVENTS */ - -public HookPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get our event variables - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - decl String:sWeapon[64]; - GetEventString(event, "weapon", sWeapon, sizeof(sWeapon)); - - /** - Return if death was not caused by a player - This is the case when the player switches teams - */ - if (StrEqual(sWeapon, "world", false)) - { - return; - } - - - /** - Check if balance is needed - */ - if (IsClientInGame(iClient) && OkToBalance() && IsUnbalanced()) - { - new iSmallerTeam = GetSmallerTeam(); - - /** - Check if balance is in progress - */ - if (g_bBalanceInProgress) - { - - /** - There is a balance in progress - Check the player who died to see if he is supposed to be switched - */ - if (g_aPlayers[iClient][hBalanceTimer] != INVALID_HANDLE) - { - - /** - The player has a timer on him to switch him to other team - Stop the timer - */ - CloseHandle(g_aPlayers[iClient][hBalanceTimer]); - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - if (g_bLogActivity) - { - LogAction(0, iClient, "[STB] With a balance in progress the queued living player died and was switched."); - } - - /** - Call the stock change team function - */ - BalancePlayer(iClient, SM_GetForcedTeam(iClient)); - return; - } - - /** - Before we continue, lets make sure the client is switchable - */ - if (IsSwitchablePlayer(iClient, GetBiggerTeam())) - { - - /** - Now we check the buddy system - */ - if (g_bBuddyEnabled) - { - - /** - Buddy system is enabled, check to see if client has buddy - */ - new iBuddyIndex = SM_GetClientBuddy(iClient); - if (iBuddyIndex != 0 || !IsClientConnected(iBuddyIndex) || !IsClientInGame(iBuddyIndex)) - { - - /** - The client has a buddy, so we check to see if they are on same team - */ - if (GetClientTeam(iClient) == GetClientTeam(iBuddyIndex)) - { - - /** - They are, but we don't bug out, we still need to start a balance - */ - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] With a balance in progress a buddy on the right team was found and skipped."); - } - } - else - { - - /** - They are not on the same team - The buddy could be in spec, and that would make it not matter where he is, or the buddy is on the smaller team - */ - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] With a balance in progress a buddy on the wrong team was switched."); - } - BalancePlayer(iClient, iSmallerTeam); - return; - } - } - else - { - - /** - Client doesn't have a buddy, balance this player - */ - BalancePlayer(iClient, iSmallerTeam); - return; - } - } - else - { - - /** - Buddy system is not enabled, balance this player - */ - BalancePlayer(iClient, iSmallerTeam); - return; - } - } - } - else - { - - /** - If we get to here then we must need to start a balance - */ - StartABalance(); - } - } -} - -public HookPlayerChangeTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get our event variables. - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - new iTeam = GetEventInt(event, "team"); - - /** - Make sure its ok to balance. - */ - if (OkToBalance()) - { - - /** - See if the client that changed teams was set to with a balance. - */ - if (g_aPlayers[iClient][hBalanceTimer] != INVALID_HANDLE - && SM_GetForcedTeam(iClient) == iTeam - && g_bBalanceInProgress) - { - - /** - The client was set to be balanced, so we close the timer. - */ - CloseHandle(g_aPlayers[iClient][hBalanceTimer]); - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - - /** - Stop the balance. - */ - g_bBalanceInProgress = false; - return; - } - - /** - It's not likely that this team change can cause us to need a balance. - If it does, start one with a small dealy to deal with forced switch backs. - */ - if (IsUnbalanced() && !g_bBalanceInProgress) - { - CreateTimer(2.0, Timer_ChangeTeamBalanceDelay, _, TIMER_FLAG_NO_MAPCHANGE); - } - } -} - -public HookRoundStart(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Set the variables we need to start a round - */ - g_bRoundStart = true; - g_bRoundEnd = false; - g_bSuddenDeath = false; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Round Started"); - } - - /** - Start a delayed balance check at the start of the round - */ - CreateTimer(float(g_iRoundStartDelay), Timer_RoundStart); -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Set the variables we need at round end - */ - g_bRoundEnd = true; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Round Ended"); - } -} - -public HookSuddenDeathBegin(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Set the variables we need for sudden death - */ - g_bSuddenDeath = true; -} - -public HookFlagEvent(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get our event variables - */ - new iClient = GetEventInt(event, "player"); - new iFlagStatus = GetEventInt(event, "eventtype"); - - /** - Make sure we have a valid client - */ - if (!IsClientInGame(iClient)) - { - return; - } - - /** - Determine what kind of event this is - */ - switch (iFlagStatus) - { - case 1: - { - - /** - The flag was picked up - */ - g_aPlayers[iClient][bFlagCarrier] = true; - } - case 2: - { - - /** - The flag was capped - */ - g_aPlayers[iClient][bFlagCarrier] = false; - } - case 3: - { - - /** - The flag was defended, we don't have to do anything - */ - } - case 4: - { - - /** - The flag was dropped - */ - g_aPlayers[iClient][bFlagCarrier] = false; - } - } -} - -/* COMMAND EVENTS */ - -public Action:Command_AddBalanceBuddy(client, args) -{ - if (client == 0) - { - ReplyToCommand(client, "[SM] %T", "PlayerLevelCmd", LANG_SERVER); - return Plugin_Handled; - } - if (!g_bIsEnabled || !g_bBuddyEnabled) - { - ReplyToCommand(client, "[SM] %T", "CmdDisabled", LANG_SERVER); - return Plugin_Handled; - } - if (g_bBuddyRestriction) - { - if (!SM_IsValidAdmin(client, g_sAdminFlag)) - { - ReplyToCommand(client, "[SM] %T", "RestrictedBuddy", LANG_SERVER); - return Plugin_Handled; - } - } - decl String:sPlayerUserId[24]; - GetCmdArg(1, sPlayerUserId, sizeof(sPlayerUserId)); - new iPlayer = GetClientOfUserId(StringToInt(sPlayerUserId)); - if (!iPlayer || !IsClientInGame(iPlayer) || client == iPlayer) - { - if (client == iPlayer) - { - PrintHintText(client, "%T", "SelectSelf", LANG_SERVER); - } - ReplyToCommand(client, "[SM] Usage: buddy "); - new Handle:playermenu = BuildPlayerMenu(); - DisplayMenu(playermenu, client, MENU_TIME_FOREVER); - } - else - { - decl String:cName[128]; - decl String:bName[128]; - GetClientName(client, cName, sizeof(cName)); - GetClientName(iPlayer, bName, sizeof(bName)); - if (SM_IsBuddyLocked(iPlayer)) - { - ReplyToCommand(client, "[SM] %T", "PlayerLockedBuddyMsg", LANG_SERVER, bName); - return Plugin_Handled; - } - SM_AssignBuddy(client, iPlayer); - PrintHintText(client, "%T", "BuddyMsg", LANG_SERVER, bName); - PrintHintText(iPlayer, "%T", "BuddyMsg", LANG_SERVER, cName); - } - return Plugin_Handled; -} - -public Action:Command_LockBuddy(client, args) -{ - if (client == 0) - { - ReplyToCommand(client, "[SM] %T", "PlayerLevelCmd", LANG_SERVER); - return Plugin_Handled; - } - if (!g_bIsEnabled) - { - ReplyToCommand(client, "[SM] %T", "CmdDisabled", LANG_SERVER); - return Plugin_Handled; - } - if (g_bBuddyRestriction) - { - if (!SM_IsValidAdmin(client, g_sAdminFlag)) - { - ReplyToCommand(client, "[SM] %T", "RestrictedBuddy", LANG_SERVER); - return Plugin_Handled; - } - } - if (SM_IsBuddyLocked(client)) - { - SM_LockBuddy(client, false); - PrintHintText(client, "%T", "BuddyLockMsgDisabled", LANG_SERVER); - } - else - { - SM_LockBuddy(client, true); - PrintHintText(client, "%T", "BuddyLockMsgEnabled", LANG_SERVER); - } - return Plugin_Handled; -} - -/** -Stock functions . - */ - -stock bool:IsUnbalanced() -{ - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Checking if teams are unbalanced"); - } - new Team1Count = GetTeamClientCount(g_aCurrentTeams[Team1]); - new Team2Count = GetTeamClientCount(g_aCurrentTeams[Team2]); - new ubCount = RoundFloat(FloatAbs(float(Team1Count - Team2Count))); - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Team1:%i Team2:%i Difference:%i", Team1Count, Team2Count, ubCount); - } - if (ubCount > g_iUnbalanceLimit) - { - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Teams are unbalanced"); - } - return true; - } - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Teams are not unbalanced"); - } - return false; -} - -stock bool:OkToBalance() -{ - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Checking if OK to balance."); - } - new bool:bResult = false; - if (g_bIsEnabled && !g_bRoundStart && !g_bRoundEnd && !g_bIsArenaMode && !g_bSuddenDeath) - { - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Passed IF statement"); - LogAction(0, -1, "[STB] Now checking admins"); - } - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientInGame(i) && !SM_IsValidAdmin(i, g_sAdminFlag)) - { - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Found at least 1 non-admin"); - LogAction(0, -1, "[STB] OK to balance"); - } - bResult = true; - break; - } - } - if (!bResult && g_bLogActivity2) - { - LogAction(0, -1, "[STB] All admins online"); - } - } - if (!bResult && g_bLogActivity2) - { - LogAction(0, -1, "[STB] Not OK to balance"); - } - return bResult; -} - -stock bool:IsSwitchablePlayer(iClient, iBiggerTeam) -{ - - /** - Run the client thru some standard checks - */ - if (!IsClientInGame(iClient) - || SM_IsValidAdmin(iClient, g_sAdminFlag) - || g_aPlayers[iClient][bFlagCarrier] - || GetClientTeam(iClient) != iBiggerTeam - || g_aPlayers[iClient][bSwitched]) - { - - /** - The supplied client can't be switched - */ - return false; - } - - /** - The supplied client can be switched - */ - return true; -} - -stock bool:HasUber(iClient) -{ - - /** - First things first, make sure the client is a medic - */ - if(TF2_GetPlayerClass(iClient) == TFClass_Medic) - { - - /** - We can only check the active weapon, so make sure the client is holding the uber gun - */ - decl String:sWeaponName[32]; - GetClientWeapon(iClient, sWeaponName, sizeof(sWeaponName)); - if(StrEqual(sWeaponName, "tf_weapon_medigun")) - { - - /** - They are, so lets check the uber level of the gun - */ - new iEntityIndex = GetEntDataEnt2(iClient, FindSendPropInfo("CTFPlayer", "m_hActiveWeapon")); - new Float:fChargeLevel = GetEntDataFloat(iEntityIndex, FindSendPropInfo("CWeaponMedigun", "m_flChargeLevel")); - if (fChargeLevel >= g_fUberLevel) - { - - /** - The client supplied has an uber above the supplied level, return true - */ - if (g_bLogActivity2) - { - LogAction(0, iClient, "[STB] Found a medic with a uber and skipped him."); - } - return true; - } - } - } - - /** - The client supplied does not have an uber above the supplied level, return false - */ - return false; -} - -stock bool:HasBuildingsBuilt(iClient) -{ - - /** - We have to start a loop to check the owner of all the valid entities - */ - new iMaxEntities = GetMaxEntities(); - for (new i = MaxClients + 1; i <= iMaxEntities; i++) - { - if (!IsValidEntity(i)) - { - - /** - Not valid, continue to next one - */ - continue; - } - - /** - Get the name of the current entity - */ - decl String:sNetClass[32]; - GetEntityNetClass(i, sNetClass, sizeof(sNetClass)); - - /** - See if its something that an engineer would build - */ - if (strcmp(sNetClass, "CObjectSentrygun") == 0 - || strcmp(sNetClass, "CObjectTeleporter") == 0 - || strcmp(sNetClass, "CObjectDispenser") == 0) - { - - /** - It is, so lets check the owner - */ - if (GetEntDataEnt2(i, g_iOwnerOffset) == iClient) - { - - /** - The client supplied is the owner, return true - */ - if (g_bLogActivity2) - { - LogAction(0, iClient, "[STB] Found an engineer with buildings and skipped him."); - } - return true; - } - } - } - - /** - The client supplied didn't have any buildings, return false - */ - return false; -} - -stock StartABalance() -{ - - /** - See if we are already started a balance - */ - if (g_hBalanceTimer != INVALID_HANDLE) - { - - /** - We have, check if we still need to - */ - if (!IsUnbalanced() || !OkToBalance()) - { - - /** - We don't, stop the balance - It's almost impossible to reach this code, but we do it just in case - */ - CloseHandle(g_hBalanceTimer); - g_hBalanceTimer = INVALID_HANDLE; - g_bBalanceInProgress = false; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Balance delay timer was not needed and was killed before the callback."); - } - return; - } - else - { - - /** - We still need to balance - Bug out and wait for the current one to finish - */ - return; - } - } - - /** - Report that teams are unbalanced - */ - PrintToChatAll("[SM] %T", "UnBalanced", LANG_SERVER); - - /** - Check to see if we are supposed to delay the balance - */ - if (g_iBalanceDelay == 0) - { - - /** - Start the balance now - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Balance is now in progress."); - } - g_bBalanceInProgress = true; - g_hBalanceTimer = INVALID_HANDLE; - - /** - Check if we are allowed to scan living players - */ - if (!g_bDeadOnly) - { - - /** - We are allowed to, so we start a timer - */ - StartALivingPlayerTimer(); - - /** - Also report that we are now scanning dead players as well - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Now scanning dead players."); - } - } - else - { - - /** - We are not allowed to, so report that we are only scanning dead players - */ - if (g_bLogActivity) - LogAction(0, -1, "[STB] Only scanning dead players."); - } - - /** - We started the balance, bug out - */ - return; - } - - /** - We are supposed to delay the balance, start a balance timer - */ - g_hBalanceTimer = CreateTimer(float(g_iBalanceDelay), Timer_BalanceTeams, _, TIMER_FLAG_NO_MAPCHANGE); - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Teams are unbalanced. Balance delay timer started."); - } -} - -stock StartALivingPlayerTimer() -{ - - /** - Start a timer to check living players - */ - if (g_hLivingPlayerCheckTimer != INVALID_HANDLE) - { - - /** - If we for some reason already have one started, stop it. - */ - CloseHandle(g_hLivingPlayerCheckTimer); - g_hLivingPlayerCheckTimer = INVALID_HANDLE; - } - - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Living player balance delay timer started."); - } - g_hLivingPlayerCheckTimer = CreateTimer(float(g_iLivingPlayerCheckDelay), Timer_LivingPlayerCheck, _, TIMER_FLAG_NO_MAPCHANGE); -} - -stock FindSwitchablePlayer() -{ - - /** - Start a loop to find a switchable player - */ - new iPlayer; - new iBiggerTeam = GetBiggerTeam(); - for (new i = 1; i <= MaxClients; i++) - { - - /** - Check the stock function to see if we are allows to even switch the player - */ - if (!IsSwitchablePlayer(i, iBiggerTeam)) - { - continue; - } - - /** - If the mod is TF2 and they have Priority Players set check if the client has buildings or an uber - */ - if (g_CurrentMod == GameType_TF && g_bPriorityPlayers) - { - if (HasUber(i) || HasBuildingsBuilt(i)) - { - continue; - } - } - - /** - So far we are able we switch this player - Now we check the buddy system - */ - if (g_bBuddyEnabled) - { - - /** - Buddy system is enabled, check to see if client has buddy - */ - if (SM_GetClientBuddy(i) != 0) - { - - /** - The client has a buddy, so we check to see if they are on same team - */ - if (GetClientTeam(i) == GetClientTeam(SM_GetClientBuddy(i))) - { - - /** - They are, so we continue to next client - */ - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] With a balance in progress a buddy on the right team was found and skipped."); - } - continue; - } - else - { - - /** - They are not on the same team, set this client - The buddy could be in spec, and that would make it not matter where he is, or the buddy is on the smaller team - */ - iPlayer = i; - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] With a balance in progress a buddy on the wrong team was found."); - } - break; - } - } - else - { - - /** - The client does not have a buddy, set this client - */ - iPlayer = i; - break; - } - } - else - { - - /** - Buddy system is not enabled, set this client - */ - iPlayer = i; - break; - } - } - - /** - Return the client we set, this could be 0, but very unlikely - */ - return iPlayer; -} - -stock BalancePlayer(iClient, iTeam) -{ - new Handle:hPack = CreateDataPack(); - WritePackCell(hPack, iClient); - WritePackCell(hPack, iTeam); - CreateTimer(0.1, Timer_BalancePlayer, hPack, TIMER_FLAG_NO_MAPCHANGE); -} - -stock CleanUp(iClient) -{ - g_aPlayers[iClient][bFlagCarrier] = false; - g_aPlayers[iClient][bSwitched] = false; - if (g_aPlayers[iClient][hForcedTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[iClient][hForcedTimer]); - g_aPlayers[iClient][hForcedTimer] = INVALID_HANDLE; - if (g_bLogActivity) - { - LogAction(0, iClient, "[STB] Forced player disconnected, killing timer."); - } - } - if (g_aPlayers[iClient][hBalanceTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[iClient][hBalanceTimer]); - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - if (g_bLogActivity) - { - LogAction(0, iClient, "[STB] Living player set to be balanced disconnected, killing timer."); - } - } -} - -stock GetSmallerTeam() -{ - - /** - Get the count of players on each team - */ - new iCountT1 = GetTeamClientCount(g_aCurrentTeams[Team1]); - new iCountT2 = GetTeamClientCount(g_aCurrentTeams[Team2]); - - /** - Return the smaller team - */ - if (iCountT1 < iCountT2) - { - return g_aCurrentTeams[Team1]; - } - else if (iCountT1 > iCountT2) - { - return g_aCurrentTeams[Team2]; - } - return 0; -} - -stock GetBiggerTeam() -{ - - /** - Get the count of players on each team - */ - new iCountT1 = GetTeamClientCount(g_aCurrentTeams[Team1]); - new iCountT2 = GetTeamClientCount(g_aCurrentTeams[Team2]); - - /** - Return the bigger team - */ - if (iCountT1 > iCountT2) - { - return g_aCurrentTeams[Team1]; - } - else if (iCountT1 < iCountT2) - { - return g_aCurrentTeams[Team2]; - } - return 0; -} - -stock SetGameCvars() -{ - if (g_bConVarControl && g_bIsEnabled) - { - if (stb_mp_autoteambalance != INVALID_HANDLE) - { - SetConVarInt(stb_mp_autoteambalance, 0); - } - if (stb_mp_teams_unbalance_limit != INVALID_HANDLE) - { - SetConVarInt(stb_mp_teams_unbalance_limit, g_iUnbalanceLimit); - } - } -} - -/* TIMER FUNCTIONS */ - -public Action:Timer_ChangeTeamBalanceDelay(Handle:timer, any:data) -{ - - /** - Finally start one if it's still unbalanced - */ - if (IsUnbalanced() && !g_bBalanceInProgress) - { - StartABalance(); - } -} - -public Action:Timer_BalanceTeams(Handle:timer, any:data) -{ - - /** - See if we still need to balance the teams - */ - if (!IsUnbalanced() || !OkToBalance()) - { - - /** - We don't, kill the balance - */ - g_bBalanceInProgress = false; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Balance delay timer was not needed and died."); - } - g_hBalanceTimer = INVALID_HANDLE; - return Plugin_Handled; - } - - /** - We still need to balance the teams - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Teams are still unbalanced. Balance is now in progress."); - } - g_bBalanceInProgress = true; - - - /** - Check if we are allowed to scan living players - */ - if (!g_bDeadOnly) - { - - /** - We are allowed to, so we start a timer - */ - StartALivingPlayerTimer(); - - /** - Also report that we are now scanning dead players as well - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Now scanning dead players."); - } - } - else - { - - /** - We are not allowed to, so report that we are only scanning dead players - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Only scanning dead players."); - } - } - - g_hBalanceTimer = INVALID_HANDLE; - return Plugin_Handled; -} - -public Action:Timer_LivingPlayerCheck(Handle:timer, any:data) -{ - - /** - Check to see if we still need to balance the teams - */ - if (!IsUnbalanced() || !OkToBalance()) - { - - /** - We don't, kill it and bug out - */ - g_bBalanceInProgress = false; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Living player balance delay timer was not needed and died."); - } - g_hLivingPlayerCheckTimer = INVALID_HANDLE; - return Plugin_Handled; - } - - /** - Call the stock function to find a player we can switch - */ - new iPlayer = FindSwitchablePlayer(); - - /** - Check to see if we found a player - */ - if (iPlayer == 0) - { - - /** - In the unlikely event that the stock function didn't return a player - Start a loop to find a random player - */ - new iBiggerTeam = GetBiggerTeam(); - do - { - iPlayer = GetRandomInt(1, MaxClients); - } while (!IsSwitchablePlayer(iPlayer, iBiggerTeam)); - - if (g_bLogActivity) - { - LogAction(0, iPlayer, "[STB] Found a random living player."); - } - } - else - { - if (g_bLogActivity) - { - LogAction(0, iPlayer, "[STB] Found a living player."); - } - } - - /** - Now that we have a player assigned them to the smaller team - */ - new iSmallerTeam = GetSmallerTeam(); - SM_SetForcedTeam(iPlayer, iSmallerTeam, true); - - /** - Let the player know we could be switching him soon - */ - PrintHintText(iPlayer, "%T", "PlayerMessage", LANG_SERVER, g_iLivingPlayerSwitchDelay); - if (g_bLogActivity) - { - LogAction(0, iPlayer, "[STB] Living player placed on a timer."); - } - - /** - Create a timer to switch the player - */ - g_aPlayers[iPlayer][hBalanceTimer] = CreateTimer(float(g_iLivingPlayerSwitchDelay), Timer_LivingPlayerBalance, iPlayer, TIMER_FLAG_NO_MAPCHANGE); - - /** - Reset the timer handle - */ - g_hLivingPlayerCheckTimer = INVALID_HANDLE; - - /** - We are done, bug out - */ - return Plugin_Handled; -} - -public Action:Timer_LivingPlayerBalance(Handle:timer, any:iClient) -{ - - /** - Check to make sure we still need to balance - */ - if (!IsUnbalanced() || !OkToBalance()) - { - - /** - We don't need to balance, bug out - */ - g_bBalanceInProgress = false; - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - SM_ClearForcedTeam(iClient); - return Plugin_Handled; - } - - /** - We still need to balance, lets make sure we can still balance this player - */ - if (!IsClientConnected(iClient) || g_aPlayers[iClient][bFlagCarrier]) - { - g_bBalanceInProgress = false; - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - SM_ClearForcedTeam(iClient); - if (g_bLogActivity) - { - if (g_aPlayers[iClient][bFlagCarrier]) - { - LogAction(0, iClient, "[STB] Living player became flag carrier, balance restarted."); - } - else - { - LogAction(0, iClient, "[STB] Living player timer was not needed and died."); - } - } - return Plugin_Handled; - } - - /** - Clear to balance this player, so do it - */ - BalancePlayer(iClient, SM_GetForcedTeam(iClient)); - if (g_bLogActivity) - { - LogAction(0, iClient, "[STB] Living player was switched."); - } - - /** - We are done, bug out - */ - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - return Plugin_Handled; -} - -public Action:Timer_BalancePlayer(Handle:timer, Handle:pack) -{ - - /** - Rest the datapack and load the variables - */ - ResetPack(pack); - new iClient = ReadPackCell(pack); - new iUnBalancedTeam = ReadPackCell(pack); - - /** - We are done with you now - */ - CloseHandle(pack); - - /** - Check the team and make sure its a valid team - */ - if(!SM_IsValidTeam(iUnBalancedTeam)) - { - if (g_bLogActivity) - { - LogAction(0, iClient, "[STB] Balance failed due to invalid team number %i", iUnBalancedTeam); - } - return Plugin_Handled; - } - - /** - Use our core function to change the clients team - */ - SM_MovePlayer(iClient, iUnBalancedTeam); - - return Plugin_Handled; -} - -public Action:Timer_RoundStart(Handle:timer, any:data) -{ - g_bRoundStart = false; - if (OkToBalance() && IsUnbalanced() && !g_bBalanceInProgress) - { - StartABalance(); - } - return Plugin_Handled; -} - -public Action:Timer_ForcedExpired(Handle:timer, any:iClient) -{ - SM_ClearForcedTeam(iClient); - g_aPlayers[iClient][bSwitched] = false; - g_aPlayers[iClient][hForcedTimer] = INVALID_HANDLE; - return Plugin_Handled; -} - -public Action:Timer_WelcomeAdvert(Handle:timer, any:iClient) -{ - if (IsClientConnected(iClient) && IsClientInGame(iClient)) - { - PrintToChat (iClient, "\x01\x04[STB]\x01 %T", "BuddyWelcomeMsg1", LANG_SERVER); - PrintToChat (iClient, "\x01\x04[STB]\x01 %T", "BuddyWelcomeMsg2", LANG_SERVER); - PrintToChat (iClient, "\x01\x04[STB]\x01 %T", "BuddyWelcomeMsg3", LANG_SERVER); - } - return Plugin_Handled; -} - -/* CONSOLE VARIABLE CHANGE EVENT */ - -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (convar == stb_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsEnabled = false; - PrintToChatAll("[SM] %T", "Disabled", LANG_SERVER); - LogAction(0, -1, "[SimpleTeamBalancer] Disabled"); - } - else - { - g_bIsEnabled = true; - SetGameCvars(); - PrintToChatAll("[SM] %T", "Enabled", LANG_SERVER); - LogAction(0, -1, "[SimpleTeamBalancer] Enabled"); - } - } - else if (convar == stb_logactivity) - { - if (StringToInt(newValue) == 0) - { - g_bLogActivity = false; - LogAction(0, -1, "[STB] Log Activity DISABLED."); - } - else - { - g_bLogActivity = true; - LogAction(0, -1, "[STB] Log Activity ENABLED."); - } - } - else if (convar == stb_logactivity2) - { - if (StringToInt(newValue) == 0) - { - g_bLogActivity2 = false; - LogAction(0, -1, "[STB] Detailed Log Activity DISABLED."); - } - else - { - g_bLogActivity2 = true; - LogAction(0, -1, "[STB] Detailed Log Activity ENABLED."); - } - } - else if (convar == stb_convarcontrol) - { - if (StringToInt(newValue) == 0) - { - g_bConVarControl = false; - } - else - { - g_bConVarControl = true; - SetGameCvars(); - } - } - else if (convar == stb_deadonly) - { - if (StringToInt(newValue) == 0) - { - g_bDeadOnly = false; - } - else - { - g_bDeadOnly = true; - } - } - else if (convar == stb_priorityenabled) - { - if (StringToInt(newValue) == 0) - { - g_bPriorityPlayers = false; - } - else - { - g_bPriorityPlayers = true; - } - } - else if (convar == stb_buddyenabled) - { - if (StringToInt(newValue) == 0) - { - g_bBuddyEnabled = false; - } - else - { - g_bBuddyEnabled = true; - } - } - else if (convar == stb_buddyrestriction) - { - if (StringToInt(newValue) == 0) - { - g_bBuddyRestriction = false; - } - else - { - g_bBuddyRestriction = true; - } - } - else if (convar == stb_unbalancelimit) - { - g_iUnbalanceLimit = StringToInt(newValue); - SetGameCvars(); - } - else if (convar == stb_balancedelay) - { - g_iBalanceDelay = StringToInt(newValue); - } - else if (convar == stb_roundstartdelay) - { - g_iRoundStartDelay = StringToInt(newValue); - } - else if (convar == stb_livingplayerswitchdelay) - { - g_iLivingPlayerSwitchDelay = StringToInt(newValue); - } - else if (convar == stb_livingplayercheckdelay) - { - g_iLivingPlayerCheckDelay = StringToInt(newValue); - } - else if (convar == stb_uberlevel) - { - g_fUberLevel = StringToFloat(newValue); - } - else if (convar == stb_switchbackforced) - { - g_iSwitchBackForced = StringToInt(newValue); - } - else if (convar == stb_adminflag) - { - SetConVarString(stb_adminflag, newValue); - } - else if (convar == stb_mp_autoteambalance) - { - SetGameCvars(); - } - else if (convar == stb_mp_teams_unbalance_limit) - { - SetGameCvars(); - } -} - -/* MENU CODE */ - -stock Handle:BuildPlayerMenu() -{ - new Handle:menu = CreateMenu(Menu_SelectPlayer); - AddTargetsToMenu(menu, 0, true, false); - SetMenuTitle(menu, "Select A Player:"); - SetMenuExitButton(menu, true); - return menu; -} - -public Menu_SelectPlayer(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[24]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - new buddy = GetClientOfUserId(StringToInt(sSelection)); - if (param1 == buddy) { - PrintHintText(param1, "%T", "SelectSelf", LANG_SERVER); - } else if (!IsClientInGame(buddy)) { - PrintHintText(param1, "%T", "BuddyGone", LANG_SERVER); - } else { - decl String:cName[128]; - decl String:bName[128]; - GetClientName(param1, cName, sizeof(cName)); - GetClientName(buddy, bName, sizeof(bName)); - if (!SM_IsBuddyLocked(buddy)) { - SM_AssignBuddy(param1, buddy); - PrintHintText(param1, "%T", "BuddyMsg", LANG_SERVER, bName); - PrintHintText(buddy, "%T", "BuddyMsg", LANG_SERVER, cName); - } else - PrintHintText(param1, "%T", "PlayerLockedBuddyMsg", LANG_SERVER, bName); - } - } else if (action == MenuAction_End) { - CloseHandle(menu); - } -} \ No newline at end of file diff --git a/Simple AllTalk Manager/addons/sourcemod/scripting/simple-teammanager.sp b/Simple AllTalk Manager/addons/sourcemod/scripting/simple-teammanager.sp deleted file mode 100644 index 008f443..0000000 --- a/Simple AllTalk Manager/addons/sourcemod/scripting/simple-teammanager.sp +++ /dev/null @@ -1,1351 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Team Manager -Description: - Manges players and their team - Admin menu integration - Allows admins/donators to swap their teams (clears force)* - Allows admins to move players to a team (forced\unforced)* - Allows admins to scramble the teams* - *Works with Simple Team Balancer (if installed) -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include - -#define PLUGIN_VERSION "2.1.$Rev$" -#define VOTE_YES "##YES##" -#define VOTE_NO "##NO##" - -enum PlayerData -{ - iNewTeam, - bool:bQueue -}; - -new Handle:stm_enabled = INVALID_HANDLE; -new Handle:stm_logactivity = INVALID_HANDLE; -new Handle:stm_adminflag_swapteam = INVALID_HANDLE; -new Handle:stm_adminflag_moveplayer = INVALID_HANDLE; -new Handle:stm_adminflag_scramble = INVALID_HANDLE; -new Handle:stm_scrambledelay = INVALID_HANDLE; -new Handle:stm_voteenabled = INVALID_HANDLE; -new Handle:stm_votewin = INVALID_HANDLE; -new Handle:stm_votedelay = INVALID_HANDLE; -new Handle:stm_mp_bonusroundtime = INVALID_HANDLE; -new Handle:g_hAdminMenu = INVALID_HANDLE; -new Handle:g_hTimerPrepScramble = INVALID_HANDLE; -new Handle:g_hTimerClearScrambleForce = INVALID_HANDLE; - -new g_aPlayers[MAXPLAYERS + 1][PlayerData]; - -new bool:g_bIsEnabled = true; -new bool:g_bVoteEnabled = true; -new bool:g_bLogActivity = true; -new bool:g_bScrambleRoundEnd = false; -new g_iVoteDelay, g_iLastVoteTime, g_iTimeLeft; -new Float:g_fScrambleDelay, Float:g_fVoteWin; - -public Plugin:myinfo = -{ - name = "Simple Team Manager", - author = "Simple Plugins", - description = "Manages players and thier team.", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -}; - -public OnPluginStart() -{ - - /** - Need to create all of our console variables. - */ - CreateConVar("stm_version", PLUGIN_VERSION, "Simple Team Manager Version",FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - stm_enabled = CreateConVar("stm_enabled", "1", "Enable or Disable Simple Team Manager", _, true, 0.0, true, 1.0); - stm_logactivity = CreateConVar("stm_logactivity", "0", "Enable or Disable the disaplying of events in the log", _, true, 0.0, true, 1.0); - stm_adminflag_swapteam = CreateConVar("stm_adminflag_swapteam", "a", "Admin flag to use for the swapteam command. Must be a in char format."); - stm_adminflag_moveplayer = CreateConVar("stm_adminflag_moveplayer", "c", "Admin flag to use for the moveplayer command. Must be a in char format."); - stm_adminflag_scramble = CreateConVar("stm_adminflag_scramble", "c", "Admin flag to use for the scrambleteam command. Must be a in char format."); - stm_scrambledelay = CreateConVar("stm_scrambledelay", "15", "Delay to scramble teams"); - stm_voteenabled = CreateConVar("stm_voteenabled", "1", "Enable or Disable voting to scramble the teams", _, true, 0.0, true, 1.0); - stm_votewin = CreateConVar("stm_votewin", "0.45", "Win percentage vote must win by", _, true, 0.0, true, 1.0); - stm_votedelay = CreateConVar("stm_votedelay", "600", "Delay before another vote can be cast"); - stm_mp_bonusroundtime = FindConVar("mp_bonusroundtime"); - - - /** - Need deal with changes to the console variables after the plugin is loaded. - We could not do this and just call the actual console variable each time we need it, but it's not efficent. - */ - HookConVarChange(stm_enabled, ConVarSettingsChanged); - HookConVarChange(stm_logactivity, ConVarSettingsChanged); - HookConVarChange(stm_scrambledelay, ConVarSettingsChanged); - HookConVarChange(stm_voteenabled, ConVarSettingsChanged); - HookConVarChange(stm_votewin, ConVarSettingsChanged); - HookConVarChange(stm_votedelay, ConVarSettingsChanged); - - /** - Need to register the commands we are going to create and use. - */ - RegConsoleCmd("sm_swapteam", Command_SwapTeam, "sm_swapteam <[0]instant/[1]queued>: Swaps your team to the other team"); - RegConsoleCmd("sm_moveplayer", Command_MovePlayer, "sm_moveplayer <[0]instant/[1]ondeath> <[0]unforced/[1]forced>: Moves a player to the specified team"); - RegConsoleCmd("sm_scrambleteams", Command_ScrambleTeams, "sm_scrambleteams: <[0]now/[1]roundend> <[0]dontrestart/[1]restartround> Scrambles the current teams"); - RegConsoleCmd("sm_votescramble", Command_VoteScramble, "sm_votescramble: Starts a vote to scramble the teams"); - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook the game events - */ - LogAction(0, -1, "[STM] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_death", HookPlayerDeath, EventHookMode_Post); - HookEvent("player_team", HookPlayerChangeTeam, EventHookMode_Post); - switch (g_CurrentMod) - { - case GameType_TF: - { - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - } - case GameType_DOD: - { - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_Post); - } - default: - { - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - } - } - - /** - Now we have to deal with the admin menu. If the admin library is loaded call the function to add our items. - */ - new Handle:gTopMenu; - if (LibraryExists("adminmenu") && ((gTopMenu = GetAdminTopMenu()) != INVALID_HANDLE)) - { - OnAdminMenuReady(gTopMenu); - } - - /** - Load translations and .cfg file - */ - LoadTranslations ("simpleteammanager.phrases"); - AutoExecConfig(true, "plugin.simpleteammanager"); - LogAction(0, -1, "[STM] Simple Team Manager is loaded."); -} - -public OnAllPluginsLoaded() -{ - //something -} - -public OnLibraryRemoved(const String:name[]) -{ - if (StrEqual(name, "adminmenu")) - { - - /** - Looks like the admin menu was removed. Set the global. - */ - g_hAdminMenu = INVALID_HANDLE; - } - else if (StrEqual(name, "simpleplugins")) - { - SetFailState("Required plugin Simple SourceMod Plugins Core was removed."); - } -} - -public OnConfigsExecuted() -{ - - /** - Once we loaded up all the console variables from the config file, lets now set all the global variables we will use. - */ - g_bIsEnabled = GetConVarBool(stm_enabled); - g_bLogActivity = GetConVarBool(stm_logactivity); - g_fScrambleDelay = GetConVarFloat(stm_scrambledelay); - g_iVoteDelay = GetConVarInt(stm_votedelay); - g_fVoteWin = GetConVarFloat(stm_votewin); - g_iLastVoteTime = RoundFloat(GetEngineTime()); - g_bScrambleRoundEnd = false; - g_hTimerClearScrambleForce = INVALID_HANDLE; - - /** - Report enabled - */ - if (g_bIsEnabled) - { - LogAction(0, -1, "[STM] Simple Team Manager is ENABLED."); - } - else - { - LogAction(0, -1, "[STM] Simple Team Manager is DISABLED."); - } - - if (g_bLogActivity) - { - LogAction(0, -1, "[STM] Log Activity ENABLED."); - } - else - { - LogAction(0, -1, "[STM] Log Activity DISABLED."); - } -} - -/* COMMANDS */ - -public Action:Command_SwapTeam(client, args) -{ - - /** - Make sure we are enabled, if not bug out. - */ - if (!g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - If this was ran from the console bug out. - */ - if (client == 0) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "PlayerLevelCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Make sure the client is authorized to run this command. - */ - decl String:sFlags[5]; - GetConVarString(stm_adminflag_swapteam, sFlags, sizeof(sFlags)); - if (!SM_IsValidAdmin(client, sFlags)) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Lets make sure the client is one a team we can swap. - If he is we set the global array to the opposite team. - */ - new iTeam = GetClientTeam(client); - if (iTeam == g_aCurrentTeams[Team1]) - { - g_aPlayers[client][iNewTeam] = g_aCurrentTeams[Team2]; - } - else if (iTeam == g_aCurrentTeams[Team2]) - { - g_aPlayers[client][iNewTeam] = g_aCurrentTeams[Team1]; - } - else - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "InValidTeam", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check to see if we have command arguments. - */ - if (GetCmdArgs()) - { - - /** - We do, so lets get it and see if the client wants to be switched instantly or queued for death. - */ - decl String:sArg[5]; - GetCmdArg(1, sArg, sizeof(sArg)); - new iWantsQue = StringToInt(sArg); - if (iWantsQue && !g_aPlayers[client][bQueue]) - { - - /** - He wants the que and isn't already in it, set the global array. - */ - g_aPlayers[client][bQueue] = true; - ReplyToCommand(client, "\x01\x04[STM]\x01 %T", "PlayerQueue", LANG_SERVER); - } - else if (!iWantsQue) - { - - /** - He wants to be switched right now, lets call the stock function. - */ - SM_MovePlayer(client, g_aPlayers[client][iNewTeam]); - } - } - else - { - - /** - There are no command arguments so we build and display the swap menu. - */ - DisplaySwapModeMenu(client, client); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_MovePlayer(client, args) -{ - - /** - Make sure we are enabled, if not bug out. - */ - if (!g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - Make sure the client is authorized to run this command. - */ - decl String:sFlags[5]; - GetConVarString(stm_adminflag_moveplayer, sFlags, sizeof(sFlags)); - if (!SM_IsValidAdmin(client, sFlags)) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check to see if we have command arguments. - */ - new iCmdArgs = GetCmdArgs(); - if (iCmdArgs == 0) - { - - /** - We don't. Build the player menu, display it, and bug out. - */ - DisplayPlayerMenu(client); - return Plugin_Handled; - } - - /** - Check the first argument - If should be a players name or userid. - */ - decl String:sPlayer[64]; - GetCmdArg(1, sPlayer, sizeof(sPlayer)); - new iPlayerIndex = FindTarget(client, sPlayer, true, true); - if (iPlayerIndex == -1 || !IsClientInGame(iPlayerIndex)) - { - - /** - We don't know who this is. Build the player menu, display it, and bug out. - */ - DisplayPlayerMenu(client); - return Plugin_Handled; - } - - /** - We have figured out the first argument, lets check the second. - If should be the team the client wants to put the player on. - */ - if (iCmdArgs >= 2) - { - - /** - We have a command argument at least, lets see if we can identify the team. - */ - decl String:sTeam[24]; - GetCmdArg(2, sTeam, sizeof(sTeam)); - - new iTeam = StringToInt(sTeam); - if (SM_IsValidTeam(iTeam)) - { - - /** - It's a vaild team so lets set the global array to the new team. - */ - g_aPlayers[iPlayerIndex][iNewTeam] = iTeam; - } - else - { - - /** - It's not a vaild team so set the menu to display to the team menu. - */ - DisplayTeamMenu(client, iPlayerIndex); - return Plugin_Handled; - } - } - else - { - /** - We were not given a team, display the team menu. - */ - DisplayTeamMenu(client, iPlayerIndex); - return Plugin_Handled; - } - - /** - Check to see if we were given any more command arguments and found a team. - */ - if (iCmdArgs < 3) - { - - /** - No more command arguments and found a team. - Now lets check to see if the player is a spectator. If he is there is no reason to ask if it's instant or on death... he can't die. - */ - if (!IsClientObserver(iPlayerIndex)) - { - - /** - Not a spectator so display the swapmode menu. - */ - DisplaySwapModeMenu(client, iPlayerIndex); - } - else - { - - /** - The player is a spectator. - We make sure the player is not set to switch on death, since a spec can't die. - */ - g_aPlayers[iPlayerIndex][bQueue] = false; - } - } - - /** - We have figured out the second argument, lets check the third. - If should be the how the client wants to move the player: instant/on death. - */ - if (iCmdArgs >= 3) - { - - /** - The client gave us a command argument, lets check it. - */ - decl String:sSwapMode[5]; - GetCmdArg(3, sSwapMode, sizeof(sSwapMode)); - new iWantsQue = StringToInt(sSwapMode); - if (iWantsQue) - { - - /** - The client wants to que the player, set the global array. - */ - g_aPlayers[iPlayerIndex][bQueue] = true; - } - else - { - - /** - The client doesn't want to que the player, set the global array. - */ - g_aPlayers[iPlayerIndex][bQueue] = false; - } - } - else - { - /** - No swapmode argument, display the menu - */ - DisplaySwapModeMenu(client, iPlayerIndex); - } - - if (iCmdArgs >= 4) - { - - /** - Since we are compiling for Simple Team Balancer, and given a 4th argument, lets check it. - If should be the if the client wants to force the player to that team. - */ - decl String:sPlayerForced[5]; - GetCmdArg(4, sPlayerForced, sizeof(sPlayerForced)); - new iForceHim = StringToInt(sPlayerForced); - if (iForceHim) - { - - /** - The client wants to force the player - */ - SM_SetForcedTeam(iPlayerIndex, g_aPlayers[iPlayerIndex][iNewTeam]); - } - else - { - - /** - The client doesn't want to force the player - */ - SM_ClearForcedTeam(iPlayerIndex); - } - } - else - { - - } - - /** - We found and processed all the arguments. - */ - if (!IsPlayerAlive(iPlayerIndex)) - { - - /** - The player is not alive or died during this process so we just move him. - */ - SM_MovePlayer(iPlayerIndex, g_aPlayers[iPlayerIndex][iNewTeam]); - } - else - { - if (!g_aPlayers[iPlayerIndex][bQueue]) - { - - /** - The player is alive and is not set to be queued so we just move him. - */ - SM_MovePlayer(iPlayerIndex, g_aPlayers[iPlayerIndex][iNewTeam]); - } - } - - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_ScrambleTeams(client, args) -{ - - /** - Make sure we are enabled, if not bug out. - */ - if (!g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - Make sure the client is authorized to run this command. - */ - decl String:sFlags[5]; - GetConVarString(stm_adminflag_scramble, sFlags, sizeof(sFlags)); - if (!SM_IsValidAdmin(client, sFlags)) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check if a scramble timer was already called, if so close it down. - */ - if (g_hTimerPrepScramble != INVALID_HANDLE) - { - CloseHandle(g_hTimerPrepScramble); - g_hTimerPrepScramble = INVALID_HANDLE; - } - - /** - Check if we have any command arguments. - If we don't we display the scramble menu and bug out. - */ - new iCmdArgs = GetCmdArgs(); - if (iCmdArgs == 0) - { - DisplayScrambleMenu(client); - return Plugin_Handled; - } - - /** - We have a command argument. - It should be whether or not to scramble at round end. - */ - decl String:sRoundEnd[5]; - GetCmdArg(1, sRoundEnd, sizeof(sRoundEnd)); - if (StringToInt(sRoundEnd)) - { - /** - The client wants to scramble at round end so we set the global bool. - */ - g_bScrambleRoundEnd = true; - } - else - { - g_bScrambleRoundEnd = false; - } - - /** - Check for another command argument. - It should be whether or not to restart the round. - */ - decl String:sRestartRound[5]; - new bool:bRestartRound = false; - GetCmdArg(1, sRestartRound, sizeof(sRestartRound)); - if (StringToInt(sRestartRound)) - { - bRestartRound = true; - } - - /** - Now we start the scramble timer. - */ - StartScrambleTimer(_, bRestartRound); - - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_VoteScramble(client, args) -{ - - /** - Make sure we are enabled, if not bug out. - */ - if (!g_bVoteEnabled || !g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - Make sure there is a vote in progress, if so bug out. - */ - if (IsVoteInProgress()) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "VoteInProgress", LANG_SERVER); - return Plugin_Handled; - } - - /** - Make sure enough time has passed since the last vote. - */ - new iVoteTime = RoundFloat(GetEngineTime()); - if (iVoteTime - g_iLastVoteTime <= g_iVoteDelay) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "ScrambleTime", LANG_SERVER); - return Plugin_Handled; - } - - /** - Enough time has passed so reset the global vote time to now. - */ - g_iLastVoteTime = iVoteTime; - - /** - Build the vote menu and send it to everyone. - */ - new Handle:hMenu = CreateMenu(Menu_VoteScramble); - SetMenuTitle(hMenu, "Scramble Teams?"); - AddMenuItem(hMenu, VOTE_YES, "Yes"); - AddMenuItem(hMenu, VOTE_NO, "No"); - SetMenuExitButton(hMenu, false); - VoteMenuToAll(hMenu, 20); - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -/* HOOKED EVENTS */ - -public HookPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Find out who died. - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - - /** - Find out how the client died. - */ - new String:sWeapon[64]; - GetEventString(event, "weapon", sWeapon, sizeof(sWeapon)); - if (StrEqual(sWeapon, "world", false)) - { - - /** - He died because he changed teams so cleanup and bug out. - */ - s_CleanUp(iClient); - return; - } - - /** - Find out if this player was queued to change teams. - */ - if (g_aPlayers[iClient][bQueue]) - { - /** - Looks like he was, so call the stock function to move him. - */ - SM_MovePlayer(iClient, g_aPlayers[iClient][iNewTeam]); - } -} - -public HookPlayerChangeTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Find out who changed teams. - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - - /** - If he was queued to switch teams we cleanup the variables. The client did it themself. - */ - if (g_aPlayers[iClient][bQueue]) - { - s_CleanUp(iClient); - } -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get the amount of time left in the map. - */ - new iTimeLeft; - GetMapTimeLeft(iTimeLeft); - - /** - Check to see if we are supposed to scramble at the end of the round and that there is enough time left in the map. - */ - if (g_bScrambleRoundEnd && iTimeLeft >= 60) - { - - /** - Check to see if there is a scramble timer in action and if so close it down. - */ - if (g_hTimerPrepScramble != INVALID_HANDLE) - { - CloseHandle(g_hTimerPrepScramble); - g_hTimerPrepScramble = INVALID_HANDLE; - } - - /** - Determine the round end chat time and run the scramble 1 second before it ends. - */ - new Float:fDelay = GetConVarFloat(stm_mp_bonusroundtime); - fDelay -= 1.0; - StartScrambleTimer(fDelay); - } -} - -public OnClientPostAdminCheck(client) -{ - - /** - Determine if the client has the flag to use the swapteam command. - */ - decl String:sFlags[5]; - GetConVarString(stm_adminflag_swapteam, sFlags, sizeof(sFlags)); - if (SM_IsValidAdmin(client, sFlags)) - { - /** - The client does so lets create a timer to run an advertise to tell him about it. - */ - CreateTimer (60.0, Timer_WelcomeAdvert, client); - } -} - -public OnClientDisconnect(client) -{ - - /** - Cleanup the clients variables. - */ - s_CleanUp(client); -} - -public SM_OnPlayerMoved(Handle:plugin, client, team) -{ - - /** - Make sure we called the move function - */ - if (plugin != GetMyHandle()) - { - if (g_bLogActivity) - { - LogAction(0, client, "[STM] Callback was not started with current plugin, bugging out."); - } - return; - } - - decl String:sPlayerName[64]; - GetClientName(client, sPlayerName, sizeof(sPlayerName)); - - PrintToChat(client, "\x01\x04[SM]\x01 %T", "PlayerSwitched", LANG_SERVER); - - s_CleanUp(client); -} - -/* TIMER FUNCTIONS */ - -public Action:Timer_PrepTeamScramble(Handle:timer, any:data) -{ - new bool:bRestartRound = data; - /** - Call the scramble the teams stock function. - */ - PrepTeamScramble(bRestartRound); - - /** - Reset the timer handle so we know the timer is done. - */ - g_hTimerPrepScramble = INVALID_HANDLE; - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Timer_ScrambleTheTeams(Handle:timer, any:data) -{ - new iPlayers[MAXPLAYERS + 1]; - new iCount, i, bool:bTeam, bool:bRestartRound = data; - - /** - Get all the client index numbers of valid players - */ - for(i = 1; i <= MaxClients; i++) - { - if(IsClientInGame(i)) // && !IsFakeClient(i)) - { - iPlayers[iCount++] = i; - } - } - - /** - Randomly sort the players - */ - SortIntegers(iPlayers, iCount, Sort_Random); - - /** - Loop through all the players and assign each one to a team, alternating each time - */ - for(i = 0; i < iCount; i++) - { - if (!bRestartRound) - { - /** - We didn't want to restart the round, so we move them to spec 1 at a time. - */ - SM_MovePlayer(iPlayers[i], g_aCurrentTeams[Spectator]); - } - SM_MovePlayer(iPlayers[i], bTeam ? g_aCurrentTeams[Team2] : g_aCurrentTeams[Team1]); - SM_SetForcedTeam(iPlayers[i], bTeam ? g_aCurrentTeams[Team2] : g_aCurrentTeams[Team1], true); - bTeam = !bTeam; - } - - /** - Reset this variable since we completed a scramble - */ - g_bScrambleRoundEnd = false; - - if (g_hTimerClearScrambleForce != INVALID_HANDLE) - { - CloseHandle(g_hTimerClearScrambleForce); - g_hTimerClearScrambleForce = INVALID_HANDLE; - } - - g_hTimerClearScrambleForce = CreateTimer(300.0, Timer_ClearScrambleForce, _, TIMER_FLAG_NO_MAPCHANGE); - - ServerCommand("mp_timelimit %i", g_iTimeLeft / 60); - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Timer_ClearScrambleForce(Handle:timer, any:data) -{ - - for(new i = 1; i <= MaxClients; i++) - { - if(IsClientInGame(i)) // && !IsFakeClient(i)) - { - SM_ClearForcedTeam(i); - PrintToChat(i, "\x01\x04[SM]\x01 Your forced team status has been cleared"); - } - } - - g_hTimerClearScrambleForce = INVALID_HANDLE; - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Timer_WelcomeAdvert(Handle:timer, any:client) -{ - - /** - Lets make sure the client is connected and actually in the game. - */ - if (IsClientConnected(client) && IsClientInGame(client)) - { - - /** - We are good to go so lets tell him about the swapteam command. - */ - PrintToChat (client, "\x01\x04[STM]\x01 %T", "SwapTeamMsg", LANG_SERVER); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -/* STOCK FUNCTIONS */ - -stock s_CleanUp(iClient) -{ - - /** - Reset all the client variables - */ - g_aPlayers[iClient][bQueue] = false; - g_aPlayers[iClient][iNewTeam] = 0; -} - -stock StartScrambleTimer(Float:fdelay = 0.0, bool:bRestartRound = false) -{ - if (fdelay == 0.0) - { - fdelay = g_fScrambleDelay; - } - if (g_hTimerPrepScramble != INVALID_HANDLE) - { - CloseHandle(g_hTimerPrepScramble); - g_hTimerPrepScramble = INVALID_HANDLE; - } - PrintCenterTextAll("%T", "Scramble", LANG_SERVER); - g_hTimerPrepScramble = CreateTimer(fdelay, Timer_PrepTeamScramble, bRestartRound, TIMER_FLAG_NO_MAPCHANGE); -} - -stock PrepTeamScramble(bool:bRestartRound = false) -{ - new iPlayers[MAXPLAYERS + 1]; - new iCount; - - GetMapTimeLeft(g_iTimeLeft); - - if (bRestartRound) - { - - for(new i = 1; i <= MaxClients; i++) - { - if(IsClientInGame(i)) - // && !IsFakeClient(i)) - { - iPlayers[iCount++] = i; - SM_ClearForcedTeam(i); - SM_ClearBuddy(i); - SM_MovePlayer(i, g_aCurrentTeams[Spectator]); - } - } - } - else - { - //Can't move them all to spec at the same time - for(new i = 1; i <= MaxClients; i++) - { - if(IsClientInGame(i)) - // && !IsFakeClient(i)) - { - iPlayers[iCount++] = i; - SM_ClearForcedTeam(i); - SM_ClearBuddy(i); - //SM_MovePlayer(i, g_aCurrentTeams[Spectator]); - } - } - } - CreateTimer(4.0, Timer_ScrambleTheTeams, bRestartRound, TIMER_FLAG_NO_MAPCHANGE); -} - -/* CONSOLE VARIABLE CHANGE EVENT */ - -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (convar == stm_enabled) { - if (StringToInt(newValue) == 0) { - g_bIsEnabled = false; - LogAction(0, -1, "[STM] Simple Team Manager is loaded and disabled."); - } else { - g_bIsEnabled = true; - LogAction(0, -1, "[STM] Simple Team Manager is loaded and enabled."); - } - } - else if (convar == stm_logactivity) { - if (StringToInt(newValue) == 0) { - g_bLogActivity = false; - LogAction(0, -1, "[STM] Log Activity DISABLED."); - } else { - g_bLogActivity = true; - LogAction(0, -1, "[STM] Log Activity ENABLED."); - } - } - else if (convar == stm_scrambledelay) - g_fScrambleDelay = StringToFloat(newValue); - else if (convar == stm_votewin) - g_fVoteWin = StringToFloat(newValue); - else if (convar == stm_votedelay) - g_iVoteDelay = StringToInt(newValue); - else if (convar == stm_voteenabled) { - if (StringToInt(newValue) == 0) - g_bVoteEnabled = false; - else - g_bVoteEnabled = true; - } -} - -/* MENU CODE */ - -public OnAdminMenuReady(Handle:topmenu) -{ - if (topmenu == g_hAdminMenu) - return; - g_hAdminMenu = topmenu; - new TopMenuObject:player_commands = FindTopMenuCategory(g_hAdminMenu, ADMINMENU_PLAYERCOMMANDS); - new TopMenuObject:server_commands = FindTopMenuCategory(g_hAdminMenu, ADMINMENU_SERVERCOMMANDS); - if (player_commands == INVALID_TOPMENUOBJECT) - return; - - AddToTopMenu(g_hAdminMenu, - "moveplayer", - TopMenuObject_Item, - AdminMenu_MovePlayer, - player_commands, - "moveplayer", - ADMFLAG_BAN); - - AddToTopMenu(g_hAdminMenu, - "scrambleteams", - TopMenuObject_Item, - AdminMenu_Scrambleteams, - server_commands, - "scrambleteams", - ADMFLAG_BAN); -} - -public AdminMenu_MovePlayer(Handle:topmenu, TopMenuAction:action, TopMenuObject:object_id, param, String:buffer[], maxlength) -{ - if (action == TopMenuAction_DisplayOption) - Format(buffer, maxlength, "Move Player"); - else if (action == TopMenuAction_SelectOption){ - DisplayPlayerMenu(param); - } -} - -public AdminMenu_Scrambleteams(Handle:topmenu, TopMenuAction:action, TopMenuObject:object_id, param, String:buffer[], maxlength) -{ - if (action == TopMenuAction_DisplayOption) - Format(buffer, maxlength, "Scramble Teams"); - else if (action == TopMenuAction_SelectOption) { - DisplayScrambleMenu(param); - } -} - -public Menu_SelectPlayer(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - DisplayTeamMenu(param1, GetClientOfUserId(StringToInt(sSelection))); - } else if (action == MenuAction_Cancel) { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -public Menu_SelectTeam(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new iTeam; - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - decl String:sIndex[64]; - if (SplitString(sSelection, "A", sIndex, sizeof(sIndex)) != -1) - iTeam = g_aCurrentTeams[Team1]; - else if (SplitString(sSelection, "B", sIndex, sizeof(sIndex)) != -1) - iTeam = g_aCurrentTeams[Team2]; - else { - SplitString(sSelection, "C", sIndex, sizeof(sIndex)); - iTeam = g_aCurrentTeams[Spectator]; - } - new iTarget = StringToInt(sIndex); - g_aPlayers[iTarget][iNewTeam] = iTeam; - DisplaySwapModeMenu(param1, iTarget); - } else if (action == MenuAction_Cancel) { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -public Menu_SwapMode(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - decl String:sIndex[64]; - - if (SplitString(sSelection, "A", sIndex, sizeof(sIndex)) == -1) - { - SplitString(sSelection, "B", sIndex, sizeof(sIndex)); - } - - new iTarget = StringToInt(sIndex); - - if (StrContains(sSelection, "A", true) != -1) - { - g_aPlayers[iTarget][bQueue] = false; - } - else if (StrContains(sSelection, "B", true) != -1) - { - g_aPlayers[iTarget][bQueue] = true; - } - - if (param1 == iTarget && !g_aPlayers[iTarget][bQueue]) - { - SM_MovePlayer(iTarget, g_aPlayers[iTarget][iNewTeam]); - } - else - { - DisplayForceModeMenu(param1, iTarget); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - { - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } - return; -} - -public Menu_ForceMode(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - decl String:sIndex[64]; - if (SplitString(sSelection, "A", sIndex, sizeof(sIndex)) == -1) - { - SplitString(sSelection, "B", sIndex, sizeof(sIndex)); - } - new iTarget = StringToInt(sIndex); - if (StrContains(sSelection, "A", true) != -1) - { - SM_ClearForcedTeam(iTarget); - } - else if (StrContains(sSelection, "B", true) != -1) - { - SM_SetForcedTeam(iTarget, g_aPlayers[iTarget][iNewTeam], true); - } - if (!g_aPlayers[iTarget][bQueue]) - { - SM_MovePlayer(iTarget, g_aPlayers[iTarget][iNewTeam]); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - { - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } - return; -} - -public Menu_VoteScramble(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_VoteEnd) { - new winning_votes, total_votes; - GetMenuVoteInfo(param2, winning_votes, total_votes); - if (param1 == 0) { - if (float(total_votes) / float(winning_votes) < g_fVoteWin) { - PrintToChatAll("\x01\x04[SM]\x01 %T", "VoteScramble2", LANG_SERVER, winning_votes, total_votes); - return; - } - PrintCenterTextAll("[SM] %T", "Scramble", LANG_SERVER); - PrintToChatAll("\x01\x04[SM]\x01 %T", "VoteScramble1", LANG_SERVER, winning_votes, total_votes); - StartScrambleTimer(); - } - if (param1 == 1) { - PrintToChatAll("\x01\x04[SM]\x01 %T", "VoteScramble2", LANG_SERVER, winning_votes, total_votes); - } - } - if (action == MenuAction_End) - CloseHandle(menu); -} - -public Menu_ScrambleTeams(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "NOW", false)) - g_bScrambleRoundEnd = false; - else - g_bScrambleRoundEnd = true; - DisplayScrambleMenu2(param1); - } else if (action == MenuAction_Cancel) { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -public Menu_ScrambleTeams2(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[64]; - new bool:bRestartRound; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "NO", false)) - { - bRestartRound = false; - } - else - { - bRestartRound = true; - } - StartScrambleTimer(_, bRestartRound); - } else if (action == MenuAction_Cancel) { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -stock DisplayScrambleMenu(iClient) -{ - new Handle:hMenu = CreateMenu(Menu_ScrambleTeams); - SetMenuTitle(hMenu, "Select When to Scramble:"); - AddMenuItem(hMenu, "NOW", "Instantly"); - AddMenuItem(hMenu, "END", "At Round End"); - SetMenuExitBackButton(hMenu, false); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} - -stock DisplayScrambleMenu2(iClient) -{ - new Handle:hMenu = CreateMenu(Menu_ScrambleTeams2); - SetMenuTitle(hMenu, "Select When to Scramble:"); - AddMenuItem(hMenu, "NO", "No Round Restart"); - AddMenuItem(hMenu, "YES", "Restart Round"); - SetMenuExitBackButton(hMenu, false); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} - -stock DisplaySwapModeMenu(iClient, iTarget) -{ - new Handle:hMenu = CreateMenu(Menu_SwapMode); - decl String:optionA[64]; - decl String:optionB[64]; - Format(optionA, sizeof(optionA), "%iA", iTarget); - Format(optionB, sizeof(optionB), "%iB", iTarget); - SetMenuTitle(hMenu, "Select When to Swap:"); - AddMenuItem(hMenu, optionA, "Instantly (Kills)"); - if (!IsClientObserver(iTarget)) - AddMenuItem(hMenu, optionB, "Queue on next death"); - SetMenuExitBackButton(hMenu, false); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} - -stock DisplayForceModeMenu(iClient, iTarget) -{ - new Handle:hMenu = CreateMenu(Menu_ForceMode); - decl String:optionA[64]; - decl String:optionB[64]; - Format(optionA, sizeof(optionA), "%iA", iTarget); - Format(optionB, sizeof(optionB), "%iB", iTarget); - SetMenuTitle(hMenu, "Select Force Mode:"); - AddMenuItem(hMenu, optionA, "UnForced"); - AddMenuItem(hMenu, optionB, "Forced"); - SetMenuExitBackButton(hMenu, false); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} - -stock DisplayTeamMenu(iClient, iTarget) -{ - new Handle:hMenu = CreateMenu(Menu_SelectTeam); - decl String:optionA[64]; - decl String:optionB[64]; - decl String:optionC[64]; - Format(optionA, sizeof(optionA), "%iA", iTarget); - Format(optionB, sizeof(optionB), "%iB", iTarget); - Format(optionC, sizeof(optionC), "%iC", iTarget); - SetMenuTitle(hMenu, "Select Team:"); - AddMenuItem(hMenu, optionA, "Team One"); - AddMenuItem(hMenu, optionB, "Team Two"); - AddMenuItem(hMenu, optionC, "Spectator"); - SetMenuExitBackButton(hMenu, false); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} - -stock DisplayPlayerMenu(iClient) -{ - new Handle:hMenu = CreateMenu(Menu_SelectPlayer); - AddTargetsToMenu(hMenu, 0, true, false); - SetMenuTitle(hMenu, "Select A Player:"); - SetMenuExitBackButton(hMenu, true); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} diff --git a/Simple AllTalk Manager/addons/sourcemod/translations/simpledonatorbenefits.phrases.txt b/Simple AllTalk Manager/addons/sourcemod/translations/simpledonatorbenefits.phrases.txt deleted file mode 100644 index 3826846..0000000 --- a/Simple AllTalk Manager/addons/sourcemod/translations/simpledonatorbenefits.phrases.txt +++ /dev/null @@ -1,62 +0,0 @@ -"Phrases" -{ - "PlayerLevelCmd" - { - "en" "Command must be run at the player level" - "fr" "Cette commande doit être tapée en jeu" - "hu" "Ezt a parancsot jatekosi szinten kell futtatni!" - } - "RestrictedCmd" - { - "en" "You must be a donator or admin to run this command" - "fr" "Vous devez être un donateur ou un admin pour lancer cette commande" - "hu" "A parancs futtatasahoz admin, vagy tamogatoi szint szukseges!" - } - "InValidTeam" - { - "en" "You must be on red or blue to swap teams" - "fr" "Vous devez être RED ou BLU pour changer d'équipe" - "hu" "Jatekban kell lenned, hogy megcsereld a csapatokat!" - } - "PlayerQueue" - { - "en" "You have been queued to swap teams on next death" - "fr" "Vous avez été mis en attente pour changer d'équipe lors de votre prochaine mort" - "hu" "A kovetkezo halalnal csapatcsere lesz" - } - "PlayerSwitched" - { - "en" "Your team has been switched as requested" - "fr" "Vous avez changé d'équipe comme demandé" - "hu" "A keresnek eleget teve a csapatod meg lett csererlve" - } - "SwapTeamMsg" - { - "en" "Type /swapteam or !swapteam to swap your team!" - } - "ReachedCount" - { - "en" "You have reached your health limit. You must die before you can use it again" - } - "AtMaxHealth" - { - "en" "You are already at your maximum health!" - } - "ToMaxHealth" - { - "en" "Instant health bonus applied! You are not at your maximun health!" - } - "HealthBonus" - { - "en" "Instant health bonus applied!" - } - "PublicJoinMessage" - { - "#format" "{1:s}" - "en" "{1} a [donator] as joined the server" - } - "PrivateJoinMessage" - { - "en" "Thanks for donating!" - } -} \ No newline at end of file diff --git a/Simple AllTalk Manager/addons/sourcemod/translations/simplespectate.phrases.txt b/Simple AllTalk Manager/addons/sourcemod/translations/simplespectate.phrases.txt deleted file mode 100644 index 2d1a096..0000000 --- a/Simple AllTalk Manager/addons/sourcemod/translations/simplespectate.phrases.txt +++ /dev/null @@ -1,42 +0,0 @@ -"Phrases" -{ - "Stopped spectating" - { - "#format" "{1:s}" - "en" "Stopped tracking player: {1}" - } - "Yourself" - { - "en" "You can't spectate yourself" - } - "Spectator" - { - "en" "You can't spectate another spectator" - } - "Spectating" - { - "#format" "{1:s}" - "en" "Now spectating {1}. Type !stopspec or /stopspec to stop spectating this player" - } - "Invalid Target" - { - "en" "Invalid target" - } - "Cant Target" - { - "en" "Can't target this player" - } - "Must Have Target" - { - "en" "You must be following/tracking a player to punish" - } - "Target Left" - { - "en" "The player you were following/tracking has left" - } - "Punished" - { - "#format" "{1:s}{2:s}{3:s}" - "en" "{1} was punished with a {2} for {3}" - } -} \ No newline at end of file diff --git a/Simple AllTalk Manager/addons/sourcemod/translations/simpleteambalancer.phrases.txt b/Simple AllTalk Manager/addons/sourcemod/translations/simpleteambalancer.phrases.txt deleted file mode 100644 index 03595fd..0000000 --- a/Simple AllTalk Manager/addons/sourcemod/translations/simpleteambalancer.phrases.txt +++ /dev/null @@ -1,130 +0,0 @@ -"Phrases" -{ - "UnBalanced" - { - "en" "Teams are unbalanced and will be balanced shortly" - "fr" "Les équipes ne sont pas équilibrées et le seront bientôt" - "de" "Die Teams sind ungleich und werden in Kürze ausgeglichen" - "hu" "A csapatok nem kiegyenlitettek! Egyensuly beallitas kovetkezik!" - } - "Enabled" - { - "en" "Simple Team Balancer is ENABLED" - "fr" "Simple Team Balancer est ACTIVE" - "de" "Simple Team Balancer ist AKTIV" - "hu" "Az Egyszeru Csapat Egyensulytarto AKTIV!" - } - "Disabled" - { - "en" "Simple Team Balancer is DISABLED" - "fr" "Simple Team Balancer est DESACTIVE" - "de" "Simple Team Balancer ist INAKTIV" - "hu" "Az Egyszeru Csapat Egyensulytarto INAKTIV!" - } - "PlayerMessage" - { - "#format" "{1:i}" - "en" "You are going to be auto balanced in {1} seconds unless a dead player can be found" - "fr" "Vous passerez dans l'autre équipe dans {1} secondes si aucun joueur mort ne peut être trouvé dans cet intervalle" - "de" "Du wirst in {1} Sekunden zum automatischen Ausgleich herangezogen wenn kein toter Spieler gefunden werden kann" - "hu" "{1} masodpercen belul at leszel helyezve a masik csapatba, hacsak nem lesz addig egy halott jatekos!" - } - "BalanceMessage" - { - "#format" "{1:s}" - "en" "{1} was moved to the other team for game balance" - "fr" "{1} est passé dans l'autre équipe pour équilibrer la partie" - "de" "{1} wurde zum anderen Team verschoben um das Spiel auszugleichen" - "hu" "{1} at lett helyezve az egyensuly megtartasa erdekeben." - } - "PlayerLevelCmd" - { - "en" "Command must be run at the player level" - "fr" "La commande doit être lancée au niveau du joueur" - "de" "Das Kommando muss auf Spieler Ebene ausgeführt werden" - "hu" "Jatekosi szinten kell futtatni ezt a parancsot!" - } - "CmdDisabled" - { - "en" "Command is currently disabled" - "fr" "La commande est actuellement désactivée" - "de" "Das Kommando ist momentan inaktiv" - "hu" "A parancs jelenleg inaktiv" - } - "RestrictedBuddy" - { - "en" "You must be a donator or admin to add a balance buddy" - "fr" "Vous devez être un donateur ou un admin pour choisir un partenaire" - "de" "Du musst ein Spender oder Admin sein um einen Partner wählen zu können" - "hu" "Tamogato vagy admin kell hogy legyel, hogy 'Tarsat' jelolhess meg" - } - "SelectSelf" - { - "en" "You cannot be your own buddy" - "fr" "Vous ne pouvez pas être votre propre partenaire" - "de" "Du kannst nicht dein eigener Partner sein" - "hu" "Nem valaszthatod ki onmagad!" - } - "BuddyGone" - { - "en" "Your selected buddy has disconnected" - "fr" "Le partenaire que vous avez sélectionné s'est déconnecté" - "de" "Dein gewählter Partner hat die Verbindung getrennt" - "hu" "A valasztott 'Tarsad' kilepett" - } - "BuddyMsg" - { - "#format" "{1:s}" - "en" "You and {1} are now buddies" - "fr" "Vous et {1} êtes maintenant partenaires" - "de" "Du und {1} seid jetzt Partner" - "hu" "{1} es Te 'Tarsak' vagytok." - } - "BuddyLockMsgDisabled" - { - "en" "You can now be anyone's buddy" - "fr" "Vous pouvez à présent être le partenaire de n'importe qui" - "de" "Du kannst jetzt jedermanns Partner sein" - "hu" "Barkinek lehetsz a 'Tarsa'." - } - "BuddyLockMsgEnabled" - { - "en" "Buddy selection locked. Only you can change your buddy" - "fr" "Sélection de partenaire bloquée. Vous êtes le seul à pouvoir choisir votre partenaire" - "de" "Wahl des Partners gesperrt. Nur du kannst deinen Partner wechseln" - "hu" "Tars-lista lezarva. Csak Te tudod modositani a Tars-listadat." - } - "PlayerLockedBuddyMsg" - { - "#format" "{1:s}" - "en" "{1} has locked his buddy selection. Try again" - "fr" "{1} a bloqué sa sélection de partenaire. Essayez de nouveau." - "de" "{1} hat seine Wahl des Partners gesperrt. Versuche es erneut" - "hu" "{1} lezarta a Tars-listajat. Probald kesobb!" - } - "BuddyWelcomeMsg1" - { - "en" "Select a balance buddy and stay together during an autobalance!" - "fr" "Choisissez un partenaire et restez ensemble durant l'équilibrage automatique!" - "de" "Wähle einen Partner und bleibt zusammen während eines Ausgleichs" - "hu" "Valasz ki egy 'Tarsat' akivel egyuttmaradhatsz a csapatkiegyenlites alatt!" - } - "BuddyWelcomeMsg2" - { - "en" "/buddy or !buddy to select a balance buddy" - "fr" "/buddy or !buddy pour choisir un partenaire" - "de" "/buddy oder !buddy um einen Partner zu wählen" - "hu" "Hasznald a /buddy vagy !buddy parancsokat a 'Tars' kijelolesehez" - } - "BuddyWelcomeMsg3" - { - "en" "/lockbuddy or !lockbuddy to lock your selection" - "fr" "/lockbuddy or !lockbuddy pour bloquer votre sélection" - "de" "/lockbuddy oder !lockbuddy um deine Auswahl zu sperren" - "hu" "Hasznald a /lockbuddy vagy a !lockbuddy parancsokat a Tars-listad lezarasahoz" - } -} - - - - diff --git a/Simple AllTalk Manager/addons/sourcemod/translations/simpleteammanager.phrases.txt b/Simple AllTalk Manager/addons/sourcemod/translations/simpleteammanager.phrases.txt deleted file mode 100644 index f2093a7..0000000 --- a/Simple AllTalk Manager/addons/sourcemod/translations/simpleteammanager.phrases.txt +++ /dev/null @@ -1,92 +0,0 @@ -"Phrases" -{ - "PlayerLevelCmd" - { - "en" "Command must be run at the player level" - "fr" "Cette commande doit être tapée en jeu" - "hu" "Ezt a parancsot jatekosi szinten kell futtatni!" - } - "RestrictedCmd" - { - "en" "You must be a donator or admin to run this command" - "fr" "Vous devez être un donateur ou un admin pour lancer cette commande" - "hu" "A parancs futtatasahoz admin, vagy tamogatoi szint szukseges!" - } - "InValidTeam" - { - "en" "You must be on red or blue to swap teams" - "fr" "Vous devez être RED ou BLU pour changer d'équipe" - "hu" "Jatekban kell lenned, hogy megcsereld a csapatokat!" - } - "PlayerInValidTeam" - { - "en" "Player must be on red or blue to swap teams" - "fr" "Le joueur doit être RED ou BLU pour changer d'équipe" - "hu" "Valamelyik csapatban kell lenni, hogy csere legyen" - } - "PlayerQueue" - { - "en" "You have been queued to swap teams on next death" - "fr" "Vous avez été mis en attente pour changer d'équipe lors de votre prochaine mort" - "hu" "A kovetkezo halalnal csapatcsere lesz" - } - "PlayerSwitched" - { - "en" "Your team has been switched" - } - "PlayerSwitched1" - { - "en" "Your team has been switched as requested" - "fr" "Vous avez changé d'équipe comme demandé" - "hu" "A keresnek eleget teve a csapatod meg lett csererlve" - } - "PlayerSwitched2" - { - "en" "Your team has been switched by an Admin" - "fr" "Vous avez été changé d'équipe par un admin" - "hu" "Az Admin megcserelte a csapatodat!" - } - "SwapTeamMsg" - { - "en" "Type /swapteam or !swapteam to swap your team!" - } - "PlayerSwitched3" - { - "#format" "{1:s}" - "en" "{1}'s team has been switched" - "fr" "{1} a changé d'équipe" - "hu" "{1} csapata meg lett cserelve" - } - "Scramble" - { - "en" "Teams are about to be scrambled!" - "fr" "Les équipes vont être rééquilibrés" - "hu" "A csapatok hamarosan meg lesznek keverve!" - } - "VoteScramble1" - { - "#format" "{1:i}{2:i}" - "en" "Vote Scramble successful with {1} votes out of {2}" - "fr" "Le vote d'équilibrage des équipes a réussi avec {1} votes pour sur {2}" - "hu" "A szavazas sikeres volt, {1} szavazat a keveresre a {2} -bol" - } - "VoteScramble2" - { - "#format" "{1:i}{2:i}" - "en" "Vote Scramble failed with {1} votes out of {2}" - "fr" "Le vote d'équilibrage a échoué avec {1} votes pour sur {2}" - "hu" "A szavazas sikertelen volt, {1} szavazat a keveresre a {2} -bol" - } - "VoteInProgress" - { - "en" "A vote is currently in progress" - "fr" "Un vote est actuellement en cours" - "hu" "Egy szavazas mar fut!" - } - "ScrambleTime" - { - "en" "A vote was recently made, please wait" - "fr" "Un vote a déjà été fait récemment, réessayez plus tard" - "hu" "Nemreg volt szavazas, kerlek varj egy kicsit!" - } -} \ No newline at end of file diff --git a/Simple AutoScrambler/addons/sourcemod/configs/simple-alltalkmanager_events.cfg b/Simple AutoScrambler/addons/sourcemod/configs/simple-alltalkmanager_events.cfg deleted file mode 100644 index b739cf0..0000000 --- a/Simple AutoScrambler/addons/sourcemod/configs/simple-alltalkmanager_events.cfg +++ /dev/null @@ -1,43 +0,0 @@ -"game_events" -{ - "teamplay_round_start" - { - "reason" "Round Start" - "setting" "1" - } - "teamplay_setup_finished" - { - "reason" "Setup Period Ended" - "setting" "0" - } - "teamplay_overtime_begin" - { - "reason" "Overtime Began" - "setting" "1" - } - "teamplay_overtime_end" - { - "reason" "Overtime Ended" - "setting" "1" - } - "teamplay_round_win" - { - "reason" "Round Ended" - "setting" "1" - } - "teamplay_suddendeath_begin" - { - "reason" "Sudden Death Began" - "setting" "1" - } - "teamplay_suddendeath_end" - { - "reason" "Sudden Death Ended" - "setting" "1" - } - "teamplay_round_stalemate" - { - "reason" "Stalemate" - "setting" "1" - } -} \ No newline at end of file diff --git a/Simple AutoScrambler/addons/sourcemod/configs/simple-chatcolors.cfg b/Simple AutoScrambler/addons/sourcemod/configs/simple-chatcolors.cfg deleted file mode 100644 index 14b98c6..0000000 --- a/Simple AutoScrambler/addons/sourcemod/configs/simple-chatcolors.cfg +++ /dev/null @@ -1,15 +0,0 @@ -"admin_colors" -{ - "groupname2" - { - "flag" "z" - "namecolor" "{green}" - "textcolor" "{olive}" - } - "groupname1" - { - "flag" "a" - "namecolor" "{teamcolor}" - "textcolor" "{green}" - } -} \ No newline at end of file diff --git a/Simple AutoScrambler/addons/sourcemod/plugins/simple-alltalkmanager.smx b/Simple AutoScrambler/addons/sourcemod/plugins/simple-alltalkmanager.smx deleted file mode 100644 index 6122756..0000000 Binary files a/Simple AutoScrambler/addons/sourcemod/plugins/simple-alltalkmanager.smx and /dev/null differ diff --git a/Simple AutoScrambler/addons/sourcemod/plugins/simple-donatorbenefits.smx b/Simple AutoScrambler/addons/sourcemod/plugins/simple-donatorbenefits.smx deleted file mode 100644 index 821d61d..0000000 Binary files a/Simple AutoScrambler/addons/sourcemod/plugins/simple-donatorbenefits.smx and /dev/null differ diff --git a/Simple AutoScrambler/addons/sourcemod/plugins/simple-messagesuppression.smx b/Simple AutoScrambler/addons/sourcemod/plugins/simple-messagesuppression.smx deleted file mode 100644 index cc20dad..0000000 Binary files a/Simple AutoScrambler/addons/sourcemod/plugins/simple-messagesuppression.smx and /dev/null differ diff --git a/Simple AutoScrambler/addons/sourcemod/plugins/simple-plugins.smx b/Simple AutoScrambler/addons/sourcemod/plugins/simple-plugins.smx deleted file mode 100644 index ac307a3..0000000 Binary files a/Simple AutoScrambler/addons/sourcemod/plugins/simple-plugins.smx and /dev/null differ diff --git a/Simple AutoScrambler/addons/sourcemod/plugins/simple-spectate.smx b/Simple AutoScrambler/addons/sourcemod/plugins/simple-spectate.smx deleted file mode 100644 index c6885b0..0000000 Binary files a/Simple AutoScrambler/addons/sourcemod/plugins/simple-spectate.smx and /dev/null differ diff --git a/Simple AutoScrambler/addons/sourcemod/plugins/simple-teambalancer.smx b/Simple AutoScrambler/addons/sourcemod/plugins/simple-teambalancer.smx deleted file mode 100644 index 95beb01..0000000 Binary files a/Simple AutoScrambler/addons/sourcemod/plugins/simple-teambalancer.smx and /dev/null differ diff --git a/Simple AutoScrambler/addons/sourcemod/plugins/simple-teammanager.smx b/Simple AutoScrambler/addons/sourcemod/plugins/simple-teammanager.smx deleted file mode 100644 index 81905ba..0000000 Binary files a/Simple AutoScrambler/addons/sourcemod/plugins/simple-teammanager.smx and /dev/null differ diff --git a/Simple AutoScrambler/addons/sourcemod/scripting/include/simple-plugins.inc b/Simple AutoScrambler/addons/sourcemod/scripting/include/simple-plugins.inc deleted file mode 100644 index 8f21956..0000000 --- a/Simple AutoScrambler/addons/sourcemod/scripting/include/simple-plugins.inc +++ /dev/null @@ -1,337 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Plugins -Description: - Included file for core plugin in the Simple Plugins project -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -*************************************************************************/ - -#if defined _simpleplugin_included - #endinput -#endif - -#define _simpleplugin_included - -#define CORE_INC_VERSION "1.1.$Rev$" - -#pragma semicolon 1 -#include -#undef REQUIRE_PLUGIN -#include -#define REQUIRE_PLUGIN -#undef REQUIRE_EXTENSIONS -#undef AUTOLOAD_EXTENSIONS -#tryinclude -#tryinclude -#tryinclude -#define AUTOLOAD_EXTENSIONS -#define REQUIRE_EXTENSIONS - -enum e_SupportedMods -{ - GameType_Unknown, - GameType_AOC, - GameType_CSS, - GameType_DOD, - GameType_FF, - GameType_HIDDEN, - GameType_HL2DM, - GameType_INS, - GameType_L4D, - GameType_NEO, - GameType_SGTLS, - GameType_TF, - GameType_ZPS -}; - -enum e_Teams -{ - Unknown, - Spectator, - Team1, - Team2 -}; - -new g_aCurrentTeams[e_Teams]; -new e_SupportedMods:g_CurrentMod; -new String:g_sGameName[e_SupportedMods][32] = { "Unknown", - "Age of Chivalry", - "Counter Strike", - "Day Of Defeat", - "Fortress Forever", - "Hidden: Source", - "Half Life 2: Deathmatch", - "Insurgency", - "Left 4 Dead", - "Neotokyo", - "Stargate TLS", - "Team Fortress 2", - "Zombie Panic: Source" - }; - -public SharedPlugin:_pl_simpleplugin = -{ - name = "simple-plugins", - file = "simple-plugins.smx", -#if defined REQUIRE_PLUGIN - required = 1 -#else - required = 0 -#endif -}; - -#if !defined REQUIRE_PLUGIN -public _pl_simpleplugin_SetNTVOptional() -{ - MarkNativeAsOptional("SM_MovePlayer"); - MarkNativeAsOptional("SM_SetForcedTeam"); - MarkNativeAsOptional("SM_GetForcedTeam"); - MarkNativeAsOptional("SM_ClearForcedTeam"); - MarkNativeAsOptional("SM_GetForcedPlayer"); - MarkNativeAsOptional("SM_AssignBuddy"); - MarkNativeAsOptional("SM_SearchBuddy"); - MarkNativeAsOptional("SM_LockBuddy"); - MarkNativeAsOptional("SM_IsBuddyLocked"); - MarkNativeAsOptional("SM_ClearBuddy"); - MarkNativeAsOptional("SM_IsValidAdmin"); - MarkNativeAsOptional("SM_IsValidTeam"); -} -#endif - -/********************************************************************** - * When a player has to moved - * - * @param plugin Plugin that initiated the move - * @param client The client index of the player that was moved - * @param team The team index the player was moved to - * @noreturn - **********************************************************************/ -forward SM_OnPlayerMoved(Handle:plugin, client, team); - -/********************************************************************** - * Move a player to the supplied team - * - * @param client The client index of the player to be moved - * @param team The team to move the player to - * @noreturn - * @error Invalid client or team index - **********************************************************************/ -native SM_MovePlayer(client, team); - -/********************************************************************** - * Move a player to the supplied team - * - * @param client The client index of the player to set - * @param team The team to move the to set - * @param override Whether or not to override another plugin - * @return True if successful, false if not - * @error Invalid client or team index - **********************************************************************/ -native SM_SetForcedTeam(client, team, bool:override = false); - -/********************************************************************** - * Gets the client's forced team index - * - * @param client The client index of the player to check - * @param plugin Optional: The plugin handle of the plugin - that set the team - * @return The team index of the forced team - Zero if no forced team - * @error Invalid client index - **********************************************************************/ -native SM_GetForcedTeam(client, &Handle:plugin = INVALID_HANDLE); - -/********************************************************************** - * Clears a client's forced team - * - * @param client The client index of the player to check - * @return True if successful, false if not - * @error Invalid client index - **********************************************************************/ -native SM_ClearForcedTeam(client); - -/********************************************************************** - * Gets a forced player on the wrong that is currently on the wrong team - * This will only return a player if the calling plugin assigned the team - * - * @param team The team index the player should be on - * @return The client index of the player - Zero if no player found - * @error Invalid client index - **********************************************************************/ -native SM_GetForcedPlayer(team); - -/********************************************************************** - * Assign a players buddy - * - * @param client The client index of the player to assign - * @param player The player index of the player to assign - * @param override Whether or not to override a player lock - * @return True if successful, false if not - * @error Invalid client or player index - **********************************************************************/ -native bool:SM_AssignBuddy(client, player, bool:override = false); - -/********************************************************************** - * Rturns the client's buddy - * - * @param client The client index of the player to assign - * @return The client index of the player's buddy - Zero if no buddy - * @error Invalid client index - **********************************************************************/ -native SM_GetClientBuddy(client); - -/********************************************************************** - * Set the buddy lock setting for a client - * - * @param client The client index of the player to assign - * @param setting Setting to set, True or False - * @return True if successful, false if not - * @error Invalid client index - **********************************************************************/ -native bool:SM_LockBuddy(client, bool:setting); - -/********************************************************************** - * Returns the buddy lock setting for a client - * - * @param client The client index of the player to assign - * @return True if locked, false if not - * @error Invalid client index - **********************************************************************/ -native bool:SM_IsBuddyLocked(client); - -/********************************************************************** - * Clear a players buddy - * - * @param client The client index of the player to clear - * @param override Whether or not to override a player lock - * @return True if successful, false if not - * @error Invalid client index - **********************************************************************/ -native bool:SM_ClearBuddy(client, bool:override = false); - -/********************************************************************** - * Determine if the player has the supplied flags - * ADMFLAG_ROOT will always return true - * - * @param client The client index of the player to assign - * @param flags The char flag(s) to check against - * @return True if valid, false if not - **********************************************************************/ -native bool:SM_IsValidAdmin(client, const String:flags[]); - - -/********************************************************************** - * Determine if the team is a valid team - * - * @param team The team index to determine if valid for - currently installed/supported mod - * @return True if valid, false if not - **********************************************************************/ -native bool:SM_IsValidTeam(team); - - -public e_SupportedMods:GetCurrentMod() -{ - new String:sGameType[64]; - GetGameFolderName(sGameType, sizeof(sGameType)); - - if (StrEqual(sGameType, "aoc", false)) - { - return GameType_AOC; - } - if (StrEqual(sGameType, "cstrike", false)) - { - return GameType_CSS; - } - if (StrEqual(sGameType, "dod", false)) - { - return GameType_DOD; - } - if (StrEqual(sGameType, "ff", false)) - { - return GameType_FF; - } - if (StrEqual(sGameType, "hidden", false)) - { - return GameType_HIDDEN; - } - if (StrEqual(sGameType, "hl2mp", false)) - { - return GameType_FF; - } - if (StrEqual(sGameType, "insurgency", false) || StrEqual(sGameType, "ins", false)) - { - return GameType_INS; - } - if (StrEqual(sGameType, "l4d", false)) - { - return GameType_L4D; - } - if (StrEqual(sGameType, "nts", false)) - { - return GameType_NEO; - } - if (StrEqual(sGameType, "sgtls", false)) - { - return GameType_SGTLS; - } - if (StrEqual(sGameType, "tf", false)) - { - return GameType_TF; - } - if (StrEqual(sGameType, "zps", false)) - { - return GameType_ZPS; - } - return GameType_Unknown; -} - -public LoadCurrentTeams() -{ - switch (g_CurrentMod) - { - case GameType_INS: - { - g_aCurrentTeams[Unknown] = 0; - g_aCurrentTeams[Spectator] = 3; - g_aCurrentTeams[Team1] = 1; - g_aCurrentTeams[Team2] = 2; - } - case default: - { - g_aCurrentTeams[Unknown] = 0; - g_aCurrentTeams[Spectator] = 1; - g_aCurrentTeams[Team1] = 2; - g_aCurrentTeams[Team2] = 3; - } - } -} diff --git a/Simple AutoScrambler/addons/sourcemod/scripting/simple-alltalkmanager.sp b/Simple AutoScrambler/addons/sourcemod/scripting/simple-alltalkmanager.sp deleted file mode 100644 index c848332..0000000 --- a/Simple AutoScrambler/addons/sourcemod/scripting/simple-alltalkmanager.sp +++ /dev/null @@ -1,515 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple AllTalk Manager -Description: - Allows you to set alltalk at different times -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#pragma semicolon 1 -#include -#include - -#define PLUGIN_VERSION "1.4.$Rev$" - -new Handle:satm_enabled = INVALID_HANDLE; -new Handle:satm_threshold_enabled = INVALID_HANDLE; -new Handle:satm_player_threshold = INVALID_HANDLE; -new Handle:satm_threshold_setting = INVALID_HANDLE; -new Handle:satm_logactivity = INVALID_HANDLE; -new Handle:satm_alltalk = INVALID_HANDLE; - -new Handle:g_aEventNames = INVALID_HANDLE; -new Handle:g_aEventReasons = INVALID_HANDLE; -new Handle:g_aEventSettings = INVALID_HANDLE; - -new bool:g_bLastThreshold = false; -new bool:g_bEnabled = true; -new bool:g_bThresholdEnabled = true; -new bool:g_bIsSetupMap = false; -new bool:g_bIsGameTF2 = false; -new bool:g_bLogActivity = false; - -new g_iLastEventIndex; - -public Plugin:myinfo = -{ - name = "Simple AllTalk Manager", - author = "Simple Plugins", - description = "Allows you to set alltalk at different times", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -} - -/** -Sourcemod callbacks -*/ -public OnPluginStart() -{ - - /** - Need to create all of our console variables. - */ - CreateConVar("satm_version", PLUGIN_VERSION, "Simple AllTalk Manager", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - satm_enabled = CreateConVar("satm_enabled", "1", "Enables/Disables Simple AllTalk Manager", _, true, 0.0, true, 1.0); - satm_threshold_enabled = CreateConVar("satm_threshold_enabled", "1", "Enables/Disables player threshold", _, true, 0.0, true, 1.0); - satm_player_threshold = CreateConVar("satm_player_threshold", "8", "Amount of players for the threshold"); - satm_threshold_setting = CreateConVar("satm_threshold_setting", "1", "Enables/Disables all talk up to player threshold, with the opposite set after the threshold", _, true, 0.0, true, 1.0); - satm_logactivity = CreateConVar("satm_logactivity", "0", "Enables/Disables log activity", _, true, 0.0, true, 1.0); - satm_alltalk = FindConVar("sv_alltalk"); - - /** - Hook console variables - */ - HookConVarChange(satm_enabled, ConVarSettingsChanged); - HookConVarChange(satm_threshold_enabled, ConVarSettingsChanged); - HookConVarChange(satm_player_threshold, ConVarSettingsChanged); - HookConVarChange(satm_logactivity, ConVarSettingsChanged); - - /** - Remove the notify flag from all talk cvar since we do it - */ - SetConVarFlags(satm_alltalk, GetConVarFlags(satm_alltalk)~FCVAR_NOTIFY); - - /** - Get the game type. We only care if it's TF2 - */ - new String:sGameType[64]; - GetGameFolderName(sGameType, sizeof(sGameType)); - if (StrEqual(sGameType, "tf", false)) - { - g_bIsGameTF2 = true; - } - - /** - Create the arrays - */ - g_aEventNames = CreateArray(255, 1); - g_aEventReasons = CreateArray(255, 1); - g_aEventSettings = CreateArray(1, 1); - - /** - Need to register the commands we are going to create and use. - */ - RegAdminCmd("sm_reloadatconfig", Command_Reload, ADMFLAG_GENERIC, "Reloads settings from config file"); - - /** - Create the config file - */ - AutoExecConfig(true); - - /** - Load the events from the config - */ - LoadEventsFromConfig(); -} - -public OnConfigsExecuted() -{ - - /** - Load up the settings - */ - g_bEnabled = GetConVarBool(satm_enabled); - g_bLogActivity = GetConVarBool(satm_logactivity); - g_bThresholdEnabled = GetConVarBool(satm_threshold_enabled); -} - -public OnMapStart() -{ - - /** - Reset the globals - */ - g_iLastEventIndex = 0; - g_bLastThreshold = false; - - /** - Check the map type if we are in TF2 - */ - if (g_bIsGameTF2) - { - g_bIsSetupMap = IsSetupPeriodMap(); - } - - /** - Set AllTalk - */ - if (g_bEnabled) - { - SetConVarBool(satm_alltalk, true); - } -} - -public OnClientDisconnect_Post(client) -{ - if (g_bEnabled) - { - SetAllTalk(-1); - } -} - -public OnClientPostAdminCheck(client) -{ - if (g_bEnabled) - { - SetAllTalk(-1); - } - CreateTimer(2.0, Timer_ShowAllTalkStatus, client, TIMER_FLAG_NO_MAPCHANGE); -} - -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (convar == satm_enabled) - { - if (StringToInt(newValue)) - { - g_bEnabled = true; - } - else - { - g_bEnabled = false; - } - } - else if (convar == satm_threshold_enabled) - { - if (StringToInt(newValue)) - { - g_bThresholdEnabled = true; - } - else - { - g_bThresholdEnabled = false; - } - } - else if (convar == satm_logactivity) - { - if (StringToInt(newValue)) - { - g_bLogActivity = true; - } - else - { - g_bLogActivity = false; - } - } - if (g_bEnabled) - { - SetAllTalk(-1); - } -} - -/** -Commands -*/ -public Action:Command_Reload(client, args) -{ - - /** - Clear the array - */ - ClearArray(g_aEventNames); - ClearArray(g_aEventReasons); - ClearArray(g_aEventSettings); - - /** - Load the events from the config - */ - LoadEventsFromConfig(); - - return Plugin_Handled; -} - -/** -Game Event Hooks -*/ -public Hook_All_Events(Handle:event, const String:name[], bool:dontBroadcast) -{ - if (!g_bIsSetupMap) - { - if (StrEqual(name, "teamplay_round_start")) - { - if (FindStringInArray(g_aEventNames, "teamplay_setup_finished") != -1) - { - g_iLastEventIndex = FindStringInArray(g_aEventNames, "teamplay_setup_finished"); - if (g_bEnabled) - { - SetAllTalk(g_iLastEventIndex); - return; - } - } - } - } - g_iLastEventIndex = FindStringInArray(g_aEventNames, name); - if (g_bEnabled) - { - SetAllTalk(g_iLastEventIndex); - } -} - -/** -Timers -*/ -public Action:Timer_ShowAllTalkStatus(Handle:timer, any:client) -{ - if (IsClientConnected(client) && IsClientInGame(client)) - { - new bool:bSetting = GetConVarBool(satm_alltalk); - if (bSetting) - { - PrintToChat(client, "\x01\x04[SM] AllTalk is \x01[on]"); - } - else - { - PrintToChat(client, "\x01\x04[SM] AllTalk is \x01[off]"); - } - } -} - -/** -Stock Functions -*/ -stock LoadEventsFromConfig() -{ - - /** - Make sure the config file is here and load it up - */ - new String:sConfigFile[256]; - BuildPath(Path_SM, sConfigFile, sizeof(sConfigFile), "configs/simple-alltalkmanager_events.cfg"); - if (!FileExists(sConfigFile)) - { - - /** - Config file doesn't exists, stop the plugin - */ - LogError("[SATM] Simple AllTalk Manager is not running! Could not find file %s", sConfigFile); - SetFailState("Could not find file %s", sConfigFile); - } - - /** - Create the arrays and variables - */ - new String:sGameEventName[256]; - new String:sReason[256]; - new iSetting; - - /** - Load config file as a KeyValues file - */ - new Handle:kvGameEvents = CreateKeyValues("game_events"); - FileToKeyValues(kvGameEvents, sConfigFile); - - if (!KvGotoFirstSubKey(kvGameEvents)) - { - return; - } - - /** - Hook the game events and load the settings - */ - do - { - - /** - Get the section name; this should be the event name - */ - KvGetSectionName(kvGameEvents, sGameEventName, sizeof(sGameEventName)); - if (!HookEventEx(sGameEventName, Hook_All_Events, EventHookMode_PostNoCopy)) - { - - /** - Could not hook this event, stop the plugin - */ - SetFailState("Could not hook event %s", sGameEventName); - } - else - { - if (g_bLogActivity) - { - LogMessage("[SATM] Hooked event: %s", sGameEventName); - } - } - - /** - Get the reason string and setting - */ - KvGetString(kvGameEvents, "reason", sReason, sizeof(sReason)); - iSetting = KvGetNum(kvGameEvents, "setting"); - if (g_bLogActivity) - { - LogMessage("[SATM] Event reason string: %s", sReason); - LogMessage("[SATM] Event setting: %i", iSetting); - } - - /** - Push the values to the arrays - */ - PushArrayString(g_aEventNames, sGameEventName); - PushArrayString(g_aEventReasons, sReason); - PushArrayCell(g_aEventSettings, iSetting); - } while (KvGotoNextKey(kvGameEvents)); - - /** - Close our handle - */ - CloseHandle(kvGameEvents); -} - -stock SetAllTalk(index) -{ - new iPlayerThreshold = GetConVarInt(satm_player_threshold); - new bool:bThresholdMet = ((GetClientCount() >= iPlayerThreshold) ? true : false); - new bool:bSetting; - - if (g_bThresholdEnabled) - { - if (bThresholdMet) - { - if (index == -1) - { - if (bThresholdMet != g_bLastThreshold) - { - g_bLastThreshold = true; - bSetting = !GetConVarBool(satm_threshold_setting); - new bool:bLastSetting = GetArrayCell(g_aEventSettings, g_iLastEventIndex); - if (bLastSetting && !bSetting) - { - bSetting = GetArrayCell(g_aEventSettings, g_iLastEventIndex); - } - } - else - { - bSetting = GetArrayCell(g_aEventSettings, g_iLastEventIndex); - } - } - else - { - bSetting = GetArrayCell(g_aEventSettings, index); - } - } - else - { - g_bLastThreshold = false; - bSetting = GetConVarBool(satm_threshold_setting); - } - } - else - { - if (index != -1) - { - bSetting = GetArrayCell(g_aEventSettings, index); - } - } - - if (GetConVarBool(satm_alltalk) != bSetting) - { - - SetConVarBool(satm_alltalk, bSetting); - - new String:sReason[256]; - if (index == -1) - { - Format(sReason, sizeof(sReason), "Player Threshold"); - } - else - { - if (!g_bIsSetupMap) - { - new String:sCurrentEvent[256]; - GetArrayString(g_aEventNames, index, sCurrentEvent, sizeof(sCurrentEvent)); - if (StrEqual(sCurrentEvent, "teamplay_setup_finished")) - { - new iRoundStartIndex = FindStringInArray(g_aEventNames, "teamplay_round_start"); - if (iRoundStartIndex != -1) - { - GetArrayString(g_aEventReasons, iRoundStartIndex, sReason, sizeof(sReason)); - } - else - { - GetArrayString(g_aEventReasons, index, sReason, sizeof(sReason)); - } - } - else - { - GetArrayString(g_aEventReasons, index, sReason, sizeof(sReason)); - } - } - else - { - GetArrayString(g_aEventReasons, index, sReason, sizeof(sReason)); - } - } - - if (bSetting) - { - PrintToChatAll("\x01\x04[SM] AllTalk turned \x01[on] \x04due to:\x01 %s", sReason); - } - else - { - PrintToChatAll("\x01\x04[SM] AllTalk turned \x01[off] \x04due to:\x01 %s", sReason); - } - } -} - -stock bool:IsSetupPeriodMap() -{ - new iEnt = -1; - new String:sMapName[32]; - - GetCurrentMap(sMapName, sizeof(sMapName)); - - if (strncmp(sMapName, "cp_", 3, false) == 0) - { - new iTeam; - while ((iEnt = FindEntityByClassname(iEnt, "team_control_point")) != -1) - { - iTeam = GetEntProp(iEnt, Prop_Send, "m_iTeamNum"); - - /** - If there is a blu CP or a neutral CP, then it's not an attack/defend map - */ - if (iTeam != 2) - { - //this is a push map - return false; - } - } - //this is a attack/defend map - return true; - } - else if (strncmp(sMapName, "ctf_", 3, false) == 0) - { - //this is a ctf map - return false; - } - return false; -} diff --git a/Simple AutoScrambler/addons/sourcemod/scripting/simple-chatcolors.sp b/Simple AutoScrambler/addons/sourcemod/scripting/simple-chatcolors.sp deleted file mode 100644 index 539d057..0000000 --- a/Simple AutoScrambler/addons/sourcemod/scripting/simple-chatcolors.sp +++ /dev/null @@ -1,496 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Chat Colors -Description: - Changes the colors of players chat based on config file -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#pragma semicolon 1 -#include -#include - -#define PLUGIN_VERSION "0.9.0.$Rev$" - -#define CHAT_SYMBOL '@' -#define TRIGGER_SYMBOL1 '!' -#define TRIGGER_SYMBOL2 '/' -#define CHAT_MAX_MESSAGE_LENGTH 1024 - -new Handle:g_hDebugCvar = INVALID_HANDLE; -new Handle:g_aGroupNames = INVALID_HANDLE; -new Handle:g_aGroupFlag = INVALID_HANDLE; -new Handle:g_aGroupNameColor = INVALID_HANDLE; -new Handle:g_aGroupTextColor = INVALID_HANDLE; - -new bool:g_bDebug = false; - -new g_iArraySize; - -new g_aPlayerColorIndex[MAXPLAYERS + 1] = { -1, ... }; - -public Plugin:myinfo = -{ - name = "Simple Chat Colors", - author = "Simple Plugins", - description = "Changes the colors of players chat based on config file.", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -}; - -/** -Sourcemod callbacks -*/ -public OnPluginStart() -{ - - /** - Need to create all of our console variables. - */ - CreateConVar("sm_chatcolors_version", PLUGIN_VERSION, "Simple Chat Colors", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - g_hDebugCvar = CreateConVar("sm_chatcolors_debug", "1", "Enable/Disable debugging information"); - - /** - Hook console variables - */ - HookConVarChange(g_hDebugCvar, ConVarSettingsChanged); - - /** - Need to register the commands we are going to use - */ - RegConsoleCmd("say", Command_Say); - RegConsoleCmd("say_team", Command_SayTeam); - RegAdminCmd("sm_reloadcolorsconfig", Command_Reload, ADMFLAG_GENERIC, "Reloads settings from config file"); - - /** - Create the arrays - */ - g_aGroupNames = CreateArray(256, 1); - g_aGroupFlag = CreateArray(15, 1); - g_aGroupNameColor = CreateArray(15, 1); - g_aGroupTextColor = CreateArray(15, 1); - - /** - Load the admins and colors from the config - */ - LoadAdminsAndColorsFromConfig(); - g_iArraySize = GetArraySize(g_aGroupNames); -} - -public OnConfigsExecuted() -{ - g_bDebug = GetConVarBool(g_hDebugCvar); - ReloadConfigFile(); -} - -public OnClientPostAdminCheck(client) -{ - - /** - Check the client to see if they are a admin - */ - CheckAdmin(client); -} - -public OnClientDisconnect(client) -{ - g_aPlayerColorIndex[client] = -1; -} - -/** -Commands -*/ -public Action:Command_Say(client, args) -{ - - /** - Make sure we are enabled. - */ - if (client == 0 || IsChatTrigger()) - { - return Plugin_Continue; - } - - if (g_aPlayerColorIndex[client] != -1) - { - - /** - The client is, so get the chat message and strip it down. - */ - decl String:sArg[CHAT_MAX_MESSAGE_LENGTH], - String:sChatMsg[CHAT_MAX_MESSAGE_LENGTH]; - - new bool:bAlive = IsPlayerAlive(client); - - GetCmdArgString(sArg, sizeof(sArg)); - StripQuotes(sArg); - TrimString(sArg); - new startidx; - if (sArg[strlen(sArg)-1] == '"') - { - sArg[strlen(sArg)-1] = '\0'; - startidx = 1; - } - - /** - Bug out if they are using the admin chat symbol (admin chat). If we are in CSS it may not find all the triggers, so we double check. - */ - if (sArg[startidx] == CHAT_SYMBOL || sArg[startidx] == TRIGGER_SYMBOL1 || sArg[startidx] == TRIGGER_SYMBOL2) - { - return Plugin_Continue; - } - - /** - Log the message for hlstatsx and other things. - */ - new iUserID = GetClientUserId(client); - decl String:sAuthID[64]; - GetClientAuthString(client, sAuthID, sizeof(sAuthID)); - LogToGame("\"%N<%i><%s><>\" say \"%s\"", client, iUserID, sAuthID, sArg); - - /** - Format the message. - */ - FormatMessage(client, 0, bAlive, sChatMsg, sArg, g_aPlayerColorIndex[client]); - - /** - Send the message. - */ - //SayText2(0, client, sChatMsg); - CPrintToChatAll(sChatMsg); - - /** - We are done, bug out, and stop the original chat message. - */ - return Plugin_Stop; - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -public Action:Command_SayTeam(client, args) -{ - - /** - Make sure we are enabled. - */ - if (client == 0 || IsChatTrigger()) - { - return Plugin_Continue; - } - - /** - Check the client to see if they are a admin - */ - if (g_aPlayerColorIndex[client] != -1) - { - - /** - The client is, so get the chat message and strip it down. - */ - decl String:sArg[CHAT_MAX_MESSAGE_LENGTH], - String:sChatMsg[CHAT_MAX_MESSAGE_LENGTH]; - - new bool:bAlive = IsPlayerAlive(client); - new iCurrentTeam = GetClientTeam(client); - - GetCmdArgString(sArg, sizeof(sArg)); - StripQuotes(sArg); - TrimString(sArg); - new startidx; - if (sArg[strlen(sArg)-1] == '"') - { - sArg[strlen(sArg)-1] = '\0'; - startidx = 1; - } - - /** - Bug out if they are using the admin chat symbol (admin chat). - */ - if (sArg[startidx] == CHAT_SYMBOL || sArg[startidx] == TRIGGER_SYMBOL1 || sArg[startidx] == TRIGGER_SYMBOL2) - { - return Plugin_Continue; - } - - /** - Log the message for hlstatsx and other things. - */ - new iUserID = GetClientUserId(client); - decl String:sAuthID[64]; - GetClientAuthString(client, sAuthID, sizeof(sAuthID)); - LogToGame("\"%N<%i><%s><>\" say_team \"%s\"", client, iUserID, sAuthID, sArg); - - /** - Format the message. - */ - FormatMessage(client, iCurrentTeam, bAlive, sChatMsg, sArg, g_aPlayerColorIndex[client]); - - /** - Send the message to the same team - */ - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientConnected(i) && IsClientInGame(i) && GetClientTeam(i) == iCurrentTeam) - { - CPrintToChat(client, sChatMsg); - } - } - - /** - We are done, bug out, and stop the original chat message. - */ - return Plugin_Stop; - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -public Action:Command_Reload(client, args) -{ - ReloadConfigFile(); - return Plugin_Handled; -} - -/** -Stock Functions -*/ -stock LoadAdminsAndColorsFromConfig() -{ - - /** - Make sure the config file is here and load it up - */ - new String:sConfigFile[256]; - BuildPath(Path_SM, sConfigFile, sizeof(sConfigFile), "configs/simple-chatcolors.cfg"); - if (!FileExists(sConfigFile)) - { - - /** - Config file doesn't exists, stop the plugin - */ - LogError("[SCC] Simple Chat Colors is not running! Could not find file %s", sConfigFile); - SetFailState("Could not find file %s", sConfigFile); - } - - /** - Create the arrays and variables - */ - new String:sGroupName[256]; - new String:sGroupFlag[15]; - new String:sGroupNameColor[15]; - new String:sGroupTextColor[15]; - - - /** - Load config file as a KeyValues file - */ - new Handle:kvChatColors = CreateKeyValues("admin_colors"); - FileToKeyValues(kvChatColors, sConfigFile); - - if (!KvGotoFirstSubKey(kvChatColors)) - { - return; - } - - /** - Load up all the groups in the file - */ - do - { - - /** - Get the section name; should be the "group" name - */ - KvGetSectionName(kvChatColors, sGroupName, sizeof(sGroupName)); - - - /** - Get the flags and colors - */ - KvGetString(kvChatColors, "flag", sGroupFlag, sizeof(sGroupFlag)); - KvGetString(kvChatColors, "namecolor", sGroupNameColor, sizeof(sGroupNameColor)); - KvGetString(kvChatColors, "textcolor", sGroupTextColor, sizeof(sGroupTextColor)); - - if (g_bDebug) - { - LogMessage("Group Name/SteamID: %s", sGroupName); - LogMessage("Flag String: %s", sGroupFlag); - LogMessage("Color on name: %s", sGroupNameColor); - LogMessage("Color of text: %s", sGroupTextColor); - } - - /** - Push the values to the arrays - */ - PushArrayString(g_aGroupNames, sGroupName); - PushArrayString(g_aGroupFlag, sGroupFlag); - PushArrayString(g_aGroupNameColor, sGroupNameColor); - PushArrayString(g_aGroupTextColor, sGroupTextColor); - } while (KvGotoNextKey(kvChatColors)); - - /** - Close our handle - */ - CloseHandle(kvChatColors); -} - -stock ReloadConfigFile() -{ - - /** - Clear the array - */ - ClearArray(g_aGroupNames); - ClearArray(g_aGroupFlag); - ClearArray(g_aGroupNameColor); - ClearArray(g_aGroupTextColor); - - /** - Load the admins, groups, and colors from the config - */ - LoadAdminsAndColorsFromConfig(); - g_iArraySize = GetArraySize(g_aGroupNames); - - /** - Recheck all the online players for assigned colors - */ - for (new index = 1; index <= MaxClients; index++) - { - if (IsClientConnected(index) && IsClientInGame(index)) - { - CheckAdmin(index); - } - } -} - -stock CheckAdmin(client) -{ - new String:sFlags[15]; - new String:sClientSteamID[64]; - new iGroupFlags; - new iFlags; - new iIndex = -1; - - /** - Look for a steamid first - */ - GetClientAuthString(client, sClientSteamID, sizeof(sClientSteamID)); - iIndex = FindStringInArray(g_aGroupNames, sClientSteamID); - if (iIndex != -1) - { - g_aPlayerColorIndex[client] = iIndex; - } - - /** - Didn't find one, check flags - */ - else - { - /** - Search for flag in groups - */ - - iFlags = GetUserFlagBits(client); - for (iIndex = 0; iIndex < g_iArraySize; iIndex++) - { - GetArrayString(g_aGroupFlag, iIndex, sFlags, sizeof(sFlags)); - iGroupFlags = ReadFlagString(sFlags); - if (iFlags & iGroupFlags) - { - g_aPlayerColorIndex[client] = iIndex; - break; - } - } - } - - if (g_bDebug) - { - PrintToChatAll("SteamID: %s", sClientSteamID); - PrintToChatAll("Array Index: %i", iIndex); - PrintToChatAll("Flag String: %s", sFlags); - PrintToChatAll("Flag Bits of Client: %i", iFlags); - PrintToChatAll("Flag Bits of Group: %i", iGroupFlags); - } -} - -stock FormatMessage(iClient, iTeam, bool:bAlive, String:sChatMsg[], const Sting:sMessage[], iArrayIndex) -{ - decl String:sDead[10], - String:sTeam[10], - String:sClientName[64]; - - GetClientName(iClient, sClientName, sizeof(sClientName)); - - if (iTeam != 0) - { - Format(sTeam, sizeof(sTeam), "(TEAM) "); - } - else - { - Format(sTeam, sizeof(sTeam), ""); - } - if (bAlive) - { - Format(sDead, sizeof(sDead), ""); - } - else - { - Format(sDead, sizeof(sDead), "*DEAD* "); - } - - new String:sNameColor[15]; - new String:sTextColor[15]; - GetArrayString(g_aGroupNameColor, iArrayIndex, sNameColor, sizeof(sNameColor)); - GetArrayString(g_aGroupTextColor, iArrayIndex, sTextColor, sizeof(sTextColor)); - - Format(sChatMsg, CHAT_MAX_MESSAGE_LENGTH, "{default}%s%s%s%s {default}: %s%s", sDead, sTeam, sNameColor, sClientName, sTextColor, sMessage); -} - -/** -Adjust the settings if a convar was changed -*/ -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (StringToInt(newValue) == 1) - { - g_bDebug = true; - } - else - { - g_bDebug = false; - } -} \ No newline at end of file diff --git a/Simple AutoScrambler/addons/sourcemod/scripting/simple-donatorbenefits.sp b/Simple AutoScrambler/addons/sourcemod/scripting/simple-donatorbenefits.sp deleted file mode 100644 index e3f6845..0000000 --- a/Simple AutoScrambler/addons/sourcemod/scripting/simple-donatorbenefits.sp +++ /dev/null @@ -1,1312 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Donator Benefits -Description: - Provides donator benefits to players -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include -#include - -#define PLUGIN_VERSION "1.1.$Rev$" - -#define CHAT_SYMBOL '@' -#define CHAT_MAX_MESSAGE_LENGTH 1024 - -enum PlayerData -{ - bool:bIsDonator, - bool:bQueue, - bool:bImmune, - iHealthCount, - iNewTeam -}; - -/** - Public convar handles - */ -new Handle:sdb_enabled = INVALID_HANDLE; -new Handle:sdb_donationflag = INVALID_HANDLE; -new Handle:sdb_soundfile = INVALID_HANDLE; -new Handle:sdb_joinsound_enabled = INVALID_HANDLE; -new Handle:sdb_joinpubmsg_enabled = INVALID_HANDLE; -new Handle:sdb_joinprivmsg_enabled = INVALID_HANDLE; -new Handle:sdb_chatcolors_enabled = INVALID_HANDLE; -new Handle:sdb_immunity_enabled = INVALID_HANDLE; -new Handle:sdb_ubercharge_enabled = INVALID_HANDLE; -new Handle:sdb_givehealth_enabled = INVALID_HANDLE; -new Handle:sdb_nofalldmg_enabled = INVALID_HANDLE; -new Handle:sdb_fastheavy_enabled = INVALID_HANDLE; -new Handle:sdb_swapteam_enabled = INVALID_HANDLE; -new Handle:sdb_chatcolor = INVALID_HANDLE; -new Handle:sdb_uberlevel = INVALID_HANDLE; -new Handle:sdb_healthcount = INVALID_HANDLE; -new Handle:sdb_healthbonus = INVALID_HANDLE; -new Handle:sdb_heavymultiplier = INVALID_HANDLE; - -/** -Create global enable/disable bools so we don't have to check the console variable on every call -*/ -new bool:g_bIsEnabled = true; -new bool:g_bIsJoinSoundEnabled = true; -new bool:g_bIsJoinPubMsgEnabled = true; -new bool:g_bIsJoinPrivMsgEnabled = true; -new bool:g_bIsChatColorsEnabled = true; -new bool:g_bIsImmuntyEnabled = true; -new bool:g_bIsUberChargeEnabled = true; -new bool:g_bIsGiveHealthEnabled = true; -new bool:g_bIsNoFallDmgEnabled = true; -new bool:g_bIsFastHeayEnabled = true; -new bool:g_bIsSwapTeamEnabled = true; - -/** - Player arrays - */ -new g_aPlayers[MAXPLAYERS + 1][PlayerData]; - - -/** -Rest of the globals -*/ -new bool:g_bRoundEnd = false; -new String:g_sCharDonatorFlag[5]; -new String:g_sSoundFile[PLATFORM_MAX_PATH]; -new String:g_sChatColor[11]; -new g_iHealthBonus; -new g_iHealthCount; -new g_iClassMaxHealth[TFClassType] = {0, 125, 125, 200, 175, 150, 300, 175, 125, 125}; -new g_fClassMaxSpeed[TFClassType] = {0, 400, 300, 240, 280, 320, 230, 300, 300, 300}; -new Float:g_fHeavyMultiplier = 0.0; -new Float:g_fUberLevel = 0.0; - -public Plugin:myinfo = -{ - name = "Simple Donation Benefits", - author = "Simple Plugins", - description = "Gives donators benefits to players", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -} - -public OnPluginStart() -{ - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook the game events - */ - LogAction(0, -1, "[SDB] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_connect", HookPlayerSpawn, EventHookMode_Pre); - HookEvent("player_spawn", HookPlayerSpawn, EventHookMode_Post); - HookEvent("player_death", HookPlayerDeath, EventHookMode_Post); - HookEvent("player_team", HookPlayerChangeTeam, EventHookMode_Post); - switch (g_CurrentMod) - { - case GameType_TF: - { - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - HookEvent("player_changeclass", HookPlayerClass, EventHookMode_Post); - } - case GameType_DOD: - { - HookEvent("dod_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_Post); - } - default: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - } - } - - /** - Create console variables - */ - CreateConVar("sdb_version", PLUGIN_VERSION, "Simple Donation Benefits", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - sdb_enabled = CreateConVar("sdb_enabled", "1", "Enable/Disable Simple Donation Benefits"); - sdb_donationflag = CreateConVar("sdb_donationflag", "a", "Flag ALREADY given to donators. Must be in char format"); - - /** - Create the enable/disable donator console variables - */ - sdb_joinsound_enabled = CreateConVar("sdb_joinsound_enabled", "1", "Enable/Disable donator join sound"); - sdb_joinpubmsg_enabled = CreateConVar("sdb_joinpubmsg_enabled", "1", "Enable/Disable public donator join message (replaces: as connected)"); - sdb_joinprivmsg_enabled = CreateConVar("sdb_joinprivmsg_enabled", "1", "Enable/Disable private donator join message (sent only to donator)"); - sdb_chatcolors_enabled = CreateConVar("sdb_chatcolors_enabled", "1", "Enable/Disable donator chat colors"); - sdb_immunity_enabled = CreateConVar("sdb_immunity_enabled", "1", "Enable/Disable donator round end immunity"); - sdb_ubercharge_enabled = CreateConVar("sdb_ubercharge_enabled", "1", "Enable/Disable donator medics starting with ubercharge"); - sdb_givehealth_enabled = CreateConVar("sdb_givehealth_enabled", "1", "Enable/Disable donator instant health bonus"); - sdb_nofalldmg_enabled = CreateConVar("sdb_nofalldmg_enabled", "1", "Enable/Disable no fall damage for donators"); - sdb_fastheavy_enabled = CreateConVar("sdb_fastheavy_enabled", "1", "Enable/Disable donator heavies moving faster while spinning"); - sdb_swapteam_enabled = CreateConVar("sdb_swampteam_enabled", "1", "Enable/Disable donator swap team ability"); - - /** - Create the donator setting console variables - */ - sdb_soundfile = CreateConVar("sdb_soundfile", "custom/donatorjoin.mp3", "The location of sound file"); - sdb_chatcolor = CreateConVar("sdb_chatcolor", "green", "Color to use for donator chat. Valid colors are green and lightgreen"); - sdb_uberlevel = CreateConVar("sdb_uberlevel", "0.5", "Uberlevel to give donator medic at spawn. 1.0 = full uber", _, true, 0.0, true, 1.0); - sdb_healthcount = CreateConVar("sdb_healthcount", "1", "Number of times a donator can use use instant health per life"); - sdb_healthbonus = CreateConVar("sdb_healthbonus", "100", "The amount of health to heal the donator"); - sdb_heavymultiplier = CreateConVar("sdb_heavyspeed", "0.5", "The speed multiplier for the fast heavy. Based on running speed. 1.0 = running speed. (Game Default is 0.20)", _, true, 0.0, true, 1.0); - - /** - Hook dukehacks calls - */ - dhAddClientHook(CHK_TakeDamage, Hacks_TakeDamageHook); - dhAddClientHook(CHK_PreThink, Hacks_PreThinkHook); - - /** - Hook the console variables if they change - */ - HookConVarChange(sdb_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_donationflag, ConVarSettingsChanged); - HookConVarChange(sdb_joinsound_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_joinpubmsg_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_joinprivmsg_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_chatcolors_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_immunity_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_ubercharge_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_givehealth_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_nofalldmg_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_swapteam_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_fastheavy_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_soundfile, ConVarSettingsChanged); - HookConVarChange(sdb_chatcolor, ConVarSettingsChanged); - HookConVarChange(sdb_uberlevel, ConVarSettingsChanged); - HookConVarChange(sdb_healthcount, ConVarSettingsChanged); - HookConVarChange(sdb_healthbonus, ConVarSettingsChanged); - HookConVarChange(sdb_heavymultiplier, ConVarSettingsChanged); - - /** - Register the commands - */ - RegConsoleCmd("sm_swapteams", Command_SwapTeam, "sm_swapteams <[0]instant/[1]queued>: Swaps your team to the other team"); - RegConsoleCmd("sm_ihealth", Command_InstantHealth, "sm_ihealth: Gives you a instant health pack"); - RegAdminCmd("sm_teaser", Command_Teaser, ADMFLAG_GENERIC,"sm_teaser <[0]add/[1]remove>: Gives temporary donator privilages to a player"); - RegConsoleCmd("say", Command_Say); - - RegConsoleCmd("sm_test", Command_TEST); - - /** - Load the translations - */ - LoadTranslations("common.phrases"); - LoadTranslations("simpledonatorbenefits.phrases"); - - /** - Load or create the config file - */ - AutoExecConfig(true, "plugin.simpledonatorbenefits"); - LogAction(0, -1, "[SDB] Simple Donator Benefits is loaded."); -} - -public OnAllPluginsLoaded() -{ - //something -} - -public OnLibraryRemoved(const String:name[]) -{ - //something -} - -public OnConfigsExecuted() -{ - /** - Load up all the variable defaults - */ - LoadUpVariables(); - - /** - If the join sound is enabled, prep the sound files - */ - if (g_bIsJoinSoundEnabled) - PrepSoundFile(); - - /** - Log our activity - */ - if (g_bIsEnabled) - LogAction(0, -1, "Simple Donation Benefits is ENABLED"); - else - LogAction(0, -1, "Simple Donation Benefits is DISABLED"); -} - -public OnClientPostAdminCheck(client) -{ - - /** - Check if the client is a donator - */ - if (SM_IsValidAdmin(client, g_sCharDonatorFlag)) - { - - /** - They are, so we set the player array to true and start a timer for the sound or add - */ - g_aPlayers[client][bIsDonator] = true; - if (g_bIsJoinSoundEnabled || g_bIsJoinPrivMsgEnabled) - { - CreateTimer(10.0, Timer_DonatorJoined, client, TIMER_FLAG_NO_MAPCHANGE); - } - } - else - { - /** - They aren't, so we set the player array to false - */ - g_aPlayers[client][bIsDonator] = false; - } -} - -public OnClientDisconnect_Post(client) -{ - - /** - Clean up the player variables - */ - CleanUpPlayer(client); -} - -public Action:Command_SwapTeam(client, args) -{ - - /** - Make sure we are enabled - */ - if (!g_bIsEnabled || !g_bIsSwapTeamEnabled) - { - return Plugin_Handled; - } - - /** - Make sure the command is not started by the server - */ - if (client == 0) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "PlayerLevelCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Make sure the player is a donator - */ - if (!g_aPlayers[client][bIsDonator]) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Lets make sure the client is one a team we can swap. - If he is we set the global array to the opposite team. - */ - new iTeam = GetClientTeam(client); - if (iTeam == g_aCurrentTeams[Team1]) - { - g_aPlayers[client][iNewTeam] = g_aCurrentTeams[Team2]; - } - else if (iTeam == g_aCurrentTeams[Team2]) - { - g_aPlayers[client][iNewTeam] = g_aCurrentTeams[Team1]; - } - else - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "InValidTeam", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check to see if we have command arguments. - */ - if (GetCmdArgs()) - { - - /** - We do, so lets get it and see if the client wants to be switched instantly or queued for death. - */ - decl String:sArg[5]; - GetCmdArg(1, sArg, sizeof(sArg)); - new iWantsQue = StringToInt(sArg); - if (iWantsQue && !g_aPlayers[client][bQueue]) - { - - /** - He wants the que and isn't already in it, set the global array. - */ - g_aPlayers[client][bQueue] = true; - ReplyToCommand(client, "\x01\x04[STM]\x01 %T", "PlayerQueue", LANG_SERVER); - } - else if (!iWantsQue) - { - - /** - He wants to be switched right now, lets call the stock function. - */ - SM_MovePlayer(client, g_aPlayers[client][iNewTeam]); - } - } - else - { - - /** - There are no command arguments so we build and display the swap menu. - */ - new Handle:hPlayerMenu = BuildSwapModeMenu(); - DisplayMenu(hPlayerMenu, client, MENU_TIME_FOREVER); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_InstantHealth(client, args) -{ - - /** - Make sure we are enabled - */ - if (!g_bIsEnabled || !g_bIsGiveHealthEnabled) - { - return Plugin_Handled; - } - - /** - Make sure the command is not started by the server - */ - if (client == 0) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "PlayerLevelCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Make sure the player is a donator - */ - if (!g_aPlayers[client][bIsDonator]) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check health count to see if the player has reached the max - */ - if (g_aPlayers[client][iHealthCount] >= g_iHealthCount) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "ReachedCount", LANG_SERVER); - return Plugin_Handled; - } - - /** - Get the class of the player and the max health for that class - */ - new iHealth = GetClientHealth(client); - new TFClassType:PlayerClass = TF2_GetPlayerClass(client); - new iMaxHealth = g_iClassMaxHealth[PlayerClass]; - - /** - Check to see if the player is at the max health of the class - */ - if (iHealth >= iMaxHealth) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "AtMaxHealth", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check the current health - */ - if (iHealth + g_iHealthBonus >= iMaxHealth) - { - - /** - Raise them to max health if the current health + bonus would go above it - */ - SetEntityHealth(client, iMaxHealth); - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "ToMaxHealth", LANG_SERVER); - } - else - { - - /** - Give them the instant health bonus - */ - SetEntityHealth(client, iHealth + g_iHealthBonus); - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "HealthBonus", LANG_SERVER); - } - - /** - Increase the count - */ - g_aPlayers[client][iHealthCount] += 1; - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_Teaser(client, args) -{ - - /** - Make sure we are enabled - */ - if (!g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - Check to see if we have command arguments. - */ - new iCmdArgs = GetCmdArgs(); - if (iCmdArgs == 0) - { - - /** - We don't so display the player menu. - */ - new Handle:hPlayerMenu = BuildPlayerMenu(); - DisplayMenu(hPlayerMenu, client, MENU_TIME_FOREVER); - return Plugin_Handled; - } - - /** - We have some arguments, see if we can find the player - */ - decl String:sPlayer[64]; - GetCmdArg(1, sPlayer, sizeof(sPlayer)); - new iTarget = FindTarget(client, sPlayer, true, true); - if (iTarget == -1 || !IsClientInGame(iTarget)) - { - - /** - We don't know who this is, so display the player menu. - */ - new Handle:hPlayerMenu = BuildPlayerMenu(); - DisplayMenu(hPlayerMenu, client, MENU_TIME_FOREVER); - } - else - { - /** - We found the player, see if we are supposed to turn it on or off. - */ - if (iCmdArgs >= 2) - { - decl String:sOn[3]; - GetCmdArg(2, sOn, sizeof(sOn)); - if (StringToInt(sOn)) - { - - /** - Turn temp benefits on. - */ - g_aPlayers[iTarget][bIsDonator] = true; - } - else - { - - /** - Turn temp benefits on. - */ - g_aPlayers[iTarget][bIsDonator] = false; - } - } - else - { - - /** - We don't know what to do, so just turn it on. - */ - g_aPlayers[iTarget][bIsDonator] = true; - } - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_Say(client, args) -{ - - /** - Make sure we are enabled. - */ - if (client == 0 || IsChatTrigger() || !g_bIsChatColorsEnabled || !g_bIsEnabled) - { - return Plugin_Continue; - } - - /** - Check the client to see if they are a donator. - */ - if (g_aPlayers[client][bIsDonator]) - { - - /** - The client is, so get the chat message and strip it down. - */ - decl String:sArg[CHAT_MAX_MESSAGE_LENGTH], - String:sChatMsg[CHAT_MAX_MESSAGE_LENGTH]; - new bool:bAlive = IsPlayerAlive(client); - GetCmdArgString(sArg, sizeof(sArg)); - StripQuotes(sArg); - TrimString(sArg); - new startidx; - if (sArg[strlen(sArg)-1] == '"') - { - sArg[strlen(sArg)-1] = '\0'; - startidx = 1; - } - - /** - Bug out if they are using the admin chat symbol (admin chat). - */ - if (sArg[startidx] == CHAT_SYMBOL) - { - return Plugin_Continue; - } - - /** - Format the message. - */ - FormatMessage(client, 0, bAlive, sChatMsg, sArg); - - /** - Send the message. - */ - SayText2(0, client, sChatMsg); - - /** - We are done, bug out, and stop the original chat message. - */ - return Plugin_Stop; - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -public Action:Hacks_TakeDamageHook(client, attacker, inflictor, Float:damage, &Float:multiplier, damagetype) -{ - - /** - Make sure we are enabled and the client is a donator. - */ - if (g_bIsEnabled && g_bIsNoFallDmgEnabled && g_aPlayers[client][bIsDonator]) - { - - /** - Check for fall damage. - */ - if (damagetype & DMG_FALL) - { - - /** - Cancel the fall damage and bug out. - */ - multiplier *= 0.0; - return Plugin_Changed; - } - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -public Action:Hacks_PreThinkHook(client) -{ - - /** - Make sure we are enabled and the client is a donator. - */ - if (!g_bIsEnabled || !g_bIsFastHeayEnabled || !g_aPlayers[client][bIsDonator]) - { - return Plugin_Continue; - } - - /** - Check the players class. We are looking for the heavy. - */ - new TFClassType:PlayerClass = TF2_GetPlayerClass(client); - if (PlayerClass == TFClass_Heavy) - { - - /** - We have a heavy, lets check the weapon. - */ - decl String:sWeaponCurrent[64]; - GetClientWeapon(client, sWeaponCurrent, sizeof(sWeaponCurrent)); - if (StrEqual(sWeaponCurrent, "tf_weapon_minigun", false)) - { - - /** - We have a minigun, check the heavies current weapon state to see if it's spinning. - */ - new iWeapon = GetPlayerWeaponSlot(client, 0); - new iWeaponState = GetEntProp(iWeapon, Prop_Send, "m_iWeaponState"); - if (iWeaponState > 0) - { - - /** - He is spinning, so lets change the heavies speed. - */ - new Float:fMaxSpeed = FloatMul(g_fHeavyMultiplier, float(g_fClassMaxSpeed[PlayerClass])); - SetEntPropFloat(client, Prop_Send, "m_flMaxspeed", fMaxSpeed); - } - } - } - - /** - We are done, bug out. - */ - // use Plugin_Continue (other options are ignored on PreThink hook) - return Plugin_Continue; -} - -public Action:HookPlayerConnect(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Make sure we are enabled. - */ - if (!g_bIsEnabled || !g_bIsJoinPubMsgEnabled || !dontBroadcast) - { - return Plugin_Continue; - } - - /** - Get our event variables and check the client. - */ - new iUserId = GetEventInt(event,"userid"); - new iClient = GetClientOfUserId(iUserId); - if (iClient != 0) - { - - /** - Get the info on the client and format the message. - */ - decl String:sClientName[255], - String:sAuthID[255], - String:sMsg[1024]; - - GetEventString(event, "name", sClientName, sizeof(sClientName)); - GetClientAuthString(iClient, sAuthID, sizeof(sAuthID)); - Format(sMsg, sizeof(sMsg), "%T", "PublicJoinMessage", LANG_SERVER, sClientName); - - /** - Print the message to the clients and do the normal functions. - */ - for (new i = 1; i <= MaxClients; i++) - { - if(IsClientConnected(i) && IsClientInGame(i)) - { - PrintToChat(i,"\x01\x05%s", sMsg); - PrintToConsole(i,"%s has connected.", sClientName); - } - } - LogToGame("\"%s<%d><%s><>\" entered the game", sClientName, iUserId, sAuthID); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public HookPlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled && g_bIsUberChargeEnabled) - { - - /** - Get the event variables and check the class for medic - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - if (TF2_GetPlayerClass(iClient) == TFClass_Medic) - { - - /** - Start a timer to get the medic the uber boost - */ - CreateTimer(0.25, Timer_PlayerUberDelay, iClient, TIMER_FLAG_NO_MAPCHANGE); - } - } -} - -public HookPlayerClass(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled && g_bIsUberChargeEnabled) - { - - /** - Get the event variables and check the class for medic - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - if (TF2_GetPlayerClass(iClient) == TFClass_Medic) - { - - /** - Start a timer to get the medic the uber boost - */ - CreateTimer(0.25, Timer_PlayerUberDelay, iClient, TIMER_FLAG_NO_MAPCHANGE); - } - } -} - -public HookPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled || g_bIsSwapTeamEnabled) - { - - /** - Get the event variables - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - new String:sWeapon[256]; - GetEventString(event, "weapon", sWeapon, sizeof(sWeapon)); - - /** - Bug out if world killed him. Means he changed team or something - */ - if (StrEqual(sWeapon, "world", false)) - { - g_aPlayers[iClient][bQueue] = false; - return; - } - - /** - If he is queued up, swap him - */ - if (g_aPlayers[iClient][bQueue]) - { - SM_MovePlayer(iClient, g_aPlayers[iClient][iNewTeam]); - } - } -} - -public HookPlayerChangeTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled || g_bIsSwapTeamEnabled) - { - - /** - Get the event variables - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - - /** - If he is queued up, clear the status - */ - if (g_aPlayers[iClient][bQueue]) - { - g_aPlayers[iClient][bQueue] = false; - } - } -} - -public HookRoundStart(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Set our variables. - */ - g_bRoundEnd = false; - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled && g_bIsImmuntyEnabled) - { - - /** - Get rid of their immunity. - */ - ProcessRoundEndImmunity(false); - } -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Set our variables. - */ - g_bRoundEnd = true; - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled && g_bIsImmuntyEnabled) - { - - /** - Give them their immunity. - */ - ProcessRoundEndImmunity(true); - } -} - -public Action:Timer_DonatorJoined(Handle:timer, any:client) -{ - - /** - Make sure sounds are enabled. - */ - if (g_bIsEnabled && g_bIsJoinSoundEnabled) - { - EmitSoundToClient(client, g_sSoundFile); - } - - /** - Make sure private messages are enabled. - */ - if (g_bIsJoinPrivMsgEnabled) - { - - /** - Send messages to the client. - */ - decl String:sMsg[1024]; - Format(sMsg, sizeof(sMsg), "%T", "PrivateJoinMessage", LANG_SERVER); - PrintToChat(client,"\x01\x05%s", sMsg); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Timer_PlayerUberDelay(Handle:timer, any:client) -{ - - /** - Make sure the client is still in game. - */ - if (IsClientInGame(client)) - { - - /** - Make sure the client is still a medic. - */ - if (TF2_GetPlayerClass(client) == TFClass_Medic) - { - - /** - Get the medgun weapon index - */ - new iIndex = GetPlayerWeaponSlot(client, 1); - if (iIndex > 0) - { - - /** - Set the uber level with the bonus. - */ - SetEntPropFloat(iIndex, Prop_Send, "m_flChargeLevel", g_fUberLevel); - } - } - } -} - -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (convar == sdb_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsEnabled = false; - } - else - { - g_bIsEnabled = true; - } - } - else if (convar == sdb_donationflag) - { - Format(g_sCharDonatorFlag, sizeof(g_sCharDonatorFlag), "%s", newValue); - } - else if (convar == sdb_soundfile) - { - Format(g_sSoundFile, sizeof(g_sSoundFile), "%s", newValue); - } - else if (convar == sdb_joinsound_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsJoinSoundEnabled = false; - } - else - { - g_bIsJoinSoundEnabled = true; - } - } - else if (convar == sdb_joinpubmsg_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsJoinPubMsgEnabled = false; - } - else - { - g_bIsJoinPubMsgEnabled = true; - } - } - else if (convar == sdb_joinprivmsg_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsJoinPrivMsgEnabled = false; - } - else - { - g_bIsJoinPrivMsgEnabled = true; - } - } - else if (convar == sdb_chatcolors_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsChatColorsEnabled = false; - } - else - { - g_bIsChatColorsEnabled = true; - } - } - else if (convar == sdb_immunity_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsImmuntyEnabled = false; - } - else - { - g_bIsImmuntyEnabled = true; - } - } - else if (convar == sdb_ubercharge_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsUberChargeEnabled = false; - } - else - { - g_bIsUberChargeEnabled = true; - } - } - else if (convar == sdb_givehealth_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsGiveHealthEnabled = false; - } - else - { - g_bIsGiveHealthEnabled = true; - } - } - else if (convar == sdb_nofalldmg_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsNoFallDmgEnabled = false; - } - else - { - g_bIsNoFallDmgEnabled = true; - } - } - else if (convar == sdb_fastheavy_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsFastHeayEnabled = false; - } - else - { - g_bIsFastHeayEnabled = true; - } - } - else if (convar == sdb_swapteam_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsSwapTeamEnabled = false; - } - else - { - g_bIsSwapTeamEnabled = true; - } - } - else if (convar == sdb_chatcolor) - { - Format(g_sChatColor, sizeof(g_sChatColor), "%s", newValue); - } - else if (convar == sdb_uberlevel) - { - g_fUberLevel = StringToFloat(newValue); - } - else if (convar == sdb_healthcount) - { - g_iHealthCount = StringToInt(newValue); - } - else if (convar == sdb_healthbonus) - { - g_iHealthBonus = StringToInt(newValue); - } - else if (convar == sdb_heavymultiplier) - { - g_fHeavyMultiplier = StringToFloat(newValue); - } -} - -stock LoadUpVariables() -{ - g_bIsEnabled = GetConVarBool(sdb_enabled); - g_bIsJoinSoundEnabled = GetConVarBool(sdb_enabled); - g_bIsJoinPubMsgEnabled = GetConVarBool(sdb_enabled); - g_bIsJoinPrivMsgEnabled = GetConVarBool(sdb_enabled); - g_bIsChatColorsEnabled = GetConVarBool(sdb_enabled); - g_bIsImmuntyEnabled = GetConVarBool(sdb_enabled); - g_bIsUberChargeEnabled = GetConVarBool(sdb_enabled); - g_bIsGiveHealthEnabled = GetConVarBool(sdb_enabled); - g_bIsNoFallDmgEnabled = GetConVarBool(sdb_enabled); - g_bIsFastHeayEnabled = GetConVarBool(sdb_enabled); - g_bIsSwapTeamEnabled = GetConVarBool(sdb_enabled); - GetConVarString(sdb_donationflag, g_sCharDonatorFlag, sizeof(g_sCharDonatorFlag)); - GetConVarString(sdb_soundfile, g_sSoundFile, sizeof(g_sSoundFile)); - GetConVarString(sdb_chatcolor, g_sChatColor, sizeof(g_sChatColor)); - g_bRoundEnd = false; - g_iHealthBonus = GetConVarInt(sdb_healthbonus); - g_iHealthCount = GetConVarInt(sdb_healthcount); - g_fHeavyMultiplier = GetConVarFloat(sdb_heavymultiplier); - g_fUberLevel = GetConVarFloat(sdb_uberlevel); -} - -stock PrepSoundFile() -{ - decl String:buffer[PLATFORM_MAX_PATH]; - PrecacheSound(g_sSoundFile, true); - Format(buffer, sizeof(buffer), "sound/%s", g_sSoundFile); - AddFileToDownloadsTable(buffer); -} - -stock CleanUpPlayer(client) -{ - g_aPlayers[client][bIsDonator] = false; - g_aPlayers[client][bQueue] = false; - g_aPlayers[client][bImmune] = false; - g_aPlayers[client][iNewTeam] = 0; - g_aPlayers[client][iHealthCount] = 0; -} - -stock ProcessRoundEndImmunity(bool:give) -{ - for (new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][bIsDonator]) - { - if (give) - { - SetEntProp(i, Prop_Data, "m_takedamage", 0, 1); - g_aPlayers[i][bImmune] = true; - } - else - { - SetEntProp(i, Prop_Data, "m_takedamage", 2, 1); - g_aPlayers[i][bImmune] = false; - } - } - } -} - -stock FormatMessage(iClient, iTeam, bool:bAlive, String:sChatMsg[], const Sting:sMessage[]) -{ - decl String:sDead[10], - String:sTeam[10], - String:sClientName[64]; - GetClientName(iClient, sClientName, sizeof(sClientName)); - if (iTeam != 0) - Format(sTeam, sizeof(sTeam), "(TEAM) "); - else - Format(sTeam, sizeof(sTeam), ""); - if (bAlive) - Format(sDead, sizeof(sDead), ""); - else - Format(sDead, sizeof(sDead), "*DEAD* "); - if (StrContains(g_sChatColor, "light", false) == -1) - Format(sChatMsg, CHAT_MAX_MESSAGE_LENGTH, "\x01%s%s\x03%s \x01: \x05%s", sDead, sTeam, sClientName, sMessage); - else - Format(sChatMsg, CHAT_MAX_MESSAGE_LENGTH, "\x01%s%s\x03%s \x01: \x04%s", sDead, sTeam, sClientName, sMessage); -} - -stock SayText2(target, author, const String:message[]) -{ - new Handle:hBf; - if (target == 0) - hBf = StartMessageAll("SayText2"); - else - hBf = StartMessageOne("SayText2", target); - if (hBf != INVALID_HANDLE) - { - BfWriteByte(hBf, author); - BfWriteByte(hBf, true); - BfWriteString(hBf, message); - EndMessage(); - } -} - -stock ProcessAdmins() -{ - for (new i = 1; i <= MaxClients; i++) - { - if (SM_IsValidAdmin(i, g_sCharDonatorFlag)) - { - g_aPlayers[i][bDonator] = true; - } - else - { - g_aPlayers[i][bDonator] = false; - } - } -} - -stock ProcessLate() -{ - if (g_bIsEnabled) - { - ProcessAdmins(); - PrepSoundFile(); - if (g_bRoundEnd && g_bIsImmuntyEnabled) - { - ProcessRoundEndImmunity(true); - } - if (!g_bIsImmuntyEnabled) - { - ProcessRoundEndImmunity(false); - } - } - else - { - ProcessRoundEndImmunity(false); - } -} - -public Menu_SwapMode(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, 64); - if (StringToInt(sSelection)) - g_aPlayers[param1][bQueue] = false; - else - g_aPlayers[param1][bQueue] = true; - if (!g_aPlayers[param1][bQueue]) - SM_MovePlayer(param1, g_aPlayers[param1][iNewTeam]); - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -public Menu_SelectPlayer(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[256]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - new iTarget = GetClientOfUserId(StringToInt(sSelection)); - if (g_aPlayers[iTarget][bIsDonator]) - g_aPlayers[iTarget][bIsDonator] = false; - else - g_aPlayers[iTarget][bIsDonator] = true; - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -stock Handle:BuildSwapModeMenu() -{ - new Handle:menu = CreateMenu(Menu_SwapMode); - SetMenuTitle(menu, "Select When to Swap:"); - AddMenuItem(menu, "0", "Instantly (Kills)"); - AddMenuItem(menu, "1", "Queue on next death"); - SetMenuExitBackButton(menu, false); - return menu; -} - -stock Handle:BuildPlayerMenu() -{ - new Handle:menu = CreateMenu(Menu_SelectPlayer); - AddTargetsToMenu(menu, 0, true, false); - SetMenuTitle(menu, "Select A Player:"); - SetMenuExitBackButton(menu, true); - return menu; -} - -public Action:Command_TEST(client, args) -{ - -} \ No newline at end of file diff --git a/Simple AutoScrambler/addons/sourcemod/scripting/simple-messagesuppression.sp b/Simple AutoScrambler/addons/sourcemod/scripting/simple-messagesuppression.sp deleted file mode 100644 index f7725a4..0000000 --- a/Simple AutoScrambler/addons/sourcemod/scripting/simple-messagesuppression.sp +++ /dev/null @@ -1,227 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Message Suppression -Description: - Blocks Specific Message Outputs -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include -#include - -#define SUPPRESS_VERSION "1.1.$Rev$" - -public Plugin:myinfo = -{ - name = "Simple Message Suppression", - author = "FlyingMongoose, psychonic", - description = "Blocks Specific Message Outputs", - version = SUPPRESS_VERSION, - url = "http://www.simple-plugins.com/" -} - -new Handle:cvarBlockSpectateMessage; -new Handle:cvarBlockDisconnectMessage; -new Handle:cvarBlockConnectMessage; -new Handle:cvarAdminShowMessages; -new iSpecTeam = 1; - - -public OnPluginStart() -{ - CreateConVar("suppress_version", SUPPRESS_VERSION, _, FCVAR_PLUGIN|FCVAR_NOTIFY|FCVAR_REPLICATED|FCVAR_SPONLY|FCVAR_DONTRECORD); - cvarBlockSpectateMessage = CreateConVar("sm_blockspectatemessage", "1", "If enabled it blocks the join team message if an administrator joins spectator", FCVAR_PLUGIN, true, 0.0, true, 1.0); - cvarBlockDisconnectMessage = CreateConVar("sm_blockdisconnectmessage", "1", "Blocks the disconnect message", FCVAR_PLUGIN, true, 0.0, true, 1.0); - cvarBlockConnectMessage = CreateConVar("sm_blockconnectmessage", "1", "If enabled it blocks the player connection message.", FCVAR_PLUGIN, true, 0.0, true, 1.0); - cvarAdminShowMessages = CreateConVar("sm_adminshowmessages", "1", "Shows disconnect/connect/team join messages for admins only (if disconnect message is set to be blocked)", FCVAR_PLUGIN, true, 0.0, true, 1.0); - HookEvent("player_team", ev_PlayerTeam, EventHookMode_Pre); - HookEvent("player_disconnect", ev_PlayerDisconnect, EventHookMode_Pre); - HookEvent("player_connect", ev_PlayerConnect, EventHookMode_Pre); - - new String:game_folder[64]; - GetGameFolderName(game_folder, sizeof(game_folder)) - - if (StrContains(game_folder, "insurgency", false) != -1) - { - iSpecTeam = 3; - } - else - { - new String:game_description[64]; - GetGameDescription(game_description, sizeof(game_description), true); - if (StrContains(game_description, "Insurgency", false) != -1) - { - iSpecTeam = 3; - } - } - - AutoExecConfig(true, "suppressmessage", "sourcemod"); -} - -public Action:ev_PlayerTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - if (GetConVarBool(cvarBlockSpectateMessage)) - { - if (!dontBroadcast && !GetEventBool(event, "silent")) - { - new iUserId = GetEventInt(event, "userid"); - new iClient = GetClientOfUserId(iUserId); - new iTeam = GetEventInt(event, "team"); - - if (iTeam == iSpecTeam && GetAdminFlag(GetUserAdmin(iClient), Admin_Kick)) - { - new iOldTeam = GetEventInt(event, "oldteam"); - new bool:bDisconnect = GetEventBool(event, "disconnect"); - new bool:bAutoteam = GetEventBool(event, "autoteam"); - decl String:strName[50]; - GetEventString(event, "name", strName, sizeof(strName)); - - if (iClient != 0) - { - if (GetConVarInt(cvarAdminShowMessages) == 1) - { - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientConnected(i) && IsClientInGame(i) && GetUserAdmin(i) != INVALID_ADMIN_ID) - { - PrintToChat(i,"%N joined team Spectator.", iClient); - PrintToConsole(i,"%N joined team Spectator.", iClient); - } - } - } - } - - new Handle:hEvent = CreateEvent("player_team"); - SetEventInt(hEvent, "userid", iUserId); - SetEventInt(hEvent, "team", iTeam); - SetEventInt(hEvent, "oldteam", iOldTeam); - SetEventBool(hEvent, "disconnect", bDisconnect); - SetEventBool(hEvent, "autoteam", bAutoteam); - SetEventBool(hEvent, "silent", true); - SetEventString(hEvent, "name", strName); - - FireEvent(hEvent, true); - - return Plugin_Handled; - } - } - } - return Plugin_Continue; -} -public Action:ev_PlayerConnect(Handle:event, const String:name[], bool:dontBroadcast) -{ - if (GetConVarBool(cvarBlockConnectMessage)) - { - if (!dontBroadcast) - { - decl String:strName[50]; - GetEventString(event, "name", strName, sizeof(strName)); - new iIndex = GetEventInt(event, "index"); - new iUserId = GetEventInt(event, "userid"); - new iClient = GetClientOfUserId(iUserId); - decl String:strNetworkId[50]; - GetEventString(event, "networkid", strNetworkId, sizeof(strNetworkId)); - decl String:strAddress[50]; - GetEventString(event, "address", strAddress, sizeof(strAddress)); - - if (iClient != 0) - { - if (GetConVarInt(cvarAdminShowMessages) == 1) - { - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientConnected(i) && IsClientInGame(i) && GetUserAdmin(i) != INVALID_ADMIN_ID) - { - PrintToChat(i,"%N has connected.", iClient); - PrintToConsole(i,"%N has connected.", iClient); - } - } - } - } - - new Handle:hEvent = CreateEvent("player_connect"); - SetEventString(hEvent, "name", strName); - SetEventInt(hEvent, "index", iIndex); - SetEventInt(hEvent, "userid", iUserId); - SetEventString(hEvent, "networkid", strNetworkId); - SetEventString(hEvent, "address", strAddress); - - FireEvent(hEvent, true); - - return Plugin_Handled; - } - } - return Plugin_Continue; -} -public Action:ev_PlayerDisconnect(Handle:event, const String:name[], bool:dontBroadcast) -{ - if (GetConVarBool(cvarBlockDisconnectMessage)) - { - if (!dontBroadcast) - { - new iUserId = GetEventInt(event, "userid"); - new iClient = GetClientOfUserId(iUserId); - decl String:strReason[50]; - GetEventString(event, "reason", strReason, sizeof(strReason)); - decl String:strName[50]; - GetEventString(event, "name", strName, sizeof(strName)); - decl String:strNetworkId[50]; - GetEventString(event, "networkid", strNetworkId, sizeof(strNetworkId)); - - if (iClient != 0) - { - if (GetConVarInt(cvarAdminShowMessages) == 1) - { - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientConnected(i) && IsClientInGame(i) && GetUserAdmin(i) != INVALID_ADMIN_ID) - { - PrintToChat(i, "%N has left the server.", iClient); - PrintToConsole(i, "Dropped %N from server (Disconnect by user.)", iClient); - } - } - } - } - - new Handle:hEvent = CreateEvent("player_disconnect"); - SetEventInt(hEvent, "userid", iUserId); - SetEventString(hEvent, "reason", strReason); - SetEventString(hEvent, "name", strName); - SetEventString(hEvent, "networkid", strNetworkId); - - FireEvent(hEvent, true); - - return Plugin_Handled; - } - } - - return Plugin_Continue; -} \ No newline at end of file diff --git a/Simple AutoScrambler/addons/sourcemod/scripting/simple-plugins.sp b/Simple AutoScrambler/addons/sourcemod/scripting/simple-plugins.sp deleted file mode 100644 index 4462b41..0000000 --- a/Simple AutoScrambler/addons/sourcemod/scripting/simple-plugins.sp +++ /dev/null @@ -1,785 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Plugins -Description: - Core plugin for Simple Plugins project -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#define CORE_PLUGIN_VERSION "1.1.$Rev$" - -#include - -enum e_PlayerInfo -{ - Handle:hForcedTeamPlugin = INVALID_HANDLE, - iForcedTeam = 0, - iBuddy = 0, - bool:bBuddyLocked = false -}; - -new Handle:g_fwdPlayerMoved; -new g_aPlayers[MAXPLAYERS + 1][e_PlayerInfo]; -new bool:g_bTeamsSwitched = false; - -/** -Setting our plugin information. -*/ -public Plugin:myinfo = -{ - name = "Simple Plugins Core Plugin", - author = "Simple Plugins", - description = "Core plugin for Simple Plugins", - version = CORE_PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -}; - -public bool:AskPluginLoad(Handle:myself, bool:late, String:error[], err_max) -{ - - /** - Register natives for other plugins - */ - CreateNative("SM_MovePlayer", Native_SM_MovePlayer); - CreateNative("SM_SetForcedTeam", Native_SM_SetForcedTeam); - CreateNative("SM_GetForcedTeam", Native_SM_GetForcedTeam); - CreateNative("SM_ClearForcedTeam", Native_SM_ClearForcedTeam); - CreateNative("SM_GetForcedPlayer", Native_SM_GetForcedPlayer); - CreateNative("SM_AssignBuddy", Native_SM_AssignBuddy); - CreateNative("SM_GetClientBuddy", Native_SM_GetClientBuddy); - CreateNative("SM_LockBuddy", Native_SM_LockBuddy); - CreateNative("SM_IsBuddyLocked", Native_SM_IsBuddyLocked); - CreateNative("SM_ClearBuddy", Native_SM_ClearBuddy); - CreateNative("SM_IsValidAdmin", Native_SM_IsValidAdmin); - CreateNative("SM_IsValidTeam", Native_SM_IsValidTeam); - RegPluginLibrary("simpleplugins"); - return true; -} - -public OnPluginStart() -{ - - CreateConVar("ssm_core_pl_ver", CORE_PLUGIN_VERSION, "Simple SourceMod Plugins Core Plugin Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - CreateConVar("ssm_core_inc_ver", CORE_INC_VERSION, "Simple SourceMod Plugins Core Include Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook some events to control forced players and check extensions - */ - decl String:sExtError[256]; - LogAction(0, -1, "[SSM] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_team", HookPlayerChangeTeam, EventHookMode_Pre); - switch (g_CurrentMod) - { - case GameType_CSS: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - new iExtStatus = GetExtensionFileStatus("game.cstrike.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SSM] Required extension was not found."); - LogAction(0, -1, "[SSM] Plugin FAILED TO LOAD."); - SetFailState("Required extension was not found."); - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SSM] Required extension is loaded with errors."); - LogAction(0, -1, "[SSM] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SSM] Plugin FAILED TO LOAD."); - SetFailState("Required extension is loaded with errors."); - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SSM] Required extension is loaded."); - } - } - case GameType_TF: - { - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_PostNoCopy); - HookUserMessage(GetUserMessageId("TextMsg"), UserMessageHook_Class, true); - new iExtStatus = GetExtensionFileStatus("game.tf2.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SSM] Required extension was not found."); - LogAction(0, -1, "[SSM] Plugin FAILED TO LOAD."); - SetFailState("Required extension was not found."); - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SSM] Required extension is loaded with errors."); - LogAction(0, -1, "[SSM] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SSM] Plugin FAILED TO LOAD."); - SetFailState("Required extension is loaded with errors."); - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SSM] Required extension is loaded."); - } - } - case GameType_DOD: - { - HookEvent("dod_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_PostNoCopy); - } - default: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - } - } - - /** - Load common translations - */ - LoadTranslations ("common.phrases"); - - /** - Create the global forward - */ - g_fwdPlayerMoved = CreateGlobalForward("SM_OnPlayerMoved", ET_Event, Param_Cell, Param_Cell, Param_Cell); -} - -public OnClientDisconnect(client) -{ - - /** - Cleanup clients/players buddy list - */ - if (!IsFakeClient(client)) - { - SM_ClearBuddy(client, true); - SM_LockBuddy(client, false); - } - SM_ClearForcedTeam(client); -} - -public HookRoundStart(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - See if the teams have been switched - */ - if (g_bTeamsSwitched) - { - - /** - Switch the teams the players are forced to - */ - for (new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][iForcedTeam] != 0) - { - if (g_aPlayers[i][iForcedTeam] == g_aCurrentTeams[Team1]) - { - g_aPlayers[i][iForcedTeam] = g_aCurrentTeams[Team2]; - } - else - { - g_aPlayers[i][iForcedTeam] = g_aCurrentTeams[Team1]; - } - } - } - } -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - g_bTeamsSwitched = false; -} - -public HookPlayerChangeTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get our event variables - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - new iTeam = GetEventInt(event, "team"); - - /** - See if the player is on the wrong team - */ - if (g_aPlayers[iClient][iForcedTeam] != 0 && g_aPlayers[iClient][iForcedTeam] != iTeam) - { - - /** - Move the player back to the forced team - */ - CreateTimer(1.0, Timer_ForcePlayerMove, iClient, TIMER_FLAG_NO_MAPCHANGE); - - /** - If the event was going to be broadcasted, we refire it so it is not broadcasted and stop this one - */ - if (!dontBroadcast) - { - new Handle:hEvent = CreateEvent("player_team"); - SetEventInt(hEvent, "userid", GetEventInt(event, "userid")); - SetEventInt(hEvent, "team", GetEventInt(event, "team")); - SetEventInt(hEvent, "oldteam", GetEventInt(event, "oldteam")); - SetEventBool(hEvent, "disconnect", GetEventBool(event, "disconnect")); - - if (g_CurrentMod == GameType_DOD || g_CurrentMod == GameType_L4D || g_CurrentMod == GameType_TF) - { - new String:sClientName[MAX_NAME_LENGTH + 1]; - GetClientName(client, sClientName, sizeof(sClientName)); - SetEventBool(hEvent, "autoteam", GetEventBool(event, "autoteam")); - SetEventBool(hEvent, "silent", true); - SetEventString(hEvent, "name", sClientName); - FireEvent(hEvent, true); - } - else - { - FireEvent(hEvent, true); - } - return Plugin_Handled; - } - } - return Plugin_Continue; -} - -public Action:UserMessageHook_Class(UserMsg:msg_id, Handle:bf, const players[], playersNum, bool:reliable, bool:init) -{ - new String:sMessage[120]; - BfReadString(bf, sMessage, sizeof(sMessage), true); - if (StrContains(sMessage, "#TF_TeamsSwitched", false) != -1) - { - g_bTeamsSwitched = true; - } - return Plugin_Continue; -} - -public Native_SM_MovePlayer(Handle:plugin, numParams) -{ - - /** - Get and check the client and team - */ - new iClient = GetNativeCell(1); - new iTeam = GetNativeCell(2); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (iTeam != g_aCurrentTeams[Spectator] && iTeam != g_aCurrentTeams[Team1] && iTeam != g_aCurrentTeams[Team2]) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid team %d", iTeam); - } - - MovePlayer(iClient, iTeam); - if (!IsClientObserver(iClient)) - { - RespawnPlayer(iClient); - } - - new fResult; - - Call_StartForward(g_fwdPlayerMoved); - Call_PushCell(plugin); - Call_PushCell(iClient); - Call_PushCell(iTeam); - Call_Finish(fResult); - - if (fResult != SP_ERROR_NONE) - { - return ThrowNativeError(fResult, "Forward failed"); - } - - return fResult; -} - -public Native_SM_SetForcedTeam(Handle:plugin, numParams) -{ - - /** - Get and check the client and team - */ - new iClient = GetNativeCell(1); - new iTeam = GetNativeCell(2); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (iTeam != g_aCurrentTeams[Spectator] && iTeam != g_aCurrentTeams[Team1] && iTeam != g_aCurrentTeams[Team2] && iTeam != g_aCurrentTeams[Unknown]) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid team %d", iTeam); - } - - new bool:bOverRide = GetNativeCell(3) ? true : false; - - if (!bOverRide && g_aPlayers[iClient][hForcedTeamPlugin] != INVALID_HANDLE && plugin != g_aPlayers[iClient][hForcedTeamPlugin]) - { - return false; - } - - g_aPlayers[iClient][hForcedTeamPlugin] = plugin; - g_aPlayers[iClient][iForcedTeam] = iTeam; - return true; -} - -public Native_SM_GetForcedTeam(Handle:plugin, numParams) -{ - - /** - Get and check the client - */ - new iClient = GetNativeCell(1); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - - /** - Get and set the plugin if they want it - */ - new Handle:hPlugin = GetNativeCell(2); - if (hPlugin != INVALID_HANDLE) - { - SetNativeCellRef(2, g_aPlayers[iClient][hForcedTeamPlugin]); - } - - /** - Return the forced team, this could be 0 - */ - return g_aPlayers[iClient][iForcedTeam]; -} - -public Native_SM_ClearForcedTeam(Handle:plugin, numParams) -{ - - /** - Get and check the client and team - */ - new iClient = GetNativeCell(1); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - - g_aPlayers[iClient][hForcedTeamPlugin] = INVALID_HANDLE; - g_aPlayers[iClient][iForcedTeam] = 0; - - return true; -} - -public Native_SM_GetForcedPlayer(Handle:plugin, numParams) -{ - - /** - Get and check the team - */ - new iTeam = GetNativeCell(1); - if (iTeam != g_aCurrentTeams[Spectator] && iTeam != g_aCurrentTeams[Team1] && iTeam != g_aCurrentTeams[Team2]) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid team %d", iTeam); - } - - /** - Start a loop to check for a player on the wrong team - Also make sure the plugin that set the forced team is the plugin that asked - */ - new iPlayer = 0; - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientInGame(i) - && GetClientTeam(i) != g_aPlayers[i][iForcedTeam] - && g_aPlayers[i][iForcedTeam] == iTeam - && g_aPlayers[i][hForcedTeamPlugin] == plugin) - { - iPlayer = i; - break; - } - } - - /** - Return the player we found, this could be 0 - */ - return iPlayer; -} - -public Native_SM_AssignBuddy(Handle:plugin, numParams) -{ - - /** - Get and check the client and player - */ - new iClient = GetNativeCell(1); - new iPlayer = GetNativeCell(2); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (iPlayer < 0 || iPlayer > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid player index (%d)", iPlayer); - } - if (!IsClientConnected(iPlayer)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Player %d is not connected", iPlayer); - } - if (!IsClientInGame(iPlayer)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Player %d is not in the game", iClient); - } - if (IsFakeClient(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Bots are not supported"); - } - - /** - See if we can override his setting - */ - new bool:bOverRide = GetNativeCell(3) ? true : false; - if (!bOverRide) - { - - /** - We can't override, so check if they are locked - */ - if (g_aPlayers[iClient][bBuddyLocked] || g_aPlayers[iPlayer][bBuddyLocked]) - { - - /** - We detected at least 1 lock, so we bug out - */ - return false; - } - } - - /** - Ready to set the buddies - */ - g_aPlayers[iClient][iBuddy] = iPlayer; - g_aPlayers[iPlayer][iBuddy] = iClient; - return true; -} - -public Native_SM_GetClientBuddy(Handle:plugin, numParams) -{ - - /** - Get and check the client - */ - new iClient = GetNativeCell(1); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (IsFakeClient(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Bots are not supported"); - } - - /** - Return the players buddy, this could be 0 - */ - return g_aPlayers[iClient][iBuddy]; -} - -public Native_SM_LockBuddy(Handle:plugin, numParams) -{ - - /** - Get and check the client - */ - new iClient = GetNativeCell(1); - new bool:bSetting = GetNativeCell(2) ? true : false; - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (IsFakeClient(iClient)) - { - return ThrowNativeError(SP_ERROR_NATIVE, "Bots are not supported"); - } - - g_aPlayers[iClient][bBuddyLocked] = bSetting; - return true; -} - -public Native_SM_IsBuddyLocked(Handle:plugin, numParams) -{ - - /** - Get and check the client - */ - new iClient = GetNativeCell(1); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (IsFakeClient(iClient)) - { - return ThrowNativeError(SP_ERROR_NATIVE, "Bots are not supported"); - } - - return g_aPlayers[iClient][bBuddyLocked]; -} - -public Native_SM_ClearBuddy(Handle:plugin, numParams) -{ - - /** - Get and check the client - */ - new iClient = GetNativeCell(1); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_NATIVE, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_NATIVE, "Client (%d) is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (IsFakeClient(iClient)) - { - return ThrowNativeError(SP_ERROR_NATIVE, "Bots are not supported"); - } - - /** - Get the clients buddy and see if we can override his setting - */ - new bool:bOverRide = GetNativeCell(2) ? true : false; - new iPlayer = g_aPlayers[iClient][iBuddy]; - - /** - There is no buddy, we don't care about anything else so bug out - */ - if (iPlayer == 0) - { - return true; - } - - /** - We determined he had a buddy, check the override setting - */ - if (!bOverRide) - { - - /** - We can't override, so check if they are locked - */ - if (g_aPlayers[iClient][bBuddyLocked] || g_aPlayers[iPlayer][bBuddyLocked]) - { - - /** - We detected at least 1 lock, so we bug out - */ - return false; - } - } - - /** - Ready to clear the buddies - */ - g_aPlayers[iClient][iBuddy] = 0; - g_aPlayers[iPlayer][iBuddy] = 0; - return true; -} - -public Native_SM_IsValidTeam(Handle:plugin, numParams) -{ - - /** - Get the team - */ - new iTeam = GetNativeCell(1); - - /** - Check the team - */ - if (iTeam == g_aCurrentTeams[Spectator] || iTeam == g_aCurrentTeams[Team1] || iTeam == g_aCurrentTeams[Team2]) - { - return true; - } - return false; -} - -public Native_SM_IsValidAdmin(Handle:plugin, numParams) -{ - /** - Get the client and flags - */ - new iClient = GetNativeCell(1); - decl String:sFlags[15]; - GetNativeString(2, sFlags, sizeof(sFlags)); - new ibFlags = ReadFlagString(sFlags); - - /** - Check the flags - */ - if ((GetUserFlagBits(iClient) & ibFlags) == ibFlags) - { - return true; - } - if (GetUserFlagBits(iClient) & ADMFLAG_ROOT) - { - return true; - } - return false; -} - -public Action:Timer_ForcePlayerMove(Handle:timer, any:iClient) -{ - - MovePlayer(iClient, g_aPlayers[iClient][iForcedTeam]); - - if (g_aPlayers[iClient][iForcedTeam] != g_aCurrentTeams[Spectator]) - { - RespawnPlayer(iClient); - } - - PrintToChat(iClient, "\x01\x04----------------------------------"); - PrintToChat(iClient, "\x01\x04You have been forced to this team."); - PrintToChat(iClient, "\x01\x04----------------------------------"); - - return Plugin_Handled; -} - -stock MovePlayer(iClient, iTeam) -{ - - /** - Change the client's team based on the mod - */ - switch (g_CurrentMod) - { - case GameType_CSS: - { - CS_SwitchTeam(iClient, iTeam); - } - default: - { - ChangeClientTeam(iClient, iTeam); - } - } -} - -stock RespawnPlayer(iClient) -{ - - /** - Respawn the client based on the mod - */ - switch (g_CurrentMod) - { - case GameType_CSS: - { - CS_RespawnPlayer(iClient); - } - case GameType_TF: - { - TF2_RespawnPlayer(iClient); - } - case GameType_INS: - { - FakeClientCommand(iClient, "kill"); - } - default: - { - // - } - } -} diff --git a/Simple AutoScrambler/addons/sourcemod/scripting/simple-roundimmunity.sp b/Simple AutoScrambler/addons/sourcemod/scripting/simple-roundimmunity.sp deleted file mode 100644 index 5f0bca3..0000000 --- a/Simple AutoScrambler/addons/sourcemod/scripting/simple-roundimmunity.sp +++ /dev/null @@ -1,947 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Round Immunity -Description: - Gives admins immunity during certain rounds -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or any later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#pragma semicolon 1 -#include -#include -#undef REQUIRE_EXTENSIONS -#undef AUTOLOAD_EXTENSIONS -#include -#include -#define REQUIRE_EXTENSIONS -#define AUTOLOAD_EXTENSIONS - -#define PLUGIN_VERSION "1.1.$Rev$" -#define SPECTATOR 1 -#define TEAM_RED 2 -#define TEAM_BLUE 3 - -#define COLOR_GREEN 0 -#define COLOR_BLACK 1 -#define COLOR_RED 2 -#define COLOR_BLUE 3 -#define COLOR_TEAM 4 -#define COLOR_RAINBOW 5 -#define COLOR_NONE 6 - -#define PLAYERCOND_SLOWED (1<<0) //1 -#define PLAYERCOND_ZOOMED (1<<1) //2 -#define PLAYERCOND_DISGUISING (1<<2) //4 -#define PLAYERCOND_DISGUISED (1<<3) //8 -#define PLAYERCOND_SPYCLOAK (1<<4) //16 -#define PLAYERCOND_UBERED (1<<5) //32 -#define PLAYERCOND_TELEPORTTRAIL (1<<6) //64 -#define PLAYERCOND_TAUNT (1<<7) //128 -// (1<<8) //256 -// (1<<9) //512 -#define PLAYERCOND_TELEPORTFLASH (1<<10) //1024 -#define PLAYERCOND_KRUBER (1<<11) //2048 -// (1<<12) //4096 -// (1<<13) //8192 -#define PLAYERCOND_BONKED (1<<14) //16384 (blame Neph if it doesn't work) -#define PLAYERCOND_BONKEDORDRINKSLOWDOWN (1<<15) //32768 -#define PLAYERCOND_HEALING (1<<16) //65536 -#define PLAYERCOND_BURNING (1<<17) //131072 -#define PLAYERCOND_FULLYCHARGEDBYMEDIC (1<<18) //262144 - -enum e_Cookies -{ - bEnabled, - iColor, - iMode -}; - -enum e_ColorNames -{ - Green, - Black, - Red, - Blue -}; - -enum e_ColorValues -{ - iRed, - iGreen, - iBlue -}; - -enum e_PlayerData -{ - Handle:hGodModeTimer, - Handle:hColorTimer, - bool:bIsAdmin, - bool:bIsImmune, - iCycleColor -}; - -/** - Global convar handles - */ -new Handle:sri_charadminflag = INVALID_HANDLE; -new Handle:sri_enabled = INVALID_HANDLE; -new Handle:sri_cookie_enabled = INVALID_HANDLE; -new Handle:sri_cookie_color = INVALID_HANDLE; -new Handle:sri_cookie_mode = INVALID_HANDLE; - -/** - Player arrays - */ -new g_aPlayers[MAXPLAYERS + 1][e_PlayerData]; -new g_aClientCookies[MAXPLAYERS + 1][e_Cookies]; - -/** - Global bools - */ -new bool:g_bLoadedLate = false; -new bool:g_bIsEnabled = true; -new bool:g_bRoundEnd = false; -new bool:g_bUseDukehacks = false; -new bool:g_bUseClientprefs = false; - -/** - Global strings/integers/floats - */ -new String:g_sCharAdminFlag[32]; -new g_iColors[e_ColorNames][e_ColorValues]; -new g_iClassMaxHealth[TFClassType] = {0, 125, 125, 200, 175, 150, 300, 175, 125, 125}; - -public Plugin:myinfo = -{ - name = "Simple Round Immunity", - author = "Simple Plugins", - description = "Gives admins immunity during certain rounds", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -} - -bool:AskPluginLoad(Handle:myself, bool:late, String:error[], err_max) -{ - g_bLoadedLate = late; - return true; -} - -public OnPluginStart() -{ - - /** - Create console variables - */ - CreateConVar("sri_version", PLUGIN_VERSION, "Simple Round Immunity", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - sri_enabled = CreateConVar("sri_enabled", "1", "Enable/Disable Admin immunity during certain round."); - sri_charadminflag = CreateConVar("sri_charadminflag", "a", "Admin flag to use for immunity (only one). Must be a in char format."); - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook some events and check extensions - */ - decl String:sExtError[256]; - LogAction(0, -1, "[SRI] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_spawn", HookPlayerSpawn, EventHookMode_Post); - HookEvent("player_hurt", HookPlayerHurt, EventHookMode_Pre); - switch (g_CurrentMod) - { - case GameType_CSS: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - new iExtStatus = GetExtensionFileStatus("game.cstrike.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SRI] Required extension was not found."); - LogAction(0, -1, "[SRI] Plugin FAILED TO LOAD."); - SetFailState("Required extension was not found."); - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SRI] Required extension is loaded with errors."); - LogAction(0, -1, "[SRI] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SRI] Plugin FAILED TO LOAD."); - SetFailState("Required extension is loaded with errors."); - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SRI] Required css extension is loaded."); - } - } - case GameType_TF: - { - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_PostNoCopy); - HookUserMessage(GetUserMessageId("TextMsg"), UserMessageHook_Class, true); - new iExtStatus = GetExtensionFileStatus("game.tf2.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SRI] Required extension was not found."); - LogAction(0, -1, "[SRI] Plugin FAILED TO LOAD."); - SetFailState("Required extension was not found."); - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SRI] Required extension is loaded with errors."); - LogAction(0, -1, "[SRI] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SRI] Plugin FAILED TO LOAD."); - SetFailState("Required extension is loaded with errors."); - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SRI] Required tf2 extension is loaded."); - } - iExtStatus = GetExtensionFileStatus("dukehacks.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SRI] Dukehacks extension was not found."); - LogAction(0, -1, "[SRI] Plugin continued to load, but that feature will not be used."); - g_bUseDukehacks = false; - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SRI] Dukehacks extension is loaded with errors."); - LogAction(0, -1, "[SRI] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SRI] Plugin continued to load, but that feature will not be used."); - g_bUseDukehacks = false; - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SRI] Dukehacks extension is loaded and will be used."); - g_bUseDukehacks = true; - dhAddClientHook(CHK_TakeDamage, Hacks_TakeDamageHook); - } - } - case GameType_DOD: - { - HookEvent("dod_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_PostNoCopy); - } - default: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - } - } - /** - Now lets check for client prefs extension - */ - new iExtStatus = GetExtensionFileStatus("clientprefs.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SRI] Client Preferences extension was not found."); - LogAction(0, -1, "[SRI] Plugin continued to load, but that feature will not be used."); - g_bUseClientprefs = false; - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SRI] Client Preferences extension is loaded with errors."); - LogAction(0, -1, "[SRI] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SRI] Plugin continued to load, but that feature will not be used."); - g_bUseClientprefs = false; - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SRI] Client Preferences extension is loaded, checking database."); - if (!SQL_CheckConfig(clientprefs)) - { - LogAction(0, -1, "[SRI] No 'clientprefs' database found. Check your database.cfg file."); - LogAction(0, -1, "[SRI] Plugin continued to load, but Client Preferences will not be used."); - g_bUseClientprefs = false; - } - g_bUseClientprefs = true; - - /** - Deal with client cookies - */ - sri_cookie_enabled = RegClientCookie("bri_client_enabled", "Enable/Disable your immunity during the bonus round.", CookieAccess_Public); - sri_cookie_color = RegClientCookie("bri_client_color", "Color to render when immune.", CookieAccess_Public); - sri_cookie_mode = RegClientCookie("bri_client_mode", "God mode to select", CookieAccess_Public); - SetCookieMenuItem(CookieMenu_TopMenu, sri_cookie_enabled, "Bonus Round Immunity"); - } - - HookConVarChange(sri_enabled, EnabledChanged); - - RegAdminCmd("sm_immunity", Command_Immunity, ADMFLAG_ROOT, "sm_immunity: Gives you immunity"); - - LoadColors(); - - AutoExecConfig(true, "plugin.simpleroundimmunity"); -} - -public OnAllPluginsLoaded() -{ - //something - // need to deal with the unloading of dukehacks, clientprefs, and simpleplugins - // should move hooking the client prefs cookies to a function to make sure they are done post plugin start if ext is loaded late -} - -public OnLibraryRemoved(const String:name[]) -{ - //something - // need to deal with the loading of dukehacks, clientprefs, and simpleplugins -} - -public OnConfigsExecuted() -{ - GetConVarString(sri_charadminflag, g_sCharAdminFlag, sizeof(g_sCharAdminFlag)); - g_bIsEnabled = GetConVarBool(sri_enabled); - g_bRoundEnd = false; -} - -/** - Client events - */ - -public OnClientPostAdminCheck(client) -{ - if (SM_IsValidAdmin(client, g_sCharAdminFlag)) - g_aPlayers[client][bIsAdmin] = true; - else - g_aPlayers[client][bIsAdmin] = false; -} - -public OnClientCookiesCached(client) -{ - decl String:sEnabled[2], String:sColor[4], String:sMode[2]; - GetClientCookie(client, sri_cookie_enabled, sEnabled, sizeof(sEnabled)); - GetClientCookie(client, sri_cookie_color, sColor, sizeof(sColor)); - GetClientCookie(client, sri_cookie_mode, sMode, sizeof(sMode)); - g_aClientCookies[client][bEnabled] = StringToInt(sEnabled); - g_aClientCookies[client][iColor] = StringToInt(sColor); - g_aClientCookies[client][iMode] = StringToInt(sMode); -} - -public OnClientDisconnect(client) -{ - CleanUp(client); -} - -/** - Commands - */ - -public Action:Command_Immunity(client, args) -{ - if (g_aPlayers[client][IsImmune]) - { - DisableImmunity(client); - } - else - { - EnableImmunity(client); - } - return Plugin_Handled; -} - -/** - Event hooks - */ - -public Action:Hacks_TakeDamageHook(client, attacker, inflictor, Float:damage, &Float:multiplier, damagetype) -{ - if (attacker == 0 || attacker >= MaxClients) - { - return Plugin_Continue; - } - if (g_aPlayers[client][IsImmune]) - { - new TFClassType:PlayerClass = TF2_GetPlayerClass(attacker); - if (PlayerClass == TFClass_Spy) - { - multiplier *= 0.0; - return Plugin_Changed; - } - } - return Plugin_Continue; -} - -public HookRoundStart(Handle:event, const String:name[], bool:dontBroadcast) -{ - g_bRoundEnd = false; - if (g_bIsEnabled) - { - for (new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][IsImmune]) - { - DisableImmunity(i); - } - } - } -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - g_bRoundEnd = true; - if (g_bIsEnabled) - { - for (new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][bIsAdmin]) - { - EnableImmunity(i); - } - } - } -} - -public HookPlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast) -{ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - if (g_bIsEnabled && g_aPlayers[iClient][bIsAdmin] && g_bRoundEnd) - { - EnableImmunity(iClient); - } -} - -public Action:HookPlayerHurt(Handle:event, const String:name[], bool:dontBroadcast) -{ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - if (g_aPlayers[iClient][IsImmune]) - { - SetEntityHealth(iClient, 2000); - return Plugin_Continue; - } - return Plugin_Continue; -} - -/** - Cookie menus - */ - -public CookieMenu_TopMenu(client, CookieMenuAction:action, any:info, String:buffer[], maxlen) -{ - if (action == CookieMenuAction_DisplayOption) - { - //don't think we need to do anything - } - else - { - new Handle:hMenu = CreateMenu(Menu_CookieSettings); - SetMenuTitle(hMenu, "Options (Current Setting)"); - if (g_aClientCookies[client][bEnabled]) - { - AddMenuItem(hMenu, "enable", "Enabled/Disable (Enabled)"); - } - else - { - AddMenuItem(hMenu, "enable", "Enabled/Disable (Disabled)"); - } - if (g_aClientCookies[client][iMode]) - { - AddMenuItem(hMenu, "mode", "Immunity Mode Setting (God Mode)"); - } - else - { - AddMenuItem(hMenu, "mode", "Immunity Mode Setting (Health)"); - } - switch (g_aClientCookies[client][iColor]) - { - case COLOR_GREEN: - { - AddMenuItem(hMenu, "color", "Color (Green)"); - } - case COLOR_BLACK: - { - AddMenuItem(hMenu, "color", "Color (Black)"); - } - case COLOR_RED: - { - AddMenuItem(hMenu, "color", "Color (Red)"); - } - case COLOR_BLUE: - { - AddMenuItem(hMenu, "color", "Color (Blue)"); - } - case COLOR_TEAM: - { - AddMenuItem(hMenu, "color", "Color (Team)"); - } - case COLOR_RAINBOW: - { - AddMenuItem(hMenu, "color", "Color (Rainbow)"); - } - case COLOR_NONE: - { - AddMenuItem(hMenu, "color", "Color (None)"); - } - } - SetMenuExitBackButton(hMenu, true); - DisplayMenu(hMenu, client, MENU_TIME_FOREVER); - } -} - -public Menu_CookieSettings(Handle:menu, MenuAction:action, param1, param2) -{ - new client = param1; - if (action == MenuAction_Select) - { - new String:sSelection[24]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "enable", false)) - { - new Handle:hMenu = CreateMenu(Menu_CookieSettingsEnable); - SetMenuTitle(hMenu, "Enable/Disable Round End Immunity"); - - if (g_aClientCookies[client][bEnabled]) - { - AddMenuItem(hMenu, "enable", "Enable (Set)"); - AddMenuItem(hMenu, "disable", "Disable"); - } - else - { - AddMenuItem(hMenu, "enable", "Enabled"); - AddMenuItem(hMenu, "disable", "Disable (Set)"); - } - - SetMenuExitBackButton(hMenu, true); - DisplayMenu(hMenu, client, MENU_TIME_FOREVER); - } - else if (StrEqual(sSelection, "mode", false)) - { - new Handle:hMenu = CreateMenu(Menu_CookieSettingsMode); - SetMenuTitle(hMenu, "Set Immunity Mode"); - - if (g_aClientCookies[client][iMode]) - { - AddMenuItem(hMenu, "god", "God Mode (Set)"); - AddMenuItem(hMenu, "health", "Health"); - } - else - { - AddMenuItem(hMenu, "god", "God Mode"); - AddMenuItem(hMenu, "health", "Health (Set)"); - } - - SetMenuExitBackButton(hMenu, true); - DisplayMenu(hMenu, client, MENU_TIME_FOREVER); - } - else - { - new Handle:hMenu = CreateMenu(Menu_CookieSettingsColors); - SetMenuTitle(hMenu, "Select Immunity Color"); - switch (g_aClientCookies[client][iColor]) - { - case COLOR_GREEN: - { - AddMenuItem(hMenu, "Green", "Green (Set)"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_BLACK: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black (Set)"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_RED: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red (Set)"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_BLUE: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue (Set)"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_TEAM: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color (Set)"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_RAINBOW: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow (Set)"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_NONE: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None (Set)"); - } - } - SetMenuExitBackButton(hMenu, true); - DisplayMenu(hMenu, client, MENU_TIME_FOREVER); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - ShowCookieMenu(client); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } -} - -public Menu_CookieSettingsEnable(Handle:menu, MenuAction:action, param1, param2) -{ - new client = param1; - if (action == MenuAction_Select) - { - new String:sSelection[24]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "enable", false)) - { - SetClientCookie(client, sri_cookie_enabled, "1"); - g_aClientCookies[client][bEnabled] = 1; - PrintToChat(client, "[SM] Bonus Round Immunity is ENABLED"); - } - else - { - SetClientCookie(client, sri_cookie_enabled, "0"); - g_aClientCookies[client][bEnabled] = 0; - PrintToChat(client, "[SM] Bonus Round Immunity is DISABLED"); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - ShowCookieMenu(client); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } -} - -public Menu_CookieSettingsColors(Handle:menu, MenuAction:action, param1, param2) -{ - new client = param1; - if (action == MenuAction_Select) - { - new String:sSelection[24]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "Green", false)) - { - SetClientCookie(client, sri_cookie_color, "0"); - g_aClientCookies[client][iColor] = COLOR_GREEN; - PrintToChat(client, "[SM] Bonus Round Immunity color set to GREEN"); - } - else if (StrEqual(sSelection, "Black", false)) - { - SetClientCookie(client, sri_cookie_color, "1"); - g_aClientCookies[client][iColor] = COLOR_BLACK; - PrintToChat(client, "[SM] Bonus Round Immunity color set to BLACK"); - } - else if (StrEqual(sSelection, "Red", false)) - { - SetClientCookie(client, sri_cookie_color, "2"); - g_aClientCookies[client][iColor] = COLOR_RED; - PrintToChat(client, "[SM] Bonus Round Immunity color set to RED"); - } - else if (StrEqual(sSelection, "Blue", false)) - { - SetClientCookie(client, sri_cookie_color, "3"); - g_aClientCookies[client][iColor] = COLOR_BLUE; - PrintToChat(client, "[SM] Bonus Round Immunity color set to BLUE"); - } - else if (StrEqual(sSelection, "Team", false)) - { - SetClientCookie(client, sri_cookie_color, "4"); - g_aClientCookies[client][iColor] = COLOR_TEAM; - PrintToChat(client, "[SM] Bonus Round Immunity color set to TEAM COLOR"); - } - else if (StrEqual(sSelection, "Rain", false)) - { - SetClientCookie(client, sri_cookie_color, "5"); - g_aClientCookies[client][iColor] = COLOR_RAINBOW; - PrintToChat(client, "[SM] Bonus Round Immunity color set to RAINBOW"); - } - else if (StrEqual(sSelection, "None", false)) - { - SetClientCookie(client, sri_cookie_color, "6"); - g_aClientCookies[client][iColor] = COLOR_NONE; - PrintToChat(client, "[SM] Bonus Round Immunity color set to NONE"); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - ShowCookieMenu(client); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } -} - -public Menu_CookieSettingsMode(Handle:menu, MenuAction:action, param1, param2) -{ - new client = param1; - if (action == MenuAction_Select) - { - new String:sSelection[24]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "god", false)) - { - SetClientCookie(client, sri_cookie_mode, "1"); - g_aClientCookies[client][iMode] = 1; - PrintToChat(client, "[SM] Bonus Round Immunity set to GOD MODE"); - } - else - { - SetClientCookie(client, sri_cookie_mode, "0"); - g_aClientCookies[client][iMode] = 0; - PrintToChat(client, "[SM] Bonus Round Immunity set to HEALTH BONUS"); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - ShowCookieMenu(client); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } -} - -/** -Timer functions - */ - -public Action:Timer_ChangeColor(Handle:timer, any:client) -{ - if (g_aPlayers[client][CycleColor]++ == 3) - { - g_aPlayers[client][CycleColor] = 0; - } - SetEntityRenderMode(client, RENDER_TRANSCOLOR); - SetEntityRenderColor(client, g_iColors[g_aPlayers[client][CycleColor]][iRed], g_iColors[g_aPlayers[client][CycleColor]][iGreen], g_iColors[g_aPlayers[client][CycleColor]][iBlue], 255); - return Plugin_Continue; -} - -public Action:Timer_UndoGodMode(Handle:timer, any:client) -{ - if (IsClientInGame(client)) - { - SetEntProp(client, Prop_Data, "m_takedamage", 2, 1); - } - g_aPlayers[iClient][hGodModeTimer] = INVALID_HANDLE; - return Plugin_Handled; -} - -/** -Stock functions . - */ - -stock CleanUp(iClient) -{ - g_aPlayers[iClient][bIsAdmin] = false; - DisableImmunity(iClient); -} - -stock EnableImmunity(iClient) -{ - SetEntityRenderMode(iClient, RENDER_TRANSCOLOR); - switch (g_aClientCookies[iClient][iColor]) - { - case COLOR_TEAM: - { - new iTeam = GetClientTeam(iClient); - SetEntityRenderColor(iClient, g_iColors[e_ColorNames:iTeam][iRed], g_iColors[e_ColorNames:iTeam][iGreen], g_iColors[e_ColorNames:iTeam][iBlue], 255); - } - case COLOR_RAINBOW: - { - if (g_aPlayers[iClient][hColorTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[iClient][hColorTimer]); - g_aPlayers[iClient][hColorTimer] = INVALID_HANDLE; - } - g_aPlayers[iClient][hColorTimer] = CreateTimer(0.2, Timer_ChangeColor, iClient, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); - } - case COLOR_NONE: - { - //We dont have to set a color - } - default: - { - SetEntityRenderColor(iClient, g_iColors[e_ColorNames:g_aClientCookies[iClient][iColor]][iRed], g_iColors[e_ColorNames:g_aClientCookies[iClient][iColor]][iGreen], g_iColors[e_ColorNames:g_aClientCookies[iClient][iColor]][iBlue], 255); - } - } - SetEntityHealth(iClient, 2000); - SetEntProp(iClient, Prop_Data, "m_takedamage", 0, 1); - g_aPlayers[iClient][hGodModeTimer] = CreateTimer(2.0, Timer_UndoGodMode, iClient); - g_aPlayers[iClient][IsImmune] = true; -} - -stock DisableImmunity(iClient) -{ - if (g_aPlayers[iClient][hGodModeTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[iClient][hGodModeTimer]); - g_aPlayers[iClient][hGodModeTimer] = INVALID_HANDLE; - } - if (g_aPlayers[iClient][hColorTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[iClient][hColorTimer]); - g_aPlayers[iClient][hColorTimer] = INVALID_HANDLE; - } - if (IsClientInGame(iClient)) - { - SetEntityRenderMode(iClient, RENDER_TRANSCOLOR); - SetEntityRenderColor(iClient, 255, 255, 255, 255); - new TFClassType:PlayerClass = TF2_GetPlayerClass(iClient); - new iMaxHealth = g_iClassMaxHealth[PlayerClass]; - SetEntityHealth(iClient, iMaxHealth); - } - g_aPlayers[iClient][CycleColor] = 0; - g_aPlayers[iClient][IsImmune] = false; -} - -stock LoadColors() -{ - g_iColors[Green][iRed] = 0; - g_iColors[Green][iGreen] = 255; - g_iColors[Green][iBlue] = 0; - - g_iColors[Black][iRed] = 10; - g_iColors[Black][iGreen] = 10; - g_iColors[Black][iBlue] = 0; - - g_iColors[Red][iRed] = 255; - g_iColors[Red][iGreen] = 0; - g_iColors[Red][iBlue] = 0; - - g_iColors[Blue][iRed] = 0; - g_iColors[Blue][iGreen] = 0; - g_iColors[Blue][iBlue] = 255; -} - -stock TF2_AddCond(client, cond) -{ - new Handle:cvar = FindConVar("sv_cheats"), bool:enabled = GetConVarBool(cvar), flags = GetConVarFlags(cvar); - if(!enabled) - { - SetConVarFlags(cvar, flags^FCVAR_NOTIFY); - SetConVarBool(cvar, true); - } - FakeClientCommand(client, "addcond %i", cond); - if(!enabled) - { - SetConVarBool(cvar, false); - SetConVarFlags(cvar, flags); - } -} - -stock TF2_RemoveCond(client, cond) -{ - new Handle:cvar = FindConVar("sv_cheats"), bool:enabled = GetConVarBool(cvar), flags = GetConVarFlags(cvar); - if(!enabled) - { - SetConVarFlags(cvar, flags^FCVAR_NOTIFY); - SetConVarBool(cvar, true); - } - FakeClientCommand(client, "removecond %i", cond); - if(!enabled) - { - SetConVarBool(cvar, false); - SetConVarFlags(cvar, flags); - } -} - -/** -Enabled hook - */ - -public EnabledChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (StringToInt(newValue) == 0) - { - UnhookEvent("player_spawn", HookPlayerSpawn, EventHookMode_Post); - UnhookEvent("teamplay_round_start", HookRoundStart, EventHookMode_Post); - UnhookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - for (new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][bIsAdmin] && g_aPlayers[i][IsImmune]) - { - DisableImmunity(i); - } - } - g_bIsEnabled = false; - } - else - { - HookEvent("player_spawn", HookPlayerSpawn, EventHookMode_Post); - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_Post); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - g_bIsEnabled = true; - } -} diff --git a/Simple AutoScrambler/addons/sourcemod/scripting/simple-spectate.sp b/Simple AutoScrambler/addons/sourcemod/scripting/simple-spectate.sp deleted file mode 100644 index 4108f8f..0000000 --- a/Simple AutoScrambler/addons/sourcemod/scripting/simple-spectate.sp +++ /dev/null @@ -1,2022 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Spectate -Description: - Spectate a player and follow them through death. -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include -#undef REQUIRE_EXTENSIONS -#undef AUTOLOAD_EXTENSIONS -#tryinclude -#define AUTOLOAD_EXTENSIONS -#define REQUIRE_EXTENSIONS - -#define PLUGIN_VERSION "1.2.1.$Rev$" - -#define SPECMODE_NONE 0 -#define SPECMODE_FIRSTPERSON 4 -#define SPECMODE_3RDPERSON 5 -#define SPECMODE_FREELOOK 6 -#define SPECMODE_CSS_FIRSTPERSON 3 -#define SPECMODE_CSS_3RDPERSON 4 -#define SPECMODE_CSS_FREELOOK 5 - -enum e_CvarHandles -{ - Handle:hHudMode, - Handle:hMenuType, - Handle:hRestrictHud, - Handle:hBan, - Handle:hBanPerm, - Handle:hBeacon, - Handle:hBlind, - Handle:hCheater, - Handle:hDrug, - Handle:hFreeze, - Handle:hFreezeBomb, - Handle:hKick, - Handle:hSlap, - Handle:hSlay, - Handle:hTimeBomb -}; - -enum e_CvarSettings -{ - bool:bHudMode, - bool:bMenuType, - bool:bRestrictHud, - bool:bBan, - bool:bBanPerm, - bool:bBeacon, - bool:bBlind, - bool:bCheater, - bool:bDrug, - bool:bFreeze, - bool:bFreezebomb, - bool:bKick, - bool:bSlap, - bool:bSlay, - bool:bTimeBomb -}; - -enum e_PluginSettings -{ - bool:bUseSteamBans, - bool:bUseSourceBans, - bool:bUseMySQLBans, - bool:bCanHUD, - bool:bUseDukehacks -}; - -enum e_Menus -{ - Handle:hSelectPlayer, - Handle:hBanTime, - Handle:hReason -}; - -enum e_Punishments -{ - Punish_None, - Punish_Ban, - Punish_Beacon, - Punish_Blind, - Punish_Cheater, - Punish_Drug, - Punish_Freeze, - Punish_FreezeBomb, - Punish_Kick, - Punish_Slap, - Punish_Slay, - Punish_TimeBomb -}; - -enum e_PlayerData -{ - bool:bIsDisplayingHud, - bool:bIsFlaggedCheater, - Handle:hHudTimer, - Handle:hTargetTimer, - iTargetIndex, - e_Punishments:TargetPunishment, - iBanTime -}; - -new Handle:sm_spectate_adminflag = INVALID_HANDLE; -new Handle:g_hAdminMenu = INVALID_HANDLE; -new Handle:g_hHud = INVALID_HANDLE; -new Handle:g_aPluginCvar[e_CvarHandles]; -new g_aPluginCvarSettings[e_CvarSettings]; -new g_aPluginSettings[e_PluginSettings]; -new g_aMenus[e_Menus]; -new g_aPlayers[MAXPLAYERS + 1][e_PlayerData]; -new String:g_sAdminFlags[16]; -new String:g_sPunishments[e_Punishments][15] = { "None", "Ban", "Beacon", "Blind", "Cheater", "Drug", "Freeze", "FreezeBomb", "Kick", "Slap", "Slay", "TimeBomb" }; - -public Plugin:myinfo = -{ - name = "Simple Spectate", - author = "Simple Plugins", - description = "Spectate a player and follow them through death.", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -}; - -/** -Sourcemod callbacks -*/ -public OnPluginStart() -{ - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook the game events - */ - LogAction(0, -1, "[SSPEC] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_team", HookPlayerChangeTeam, EventHookMode_Pre); - - /** - Need to create all of our console variables. - */ - CreateConVar("sm_spectate_version", PLUGIN_VERSION, "Sourcemod Spectate", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - g_aPluginCvar[hHudMode] = CreateConVar("sm_spectate_hudmode", "1", "Hud Mode: 0 = Hud Text | 1 = Panel/Menu (NOTE: The panel/menu will override other menus until canceled)"); - g_aPluginCvar[hMenuType] = CreateConVar("sm_spectate_menutype", "0", "Menu Mode: 0 = Panel | 1 = Menu"); - g_aPluginCvar[hRestrictHud] = CreateConVar("sm_spectate_restricthud", "0", "Restrict the hud to the admin flag provided"); - g_aPluginCvar[hBan] = CreateConVar("sm_spectate_ban", "1", "Enable/Disable ban option"); - g_aPluginCvar[hBanPerm] = CreateConVar("sm_spectate_banperm", "1", "Enable/Disable permanent ban option"); - g_aPluginCvar[hBeacon] = CreateConVar("sm_spectate_beacon", "1", "Enable/Disable beacon option"); - g_aPluginCvar[hBlind] = CreateConVar("sm_spectate_blind", "1", "Enable/Disable blind option"); - g_aPluginCvar[hCheater] = CreateConVar("sm_spectate_cheater", "1", "Enable/Disable cheater option"); - g_aPluginCvar[hDrug] = CreateConVar("sm_spectate_drug", "1", "Enable/Disable drug option"); - g_aPluginCvar[hFreeze] = CreateConVar("sm_spectate_freeze", "1", "Enable/Disable freeze option"); - g_aPluginCvar[hFreezeBomb] = CreateConVar("sm_spectate_freezebomb", "1", "Enable/Disable freezebomb option"); - g_aPluginCvar[hKick] = CreateConVar("sm_spectate_kick", "1", "Enable/Disable kick option"); - g_aPluginCvar[hSlap] = CreateConVar("sm_spectate_slap", "1", "Enable/Disable slap option"); - g_aPluginCvar[hSlay] = CreateConVar("sm_spectate_slay", "1", "Enable/Disable slay option"); - g_aPluginCvar[hTimeBomb] = CreateConVar("sm_spectate_timebomb", "1", "Enable/Disable timebomb option"); - - sm_spectate_adminflag = CreateConVar("sm_spectate_adminflag", "d", "Admin Flag to use for admin hud"); - - /** - Hook console variables - */ - new e_CvarHandles:iCvar; - for ( ; _:iCvar < sizeof(g_aPluginCvar); iCvar++) - { - HookConVarChange(g_aPluginCvar[iCvar], ConVarSettingsChanged); - } - - /** - Need to register the commands we are going to create and use. - */ - RegConsoleCmd("sm_spectate", Command_Spectate, "Spectate a player"); - RegConsoleCmd("sm_spec", Command_Spectate, "Spectate a player"); - RegConsoleCmd("sm_observe", Command_Spectate, "Spectate a player"); - RegConsoleCmd("sm_stopspec", Command_StopSpectate, "Stop Spectating a player"); - RegConsoleCmd("sm_endobserve", Command_StopSpectate, "Stop Spectating a player"); - RegConsoleCmd("sm_specinfo", Command_ToggleHud, "Toggles the hud display if in spectator"); - - /** - Now we have to deal with the admin menu. If the admin library is loaded call the function to add our items. - */ - new Handle:gTopMenu; - if (LibraryExists("adminmenu") && ((gTopMenu = GetAdminTopMenu()) != INVALID_HANDLE)) - { - OnAdminMenuReady(gTopMenu); - } - - /** - Deal with the hud - Thanks to Spray Trace plugin (http://forums.alliedmods.net/showthread.php?p=665448) - */ - new String:sHudGames[32]; - GetGameFolderName(sHudGames, sizeof(sHudGames)); - g_aPluginSettings[bCanHUD] = StrEqual(sHudGames,"tf",false) - || StrEqual(sHudGames,"hl2mp",false) - || StrEqual(sHudGames,"sourceforts",false) - || StrEqual(sHudGames,"obsidian",false) - || StrEqual(sHudGames,"left4dead",false) - || StrEqual(sHudGames,"l4d",false); - - if (g_aPluginSettings[bCanHUD]) - { - g_hHud = CreateHudSynchronizer(); - } - - /** - Load translations - */ - LoadTranslations ("common.phrases"); - LoadTranslations ("simplespectate.phrases"); - - /** - Create the config file - */ - AutoExecConfig(true); -} - -public OnConfigsExecuted() -{ - new e_CvarHandles:iCvar; - for ( ; _:iCvar < sizeof(g_aPluginCvarSettings); iCvar++) - { - g_aPluginCvarSettings[iCvar] = GetConVarBool(g_aPluginCvar[iCvar]); - } - - /* - Build the global menus - */ - g_aMenus[hSelectPlayer] = BuildSelectPlayerMenu(); - g_aMenus[hBanTime] = BuildBanTimeMenu(); - g_aMenus[hReason] = BuildReasonMenu(); - - GetConVarString(sm_spectate_adminflag, g_sAdminFlags, sizeof(g_sAdminFlags)); -} - -public OnAllPluginsLoaded() -{ - - /* - Check for steambans - */ - if (FindConVar("sbsrc_version") != INVALID_HANDLE) - { - g_aPluginSettings[bUseSteamBans] = true; - } - else - { - g_aPluginSettings[bUseSteamBans] = false; - } - - /* - Check for sourcebans - */ - if (FindConVar("sb_version") != INVALID_HANDLE) - { - g_aPluginSettings[bUseSourceBans] = true; - } - else - { - g_aPluginSettings[bUseSourceBans] = false; - } - - /* - Check for mysql bans - */ - if (FindConVar("mysql_bans_version") != INVALID_HANDLE) - { - g_aPluginSettings[bUseMySQLBans] = true; - } - else - { - g_aPluginSettings[bUseMySQLBans] = false; - } - - /* - Check for dukehacks - */ - new String:sExtError[256]; - new iExtStatus = GetExtensionFileStatus("dukehacks.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SSPEC] Dukehacks extension was not found."); - LogAction(0, -1, "[SSPEC] Plugin continued to load, but that feature will not be used."); - g_aPluginSettings[bUseDukehacks] = false; - } - else if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SSPEC] Dukehacks extension is loaded with errors."); - LogAction(0, -1, "[SSPEC] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SSPEC] Plugin continued to load, but that feature will not be used."); - g_aPluginSettings[bUseDukehacks] = false; - } - else if (iExtStatus == 1) - { - LogAction(0, -1, "[SSPEC] Dukehacks extension is loaded and will be used."); - g_aPluginSettings[bUseDukehacks] = true; - dhAddClientHook(CHK_TakeDamage, Hacks_TakeDamageHook); - } - - /* - Deal with some known plugin conflicts - */ - new Handle:hObserveClient = FindConVar("observe_version"); - if (hObserveClient != INVALID_HANDLE) - { - new String:sNewFile[PLATFORM_MAX_PATH + 1], String:sOldFile[PLATFORM_MAX_PATH + 1]; - BuildPath(Path_SM, sNewFile, sizeof(sNewFile), "plugins/disabled/observe.smx"); - BuildPath(Path_SM, sOldFile, sizeof(sOldFile), "plugins/observe.smx"); - - /** - Check if plugins/observe.smx exists, and if not, ignore - */ - if(!FileExists(sOldFile)) - { - return; - } - - /** - Check if plugins/disabled/observe.smx already exists, and if so, delete it - */ - if(FileExists(sNewFile)) - { - DeleteFile(sNewFile); - } - - /** - Unload plugins/observe.smx and move it to plugins/disabled/observe.smx - */ - LogAction(0, -1, "Detected the plugin ObserveClient"); - LogAction(0, -1, "ObserveClient plugin conflicts with Simple Spectate"); - LogAction(0, -1, "Unloading plugin and disabling ObserveClient plugin"); - ServerCommand("sm plugins unload observe"); - RenameFile(sNewFile, sOldFile); - } -} - -public OnLibraryRemoved(const String:name[]) -{ - if (StrEqual(name, "adminmenu")) - { - - /** - Looks like the admin menu was removed. Set the global. - */ - g_hAdminMenu = INVALID_HANDLE; - } - else if (StrEqual(name, "simpleplugins")) - { - //something - } -} - -public OnClientDisconnect(client) -{ - - /** - Cleanup the clients variables. - */ - ResetClient(client); - - /** - Run a loop and see if we are supposed to spectate this person (is a target) - */ - for(new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][iTargetIndex] == client) - { - - /** - Cleanup the clients variables. - */ - StopFollowingPlayer(i); - g_aPlayers[i][TargetPunishment] = Punish_None; - g_aPlayers[i][iBanTime] = 0; - } - } -} - -/** -Thirdparty callbacks -*/ -public SM_OnPlayerMoved(Handle:plugin, client, team) -{ - - /** - Make sure we called the move function - */ - if (plugin != GetMyHandle()) - { - return; - } - - //Nothing -} - -public Action:Hacks_TakeDamageHook(client, attacker, inflictor, Float:damage, &Float:multiplier, damagetype) -{ - - /** - Check for a valid client - */ - if (client > 0 && client <= MaxClients) - { - - /** - Check if the client taking damage is flagged as a cheater - */ - if (g_aPlayers[client][bIsFlaggedCheater]) - { - - /** - Check for fall damage and increase it - */ - if (damagetype & DMG_FALL) - { - multiplier *= 1000.0; - return Plugin_Changed; - } - } - } - - /** - Check for a valid attacker - */ - if (attacker > 0 && attacker <= MaxClients) - { - - /** - Check if the attacker causing the damage is flagged as a cheater - */ - if (g_aPlayers[attacker][bIsFlaggedCheater]) - { - - /** - Make sure they are not hurting themselves - */ - if (client != attacker) - { - - /** - Stop the damage - */ - multiplier *= 0.0; - return Plugin_Changed; - } - } - } - return Plugin_Continue; -} - -/** -Events -*/ -public Action:HookPlayerChangeTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get the client and team - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - new iTeam = GetEventInt(event, "team"); - - /** - Make sure it's a valid client - */ - if (iClient == 0) - { - return Plugin_Continue; - } - - /** - If it's a move to spectator start displaying the hud - */ - else if ((iTeam == g_aCurrentTeams[Spectator]) && (GetUserFlagBits(iClient) & ADMFLAG_GENERIC)) - { - StartDisplayingHud(iClient); - - /** - If the event was going to be broadcasted, we refire it so it is not broadcasted and stop this one - */ - if (!dontBroadcast) - { - new Handle:hEvent = CreateEvent("player_team"); - SetEventInt(hEvent, "userid", GetEventInt(event, "userid")); - SetEventInt(hEvent, "team", GetEventInt(event, "team")); - SetEventInt(hEvent, "oldteam", GetEventInt(event, "oldteam")); - SetEventBool(hEvent, "disconnect", GetEventBool(event, "disconnect")); - - if (g_CurrentMod == GameType_DOD || g_CurrentMod == GameType_L4D || g_CurrentMod == GameType_TF) - { - new String:sClientName[MAX_NAME_LENGTH + 1]; - GetClientName(client, sClientName, sizeof(sClientName)); - SetEventBool(hEvent, "autoteam", GetEventBool(event, "autoteam")); - SetEventBool(hEvent, "silent", true); - SetEventString(hEvent, "name", sClientName); - FireEvent(hEvent, true); - } - else - { - FireEvent(hEvent, true); - } - return Plugin_Handled; - } - } - - /** - Otherwise cleanup the client - */ - else - { - StopDisplayingHud(iClient); - StopFollowingPlayer(iClient); - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -/** -Commands -*/ -public Action:Command_Spectate(client, args) -{ - - /** - See if we already have a target (for toggling of command) - */ - if (g_aPlayers[client][iTargetIndex]) - { - - /** - We do, toggle it off - */ - StopFollowingPlayer(client); - - /** - We are done, bug out. - */ - return Plugin_Handled; - } - - /** - We don't... must want to enable it - See if we have some command arguments. - */ - new iCmdArgs = GetCmdArgs(); - if (iCmdArgs == 0) - { - - /** - We don't have any. Display the player menu. - */ - if (g_aPlayers[client][bIsDisplayingHud]) - { - StopDisplayingHud(client); - } - - DisplayMenu(BuildPlayerListMenu(), client, MENU_TIME_FOREVER); - return Plugin_Handled; - } - - /** - We have an argument. - Try to find the target. - */ - new String:sPlayer[128]; - GetCmdArg(1, sPlayer, sizeof(sPlayer)); - new iTarget = FindTarget(client, sPlayer, true, true); - if (iTarget == -1 || !IsClientInGame(iTarget)) - { - - /** - We couldn't find the target. Display the player menu. - */ - if (g_aPlayers[client][bIsDisplayingHud]) - { - StopDisplayingHud(client); - } - - DisplayMenu(BuildPlayerListMenu(), client, MENU_TIME_FOREVER); - return Plugin_Handled; - } - - /** - We found the target. - Call the stock function to spectate the target. - */ - StartFollowingPlayer(client, iTarget); - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_StopSpectate(client, args) -{ - - /** - Cleanup the clients variables. - */ - StopFollowingPlayer(client); - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_ToggleHud(client, args) -{ - - /** - Toggle the hud - */ - if (g_aPlayers[client][bIsDisplayingHud]) - { - StopDisplayingHud(client); - } - else - { - StartDisplayingHud(client); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -/** -Timers -*/ -public Action:Timer_ResetTarget(Handle:timer, any:client) -{ - - new iTargetID = GetEntPropEnt(client, Prop_Send, "m_hObserverTarget"); - - if (iTargetID != g_aPlayers[client][iTargetIndex] && IsPlayerAlive(g_aPlayers[client][iTargetIndex])) - { - - /** - Run the command to spectate the target from the clients prospectative. - */ - FakeClientCommandEx(client, "spec_player \"%N\"", g_aPlayers[client][iTargetIndex]); - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -public Action:Timer_UpdateHud(Handle:timer, any:client) -{ - - /** - Make sure the client is still in game and a spectator - */ - if (!IsClientConnected(client) || !IsClientInGame(client) || GetClientTeam(client) != g_aCurrentTeams[Spectator] || !g_aPlayers[client][bIsDisplayingHud]) - { - - /** - We are done, bug out - */ - g_aPlayers[client][hHudTimer] = INVALID_HANDLE; - g_aPlayers[client][bIsDisplayingHud] = false; - return Plugin_Stop; - } - /** - Get the target - */ - new iTarget = GetEntPropEnt(client, Prop_Send, "m_hObserverTarget"); - - /** - Check to make sure the target is valid - */ - if (iTarget <= 0 || iTarget > MaxClients) - { - return Plugin_Continue; - } - - /** - Get the spectator mode - */ - new iSpecMode = GetEntProp(client, Prop_Send, "m_iObserverMode"); - - /** - This is a double check to make sure we are in spec - If we are on a regular team, specmod would = none or zero - */ - if (iSpecMode == SPECMODE_NONE) - { - - /** - We are done, bug out - */ - g_aPlayers[client][hHudTimer] = INVALID_HANDLE; - g_aPlayers[client][bIsDisplayingHud] = false; - return Plugin_Stop; - } - - /** - Check the spectator mode - CSS has different index's so we have to check game type first - */ - if (g_CurrentMod == GameType_CSS) - { - switch (iSpecMode) - { - case SPECMODE_CSS_FIRSTPERSON: - { - //Do Nothing - } - case SPECMODE_CSS_3RDPERSON: - { - //Do Nothing - } - case SPECMODE_CSS_FREELOOK: - { - return Plugin_Continue; - } - } - } - else - { - switch (iSpecMode) - { - case SPECMODE_FIRSTPERSON: - { - //Do Nothing - } - case SPECMODE_3RDPERSON: - { - //Do Nothing - } - case SPECMODE_FREELOOK: - { - return Plugin_Continue; - } - } - } - - - /** - Display with the hud - */ - if (g_aPluginSettings[bCanHUD] && !g_aPluginCvarSettings[bHudMode]) - { - new String:sSteamID[64]; - GetClientAuthString(iTarget, sSteamID, sizeof(sSteamID)); - SetHudTextParams(0.04, 0.6, 0.5, 255, 50, 50, 255); - ShowSyncHudText(client, g_hHud, "%N [%s]", iTarget, sSteamID); - } - else if (g_aPluginCvarSettings[bHudMode]) - { - if (g_aPluginCvarSettings[bMenuType]) - { - DisplayMenu(BuildPlayerHudMenu(client, iTarget), client, 1); - } - else - { - new Handle:hPanel = BuildPlayerHudPanel(client, iTarget); - SendPanelToClient(hPanel, client, Panel_PlayerHud, 1); - CloseHandle(hPanel); - } - } - - /** - We are done, keep going! - */ - return Plugin_Continue; -} - -/** -Admin Menu Callbacks -*/ -public OnAdminMenuReady(Handle:topmenu) -{ - if (topmenu == g_hAdminMenu) - { - return; - } - g_hAdminMenu = topmenu; - new TopMenuObject:player_commands = FindTopMenuCategory(g_hAdminMenu, ADMINMENU_PLAYERCOMMANDS); - if (player_commands == INVALID_TOPMENUOBJECT) - { - return; - } - AddToTopMenu(g_hAdminMenu, - "sm_spectate", - TopMenuObject_Item, - AdminMenu_SpecPlayer, - player_commands, - "sm_spectate", - ADMFLAG_GENERIC); -} - -public AdminMenu_SpecPlayer(Handle:topmenu, TopMenuAction:action, TopMenuObject:object_id, param, String:buffer[], maxlength) -{ - if (action == TopMenuAction_DisplayOption) - { - - if (g_aPlayers[param][bIsDisplayingHud]) - { - StopDisplayingHud(param); - } - /** - See if we already have a target - */ - if (g_aPlayers[param][iTargetIndex]) - { - Format(buffer, maxlength, "Spectate(Disable)"); - } - else - { - Format(buffer, maxlength, "Spectate(Select Player)"); - } - } - else if (action == TopMenuAction_SelectOption) - { - - /** - See if we already have a target - */ - if (g_aPlayers[param][iTargetIndex]) - { - - /** - We do, toggle it off - */ - StopFollowingPlayer(param); - - /** - We are done, bug out. - */ - return; - } - else - { - DisplayMenu(BuildPlayerListMenu(), param, MENU_TIME_FOREVER); - } - } -} - -/** -Select Player Menu Callbacks -*/ -public Menu_PlayerList(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - /** - Get the selected player - */ - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - new iTarget = GetClientOfUserId(StringToInt(sSelection)); - - /** - Start following the player - */ - StartFollowingPlayer(param1, iTarget); - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_GENERIC) - { - - /** - Display the last admin menu - */ - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } - else if (param2 == MenuCancel_Exit && GetClientTeam(param1) == g_aCurrentTeams[Spectator]) - { - /** - They canceled the current menu, start the hud back up - */ - StartDisplayingHud(param1); - } - } - else if (action == MenuAction_End) - { - - /** - Not a global menu, close it - */ - CloseHandle(menu); - } -} - -public Menu_SelectPlayer(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - - /** - Get the selected player - */ - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (strcmp(sSelection, "Current", false) == 0) - { - /** - Get the current target - */ - new iTarget = GetEntPropEnt(param1, Prop_Send, "m_hObserverTarget"); - - /** - Check to make sure the target is valid - */ - if (iTarget <= 0 || iTarget > MaxClients) - { - PrintToChat(param1, "\x03[SM-SPEC]\x01 %t", "Invalid Target"); - DisplayMenu(BuildPlayerListMenu(), param1, MENU_TIME_FOREVER); - } - - /** - Start following the player - */ - StartFollowingPlayer(param1, iTarget); - } - else - { - - /** - They want to select a player, show the player list - */ - DisplayMenu(BuildPlayerListMenu(), param1, MENU_TIME_FOREVER); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - - /** - They canceled the current menu, start the hud back up - */ - StartDisplayingHud(param1); - } - } - else if (action == MenuAction_End) - { - /** - Its a global menu, leave it alive - */ - } -} - -/** -Punishment Menu Callbacks -*/ -public Menu_Punishments(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - - /** - Get the menu selection - */ - new String:sSelection[15]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - - /** - Search for the correct index - */ - new e_Punishments:Index = Punish_None; - for ( ; _:Index <= sizeof(g_sPunishments); Index++) - { - if (StrEqual(sSelection, g_sPunishments[Index])) - { - break; - } - } - - /** - Display the next menu - */ - if (Index == Punish_Ban) - { - - /** - Set the punishment index and display ban time menu - */ - g_aPlayers[param1][TargetPunishment] = Index; - DisplayMenu(g_aMenus[hBanTime], param1, MENU_TIME_FOREVER); - } - else if (Index == Punish_Cheater) - { - - /** - Ask for confirmation before we set punishment index - */ - new Handle:hPanel = BuildAdminCheaterPanel(); - SendPanelToClient(hPanel, param1, Panel_AdminCheater, MENU_TIME_FOREVER); - CloseHandle(hPanel); - } - else - { - - /** - Set the punishment index and display reason menu - */ - g_aPlayers[param1][TargetPunishment] = Index; - DisplayMenu(g_aMenus[hReason], param1, MENU_TIME_FOREVER); - } - } - else if (action == MenuAction_Cancel) - { - - /** - They canceled the current menu, start the hud back up - */ - StartDisplayingHud(param1); - } - else if (action == MenuAction_End) - { - - /** - Not a global menu, close it - */ - CloseHandle(menu); - } -} - -public Menu_BanTime(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - - /** - Get the menu selection - */ - new String:sSelection[15]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - - /** - Set the ban time global - */ - g_aPlayers[param1][iBanTime] = StringToInt(sSelection); - - /** - Display the reason menu - */ - DisplayMenu(g_aMenus[hReason], param1, MENU_TIME_FOREVER); - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - - /** - They canceled the current menu, start the hud back up - */ - StartDisplayingHud(param1); - } - } - else if (action == MenuAction_End) - { - /** - Its a global menu, leave it alive - */ - } -} - -public Menu_Reason(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - - /** - Get the menu selection - */ - new String:sSelection[15]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - - /** - Perform the punishment - */ - PerformPunishment(param1, g_aPlayers[param1][iTargetIndex], g_aPlayers[param1][TargetPunishment], sSelection, g_aPlayers[param1][iBanTime]); - - /** - Reactivate the hud if still in spectator - */ - if (GetClientTeam(param1) == g_aCurrentTeams[Spectator]) - { - StartDisplayingHud(param1); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - - /** - They canceled the current menu, start the hud back up - */ - StartDisplayingHud(param1); - } - } - else if (action == MenuAction_End) - { - /** - Its a global menu, leave it alive - */ - } -} - -public Panel_AdminCheater(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - if (param2 == 1) - { - - /** - Set the punishment index and display reason menu - */ - g_aPlayers[param1][TargetPunishment] = Punish_Cheater; - DisplayMenu(g_aMenus[hReason], param1, MENU_TIME_FOREVER); - } - else - { - - /** - Reactivate the hud if still in spectator - */ - if (GetClientTeam(param1) == g_aCurrentTeams[Spectator]) - { - StartDisplayingHud(param1); - } - } - } -} - -public Panel_PublicCheater(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - if (param2 == 1) - { - //Waiting for SB 2.0 and sb_submission to be published - } - else - { - - /** - Reactivate the hud if still in spectator - */ - if (GetClientTeam(param1) == g_aCurrentTeams[Spectator]) - { - StartDisplayingHud(param1); - } - } - } -} - -/** -Hud Menu/Panel Callbacks -*/ -public Menu_PlayerHud(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "stop", false)) - { - StopFollowingPlayer(param1); - } - else if (StrEqual(sSelection, "start", false)) - { - StopDisplayingHud(param1); - DisplayMenu(g_aMenus[hSelectPlayer], param1, MENU_TIME_FOREVER); - } - else if (StrEqual(sSelection, "removecheater", false)) - { - g_aPlayers[g_aPlayers[param1][iTargetIndex]][bIsFlaggedCheater] = false; - } - else if (StrEqual(sSelection, "punish", false)) - { - if (g_aPlayers[param1][iTargetIndex]) - { - StopDisplayingHud(param1); - DisplayMenu(BuildPunishmentMenu(param1), param1, MENU_TIME_FOREVER); - } - else - { - StopDisplayingHud(param1); - PrintToChat(param1, "\x03[SM-SPEC]\x01 %t", "Must Have Target"); - DisplayMenu(g_aMenus[hSelectPlayer], param1, MENU_TIME_FOREVER); - } - } - else if (StrEqual(sSelection, "reportcheater", false)) - { - if (g_aPlayers[param1][iTargetIndex]) - { - StopDisplayingHud(param1); - new Handle:hPanel = BuildPublicCheaterPanel(); - SendPanelToClient(hPanel, param1, Panel_PublicCheater, MENU_TIME_FOREVER); - CloseHandle(hPanel); - } - else - { - StopDisplayingHud(param1); - PrintToChat(param1, "\x03[SM-SPEC]\x01 %t", "Must Have Target"); - DisplayMenu(g_aMenus[hSelectPlayer], param1, MENU_TIME_FOREVER); - } - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_Interrupted) - { - if (GetClientMenu(param1) == MenuSource_External) - { - StopDisplayingHud(param1); - } - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } -} - -public Panel_PlayerHud(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - switch (param2) - { - case 1: - { - if (g_aPlayers[param1][iTargetIndex]) - { - StopFollowingPlayer(param1); - } - else - { - StopDisplayingHud(param1); - DisplayMenu(BuildSelectPlayerMenu(), param1, MENU_TIME_FOREVER); - } - } - case 2: - { - if (!g_aPlayers[param1][iTargetIndex]) - { - StopDisplayingHud(param1); - PrintToChat(param1, "\x03[SM-SPEC]\x01 %t", "Must Have Target"); - DisplayMenu(g_aMenus[hSelectPlayer], param1, MENU_TIME_FOREVER); - return; - } - - if ((GetUserFlagBits(param1) & ADMFLAG_GENERIC) || (GetUserFlagBits(param1) & ADMFLAG_ROOT)) - { - if (g_aPlayers[g_aPlayers[param1][iTargetIndex]][bIsFlaggedCheater] && (GetUserFlagBits(param1) & ADMFLAG_ROOT)) - { - //Remove cheater flag - g_aPlayers[g_aPlayers[param1][iTargetIndex]][bIsFlaggedCheater] = false; - } - else - { - //Punish menu - StopDisplayingHud(param1); - DisplayMenu(BuildPunishmentMenu(param1), param1, MENU_TIME_FOREVER); - } - } - else - { - //Report Cheater - new Handle:hPanel = BuildPublicCheaterPanel(); - SendPanelToClient(hPanel, param1, Panel_PublicCheater, MENU_TIME_FOREVER); - CloseHandle(hPanel); - } - } - case 3: - { - StopDisplayingHud(param1); - } - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_Interrupted) - { - if (GetClientMenu(param1) == MenuSource_External) - { - StopDisplayingHud(param1); - } - } - } -} - - -/** -Stock functions -*/ -stock StartFollowingPlayer(client, target) -{ - - /** - If we have an open timer, close it. - */ - if (g_aPlayers[client][hTargetTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[client][hTargetTimer]); - g_aPlayers[client][hTargetTimer] = INVALID_HANDLE; - } - - /** - Make sure the target is on a non spectator team, and the client != target - */ - if (client == target) - { - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Yourself"); - return; - } - new iTargetTeam = GetClientTeam(target); - if (iTargetTeam == g_aCurrentTeams[Spectator] || iTargetTeam == g_aCurrentTeams[Unknown]) - { - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Spectator"); - return; - } - - /** - Check to see if client is already a spectator - */ - if (GetClientTeam(client) != g_aCurrentTeams[Spectator]) - { - - /** - Client is not a spectator, lets move them to spec. - */ - SM_MovePlayer(client, g_aCurrentTeams[Spectator]); - } - - /** - If we are using steambans call sb_status - */ - if (g_aPluginSettings[bUseSteamBans]) - { - FakeClientCommandEx(client, "sb_status"); - } - - - /** - Set the global and start to spectate the target. - Making sure it's long enough to deal with moving the client to spec if we had to. - */ - new String:sTargetName[MAX_NAME_LENGTH + 1]; - GetClientName(target, sTargetName, sizeof(sTargetName)); - g_aPlayers[client][iTargetIndex] = target; - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Spectating", sTargetName); - g_aPlayers[client][hTargetTimer] = CreateTimer(0.5, Timer_ResetTarget, client, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); - if (!g_aPlayers[client][bIsDisplayingHud] && GetClientTeam(client) == g_aCurrentTeams[Spectator]) - { - StartDisplayingHud(client); - } -} - -stock StopFollowingPlayer(client) -{ - - /** - If we have an open timer, close it. - */ - if (g_aPlayers[client][hTargetTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[client][hTargetTimer]); - } - - /** - Tell the client we can't spec his target anymore... if they are in game. - */ - if (IsClientInGame(client) && g_aPlayers[client][iTargetIndex] != 0) - { - new String:sTargetName[MAX_NAME_LENGTH + 1]; - GetClientName(g_aPlayers[client][iTargetIndex], sTargetName, sizeof(sTargetName)); - if (!IsClientConnected(g_aPlayers[client][iTargetIndex]) || !IsClientInGame(g_aPlayers[client][iTargetIndex])) - { - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Target Left"); - } - else - { - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Stopped spectating", sTargetName); - } - } - - /** - Null the globals. - */ - g_aPlayers[client][iTargetIndex] = 0; - g_aPlayers[client][hTargetTimer] = INVALID_HANDLE; -} - -stock StartDisplayingHud(client) -{ - if (g_aPluginCvarSettings[bRestrictHud] && !SM_IsValidAdmin(client, g_sAdminFlags)) - { - return; - } - else - { - /** - Double check the hud timer - We should not have one, but if we do, lets cancel it for the current callback - */ - StopDisplayingHud(client); - - /** - Now we can safely display the hud and make sure the current stored handle is the current timer - */ - g_aPlayers[client][bIsDisplayingHud] = true; - g_aPlayers[client][hHudTimer] = CreateTimer(0.5, Timer_UpdateHud, client, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); - } -} - -stock StopDisplayingHud(client) -{ - if (g_aPlayers[client][hHudTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[client][hHudTimer]); - } - g_aPlayers[client][hHudTimer] = INVALID_HANDLE; - g_aPlayers[client][bIsDisplayingHud] = false; -} - -stock ResetClient(client) -{ - StopFollowingPlayer(client); - StopDisplayingHud(client); - - g_aPlayers[client][bIsFlaggedCheater] = false; - g_aPlayers[client][TargetPunishment] = Punish_None; - g_aPlayers[client][iBanTime] = -1; -} - -stock PerformPunishment(client, target, e_Punishments:punishment, const String:reason[], time = 300) -{ - new String:sTargetName[MAX_NAME_LENGTH + 1], - String:sTargetID[64]; - - /** - The target could have left the game by the time we get here - Check for a valid target - */ - if (!IsClientConnected(target) || !IsClientInGame(target)) - { - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Target Left"); - return; - } - - GetClientName(target, sTargetName, sizeof(sTargetName)); - GetClientAuthString(target, sTargetID, sizeof(sTargetID)); - - switch (punishment) - { - case Punish_Kick: - { - KickClient(g_aPlayers[client][iTargetIndex], "%s", reason); - } - case Punish_Ban: - { - if (g_aPluginSettings[bUseSourceBans]) - { - ClientCommand(client, "sm_ban #%d %d \"%s\"", GetClientUserId(target), time, reason); - } - else if (g_aPluginSettings[bUseMySQLBans]) - { - ClientCommand(client, "mysql_ban #%d %d \"%s\"", GetClientUserId(target), time, reason); - } - else - { - BanClient(target, time, BANFLAG_AUTHID, reason, reason); - } - } - case Punish_Cheater: - { - g_aPlayers[target][bIsFlaggedCheater] = true; - } - case Punish_Beacon: - { - ClientCommand(client, "sm_beacon \"%s\"", sTargetName); - } - case Punish_Blind: - { - ClientCommand(client, "sm_blind \"%s\"", sTargetName); - } - case Punish_Drug: - { - ClientCommand(client, "sm_drug \"%s\"", sTargetName); - } - case Punish_Freeze: - { - ClientCommand(client, "sm_freeze \"%s\"", sTargetName); - } - case Punish_FreezeBomb: - { - ClientCommand(client, "sm_freezebomb \"%s\"", sTargetName); - } - case Punish_Slap: - { - ClientCommand(client, "sm_slap \"%s\" 10", sTargetName); - } - case Punish_Slay: - { - ClientCommand(client, "sm_slay \"%s\"", sTargetName); - } - case Punish_TimeBomb: - { - ClientCommand(client, "sm_timebomb \"%s\"", sTargetName); - } - } - - if (punishment == Punish_Cheater) - { - LogAction(client, target, "[SM SPEC] %N marked %N(%s) with a %s flag for %s", client, target, sTargetID, g_sPunishments[punishment], reason); - } - else - { - ShowActivity(client, "%t", "Punished", sTargetName, g_sPunishments[punishment], reason); - LogAction(client, target, "[SM SPEC] %N punished %N(%s) with a %s for %s", client, target, sTargetID, g_sPunishments[punishment], reason); - } - - /** - Null the globals. - */ - g_aPlayers[client][TargetPunishment] = Punish_None; - g_aPlayers[client][iBanTime] = -1; -} - -/** -Build the menu of player names -*/ -stock Handle:BuildPlayerListMenu() -{ - new Handle:hMenu = CreateMenu(Menu_PlayerList); - AddTargetsToMenu(hMenu, 0, true, false); - SetMenuTitle(hMenu, "Select A Player:"); - SetMenuExitBackButton(hMenu, true); - return hMenu; -} - -/** -Build the select player menu (current or list of players) -*/ -stock Handle:BuildSelectPlayerMenu() -{ - new Handle:hMenu = CreateMenu(Menu_SelectPlayer); - SetMenuTitle(hMenu, "Select A Player:"); - AddMenuItem(hMenu, "Current", "Current Target"); - AddMenuItem(hMenu, "List", "Player List"); - SetMenuExitBackButton(hMenu, true); - return hMenu; -} - -/** -Build the punishmenu menu -*/ -stock Handle:BuildPunishmentMenu(iClient) -{ - new Handle:hMenu = CreateMenu(Menu_Punishments); - SetMenuTitle(hMenu, "Select A Punishment:"); - SetMenuExitBackButton(hMenu, true); - SetMenuExitButton(hMenu, true); - - if (g_aPluginCvarSettings[bKick] && ((GetUserFlagBits(iClient) & ADMFLAG_GENERIC) || (GetUserFlagBits(iClient) & ADMFLAG_ROOT))) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Kick], "Kick"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Kick], "Kick", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bBan] && ((GetUserFlagBits(iClient) & ADMFLAG_GENERIC) || (GetUserFlagBits(iClient) & ADMFLAG_ROOT))) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Ban], "Ban"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Ban], "Ban", ITEMDRAW_DISABLED); - } - - if (g_aPluginSettings[bUseDukehacks] && g_aPluginCvarSettings[bCheater] && (GetUserFlagBits(iClient) & ADMFLAG_ROOT)) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Cheater], "Flag As Cheater"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Cheater], "Flag As Cheater", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bBeacon]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Beacon], "Beacon"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Beacon], "Beacon", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bBlind]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Blind], "Blind"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Blind], "Blind", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bDrug]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Drug], "Drug"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Drug], "Drug", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bFreeze]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Freeze], "Freeze"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Freeze], "Freeze", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bFreezebomb]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_FreezeBomb], "Freeze Bomb"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_FreezeBomb], "Freeze Bomb", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bSlap]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Slap], "Slap"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Slap], "Slap", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bSlay]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Slay], "Slay"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Slay], "Slay", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bTimeBomb]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_TimeBomb], "Time Bomb"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_TimeBomb], "Time Bomb", ITEMDRAW_DISABLED); - } - - return hMenu; -} - -/** -Build the punishmenu menu -*/ -stock Handle:BuildBanTimeMenu() -{ - new Handle:hMenu = CreateMenu(Menu_BanTime); - SetMenuTitle(hMenu, "Select Ban Type:"); - - if (g_aPluginCvarSettings[bBanPerm]) - { - AddMenuItem(hMenu, "permban", "Permanent"); - } - else - { - AddMenuItem(hMenu, "permban", "Permanent", ITEMDRAW_DISABLED); - } - - AddMenuItem(hMenu, "10", "10 Minutes"); - AddMenuItem(hMenu, "30", "30 Minutes"); - AddMenuItem(hMenu, "60", "1 Hour"); - AddMenuItem(hMenu, "240", "4 Hours"); - AddMenuItem(hMenu, "1440", "1 Day"); - AddMenuItem(hMenu, "10080", "1 Week"); - - SetMenuExitBackButton(hMenu, true); - return hMenu; -} - -/** -Build the punishmenu menu -*/ -stock Handle:BuildReasonMenu() -{ - new Handle:hMenu = CreateMenu(Menu_Reason); - SetMenuTitle(hMenu, "Select A Reason:"); - - AddMenuItem(hMenu, "Abusive", "Abusive"); - AddMenuItem(hMenu, "Racism", "Racism"); - AddMenuItem(hMenu, "General cheating/exploits", "General cheating/exploits"); - AddMenuItem(hMenu, "Wallhack", "Wallhack"); - AddMenuItem(hMenu, "Aimbot", "Aimbot"); - AddMenuItem(hMenu, "Speedhacking", "Speedhacking"); - AddMenuItem(hMenu, "Mic spamming", "Mic spamming"); - AddMenuItem(hMenu, "Admin disrepect", "Admin disrepect"); - AddMenuItem(hMenu, "Camping", "Camping"); - AddMenuItem(hMenu, "Team killing", "Team killing"); - AddMenuItem(hMenu, "Unacceptable Spray", "Unacceptable Spray"); - AddMenuItem(hMenu, "Breaking Server Rules", "Breaking Server Rules"); - AddMenuItem(hMenu, "Other", "Other"); - - SetMenuExitBackButton(hMenu, true); - return hMenu; -} - -/** -Build the cheater displays -*/ -stock Handle:BuildAdminCheaterPanel() -{ - - /** - Create the menu and set the menu options. - */ - new Handle:hPanel = CreatePanel(); - SetPanelTitle(hPanel, "Simple Spectator:"); - - DrawPanelText(hPanel, "Are you sure you want to"); - DrawPanelText(hPanel, "flag this player as a cheater?"); - DrawPanelText(hPanel, "They will not be able to damage"); - DrawPanelText(hPanel, "anyone and die on fall damage."); - DrawPanelItem(hPanel, "Yes"); - DrawPanelItem(hPanel, "No"); - - return hPanel; -} - -stock Handle:BuildPublicCheaterPanel() -{ - - /** - Create the menu and set the menu options. - */ - new Handle:hPanel = CreatePanel(); - SetPanelTitle(hPanel, "Simple Spectator:"); - - DrawPanelText(hPanel, "Are you sure you want to"); - DrawPanelText(hPanel, "submit this player as a cheater?"); - DrawPanelItem(hPanel, "Yes (Not Implemented Yet)", ITEMDRAW_DISABLED); - DrawPanelItem(hPanel, "No"); - return hPanel; -} - -/** -Build the hud displays -*/ -stock Handle:BuildPlayerHudMenu(iClient, iTarget) -{ - - /** - Create all the string variables we will need - */ - new String:sTargetName[MAX_NAME_LENGTH + 1], - String:sTargetID[64], - String:sTargetIP[16]; - - new String:sDisplayName[MAX_NAME_LENGTH + 1], - String:sDisplayID[64], - String:sDisplayIP[64], - String:sDisplayFrags[16], - String:sDisplayDeaths[16]; - - new iTargetFrags, - iTargetDeaths; - - /** - Get the targets information - */ - GetClientName(iTarget, sTargetName, sizeof(sTargetName)); - GetClientIP(iTarget, sTargetIP, sizeof(sTargetIP)); - GetClientAuthString(iTarget, sTargetID, sizeof(sTargetID)); - iTargetFrags = GetClientFrags(iTarget); - iTargetDeaths = GetClientDeaths(iTarget); - - /** - Format the strings for the menu - */ - Format(sDisplayName, sizeof(sDisplayName), "Player: %s", sTargetName); - Format(sDisplayID, sizeof(sDisplayID), "Steam ID: %s", sTargetID); - Format(sDisplayIP, sizeof(sDisplayIP), "IP Address: %s", sTargetIP); - Format(sDisplayFrags, sizeof(sDisplayFrags), "Kills: %i", iTargetFrags); - Format(sDisplayDeaths, sizeof(sDisplayDeaths), "Deaths: %i", iTargetDeaths); - - /** - Create the menu and set the menu options. - */ - new Handle:hMenu = CreateMenu(Menu_PlayerHud); - SetMenuExitBackButton(hMenu, false); - SetMenuTitle(hMenu, "Simple Spectator"); - - AddMenuItem(hMenu, "name", sDisplayName, ITEMDRAW_DISABLED); - AddMenuItem(hMenu, "steamid", sDisplayID, ITEMDRAW_DISABLED); - - if (SM_IsValidAdmin(iClient, g_sAdminFlags)) - { - AddMenuItem(hMenu, "ip", sDisplayIP, ITEMDRAW_DISABLED); - } - - AddMenuItem(hMenu, "kills", sDisplayFrags, ITEMDRAW_DISABLED); - AddMenuItem(hMenu, "deaths", sDisplayDeaths, ITEMDRAW_DISABLED); - - if (g_aPlayers[iClient][iTargetIndex]) - { - AddMenuItem(hMenu, "stop", "Stop Following"); - } - else - { - AddMenuItem(hMenu, "start", "Follow Player"); - } - - if ((GetUserFlagBits(iClient) & ADMFLAG_GENERIC) || (GetUserFlagBits(iClient) & ADMFLAG_ROOT)) - { - if (g_aPlayers[iTarget][bIsFlaggedCheater] && (GetUserFlagBits(iClient) & ADMFLAG_ROOT)) - { - AddMenuItem(hMenu, "removecheater", "Remove Cheater Flag"); - } - else - { - if (CanUserTarget(iClient, iTarget)) - { - AddMenuItem(hMenu, "punish", "Punish Player"); - } - else - { - AddMenuItem(hMenu, "punish", "Punish Player (Immune)", ITEMDRAW_DISABLED); - } - } - } - else - { - AddMenuItem(hMenu, "reportcheater", "Report Cheater"); - } - - SetMenuPagination(hMenu, MENU_NO_PAGINATION); - SetMenuExitButton(hMenu, true); - return hMenu; -} - -stock Handle:BuildPlayerHudPanel(iClient, iTarget) -{ - - /** - Create all the string variables we will need - */ - new String:sTargetName[MAX_NAME_LENGTH + 1], - String:sTargetID[64], - String:sTargetIP[16]; - - new String:sDisplayName[MAX_NAME_LENGTH + 1], - String:sDisplayID[64], - String:sDisplayIP[64], - String:sDisplayFrags[16], - String:sDisplayDeaths[16]; - - new iTargetFrags, - iTargetDeaths; - - /** - Get the targets information - */ - GetClientName(iTarget, sTargetName, sizeof(sTargetName)); - GetClientIP(iTarget, sTargetIP, sizeof(sTargetIP)); - GetClientAuthString(iTarget, sTargetID, sizeof(sTargetID)); - iTargetFrags = GetClientFrags(iTarget); - iTargetDeaths = GetClientDeaths(iTarget); - - /** - Format the strings for the menu - */ - Format(sDisplayName, sizeof(sDisplayName), "Player: %s", sTargetName); - Format(sDisplayID, sizeof(sDisplayID), "Steam ID: %s", sTargetID); - Format(sDisplayIP, sizeof(sDisplayIP), "IP Address: %s", sTargetIP); - Format(sDisplayFrags, sizeof(sDisplayFrags), "Kills: %i", iTargetFrags); - Format(sDisplayDeaths, sizeof(sDisplayDeaths), "Deaths: %i", iTargetDeaths); - - /** - Create the menu and set the menu options. - */ - new Handle:hPanel = CreatePanel(); - SetPanelTitle(hPanel, "Simple Spectator"); - - DrawPanelText(hPanel, "Player Information:"); - DrawPanelText(hPanel, sDisplayName); - DrawPanelText(hPanel, sDisplayID); - if (SM_IsValidAdmin(iClient, g_sAdminFlags)) - { - DrawPanelText(hPanel, sDisplayIP); - } - - DrawPanelText(hPanel, sDisplayFrags); - DrawPanelText(hPanel, sDisplayDeaths); - - if (g_aPlayers[iClient][iTargetIndex]) - { - DrawPanelItem(hPanel, "Stop Following"); - } - else - { - DrawPanelItem(hPanel, "Follow Player"); - } - - if ((GetUserFlagBits(iClient) & ADMFLAG_GENERIC) || (GetUserFlagBits(iClient) & ADMFLAG_ROOT)) - { - if (g_aPlayers[iTarget][bIsFlaggedCheater] && (GetUserFlagBits(iClient) & ADMFLAG_ROOT)) - { - DrawPanelItem(hPanel, "Remove Cheater Flag"); - } - else - { - if (CanUserTarget(iClient, iTarget)) - { - DrawPanelItem(hPanel, "Punish Player"); - } - else - { - DrawPanelItem(hPanel, "Punish Player (Immune)", ITEMDRAW_DISABLED); - } - } - } - else - { - DrawPanelItem(hPanel, "Report Cheater"); - } - - DrawPanelItem(hPanel, "Close Hud Panel"); - return hPanel; -} - -/** -Adjust the settings if a convar was changed -*/ -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - for (new iCvar = 0 ; _:iCvar < sizeof(g_aPluginCvarSettings); iCvar++) - { - if (g_aPluginCvar[_:iCvar] == convar) - { - if (StringToInt(newValue) == 1) - { - g_aPluginCvarSettings[_:iCvar] = true; - } - else - { - g_aPluginCvarSettings[_:iCvar] = false; - } - } - } - - /* - ReBuild the global menu that depends on cvars - */ - g_aMenus[hBanTime] = BuildBanTimeMenu(); - - /** - Run a loop to reset the hud - */ - for(new i = 1; i <= MaxClients; i++) - { - StopDisplayingHud(i); - if (IsClientConnected(i) && IsClientInGame(i) && GetClientTeam(i) == g_aCurrentTeams[Spectator]) - { - StartDisplayingHud(i); - } - } -} diff --git a/Simple AutoScrambler/addons/sourcemod/scripting/simple-teambalancer.sp b/Simple AutoScrambler/addons/sourcemod/scripting/simple-teambalancer.sp deleted file mode 100644 index 3302255..0000000 --- a/Simple AutoScrambler/addons/sourcemod/scripting/simple-teambalancer.sp +++ /dev/null @@ -1,1797 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Team Balancer -Description: - Balances teams based upon player count - Player will not be balanced more than once in 5 (default) mins - Buddy system tries to keep buddies together - Ability to prioritize players - Ability to force players to accept the new team - Admins are immune -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include -#include - -#define PLUGIN_VERSION "2.1.$Rev$" - -enum PlayerData -{ - Handle:hBalanceTimer, - Handle:hForcedTimer, - bool:bSwitched, - bool:bFlagCarrier -}; - -/** - Global convar handles - */ -new Handle:stb_enabled = INVALID_HANDLE; -new Handle:stb_buddyenabled = INVALID_HANDLE; -new Handle:stb_logactivity = INVALID_HANDLE; -new Handle:stb_logactivity2 = INVALID_HANDLE; -new Handle:stb_unbalancelimit = INVALID_HANDLE; -new Handle:stb_deadonly = INVALID_HANDLE; -new Handle:stb_priorityenabled = INVALID_HANDLE; -new Handle:stb_uberlevel = INVALID_HANDLE; -new Handle:stb_balancedelay = INVALID_HANDLE; -new Handle:stb_livingplayerswitchdelay = INVALID_HANDLE; -new Handle:stb_livingplayercheckdelay = INVALID_HANDLE; -new Handle:stb_roundstartdelay = INVALID_HANDLE; -new Handle:stb_switchbackforced = INVALID_HANDLE; -new Handle:stb_adminflag = INVALID_HANDLE; -new Handle:stb_buddyrestriction = INVALID_HANDLE; -new Handle:stb_convarcontrol = INVALID_HANDLE; - -/** - Built-in cvars handles - */ -new Handle:stb_mp_autoteambalance = INVALID_HANDLE; -new Handle:stb_mp_teams_unbalance_limit = INVALID_HANDLE; -new Handle:TFGameModeArena = INVALID_HANDLE; - -/** - Timer handles - */ -new Handle:g_hBalanceTimer = INVALID_HANDLE; -new Handle:g_hLivingPlayerCheckTimer = INVALID_HANDLE; - -/** - Player arrays - */ -new g_aPlayers[MAXPLAYERS + 1][PlayerData]; - -/** -Global bools -*/ -new bool:g_bIsEnabled = true; -new bool:g_bPriorityPlayers = true; -new bool:g_bBuddyRestriction = false; -new bool:g_bLogActivity = false; -new bool:g_bLogActivity2 = false; -new bool:g_bDeadOnly = false; -new bool:g_bConVarControl = true; -new bool:g_bBuddyEnabled = true; -new bool:g_bBalanceInProgress = false; -new bool:g_bRoundStart = false; -new bool:g_bRoundEnd = false; -new bool:g_bSuddenDeath = false; -new bool:g_bIsArenaMode = false; - -/** - Global strings/integers/floats - */ -new g_iUnbalanceLimit, g_iLivingPlayerSwitchDelay, g_iLivingPlayerCheckDelay; -new g_iRoundStartDelay, g_iSwitchBackForced, g_iBalanceDelay; -new Float:g_fUberLevel; -new g_iOwnerOffset; -new String:g_sAdminFlag[5]; - -public Plugin:myinfo = -{ - name = "Simple Team Balancer", - author = "Simple Plugins", - description = "Balances teams based upon player count.", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -} - -public OnPluginStart() -{ - - /** - Create console variables - */ - CreateConVar("stb_version", PLUGIN_VERSION, "Simple Team Balancer", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - stb_enabled = CreateConVar("stb_enabled", "1", "Enable or Disable Simple Team Balancer", _, true, 0.0, true, 1.0); - stb_priorityenabled = CreateConVar("stb_priorityenabled", "1", "Enable or Disable the prioritization of living players", _, true, 0.0, true, 1.0); - stb_buddyrestriction = CreateConVar("stb_buddyrestriction", "0", "Enable or Disable Admin Only buddy lists", _, true, 0.0, true, 1.0); - stb_logactivity = CreateConVar("stb_logactivity", "0", "Enable or Disable the disaplying of events in the log", _, true, 0.0, true, 1.0); - stb_logactivity2 = CreateConVar("stb_logactivity2", "0", "Enable or Disable the disaplying of detailed events in the log (WILL SPAM LOG)", _, true, 0.0, true, 1.0); - stb_deadonly = CreateConVar("stb_deadonly", "0", "Enable or Disable the switching of only dead players", _, true, 0.0, true, 1.0); - stb_convarcontrol = CreateConVar("stb_convarcontrol", "1", "Enable or Disable the control of builtin console variables", _, true, 0.0, true, 1.0); - stb_buddyenabled = CreateConVar("stb_buddyenabled", "1", "Enable or Disable the buddy system", _, true, 0.0, true, 1.0); - stb_unbalancelimit = CreateConVar("stb_unbalancelimit", "2", "Amount of players teams are ALLOWED to be unbalanced by", _, true, 1.0, true, 32.0); - stb_balancedelay = CreateConVar("stb_balancedelay", "10", "Delay in seconds to start an autobalance"); - stb_livingplayerswitchdelay = CreateConVar("stb_livingplayerswitchdelay", "20", "Delay in seconds to switch living players once selected"); - stb_livingplayercheckdelay = CreateConVar("stb_livingplayercheckdelay", "10", "Delay in seconds to start checking living players once teams become unbalanced"); - stb_roundstartdelay = CreateConVar("stb_roundstartdelay", "15", "Delay in seconds to start balancing teams after the start of a round"); - stb_switchbackforced = CreateConVar("stb_switchbackforced", "300", "Amount of time in seconds to not switch a player twice and force the team if enabled"); - stb_uberlevel = CreateConVar("stb_uberlevel", "1.0", "Min uber level medic must have to have priority over other living players. Setting to 0 will rarely switch a living medic", _, true, 0.0, true, 1.0); - stb_adminflag = CreateConVar("stb_adminflag", "a", "Admin flag to use for immunity. Must be a in char format."); - stb_mp_autoteambalance = FindConVar("mp_autoteambalance"); - stb_mp_teams_unbalance_limit = FindConVar("mp_teams_unbalance_limit"); - - /** - Removing the notify tags from the built in cvars. We dont want spam. - */ - if (stb_mp_autoteambalance != INVALID_HANDLE) - { - SetConVarFlags(stb_mp_autoteambalance, GetConVarFlags(stb_mp_autoteambalance)^FCVAR_NOTIFY); - } - if (stb_mp_teams_unbalance_limit != INVALID_HANDLE) - { - SetConVarFlags(stb_mp_teams_unbalance_limit, GetConVarFlags(stb_mp_teams_unbalance_limit)^FCVAR_NOTIFY); - } - - /** - Hook console variables - */ - HookConVarChange(stb_enabled, ConVarSettingsChanged); - HookConVarChange(stb_priorityenabled, ConVarSettingsChanged); - HookConVarChange(stb_buddyrestriction, ConVarSettingsChanged); - HookConVarChange(stb_logactivity, ConVarSettingsChanged); - HookConVarChange(stb_logactivity2, ConVarSettingsChanged); - HookConVarChange(stb_deadonly, ConVarSettingsChanged); - HookConVarChange(stb_convarcontrol, ConVarSettingsChanged); - HookConVarChange(stb_buddyenabled, ConVarSettingsChanged); - HookConVarChange(stb_unbalancelimit, ConVarSettingsChanged); - HookConVarChange(stb_balancedelay, ConVarSettingsChanged); - HookConVarChange(stb_livingplayerswitchdelay, ConVarSettingsChanged); - HookConVarChange(stb_livingplayercheckdelay, ConVarSettingsChanged); - HookConVarChange(stb_roundstartdelay, ConVarSettingsChanged); - HookConVarChange(stb_switchbackforced, ConVarSettingsChanged); - HookConVarChange(stb_uberlevel, ConVarSettingsChanged); - HookConVarChange(stb_mp_autoteambalance, ConVarSettingsChanged); - HookConVarChange(stb_mp_teams_unbalance_limit, ConVarSettingsChanged); - - /** - Create console commands - */ - RegConsoleCmd("sm_buddy", Command_AddBalanceBuddy, "Add a balance buddy"); - RegConsoleCmd("sm_lockbuddy", Command_LockBuddy, "Locks your balance buddy selection"); - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook the game events - */ - LogAction(0, -1, "[STB] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_death", HookPlayerDeath, EventHookMode_Post); - HookEvent("player_team", HookPlayerChangeTeam, EventHookMode_Post); - switch (g_CurrentMod) - { - case GameType_TF: - { - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - HookEvent("teamplay_suddendeath_begin", HookSuddenDeathBegin, EventHookMode_PostNoCopy); - HookEvent("teamplay_flag_event", HookFlagEvent, EventHookMode_Post); - TFGameModeArena = FindConVar("tf_gamemode_arena"); - g_iOwnerOffset = FindSendPropInfo("CBaseObject", "m_hBuilder"); - } - case GameType_DOD: - { - HookEvent("dod_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_Post); - } - default: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - } - } - - /** - Load translations and .cfg file - */ - LoadTranslations ("simpleteambalancer.phrases"); - AutoExecConfig(true, "plugin.simpleteambalancer"); - LogAction(0, -1, "[STB] Simple Team Balancer is loaded."); -} - -public OnAllPluginsLoaded() -{ - //something -} - -public OnLibraryRemoved(const String:name[]) -{ - //something -} - -public OnConfigsExecuted() -{ - - /** - Load up global variables - */ - g_bIsEnabled = GetConVarBool(stb_enabled); - g_bBuddyEnabled = GetConVarBool(stb_buddyenabled); - g_bLogActivity = GetConVarBool(stb_logactivity); - g_bLogActivity2 = GetConVarBool(stb_logactivity2); - g_bDeadOnly = GetConVarBool(stb_deadonly); - g_bPriorityPlayers = GetConVarBool(stb_priorityenabled); - g_bBuddyRestriction = GetConVarBool(stb_buddyrestriction); - g_bConVarControl = GetConVarBool(stb_convarcontrol); - g_fUberLevel = GetConVarFloat(stb_uberlevel); - g_iUnbalanceLimit = GetConVarInt(stb_unbalancelimit); - g_iBalanceDelay = GetConVarInt(stb_balancedelay); - g_iLivingPlayerSwitchDelay = GetConVarInt(stb_livingplayerswitchdelay); - g_iLivingPlayerCheckDelay = GetConVarInt(stb_livingplayercheckdelay); - g_iRoundStartDelay = GetConVarInt(stb_roundstartdelay); - g_iSwitchBackForced = GetConVarInt(stb_switchbackforced); - GetConVarString(stb_adminflag, g_sAdminFlag, sizeof(g_sAdminFlag)); - - /** - Report enabled - */ - if (g_bIsEnabled) - { - LogAction(0, -1, "[STB] Simple Team Balancer is ENABLED."); - } - else - { - LogAction(0, -1, "[STB] Simple Team Balancer is DISABLED."); - } - - - /** - Report log activity - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Log Activity ENABLED."); - } - else - { - LogAction(0, -1, "[STB] Log Activity DISABLED."); - } - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Detailed Log Activity ENABLED."); - } - else - { - LogAction(0, -1, "[STB] Detailed Log Activity DISABLED."); - } -} - -public OnMapStart() -{ - - /** - Check for arena mode - */ - if (g_CurrentMod == GameType_TF && GetConVarBool(TFGameModeArena)) - { - g_bIsArenaMode = true; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Simple Team Balancer detected arena mode and will be bypassed"); - } - } - else - { - g_bIsArenaMode = false; - } - - /** - Reset the globals - */ - g_bBalanceInProgress = false; - g_bRoundStart = false; - g_bRoundEnd = false; - g_bSuddenDeath = false; - - /** - Set the built-in convars - */ - SetGameCvars(); -} - -public OnClientPostAdminCheck(client) -{ - - /** - Make sure its a valid connected client and buddy system is enabled - */ - if (client == 0 || !g_bIsEnabled || !IsClientConnected(client) || !g_bBuddyEnabled) - { - return; - } - - /** - Make sure if its set for admins only they have the flags - */ - if (g_bBuddyRestriction && !SM_IsValidAdmin(client, g_sAdminFlag)) - { - return; - } - - /** - Start the advertisement timer - */ - CreateTimer (60.0, Timer_WelcomeAdvert, client); -} - -public OnClientDisconnect(client) -{ - - /** - Call stock function to cleaup - */ - CleanUp(client); -} - -public OnClientDisconnect_Post(client) -{ - - /** - Determine if we need a balance - */ - if (OkToBalance() && IsUnbalanced() && !g_bBalanceInProgress) - { - - /** - No balance in progress but balance is needed - */ - StartABalance(); - } -} - -public SM_OnPlayerMoved(Handle:plugin, client, team) -{ - - /** - Make sure we called the move function - */ - if (plugin != GetMyHandle()) - { - if (g_bLogActivity2) - { - LogAction(0, client, "[STB] Callback was not started with current plugin, bugging out."); - } - return; - } - - /** - Get the players name and report the event - */ - decl String:sPlayerName[64]; - GetClientName(client, sPlayerName, sizeof(sPlayerName)); - if (g_bLogActivity) - { - LogAction(0, client, "[STB] Changed %s to team %i.", sPlayerName, team); - } - - /** - If we are in TF2 fire the bult-in team balance event - */ - if(g_CurrentMod == GameType_TF) - { - new Handle:event = CreateEvent("teamplay_teambalanced_player"); - SetEventInt(event, "player", client); - SetEventInt(event, "team", team); - FireEvent(event); - } - - /** - Notify the players - */ - PrintToChatAll("[SM] %T", "BalanceMessage", LANG_SERVER, sPlayerName); - - /** - Set the players variables and start a timer - */ - g_aPlayers[client][bSwitched] = true; - g_aPlayers[client][hForcedTimer] = CreateTimer(float(g_iSwitchBackForced), Timer_ForcedExpired, client, TIMER_FLAG_NO_MAPCHANGE); - - /** - We are done, log the completion and end the balance - */ - if (g_bLogActivity) - { - LogAction(0, client, "[STB] Balance finished."); - } - g_bBalanceInProgress = false; -} - -/* HOOKED EVENTS */ - -public HookPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get our event variables - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - decl String:sWeapon[64]; - GetEventString(event, "weapon", sWeapon, sizeof(sWeapon)); - - /** - Return if death was not caused by a player - This is the case when the player switches teams - */ - if (StrEqual(sWeapon, "world", false)) - { - return; - } - - - /** - Check if balance is needed - */ - if (IsClientInGame(iClient) && OkToBalance() && IsUnbalanced()) - { - new iSmallerTeam = GetSmallerTeam(); - - /** - Check if balance is in progress - */ - if (g_bBalanceInProgress) - { - - /** - There is a balance in progress - Check the player who died to see if he is supposed to be switched - */ - if (g_aPlayers[iClient][hBalanceTimer] != INVALID_HANDLE) - { - - /** - The player has a timer on him to switch him to other team - Stop the timer - */ - CloseHandle(g_aPlayers[iClient][hBalanceTimer]); - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - if (g_bLogActivity) - { - LogAction(0, iClient, "[STB] With a balance in progress the queued living player died and was switched."); - } - - /** - Call the stock change team function - */ - BalancePlayer(iClient, SM_GetForcedTeam(iClient)); - return; - } - - /** - Before we continue, lets make sure the client is switchable - */ - if (IsSwitchablePlayer(iClient, GetBiggerTeam())) - { - - /** - Now we check the buddy system - */ - if (g_bBuddyEnabled) - { - - /** - Buddy system is enabled, check to see if client has buddy - */ - new iBuddyIndex = SM_GetClientBuddy(iClient); - if (iBuddyIndex != 0 || !IsClientConnected(iBuddyIndex) || !IsClientInGame(iBuddyIndex)) - { - - /** - The client has a buddy, so we check to see if they are on same team - */ - if (GetClientTeam(iClient) == GetClientTeam(iBuddyIndex)) - { - - /** - They are, but we don't bug out, we still need to start a balance - */ - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] With a balance in progress a buddy on the right team was found and skipped."); - } - } - else - { - - /** - They are not on the same team - The buddy could be in spec, and that would make it not matter where he is, or the buddy is on the smaller team - */ - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] With a balance in progress a buddy on the wrong team was switched."); - } - BalancePlayer(iClient, iSmallerTeam); - return; - } - } - else - { - - /** - Client doesn't have a buddy, balance this player - */ - BalancePlayer(iClient, iSmallerTeam); - return; - } - } - else - { - - /** - Buddy system is not enabled, balance this player - */ - BalancePlayer(iClient, iSmallerTeam); - return; - } - } - } - else - { - - /** - If we get to here then we must need to start a balance - */ - StartABalance(); - } - } -} - -public HookPlayerChangeTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get our event variables. - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - new iTeam = GetEventInt(event, "team"); - - /** - Make sure its ok to balance. - */ - if (OkToBalance()) - { - - /** - See if the client that changed teams was set to with a balance. - */ - if (g_aPlayers[iClient][hBalanceTimer] != INVALID_HANDLE - && SM_GetForcedTeam(iClient) == iTeam - && g_bBalanceInProgress) - { - - /** - The client was set to be balanced, so we close the timer. - */ - CloseHandle(g_aPlayers[iClient][hBalanceTimer]); - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - - /** - Stop the balance. - */ - g_bBalanceInProgress = false; - return; - } - - /** - It's not likely that this team change can cause us to need a balance. - If it does, start one with a small dealy to deal with forced switch backs. - */ - if (IsUnbalanced() && !g_bBalanceInProgress) - { - CreateTimer(2.0, Timer_ChangeTeamBalanceDelay, _, TIMER_FLAG_NO_MAPCHANGE); - } - } -} - -public HookRoundStart(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Set the variables we need to start a round - */ - g_bRoundStart = true; - g_bRoundEnd = false; - g_bSuddenDeath = false; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Round Started"); - } - - /** - Start a delayed balance check at the start of the round - */ - CreateTimer(float(g_iRoundStartDelay), Timer_RoundStart); -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Set the variables we need at round end - */ - g_bRoundEnd = true; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Round Ended"); - } -} - -public HookSuddenDeathBegin(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Set the variables we need for sudden death - */ - g_bSuddenDeath = true; -} - -public HookFlagEvent(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get our event variables - */ - new iClient = GetEventInt(event, "player"); - new iFlagStatus = GetEventInt(event, "eventtype"); - - /** - Make sure we have a valid client - */ - if (!IsClientInGame(iClient)) - { - return; - } - - /** - Determine what kind of event this is - */ - switch (iFlagStatus) - { - case 1: - { - - /** - The flag was picked up - */ - g_aPlayers[iClient][bFlagCarrier] = true; - } - case 2: - { - - /** - The flag was capped - */ - g_aPlayers[iClient][bFlagCarrier] = false; - } - case 3: - { - - /** - The flag was defended, we don't have to do anything - */ - } - case 4: - { - - /** - The flag was dropped - */ - g_aPlayers[iClient][bFlagCarrier] = false; - } - } -} - -/* COMMAND EVENTS */ - -public Action:Command_AddBalanceBuddy(client, args) -{ - if (client == 0) - { - ReplyToCommand(client, "[SM] %T", "PlayerLevelCmd", LANG_SERVER); - return Plugin_Handled; - } - if (!g_bIsEnabled || !g_bBuddyEnabled) - { - ReplyToCommand(client, "[SM] %T", "CmdDisabled", LANG_SERVER); - return Plugin_Handled; - } - if (g_bBuddyRestriction) - { - if (!SM_IsValidAdmin(client, g_sAdminFlag)) - { - ReplyToCommand(client, "[SM] %T", "RestrictedBuddy", LANG_SERVER); - return Plugin_Handled; - } - } - decl String:sPlayerUserId[24]; - GetCmdArg(1, sPlayerUserId, sizeof(sPlayerUserId)); - new iPlayer = GetClientOfUserId(StringToInt(sPlayerUserId)); - if (!iPlayer || !IsClientInGame(iPlayer) || client == iPlayer) - { - if (client == iPlayer) - { - PrintHintText(client, "%T", "SelectSelf", LANG_SERVER); - } - ReplyToCommand(client, "[SM] Usage: buddy "); - new Handle:playermenu = BuildPlayerMenu(); - DisplayMenu(playermenu, client, MENU_TIME_FOREVER); - } - else - { - decl String:cName[128]; - decl String:bName[128]; - GetClientName(client, cName, sizeof(cName)); - GetClientName(iPlayer, bName, sizeof(bName)); - if (SM_IsBuddyLocked(iPlayer)) - { - ReplyToCommand(client, "[SM] %T", "PlayerLockedBuddyMsg", LANG_SERVER, bName); - return Plugin_Handled; - } - SM_AssignBuddy(client, iPlayer); - PrintHintText(client, "%T", "BuddyMsg", LANG_SERVER, bName); - PrintHintText(iPlayer, "%T", "BuddyMsg", LANG_SERVER, cName); - } - return Plugin_Handled; -} - -public Action:Command_LockBuddy(client, args) -{ - if (client == 0) - { - ReplyToCommand(client, "[SM] %T", "PlayerLevelCmd", LANG_SERVER); - return Plugin_Handled; - } - if (!g_bIsEnabled) - { - ReplyToCommand(client, "[SM] %T", "CmdDisabled", LANG_SERVER); - return Plugin_Handled; - } - if (g_bBuddyRestriction) - { - if (!SM_IsValidAdmin(client, g_sAdminFlag)) - { - ReplyToCommand(client, "[SM] %T", "RestrictedBuddy", LANG_SERVER); - return Plugin_Handled; - } - } - if (SM_IsBuddyLocked(client)) - { - SM_LockBuddy(client, false); - PrintHintText(client, "%T", "BuddyLockMsgDisabled", LANG_SERVER); - } - else - { - SM_LockBuddy(client, true); - PrintHintText(client, "%T", "BuddyLockMsgEnabled", LANG_SERVER); - } - return Plugin_Handled; -} - -/** -Stock functions . - */ - -stock bool:IsUnbalanced() -{ - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Checking if teams are unbalanced"); - } - new Team1Count = GetTeamClientCount(g_aCurrentTeams[Team1]); - new Team2Count = GetTeamClientCount(g_aCurrentTeams[Team2]); - new ubCount = RoundFloat(FloatAbs(float(Team1Count - Team2Count))); - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Team1:%i Team2:%i Difference:%i", Team1Count, Team2Count, ubCount); - } - if (ubCount > g_iUnbalanceLimit) - { - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Teams are unbalanced"); - } - return true; - } - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Teams are not unbalanced"); - } - return false; -} - -stock bool:OkToBalance() -{ - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Checking if OK to balance."); - } - new bool:bResult = false; - if (g_bIsEnabled && !g_bRoundStart && !g_bRoundEnd && !g_bIsArenaMode && !g_bSuddenDeath) - { - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Passed IF statement"); - LogAction(0, -1, "[STB] Now checking admins"); - } - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientInGame(i) && !SM_IsValidAdmin(i, g_sAdminFlag)) - { - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Found at least 1 non-admin"); - LogAction(0, -1, "[STB] OK to balance"); - } - bResult = true; - break; - } - } - if (!bResult && g_bLogActivity2) - { - LogAction(0, -1, "[STB] All admins online"); - } - } - if (!bResult && g_bLogActivity2) - { - LogAction(0, -1, "[STB] Not OK to balance"); - } - return bResult; -} - -stock bool:IsSwitchablePlayer(iClient, iBiggerTeam) -{ - - /** - Run the client thru some standard checks - */ - if (!IsClientInGame(iClient) - || SM_IsValidAdmin(iClient, g_sAdminFlag) - || g_aPlayers[iClient][bFlagCarrier] - || GetClientTeam(iClient) != iBiggerTeam - || g_aPlayers[iClient][bSwitched]) - { - - /** - The supplied client can't be switched - */ - return false; - } - - /** - The supplied client can be switched - */ - return true; -} - -stock bool:HasUber(iClient) -{ - - /** - First things first, make sure the client is a medic - */ - if(TF2_GetPlayerClass(iClient) == TFClass_Medic) - { - - /** - We can only check the active weapon, so make sure the client is holding the uber gun - */ - decl String:sWeaponName[32]; - GetClientWeapon(iClient, sWeaponName, sizeof(sWeaponName)); - if(StrEqual(sWeaponName, "tf_weapon_medigun")) - { - - /** - They are, so lets check the uber level of the gun - */ - new iEntityIndex = GetEntDataEnt2(iClient, FindSendPropInfo("CTFPlayer", "m_hActiveWeapon")); - new Float:fChargeLevel = GetEntDataFloat(iEntityIndex, FindSendPropInfo("CWeaponMedigun", "m_flChargeLevel")); - if (fChargeLevel >= g_fUberLevel) - { - - /** - The client supplied has an uber above the supplied level, return true - */ - if (g_bLogActivity2) - { - LogAction(0, iClient, "[STB] Found a medic with a uber and skipped him."); - } - return true; - } - } - } - - /** - The client supplied does not have an uber above the supplied level, return false - */ - return false; -} - -stock bool:HasBuildingsBuilt(iClient) -{ - - /** - We have to start a loop to check the owner of all the valid entities - */ - new iMaxEntities = GetMaxEntities(); - for (new i = MaxClients + 1; i <= iMaxEntities; i++) - { - if (!IsValidEntity(i)) - { - - /** - Not valid, continue to next one - */ - continue; - } - - /** - Get the name of the current entity - */ - decl String:sNetClass[32]; - GetEntityNetClass(i, sNetClass, sizeof(sNetClass)); - - /** - See if its something that an engineer would build - */ - if (strcmp(sNetClass, "CObjectSentrygun") == 0 - || strcmp(sNetClass, "CObjectTeleporter") == 0 - || strcmp(sNetClass, "CObjectDispenser") == 0) - { - - /** - It is, so lets check the owner - */ - if (GetEntDataEnt2(i, g_iOwnerOffset) == iClient) - { - - /** - The client supplied is the owner, return true - */ - if (g_bLogActivity2) - { - LogAction(0, iClient, "[STB] Found an engineer with buildings and skipped him."); - } - return true; - } - } - } - - /** - The client supplied didn't have any buildings, return false - */ - return false; -} - -stock StartABalance() -{ - - /** - See if we are already started a balance - */ - if (g_hBalanceTimer != INVALID_HANDLE) - { - - /** - We have, check if we still need to - */ - if (!IsUnbalanced() || !OkToBalance()) - { - - /** - We don't, stop the balance - It's almost impossible to reach this code, but we do it just in case - */ - CloseHandle(g_hBalanceTimer); - g_hBalanceTimer = INVALID_HANDLE; - g_bBalanceInProgress = false; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Balance delay timer was not needed and was killed before the callback."); - } - return; - } - else - { - - /** - We still need to balance - Bug out and wait for the current one to finish - */ - return; - } - } - - /** - Report that teams are unbalanced - */ - PrintToChatAll("[SM] %T", "UnBalanced", LANG_SERVER); - - /** - Check to see if we are supposed to delay the balance - */ - if (g_iBalanceDelay == 0) - { - - /** - Start the balance now - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Balance is now in progress."); - } - g_bBalanceInProgress = true; - g_hBalanceTimer = INVALID_HANDLE; - - /** - Check if we are allowed to scan living players - */ - if (!g_bDeadOnly) - { - - /** - We are allowed to, so we start a timer - */ - StartALivingPlayerTimer(); - - /** - Also report that we are now scanning dead players as well - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Now scanning dead players."); - } - } - else - { - - /** - We are not allowed to, so report that we are only scanning dead players - */ - if (g_bLogActivity) - LogAction(0, -1, "[STB] Only scanning dead players."); - } - - /** - We started the balance, bug out - */ - return; - } - - /** - We are supposed to delay the balance, start a balance timer - */ - g_hBalanceTimer = CreateTimer(float(g_iBalanceDelay), Timer_BalanceTeams, _, TIMER_FLAG_NO_MAPCHANGE); - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Teams are unbalanced. Balance delay timer started."); - } -} - -stock StartALivingPlayerTimer() -{ - - /** - Start a timer to check living players - */ - if (g_hLivingPlayerCheckTimer != INVALID_HANDLE) - { - - /** - If we for some reason already have one started, stop it. - */ - CloseHandle(g_hLivingPlayerCheckTimer); - g_hLivingPlayerCheckTimer = INVALID_HANDLE; - } - - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Living player balance delay timer started."); - } - g_hLivingPlayerCheckTimer = CreateTimer(float(g_iLivingPlayerCheckDelay), Timer_LivingPlayerCheck, _, TIMER_FLAG_NO_MAPCHANGE); -} - -stock FindSwitchablePlayer() -{ - - /** - Start a loop to find a switchable player - */ - new iPlayer; - new iBiggerTeam = GetBiggerTeam(); - for (new i = 1; i <= MaxClients; i++) - { - - /** - Check the stock function to see if we are allows to even switch the player - */ - if (!IsSwitchablePlayer(i, iBiggerTeam)) - { - continue; - } - - /** - If the mod is TF2 and they have Priority Players set check if the client has buildings or an uber - */ - if (g_CurrentMod == GameType_TF && g_bPriorityPlayers) - { - if (HasUber(i) || HasBuildingsBuilt(i)) - { - continue; - } - } - - /** - So far we are able we switch this player - Now we check the buddy system - */ - if (g_bBuddyEnabled) - { - - /** - Buddy system is enabled, check to see if client has buddy - */ - if (SM_GetClientBuddy(i) != 0) - { - - /** - The client has a buddy, so we check to see if they are on same team - */ - if (GetClientTeam(i) == GetClientTeam(SM_GetClientBuddy(i))) - { - - /** - They are, so we continue to next client - */ - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] With a balance in progress a buddy on the right team was found and skipped."); - } - continue; - } - else - { - - /** - They are not on the same team, set this client - The buddy could be in spec, and that would make it not matter where he is, or the buddy is on the smaller team - */ - iPlayer = i; - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] With a balance in progress a buddy on the wrong team was found."); - } - break; - } - } - else - { - - /** - The client does not have a buddy, set this client - */ - iPlayer = i; - break; - } - } - else - { - - /** - Buddy system is not enabled, set this client - */ - iPlayer = i; - break; - } - } - - /** - Return the client we set, this could be 0, but very unlikely - */ - return iPlayer; -} - -stock BalancePlayer(iClient, iTeam) -{ - new Handle:hPack = CreateDataPack(); - WritePackCell(hPack, iClient); - WritePackCell(hPack, iTeam); - CreateTimer(0.1, Timer_BalancePlayer, hPack, TIMER_FLAG_NO_MAPCHANGE); -} - -stock CleanUp(iClient) -{ - g_aPlayers[iClient][bFlagCarrier] = false; - g_aPlayers[iClient][bSwitched] = false; - if (g_aPlayers[iClient][hForcedTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[iClient][hForcedTimer]); - g_aPlayers[iClient][hForcedTimer] = INVALID_HANDLE; - if (g_bLogActivity) - { - LogAction(0, iClient, "[STB] Forced player disconnected, killing timer."); - } - } - if (g_aPlayers[iClient][hBalanceTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[iClient][hBalanceTimer]); - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - if (g_bLogActivity) - { - LogAction(0, iClient, "[STB] Living player set to be balanced disconnected, killing timer."); - } - } -} - -stock GetSmallerTeam() -{ - - /** - Get the count of players on each team - */ - new iCountT1 = GetTeamClientCount(g_aCurrentTeams[Team1]); - new iCountT2 = GetTeamClientCount(g_aCurrentTeams[Team2]); - - /** - Return the smaller team - */ - if (iCountT1 < iCountT2) - { - return g_aCurrentTeams[Team1]; - } - else if (iCountT1 > iCountT2) - { - return g_aCurrentTeams[Team2]; - } - return 0; -} - -stock GetBiggerTeam() -{ - - /** - Get the count of players on each team - */ - new iCountT1 = GetTeamClientCount(g_aCurrentTeams[Team1]); - new iCountT2 = GetTeamClientCount(g_aCurrentTeams[Team2]); - - /** - Return the bigger team - */ - if (iCountT1 > iCountT2) - { - return g_aCurrentTeams[Team1]; - } - else if (iCountT1 < iCountT2) - { - return g_aCurrentTeams[Team2]; - } - return 0; -} - -stock SetGameCvars() -{ - if (g_bConVarControl && g_bIsEnabled) - { - if (stb_mp_autoteambalance != INVALID_HANDLE) - { - SetConVarInt(stb_mp_autoteambalance, 0); - } - if (stb_mp_teams_unbalance_limit != INVALID_HANDLE) - { - SetConVarInt(stb_mp_teams_unbalance_limit, g_iUnbalanceLimit); - } - } -} - -/* TIMER FUNCTIONS */ - -public Action:Timer_ChangeTeamBalanceDelay(Handle:timer, any:data) -{ - - /** - Finally start one if it's still unbalanced - */ - if (IsUnbalanced() && !g_bBalanceInProgress) - { - StartABalance(); - } -} - -public Action:Timer_BalanceTeams(Handle:timer, any:data) -{ - - /** - See if we still need to balance the teams - */ - if (!IsUnbalanced() || !OkToBalance()) - { - - /** - We don't, kill the balance - */ - g_bBalanceInProgress = false; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Balance delay timer was not needed and died."); - } - g_hBalanceTimer = INVALID_HANDLE; - return Plugin_Handled; - } - - /** - We still need to balance the teams - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Teams are still unbalanced. Balance is now in progress."); - } - g_bBalanceInProgress = true; - - - /** - Check if we are allowed to scan living players - */ - if (!g_bDeadOnly) - { - - /** - We are allowed to, so we start a timer - */ - StartALivingPlayerTimer(); - - /** - Also report that we are now scanning dead players as well - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Now scanning dead players."); - } - } - else - { - - /** - We are not allowed to, so report that we are only scanning dead players - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Only scanning dead players."); - } - } - - g_hBalanceTimer = INVALID_HANDLE; - return Plugin_Handled; -} - -public Action:Timer_LivingPlayerCheck(Handle:timer, any:data) -{ - - /** - Check to see if we still need to balance the teams - */ - if (!IsUnbalanced() || !OkToBalance()) - { - - /** - We don't, kill it and bug out - */ - g_bBalanceInProgress = false; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Living player balance delay timer was not needed and died."); - } - g_hLivingPlayerCheckTimer = INVALID_HANDLE; - return Plugin_Handled; - } - - /** - Call the stock function to find a player we can switch - */ - new iPlayer = FindSwitchablePlayer(); - - /** - Check to see if we found a player - */ - if (iPlayer == 0) - { - - /** - In the unlikely event that the stock function didn't return a player - Start a loop to find a random player - */ - new iBiggerTeam = GetBiggerTeam(); - do - { - iPlayer = GetRandomInt(1, MaxClients); - } while (!IsSwitchablePlayer(iPlayer, iBiggerTeam)); - - if (g_bLogActivity) - { - LogAction(0, iPlayer, "[STB] Found a random living player."); - } - } - else - { - if (g_bLogActivity) - { - LogAction(0, iPlayer, "[STB] Found a living player."); - } - } - - /** - Now that we have a player assigned them to the smaller team - */ - new iSmallerTeam = GetSmallerTeam(); - SM_SetForcedTeam(iPlayer, iSmallerTeam, true); - - /** - Let the player know we could be switching him soon - */ - PrintHintText(iPlayer, "%T", "PlayerMessage", LANG_SERVER, g_iLivingPlayerSwitchDelay); - if (g_bLogActivity) - { - LogAction(0, iPlayer, "[STB] Living player placed on a timer."); - } - - /** - Create a timer to switch the player - */ - g_aPlayers[iPlayer][hBalanceTimer] = CreateTimer(float(g_iLivingPlayerSwitchDelay), Timer_LivingPlayerBalance, iPlayer, TIMER_FLAG_NO_MAPCHANGE); - - /** - Reset the timer handle - */ - g_hLivingPlayerCheckTimer = INVALID_HANDLE; - - /** - We are done, bug out - */ - return Plugin_Handled; -} - -public Action:Timer_LivingPlayerBalance(Handle:timer, any:iClient) -{ - - /** - Check to make sure we still need to balance - */ - if (!IsUnbalanced() || !OkToBalance()) - { - - /** - We don't need to balance, bug out - */ - g_bBalanceInProgress = false; - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - SM_ClearForcedTeam(iClient); - return Plugin_Handled; - } - - /** - We still need to balance, lets make sure we can still balance this player - */ - if (!IsClientConnected(iClient) || g_aPlayers[iClient][bFlagCarrier]) - { - g_bBalanceInProgress = false; - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - SM_ClearForcedTeam(iClient); - if (g_bLogActivity) - { - if (g_aPlayers[iClient][bFlagCarrier]) - { - LogAction(0, iClient, "[STB] Living player became flag carrier, balance restarted."); - } - else - { - LogAction(0, iClient, "[STB] Living player timer was not needed and died."); - } - } - return Plugin_Handled; - } - - /** - Clear to balance this player, so do it - */ - BalancePlayer(iClient, SM_GetForcedTeam(iClient)); - if (g_bLogActivity) - { - LogAction(0, iClient, "[STB] Living player was switched."); - } - - /** - We are done, bug out - */ - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - return Plugin_Handled; -} - -public Action:Timer_BalancePlayer(Handle:timer, Handle:pack) -{ - - /** - Rest the datapack and load the variables - */ - ResetPack(pack); - new iClient = ReadPackCell(pack); - new iUnBalancedTeam = ReadPackCell(pack); - - /** - We are done with you now - */ - CloseHandle(pack); - - /** - Check the team and make sure its a valid team - */ - if(!SM_IsValidTeam(iUnBalancedTeam)) - { - if (g_bLogActivity) - { - LogAction(0, iClient, "[STB] Balance failed due to invalid team number %i", iUnBalancedTeam); - } - return Plugin_Handled; - } - - /** - Use our core function to change the clients team - */ - SM_MovePlayer(iClient, iUnBalancedTeam); - - return Plugin_Handled; -} - -public Action:Timer_RoundStart(Handle:timer, any:data) -{ - g_bRoundStart = false; - if (OkToBalance() && IsUnbalanced() && !g_bBalanceInProgress) - { - StartABalance(); - } - return Plugin_Handled; -} - -public Action:Timer_ForcedExpired(Handle:timer, any:iClient) -{ - SM_ClearForcedTeam(iClient); - g_aPlayers[iClient][bSwitched] = false; - g_aPlayers[iClient][hForcedTimer] = INVALID_HANDLE; - return Plugin_Handled; -} - -public Action:Timer_WelcomeAdvert(Handle:timer, any:iClient) -{ - if (IsClientConnected(iClient) && IsClientInGame(iClient)) - { - PrintToChat (iClient, "\x01\x04[STB]\x01 %T", "BuddyWelcomeMsg1", LANG_SERVER); - PrintToChat (iClient, "\x01\x04[STB]\x01 %T", "BuddyWelcomeMsg2", LANG_SERVER); - PrintToChat (iClient, "\x01\x04[STB]\x01 %T", "BuddyWelcomeMsg3", LANG_SERVER); - } - return Plugin_Handled; -} - -/* CONSOLE VARIABLE CHANGE EVENT */ - -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (convar == stb_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsEnabled = false; - PrintToChatAll("[SM] %T", "Disabled", LANG_SERVER); - LogAction(0, -1, "[SimpleTeamBalancer] Disabled"); - } - else - { - g_bIsEnabled = true; - SetGameCvars(); - PrintToChatAll("[SM] %T", "Enabled", LANG_SERVER); - LogAction(0, -1, "[SimpleTeamBalancer] Enabled"); - } - } - else if (convar == stb_logactivity) - { - if (StringToInt(newValue) == 0) - { - g_bLogActivity = false; - LogAction(0, -1, "[STB] Log Activity DISABLED."); - } - else - { - g_bLogActivity = true; - LogAction(0, -1, "[STB] Log Activity ENABLED."); - } - } - else if (convar == stb_logactivity2) - { - if (StringToInt(newValue) == 0) - { - g_bLogActivity2 = false; - LogAction(0, -1, "[STB] Detailed Log Activity DISABLED."); - } - else - { - g_bLogActivity2 = true; - LogAction(0, -1, "[STB] Detailed Log Activity ENABLED."); - } - } - else if (convar == stb_convarcontrol) - { - if (StringToInt(newValue) == 0) - { - g_bConVarControl = false; - } - else - { - g_bConVarControl = true; - SetGameCvars(); - } - } - else if (convar == stb_deadonly) - { - if (StringToInt(newValue) == 0) - { - g_bDeadOnly = false; - } - else - { - g_bDeadOnly = true; - } - } - else if (convar == stb_priorityenabled) - { - if (StringToInt(newValue) == 0) - { - g_bPriorityPlayers = false; - } - else - { - g_bPriorityPlayers = true; - } - } - else if (convar == stb_buddyenabled) - { - if (StringToInt(newValue) == 0) - { - g_bBuddyEnabled = false; - } - else - { - g_bBuddyEnabled = true; - } - } - else if (convar == stb_buddyrestriction) - { - if (StringToInt(newValue) == 0) - { - g_bBuddyRestriction = false; - } - else - { - g_bBuddyRestriction = true; - } - } - else if (convar == stb_unbalancelimit) - { - g_iUnbalanceLimit = StringToInt(newValue); - SetGameCvars(); - } - else if (convar == stb_balancedelay) - { - g_iBalanceDelay = StringToInt(newValue); - } - else if (convar == stb_roundstartdelay) - { - g_iRoundStartDelay = StringToInt(newValue); - } - else if (convar == stb_livingplayerswitchdelay) - { - g_iLivingPlayerSwitchDelay = StringToInt(newValue); - } - else if (convar == stb_livingplayercheckdelay) - { - g_iLivingPlayerCheckDelay = StringToInt(newValue); - } - else if (convar == stb_uberlevel) - { - g_fUberLevel = StringToFloat(newValue); - } - else if (convar == stb_switchbackforced) - { - g_iSwitchBackForced = StringToInt(newValue); - } - else if (convar == stb_adminflag) - { - SetConVarString(stb_adminflag, newValue); - } - else if (convar == stb_mp_autoteambalance) - { - SetGameCvars(); - } - else if (convar == stb_mp_teams_unbalance_limit) - { - SetGameCvars(); - } -} - -/* MENU CODE */ - -stock Handle:BuildPlayerMenu() -{ - new Handle:menu = CreateMenu(Menu_SelectPlayer); - AddTargetsToMenu(menu, 0, true, false); - SetMenuTitle(menu, "Select A Player:"); - SetMenuExitButton(menu, true); - return menu; -} - -public Menu_SelectPlayer(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[24]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - new buddy = GetClientOfUserId(StringToInt(sSelection)); - if (param1 == buddy) { - PrintHintText(param1, "%T", "SelectSelf", LANG_SERVER); - } else if (!IsClientInGame(buddy)) { - PrintHintText(param1, "%T", "BuddyGone", LANG_SERVER); - } else { - decl String:cName[128]; - decl String:bName[128]; - GetClientName(param1, cName, sizeof(cName)); - GetClientName(buddy, bName, sizeof(bName)); - if (!SM_IsBuddyLocked(buddy)) { - SM_AssignBuddy(param1, buddy); - PrintHintText(param1, "%T", "BuddyMsg", LANG_SERVER, bName); - PrintHintText(buddy, "%T", "BuddyMsg", LANG_SERVER, cName); - } else - PrintHintText(param1, "%T", "PlayerLockedBuddyMsg", LANG_SERVER, bName); - } - } else if (action == MenuAction_End) { - CloseHandle(menu); - } -} \ No newline at end of file diff --git a/Simple AutoScrambler/addons/sourcemod/scripting/simple-teammanager.sp b/Simple AutoScrambler/addons/sourcemod/scripting/simple-teammanager.sp deleted file mode 100644 index 008f443..0000000 --- a/Simple AutoScrambler/addons/sourcemod/scripting/simple-teammanager.sp +++ /dev/null @@ -1,1351 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Team Manager -Description: - Manges players and their team - Admin menu integration - Allows admins/donators to swap their teams (clears force)* - Allows admins to move players to a team (forced\unforced)* - Allows admins to scramble the teams* - *Works with Simple Team Balancer (if installed) -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include - -#define PLUGIN_VERSION "2.1.$Rev$" -#define VOTE_YES "##YES##" -#define VOTE_NO "##NO##" - -enum PlayerData -{ - iNewTeam, - bool:bQueue -}; - -new Handle:stm_enabled = INVALID_HANDLE; -new Handle:stm_logactivity = INVALID_HANDLE; -new Handle:stm_adminflag_swapteam = INVALID_HANDLE; -new Handle:stm_adminflag_moveplayer = INVALID_HANDLE; -new Handle:stm_adminflag_scramble = INVALID_HANDLE; -new Handle:stm_scrambledelay = INVALID_HANDLE; -new Handle:stm_voteenabled = INVALID_HANDLE; -new Handle:stm_votewin = INVALID_HANDLE; -new Handle:stm_votedelay = INVALID_HANDLE; -new Handle:stm_mp_bonusroundtime = INVALID_HANDLE; -new Handle:g_hAdminMenu = INVALID_HANDLE; -new Handle:g_hTimerPrepScramble = INVALID_HANDLE; -new Handle:g_hTimerClearScrambleForce = INVALID_HANDLE; - -new g_aPlayers[MAXPLAYERS + 1][PlayerData]; - -new bool:g_bIsEnabled = true; -new bool:g_bVoteEnabled = true; -new bool:g_bLogActivity = true; -new bool:g_bScrambleRoundEnd = false; -new g_iVoteDelay, g_iLastVoteTime, g_iTimeLeft; -new Float:g_fScrambleDelay, Float:g_fVoteWin; - -public Plugin:myinfo = -{ - name = "Simple Team Manager", - author = "Simple Plugins", - description = "Manages players and thier team.", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -}; - -public OnPluginStart() -{ - - /** - Need to create all of our console variables. - */ - CreateConVar("stm_version", PLUGIN_VERSION, "Simple Team Manager Version",FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - stm_enabled = CreateConVar("stm_enabled", "1", "Enable or Disable Simple Team Manager", _, true, 0.0, true, 1.0); - stm_logactivity = CreateConVar("stm_logactivity", "0", "Enable or Disable the disaplying of events in the log", _, true, 0.0, true, 1.0); - stm_adminflag_swapteam = CreateConVar("stm_adminflag_swapteam", "a", "Admin flag to use for the swapteam command. Must be a in char format."); - stm_adminflag_moveplayer = CreateConVar("stm_adminflag_moveplayer", "c", "Admin flag to use for the moveplayer command. Must be a in char format."); - stm_adminflag_scramble = CreateConVar("stm_adminflag_scramble", "c", "Admin flag to use for the scrambleteam command. Must be a in char format."); - stm_scrambledelay = CreateConVar("stm_scrambledelay", "15", "Delay to scramble teams"); - stm_voteenabled = CreateConVar("stm_voteenabled", "1", "Enable or Disable voting to scramble the teams", _, true, 0.0, true, 1.0); - stm_votewin = CreateConVar("stm_votewin", "0.45", "Win percentage vote must win by", _, true, 0.0, true, 1.0); - stm_votedelay = CreateConVar("stm_votedelay", "600", "Delay before another vote can be cast"); - stm_mp_bonusroundtime = FindConVar("mp_bonusroundtime"); - - - /** - Need deal with changes to the console variables after the plugin is loaded. - We could not do this and just call the actual console variable each time we need it, but it's not efficent. - */ - HookConVarChange(stm_enabled, ConVarSettingsChanged); - HookConVarChange(stm_logactivity, ConVarSettingsChanged); - HookConVarChange(stm_scrambledelay, ConVarSettingsChanged); - HookConVarChange(stm_voteenabled, ConVarSettingsChanged); - HookConVarChange(stm_votewin, ConVarSettingsChanged); - HookConVarChange(stm_votedelay, ConVarSettingsChanged); - - /** - Need to register the commands we are going to create and use. - */ - RegConsoleCmd("sm_swapteam", Command_SwapTeam, "sm_swapteam <[0]instant/[1]queued>: Swaps your team to the other team"); - RegConsoleCmd("sm_moveplayer", Command_MovePlayer, "sm_moveplayer <[0]instant/[1]ondeath> <[0]unforced/[1]forced>: Moves a player to the specified team"); - RegConsoleCmd("sm_scrambleteams", Command_ScrambleTeams, "sm_scrambleteams: <[0]now/[1]roundend> <[0]dontrestart/[1]restartround> Scrambles the current teams"); - RegConsoleCmd("sm_votescramble", Command_VoteScramble, "sm_votescramble: Starts a vote to scramble the teams"); - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook the game events - */ - LogAction(0, -1, "[STM] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_death", HookPlayerDeath, EventHookMode_Post); - HookEvent("player_team", HookPlayerChangeTeam, EventHookMode_Post); - switch (g_CurrentMod) - { - case GameType_TF: - { - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - } - case GameType_DOD: - { - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_Post); - } - default: - { - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - } - } - - /** - Now we have to deal with the admin menu. If the admin library is loaded call the function to add our items. - */ - new Handle:gTopMenu; - if (LibraryExists("adminmenu") && ((gTopMenu = GetAdminTopMenu()) != INVALID_HANDLE)) - { - OnAdminMenuReady(gTopMenu); - } - - /** - Load translations and .cfg file - */ - LoadTranslations ("simpleteammanager.phrases"); - AutoExecConfig(true, "plugin.simpleteammanager"); - LogAction(0, -1, "[STM] Simple Team Manager is loaded."); -} - -public OnAllPluginsLoaded() -{ - //something -} - -public OnLibraryRemoved(const String:name[]) -{ - if (StrEqual(name, "adminmenu")) - { - - /** - Looks like the admin menu was removed. Set the global. - */ - g_hAdminMenu = INVALID_HANDLE; - } - else if (StrEqual(name, "simpleplugins")) - { - SetFailState("Required plugin Simple SourceMod Plugins Core was removed."); - } -} - -public OnConfigsExecuted() -{ - - /** - Once we loaded up all the console variables from the config file, lets now set all the global variables we will use. - */ - g_bIsEnabled = GetConVarBool(stm_enabled); - g_bLogActivity = GetConVarBool(stm_logactivity); - g_fScrambleDelay = GetConVarFloat(stm_scrambledelay); - g_iVoteDelay = GetConVarInt(stm_votedelay); - g_fVoteWin = GetConVarFloat(stm_votewin); - g_iLastVoteTime = RoundFloat(GetEngineTime()); - g_bScrambleRoundEnd = false; - g_hTimerClearScrambleForce = INVALID_HANDLE; - - /** - Report enabled - */ - if (g_bIsEnabled) - { - LogAction(0, -1, "[STM] Simple Team Manager is ENABLED."); - } - else - { - LogAction(0, -1, "[STM] Simple Team Manager is DISABLED."); - } - - if (g_bLogActivity) - { - LogAction(0, -1, "[STM] Log Activity ENABLED."); - } - else - { - LogAction(0, -1, "[STM] Log Activity DISABLED."); - } -} - -/* COMMANDS */ - -public Action:Command_SwapTeam(client, args) -{ - - /** - Make sure we are enabled, if not bug out. - */ - if (!g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - If this was ran from the console bug out. - */ - if (client == 0) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "PlayerLevelCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Make sure the client is authorized to run this command. - */ - decl String:sFlags[5]; - GetConVarString(stm_adminflag_swapteam, sFlags, sizeof(sFlags)); - if (!SM_IsValidAdmin(client, sFlags)) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Lets make sure the client is one a team we can swap. - If he is we set the global array to the opposite team. - */ - new iTeam = GetClientTeam(client); - if (iTeam == g_aCurrentTeams[Team1]) - { - g_aPlayers[client][iNewTeam] = g_aCurrentTeams[Team2]; - } - else if (iTeam == g_aCurrentTeams[Team2]) - { - g_aPlayers[client][iNewTeam] = g_aCurrentTeams[Team1]; - } - else - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "InValidTeam", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check to see if we have command arguments. - */ - if (GetCmdArgs()) - { - - /** - We do, so lets get it and see if the client wants to be switched instantly or queued for death. - */ - decl String:sArg[5]; - GetCmdArg(1, sArg, sizeof(sArg)); - new iWantsQue = StringToInt(sArg); - if (iWantsQue && !g_aPlayers[client][bQueue]) - { - - /** - He wants the que and isn't already in it, set the global array. - */ - g_aPlayers[client][bQueue] = true; - ReplyToCommand(client, "\x01\x04[STM]\x01 %T", "PlayerQueue", LANG_SERVER); - } - else if (!iWantsQue) - { - - /** - He wants to be switched right now, lets call the stock function. - */ - SM_MovePlayer(client, g_aPlayers[client][iNewTeam]); - } - } - else - { - - /** - There are no command arguments so we build and display the swap menu. - */ - DisplaySwapModeMenu(client, client); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_MovePlayer(client, args) -{ - - /** - Make sure we are enabled, if not bug out. - */ - if (!g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - Make sure the client is authorized to run this command. - */ - decl String:sFlags[5]; - GetConVarString(stm_adminflag_moveplayer, sFlags, sizeof(sFlags)); - if (!SM_IsValidAdmin(client, sFlags)) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check to see if we have command arguments. - */ - new iCmdArgs = GetCmdArgs(); - if (iCmdArgs == 0) - { - - /** - We don't. Build the player menu, display it, and bug out. - */ - DisplayPlayerMenu(client); - return Plugin_Handled; - } - - /** - Check the first argument - If should be a players name or userid. - */ - decl String:sPlayer[64]; - GetCmdArg(1, sPlayer, sizeof(sPlayer)); - new iPlayerIndex = FindTarget(client, sPlayer, true, true); - if (iPlayerIndex == -1 || !IsClientInGame(iPlayerIndex)) - { - - /** - We don't know who this is. Build the player menu, display it, and bug out. - */ - DisplayPlayerMenu(client); - return Plugin_Handled; - } - - /** - We have figured out the first argument, lets check the second. - If should be the team the client wants to put the player on. - */ - if (iCmdArgs >= 2) - { - - /** - We have a command argument at least, lets see if we can identify the team. - */ - decl String:sTeam[24]; - GetCmdArg(2, sTeam, sizeof(sTeam)); - - new iTeam = StringToInt(sTeam); - if (SM_IsValidTeam(iTeam)) - { - - /** - It's a vaild team so lets set the global array to the new team. - */ - g_aPlayers[iPlayerIndex][iNewTeam] = iTeam; - } - else - { - - /** - It's not a vaild team so set the menu to display to the team menu. - */ - DisplayTeamMenu(client, iPlayerIndex); - return Plugin_Handled; - } - } - else - { - /** - We were not given a team, display the team menu. - */ - DisplayTeamMenu(client, iPlayerIndex); - return Plugin_Handled; - } - - /** - Check to see if we were given any more command arguments and found a team. - */ - if (iCmdArgs < 3) - { - - /** - No more command arguments and found a team. - Now lets check to see if the player is a spectator. If he is there is no reason to ask if it's instant or on death... he can't die. - */ - if (!IsClientObserver(iPlayerIndex)) - { - - /** - Not a spectator so display the swapmode menu. - */ - DisplaySwapModeMenu(client, iPlayerIndex); - } - else - { - - /** - The player is a spectator. - We make sure the player is not set to switch on death, since a spec can't die. - */ - g_aPlayers[iPlayerIndex][bQueue] = false; - } - } - - /** - We have figured out the second argument, lets check the third. - If should be the how the client wants to move the player: instant/on death. - */ - if (iCmdArgs >= 3) - { - - /** - The client gave us a command argument, lets check it. - */ - decl String:sSwapMode[5]; - GetCmdArg(3, sSwapMode, sizeof(sSwapMode)); - new iWantsQue = StringToInt(sSwapMode); - if (iWantsQue) - { - - /** - The client wants to que the player, set the global array. - */ - g_aPlayers[iPlayerIndex][bQueue] = true; - } - else - { - - /** - The client doesn't want to que the player, set the global array. - */ - g_aPlayers[iPlayerIndex][bQueue] = false; - } - } - else - { - /** - No swapmode argument, display the menu - */ - DisplaySwapModeMenu(client, iPlayerIndex); - } - - if (iCmdArgs >= 4) - { - - /** - Since we are compiling for Simple Team Balancer, and given a 4th argument, lets check it. - If should be the if the client wants to force the player to that team. - */ - decl String:sPlayerForced[5]; - GetCmdArg(4, sPlayerForced, sizeof(sPlayerForced)); - new iForceHim = StringToInt(sPlayerForced); - if (iForceHim) - { - - /** - The client wants to force the player - */ - SM_SetForcedTeam(iPlayerIndex, g_aPlayers[iPlayerIndex][iNewTeam]); - } - else - { - - /** - The client doesn't want to force the player - */ - SM_ClearForcedTeam(iPlayerIndex); - } - } - else - { - - } - - /** - We found and processed all the arguments. - */ - if (!IsPlayerAlive(iPlayerIndex)) - { - - /** - The player is not alive or died during this process so we just move him. - */ - SM_MovePlayer(iPlayerIndex, g_aPlayers[iPlayerIndex][iNewTeam]); - } - else - { - if (!g_aPlayers[iPlayerIndex][bQueue]) - { - - /** - The player is alive and is not set to be queued so we just move him. - */ - SM_MovePlayer(iPlayerIndex, g_aPlayers[iPlayerIndex][iNewTeam]); - } - } - - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_ScrambleTeams(client, args) -{ - - /** - Make sure we are enabled, if not bug out. - */ - if (!g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - Make sure the client is authorized to run this command. - */ - decl String:sFlags[5]; - GetConVarString(stm_adminflag_scramble, sFlags, sizeof(sFlags)); - if (!SM_IsValidAdmin(client, sFlags)) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check if a scramble timer was already called, if so close it down. - */ - if (g_hTimerPrepScramble != INVALID_HANDLE) - { - CloseHandle(g_hTimerPrepScramble); - g_hTimerPrepScramble = INVALID_HANDLE; - } - - /** - Check if we have any command arguments. - If we don't we display the scramble menu and bug out. - */ - new iCmdArgs = GetCmdArgs(); - if (iCmdArgs == 0) - { - DisplayScrambleMenu(client); - return Plugin_Handled; - } - - /** - We have a command argument. - It should be whether or not to scramble at round end. - */ - decl String:sRoundEnd[5]; - GetCmdArg(1, sRoundEnd, sizeof(sRoundEnd)); - if (StringToInt(sRoundEnd)) - { - /** - The client wants to scramble at round end so we set the global bool. - */ - g_bScrambleRoundEnd = true; - } - else - { - g_bScrambleRoundEnd = false; - } - - /** - Check for another command argument. - It should be whether or not to restart the round. - */ - decl String:sRestartRound[5]; - new bool:bRestartRound = false; - GetCmdArg(1, sRestartRound, sizeof(sRestartRound)); - if (StringToInt(sRestartRound)) - { - bRestartRound = true; - } - - /** - Now we start the scramble timer. - */ - StartScrambleTimer(_, bRestartRound); - - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_VoteScramble(client, args) -{ - - /** - Make sure we are enabled, if not bug out. - */ - if (!g_bVoteEnabled || !g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - Make sure there is a vote in progress, if so bug out. - */ - if (IsVoteInProgress()) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "VoteInProgress", LANG_SERVER); - return Plugin_Handled; - } - - /** - Make sure enough time has passed since the last vote. - */ - new iVoteTime = RoundFloat(GetEngineTime()); - if (iVoteTime - g_iLastVoteTime <= g_iVoteDelay) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "ScrambleTime", LANG_SERVER); - return Plugin_Handled; - } - - /** - Enough time has passed so reset the global vote time to now. - */ - g_iLastVoteTime = iVoteTime; - - /** - Build the vote menu and send it to everyone. - */ - new Handle:hMenu = CreateMenu(Menu_VoteScramble); - SetMenuTitle(hMenu, "Scramble Teams?"); - AddMenuItem(hMenu, VOTE_YES, "Yes"); - AddMenuItem(hMenu, VOTE_NO, "No"); - SetMenuExitButton(hMenu, false); - VoteMenuToAll(hMenu, 20); - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -/* HOOKED EVENTS */ - -public HookPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Find out who died. - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - - /** - Find out how the client died. - */ - new String:sWeapon[64]; - GetEventString(event, "weapon", sWeapon, sizeof(sWeapon)); - if (StrEqual(sWeapon, "world", false)) - { - - /** - He died because he changed teams so cleanup and bug out. - */ - s_CleanUp(iClient); - return; - } - - /** - Find out if this player was queued to change teams. - */ - if (g_aPlayers[iClient][bQueue]) - { - /** - Looks like he was, so call the stock function to move him. - */ - SM_MovePlayer(iClient, g_aPlayers[iClient][iNewTeam]); - } -} - -public HookPlayerChangeTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Find out who changed teams. - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - - /** - If he was queued to switch teams we cleanup the variables. The client did it themself. - */ - if (g_aPlayers[iClient][bQueue]) - { - s_CleanUp(iClient); - } -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get the amount of time left in the map. - */ - new iTimeLeft; - GetMapTimeLeft(iTimeLeft); - - /** - Check to see if we are supposed to scramble at the end of the round and that there is enough time left in the map. - */ - if (g_bScrambleRoundEnd && iTimeLeft >= 60) - { - - /** - Check to see if there is a scramble timer in action and if so close it down. - */ - if (g_hTimerPrepScramble != INVALID_HANDLE) - { - CloseHandle(g_hTimerPrepScramble); - g_hTimerPrepScramble = INVALID_HANDLE; - } - - /** - Determine the round end chat time and run the scramble 1 second before it ends. - */ - new Float:fDelay = GetConVarFloat(stm_mp_bonusroundtime); - fDelay -= 1.0; - StartScrambleTimer(fDelay); - } -} - -public OnClientPostAdminCheck(client) -{ - - /** - Determine if the client has the flag to use the swapteam command. - */ - decl String:sFlags[5]; - GetConVarString(stm_adminflag_swapteam, sFlags, sizeof(sFlags)); - if (SM_IsValidAdmin(client, sFlags)) - { - /** - The client does so lets create a timer to run an advertise to tell him about it. - */ - CreateTimer (60.0, Timer_WelcomeAdvert, client); - } -} - -public OnClientDisconnect(client) -{ - - /** - Cleanup the clients variables. - */ - s_CleanUp(client); -} - -public SM_OnPlayerMoved(Handle:plugin, client, team) -{ - - /** - Make sure we called the move function - */ - if (plugin != GetMyHandle()) - { - if (g_bLogActivity) - { - LogAction(0, client, "[STM] Callback was not started with current plugin, bugging out."); - } - return; - } - - decl String:sPlayerName[64]; - GetClientName(client, sPlayerName, sizeof(sPlayerName)); - - PrintToChat(client, "\x01\x04[SM]\x01 %T", "PlayerSwitched", LANG_SERVER); - - s_CleanUp(client); -} - -/* TIMER FUNCTIONS */ - -public Action:Timer_PrepTeamScramble(Handle:timer, any:data) -{ - new bool:bRestartRound = data; - /** - Call the scramble the teams stock function. - */ - PrepTeamScramble(bRestartRound); - - /** - Reset the timer handle so we know the timer is done. - */ - g_hTimerPrepScramble = INVALID_HANDLE; - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Timer_ScrambleTheTeams(Handle:timer, any:data) -{ - new iPlayers[MAXPLAYERS + 1]; - new iCount, i, bool:bTeam, bool:bRestartRound = data; - - /** - Get all the client index numbers of valid players - */ - for(i = 1; i <= MaxClients; i++) - { - if(IsClientInGame(i)) // && !IsFakeClient(i)) - { - iPlayers[iCount++] = i; - } - } - - /** - Randomly sort the players - */ - SortIntegers(iPlayers, iCount, Sort_Random); - - /** - Loop through all the players and assign each one to a team, alternating each time - */ - for(i = 0; i < iCount; i++) - { - if (!bRestartRound) - { - /** - We didn't want to restart the round, so we move them to spec 1 at a time. - */ - SM_MovePlayer(iPlayers[i], g_aCurrentTeams[Spectator]); - } - SM_MovePlayer(iPlayers[i], bTeam ? g_aCurrentTeams[Team2] : g_aCurrentTeams[Team1]); - SM_SetForcedTeam(iPlayers[i], bTeam ? g_aCurrentTeams[Team2] : g_aCurrentTeams[Team1], true); - bTeam = !bTeam; - } - - /** - Reset this variable since we completed a scramble - */ - g_bScrambleRoundEnd = false; - - if (g_hTimerClearScrambleForce != INVALID_HANDLE) - { - CloseHandle(g_hTimerClearScrambleForce); - g_hTimerClearScrambleForce = INVALID_HANDLE; - } - - g_hTimerClearScrambleForce = CreateTimer(300.0, Timer_ClearScrambleForce, _, TIMER_FLAG_NO_MAPCHANGE); - - ServerCommand("mp_timelimit %i", g_iTimeLeft / 60); - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Timer_ClearScrambleForce(Handle:timer, any:data) -{ - - for(new i = 1; i <= MaxClients; i++) - { - if(IsClientInGame(i)) // && !IsFakeClient(i)) - { - SM_ClearForcedTeam(i); - PrintToChat(i, "\x01\x04[SM]\x01 Your forced team status has been cleared"); - } - } - - g_hTimerClearScrambleForce = INVALID_HANDLE; - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Timer_WelcomeAdvert(Handle:timer, any:client) -{ - - /** - Lets make sure the client is connected and actually in the game. - */ - if (IsClientConnected(client) && IsClientInGame(client)) - { - - /** - We are good to go so lets tell him about the swapteam command. - */ - PrintToChat (client, "\x01\x04[STM]\x01 %T", "SwapTeamMsg", LANG_SERVER); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -/* STOCK FUNCTIONS */ - -stock s_CleanUp(iClient) -{ - - /** - Reset all the client variables - */ - g_aPlayers[iClient][bQueue] = false; - g_aPlayers[iClient][iNewTeam] = 0; -} - -stock StartScrambleTimer(Float:fdelay = 0.0, bool:bRestartRound = false) -{ - if (fdelay == 0.0) - { - fdelay = g_fScrambleDelay; - } - if (g_hTimerPrepScramble != INVALID_HANDLE) - { - CloseHandle(g_hTimerPrepScramble); - g_hTimerPrepScramble = INVALID_HANDLE; - } - PrintCenterTextAll("%T", "Scramble", LANG_SERVER); - g_hTimerPrepScramble = CreateTimer(fdelay, Timer_PrepTeamScramble, bRestartRound, TIMER_FLAG_NO_MAPCHANGE); -} - -stock PrepTeamScramble(bool:bRestartRound = false) -{ - new iPlayers[MAXPLAYERS + 1]; - new iCount; - - GetMapTimeLeft(g_iTimeLeft); - - if (bRestartRound) - { - - for(new i = 1; i <= MaxClients; i++) - { - if(IsClientInGame(i)) - // && !IsFakeClient(i)) - { - iPlayers[iCount++] = i; - SM_ClearForcedTeam(i); - SM_ClearBuddy(i); - SM_MovePlayer(i, g_aCurrentTeams[Spectator]); - } - } - } - else - { - //Can't move them all to spec at the same time - for(new i = 1; i <= MaxClients; i++) - { - if(IsClientInGame(i)) - // && !IsFakeClient(i)) - { - iPlayers[iCount++] = i; - SM_ClearForcedTeam(i); - SM_ClearBuddy(i); - //SM_MovePlayer(i, g_aCurrentTeams[Spectator]); - } - } - } - CreateTimer(4.0, Timer_ScrambleTheTeams, bRestartRound, TIMER_FLAG_NO_MAPCHANGE); -} - -/* CONSOLE VARIABLE CHANGE EVENT */ - -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (convar == stm_enabled) { - if (StringToInt(newValue) == 0) { - g_bIsEnabled = false; - LogAction(0, -1, "[STM] Simple Team Manager is loaded and disabled."); - } else { - g_bIsEnabled = true; - LogAction(0, -1, "[STM] Simple Team Manager is loaded and enabled."); - } - } - else if (convar == stm_logactivity) { - if (StringToInt(newValue) == 0) { - g_bLogActivity = false; - LogAction(0, -1, "[STM] Log Activity DISABLED."); - } else { - g_bLogActivity = true; - LogAction(0, -1, "[STM] Log Activity ENABLED."); - } - } - else if (convar == stm_scrambledelay) - g_fScrambleDelay = StringToFloat(newValue); - else if (convar == stm_votewin) - g_fVoteWin = StringToFloat(newValue); - else if (convar == stm_votedelay) - g_iVoteDelay = StringToInt(newValue); - else if (convar == stm_voteenabled) { - if (StringToInt(newValue) == 0) - g_bVoteEnabled = false; - else - g_bVoteEnabled = true; - } -} - -/* MENU CODE */ - -public OnAdminMenuReady(Handle:topmenu) -{ - if (topmenu == g_hAdminMenu) - return; - g_hAdminMenu = topmenu; - new TopMenuObject:player_commands = FindTopMenuCategory(g_hAdminMenu, ADMINMENU_PLAYERCOMMANDS); - new TopMenuObject:server_commands = FindTopMenuCategory(g_hAdminMenu, ADMINMENU_SERVERCOMMANDS); - if (player_commands == INVALID_TOPMENUOBJECT) - return; - - AddToTopMenu(g_hAdminMenu, - "moveplayer", - TopMenuObject_Item, - AdminMenu_MovePlayer, - player_commands, - "moveplayer", - ADMFLAG_BAN); - - AddToTopMenu(g_hAdminMenu, - "scrambleteams", - TopMenuObject_Item, - AdminMenu_Scrambleteams, - server_commands, - "scrambleteams", - ADMFLAG_BAN); -} - -public AdminMenu_MovePlayer(Handle:topmenu, TopMenuAction:action, TopMenuObject:object_id, param, String:buffer[], maxlength) -{ - if (action == TopMenuAction_DisplayOption) - Format(buffer, maxlength, "Move Player"); - else if (action == TopMenuAction_SelectOption){ - DisplayPlayerMenu(param); - } -} - -public AdminMenu_Scrambleteams(Handle:topmenu, TopMenuAction:action, TopMenuObject:object_id, param, String:buffer[], maxlength) -{ - if (action == TopMenuAction_DisplayOption) - Format(buffer, maxlength, "Scramble Teams"); - else if (action == TopMenuAction_SelectOption) { - DisplayScrambleMenu(param); - } -} - -public Menu_SelectPlayer(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - DisplayTeamMenu(param1, GetClientOfUserId(StringToInt(sSelection))); - } else if (action == MenuAction_Cancel) { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -public Menu_SelectTeam(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new iTeam; - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - decl String:sIndex[64]; - if (SplitString(sSelection, "A", sIndex, sizeof(sIndex)) != -1) - iTeam = g_aCurrentTeams[Team1]; - else if (SplitString(sSelection, "B", sIndex, sizeof(sIndex)) != -1) - iTeam = g_aCurrentTeams[Team2]; - else { - SplitString(sSelection, "C", sIndex, sizeof(sIndex)); - iTeam = g_aCurrentTeams[Spectator]; - } - new iTarget = StringToInt(sIndex); - g_aPlayers[iTarget][iNewTeam] = iTeam; - DisplaySwapModeMenu(param1, iTarget); - } else if (action == MenuAction_Cancel) { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -public Menu_SwapMode(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - decl String:sIndex[64]; - - if (SplitString(sSelection, "A", sIndex, sizeof(sIndex)) == -1) - { - SplitString(sSelection, "B", sIndex, sizeof(sIndex)); - } - - new iTarget = StringToInt(sIndex); - - if (StrContains(sSelection, "A", true) != -1) - { - g_aPlayers[iTarget][bQueue] = false; - } - else if (StrContains(sSelection, "B", true) != -1) - { - g_aPlayers[iTarget][bQueue] = true; - } - - if (param1 == iTarget && !g_aPlayers[iTarget][bQueue]) - { - SM_MovePlayer(iTarget, g_aPlayers[iTarget][iNewTeam]); - } - else - { - DisplayForceModeMenu(param1, iTarget); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - { - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } - return; -} - -public Menu_ForceMode(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - decl String:sIndex[64]; - if (SplitString(sSelection, "A", sIndex, sizeof(sIndex)) == -1) - { - SplitString(sSelection, "B", sIndex, sizeof(sIndex)); - } - new iTarget = StringToInt(sIndex); - if (StrContains(sSelection, "A", true) != -1) - { - SM_ClearForcedTeam(iTarget); - } - else if (StrContains(sSelection, "B", true) != -1) - { - SM_SetForcedTeam(iTarget, g_aPlayers[iTarget][iNewTeam], true); - } - if (!g_aPlayers[iTarget][bQueue]) - { - SM_MovePlayer(iTarget, g_aPlayers[iTarget][iNewTeam]); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - { - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } - return; -} - -public Menu_VoteScramble(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_VoteEnd) { - new winning_votes, total_votes; - GetMenuVoteInfo(param2, winning_votes, total_votes); - if (param1 == 0) { - if (float(total_votes) / float(winning_votes) < g_fVoteWin) { - PrintToChatAll("\x01\x04[SM]\x01 %T", "VoteScramble2", LANG_SERVER, winning_votes, total_votes); - return; - } - PrintCenterTextAll("[SM] %T", "Scramble", LANG_SERVER); - PrintToChatAll("\x01\x04[SM]\x01 %T", "VoteScramble1", LANG_SERVER, winning_votes, total_votes); - StartScrambleTimer(); - } - if (param1 == 1) { - PrintToChatAll("\x01\x04[SM]\x01 %T", "VoteScramble2", LANG_SERVER, winning_votes, total_votes); - } - } - if (action == MenuAction_End) - CloseHandle(menu); -} - -public Menu_ScrambleTeams(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "NOW", false)) - g_bScrambleRoundEnd = false; - else - g_bScrambleRoundEnd = true; - DisplayScrambleMenu2(param1); - } else if (action == MenuAction_Cancel) { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -public Menu_ScrambleTeams2(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[64]; - new bool:bRestartRound; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "NO", false)) - { - bRestartRound = false; - } - else - { - bRestartRound = true; - } - StartScrambleTimer(_, bRestartRound); - } else if (action == MenuAction_Cancel) { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -stock DisplayScrambleMenu(iClient) -{ - new Handle:hMenu = CreateMenu(Menu_ScrambleTeams); - SetMenuTitle(hMenu, "Select When to Scramble:"); - AddMenuItem(hMenu, "NOW", "Instantly"); - AddMenuItem(hMenu, "END", "At Round End"); - SetMenuExitBackButton(hMenu, false); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} - -stock DisplayScrambleMenu2(iClient) -{ - new Handle:hMenu = CreateMenu(Menu_ScrambleTeams2); - SetMenuTitle(hMenu, "Select When to Scramble:"); - AddMenuItem(hMenu, "NO", "No Round Restart"); - AddMenuItem(hMenu, "YES", "Restart Round"); - SetMenuExitBackButton(hMenu, false); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} - -stock DisplaySwapModeMenu(iClient, iTarget) -{ - new Handle:hMenu = CreateMenu(Menu_SwapMode); - decl String:optionA[64]; - decl String:optionB[64]; - Format(optionA, sizeof(optionA), "%iA", iTarget); - Format(optionB, sizeof(optionB), "%iB", iTarget); - SetMenuTitle(hMenu, "Select When to Swap:"); - AddMenuItem(hMenu, optionA, "Instantly (Kills)"); - if (!IsClientObserver(iTarget)) - AddMenuItem(hMenu, optionB, "Queue on next death"); - SetMenuExitBackButton(hMenu, false); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} - -stock DisplayForceModeMenu(iClient, iTarget) -{ - new Handle:hMenu = CreateMenu(Menu_ForceMode); - decl String:optionA[64]; - decl String:optionB[64]; - Format(optionA, sizeof(optionA), "%iA", iTarget); - Format(optionB, sizeof(optionB), "%iB", iTarget); - SetMenuTitle(hMenu, "Select Force Mode:"); - AddMenuItem(hMenu, optionA, "UnForced"); - AddMenuItem(hMenu, optionB, "Forced"); - SetMenuExitBackButton(hMenu, false); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} - -stock DisplayTeamMenu(iClient, iTarget) -{ - new Handle:hMenu = CreateMenu(Menu_SelectTeam); - decl String:optionA[64]; - decl String:optionB[64]; - decl String:optionC[64]; - Format(optionA, sizeof(optionA), "%iA", iTarget); - Format(optionB, sizeof(optionB), "%iB", iTarget); - Format(optionC, sizeof(optionC), "%iC", iTarget); - SetMenuTitle(hMenu, "Select Team:"); - AddMenuItem(hMenu, optionA, "Team One"); - AddMenuItem(hMenu, optionB, "Team Two"); - AddMenuItem(hMenu, optionC, "Spectator"); - SetMenuExitBackButton(hMenu, false); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} - -stock DisplayPlayerMenu(iClient) -{ - new Handle:hMenu = CreateMenu(Menu_SelectPlayer); - AddTargetsToMenu(hMenu, 0, true, false); - SetMenuTitle(hMenu, "Select A Player:"); - SetMenuExitBackButton(hMenu, true); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} diff --git a/Simple AutoScrambler/addons/sourcemod/translations/simpledonatorbenefits.phrases.txt b/Simple AutoScrambler/addons/sourcemod/translations/simpledonatorbenefits.phrases.txt deleted file mode 100644 index 3826846..0000000 --- a/Simple AutoScrambler/addons/sourcemod/translations/simpledonatorbenefits.phrases.txt +++ /dev/null @@ -1,62 +0,0 @@ -"Phrases" -{ - "PlayerLevelCmd" - { - "en" "Command must be run at the player level" - "fr" "Cette commande doit être tapée en jeu" - "hu" "Ezt a parancsot jatekosi szinten kell futtatni!" - } - "RestrictedCmd" - { - "en" "You must be a donator or admin to run this command" - "fr" "Vous devez être un donateur ou un admin pour lancer cette commande" - "hu" "A parancs futtatasahoz admin, vagy tamogatoi szint szukseges!" - } - "InValidTeam" - { - "en" "You must be on red or blue to swap teams" - "fr" "Vous devez être RED ou BLU pour changer d'équipe" - "hu" "Jatekban kell lenned, hogy megcsereld a csapatokat!" - } - "PlayerQueue" - { - "en" "You have been queued to swap teams on next death" - "fr" "Vous avez été mis en attente pour changer d'équipe lors de votre prochaine mort" - "hu" "A kovetkezo halalnal csapatcsere lesz" - } - "PlayerSwitched" - { - "en" "Your team has been switched as requested" - "fr" "Vous avez changé d'équipe comme demandé" - "hu" "A keresnek eleget teve a csapatod meg lett csererlve" - } - "SwapTeamMsg" - { - "en" "Type /swapteam or !swapteam to swap your team!" - } - "ReachedCount" - { - "en" "You have reached your health limit. You must die before you can use it again" - } - "AtMaxHealth" - { - "en" "You are already at your maximum health!" - } - "ToMaxHealth" - { - "en" "Instant health bonus applied! You are not at your maximun health!" - } - "HealthBonus" - { - "en" "Instant health bonus applied!" - } - "PublicJoinMessage" - { - "#format" "{1:s}" - "en" "{1} a [donator] as joined the server" - } - "PrivateJoinMessage" - { - "en" "Thanks for donating!" - } -} \ No newline at end of file diff --git a/Simple AutoScrambler/addons/sourcemod/translations/simplespectate.phrases.txt b/Simple AutoScrambler/addons/sourcemod/translations/simplespectate.phrases.txt deleted file mode 100644 index 2d1a096..0000000 --- a/Simple AutoScrambler/addons/sourcemod/translations/simplespectate.phrases.txt +++ /dev/null @@ -1,42 +0,0 @@ -"Phrases" -{ - "Stopped spectating" - { - "#format" "{1:s}" - "en" "Stopped tracking player: {1}" - } - "Yourself" - { - "en" "You can't spectate yourself" - } - "Spectator" - { - "en" "You can't spectate another spectator" - } - "Spectating" - { - "#format" "{1:s}" - "en" "Now spectating {1}. Type !stopspec or /stopspec to stop spectating this player" - } - "Invalid Target" - { - "en" "Invalid target" - } - "Cant Target" - { - "en" "Can't target this player" - } - "Must Have Target" - { - "en" "You must be following/tracking a player to punish" - } - "Target Left" - { - "en" "The player you were following/tracking has left" - } - "Punished" - { - "#format" "{1:s}{2:s}{3:s}" - "en" "{1} was punished with a {2} for {3}" - } -} \ No newline at end of file diff --git a/Simple AutoScrambler/addons/sourcemod/translations/simpleteambalancer.phrases.txt b/Simple AutoScrambler/addons/sourcemod/translations/simpleteambalancer.phrases.txt deleted file mode 100644 index 03595fd..0000000 --- a/Simple AutoScrambler/addons/sourcemod/translations/simpleteambalancer.phrases.txt +++ /dev/null @@ -1,130 +0,0 @@ -"Phrases" -{ - "UnBalanced" - { - "en" "Teams are unbalanced and will be balanced shortly" - "fr" "Les équipes ne sont pas équilibrées et le seront bientôt" - "de" "Die Teams sind ungleich und werden in Kürze ausgeglichen" - "hu" "A csapatok nem kiegyenlitettek! Egyensuly beallitas kovetkezik!" - } - "Enabled" - { - "en" "Simple Team Balancer is ENABLED" - "fr" "Simple Team Balancer est ACTIVE" - "de" "Simple Team Balancer ist AKTIV" - "hu" "Az Egyszeru Csapat Egyensulytarto AKTIV!" - } - "Disabled" - { - "en" "Simple Team Balancer is DISABLED" - "fr" "Simple Team Balancer est DESACTIVE" - "de" "Simple Team Balancer ist INAKTIV" - "hu" "Az Egyszeru Csapat Egyensulytarto INAKTIV!" - } - "PlayerMessage" - { - "#format" "{1:i}" - "en" "You are going to be auto balanced in {1} seconds unless a dead player can be found" - "fr" "Vous passerez dans l'autre équipe dans {1} secondes si aucun joueur mort ne peut être trouvé dans cet intervalle" - "de" "Du wirst in {1} Sekunden zum automatischen Ausgleich herangezogen wenn kein toter Spieler gefunden werden kann" - "hu" "{1} masodpercen belul at leszel helyezve a masik csapatba, hacsak nem lesz addig egy halott jatekos!" - } - "BalanceMessage" - { - "#format" "{1:s}" - "en" "{1} was moved to the other team for game balance" - "fr" "{1} est passé dans l'autre équipe pour équilibrer la partie" - "de" "{1} wurde zum anderen Team verschoben um das Spiel auszugleichen" - "hu" "{1} at lett helyezve az egyensuly megtartasa erdekeben." - } - "PlayerLevelCmd" - { - "en" "Command must be run at the player level" - "fr" "La commande doit être lancée au niveau du joueur" - "de" "Das Kommando muss auf Spieler Ebene ausgeführt werden" - "hu" "Jatekosi szinten kell futtatni ezt a parancsot!" - } - "CmdDisabled" - { - "en" "Command is currently disabled" - "fr" "La commande est actuellement désactivée" - "de" "Das Kommando ist momentan inaktiv" - "hu" "A parancs jelenleg inaktiv" - } - "RestrictedBuddy" - { - "en" "You must be a donator or admin to add a balance buddy" - "fr" "Vous devez être un donateur ou un admin pour choisir un partenaire" - "de" "Du musst ein Spender oder Admin sein um einen Partner wählen zu können" - "hu" "Tamogato vagy admin kell hogy legyel, hogy 'Tarsat' jelolhess meg" - } - "SelectSelf" - { - "en" "You cannot be your own buddy" - "fr" "Vous ne pouvez pas être votre propre partenaire" - "de" "Du kannst nicht dein eigener Partner sein" - "hu" "Nem valaszthatod ki onmagad!" - } - "BuddyGone" - { - "en" "Your selected buddy has disconnected" - "fr" "Le partenaire que vous avez sélectionné s'est déconnecté" - "de" "Dein gewählter Partner hat die Verbindung getrennt" - "hu" "A valasztott 'Tarsad' kilepett" - } - "BuddyMsg" - { - "#format" "{1:s}" - "en" "You and {1} are now buddies" - "fr" "Vous et {1} êtes maintenant partenaires" - "de" "Du und {1} seid jetzt Partner" - "hu" "{1} es Te 'Tarsak' vagytok." - } - "BuddyLockMsgDisabled" - { - "en" "You can now be anyone's buddy" - "fr" "Vous pouvez à présent être le partenaire de n'importe qui" - "de" "Du kannst jetzt jedermanns Partner sein" - "hu" "Barkinek lehetsz a 'Tarsa'." - } - "BuddyLockMsgEnabled" - { - "en" "Buddy selection locked. Only you can change your buddy" - "fr" "Sélection de partenaire bloquée. Vous êtes le seul à pouvoir choisir votre partenaire" - "de" "Wahl des Partners gesperrt. Nur du kannst deinen Partner wechseln" - "hu" "Tars-lista lezarva. Csak Te tudod modositani a Tars-listadat." - } - "PlayerLockedBuddyMsg" - { - "#format" "{1:s}" - "en" "{1} has locked his buddy selection. Try again" - "fr" "{1} a bloqué sa sélection de partenaire. Essayez de nouveau." - "de" "{1} hat seine Wahl des Partners gesperrt. Versuche es erneut" - "hu" "{1} lezarta a Tars-listajat. Probald kesobb!" - } - "BuddyWelcomeMsg1" - { - "en" "Select a balance buddy and stay together during an autobalance!" - "fr" "Choisissez un partenaire et restez ensemble durant l'équilibrage automatique!" - "de" "Wähle einen Partner und bleibt zusammen während eines Ausgleichs" - "hu" "Valasz ki egy 'Tarsat' akivel egyuttmaradhatsz a csapatkiegyenlites alatt!" - } - "BuddyWelcomeMsg2" - { - "en" "/buddy or !buddy to select a balance buddy" - "fr" "/buddy or !buddy pour choisir un partenaire" - "de" "/buddy oder !buddy um einen Partner zu wählen" - "hu" "Hasznald a /buddy vagy !buddy parancsokat a 'Tars' kijelolesehez" - } - "BuddyWelcomeMsg3" - { - "en" "/lockbuddy or !lockbuddy to lock your selection" - "fr" "/lockbuddy or !lockbuddy pour bloquer votre sélection" - "de" "/lockbuddy oder !lockbuddy um deine Auswahl zu sperren" - "hu" "Hasznald a /lockbuddy vagy a !lockbuddy parancsokat a Tars-listad lezarasahoz" - } -} - - - - diff --git a/Simple AutoScrambler/addons/sourcemod/translations/simpleteammanager.phrases.txt b/Simple AutoScrambler/addons/sourcemod/translations/simpleteammanager.phrases.txt deleted file mode 100644 index f2093a7..0000000 --- a/Simple AutoScrambler/addons/sourcemod/translations/simpleteammanager.phrases.txt +++ /dev/null @@ -1,92 +0,0 @@ -"Phrases" -{ - "PlayerLevelCmd" - { - "en" "Command must be run at the player level" - "fr" "Cette commande doit être tapée en jeu" - "hu" "Ezt a parancsot jatekosi szinten kell futtatni!" - } - "RestrictedCmd" - { - "en" "You must be a donator or admin to run this command" - "fr" "Vous devez être un donateur ou un admin pour lancer cette commande" - "hu" "A parancs futtatasahoz admin, vagy tamogatoi szint szukseges!" - } - "InValidTeam" - { - "en" "You must be on red or blue to swap teams" - "fr" "Vous devez être RED ou BLU pour changer d'équipe" - "hu" "Jatekban kell lenned, hogy megcsereld a csapatokat!" - } - "PlayerInValidTeam" - { - "en" "Player must be on red or blue to swap teams" - "fr" "Le joueur doit être RED ou BLU pour changer d'équipe" - "hu" "Valamelyik csapatban kell lenni, hogy csere legyen" - } - "PlayerQueue" - { - "en" "You have been queued to swap teams on next death" - "fr" "Vous avez été mis en attente pour changer d'équipe lors de votre prochaine mort" - "hu" "A kovetkezo halalnal csapatcsere lesz" - } - "PlayerSwitched" - { - "en" "Your team has been switched" - } - "PlayerSwitched1" - { - "en" "Your team has been switched as requested" - "fr" "Vous avez changé d'équipe comme demandé" - "hu" "A keresnek eleget teve a csapatod meg lett csererlve" - } - "PlayerSwitched2" - { - "en" "Your team has been switched by an Admin" - "fr" "Vous avez été changé d'équipe par un admin" - "hu" "Az Admin megcserelte a csapatodat!" - } - "SwapTeamMsg" - { - "en" "Type /swapteam or !swapteam to swap your team!" - } - "PlayerSwitched3" - { - "#format" "{1:s}" - "en" "{1}'s team has been switched" - "fr" "{1} a changé d'équipe" - "hu" "{1} csapata meg lett cserelve" - } - "Scramble" - { - "en" "Teams are about to be scrambled!" - "fr" "Les équipes vont être rééquilibrés" - "hu" "A csapatok hamarosan meg lesznek keverve!" - } - "VoteScramble1" - { - "#format" "{1:i}{2:i}" - "en" "Vote Scramble successful with {1} votes out of {2}" - "fr" "Le vote d'équilibrage des équipes a réussi avec {1} votes pour sur {2}" - "hu" "A szavazas sikeres volt, {1} szavazat a keveresre a {2} -bol" - } - "VoteScramble2" - { - "#format" "{1:i}{2:i}" - "en" "Vote Scramble failed with {1} votes out of {2}" - "fr" "Le vote d'équilibrage a échoué avec {1} votes pour sur {2}" - "hu" "A szavazas sikertelen volt, {1} szavazat a keveresre a {2} -bol" - } - "VoteInProgress" - { - "en" "A vote is currently in progress" - "fr" "Un vote est actuellement en cours" - "hu" "Egy szavazas mar fut!" - } - "ScrambleTime" - { - "en" "A vote was recently made, please wait" - "fr" "Un vote a déjà été fait récemment, réessayez plus tard" - "hu" "Nemreg volt szavazas, kerlek varj egy kicsit!" - } -} \ No newline at end of file diff --git a/Simple Chat Colors/addons/sourcemod/configs/simple-alltalkmanager_events.cfg b/Simple Chat Colors/addons/sourcemod/configs/simple-alltalkmanager_events.cfg deleted file mode 100644 index b739cf0..0000000 --- a/Simple Chat Colors/addons/sourcemod/configs/simple-alltalkmanager_events.cfg +++ /dev/null @@ -1,43 +0,0 @@ -"game_events" -{ - "teamplay_round_start" - { - "reason" "Round Start" - "setting" "1" - } - "teamplay_setup_finished" - { - "reason" "Setup Period Ended" - "setting" "0" - } - "teamplay_overtime_begin" - { - "reason" "Overtime Began" - "setting" "1" - } - "teamplay_overtime_end" - { - "reason" "Overtime Ended" - "setting" "1" - } - "teamplay_round_win" - { - "reason" "Round Ended" - "setting" "1" - } - "teamplay_suddendeath_begin" - { - "reason" "Sudden Death Began" - "setting" "1" - } - "teamplay_suddendeath_end" - { - "reason" "Sudden Death Ended" - "setting" "1" - } - "teamplay_round_stalemate" - { - "reason" "Stalemate" - "setting" "1" - } -} \ No newline at end of file diff --git a/Simple Chat Colors/addons/sourcemod/plugins/simple-alltalkmanager.smx b/Simple Chat Colors/addons/sourcemod/plugins/simple-alltalkmanager.smx deleted file mode 100644 index 6122756..0000000 Binary files a/Simple Chat Colors/addons/sourcemod/plugins/simple-alltalkmanager.smx and /dev/null differ diff --git a/Simple Chat Colors/addons/sourcemod/plugins/simple-chatcolors.smx b/Simple Chat Colors/addons/sourcemod/plugins/simple-chatcolors.smx new file mode 100644 index 0000000..4ffa03c Binary files /dev/null and b/Simple Chat Colors/addons/sourcemod/plugins/simple-chatcolors.smx differ diff --git a/Simple Chat Colors/addons/sourcemod/plugins/simple-donatorbenefits.smx b/Simple Chat Colors/addons/sourcemod/plugins/simple-donatorbenefits.smx deleted file mode 100644 index 821d61d..0000000 Binary files a/Simple Chat Colors/addons/sourcemod/plugins/simple-donatorbenefits.smx and /dev/null differ diff --git a/Simple Chat Colors/addons/sourcemod/plugins/simple-messagesuppression.smx b/Simple Chat Colors/addons/sourcemod/plugins/simple-messagesuppression.smx deleted file mode 100644 index cc20dad..0000000 Binary files a/Simple Chat Colors/addons/sourcemod/plugins/simple-messagesuppression.smx and /dev/null differ diff --git a/Simple Chat Colors/addons/sourcemod/plugins/simple-plugins.smx b/Simple Chat Colors/addons/sourcemod/plugins/simple-plugins.smx deleted file mode 100644 index ac307a3..0000000 Binary files a/Simple Chat Colors/addons/sourcemod/plugins/simple-plugins.smx and /dev/null differ diff --git a/Simple Chat Colors/addons/sourcemod/plugins/simple-spectate.smx b/Simple Chat Colors/addons/sourcemod/plugins/simple-spectate.smx deleted file mode 100644 index c6885b0..0000000 Binary files a/Simple Chat Colors/addons/sourcemod/plugins/simple-spectate.smx and /dev/null differ diff --git a/Simple Chat Colors/addons/sourcemod/plugins/simple-teambalancer.smx b/Simple Chat Colors/addons/sourcemod/plugins/simple-teambalancer.smx deleted file mode 100644 index 95beb01..0000000 Binary files a/Simple Chat Colors/addons/sourcemod/plugins/simple-teambalancer.smx and /dev/null differ diff --git a/Simple Chat Colors/addons/sourcemod/plugins/simple-teammanager.smx b/Simple Chat Colors/addons/sourcemod/plugins/simple-teammanager.smx deleted file mode 100644 index 81905ba..0000000 Binary files a/Simple Chat Colors/addons/sourcemod/plugins/simple-teammanager.smx and /dev/null differ diff --git a/Simple Chat Colors/addons/sourcemod/scripting/include/simple-plugins.inc b/Simple Chat Colors/addons/sourcemod/scripting/include/simple-plugins.inc deleted file mode 100644 index 8f21956..0000000 --- a/Simple Chat Colors/addons/sourcemod/scripting/include/simple-plugins.inc +++ /dev/null @@ -1,337 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Plugins -Description: - Included file for core plugin in the Simple Plugins project -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -*************************************************************************/ - -#if defined _simpleplugin_included - #endinput -#endif - -#define _simpleplugin_included - -#define CORE_INC_VERSION "1.1.$Rev$" - -#pragma semicolon 1 -#include -#undef REQUIRE_PLUGIN -#include -#define REQUIRE_PLUGIN -#undef REQUIRE_EXTENSIONS -#undef AUTOLOAD_EXTENSIONS -#tryinclude -#tryinclude -#tryinclude -#define AUTOLOAD_EXTENSIONS -#define REQUIRE_EXTENSIONS - -enum e_SupportedMods -{ - GameType_Unknown, - GameType_AOC, - GameType_CSS, - GameType_DOD, - GameType_FF, - GameType_HIDDEN, - GameType_HL2DM, - GameType_INS, - GameType_L4D, - GameType_NEO, - GameType_SGTLS, - GameType_TF, - GameType_ZPS -}; - -enum e_Teams -{ - Unknown, - Spectator, - Team1, - Team2 -}; - -new g_aCurrentTeams[e_Teams]; -new e_SupportedMods:g_CurrentMod; -new String:g_sGameName[e_SupportedMods][32] = { "Unknown", - "Age of Chivalry", - "Counter Strike", - "Day Of Defeat", - "Fortress Forever", - "Hidden: Source", - "Half Life 2: Deathmatch", - "Insurgency", - "Left 4 Dead", - "Neotokyo", - "Stargate TLS", - "Team Fortress 2", - "Zombie Panic: Source" - }; - -public SharedPlugin:_pl_simpleplugin = -{ - name = "simple-plugins", - file = "simple-plugins.smx", -#if defined REQUIRE_PLUGIN - required = 1 -#else - required = 0 -#endif -}; - -#if !defined REQUIRE_PLUGIN -public _pl_simpleplugin_SetNTVOptional() -{ - MarkNativeAsOptional("SM_MovePlayer"); - MarkNativeAsOptional("SM_SetForcedTeam"); - MarkNativeAsOptional("SM_GetForcedTeam"); - MarkNativeAsOptional("SM_ClearForcedTeam"); - MarkNativeAsOptional("SM_GetForcedPlayer"); - MarkNativeAsOptional("SM_AssignBuddy"); - MarkNativeAsOptional("SM_SearchBuddy"); - MarkNativeAsOptional("SM_LockBuddy"); - MarkNativeAsOptional("SM_IsBuddyLocked"); - MarkNativeAsOptional("SM_ClearBuddy"); - MarkNativeAsOptional("SM_IsValidAdmin"); - MarkNativeAsOptional("SM_IsValidTeam"); -} -#endif - -/********************************************************************** - * When a player has to moved - * - * @param plugin Plugin that initiated the move - * @param client The client index of the player that was moved - * @param team The team index the player was moved to - * @noreturn - **********************************************************************/ -forward SM_OnPlayerMoved(Handle:plugin, client, team); - -/********************************************************************** - * Move a player to the supplied team - * - * @param client The client index of the player to be moved - * @param team The team to move the player to - * @noreturn - * @error Invalid client or team index - **********************************************************************/ -native SM_MovePlayer(client, team); - -/********************************************************************** - * Move a player to the supplied team - * - * @param client The client index of the player to set - * @param team The team to move the to set - * @param override Whether or not to override another plugin - * @return True if successful, false if not - * @error Invalid client or team index - **********************************************************************/ -native SM_SetForcedTeam(client, team, bool:override = false); - -/********************************************************************** - * Gets the client's forced team index - * - * @param client The client index of the player to check - * @param plugin Optional: The plugin handle of the plugin - that set the team - * @return The team index of the forced team - Zero if no forced team - * @error Invalid client index - **********************************************************************/ -native SM_GetForcedTeam(client, &Handle:plugin = INVALID_HANDLE); - -/********************************************************************** - * Clears a client's forced team - * - * @param client The client index of the player to check - * @return True if successful, false if not - * @error Invalid client index - **********************************************************************/ -native SM_ClearForcedTeam(client); - -/********************************************************************** - * Gets a forced player on the wrong that is currently on the wrong team - * This will only return a player if the calling plugin assigned the team - * - * @param team The team index the player should be on - * @return The client index of the player - Zero if no player found - * @error Invalid client index - **********************************************************************/ -native SM_GetForcedPlayer(team); - -/********************************************************************** - * Assign a players buddy - * - * @param client The client index of the player to assign - * @param player The player index of the player to assign - * @param override Whether or not to override a player lock - * @return True if successful, false if not - * @error Invalid client or player index - **********************************************************************/ -native bool:SM_AssignBuddy(client, player, bool:override = false); - -/********************************************************************** - * Rturns the client's buddy - * - * @param client The client index of the player to assign - * @return The client index of the player's buddy - Zero if no buddy - * @error Invalid client index - **********************************************************************/ -native SM_GetClientBuddy(client); - -/********************************************************************** - * Set the buddy lock setting for a client - * - * @param client The client index of the player to assign - * @param setting Setting to set, True or False - * @return True if successful, false if not - * @error Invalid client index - **********************************************************************/ -native bool:SM_LockBuddy(client, bool:setting); - -/********************************************************************** - * Returns the buddy lock setting for a client - * - * @param client The client index of the player to assign - * @return True if locked, false if not - * @error Invalid client index - **********************************************************************/ -native bool:SM_IsBuddyLocked(client); - -/********************************************************************** - * Clear a players buddy - * - * @param client The client index of the player to clear - * @param override Whether or not to override a player lock - * @return True if successful, false if not - * @error Invalid client index - **********************************************************************/ -native bool:SM_ClearBuddy(client, bool:override = false); - -/********************************************************************** - * Determine if the player has the supplied flags - * ADMFLAG_ROOT will always return true - * - * @param client The client index of the player to assign - * @param flags The char flag(s) to check against - * @return True if valid, false if not - **********************************************************************/ -native bool:SM_IsValidAdmin(client, const String:flags[]); - - -/********************************************************************** - * Determine if the team is a valid team - * - * @param team The team index to determine if valid for - currently installed/supported mod - * @return True if valid, false if not - **********************************************************************/ -native bool:SM_IsValidTeam(team); - - -public e_SupportedMods:GetCurrentMod() -{ - new String:sGameType[64]; - GetGameFolderName(sGameType, sizeof(sGameType)); - - if (StrEqual(sGameType, "aoc", false)) - { - return GameType_AOC; - } - if (StrEqual(sGameType, "cstrike", false)) - { - return GameType_CSS; - } - if (StrEqual(sGameType, "dod", false)) - { - return GameType_DOD; - } - if (StrEqual(sGameType, "ff", false)) - { - return GameType_FF; - } - if (StrEqual(sGameType, "hidden", false)) - { - return GameType_HIDDEN; - } - if (StrEqual(sGameType, "hl2mp", false)) - { - return GameType_FF; - } - if (StrEqual(sGameType, "insurgency", false) || StrEqual(sGameType, "ins", false)) - { - return GameType_INS; - } - if (StrEqual(sGameType, "l4d", false)) - { - return GameType_L4D; - } - if (StrEqual(sGameType, "nts", false)) - { - return GameType_NEO; - } - if (StrEqual(sGameType, "sgtls", false)) - { - return GameType_SGTLS; - } - if (StrEqual(sGameType, "tf", false)) - { - return GameType_TF; - } - if (StrEqual(sGameType, "zps", false)) - { - return GameType_ZPS; - } - return GameType_Unknown; -} - -public LoadCurrentTeams() -{ - switch (g_CurrentMod) - { - case GameType_INS: - { - g_aCurrentTeams[Unknown] = 0; - g_aCurrentTeams[Spectator] = 3; - g_aCurrentTeams[Team1] = 1; - g_aCurrentTeams[Team2] = 2; - } - case default: - { - g_aCurrentTeams[Unknown] = 0; - g_aCurrentTeams[Spectator] = 1; - g_aCurrentTeams[Team1] = 2; - g_aCurrentTeams[Team2] = 3; - } - } -} diff --git a/Simple Chat Colors/addons/sourcemod/scripting/simple-alltalkmanager.sp b/Simple Chat Colors/addons/sourcemod/scripting/simple-alltalkmanager.sp deleted file mode 100644 index c848332..0000000 --- a/Simple Chat Colors/addons/sourcemod/scripting/simple-alltalkmanager.sp +++ /dev/null @@ -1,515 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple AllTalk Manager -Description: - Allows you to set alltalk at different times -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#pragma semicolon 1 -#include -#include - -#define PLUGIN_VERSION "1.4.$Rev$" - -new Handle:satm_enabled = INVALID_HANDLE; -new Handle:satm_threshold_enabled = INVALID_HANDLE; -new Handle:satm_player_threshold = INVALID_HANDLE; -new Handle:satm_threshold_setting = INVALID_HANDLE; -new Handle:satm_logactivity = INVALID_HANDLE; -new Handle:satm_alltalk = INVALID_HANDLE; - -new Handle:g_aEventNames = INVALID_HANDLE; -new Handle:g_aEventReasons = INVALID_HANDLE; -new Handle:g_aEventSettings = INVALID_HANDLE; - -new bool:g_bLastThreshold = false; -new bool:g_bEnabled = true; -new bool:g_bThresholdEnabled = true; -new bool:g_bIsSetupMap = false; -new bool:g_bIsGameTF2 = false; -new bool:g_bLogActivity = false; - -new g_iLastEventIndex; - -public Plugin:myinfo = -{ - name = "Simple AllTalk Manager", - author = "Simple Plugins", - description = "Allows you to set alltalk at different times", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -} - -/** -Sourcemod callbacks -*/ -public OnPluginStart() -{ - - /** - Need to create all of our console variables. - */ - CreateConVar("satm_version", PLUGIN_VERSION, "Simple AllTalk Manager", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - satm_enabled = CreateConVar("satm_enabled", "1", "Enables/Disables Simple AllTalk Manager", _, true, 0.0, true, 1.0); - satm_threshold_enabled = CreateConVar("satm_threshold_enabled", "1", "Enables/Disables player threshold", _, true, 0.0, true, 1.0); - satm_player_threshold = CreateConVar("satm_player_threshold", "8", "Amount of players for the threshold"); - satm_threshold_setting = CreateConVar("satm_threshold_setting", "1", "Enables/Disables all talk up to player threshold, with the opposite set after the threshold", _, true, 0.0, true, 1.0); - satm_logactivity = CreateConVar("satm_logactivity", "0", "Enables/Disables log activity", _, true, 0.0, true, 1.0); - satm_alltalk = FindConVar("sv_alltalk"); - - /** - Hook console variables - */ - HookConVarChange(satm_enabled, ConVarSettingsChanged); - HookConVarChange(satm_threshold_enabled, ConVarSettingsChanged); - HookConVarChange(satm_player_threshold, ConVarSettingsChanged); - HookConVarChange(satm_logactivity, ConVarSettingsChanged); - - /** - Remove the notify flag from all talk cvar since we do it - */ - SetConVarFlags(satm_alltalk, GetConVarFlags(satm_alltalk)~FCVAR_NOTIFY); - - /** - Get the game type. We only care if it's TF2 - */ - new String:sGameType[64]; - GetGameFolderName(sGameType, sizeof(sGameType)); - if (StrEqual(sGameType, "tf", false)) - { - g_bIsGameTF2 = true; - } - - /** - Create the arrays - */ - g_aEventNames = CreateArray(255, 1); - g_aEventReasons = CreateArray(255, 1); - g_aEventSettings = CreateArray(1, 1); - - /** - Need to register the commands we are going to create and use. - */ - RegAdminCmd("sm_reloadatconfig", Command_Reload, ADMFLAG_GENERIC, "Reloads settings from config file"); - - /** - Create the config file - */ - AutoExecConfig(true); - - /** - Load the events from the config - */ - LoadEventsFromConfig(); -} - -public OnConfigsExecuted() -{ - - /** - Load up the settings - */ - g_bEnabled = GetConVarBool(satm_enabled); - g_bLogActivity = GetConVarBool(satm_logactivity); - g_bThresholdEnabled = GetConVarBool(satm_threshold_enabled); -} - -public OnMapStart() -{ - - /** - Reset the globals - */ - g_iLastEventIndex = 0; - g_bLastThreshold = false; - - /** - Check the map type if we are in TF2 - */ - if (g_bIsGameTF2) - { - g_bIsSetupMap = IsSetupPeriodMap(); - } - - /** - Set AllTalk - */ - if (g_bEnabled) - { - SetConVarBool(satm_alltalk, true); - } -} - -public OnClientDisconnect_Post(client) -{ - if (g_bEnabled) - { - SetAllTalk(-1); - } -} - -public OnClientPostAdminCheck(client) -{ - if (g_bEnabled) - { - SetAllTalk(-1); - } - CreateTimer(2.0, Timer_ShowAllTalkStatus, client, TIMER_FLAG_NO_MAPCHANGE); -} - -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (convar == satm_enabled) - { - if (StringToInt(newValue)) - { - g_bEnabled = true; - } - else - { - g_bEnabled = false; - } - } - else if (convar == satm_threshold_enabled) - { - if (StringToInt(newValue)) - { - g_bThresholdEnabled = true; - } - else - { - g_bThresholdEnabled = false; - } - } - else if (convar == satm_logactivity) - { - if (StringToInt(newValue)) - { - g_bLogActivity = true; - } - else - { - g_bLogActivity = false; - } - } - if (g_bEnabled) - { - SetAllTalk(-1); - } -} - -/** -Commands -*/ -public Action:Command_Reload(client, args) -{ - - /** - Clear the array - */ - ClearArray(g_aEventNames); - ClearArray(g_aEventReasons); - ClearArray(g_aEventSettings); - - /** - Load the events from the config - */ - LoadEventsFromConfig(); - - return Plugin_Handled; -} - -/** -Game Event Hooks -*/ -public Hook_All_Events(Handle:event, const String:name[], bool:dontBroadcast) -{ - if (!g_bIsSetupMap) - { - if (StrEqual(name, "teamplay_round_start")) - { - if (FindStringInArray(g_aEventNames, "teamplay_setup_finished") != -1) - { - g_iLastEventIndex = FindStringInArray(g_aEventNames, "teamplay_setup_finished"); - if (g_bEnabled) - { - SetAllTalk(g_iLastEventIndex); - return; - } - } - } - } - g_iLastEventIndex = FindStringInArray(g_aEventNames, name); - if (g_bEnabled) - { - SetAllTalk(g_iLastEventIndex); - } -} - -/** -Timers -*/ -public Action:Timer_ShowAllTalkStatus(Handle:timer, any:client) -{ - if (IsClientConnected(client) && IsClientInGame(client)) - { - new bool:bSetting = GetConVarBool(satm_alltalk); - if (bSetting) - { - PrintToChat(client, "\x01\x04[SM] AllTalk is \x01[on]"); - } - else - { - PrintToChat(client, "\x01\x04[SM] AllTalk is \x01[off]"); - } - } -} - -/** -Stock Functions -*/ -stock LoadEventsFromConfig() -{ - - /** - Make sure the config file is here and load it up - */ - new String:sConfigFile[256]; - BuildPath(Path_SM, sConfigFile, sizeof(sConfigFile), "configs/simple-alltalkmanager_events.cfg"); - if (!FileExists(sConfigFile)) - { - - /** - Config file doesn't exists, stop the plugin - */ - LogError("[SATM] Simple AllTalk Manager is not running! Could not find file %s", sConfigFile); - SetFailState("Could not find file %s", sConfigFile); - } - - /** - Create the arrays and variables - */ - new String:sGameEventName[256]; - new String:sReason[256]; - new iSetting; - - /** - Load config file as a KeyValues file - */ - new Handle:kvGameEvents = CreateKeyValues("game_events"); - FileToKeyValues(kvGameEvents, sConfigFile); - - if (!KvGotoFirstSubKey(kvGameEvents)) - { - return; - } - - /** - Hook the game events and load the settings - */ - do - { - - /** - Get the section name; this should be the event name - */ - KvGetSectionName(kvGameEvents, sGameEventName, sizeof(sGameEventName)); - if (!HookEventEx(sGameEventName, Hook_All_Events, EventHookMode_PostNoCopy)) - { - - /** - Could not hook this event, stop the plugin - */ - SetFailState("Could not hook event %s", sGameEventName); - } - else - { - if (g_bLogActivity) - { - LogMessage("[SATM] Hooked event: %s", sGameEventName); - } - } - - /** - Get the reason string and setting - */ - KvGetString(kvGameEvents, "reason", sReason, sizeof(sReason)); - iSetting = KvGetNum(kvGameEvents, "setting"); - if (g_bLogActivity) - { - LogMessage("[SATM] Event reason string: %s", sReason); - LogMessage("[SATM] Event setting: %i", iSetting); - } - - /** - Push the values to the arrays - */ - PushArrayString(g_aEventNames, sGameEventName); - PushArrayString(g_aEventReasons, sReason); - PushArrayCell(g_aEventSettings, iSetting); - } while (KvGotoNextKey(kvGameEvents)); - - /** - Close our handle - */ - CloseHandle(kvGameEvents); -} - -stock SetAllTalk(index) -{ - new iPlayerThreshold = GetConVarInt(satm_player_threshold); - new bool:bThresholdMet = ((GetClientCount() >= iPlayerThreshold) ? true : false); - new bool:bSetting; - - if (g_bThresholdEnabled) - { - if (bThresholdMet) - { - if (index == -1) - { - if (bThresholdMet != g_bLastThreshold) - { - g_bLastThreshold = true; - bSetting = !GetConVarBool(satm_threshold_setting); - new bool:bLastSetting = GetArrayCell(g_aEventSettings, g_iLastEventIndex); - if (bLastSetting && !bSetting) - { - bSetting = GetArrayCell(g_aEventSettings, g_iLastEventIndex); - } - } - else - { - bSetting = GetArrayCell(g_aEventSettings, g_iLastEventIndex); - } - } - else - { - bSetting = GetArrayCell(g_aEventSettings, index); - } - } - else - { - g_bLastThreshold = false; - bSetting = GetConVarBool(satm_threshold_setting); - } - } - else - { - if (index != -1) - { - bSetting = GetArrayCell(g_aEventSettings, index); - } - } - - if (GetConVarBool(satm_alltalk) != bSetting) - { - - SetConVarBool(satm_alltalk, bSetting); - - new String:sReason[256]; - if (index == -1) - { - Format(sReason, sizeof(sReason), "Player Threshold"); - } - else - { - if (!g_bIsSetupMap) - { - new String:sCurrentEvent[256]; - GetArrayString(g_aEventNames, index, sCurrentEvent, sizeof(sCurrentEvent)); - if (StrEqual(sCurrentEvent, "teamplay_setup_finished")) - { - new iRoundStartIndex = FindStringInArray(g_aEventNames, "teamplay_round_start"); - if (iRoundStartIndex != -1) - { - GetArrayString(g_aEventReasons, iRoundStartIndex, sReason, sizeof(sReason)); - } - else - { - GetArrayString(g_aEventReasons, index, sReason, sizeof(sReason)); - } - } - else - { - GetArrayString(g_aEventReasons, index, sReason, sizeof(sReason)); - } - } - else - { - GetArrayString(g_aEventReasons, index, sReason, sizeof(sReason)); - } - } - - if (bSetting) - { - PrintToChatAll("\x01\x04[SM] AllTalk turned \x01[on] \x04due to:\x01 %s", sReason); - } - else - { - PrintToChatAll("\x01\x04[SM] AllTalk turned \x01[off] \x04due to:\x01 %s", sReason); - } - } -} - -stock bool:IsSetupPeriodMap() -{ - new iEnt = -1; - new String:sMapName[32]; - - GetCurrentMap(sMapName, sizeof(sMapName)); - - if (strncmp(sMapName, "cp_", 3, false) == 0) - { - new iTeam; - while ((iEnt = FindEntityByClassname(iEnt, "team_control_point")) != -1) - { - iTeam = GetEntProp(iEnt, Prop_Send, "m_iTeamNum"); - - /** - If there is a blu CP or a neutral CP, then it's not an attack/defend map - */ - if (iTeam != 2) - { - //this is a push map - return false; - } - } - //this is a attack/defend map - return true; - } - else if (strncmp(sMapName, "ctf_", 3, false) == 0) - { - //this is a ctf map - return false; - } - return false; -} diff --git a/Simple Chat Colors/addons/sourcemod/scripting/simple-autoscrambler.sp b/Simple Chat Colors/addons/sourcemod/scripting/simple-autoscrambler.sp deleted file mode 100644 index 6c6799e..0000000 --- a/Simple Chat Colors/addons/sourcemod/scripting/simple-autoscrambler.sp +++ /dev/null @@ -1,459 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple AutoScrambler -Description: - Automatically scrambles the teams based upon a number of events. -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include - -#define PLUGIN_VERSION "1.1.$Rev$" - -/** -Different scramble modes: - -1 = Full Scramble, dont restart round. -2 = Admins Immune, dont restart round. -3 = Full Scramble, restart round and reset scores. -4 = Admins Immune, restart round and reset scores. - -*/ - -/** -Different top player modes: - -1 = Divide Top 4 players on the two teams. -2 = Protect the Top 2 players on each team. - -*/ - -enum PlayerData -{ - Handle:hForcedTimer, - bool:bProtected; -}; - -/** -Cvars used for admins -*/ -new Handle: sas_admin_immunity_enabled = INVALID_HANDLE, - Handle: sas_admin_flag_scramblenow = INVALID_HANDLE, - Handle: sas_admin_flag_immunity = INVALID_HANDLE; - -/** -Cvars used for autoscramble -*/ -new Handle: sas_autoscramble_enabled = INVALID_HANDLE, - Handle: sas_autoscramble_minplayers = INVALID_HANDLE, - Handle: sas_autoscramble_mode = INVALID_HANDLE, - Handle: sas_autoscramble_winstreak = INVALID_HANDLE, - Handle: sas_autoscramble_steamroll = INVALID_HANDLE, - Handle: sas_autoscramble_frags = INVALID_HANDLE; - -/** -Cvars used for voting -*/ -new Handle: sas_vote_enabled = INVALID_HANDLE, - Handle: sas_vote_upcount = INVALID_HANDLE, - Handle: sas_vote_winpercent = INVALID_HANDLE, - Handle: sas_vote_mode = INVALID_HANDLE, - Handle: sas_vote_minplayers = INVALID_HANDLE; - -/** -Additional cvars -*/ -new Handle: sas_enabled = INVALID_HANDLE, - Handle: sas_timer_scrambledelay = INVALID_HANDLE, - Handle: TFGameModeArena = INVALID_HANDLE; - -/** -Timers -*/ -new Handle: g_hScrambleTimer = INVALID_HANDLE; - -/** - Player arrays - */ -new g_aPlayers[MAXPLAYERS + 1][PlayerData]; - -/** - Cvar variables - */ -new bool: g_bIsEnabled, - bool: g_bIsAutoScrambleEnabled, - bool: g_bIsVoteEnabled, - bool: g_bIsAdminImmunityEnabled; -new Float: g_fTimer_ScrambleDelay, - Float: g_fVote_UpCount, - Float: g_fVote_WinPercent; -new g_iAutoScramble_Minplayers, - g_iAutoScramble_Mode, - g_iAutoScramble_WinStreak, - g_iAutoScramble_SteamRoll, - g_iAutoScramble_Frags, - g_iVote_Mode, - g_iVote_MinPlayers; -new String: g_sScrambleNowFlag[5], - String: g_sAdminImmunityFlag[5]; - -/** -Other globals -*/ -new g_iMaxEntities, - g_iOwnerOffset; - -public Plugin:myinfo = -{ - name = "Simple AutoScrambler", - author = "Simple Plugins", - description = "Automatically scrambles the teams based upon a number of events.", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -}; - -public OnPluginStart() -{ - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook the game events - */ - LogAction(0, -1, "[SAS] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - switch (g_CurrentMod) - { - case GameType_TF: - { - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - } - case GameType_DOD: - { - HookEvent("dod_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_Post); - } - default: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_Post); - } - } - - /** - Create console variables - */ - CreateConVar("sas_version", PLUGIN_VERSION, "Simple AutoScrambler Version",FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - sas_enabled = CreateConVar("sas_enabled", "1", "Enable/Disable Simple AutoScrambler"); - sas_timer_scrambledelay = CreateConVar("sas_timer_scrambledelay", "5.0", "Delay used after a scramble has been started", _, true, 1.0, true, 30.0); - - /** - Cvars used for admins - */ - sas_admin_immunity_enabled = CreateConVar("sas_admin_immunity_enabled", "1", "Enable/Disable admin immunity for scrambles"); - sas_admin_flag_scramblenow = CreateConVar("sas_admin_flag_scramblenow", "z", "Admin flag to use for scramblenow function/command"); - sas_admin_flag_immunity = CreateConVar("sas_admin_flag_immunity", "z", "Admin flag to use for scramble immunity"); - - /** - Cvars used for autoscramble - */ - sas_autoscramble_enabled = CreateConVar("sas_autoscramble_enabled", "1", "Enable/Disable the autoscramble function"); - sas_autoscramble_minplayers = CreateConVar("sas_autoscramble_minplayers", "16", "Min players needed to start an autoscramble"); - sas_autoscramble_mode = CreateConVar("sas_autoscramble_mode", "1", "Scramble mode used when autoscrambling"); - sas_autoscramble_winstreak = CreateConVar("sas_autoscramble_winstreak", "5", "Max amount of wins in a row a team can achieve before an autoscramble starts"); - sas_autoscramble_steamroll = CreateConVar("sas_autoscramble_steamroll", "120", "Shortest amount of time a team can win by before an autoscramble starts (seconds)"); - sas_autoscramble_frags = CreateConVar("sas_autoscramble_frags", "1", "Min players needed to start a vote and scramble"); - - /** - Cvars used for voting - */ - sas_vote_enabled = CreateConVar("sas_vote_enabled", "1", "Enable/Disable voting for scramble"); - sas_vote_upcount = CreateConVar("sas_vote_upcount", "5", "Amount of people wanting a scramble before a vote starts. If less than 1 it will be considered a percentage. (ie 0.5 = 50% | 1 = 1 Player | 5 = 5 Players)"); - sas_vote_winpercent = CreateConVar("sas_vote_winpercent", "0.6", "Percentage of votes needed to scramble", _, true, 0.0, true, 1.0); - sas_vote_mode = CreateConVar("sas_vote_mode", "1", "Scramble mode used when a vote results in a scramble"); - sas_vote_minplayers = CreateConVar("sas_vote_minplayers", "16", "Min players needed to start a vote and scramble"); - - /** - Hook the console variables if they change - */ - HookConVarChange(sas_enabled, ConVarSettingsChanged); - HookConVarChange(sas_timer_scrambledelay, ConVarSettingsChanged); - HookConVarChange(sas_admin_immunity_enabled, ConVarSettingsChanged); - HookConVarChange(sas_admin_flag_scramblenow, ConVarSettingsChanged); - HookConVarChange(sas_admin_flag_immunity, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_enabled, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_minplayers, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_mode, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_winstreak, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_steamroll, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_frags, ConVarSettingsChanged); - HookConVarChange(sas_vote_enabled, ConVarSettingsChanged); - HookConVarChange(sas_vote_upcount, ConVarSettingsChanged); - HookConVarChange(sas_vote_winpercent, ConVarSettingsChanged); - HookConVarChange(sas_vote_mode, ConVarSettingsChanged); - HookConVarChange(sas_vote_minplayers, ConVarSettingsChanged); - - /** - Register the command - */ - RegConsoleCmd("sm_scramblenow", Command_ScrambleNow, "sm_scramblenow (mode): Scrambles the teams"); - - /** - Load translations and .cfg file - */ - LoadTranslations ("simpleautoscrambler.phrases"); - AutoExecConfig(true, "plugin.simpleautoscrambler"); - LogAction(0, -1, "[SAS] Simple AutoScrambler is loaded."); -} - -public OnAllPluginsLoaded() -{ - //something -} - -public OnLibraryRemoved(const String:name[]) -{ - //something -} - -public OnConfigsExecuted() -{ - - /** - Load up all the variable defaults - */ - LoadUpVariables(); - - /** - Log our activity - */ - if (g_bIsEnabled) - LogAction(0, -1, "Simple AutoScrambler is ENABLED"); - else - LogAction(0, -1, "Simple AutoScrambler is DISABLED"); -} - -public Action:Command_ScrambleNow(client, args) -{ - - /** - Make sure we are enabled - */ - if (!g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - Make sure the client is authorized to run this command. - */ - if (!SM_IsValidAdmin(client, g_sScrambleNowFlag)) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Make sure it's ok to scramble at this time - */ - if (!OkToScramble) - { - return Plugin_Handled; - } - - /** - Make sure it's ok to scramble at this time - */ - LogAction(0, -1, "[SAS] The scramblenow command was used"); - - /** - Scramble the teams - */ - StartAScramble(); - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public HookRoundStart(Handle:event, const String:name[], bool:dontBroadcast) -{ - -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - -} - -public Action:Timer_ScrambleTeams(Handle:timer, any:mode) -{ - - /** - Make sure it's still ok to scramble - */ - if (!OkToScramble) - { - return Plugin_Handled; - } - - - switch (mode) - { - case - - - - } - - - /** - Reset the handle because the timer is over and the callback is done - */ - g_hScrambleTimer = INVALID_HANDLE; - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - -} - -stock StartAScramble(mode) -{ - - /** - See if we are already started a scramble - */ - if (g_hScrambleTimer == INVALID_HANDLE) - { - - /** - There is a scramble in progress - */ - return; - - } - - /** - Report that a scramble is about to start - */ - PrintCenterTextAll("%T", "Scramble", LANG_SERVER); - - /** - Start a timer and log the action - */ - g_hScrambleTimer = CreateTimer(g_fTimer_ScrambleDelay, Timer_ScrambleTeams, mode, TIMER_FLAG_NO_MAPCHANGE); - LogAction(0, -1, "[SAS] A scamble timer was started"); -} - -stock bool:OkToScramble() -{ - -} - -stock LoadUpVariables() -{ - g_bIsEnabled = GetConVarBool(sas_enabled); - g_bIsAutoScrambleEnabled = GetConVarBool(sas_autoscramble_enabled); - g_bIsVoteEnabled = GetConVarBool(sas_vote_enabled); - g_bIsAdminImmunityEnabled = GetConVarBool(sas_admin_immunity_enabled); - g_iAutoScramble_Minplayers = GetConVarInt(sas_autoscramble_minplayers); - g_iAutoScramble_Mode = GetConVarInt(sas_autoscramble_mode); - g_iAutoScramble_WinStreak = GetConVarInt(sas_autoscramble_winstreak); - g_iAutoScramble_SteamRoll = GetConVarInt(sas_autoscramble_steamroll); - g_iAutoScramble_Frags = GetConVarInt(sas_autoscramble_frags); - g_iVote_Mode = GetConVarInt(sas_vote_mode); - g_iVote_MinPlayers = GetConVarInt(sas_vote_minplayers); - GetConVarString(sas_admin_flag_scramblenow, g_sScrambleNowFlag, sizeof(g_sScrambleNowFlag)); - GetConVarString(sas_admin_flag_immunity, g_sAdminImmunityFlag, sizeof(g_sAdminImmunityFlag)); - g_fTimer_ScrambleDelay = GetConVarFloat(sas_timer_scrambledelay); - g_fVote_UpCount = GetConVarFloat(sas_vote_upcount); - g_fVote_WinPercent = GetConVarFloat(sas_vote_winpercent); - g_iMaxEntities = GetMaxEntities(); - g_iOwnerOffset = FindSendPropInfo("CBaseObject", "m_hBuilder"); -} - -stock TF2_DestroyBuildings(client) -{ - - /** - We have to start a loop to check the owner of all the valid entities - */ - for (new i = MaxClients + 1; i <= g_iMaxEntities; i++) - { - if (!IsValidEntity(i)) - { - - /** - Not valid, continue to next one - */ - continue; - } - - /** - Get the name of the current entity - */ - decl String:sNetClass[32]; - GetEntityNetClass(i, sNetClass, sizeof(sNetClass)); - - /** - See if its something that an engineer would build - */ - if (strcmp(sNetClass, "CObjectSentrygun") == 0 - || strcmp(sNetClass, "CObjectTeleporter") == 0 - || strcmp(sNetClass, "CObjectDispenser") == 0) - { - - /** - It is, so lets check the owner - */ - if (GetEntDataEnt2(i, g_iOwnerOffset) == client) - { - - /** - It's the clients building, so we blow it up. - */ - SetVariantInt(9999); - AcceptEntityInput(i, "RemoveHealth"); - } - } - } -} \ No newline at end of file diff --git a/Simple Chat Colors/addons/sourcemod/scripting/simple-donatorbenefits.sp b/Simple Chat Colors/addons/sourcemod/scripting/simple-donatorbenefits.sp deleted file mode 100644 index e3f6845..0000000 --- a/Simple Chat Colors/addons/sourcemod/scripting/simple-donatorbenefits.sp +++ /dev/null @@ -1,1312 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Donator Benefits -Description: - Provides donator benefits to players -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include -#include - -#define PLUGIN_VERSION "1.1.$Rev$" - -#define CHAT_SYMBOL '@' -#define CHAT_MAX_MESSAGE_LENGTH 1024 - -enum PlayerData -{ - bool:bIsDonator, - bool:bQueue, - bool:bImmune, - iHealthCount, - iNewTeam -}; - -/** - Public convar handles - */ -new Handle:sdb_enabled = INVALID_HANDLE; -new Handle:sdb_donationflag = INVALID_HANDLE; -new Handle:sdb_soundfile = INVALID_HANDLE; -new Handle:sdb_joinsound_enabled = INVALID_HANDLE; -new Handle:sdb_joinpubmsg_enabled = INVALID_HANDLE; -new Handle:sdb_joinprivmsg_enabled = INVALID_HANDLE; -new Handle:sdb_chatcolors_enabled = INVALID_HANDLE; -new Handle:sdb_immunity_enabled = INVALID_HANDLE; -new Handle:sdb_ubercharge_enabled = INVALID_HANDLE; -new Handle:sdb_givehealth_enabled = INVALID_HANDLE; -new Handle:sdb_nofalldmg_enabled = INVALID_HANDLE; -new Handle:sdb_fastheavy_enabled = INVALID_HANDLE; -new Handle:sdb_swapteam_enabled = INVALID_HANDLE; -new Handle:sdb_chatcolor = INVALID_HANDLE; -new Handle:sdb_uberlevel = INVALID_HANDLE; -new Handle:sdb_healthcount = INVALID_HANDLE; -new Handle:sdb_healthbonus = INVALID_HANDLE; -new Handle:sdb_heavymultiplier = INVALID_HANDLE; - -/** -Create global enable/disable bools so we don't have to check the console variable on every call -*/ -new bool:g_bIsEnabled = true; -new bool:g_bIsJoinSoundEnabled = true; -new bool:g_bIsJoinPubMsgEnabled = true; -new bool:g_bIsJoinPrivMsgEnabled = true; -new bool:g_bIsChatColorsEnabled = true; -new bool:g_bIsImmuntyEnabled = true; -new bool:g_bIsUberChargeEnabled = true; -new bool:g_bIsGiveHealthEnabled = true; -new bool:g_bIsNoFallDmgEnabled = true; -new bool:g_bIsFastHeayEnabled = true; -new bool:g_bIsSwapTeamEnabled = true; - -/** - Player arrays - */ -new g_aPlayers[MAXPLAYERS + 1][PlayerData]; - - -/** -Rest of the globals -*/ -new bool:g_bRoundEnd = false; -new String:g_sCharDonatorFlag[5]; -new String:g_sSoundFile[PLATFORM_MAX_PATH]; -new String:g_sChatColor[11]; -new g_iHealthBonus; -new g_iHealthCount; -new g_iClassMaxHealth[TFClassType] = {0, 125, 125, 200, 175, 150, 300, 175, 125, 125}; -new g_fClassMaxSpeed[TFClassType] = {0, 400, 300, 240, 280, 320, 230, 300, 300, 300}; -new Float:g_fHeavyMultiplier = 0.0; -new Float:g_fUberLevel = 0.0; - -public Plugin:myinfo = -{ - name = "Simple Donation Benefits", - author = "Simple Plugins", - description = "Gives donators benefits to players", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -} - -public OnPluginStart() -{ - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook the game events - */ - LogAction(0, -1, "[SDB] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_connect", HookPlayerSpawn, EventHookMode_Pre); - HookEvent("player_spawn", HookPlayerSpawn, EventHookMode_Post); - HookEvent("player_death", HookPlayerDeath, EventHookMode_Post); - HookEvent("player_team", HookPlayerChangeTeam, EventHookMode_Post); - switch (g_CurrentMod) - { - case GameType_TF: - { - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - HookEvent("player_changeclass", HookPlayerClass, EventHookMode_Post); - } - case GameType_DOD: - { - HookEvent("dod_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_Post); - } - default: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - } - } - - /** - Create console variables - */ - CreateConVar("sdb_version", PLUGIN_VERSION, "Simple Donation Benefits", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - sdb_enabled = CreateConVar("sdb_enabled", "1", "Enable/Disable Simple Donation Benefits"); - sdb_donationflag = CreateConVar("sdb_donationflag", "a", "Flag ALREADY given to donators. Must be in char format"); - - /** - Create the enable/disable donator console variables - */ - sdb_joinsound_enabled = CreateConVar("sdb_joinsound_enabled", "1", "Enable/Disable donator join sound"); - sdb_joinpubmsg_enabled = CreateConVar("sdb_joinpubmsg_enabled", "1", "Enable/Disable public donator join message (replaces: as connected)"); - sdb_joinprivmsg_enabled = CreateConVar("sdb_joinprivmsg_enabled", "1", "Enable/Disable private donator join message (sent only to donator)"); - sdb_chatcolors_enabled = CreateConVar("sdb_chatcolors_enabled", "1", "Enable/Disable donator chat colors"); - sdb_immunity_enabled = CreateConVar("sdb_immunity_enabled", "1", "Enable/Disable donator round end immunity"); - sdb_ubercharge_enabled = CreateConVar("sdb_ubercharge_enabled", "1", "Enable/Disable donator medics starting with ubercharge"); - sdb_givehealth_enabled = CreateConVar("sdb_givehealth_enabled", "1", "Enable/Disable donator instant health bonus"); - sdb_nofalldmg_enabled = CreateConVar("sdb_nofalldmg_enabled", "1", "Enable/Disable no fall damage for donators"); - sdb_fastheavy_enabled = CreateConVar("sdb_fastheavy_enabled", "1", "Enable/Disable donator heavies moving faster while spinning"); - sdb_swapteam_enabled = CreateConVar("sdb_swampteam_enabled", "1", "Enable/Disable donator swap team ability"); - - /** - Create the donator setting console variables - */ - sdb_soundfile = CreateConVar("sdb_soundfile", "custom/donatorjoin.mp3", "The location of sound file"); - sdb_chatcolor = CreateConVar("sdb_chatcolor", "green", "Color to use for donator chat. Valid colors are green and lightgreen"); - sdb_uberlevel = CreateConVar("sdb_uberlevel", "0.5", "Uberlevel to give donator medic at spawn. 1.0 = full uber", _, true, 0.0, true, 1.0); - sdb_healthcount = CreateConVar("sdb_healthcount", "1", "Number of times a donator can use use instant health per life"); - sdb_healthbonus = CreateConVar("sdb_healthbonus", "100", "The amount of health to heal the donator"); - sdb_heavymultiplier = CreateConVar("sdb_heavyspeed", "0.5", "The speed multiplier for the fast heavy. Based on running speed. 1.0 = running speed. (Game Default is 0.20)", _, true, 0.0, true, 1.0); - - /** - Hook dukehacks calls - */ - dhAddClientHook(CHK_TakeDamage, Hacks_TakeDamageHook); - dhAddClientHook(CHK_PreThink, Hacks_PreThinkHook); - - /** - Hook the console variables if they change - */ - HookConVarChange(sdb_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_donationflag, ConVarSettingsChanged); - HookConVarChange(sdb_joinsound_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_joinpubmsg_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_joinprivmsg_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_chatcolors_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_immunity_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_ubercharge_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_givehealth_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_nofalldmg_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_swapteam_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_fastheavy_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_soundfile, ConVarSettingsChanged); - HookConVarChange(sdb_chatcolor, ConVarSettingsChanged); - HookConVarChange(sdb_uberlevel, ConVarSettingsChanged); - HookConVarChange(sdb_healthcount, ConVarSettingsChanged); - HookConVarChange(sdb_healthbonus, ConVarSettingsChanged); - HookConVarChange(sdb_heavymultiplier, ConVarSettingsChanged); - - /** - Register the commands - */ - RegConsoleCmd("sm_swapteams", Command_SwapTeam, "sm_swapteams <[0]instant/[1]queued>: Swaps your team to the other team"); - RegConsoleCmd("sm_ihealth", Command_InstantHealth, "sm_ihealth: Gives you a instant health pack"); - RegAdminCmd("sm_teaser", Command_Teaser, ADMFLAG_GENERIC,"sm_teaser <[0]add/[1]remove>: Gives temporary donator privilages to a player"); - RegConsoleCmd("say", Command_Say); - - RegConsoleCmd("sm_test", Command_TEST); - - /** - Load the translations - */ - LoadTranslations("common.phrases"); - LoadTranslations("simpledonatorbenefits.phrases"); - - /** - Load or create the config file - */ - AutoExecConfig(true, "plugin.simpledonatorbenefits"); - LogAction(0, -1, "[SDB] Simple Donator Benefits is loaded."); -} - -public OnAllPluginsLoaded() -{ - //something -} - -public OnLibraryRemoved(const String:name[]) -{ - //something -} - -public OnConfigsExecuted() -{ - /** - Load up all the variable defaults - */ - LoadUpVariables(); - - /** - If the join sound is enabled, prep the sound files - */ - if (g_bIsJoinSoundEnabled) - PrepSoundFile(); - - /** - Log our activity - */ - if (g_bIsEnabled) - LogAction(0, -1, "Simple Donation Benefits is ENABLED"); - else - LogAction(0, -1, "Simple Donation Benefits is DISABLED"); -} - -public OnClientPostAdminCheck(client) -{ - - /** - Check if the client is a donator - */ - if (SM_IsValidAdmin(client, g_sCharDonatorFlag)) - { - - /** - They are, so we set the player array to true and start a timer for the sound or add - */ - g_aPlayers[client][bIsDonator] = true; - if (g_bIsJoinSoundEnabled || g_bIsJoinPrivMsgEnabled) - { - CreateTimer(10.0, Timer_DonatorJoined, client, TIMER_FLAG_NO_MAPCHANGE); - } - } - else - { - /** - They aren't, so we set the player array to false - */ - g_aPlayers[client][bIsDonator] = false; - } -} - -public OnClientDisconnect_Post(client) -{ - - /** - Clean up the player variables - */ - CleanUpPlayer(client); -} - -public Action:Command_SwapTeam(client, args) -{ - - /** - Make sure we are enabled - */ - if (!g_bIsEnabled || !g_bIsSwapTeamEnabled) - { - return Plugin_Handled; - } - - /** - Make sure the command is not started by the server - */ - if (client == 0) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "PlayerLevelCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Make sure the player is a donator - */ - if (!g_aPlayers[client][bIsDonator]) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Lets make sure the client is one a team we can swap. - If he is we set the global array to the opposite team. - */ - new iTeam = GetClientTeam(client); - if (iTeam == g_aCurrentTeams[Team1]) - { - g_aPlayers[client][iNewTeam] = g_aCurrentTeams[Team2]; - } - else if (iTeam == g_aCurrentTeams[Team2]) - { - g_aPlayers[client][iNewTeam] = g_aCurrentTeams[Team1]; - } - else - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "InValidTeam", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check to see if we have command arguments. - */ - if (GetCmdArgs()) - { - - /** - We do, so lets get it and see if the client wants to be switched instantly or queued for death. - */ - decl String:sArg[5]; - GetCmdArg(1, sArg, sizeof(sArg)); - new iWantsQue = StringToInt(sArg); - if (iWantsQue && !g_aPlayers[client][bQueue]) - { - - /** - He wants the que and isn't already in it, set the global array. - */ - g_aPlayers[client][bQueue] = true; - ReplyToCommand(client, "\x01\x04[STM]\x01 %T", "PlayerQueue", LANG_SERVER); - } - else if (!iWantsQue) - { - - /** - He wants to be switched right now, lets call the stock function. - */ - SM_MovePlayer(client, g_aPlayers[client][iNewTeam]); - } - } - else - { - - /** - There are no command arguments so we build and display the swap menu. - */ - new Handle:hPlayerMenu = BuildSwapModeMenu(); - DisplayMenu(hPlayerMenu, client, MENU_TIME_FOREVER); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_InstantHealth(client, args) -{ - - /** - Make sure we are enabled - */ - if (!g_bIsEnabled || !g_bIsGiveHealthEnabled) - { - return Plugin_Handled; - } - - /** - Make sure the command is not started by the server - */ - if (client == 0) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "PlayerLevelCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Make sure the player is a donator - */ - if (!g_aPlayers[client][bIsDonator]) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check health count to see if the player has reached the max - */ - if (g_aPlayers[client][iHealthCount] >= g_iHealthCount) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "ReachedCount", LANG_SERVER); - return Plugin_Handled; - } - - /** - Get the class of the player and the max health for that class - */ - new iHealth = GetClientHealth(client); - new TFClassType:PlayerClass = TF2_GetPlayerClass(client); - new iMaxHealth = g_iClassMaxHealth[PlayerClass]; - - /** - Check to see if the player is at the max health of the class - */ - if (iHealth >= iMaxHealth) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "AtMaxHealth", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check the current health - */ - if (iHealth + g_iHealthBonus >= iMaxHealth) - { - - /** - Raise them to max health if the current health + bonus would go above it - */ - SetEntityHealth(client, iMaxHealth); - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "ToMaxHealth", LANG_SERVER); - } - else - { - - /** - Give them the instant health bonus - */ - SetEntityHealth(client, iHealth + g_iHealthBonus); - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "HealthBonus", LANG_SERVER); - } - - /** - Increase the count - */ - g_aPlayers[client][iHealthCount] += 1; - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_Teaser(client, args) -{ - - /** - Make sure we are enabled - */ - if (!g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - Check to see if we have command arguments. - */ - new iCmdArgs = GetCmdArgs(); - if (iCmdArgs == 0) - { - - /** - We don't so display the player menu. - */ - new Handle:hPlayerMenu = BuildPlayerMenu(); - DisplayMenu(hPlayerMenu, client, MENU_TIME_FOREVER); - return Plugin_Handled; - } - - /** - We have some arguments, see if we can find the player - */ - decl String:sPlayer[64]; - GetCmdArg(1, sPlayer, sizeof(sPlayer)); - new iTarget = FindTarget(client, sPlayer, true, true); - if (iTarget == -1 || !IsClientInGame(iTarget)) - { - - /** - We don't know who this is, so display the player menu. - */ - new Handle:hPlayerMenu = BuildPlayerMenu(); - DisplayMenu(hPlayerMenu, client, MENU_TIME_FOREVER); - } - else - { - /** - We found the player, see if we are supposed to turn it on or off. - */ - if (iCmdArgs >= 2) - { - decl String:sOn[3]; - GetCmdArg(2, sOn, sizeof(sOn)); - if (StringToInt(sOn)) - { - - /** - Turn temp benefits on. - */ - g_aPlayers[iTarget][bIsDonator] = true; - } - else - { - - /** - Turn temp benefits on. - */ - g_aPlayers[iTarget][bIsDonator] = false; - } - } - else - { - - /** - We don't know what to do, so just turn it on. - */ - g_aPlayers[iTarget][bIsDonator] = true; - } - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_Say(client, args) -{ - - /** - Make sure we are enabled. - */ - if (client == 0 || IsChatTrigger() || !g_bIsChatColorsEnabled || !g_bIsEnabled) - { - return Plugin_Continue; - } - - /** - Check the client to see if they are a donator. - */ - if (g_aPlayers[client][bIsDonator]) - { - - /** - The client is, so get the chat message and strip it down. - */ - decl String:sArg[CHAT_MAX_MESSAGE_LENGTH], - String:sChatMsg[CHAT_MAX_MESSAGE_LENGTH]; - new bool:bAlive = IsPlayerAlive(client); - GetCmdArgString(sArg, sizeof(sArg)); - StripQuotes(sArg); - TrimString(sArg); - new startidx; - if (sArg[strlen(sArg)-1] == '"') - { - sArg[strlen(sArg)-1] = '\0'; - startidx = 1; - } - - /** - Bug out if they are using the admin chat symbol (admin chat). - */ - if (sArg[startidx] == CHAT_SYMBOL) - { - return Plugin_Continue; - } - - /** - Format the message. - */ - FormatMessage(client, 0, bAlive, sChatMsg, sArg); - - /** - Send the message. - */ - SayText2(0, client, sChatMsg); - - /** - We are done, bug out, and stop the original chat message. - */ - return Plugin_Stop; - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -public Action:Hacks_TakeDamageHook(client, attacker, inflictor, Float:damage, &Float:multiplier, damagetype) -{ - - /** - Make sure we are enabled and the client is a donator. - */ - if (g_bIsEnabled && g_bIsNoFallDmgEnabled && g_aPlayers[client][bIsDonator]) - { - - /** - Check for fall damage. - */ - if (damagetype & DMG_FALL) - { - - /** - Cancel the fall damage and bug out. - */ - multiplier *= 0.0; - return Plugin_Changed; - } - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -public Action:Hacks_PreThinkHook(client) -{ - - /** - Make sure we are enabled and the client is a donator. - */ - if (!g_bIsEnabled || !g_bIsFastHeayEnabled || !g_aPlayers[client][bIsDonator]) - { - return Plugin_Continue; - } - - /** - Check the players class. We are looking for the heavy. - */ - new TFClassType:PlayerClass = TF2_GetPlayerClass(client); - if (PlayerClass == TFClass_Heavy) - { - - /** - We have a heavy, lets check the weapon. - */ - decl String:sWeaponCurrent[64]; - GetClientWeapon(client, sWeaponCurrent, sizeof(sWeaponCurrent)); - if (StrEqual(sWeaponCurrent, "tf_weapon_minigun", false)) - { - - /** - We have a minigun, check the heavies current weapon state to see if it's spinning. - */ - new iWeapon = GetPlayerWeaponSlot(client, 0); - new iWeaponState = GetEntProp(iWeapon, Prop_Send, "m_iWeaponState"); - if (iWeaponState > 0) - { - - /** - He is spinning, so lets change the heavies speed. - */ - new Float:fMaxSpeed = FloatMul(g_fHeavyMultiplier, float(g_fClassMaxSpeed[PlayerClass])); - SetEntPropFloat(client, Prop_Send, "m_flMaxspeed", fMaxSpeed); - } - } - } - - /** - We are done, bug out. - */ - // use Plugin_Continue (other options are ignored on PreThink hook) - return Plugin_Continue; -} - -public Action:HookPlayerConnect(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Make sure we are enabled. - */ - if (!g_bIsEnabled || !g_bIsJoinPubMsgEnabled || !dontBroadcast) - { - return Plugin_Continue; - } - - /** - Get our event variables and check the client. - */ - new iUserId = GetEventInt(event,"userid"); - new iClient = GetClientOfUserId(iUserId); - if (iClient != 0) - { - - /** - Get the info on the client and format the message. - */ - decl String:sClientName[255], - String:sAuthID[255], - String:sMsg[1024]; - - GetEventString(event, "name", sClientName, sizeof(sClientName)); - GetClientAuthString(iClient, sAuthID, sizeof(sAuthID)); - Format(sMsg, sizeof(sMsg), "%T", "PublicJoinMessage", LANG_SERVER, sClientName); - - /** - Print the message to the clients and do the normal functions. - */ - for (new i = 1; i <= MaxClients; i++) - { - if(IsClientConnected(i) && IsClientInGame(i)) - { - PrintToChat(i,"\x01\x05%s", sMsg); - PrintToConsole(i,"%s has connected.", sClientName); - } - } - LogToGame("\"%s<%d><%s><>\" entered the game", sClientName, iUserId, sAuthID); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public HookPlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled && g_bIsUberChargeEnabled) - { - - /** - Get the event variables and check the class for medic - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - if (TF2_GetPlayerClass(iClient) == TFClass_Medic) - { - - /** - Start a timer to get the medic the uber boost - */ - CreateTimer(0.25, Timer_PlayerUberDelay, iClient, TIMER_FLAG_NO_MAPCHANGE); - } - } -} - -public HookPlayerClass(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled && g_bIsUberChargeEnabled) - { - - /** - Get the event variables and check the class for medic - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - if (TF2_GetPlayerClass(iClient) == TFClass_Medic) - { - - /** - Start a timer to get the medic the uber boost - */ - CreateTimer(0.25, Timer_PlayerUberDelay, iClient, TIMER_FLAG_NO_MAPCHANGE); - } - } -} - -public HookPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled || g_bIsSwapTeamEnabled) - { - - /** - Get the event variables - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - new String:sWeapon[256]; - GetEventString(event, "weapon", sWeapon, sizeof(sWeapon)); - - /** - Bug out if world killed him. Means he changed team or something - */ - if (StrEqual(sWeapon, "world", false)) - { - g_aPlayers[iClient][bQueue] = false; - return; - } - - /** - If he is queued up, swap him - */ - if (g_aPlayers[iClient][bQueue]) - { - SM_MovePlayer(iClient, g_aPlayers[iClient][iNewTeam]); - } - } -} - -public HookPlayerChangeTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled || g_bIsSwapTeamEnabled) - { - - /** - Get the event variables - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - - /** - If he is queued up, clear the status - */ - if (g_aPlayers[iClient][bQueue]) - { - g_aPlayers[iClient][bQueue] = false; - } - } -} - -public HookRoundStart(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Set our variables. - */ - g_bRoundEnd = false; - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled && g_bIsImmuntyEnabled) - { - - /** - Get rid of their immunity. - */ - ProcessRoundEndImmunity(false); - } -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Set our variables. - */ - g_bRoundEnd = true; - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled && g_bIsImmuntyEnabled) - { - - /** - Give them their immunity. - */ - ProcessRoundEndImmunity(true); - } -} - -public Action:Timer_DonatorJoined(Handle:timer, any:client) -{ - - /** - Make sure sounds are enabled. - */ - if (g_bIsEnabled && g_bIsJoinSoundEnabled) - { - EmitSoundToClient(client, g_sSoundFile); - } - - /** - Make sure private messages are enabled. - */ - if (g_bIsJoinPrivMsgEnabled) - { - - /** - Send messages to the client. - */ - decl String:sMsg[1024]; - Format(sMsg, sizeof(sMsg), "%T", "PrivateJoinMessage", LANG_SERVER); - PrintToChat(client,"\x01\x05%s", sMsg); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Timer_PlayerUberDelay(Handle:timer, any:client) -{ - - /** - Make sure the client is still in game. - */ - if (IsClientInGame(client)) - { - - /** - Make sure the client is still a medic. - */ - if (TF2_GetPlayerClass(client) == TFClass_Medic) - { - - /** - Get the medgun weapon index - */ - new iIndex = GetPlayerWeaponSlot(client, 1); - if (iIndex > 0) - { - - /** - Set the uber level with the bonus. - */ - SetEntPropFloat(iIndex, Prop_Send, "m_flChargeLevel", g_fUberLevel); - } - } - } -} - -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (convar == sdb_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsEnabled = false; - } - else - { - g_bIsEnabled = true; - } - } - else if (convar == sdb_donationflag) - { - Format(g_sCharDonatorFlag, sizeof(g_sCharDonatorFlag), "%s", newValue); - } - else if (convar == sdb_soundfile) - { - Format(g_sSoundFile, sizeof(g_sSoundFile), "%s", newValue); - } - else if (convar == sdb_joinsound_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsJoinSoundEnabled = false; - } - else - { - g_bIsJoinSoundEnabled = true; - } - } - else if (convar == sdb_joinpubmsg_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsJoinPubMsgEnabled = false; - } - else - { - g_bIsJoinPubMsgEnabled = true; - } - } - else if (convar == sdb_joinprivmsg_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsJoinPrivMsgEnabled = false; - } - else - { - g_bIsJoinPrivMsgEnabled = true; - } - } - else if (convar == sdb_chatcolors_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsChatColorsEnabled = false; - } - else - { - g_bIsChatColorsEnabled = true; - } - } - else if (convar == sdb_immunity_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsImmuntyEnabled = false; - } - else - { - g_bIsImmuntyEnabled = true; - } - } - else if (convar == sdb_ubercharge_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsUberChargeEnabled = false; - } - else - { - g_bIsUberChargeEnabled = true; - } - } - else if (convar == sdb_givehealth_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsGiveHealthEnabled = false; - } - else - { - g_bIsGiveHealthEnabled = true; - } - } - else if (convar == sdb_nofalldmg_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsNoFallDmgEnabled = false; - } - else - { - g_bIsNoFallDmgEnabled = true; - } - } - else if (convar == sdb_fastheavy_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsFastHeayEnabled = false; - } - else - { - g_bIsFastHeayEnabled = true; - } - } - else if (convar == sdb_swapteam_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsSwapTeamEnabled = false; - } - else - { - g_bIsSwapTeamEnabled = true; - } - } - else if (convar == sdb_chatcolor) - { - Format(g_sChatColor, sizeof(g_sChatColor), "%s", newValue); - } - else if (convar == sdb_uberlevel) - { - g_fUberLevel = StringToFloat(newValue); - } - else if (convar == sdb_healthcount) - { - g_iHealthCount = StringToInt(newValue); - } - else if (convar == sdb_healthbonus) - { - g_iHealthBonus = StringToInt(newValue); - } - else if (convar == sdb_heavymultiplier) - { - g_fHeavyMultiplier = StringToFloat(newValue); - } -} - -stock LoadUpVariables() -{ - g_bIsEnabled = GetConVarBool(sdb_enabled); - g_bIsJoinSoundEnabled = GetConVarBool(sdb_enabled); - g_bIsJoinPubMsgEnabled = GetConVarBool(sdb_enabled); - g_bIsJoinPrivMsgEnabled = GetConVarBool(sdb_enabled); - g_bIsChatColorsEnabled = GetConVarBool(sdb_enabled); - g_bIsImmuntyEnabled = GetConVarBool(sdb_enabled); - g_bIsUberChargeEnabled = GetConVarBool(sdb_enabled); - g_bIsGiveHealthEnabled = GetConVarBool(sdb_enabled); - g_bIsNoFallDmgEnabled = GetConVarBool(sdb_enabled); - g_bIsFastHeayEnabled = GetConVarBool(sdb_enabled); - g_bIsSwapTeamEnabled = GetConVarBool(sdb_enabled); - GetConVarString(sdb_donationflag, g_sCharDonatorFlag, sizeof(g_sCharDonatorFlag)); - GetConVarString(sdb_soundfile, g_sSoundFile, sizeof(g_sSoundFile)); - GetConVarString(sdb_chatcolor, g_sChatColor, sizeof(g_sChatColor)); - g_bRoundEnd = false; - g_iHealthBonus = GetConVarInt(sdb_healthbonus); - g_iHealthCount = GetConVarInt(sdb_healthcount); - g_fHeavyMultiplier = GetConVarFloat(sdb_heavymultiplier); - g_fUberLevel = GetConVarFloat(sdb_uberlevel); -} - -stock PrepSoundFile() -{ - decl String:buffer[PLATFORM_MAX_PATH]; - PrecacheSound(g_sSoundFile, true); - Format(buffer, sizeof(buffer), "sound/%s", g_sSoundFile); - AddFileToDownloadsTable(buffer); -} - -stock CleanUpPlayer(client) -{ - g_aPlayers[client][bIsDonator] = false; - g_aPlayers[client][bQueue] = false; - g_aPlayers[client][bImmune] = false; - g_aPlayers[client][iNewTeam] = 0; - g_aPlayers[client][iHealthCount] = 0; -} - -stock ProcessRoundEndImmunity(bool:give) -{ - for (new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][bIsDonator]) - { - if (give) - { - SetEntProp(i, Prop_Data, "m_takedamage", 0, 1); - g_aPlayers[i][bImmune] = true; - } - else - { - SetEntProp(i, Prop_Data, "m_takedamage", 2, 1); - g_aPlayers[i][bImmune] = false; - } - } - } -} - -stock FormatMessage(iClient, iTeam, bool:bAlive, String:sChatMsg[], const Sting:sMessage[]) -{ - decl String:sDead[10], - String:sTeam[10], - String:sClientName[64]; - GetClientName(iClient, sClientName, sizeof(sClientName)); - if (iTeam != 0) - Format(sTeam, sizeof(sTeam), "(TEAM) "); - else - Format(sTeam, sizeof(sTeam), ""); - if (bAlive) - Format(sDead, sizeof(sDead), ""); - else - Format(sDead, sizeof(sDead), "*DEAD* "); - if (StrContains(g_sChatColor, "light", false) == -1) - Format(sChatMsg, CHAT_MAX_MESSAGE_LENGTH, "\x01%s%s\x03%s \x01: \x05%s", sDead, sTeam, sClientName, sMessage); - else - Format(sChatMsg, CHAT_MAX_MESSAGE_LENGTH, "\x01%s%s\x03%s \x01: \x04%s", sDead, sTeam, sClientName, sMessage); -} - -stock SayText2(target, author, const String:message[]) -{ - new Handle:hBf; - if (target == 0) - hBf = StartMessageAll("SayText2"); - else - hBf = StartMessageOne("SayText2", target); - if (hBf != INVALID_HANDLE) - { - BfWriteByte(hBf, author); - BfWriteByte(hBf, true); - BfWriteString(hBf, message); - EndMessage(); - } -} - -stock ProcessAdmins() -{ - for (new i = 1; i <= MaxClients; i++) - { - if (SM_IsValidAdmin(i, g_sCharDonatorFlag)) - { - g_aPlayers[i][bDonator] = true; - } - else - { - g_aPlayers[i][bDonator] = false; - } - } -} - -stock ProcessLate() -{ - if (g_bIsEnabled) - { - ProcessAdmins(); - PrepSoundFile(); - if (g_bRoundEnd && g_bIsImmuntyEnabled) - { - ProcessRoundEndImmunity(true); - } - if (!g_bIsImmuntyEnabled) - { - ProcessRoundEndImmunity(false); - } - } - else - { - ProcessRoundEndImmunity(false); - } -} - -public Menu_SwapMode(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, 64); - if (StringToInt(sSelection)) - g_aPlayers[param1][bQueue] = false; - else - g_aPlayers[param1][bQueue] = true; - if (!g_aPlayers[param1][bQueue]) - SM_MovePlayer(param1, g_aPlayers[param1][iNewTeam]); - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -public Menu_SelectPlayer(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[256]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - new iTarget = GetClientOfUserId(StringToInt(sSelection)); - if (g_aPlayers[iTarget][bIsDonator]) - g_aPlayers[iTarget][bIsDonator] = false; - else - g_aPlayers[iTarget][bIsDonator] = true; - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -stock Handle:BuildSwapModeMenu() -{ - new Handle:menu = CreateMenu(Menu_SwapMode); - SetMenuTitle(menu, "Select When to Swap:"); - AddMenuItem(menu, "0", "Instantly (Kills)"); - AddMenuItem(menu, "1", "Queue on next death"); - SetMenuExitBackButton(menu, false); - return menu; -} - -stock Handle:BuildPlayerMenu() -{ - new Handle:menu = CreateMenu(Menu_SelectPlayer); - AddTargetsToMenu(menu, 0, true, false); - SetMenuTitle(menu, "Select A Player:"); - SetMenuExitBackButton(menu, true); - return menu; -} - -public Action:Command_TEST(client, args) -{ - -} \ No newline at end of file diff --git a/Simple Chat Colors/addons/sourcemod/scripting/simple-messagesuppression.sp b/Simple Chat Colors/addons/sourcemod/scripting/simple-messagesuppression.sp deleted file mode 100644 index f7725a4..0000000 --- a/Simple Chat Colors/addons/sourcemod/scripting/simple-messagesuppression.sp +++ /dev/null @@ -1,227 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Message Suppression -Description: - Blocks Specific Message Outputs -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include -#include - -#define SUPPRESS_VERSION "1.1.$Rev$" - -public Plugin:myinfo = -{ - name = "Simple Message Suppression", - author = "FlyingMongoose, psychonic", - description = "Blocks Specific Message Outputs", - version = SUPPRESS_VERSION, - url = "http://www.simple-plugins.com/" -} - -new Handle:cvarBlockSpectateMessage; -new Handle:cvarBlockDisconnectMessage; -new Handle:cvarBlockConnectMessage; -new Handle:cvarAdminShowMessages; -new iSpecTeam = 1; - - -public OnPluginStart() -{ - CreateConVar("suppress_version", SUPPRESS_VERSION, _, FCVAR_PLUGIN|FCVAR_NOTIFY|FCVAR_REPLICATED|FCVAR_SPONLY|FCVAR_DONTRECORD); - cvarBlockSpectateMessage = CreateConVar("sm_blockspectatemessage", "1", "If enabled it blocks the join team message if an administrator joins spectator", FCVAR_PLUGIN, true, 0.0, true, 1.0); - cvarBlockDisconnectMessage = CreateConVar("sm_blockdisconnectmessage", "1", "Blocks the disconnect message", FCVAR_PLUGIN, true, 0.0, true, 1.0); - cvarBlockConnectMessage = CreateConVar("sm_blockconnectmessage", "1", "If enabled it blocks the player connection message.", FCVAR_PLUGIN, true, 0.0, true, 1.0); - cvarAdminShowMessages = CreateConVar("sm_adminshowmessages", "1", "Shows disconnect/connect/team join messages for admins only (if disconnect message is set to be blocked)", FCVAR_PLUGIN, true, 0.0, true, 1.0); - HookEvent("player_team", ev_PlayerTeam, EventHookMode_Pre); - HookEvent("player_disconnect", ev_PlayerDisconnect, EventHookMode_Pre); - HookEvent("player_connect", ev_PlayerConnect, EventHookMode_Pre); - - new String:game_folder[64]; - GetGameFolderName(game_folder, sizeof(game_folder)) - - if (StrContains(game_folder, "insurgency", false) != -1) - { - iSpecTeam = 3; - } - else - { - new String:game_description[64]; - GetGameDescription(game_description, sizeof(game_description), true); - if (StrContains(game_description, "Insurgency", false) != -1) - { - iSpecTeam = 3; - } - } - - AutoExecConfig(true, "suppressmessage", "sourcemod"); -} - -public Action:ev_PlayerTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - if (GetConVarBool(cvarBlockSpectateMessage)) - { - if (!dontBroadcast && !GetEventBool(event, "silent")) - { - new iUserId = GetEventInt(event, "userid"); - new iClient = GetClientOfUserId(iUserId); - new iTeam = GetEventInt(event, "team"); - - if (iTeam == iSpecTeam && GetAdminFlag(GetUserAdmin(iClient), Admin_Kick)) - { - new iOldTeam = GetEventInt(event, "oldteam"); - new bool:bDisconnect = GetEventBool(event, "disconnect"); - new bool:bAutoteam = GetEventBool(event, "autoteam"); - decl String:strName[50]; - GetEventString(event, "name", strName, sizeof(strName)); - - if (iClient != 0) - { - if (GetConVarInt(cvarAdminShowMessages) == 1) - { - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientConnected(i) && IsClientInGame(i) && GetUserAdmin(i) != INVALID_ADMIN_ID) - { - PrintToChat(i,"%N joined team Spectator.", iClient); - PrintToConsole(i,"%N joined team Spectator.", iClient); - } - } - } - } - - new Handle:hEvent = CreateEvent("player_team"); - SetEventInt(hEvent, "userid", iUserId); - SetEventInt(hEvent, "team", iTeam); - SetEventInt(hEvent, "oldteam", iOldTeam); - SetEventBool(hEvent, "disconnect", bDisconnect); - SetEventBool(hEvent, "autoteam", bAutoteam); - SetEventBool(hEvent, "silent", true); - SetEventString(hEvent, "name", strName); - - FireEvent(hEvent, true); - - return Plugin_Handled; - } - } - } - return Plugin_Continue; -} -public Action:ev_PlayerConnect(Handle:event, const String:name[], bool:dontBroadcast) -{ - if (GetConVarBool(cvarBlockConnectMessage)) - { - if (!dontBroadcast) - { - decl String:strName[50]; - GetEventString(event, "name", strName, sizeof(strName)); - new iIndex = GetEventInt(event, "index"); - new iUserId = GetEventInt(event, "userid"); - new iClient = GetClientOfUserId(iUserId); - decl String:strNetworkId[50]; - GetEventString(event, "networkid", strNetworkId, sizeof(strNetworkId)); - decl String:strAddress[50]; - GetEventString(event, "address", strAddress, sizeof(strAddress)); - - if (iClient != 0) - { - if (GetConVarInt(cvarAdminShowMessages) == 1) - { - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientConnected(i) && IsClientInGame(i) && GetUserAdmin(i) != INVALID_ADMIN_ID) - { - PrintToChat(i,"%N has connected.", iClient); - PrintToConsole(i,"%N has connected.", iClient); - } - } - } - } - - new Handle:hEvent = CreateEvent("player_connect"); - SetEventString(hEvent, "name", strName); - SetEventInt(hEvent, "index", iIndex); - SetEventInt(hEvent, "userid", iUserId); - SetEventString(hEvent, "networkid", strNetworkId); - SetEventString(hEvent, "address", strAddress); - - FireEvent(hEvent, true); - - return Plugin_Handled; - } - } - return Plugin_Continue; -} -public Action:ev_PlayerDisconnect(Handle:event, const String:name[], bool:dontBroadcast) -{ - if (GetConVarBool(cvarBlockDisconnectMessage)) - { - if (!dontBroadcast) - { - new iUserId = GetEventInt(event, "userid"); - new iClient = GetClientOfUserId(iUserId); - decl String:strReason[50]; - GetEventString(event, "reason", strReason, sizeof(strReason)); - decl String:strName[50]; - GetEventString(event, "name", strName, sizeof(strName)); - decl String:strNetworkId[50]; - GetEventString(event, "networkid", strNetworkId, sizeof(strNetworkId)); - - if (iClient != 0) - { - if (GetConVarInt(cvarAdminShowMessages) == 1) - { - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientConnected(i) && IsClientInGame(i) && GetUserAdmin(i) != INVALID_ADMIN_ID) - { - PrintToChat(i, "%N has left the server.", iClient); - PrintToConsole(i, "Dropped %N from server (Disconnect by user.)", iClient); - } - } - } - } - - new Handle:hEvent = CreateEvent("player_disconnect"); - SetEventInt(hEvent, "userid", iUserId); - SetEventString(hEvent, "reason", strReason); - SetEventString(hEvent, "name", strName); - SetEventString(hEvent, "networkid", strNetworkId); - - FireEvent(hEvent, true); - - return Plugin_Handled; - } - } - - return Plugin_Continue; -} \ No newline at end of file diff --git a/Simple Chat Colors/addons/sourcemod/scripting/simple-plugins.sp b/Simple Chat Colors/addons/sourcemod/scripting/simple-plugins.sp deleted file mode 100644 index 4462b41..0000000 --- a/Simple Chat Colors/addons/sourcemod/scripting/simple-plugins.sp +++ /dev/null @@ -1,785 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Plugins -Description: - Core plugin for Simple Plugins project -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#define CORE_PLUGIN_VERSION "1.1.$Rev$" - -#include - -enum e_PlayerInfo -{ - Handle:hForcedTeamPlugin = INVALID_HANDLE, - iForcedTeam = 0, - iBuddy = 0, - bool:bBuddyLocked = false -}; - -new Handle:g_fwdPlayerMoved; -new g_aPlayers[MAXPLAYERS + 1][e_PlayerInfo]; -new bool:g_bTeamsSwitched = false; - -/** -Setting our plugin information. -*/ -public Plugin:myinfo = -{ - name = "Simple Plugins Core Plugin", - author = "Simple Plugins", - description = "Core plugin for Simple Plugins", - version = CORE_PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -}; - -public bool:AskPluginLoad(Handle:myself, bool:late, String:error[], err_max) -{ - - /** - Register natives for other plugins - */ - CreateNative("SM_MovePlayer", Native_SM_MovePlayer); - CreateNative("SM_SetForcedTeam", Native_SM_SetForcedTeam); - CreateNative("SM_GetForcedTeam", Native_SM_GetForcedTeam); - CreateNative("SM_ClearForcedTeam", Native_SM_ClearForcedTeam); - CreateNative("SM_GetForcedPlayer", Native_SM_GetForcedPlayer); - CreateNative("SM_AssignBuddy", Native_SM_AssignBuddy); - CreateNative("SM_GetClientBuddy", Native_SM_GetClientBuddy); - CreateNative("SM_LockBuddy", Native_SM_LockBuddy); - CreateNative("SM_IsBuddyLocked", Native_SM_IsBuddyLocked); - CreateNative("SM_ClearBuddy", Native_SM_ClearBuddy); - CreateNative("SM_IsValidAdmin", Native_SM_IsValidAdmin); - CreateNative("SM_IsValidTeam", Native_SM_IsValidTeam); - RegPluginLibrary("simpleplugins"); - return true; -} - -public OnPluginStart() -{ - - CreateConVar("ssm_core_pl_ver", CORE_PLUGIN_VERSION, "Simple SourceMod Plugins Core Plugin Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - CreateConVar("ssm_core_inc_ver", CORE_INC_VERSION, "Simple SourceMod Plugins Core Include Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook some events to control forced players and check extensions - */ - decl String:sExtError[256]; - LogAction(0, -1, "[SSM] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_team", HookPlayerChangeTeam, EventHookMode_Pre); - switch (g_CurrentMod) - { - case GameType_CSS: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - new iExtStatus = GetExtensionFileStatus("game.cstrike.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SSM] Required extension was not found."); - LogAction(0, -1, "[SSM] Plugin FAILED TO LOAD."); - SetFailState("Required extension was not found."); - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SSM] Required extension is loaded with errors."); - LogAction(0, -1, "[SSM] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SSM] Plugin FAILED TO LOAD."); - SetFailState("Required extension is loaded with errors."); - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SSM] Required extension is loaded."); - } - } - case GameType_TF: - { - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_PostNoCopy); - HookUserMessage(GetUserMessageId("TextMsg"), UserMessageHook_Class, true); - new iExtStatus = GetExtensionFileStatus("game.tf2.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SSM] Required extension was not found."); - LogAction(0, -1, "[SSM] Plugin FAILED TO LOAD."); - SetFailState("Required extension was not found."); - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SSM] Required extension is loaded with errors."); - LogAction(0, -1, "[SSM] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SSM] Plugin FAILED TO LOAD."); - SetFailState("Required extension is loaded with errors."); - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SSM] Required extension is loaded."); - } - } - case GameType_DOD: - { - HookEvent("dod_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_PostNoCopy); - } - default: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - } - } - - /** - Load common translations - */ - LoadTranslations ("common.phrases"); - - /** - Create the global forward - */ - g_fwdPlayerMoved = CreateGlobalForward("SM_OnPlayerMoved", ET_Event, Param_Cell, Param_Cell, Param_Cell); -} - -public OnClientDisconnect(client) -{ - - /** - Cleanup clients/players buddy list - */ - if (!IsFakeClient(client)) - { - SM_ClearBuddy(client, true); - SM_LockBuddy(client, false); - } - SM_ClearForcedTeam(client); -} - -public HookRoundStart(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - See if the teams have been switched - */ - if (g_bTeamsSwitched) - { - - /** - Switch the teams the players are forced to - */ - for (new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][iForcedTeam] != 0) - { - if (g_aPlayers[i][iForcedTeam] == g_aCurrentTeams[Team1]) - { - g_aPlayers[i][iForcedTeam] = g_aCurrentTeams[Team2]; - } - else - { - g_aPlayers[i][iForcedTeam] = g_aCurrentTeams[Team1]; - } - } - } - } -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - g_bTeamsSwitched = false; -} - -public HookPlayerChangeTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get our event variables - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - new iTeam = GetEventInt(event, "team"); - - /** - See if the player is on the wrong team - */ - if (g_aPlayers[iClient][iForcedTeam] != 0 && g_aPlayers[iClient][iForcedTeam] != iTeam) - { - - /** - Move the player back to the forced team - */ - CreateTimer(1.0, Timer_ForcePlayerMove, iClient, TIMER_FLAG_NO_MAPCHANGE); - - /** - If the event was going to be broadcasted, we refire it so it is not broadcasted and stop this one - */ - if (!dontBroadcast) - { - new Handle:hEvent = CreateEvent("player_team"); - SetEventInt(hEvent, "userid", GetEventInt(event, "userid")); - SetEventInt(hEvent, "team", GetEventInt(event, "team")); - SetEventInt(hEvent, "oldteam", GetEventInt(event, "oldteam")); - SetEventBool(hEvent, "disconnect", GetEventBool(event, "disconnect")); - - if (g_CurrentMod == GameType_DOD || g_CurrentMod == GameType_L4D || g_CurrentMod == GameType_TF) - { - new String:sClientName[MAX_NAME_LENGTH + 1]; - GetClientName(client, sClientName, sizeof(sClientName)); - SetEventBool(hEvent, "autoteam", GetEventBool(event, "autoteam")); - SetEventBool(hEvent, "silent", true); - SetEventString(hEvent, "name", sClientName); - FireEvent(hEvent, true); - } - else - { - FireEvent(hEvent, true); - } - return Plugin_Handled; - } - } - return Plugin_Continue; -} - -public Action:UserMessageHook_Class(UserMsg:msg_id, Handle:bf, const players[], playersNum, bool:reliable, bool:init) -{ - new String:sMessage[120]; - BfReadString(bf, sMessage, sizeof(sMessage), true); - if (StrContains(sMessage, "#TF_TeamsSwitched", false) != -1) - { - g_bTeamsSwitched = true; - } - return Plugin_Continue; -} - -public Native_SM_MovePlayer(Handle:plugin, numParams) -{ - - /** - Get and check the client and team - */ - new iClient = GetNativeCell(1); - new iTeam = GetNativeCell(2); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (iTeam != g_aCurrentTeams[Spectator] && iTeam != g_aCurrentTeams[Team1] && iTeam != g_aCurrentTeams[Team2]) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid team %d", iTeam); - } - - MovePlayer(iClient, iTeam); - if (!IsClientObserver(iClient)) - { - RespawnPlayer(iClient); - } - - new fResult; - - Call_StartForward(g_fwdPlayerMoved); - Call_PushCell(plugin); - Call_PushCell(iClient); - Call_PushCell(iTeam); - Call_Finish(fResult); - - if (fResult != SP_ERROR_NONE) - { - return ThrowNativeError(fResult, "Forward failed"); - } - - return fResult; -} - -public Native_SM_SetForcedTeam(Handle:plugin, numParams) -{ - - /** - Get and check the client and team - */ - new iClient = GetNativeCell(1); - new iTeam = GetNativeCell(2); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (iTeam != g_aCurrentTeams[Spectator] && iTeam != g_aCurrentTeams[Team1] && iTeam != g_aCurrentTeams[Team2] && iTeam != g_aCurrentTeams[Unknown]) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid team %d", iTeam); - } - - new bool:bOverRide = GetNativeCell(3) ? true : false; - - if (!bOverRide && g_aPlayers[iClient][hForcedTeamPlugin] != INVALID_HANDLE && plugin != g_aPlayers[iClient][hForcedTeamPlugin]) - { - return false; - } - - g_aPlayers[iClient][hForcedTeamPlugin] = plugin; - g_aPlayers[iClient][iForcedTeam] = iTeam; - return true; -} - -public Native_SM_GetForcedTeam(Handle:plugin, numParams) -{ - - /** - Get and check the client - */ - new iClient = GetNativeCell(1); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - - /** - Get and set the plugin if they want it - */ - new Handle:hPlugin = GetNativeCell(2); - if (hPlugin != INVALID_HANDLE) - { - SetNativeCellRef(2, g_aPlayers[iClient][hForcedTeamPlugin]); - } - - /** - Return the forced team, this could be 0 - */ - return g_aPlayers[iClient][iForcedTeam]; -} - -public Native_SM_ClearForcedTeam(Handle:plugin, numParams) -{ - - /** - Get and check the client and team - */ - new iClient = GetNativeCell(1); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - - g_aPlayers[iClient][hForcedTeamPlugin] = INVALID_HANDLE; - g_aPlayers[iClient][iForcedTeam] = 0; - - return true; -} - -public Native_SM_GetForcedPlayer(Handle:plugin, numParams) -{ - - /** - Get and check the team - */ - new iTeam = GetNativeCell(1); - if (iTeam != g_aCurrentTeams[Spectator] && iTeam != g_aCurrentTeams[Team1] && iTeam != g_aCurrentTeams[Team2]) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid team %d", iTeam); - } - - /** - Start a loop to check for a player on the wrong team - Also make sure the plugin that set the forced team is the plugin that asked - */ - new iPlayer = 0; - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientInGame(i) - && GetClientTeam(i) != g_aPlayers[i][iForcedTeam] - && g_aPlayers[i][iForcedTeam] == iTeam - && g_aPlayers[i][hForcedTeamPlugin] == plugin) - { - iPlayer = i; - break; - } - } - - /** - Return the player we found, this could be 0 - */ - return iPlayer; -} - -public Native_SM_AssignBuddy(Handle:plugin, numParams) -{ - - /** - Get and check the client and player - */ - new iClient = GetNativeCell(1); - new iPlayer = GetNativeCell(2); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (iPlayer < 0 || iPlayer > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid player index (%d)", iPlayer); - } - if (!IsClientConnected(iPlayer)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Player %d is not connected", iPlayer); - } - if (!IsClientInGame(iPlayer)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Player %d is not in the game", iClient); - } - if (IsFakeClient(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Bots are not supported"); - } - - /** - See if we can override his setting - */ - new bool:bOverRide = GetNativeCell(3) ? true : false; - if (!bOverRide) - { - - /** - We can't override, so check if they are locked - */ - if (g_aPlayers[iClient][bBuddyLocked] || g_aPlayers[iPlayer][bBuddyLocked]) - { - - /** - We detected at least 1 lock, so we bug out - */ - return false; - } - } - - /** - Ready to set the buddies - */ - g_aPlayers[iClient][iBuddy] = iPlayer; - g_aPlayers[iPlayer][iBuddy] = iClient; - return true; -} - -public Native_SM_GetClientBuddy(Handle:plugin, numParams) -{ - - /** - Get and check the client - */ - new iClient = GetNativeCell(1); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (IsFakeClient(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Bots are not supported"); - } - - /** - Return the players buddy, this could be 0 - */ - return g_aPlayers[iClient][iBuddy]; -} - -public Native_SM_LockBuddy(Handle:plugin, numParams) -{ - - /** - Get and check the client - */ - new iClient = GetNativeCell(1); - new bool:bSetting = GetNativeCell(2) ? true : false; - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (IsFakeClient(iClient)) - { - return ThrowNativeError(SP_ERROR_NATIVE, "Bots are not supported"); - } - - g_aPlayers[iClient][bBuddyLocked] = bSetting; - return true; -} - -public Native_SM_IsBuddyLocked(Handle:plugin, numParams) -{ - - /** - Get and check the client - */ - new iClient = GetNativeCell(1); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (IsFakeClient(iClient)) - { - return ThrowNativeError(SP_ERROR_NATIVE, "Bots are not supported"); - } - - return g_aPlayers[iClient][bBuddyLocked]; -} - -public Native_SM_ClearBuddy(Handle:plugin, numParams) -{ - - /** - Get and check the client - */ - new iClient = GetNativeCell(1); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_NATIVE, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_NATIVE, "Client (%d) is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (IsFakeClient(iClient)) - { - return ThrowNativeError(SP_ERROR_NATIVE, "Bots are not supported"); - } - - /** - Get the clients buddy and see if we can override his setting - */ - new bool:bOverRide = GetNativeCell(2) ? true : false; - new iPlayer = g_aPlayers[iClient][iBuddy]; - - /** - There is no buddy, we don't care about anything else so bug out - */ - if (iPlayer == 0) - { - return true; - } - - /** - We determined he had a buddy, check the override setting - */ - if (!bOverRide) - { - - /** - We can't override, so check if they are locked - */ - if (g_aPlayers[iClient][bBuddyLocked] || g_aPlayers[iPlayer][bBuddyLocked]) - { - - /** - We detected at least 1 lock, so we bug out - */ - return false; - } - } - - /** - Ready to clear the buddies - */ - g_aPlayers[iClient][iBuddy] = 0; - g_aPlayers[iPlayer][iBuddy] = 0; - return true; -} - -public Native_SM_IsValidTeam(Handle:plugin, numParams) -{ - - /** - Get the team - */ - new iTeam = GetNativeCell(1); - - /** - Check the team - */ - if (iTeam == g_aCurrentTeams[Spectator] || iTeam == g_aCurrentTeams[Team1] || iTeam == g_aCurrentTeams[Team2]) - { - return true; - } - return false; -} - -public Native_SM_IsValidAdmin(Handle:plugin, numParams) -{ - /** - Get the client and flags - */ - new iClient = GetNativeCell(1); - decl String:sFlags[15]; - GetNativeString(2, sFlags, sizeof(sFlags)); - new ibFlags = ReadFlagString(sFlags); - - /** - Check the flags - */ - if ((GetUserFlagBits(iClient) & ibFlags) == ibFlags) - { - return true; - } - if (GetUserFlagBits(iClient) & ADMFLAG_ROOT) - { - return true; - } - return false; -} - -public Action:Timer_ForcePlayerMove(Handle:timer, any:iClient) -{ - - MovePlayer(iClient, g_aPlayers[iClient][iForcedTeam]); - - if (g_aPlayers[iClient][iForcedTeam] != g_aCurrentTeams[Spectator]) - { - RespawnPlayer(iClient); - } - - PrintToChat(iClient, "\x01\x04----------------------------------"); - PrintToChat(iClient, "\x01\x04You have been forced to this team."); - PrintToChat(iClient, "\x01\x04----------------------------------"); - - return Plugin_Handled; -} - -stock MovePlayer(iClient, iTeam) -{ - - /** - Change the client's team based on the mod - */ - switch (g_CurrentMod) - { - case GameType_CSS: - { - CS_SwitchTeam(iClient, iTeam); - } - default: - { - ChangeClientTeam(iClient, iTeam); - } - } -} - -stock RespawnPlayer(iClient) -{ - - /** - Respawn the client based on the mod - */ - switch (g_CurrentMod) - { - case GameType_CSS: - { - CS_RespawnPlayer(iClient); - } - case GameType_TF: - { - TF2_RespawnPlayer(iClient); - } - case GameType_INS: - { - FakeClientCommand(iClient, "kill"); - } - default: - { - // - } - } -} diff --git a/Simple Chat Colors/addons/sourcemod/scripting/simple-roundimmunity.sp b/Simple Chat Colors/addons/sourcemod/scripting/simple-roundimmunity.sp deleted file mode 100644 index 5f0bca3..0000000 --- a/Simple Chat Colors/addons/sourcemod/scripting/simple-roundimmunity.sp +++ /dev/null @@ -1,947 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Round Immunity -Description: - Gives admins immunity during certain rounds -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or any later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#pragma semicolon 1 -#include -#include -#undef REQUIRE_EXTENSIONS -#undef AUTOLOAD_EXTENSIONS -#include -#include -#define REQUIRE_EXTENSIONS -#define AUTOLOAD_EXTENSIONS - -#define PLUGIN_VERSION "1.1.$Rev$" -#define SPECTATOR 1 -#define TEAM_RED 2 -#define TEAM_BLUE 3 - -#define COLOR_GREEN 0 -#define COLOR_BLACK 1 -#define COLOR_RED 2 -#define COLOR_BLUE 3 -#define COLOR_TEAM 4 -#define COLOR_RAINBOW 5 -#define COLOR_NONE 6 - -#define PLAYERCOND_SLOWED (1<<0) //1 -#define PLAYERCOND_ZOOMED (1<<1) //2 -#define PLAYERCOND_DISGUISING (1<<2) //4 -#define PLAYERCOND_DISGUISED (1<<3) //8 -#define PLAYERCOND_SPYCLOAK (1<<4) //16 -#define PLAYERCOND_UBERED (1<<5) //32 -#define PLAYERCOND_TELEPORTTRAIL (1<<6) //64 -#define PLAYERCOND_TAUNT (1<<7) //128 -// (1<<8) //256 -// (1<<9) //512 -#define PLAYERCOND_TELEPORTFLASH (1<<10) //1024 -#define PLAYERCOND_KRUBER (1<<11) //2048 -// (1<<12) //4096 -// (1<<13) //8192 -#define PLAYERCOND_BONKED (1<<14) //16384 (blame Neph if it doesn't work) -#define PLAYERCOND_BONKEDORDRINKSLOWDOWN (1<<15) //32768 -#define PLAYERCOND_HEALING (1<<16) //65536 -#define PLAYERCOND_BURNING (1<<17) //131072 -#define PLAYERCOND_FULLYCHARGEDBYMEDIC (1<<18) //262144 - -enum e_Cookies -{ - bEnabled, - iColor, - iMode -}; - -enum e_ColorNames -{ - Green, - Black, - Red, - Blue -}; - -enum e_ColorValues -{ - iRed, - iGreen, - iBlue -}; - -enum e_PlayerData -{ - Handle:hGodModeTimer, - Handle:hColorTimer, - bool:bIsAdmin, - bool:bIsImmune, - iCycleColor -}; - -/** - Global convar handles - */ -new Handle:sri_charadminflag = INVALID_HANDLE; -new Handle:sri_enabled = INVALID_HANDLE; -new Handle:sri_cookie_enabled = INVALID_HANDLE; -new Handle:sri_cookie_color = INVALID_HANDLE; -new Handle:sri_cookie_mode = INVALID_HANDLE; - -/** - Player arrays - */ -new g_aPlayers[MAXPLAYERS + 1][e_PlayerData]; -new g_aClientCookies[MAXPLAYERS + 1][e_Cookies]; - -/** - Global bools - */ -new bool:g_bLoadedLate = false; -new bool:g_bIsEnabled = true; -new bool:g_bRoundEnd = false; -new bool:g_bUseDukehacks = false; -new bool:g_bUseClientprefs = false; - -/** - Global strings/integers/floats - */ -new String:g_sCharAdminFlag[32]; -new g_iColors[e_ColorNames][e_ColorValues]; -new g_iClassMaxHealth[TFClassType] = {0, 125, 125, 200, 175, 150, 300, 175, 125, 125}; - -public Plugin:myinfo = -{ - name = "Simple Round Immunity", - author = "Simple Plugins", - description = "Gives admins immunity during certain rounds", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -} - -bool:AskPluginLoad(Handle:myself, bool:late, String:error[], err_max) -{ - g_bLoadedLate = late; - return true; -} - -public OnPluginStart() -{ - - /** - Create console variables - */ - CreateConVar("sri_version", PLUGIN_VERSION, "Simple Round Immunity", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - sri_enabled = CreateConVar("sri_enabled", "1", "Enable/Disable Admin immunity during certain round."); - sri_charadminflag = CreateConVar("sri_charadminflag", "a", "Admin flag to use for immunity (only one). Must be a in char format."); - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook some events and check extensions - */ - decl String:sExtError[256]; - LogAction(0, -1, "[SRI] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_spawn", HookPlayerSpawn, EventHookMode_Post); - HookEvent("player_hurt", HookPlayerHurt, EventHookMode_Pre); - switch (g_CurrentMod) - { - case GameType_CSS: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - new iExtStatus = GetExtensionFileStatus("game.cstrike.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SRI] Required extension was not found."); - LogAction(0, -1, "[SRI] Plugin FAILED TO LOAD."); - SetFailState("Required extension was not found."); - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SRI] Required extension is loaded with errors."); - LogAction(0, -1, "[SRI] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SRI] Plugin FAILED TO LOAD."); - SetFailState("Required extension is loaded with errors."); - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SRI] Required css extension is loaded."); - } - } - case GameType_TF: - { - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_PostNoCopy); - HookUserMessage(GetUserMessageId("TextMsg"), UserMessageHook_Class, true); - new iExtStatus = GetExtensionFileStatus("game.tf2.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SRI] Required extension was not found."); - LogAction(0, -1, "[SRI] Plugin FAILED TO LOAD."); - SetFailState("Required extension was not found."); - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SRI] Required extension is loaded with errors."); - LogAction(0, -1, "[SRI] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SRI] Plugin FAILED TO LOAD."); - SetFailState("Required extension is loaded with errors."); - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SRI] Required tf2 extension is loaded."); - } - iExtStatus = GetExtensionFileStatus("dukehacks.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SRI] Dukehacks extension was not found."); - LogAction(0, -1, "[SRI] Plugin continued to load, but that feature will not be used."); - g_bUseDukehacks = false; - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SRI] Dukehacks extension is loaded with errors."); - LogAction(0, -1, "[SRI] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SRI] Plugin continued to load, but that feature will not be used."); - g_bUseDukehacks = false; - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SRI] Dukehacks extension is loaded and will be used."); - g_bUseDukehacks = true; - dhAddClientHook(CHK_TakeDamage, Hacks_TakeDamageHook); - } - } - case GameType_DOD: - { - HookEvent("dod_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_PostNoCopy); - } - default: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - } - } - /** - Now lets check for client prefs extension - */ - new iExtStatus = GetExtensionFileStatus("clientprefs.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SRI] Client Preferences extension was not found."); - LogAction(0, -1, "[SRI] Plugin continued to load, but that feature will not be used."); - g_bUseClientprefs = false; - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SRI] Client Preferences extension is loaded with errors."); - LogAction(0, -1, "[SRI] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SRI] Plugin continued to load, but that feature will not be used."); - g_bUseClientprefs = false; - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SRI] Client Preferences extension is loaded, checking database."); - if (!SQL_CheckConfig(clientprefs)) - { - LogAction(0, -1, "[SRI] No 'clientprefs' database found. Check your database.cfg file."); - LogAction(0, -1, "[SRI] Plugin continued to load, but Client Preferences will not be used."); - g_bUseClientprefs = false; - } - g_bUseClientprefs = true; - - /** - Deal with client cookies - */ - sri_cookie_enabled = RegClientCookie("bri_client_enabled", "Enable/Disable your immunity during the bonus round.", CookieAccess_Public); - sri_cookie_color = RegClientCookie("bri_client_color", "Color to render when immune.", CookieAccess_Public); - sri_cookie_mode = RegClientCookie("bri_client_mode", "God mode to select", CookieAccess_Public); - SetCookieMenuItem(CookieMenu_TopMenu, sri_cookie_enabled, "Bonus Round Immunity"); - } - - HookConVarChange(sri_enabled, EnabledChanged); - - RegAdminCmd("sm_immunity", Command_Immunity, ADMFLAG_ROOT, "sm_immunity: Gives you immunity"); - - LoadColors(); - - AutoExecConfig(true, "plugin.simpleroundimmunity"); -} - -public OnAllPluginsLoaded() -{ - //something - // need to deal with the unloading of dukehacks, clientprefs, and simpleplugins - // should move hooking the client prefs cookies to a function to make sure they are done post plugin start if ext is loaded late -} - -public OnLibraryRemoved(const String:name[]) -{ - //something - // need to deal with the loading of dukehacks, clientprefs, and simpleplugins -} - -public OnConfigsExecuted() -{ - GetConVarString(sri_charadminflag, g_sCharAdminFlag, sizeof(g_sCharAdminFlag)); - g_bIsEnabled = GetConVarBool(sri_enabled); - g_bRoundEnd = false; -} - -/** - Client events - */ - -public OnClientPostAdminCheck(client) -{ - if (SM_IsValidAdmin(client, g_sCharAdminFlag)) - g_aPlayers[client][bIsAdmin] = true; - else - g_aPlayers[client][bIsAdmin] = false; -} - -public OnClientCookiesCached(client) -{ - decl String:sEnabled[2], String:sColor[4], String:sMode[2]; - GetClientCookie(client, sri_cookie_enabled, sEnabled, sizeof(sEnabled)); - GetClientCookie(client, sri_cookie_color, sColor, sizeof(sColor)); - GetClientCookie(client, sri_cookie_mode, sMode, sizeof(sMode)); - g_aClientCookies[client][bEnabled] = StringToInt(sEnabled); - g_aClientCookies[client][iColor] = StringToInt(sColor); - g_aClientCookies[client][iMode] = StringToInt(sMode); -} - -public OnClientDisconnect(client) -{ - CleanUp(client); -} - -/** - Commands - */ - -public Action:Command_Immunity(client, args) -{ - if (g_aPlayers[client][IsImmune]) - { - DisableImmunity(client); - } - else - { - EnableImmunity(client); - } - return Plugin_Handled; -} - -/** - Event hooks - */ - -public Action:Hacks_TakeDamageHook(client, attacker, inflictor, Float:damage, &Float:multiplier, damagetype) -{ - if (attacker == 0 || attacker >= MaxClients) - { - return Plugin_Continue; - } - if (g_aPlayers[client][IsImmune]) - { - new TFClassType:PlayerClass = TF2_GetPlayerClass(attacker); - if (PlayerClass == TFClass_Spy) - { - multiplier *= 0.0; - return Plugin_Changed; - } - } - return Plugin_Continue; -} - -public HookRoundStart(Handle:event, const String:name[], bool:dontBroadcast) -{ - g_bRoundEnd = false; - if (g_bIsEnabled) - { - for (new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][IsImmune]) - { - DisableImmunity(i); - } - } - } -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - g_bRoundEnd = true; - if (g_bIsEnabled) - { - for (new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][bIsAdmin]) - { - EnableImmunity(i); - } - } - } -} - -public HookPlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast) -{ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - if (g_bIsEnabled && g_aPlayers[iClient][bIsAdmin] && g_bRoundEnd) - { - EnableImmunity(iClient); - } -} - -public Action:HookPlayerHurt(Handle:event, const String:name[], bool:dontBroadcast) -{ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - if (g_aPlayers[iClient][IsImmune]) - { - SetEntityHealth(iClient, 2000); - return Plugin_Continue; - } - return Plugin_Continue; -} - -/** - Cookie menus - */ - -public CookieMenu_TopMenu(client, CookieMenuAction:action, any:info, String:buffer[], maxlen) -{ - if (action == CookieMenuAction_DisplayOption) - { - //don't think we need to do anything - } - else - { - new Handle:hMenu = CreateMenu(Menu_CookieSettings); - SetMenuTitle(hMenu, "Options (Current Setting)"); - if (g_aClientCookies[client][bEnabled]) - { - AddMenuItem(hMenu, "enable", "Enabled/Disable (Enabled)"); - } - else - { - AddMenuItem(hMenu, "enable", "Enabled/Disable (Disabled)"); - } - if (g_aClientCookies[client][iMode]) - { - AddMenuItem(hMenu, "mode", "Immunity Mode Setting (God Mode)"); - } - else - { - AddMenuItem(hMenu, "mode", "Immunity Mode Setting (Health)"); - } - switch (g_aClientCookies[client][iColor]) - { - case COLOR_GREEN: - { - AddMenuItem(hMenu, "color", "Color (Green)"); - } - case COLOR_BLACK: - { - AddMenuItem(hMenu, "color", "Color (Black)"); - } - case COLOR_RED: - { - AddMenuItem(hMenu, "color", "Color (Red)"); - } - case COLOR_BLUE: - { - AddMenuItem(hMenu, "color", "Color (Blue)"); - } - case COLOR_TEAM: - { - AddMenuItem(hMenu, "color", "Color (Team)"); - } - case COLOR_RAINBOW: - { - AddMenuItem(hMenu, "color", "Color (Rainbow)"); - } - case COLOR_NONE: - { - AddMenuItem(hMenu, "color", "Color (None)"); - } - } - SetMenuExitBackButton(hMenu, true); - DisplayMenu(hMenu, client, MENU_TIME_FOREVER); - } -} - -public Menu_CookieSettings(Handle:menu, MenuAction:action, param1, param2) -{ - new client = param1; - if (action == MenuAction_Select) - { - new String:sSelection[24]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "enable", false)) - { - new Handle:hMenu = CreateMenu(Menu_CookieSettingsEnable); - SetMenuTitle(hMenu, "Enable/Disable Round End Immunity"); - - if (g_aClientCookies[client][bEnabled]) - { - AddMenuItem(hMenu, "enable", "Enable (Set)"); - AddMenuItem(hMenu, "disable", "Disable"); - } - else - { - AddMenuItem(hMenu, "enable", "Enabled"); - AddMenuItem(hMenu, "disable", "Disable (Set)"); - } - - SetMenuExitBackButton(hMenu, true); - DisplayMenu(hMenu, client, MENU_TIME_FOREVER); - } - else if (StrEqual(sSelection, "mode", false)) - { - new Handle:hMenu = CreateMenu(Menu_CookieSettingsMode); - SetMenuTitle(hMenu, "Set Immunity Mode"); - - if (g_aClientCookies[client][iMode]) - { - AddMenuItem(hMenu, "god", "God Mode (Set)"); - AddMenuItem(hMenu, "health", "Health"); - } - else - { - AddMenuItem(hMenu, "god", "God Mode"); - AddMenuItem(hMenu, "health", "Health (Set)"); - } - - SetMenuExitBackButton(hMenu, true); - DisplayMenu(hMenu, client, MENU_TIME_FOREVER); - } - else - { - new Handle:hMenu = CreateMenu(Menu_CookieSettingsColors); - SetMenuTitle(hMenu, "Select Immunity Color"); - switch (g_aClientCookies[client][iColor]) - { - case COLOR_GREEN: - { - AddMenuItem(hMenu, "Green", "Green (Set)"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_BLACK: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black (Set)"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_RED: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red (Set)"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_BLUE: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue (Set)"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_TEAM: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color (Set)"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_RAINBOW: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow (Set)"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_NONE: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None (Set)"); - } - } - SetMenuExitBackButton(hMenu, true); - DisplayMenu(hMenu, client, MENU_TIME_FOREVER); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - ShowCookieMenu(client); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } -} - -public Menu_CookieSettingsEnable(Handle:menu, MenuAction:action, param1, param2) -{ - new client = param1; - if (action == MenuAction_Select) - { - new String:sSelection[24]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "enable", false)) - { - SetClientCookie(client, sri_cookie_enabled, "1"); - g_aClientCookies[client][bEnabled] = 1; - PrintToChat(client, "[SM] Bonus Round Immunity is ENABLED"); - } - else - { - SetClientCookie(client, sri_cookie_enabled, "0"); - g_aClientCookies[client][bEnabled] = 0; - PrintToChat(client, "[SM] Bonus Round Immunity is DISABLED"); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - ShowCookieMenu(client); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } -} - -public Menu_CookieSettingsColors(Handle:menu, MenuAction:action, param1, param2) -{ - new client = param1; - if (action == MenuAction_Select) - { - new String:sSelection[24]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "Green", false)) - { - SetClientCookie(client, sri_cookie_color, "0"); - g_aClientCookies[client][iColor] = COLOR_GREEN; - PrintToChat(client, "[SM] Bonus Round Immunity color set to GREEN"); - } - else if (StrEqual(sSelection, "Black", false)) - { - SetClientCookie(client, sri_cookie_color, "1"); - g_aClientCookies[client][iColor] = COLOR_BLACK; - PrintToChat(client, "[SM] Bonus Round Immunity color set to BLACK"); - } - else if (StrEqual(sSelection, "Red", false)) - { - SetClientCookie(client, sri_cookie_color, "2"); - g_aClientCookies[client][iColor] = COLOR_RED; - PrintToChat(client, "[SM] Bonus Round Immunity color set to RED"); - } - else if (StrEqual(sSelection, "Blue", false)) - { - SetClientCookie(client, sri_cookie_color, "3"); - g_aClientCookies[client][iColor] = COLOR_BLUE; - PrintToChat(client, "[SM] Bonus Round Immunity color set to BLUE"); - } - else if (StrEqual(sSelection, "Team", false)) - { - SetClientCookie(client, sri_cookie_color, "4"); - g_aClientCookies[client][iColor] = COLOR_TEAM; - PrintToChat(client, "[SM] Bonus Round Immunity color set to TEAM COLOR"); - } - else if (StrEqual(sSelection, "Rain", false)) - { - SetClientCookie(client, sri_cookie_color, "5"); - g_aClientCookies[client][iColor] = COLOR_RAINBOW; - PrintToChat(client, "[SM] Bonus Round Immunity color set to RAINBOW"); - } - else if (StrEqual(sSelection, "None", false)) - { - SetClientCookie(client, sri_cookie_color, "6"); - g_aClientCookies[client][iColor] = COLOR_NONE; - PrintToChat(client, "[SM] Bonus Round Immunity color set to NONE"); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - ShowCookieMenu(client); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } -} - -public Menu_CookieSettingsMode(Handle:menu, MenuAction:action, param1, param2) -{ - new client = param1; - if (action == MenuAction_Select) - { - new String:sSelection[24]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "god", false)) - { - SetClientCookie(client, sri_cookie_mode, "1"); - g_aClientCookies[client][iMode] = 1; - PrintToChat(client, "[SM] Bonus Round Immunity set to GOD MODE"); - } - else - { - SetClientCookie(client, sri_cookie_mode, "0"); - g_aClientCookies[client][iMode] = 0; - PrintToChat(client, "[SM] Bonus Round Immunity set to HEALTH BONUS"); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - ShowCookieMenu(client); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } -} - -/** -Timer functions - */ - -public Action:Timer_ChangeColor(Handle:timer, any:client) -{ - if (g_aPlayers[client][CycleColor]++ == 3) - { - g_aPlayers[client][CycleColor] = 0; - } - SetEntityRenderMode(client, RENDER_TRANSCOLOR); - SetEntityRenderColor(client, g_iColors[g_aPlayers[client][CycleColor]][iRed], g_iColors[g_aPlayers[client][CycleColor]][iGreen], g_iColors[g_aPlayers[client][CycleColor]][iBlue], 255); - return Plugin_Continue; -} - -public Action:Timer_UndoGodMode(Handle:timer, any:client) -{ - if (IsClientInGame(client)) - { - SetEntProp(client, Prop_Data, "m_takedamage", 2, 1); - } - g_aPlayers[iClient][hGodModeTimer] = INVALID_HANDLE; - return Plugin_Handled; -} - -/** -Stock functions . - */ - -stock CleanUp(iClient) -{ - g_aPlayers[iClient][bIsAdmin] = false; - DisableImmunity(iClient); -} - -stock EnableImmunity(iClient) -{ - SetEntityRenderMode(iClient, RENDER_TRANSCOLOR); - switch (g_aClientCookies[iClient][iColor]) - { - case COLOR_TEAM: - { - new iTeam = GetClientTeam(iClient); - SetEntityRenderColor(iClient, g_iColors[e_ColorNames:iTeam][iRed], g_iColors[e_ColorNames:iTeam][iGreen], g_iColors[e_ColorNames:iTeam][iBlue], 255); - } - case COLOR_RAINBOW: - { - if (g_aPlayers[iClient][hColorTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[iClient][hColorTimer]); - g_aPlayers[iClient][hColorTimer] = INVALID_HANDLE; - } - g_aPlayers[iClient][hColorTimer] = CreateTimer(0.2, Timer_ChangeColor, iClient, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); - } - case COLOR_NONE: - { - //We dont have to set a color - } - default: - { - SetEntityRenderColor(iClient, g_iColors[e_ColorNames:g_aClientCookies[iClient][iColor]][iRed], g_iColors[e_ColorNames:g_aClientCookies[iClient][iColor]][iGreen], g_iColors[e_ColorNames:g_aClientCookies[iClient][iColor]][iBlue], 255); - } - } - SetEntityHealth(iClient, 2000); - SetEntProp(iClient, Prop_Data, "m_takedamage", 0, 1); - g_aPlayers[iClient][hGodModeTimer] = CreateTimer(2.0, Timer_UndoGodMode, iClient); - g_aPlayers[iClient][IsImmune] = true; -} - -stock DisableImmunity(iClient) -{ - if (g_aPlayers[iClient][hGodModeTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[iClient][hGodModeTimer]); - g_aPlayers[iClient][hGodModeTimer] = INVALID_HANDLE; - } - if (g_aPlayers[iClient][hColorTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[iClient][hColorTimer]); - g_aPlayers[iClient][hColorTimer] = INVALID_HANDLE; - } - if (IsClientInGame(iClient)) - { - SetEntityRenderMode(iClient, RENDER_TRANSCOLOR); - SetEntityRenderColor(iClient, 255, 255, 255, 255); - new TFClassType:PlayerClass = TF2_GetPlayerClass(iClient); - new iMaxHealth = g_iClassMaxHealth[PlayerClass]; - SetEntityHealth(iClient, iMaxHealth); - } - g_aPlayers[iClient][CycleColor] = 0; - g_aPlayers[iClient][IsImmune] = false; -} - -stock LoadColors() -{ - g_iColors[Green][iRed] = 0; - g_iColors[Green][iGreen] = 255; - g_iColors[Green][iBlue] = 0; - - g_iColors[Black][iRed] = 10; - g_iColors[Black][iGreen] = 10; - g_iColors[Black][iBlue] = 0; - - g_iColors[Red][iRed] = 255; - g_iColors[Red][iGreen] = 0; - g_iColors[Red][iBlue] = 0; - - g_iColors[Blue][iRed] = 0; - g_iColors[Blue][iGreen] = 0; - g_iColors[Blue][iBlue] = 255; -} - -stock TF2_AddCond(client, cond) -{ - new Handle:cvar = FindConVar("sv_cheats"), bool:enabled = GetConVarBool(cvar), flags = GetConVarFlags(cvar); - if(!enabled) - { - SetConVarFlags(cvar, flags^FCVAR_NOTIFY); - SetConVarBool(cvar, true); - } - FakeClientCommand(client, "addcond %i", cond); - if(!enabled) - { - SetConVarBool(cvar, false); - SetConVarFlags(cvar, flags); - } -} - -stock TF2_RemoveCond(client, cond) -{ - new Handle:cvar = FindConVar("sv_cheats"), bool:enabled = GetConVarBool(cvar), flags = GetConVarFlags(cvar); - if(!enabled) - { - SetConVarFlags(cvar, flags^FCVAR_NOTIFY); - SetConVarBool(cvar, true); - } - FakeClientCommand(client, "removecond %i", cond); - if(!enabled) - { - SetConVarBool(cvar, false); - SetConVarFlags(cvar, flags); - } -} - -/** -Enabled hook - */ - -public EnabledChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (StringToInt(newValue) == 0) - { - UnhookEvent("player_spawn", HookPlayerSpawn, EventHookMode_Post); - UnhookEvent("teamplay_round_start", HookRoundStart, EventHookMode_Post); - UnhookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - for (new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][bIsAdmin] && g_aPlayers[i][IsImmune]) - { - DisableImmunity(i); - } - } - g_bIsEnabled = false; - } - else - { - HookEvent("player_spawn", HookPlayerSpawn, EventHookMode_Post); - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_Post); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - g_bIsEnabled = true; - } -} diff --git a/Simple Chat Colors/addons/sourcemod/scripting/simple-spectate.sp b/Simple Chat Colors/addons/sourcemod/scripting/simple-spectate.sp deleted file mode 100644 index 4108f8f..0000000 --- a/Simple Chat Colors/addons/sourcemod/scripting/simple-spectate.sp +++ /dev/null @@ -1,2022 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Spectate -Description: - Spectate a player and follow them through death. -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include -#undef REQUIRE_EXTENSIONS -#undef AUTOLOAD_EXTENSIONS -#tryinclude -#define AUTOLOAD_EXTENSIONS -#define REQUIRE_EXTENSIONS - -#define PLUGIN_VERSION "1.2.1.$Rev$" - -#define SPECMODE_NONE 0 -#define SPECMODE_FIRSTPERSON 4 -#define SPECMODE_3RDPERSON 5 -#define SPECMODE_FREELOOK 6 -#define SPECMODE_CSS_FIRSTPERSON 3 -#define SPECMODE_CSS_3RDPERSON 4 -#define SPECMODE_CSS_FREELOOK 5 - -enum e_CvarHandles -{ - Handle:hHudMode, - Handle:hMenuType, - Handle:hRestrictHud, - Handle:hBan, - Handle:hBanPerm, - Handle:hBeacon, - Handle:hBlind, - Handle:hCheater, - Handle:hDrug, - Handle:hFreeze, - Handle:hFreezeBomb, - Handle:hKick, - Handle:hSlap, - Handle:hSlay, - Handle:hTimeBomb -}; - -enum e_CvarSettings -{ - bool:bHudMode, - bool:bMenuType, - bool:bRestrictHud, - bool:bBan, - bool:bBanPerm, - bool:bBeacon, - bool:bBlind, - bool:bCheater, - bool:bDrug, - bool:bFreeze, - bool:bFreezebomb, - bool:bKick, - bool:bSlap, - bool:bSlay, - bool:bTimeBomb -}; - -enum e_PluginSettings -{ - bool:bUseSteamBans, - bool:bUseSourceBans, - bool:bUseMySQLBans, - bool:bCanHUD, - bool:bUseDukehacks -}; - -enum e_Menus -{ - Handle:hSelectPlayer, - Handle:hBanTime, - Handle:hReason -}; - -enum e_Punishments -{ - Punish_None, - Punish_Ban, - Punish_Beacon, - Punish_Blind, - Punish_Cheater, - Punish_Drug, - Punish_Freeze, - Punish_FreezeBomb, - Punish_Kick, - Punish_Slap, - Punish_Slay, - Punish_TimeBomb -}; - -enum e_PlayerData -{ - bool:bIsDisplayingHud, - bool:bIsFlaggedCheater, - Handle:hHudTimer, - Handle:hTargetTimer, - iTargetIndex, - e_Punishments:TargetPunishment, - iBanTime -}; - -new Handle:sm_spectate_adminflag = INVALID_HANDLE; -new Handle:g_hAdminMenu = INVALID_HANDLE; -new Handle:g_hHud = INVALID_HANDLE; -new Handle:g_aPluginCvar[e_CvarHandles]; -new g_aPluginCvarSettings[e_CvarSettings]; -new g_aPluginSettings[e_PluginSettings]; -new g_aMenus[e_Menus]; -new g_aPlayers[MAXPLAYERS + 1][e_PlayerData]; -new String:g_sAdminFlags[16]; -new String:g_sPunishments[e_Punishments][15] = { "None", "Ban", "Beacon", "Blind", "Cheater", "Drug", "Freeze", "FreezeBomb", "Kick", "Slap", "Slay", "TimeBomb" }; - -public Plugin:myinfo = -{ - name = "Simple Spectate", - author = "Simple Plugins", - description = "Spectate a player and follow them through death.", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -}; - -/** -Sourcemod callbacks -*/ -public OnPluginStart() -{ - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook the game events - */ - LogAction(0, -1, "[SSPEC] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_team", HookPlayerChangeTeam, EventHookMode_Pre); - - /** - Need to create all of our console variables. - */ - CreateConVar("sm_spectate_version", PLUGIN_VERSION, "Sourcemod Spectate", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - g_aPluginCvar[hHudMode] = CreateConVar("sm_spectate_hudmode", "1", "Hud Mode: 0 = Hud Text | 1 = Panel/Menu (NOTE: The panel/menu will override other menus until canceled)"); - g_aPluginCvar[hMenuType] = CreateConVar("sm_spectate_menutype", "0", "Menu Mode: 0 = Panel | 1 = Menu"); - g_aPluginCvar[hRestrictHud] = CreateConVar("sm_spectate_restricthud", "0", "Restrict the hud to the admin flag provided"); - g_aPluginCvar[hBan] = CreateConVar("sm_spectate_ban", "1", "Enable/Disable ban option"); - g_aPluginCvar[hBanPerm] = CreateConVar("sm_spectate_banperm", "1", "Enable/Disable permanent ban option"); - g_aPluginCvar[hBeacon] = CreateConVar("sm_spectate_beacon", "1", "Enable/Disable beacon option"); - g_aPluginCvar[hBlind] = CreateConVar("sm_spectate_blind", "1", "Enable/Disable blind option"); - g_aPluginCvar[hCheater] = CreateConVar("sm_spectate_cheater", "1", "Enable/Disable cheater option"); - g_aPluginCvar[hDrug] = CreateConVar("sm_spectate_drug", "1", "Enable/Disable drug option"); - g_aPluginCvar[hFreeze] = CreateConVar("sm_spectate_freeze", "1", "Enable/Disable freeze option"); - g_aPluginCvar[hFreezeBomb] = CreateConVar("sm_spectate_freezebomb", "1", "Enable/Disable freezebomb option"); - g_aPluginCvar[hKick] = CreateConVar("sm_spectate_kick", "1", "Enable/Disable kick option"); - g_aPluginCvar[hSlap] = CreateConVar("sm_spectate_slap", "1", "Enable/Disable slap option"); - g_aPluginCvar[hSlay] = CreateConVar("sm_spectate_slay", "1", "Enable/Disable slay option"); - g_aPluginCvar[hTimeBomb] = CreateConVar("sm_spectate_timebomb", "1", "Enable/Disable timebomb option"); - - sm_spectate_adminflag = CreateConVar("sm_spectate_adminflag", "d", "Admin Flag to use for admin hud"); - - /** - Hook console variables - */ - new e_CvarHandles:iCvar; - for ( ; _:iCvar < sizeof(g_aPluginCvar); iCvar++) - { - HookConVarChange(g_aPluginCvar[iCvar], ConVarSettingsChanged); - } - - /** - Need to register the commands we are going to create and use. - */ - RegConsoleCmd("sm_spectate", Command_Spectate, "Spectate a player"); - RegConsoleCmd("sm_spec", Command_Spectate, "Spectate a player"); - RegConsoleCmd("sm_observe", Command_Spectate, "Spectate a player"); - RegConsoleCmd("sm_stopspec", Command_StopSpectate, "Stop Spectating a player"); - RegConsoleCmd("sm_endobserve", Command_StopSpectate, "Stop Spectating a player"); - RegConsoleCmd("sm_specinfo", Command_ToggleHud, "Toggles the hud display if in spectator"); - - /** - Now we have to deal with the admin menu. If the admin library is loaded call the function to add our items. - */ - new Handle:gTopMenu; - if (LibraryExists("adminmenu") && ((gTopMenu = GetAdminTopMenu()) != INVALID_HANDLE)) - { - OnAdminMenuReady(gTopMenu); - } - - /** - Deal with the hud - Thanks to Spray Trace plugin (http://forums.alliedmods.net/showthread.php?p=665448) - */ - new String:sHudGames[32]; - GetGameFolderName(sHudGames, sizeof(sHudGames)); - g_aPluginSettings[bCanHUD] = StrEqual(sHudGames,"tf",false) - || StrEqual(sHudGames,"hl2mp",false) - || StrEqual(sHudGames,"sourceforts",false) - || StrEqual(sHudGames,"obsidian",false) - || StrEqual(sHudGames,"left4dead",false) - || StrEqual(sHudGames,"l4d",false); - - if (g_aPluginSettings[bCanHUD]) - { - g_hHud = CreateHudSynchronizer(); - } - - /** - Load translations - */ - LoadTranslations ("common.phrases"); - LoadTranslations ("simplespectate.phrases"); - - /** - Create the config file - */ - AutoExecConfig(true); -} - -public OnConfigsExecuted() -{ - new e_CvarHandles:iCvar; - for ( ; _:iCvar < sizeof(g_aPluginCvarSettings); iCvar++) - { - g_aPluginCvarSettings[iCvar] = GetConVarBool(g_aPluginCvar[iCvar]); - } - - /* - Build the global menus - */ - g_aMenus[hSelectPlayer] = BuildSelectPlayerMenu(); - g_aMenus[hBanTime] = BuildBanTimeMenu(); - g_aMenus[hReason] = BuildReasonMenu(); - - GetConVarString(sm_spectate_adminflag, g_sAdminFlags, sizeof(g_sAdminFlags)); -} - -public OnAllPluginsLoaded() -{ - - /* - Check for steambans - */ - if (FindConVar("sbsrc_version") != INVALID_HANDLE) - { - g_aPluginSettings[bUseSteamBans] = true; - } - else - { - g_aPluginSettings[bUseSteamBans] = false; - } - - /* - Check for sourcebans - */ - if (FindConVar("sb_version") != INVALID_HANDLE) - { - g_aPluginSettings[bUseSourceBans] = true; - } - else - { - g_aPluginSettings[bUseSourceBans] = false; - } - - /* - Check for mysql bans - */ - if (FindConVar("mysql_bans_version") != INVALID_HANDLE) - { - g_aPluginSettings[bUseMySQLBans] = true; - } - else - { - g_aPluginSettings[bUseMySQLBans] = false; - } - - /* - Check for dukehacks - */ - new String:sExtError[256]; - new iExtStatus = GetExtensionFileStatus("dukehacks.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SSPEC] Dukehacks extension was not found."); - LogAction(0, -1, "[SSPEC] Plugin continued to load, but that feature will not be used."); - g_aPluginSettings[bUseDukehacks] = false; - } - else if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SSPEC] Dukehacks extension is loaded with errors."); - LogAction(0, -1, "[SSPEC] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SSPEC] Plugin continued to load, but that feature will not be used."); - g_aPluginSettings[bUseDukehacks] = false; - } - else if (iExtStatus == 1) - { - LogAction(0, -1, "[SSPEC] Dukehacks extension is loaded and will be used."); - g_aPluginSettings[bUseDukehacks] = true; - dhAddClientHook(CHK_TakeDamage, Hacks_TakeDamageHook); - } - - /* - Deal with some known plugin conflicts - */ - new Handle:hObserveClient = FindConVar("observe_version"); - if (hObserveClient != INVALID_HANDLE) - { - new String:sNewFile[PLATFORM_MAX_PATH + 1], String:sOldFile[PLATFORM_MAX_PATH + 1]; - BuildPath(Path_SM, sNewFile, sizeof(sNewFile), "plugins/disabled/observe.smx"); - BuildPath(Path_SM, sOldFile, sizeof(sOldFile), "plugins/observe.smx"); - - /** - Check if plugins/observe.smx exists, and if not, ignore - */ - if(!FileExists(sOldFile)) - { - return; - } - - /** - Check if plugins/disabled/observe.smx already exists, and if so, delete it - */ - if(FileExists(sNewFile)) - { - DeleteFile(sNewFile); - } - - /** - Unload plugins/observe.smx and move it to plugins/disabled/observe.smx - */ - LogAction(0, -1, "Detected the plugin ObserveClient"); - LogAction(0, -1, "ObserveClient plugin conflicts with Simple Spectate"); - LogAction(0, -1, "Unloading plugin and disabling ObserveClient plugin"); - ServerCommand("sm plugins unload observe"); - RenameFile(sNewFile, sOldFile); - } -} - -public OnLibraryRemoved(const String:name[]) -{ - if (StrEqual(name, "adminmenu")) - { - - /** - Looks like the admin menu was removed. Set the global. - */ - g_hAdminMenu = INVALID_HANDLE; - } - else if (StrEqual(name, "simpleplugins")) - { - //something - } -} - -public OnClientDisconnect(client) -{ - - /** - Cleanup the clients variables. - */ - ResetClient(client); - - /** - Run a loop and see if we are supposed to spectate this person (is a target) - */ - for(new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][iTargetIndex] == client) - { - - /** - Cleanup the clients variables. - */ - StopFollowingPlayer(i); - g_aPlayers[i][TargetPunishment] = Punish_None; - g_aPlayers[i][iBanTime] = 0; - } - } -} - -/** -Thirdparty callbacks -*/ -public SM_OnPlayerMoved(Handle:plugin, client, team) -{ - - /** - Make sure we called the move function - */ - if (plugin != GetMyHandle()) - { - return; - } - - //Nothing -} - -public Action:Hacks_TakeDamageHook(client, attacker, inflictor, Float:damage, &Float:multiplier, damagetype) -{ - - /** - Check for a valid client - */ - if (client > 0 && client <= MaxClients) - { - - /** - Check if the client taking damage is flagged as a cheater - */ - if (g_aPlayers[client][bIsFlaggedCheater]) - { - - /** - Check for fall damage and increase it - */ - if (damagetype & DMG_FALL) - { - multiplier *= 1000.0; - return Plugin_Changed; - } - } - } - - /** - Check for a valid attacker - */ - if (attacker > 0 && attacker <= MaxClients) - { - - /** - Check if the attacker causing the damage is flagged as a cheater - */ - if (g_aPlayers[attacker][bIsFlaggedCheater]) - { - - /** - Make sure they are not hurting themselves - */ - if (client != attacker) - { - - /** - Stop the damage - */ - multiplier *= 0.0; - return Plugin_Changed; - } - } - } - return Plugin_Continue; -} - -/** -Events -*/ -public Action:HookPlayerChangeTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get the client and team - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - new iTeam = GetEventInt(event, "team"); - - /** - Make sure it's a valid client - */ - if (iClient == 0) - { - return Plugin_Continue; - } - - /** - If it's a move to spectator start displaying the hud - */ - else if ((iTeam == g_aCurrentTeams[Spectator]) && (GetUserFlagBits(iClient) & ADMFLAG_GENERIC)) - { - StartDisplayingHud(iClient); - - /** - If the event was going to be broadcasted, we refire it so it is not broadcasted and stop this one - */ - if (!dontBroadcast) - { - new Handle:hEvent = CreateEvent("player_team"); - SetEventInt(hEvent, "userid", GetEventInt(event, "userid")); - SetEventInt(hEvent, "team", GetEventInt(event, "team")); - SetEventInt(hEvent, "oldteam", GetEventInt(event, "oldteam")); - SetEventBool(hEvent, "disconnect", GetEventBool(event, "disconnect")); - - if (g_CurrentMod == GameType_DOD || g_CurrentMod == GameType_L4D || g_CurrentMod == GameType_TF) - { - new String:sClientName[MAX_NAME_LENGTH + 1]; - GetClientName(client, sClientName, sizeof(sClientName)); - SetEventBool(hEvent, "autoteam", GetEventBool(event, "autoteam")); - SetEventBool(hEvent, "silent", true); - SetEventString(hEvent, "name", sClientName); - FireEvent(hEvent, true); - } - else - { - FireEvent(hEvent, true); - } - return Plugin_Handled; - } - } - - /** - Otherwise cleanup the client - */ - else - { - StopDisplayingHud(iClient); - StopFollowingPlayer(iClient); - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -/** -Commands -*/ -public Action:Command_Spectate(client, args) -{ - - /** - See if we already have a target (for toggling of command) - */ - if (g_aPlayers[client][iTargetIndex]) - { - - /** - We do, toggle it off - */ - StopFollowingPlayer(client); - - /** - We are done, bug out. - */ - return Plugin_Handled; - } - - /** - We don't... must want to enable it - See if we have some command arguments. - */ - new iCmdArgs = GetCmdArgs(); - if (iCmdArgs == 0) - { - - /** - We don't have any. Display the player menu. - */ - if (g_aPlayers[client][bIsDisplayingHud]) - { - StopDisplayingHud(client); - } - - DisplayMenu(BuildPlayerListMenu(), client, MENU_TIME_FOREVER); - return Plugin_Handled; - } - - /** - We have an argument. - Try to find the target. - */ - new String:sPlayer[128]; - GetCmdArg(1, sPlayer, sizeof(sPlayer)); - new iTarget = FindTarget(client, sPlayer, true, true); - if (iTarget == -1 || !IsClientInGame(iTarget)) - { - - /** - We couldn't find the target. Display the player menu. - */ - if (g_aPlayers[client][bIsDisplayingHud]) - { - StopDisplayingHud(client); - } - - DisplayMenu(BuildPlayerListMenu(), client, MENU_TIME_FOREVER); - return Plugin_Handled; - } - - /** - We found the target. - Call the stock function to spectate the target. - */ - StartFollowingPlayer(client, iTarget); - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_StopSpectate(client, args) -{ - - /** - Cleanup the clients variables. - */ - StopFollowingPlayer(client); - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_ToggleHud(client, args) -{ - - /** - Toggle the hud - */ - if (g_aPlayers[client][bIsDisplayingHud]) - { - StopDisplayingHud(client); - } - else - { - StartDisplayingHud(client); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -/** -Timers -*/ -public Action:Timer_ResetTarget(Handle:timer, any:client) -{ - - new iTargetID = GetEntPropEnt(client, Prop_Send, "m_hObserverTarget"); - - if (iTargetID != g_aPlayers[client][iTargetIndex] && IsPlayerAlive(g_aPlayers[client][iTargetIndex])) - { - - /** - Run the command to spectate the target from the clients prospectative. - */ - FakeClientCommandEx(client, "spec_player \"%N\"", g_aPlayers[client][iTargetIndex]); - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -public Action:Timer_UpdateHud(Handle:timer, any:client) -{ - - /** - Make sure the client is still in game and a spectator - */ - if (!IsClientConnected(client) || !IsClientInGame(client) || GetClientTeam(client) != g_aCurrentTeams[Spectator] || !g_aPlayers[client][bIsDisplayingHud]) - { - - /** - We are done, bug out - */ - g_aPlayers[client][hHudTimer] = INVALID_HANDLE; - g_aPlayers[client][bIsDisplayingHud] = false; - return Plugin_Stop; - } - /** - Get the target - */ - new iTarget = GetEntPropEnt(client, Prop_Send, "m_hObserverTarget"); - - /** - Check to make sure the target is valid - */ - if (iTarget <= 0 || iTarget > MaxClients) - { - return Plugin_Continue; - } - - /** - Get the spectator mode - */ - new iSpecMode = GetEntProp(client, Prop_Send, "m_iObserverMode"); - - /** - This is a double check to make sure we are in spec - If we are on a regular team, specmod would = none or zero - */ - if (iSpecMode == SPECMODE_NONE) - { - - /** - We are done, bug out - */ - g_aPlayers[client][hHudTimer] = INVALID_HANDLE; - g_aPlayers[client][bIsDisplayingHud] = false; - return Plugin_Stop; - } - - /** - Check the spectator mode - CSS has different index's so we have to check game type first - */ - if (g_CurrentMod == GameType_CSS) - { - switch (iSpecMode) - { - case SPECMODE_CSS_FIRSTPERSON: - { - //Do Nothing - } - case SPECMODE_CSS_3RDPERSON: - { - //Do Nothing - } - case SPECMODE_CSS_FREELOOK: - { - return Plugin_Continue; - } - } - } - else - { - switch (iSpecMode) - { - case SPECMODE_FIRSTPERSON: - { - //Do Nothing - } - case SPECMODE_3RDPERSON: - { - //Do Nothing - } - case SPECMODE_FREELOOK: - { - return Plugin_Continue; - } - } - } - - - /** - Display with the hud - */ - if (g_aPluginSettings[bCanHUD] && !g_aPluginCvarSettings[bHudMode]) - { - new String:sSteamID[64]; - GetClientAuthString(iTarget, sSteamID, sizeof(sSteamID)); - SetHudTextParams(0.04, 0.6, 0.5, 255, 50, 50, 255); - ShowSyncHudText(client, g_hHud, "%N [%s]", iTarget, sSteamID); - } - else if (g_aPluginCvarSettings[bHudMode]) - { - if (g_aPluginCvarSettings[bMenuType]) - { - DisplayMenu(BuildPlayerHudMenu(client, iTarget), client, 1); - } - else - { - new Handle:hPanel = BuildPlayerHudPanel(client, iTarget); - SendPanelToClient(hPanel, client, Panel_PlayerHud, 1); - CloseHandle(hPanel); - } - } - - /** - We are done, keep going! - */ - return Plugin_Continue; -} - -/** -Admin Menu Callbacks -*/ -public OnAdminMenuReady(Handle:topmenu) -{ - if (topmenu == g_hAdminMenu) - { - return; - } - g_hAdminMenu = topmenu; - new TopMenuObject:player_commands = FindTopMenuCategory(g_hAdminMenu, ADMINMENU_PLAYERCOMMANDS); - if (player_commands == INVALID_TOPMENUOBJECT) - { - return; - } - AddToTopMenu(g_hAdminMenu, - "sm_spectate", - TopMenuObject_Item, - AdminMenu_SpecPlayer, - player_commands, - "sm_spectate", - ADMFLAG_GENERIC); -} - -public AdminMenu_SpecPlayer(Handle:topmenu, TopMenuAction:action, TopMenuObject:object_id, param, String:buffer[], maxlength) -{ - if (action == TopMenuAction_DisplayOption) - { - - if (g_aPlayers[param][bIsDisplayingHud]) - { - StopDisplayingHud(param); - } - /** - See if we already have a target - */ - if (g_aPlayers[param][iTargetIndex]) - { - Format(buffer, maxlength, "Spectate(Disable)"); - } - else - { - Format(buffer, maxlength, "Spectate(Select Player)"); - } - } - else if (action == TopMenuAction_SelectOption) - { - - /** - See if we already have a target - */ - if (g_aPlayers[param][iTargetIndex]) - { - - /** - We do, toggle it off - */ - StopFollowingPlayer(param); - - /** - We are done, bug out. - */ - return; - } - else - { - DisplayMenu(BuildPlayerListMenu(), param, MENU_TIME_FOREVER); - } - } -} - -/** -Select Player Menu Callbacks -*/ -public Menu_PlayerList(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - /** - Get the selected player - */ - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - new iTarget = GetClientOfUserId(StringToInt(sSelection)); - - /** - Start following the player - */ - StartFollowingPlayer(param1, iTarget); - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_GENERIC) - { - - /** - Display the last admin menu - */ - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } - else if (param2 == MenuCancel_Exit && GetClientTeam(param1) == g_aCurrentTeams[Spectator]) - { - /** - They canceled the current menu, start the hud back up - */ - StartDisplayingHud(param1); - } - } - else if (action == MenuAction_End) - { - - /** - Not a global menu, close it - */ - CloseHandle(menu); - } -} - -public Menu_SelectPlayer(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - - /** - Get the selected player - */ - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (strcmp(sSelection, "Current", false) == 0) - { - /** - Get the current target - */ - new iTarget = GetEntPropEnt(param1, Prop_Send, "m_hObserverTarget"); - - /** - Check to make sure the target is valid - */ - if (iTarget <= 0 || iTarget > MaxClients) - { - PrintToChat(param1, "\x03[SM-SPEC]\x01 %t", "Invalid Target"); - DisplayMenu(BuildPlayerListMenu(), param1, MENU_TIME_FOREVER); - } - - /** - Start following the player - */ - StartFollowingPlayer(param1, iTarget); - } - else - { - - /** - They want to select a player, show the player list - */ - DisplayMenu(BuildPlayerListMenu(), param1, MENU_TIME_FOREVER); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - - /** - They canceled the current menu, start the hud back up - */ - StartDisplayingHud(param1); - } - } - else if (action == MenuAction_End) - { - /** - Its a global menu, leave it alive - */ - } -} - -/** -Punishment Menu Callbacks -*/ -public Menu_Punishments(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - - /** - Get the menu selection - */ - new String:sSelection[15]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - - /** - Search for the correct index - */ - new e_Punishments:Index = Punish_None; - for ( ; _:Index <= sizeof(g_sPunishments); Index++) - { - if (StrEqual(sSelection, g_sPunishments[Index])) - { - break; - } - } - - /** - Display the next menu - */ - if (Index == Punish_Ban) - { - - /** - Set the punishment index and display ban time menu - */ - g_aPlayers[param1][TargetPunishment] = Index; - DisplayMenu(g_aMenus[hBanTime], param1, MENU_TIME_FOREVER); - } - else if (Index == Punish_Cheater) - { - - /** - Ask for confirmation before we set punishment index - */ - new Handle:hPanel = BuildAdminCheaterPanel(); - SendPanelToClient(hPanel, param1, Panel_AdminCheater, MENU_TIME_FOREVER); - CloseHandle(hPanel); - } - else - { - - /** - Set the punishment index and display reason menu - */ - g_aPlayers[param1][TargetPunishment] = Index; - DisplayMenu(g_aMenus[hReason], param1, MENU_TIME_FOREVER); - } - } - else if (action == MenuAction_Cancel) - { - - /** - They canceled the current menu, start the hud back up - */ - StartDisplayingHud(param1); - } - else if (action == MenuAction_End) - { - - /** - Not a global menu, close it - */ - CloseHandle(menu); - } -} - -public Menu_BanTime(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - - /** - Get the menu selection - */ - new String:sSelection[15]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - - /** - Set the ban time global - */ - g_aPlayers[param1][iBanTime] = StringToInt(sSelection); - - /** - Display the reason menu - */ - DisplayMenu(g_aMenus[hReason], param1, MENU_TIME_FOREVER); - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - - /** - They canceled the current menu, start the hud back up - */ - StartDisplayingHud(param1); - } - } - else if (action == MenuAction_End) - { - /** - Its a global menu, leave it alive - */ - } -} - -public Menu_Reason(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - - /** - Get the menu selection - */ - new String:sSelection[15]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - - /** - Perform the punishment - */ - PerformPunishment(param1, g_aPlayers[param1][iTargetIndex], g_aPlayers[param1][TargetPunishment], sSelection, g_aPlayers[param1][iBanTime]); - - /** - Reactivate the hud if still in spectator - */ - if (GetClientTeam(param1) == g_aCurrentTeams[Spectator]) - { - StartDisplayingHud(param1); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - - /** - They canceled the current menu, start the hud back up - */ - StartDisplayingHud(param1); - } - } - else if (action == MenuAction_End) - { - /** - Its a global menu, leave it alive - */ - } -} - -public Panel_AdminCheater(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - if (param2 == 1) - { - - /** - Set the punishment index and display reason menu - */ - g_aPlayers[param1][TargetPunishment] = Punish_Cheater; - DisplayMenu(g_aMenus[hReason], param1, MENU_TIME_FOREVER); - } - else - { - - /** - Reactivate the hud if still in spectator - */ - if (GetClientTeam(param1) == g_aCurrentTeams[Spectator]) - { - StartDisplayingHud(param1); - } - } - } -} - -public Panel_PublicCheater(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - if (param2 == 1) - { - //Waiting for SB 2.0 and sb_submission to be published - } - else - { - - /** - Reactivate the hud if still in spectator - */ - if (GetClientTeam(param1) == g_aCurrentTeams[Spectator]) - { - StartDisplayingHud(param1); - } - } - } -} - -/** -Hud Menu/Panel Callbacks -*/ -public Menu_PlayerHud(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "stop", false)) - { - StopFollowingPlayer(param1); - } - else if (StrEqual(sSelection, "start", false)) - { - StopDisplayingHud(param1); - DisplayMenu(g_aMenus[hSelectPlayer], param1, MENU_TIME_FOREVER); - } - else if (StrEqual(sSelection, "removecheater", false)) - { - g_aPlayers[g_aPlayers[param1][iTargetIndex]][bIsFlaggedCheater] = false; - } - else if (StrEqual(sSelection, "punish", false)) - { - if (g_aPlayers[param1][iTargetIndex]) - { - StopDisplayingHud(param1); - DisplayMenu(BuildPunishmentMenu(param1), param1, MENU_TIME_FOREVER); - } - else - { - StopDisplayingHud(param1); - PrintToChat(param1, "\x03[SM-SPEC]\x01 %t", "Must Have Target"); - DisplayMenu(g_aMenus[hSelectPlayer], param1, MENU_TIME_FOREVER); - } - } - else if (StrEqual(sSelection, "reportcheater", false)) - { - if (g_aPlayers[param1][iTargetIndex]) - { - StopDisplayingHud(param1); - new Handle:hPanel = BuildPublicCheaterPanel(); - SendPanelToClient(hPanel, param1, Panel_PublicCheater, MENU_TIME_FOREVER); - CloseHandle(hPanel); - } - else - { - StopDisplayingHud(param1); - PrintToChat(param1, "\x03[SM-SPEC]\x01 %t", "Must Have Target"); - DisplayMenu(g_aMenus[hSelectPlayer], param1, MENU_TIME_FOREVER); - } - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_Interrupted) - { - if (GetClientMenu(param1) == MenuSource_External) - { - StopDisplayingHud(param1); - } - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } -} - -public Panel_PlayerHud(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - switch (param2) - { - case 1: - { - if (g_aPlayers[param1][iTargetIndex]) - { - StopFollowingPlayer(param1); - } - else - { - StopDisplayingHud(param1); - DisplayMenu(BuildSelectPlayerMenu(), param1, MENU_TIME_FOREVER); - } - } - case 2: - { - if (!g_aPlayers[param1][iTargetIndex]) - { - StopDisplayingHud(param1); - PrintToChat(param1, "\x03[SM-SPEC]\x01 %t", "Must Have Target"); - DisplayMenu(g_aMenus[hSelectPlayer], param1, MENU_TIME_FOREVER); - return; - } - - if ((GetUserFlagBits(param1) & ADMFLAG_GENERIC) || (GetUserFlagBits(param1) & ADMFLAG_ROOT)) - { - if (g_aPlayers[g_aPlayers[param1][iTargetIndex]][bIsFlaggedCheater] && (GetUserFlagBits(param1) & ADMFLAG_ROOT)) - { - //Remove cheater flag - g_aPlayers[g_aPlayers[param1][iTargetIndex]][bIsFlaggedCheater] = false; - } - else - { - //Punish menu - StopDisplayingHud(param1); - DisplayMenu(BuildPunishmentMenu(param1), param1, MENU_TIME_FOREVER); - } - } - else - { - //Report Cheater - new Handle:hPanel = BuildPublicCheaterPanel(); - SendPanelToClient(hPanel, param1, Panel_PublicCheater, MENU_TIME_FOREVER); - CloseHandle(hPanel); - } - } - case 3: - { - StopDisplayingHud(param1); - } - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_Interrupted) - { - if (GetClientMenu(param1) == MenuSource_External) - { - StopDisplayingHud(param1); - } - } - } -} - - -/** -Stock functions -*/ -stock StartFollowingPlayer(client, target) -{ - - /** - If we have an open timer, close it. - */ - if (g_aPlayers[client][hTargetTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[client][hTargetTimer]); - g_aPlayers[client][hTargetTimer] = INVALID_HANDLE; - } - - /** - Make sure the target is on a non spectator team, and the client != target - */ - if (client == target) - { - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Yourself"); - return; - } - new iTargetTeam = GetClientTeam(target); - if (iTargetTeam == g_aCurrentTeams[Spectator] || iTargetTeam == g_aCurrentTeams[Unknown]) - { - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Spectator"); - return; - } - - /** - Check to see if client is already a spectator - */ - if (GetClientTeam(client) != g_aCurrentTeams[Spectator]) - { - - /** - Client is not a spectator, lets move them to spec. - */ - SM_MovePlayer(client, g_aCurrentTeams[Spectator]); - } - - /** - If we are using steambans call sb_status - */ - if (g_aPluginSettings[bUseSteamBans]) - { - FakeClientCommandEx(client, "sb_status"); - } - - - /** - Set the global and start to spectate the target. - Making sure it's long enough to deal with moving the client to spec if we had to. - */ - new String:sTargetName[MAX_NAME_LENGTH + 1]; - GetClientName(target, sTargetName, sizeof(sTargetName)); - g_aPlayers[client][iTargetIndex] = target; - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Spectating", sTargetName); - g_aPlayers[client][hTargetTimer] = CreateTimer(0.5, Timer_ResetTarget, client, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); - if (!g_aPlayers[client][bIsDisplayingHud] && GetClientTeam(client) == g_aCurrentTeams[Spectator]) - { - StartDisplayingHud(client); - } -} - -stock StopFollowingPlayer(client) -{ - - /** - If we have an open timer, close it. - */ - if (g_aPlayers[client][hTargetTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[client][hTargetTimer]); - } - - /** - Tell the client we can't spec his target anymore... if they are in game. - */ - if (IsClientInGame(client) && g_aPlayers[client][iTargetIndex] != 0) - { - new String:sTargetName[MAX_NAME_LENGTH + 1]; - GetClientName(g_aPlayers[client][iTargetIndex], sTargetName, sizeof(sTargetName)); - if (!IsClientConnected(g_aPlayers[client][iTargetIndex]) || !IsClientInGame(g_aPlayers[client][iTargetIndex])) - { - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Target Left"); - } - else - { - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Stopped spectating", sTargetName); - } - } - - /** - Null the globals. - */ - g_aPlayers[client][iTargetIndex] = 0; - g_aPlayers[client][hTargetTimer] = INVALID_HANDLE; -} - -stock StartDisplayingHud(client) -{ - if (g_aPluginCvarSettings[bRestrictHud] && !SM_IsValidAdmin(client, g_sAdminFlags)) - { - return; - } - else - { - /** - Double check the hud timer - We should not have one, but if we do, lets cancel it for the current callback - */ - StopDisplayingHud(client); - - /** - Now we can safely display the hud and make sure the current stored handle is the current timer - */ - g_aPlayers[client][bIsDisplayingHud] = true; - g_aPlayers[client][hHudTimer] = CreateTimer(0.5, Timer_UpdateHud, client, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); - } -} - -stock StopDisplayingHud(client) -{ - if (g_aPlayers[client][hHudTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[client][hHudTimer]); - } - g_aPlayers[client][hHudTimer] = INVALID_HANDLE; - g_aPlayers[client][bIsDisplayingHud] = false; -} - -stock ResetClient(client) -{ - StopFollowingPlayer(client); - StopDisplayingHud(client); - - g_aPlayers[client][bIsFlaggedCheater] = false; - g_aPlayers[client][TargetPunishment] = Punish_None; - g_aPlayers[client][iBanTime] = -1; -} - -stock PerformPunishment(client, target, e_Punishments:punishment, const String:reason[], time = 300) -{ - new String:sTargetName[MAX_NAME_LENGTH + 1], - String:sTargetID[64]; - - /** - The target could have left the game by the time we get here - Check for a valid target - */ - if (!IsClientConnected(target) || !IsClientInGame(target)) - { - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Target Left"); - return; - } - - GetClientName(target, sTargetName, sizeof(sTargetName)); - GetClientAuthString(target, sTargetID, sizeof(sTargetID)); - - switch (punishment) - { - case Punish_Kick: - { - KickClient(g_aPlayers[client][iTargetIndex], "%s", reason); - } - case Punish_Ban: - { - if (g_aPluginSettings[bUseSourceBans]) - { - ClientCommand(client, "sm_ban #%d %d \"%s\"", GetClientUserId(target), time, reason); - } - else if (g_aPluginSettings[bUseMySQLBans]) - { - ClientCommand(client, "mysql_ban #%d %d \"%s\"", GetClientUserId(target), time, reason); - } - else - { - BanClient(target, time, BANFLAG_AUTHID, reason, reason); - } - } - case Punish_Cheater: - { - g_aPlayers[target][bIsFlaggedCheater] = true; - } - case Punish_Beacon: - { - ClientCommand(client, "sm_beacon \"%s\"", sTargetName); - } - case Punish_Blind: - { - ClientCommand(client, "sm_blind \"%s\"", sTargetName); - } - case Punish_Drug: - { - ClientCommand(client, "sm_drug \"%s\"", sTargetName); - } - case Punish_Freeze: - { - ClientCommand(client, "sm_freeze \"%s\"", sTargetName); - } - case Punish_FreezeBomb: - { - ClientCommand(client, "sm_freezebomb \"%s\"", sTargetName); - } - case Punish_Slap: - { - ClientCommand(client, "sm_slap \"%s\" 10", sTargetName); - } - case Punish_Slay: - { - ClientCommand(client, "sm_slay \"%s\"", sTargetName); - } - case Punish_TimeBomb: - { - ClientCommand(client, "sm_timebomb \"%s\"", sTargetName); - } - } - - if (punishment == Punish_Cheater) - { - LogAction(client, target, "[SM SPEC] %N marked %N(%s) with a %s flag for %s", client, target, sTargetID, g_sPunishments[punishment], reason); - } - else - { - ShowActivity(client, "%t", "Punished", sTargetName, g_sPunishments[punishment], reason); - LogAction(client, target, "[SM SPEC] %N punished %N(%s) with a %s for %s", client, target, sTargetID, g_sPunishments[punishment], reason); - } - - /** - Null the globals. - */ - g_aPlayers[client][TargetPunishment] = Punish_None; - g_aPlayers[client][iBanTime] = -1; -} - -/** -Build the menu of player names -*/ -stock Handle:BuildPlayerListMenu() -{ - new Handle:hMenu = CreateMenu(Menu_PlayerList); - AddTargetsToMenu(hMenu, 0, true, false); - SetMenuTitle(hMenu, "Select A Player:"); - SetMenuExitBackButton(hMenu, true); - return hMenu; -} - -/** -Build the select player menu (current or list of players) -*/ -stock Handle:BuildSelectPlayerMenu() -{ - new Handle:hMenu = CreateMenu(Menu_SelectPlayer); - SetMenuTitle(hMenu, "Select A Player:"); - AddMenuItem(hMenu, "Current", "Current Target"); - AddMenuItem(hMenu, "List", "Player List"); - SetMenuExitBackButton(hMenu, true); - return hMenu; -} - -/** -Build the punishmenu menu -*/ -stock Handle:BuildPunishmentMenu(iClient) -{ - new Handle:hMenu = CreateMenu(Menu_Punishments); - SetMenuTitle(hMenu, "Select A Punishment:"); - SetMenuExitBackButton(hMenu, true); - SetMenuExitButton(hMenu, true); - - if (g_aPluginCvarSettings[bKick] && ((GetUserFlagBits(iClient) & ADMFLAG_GENERIC) || (GetUserFlagBits(iClient) & ADMFLAG_ROOT))) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Kick], "Kick"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Kick], "Kick", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bBan] && ((GetUserFlagBits(iClient) & ADMFLAG_GENERIC) || (GetUserFlagBits(iClient) & ADMFLAG_ROOT))) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Ban], "Ban"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Ban], "Ban", ITEMDRAW_DISABLED); - } - - if (g_aPluginSettings[bUseDukehacks] && g_aPluginCvarSettings[bCheater] && (GetUserFlagBits(iClient) & ADMFLAG_ROOT)) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Cheater], "Flag As Cheater"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Cheater], "Flag As Cheater", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bBeacon]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Beacon], "Beacon"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Beacon], "Beacon", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bBlind]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Blind], "Blind"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Blind], "Blind", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bDrug]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Drug], "Drug"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Drug], "Drug", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bFreeze]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Freeze], "Freeze"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Freeze], "Freeze", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bFreezebomb]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_FreezeBomb], "Freeze Bomb"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_FreezeBomb], "Freeze Bomb", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bSlap]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Slap], "Slap"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Slap], "Slap", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bSlay]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Slay], "Slay"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Slay], "Slay", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bTimeBomb]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_TimeBomb], "Time Bomb"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_TimeBomb], "Time Bomb", ITEMDRAW_DISABLED); - } - - return hMenu; -} - -/** -Build the punishmenu menu -*/ -stock Handle:BuildBanTimeMenu() -{ - new Handle:hMenu = CreateMenu(Menu_BanTime); - SetMenuTitle(hMenu, "Select Ban Type:"); - - if (g_aPluginCvarSettings[bBanPerm]) - { - AddMenuItem(hMenu, "permban", "Permanent"); - } - else - { - AddMenuItem(hMenu, "permban", "Permanent", ITEMDRAW_DISABLED); - } - - AddMenuItem(hMenu, "10", "10 Minutes"); - AddMenuItem(hMenu, "30", "30 Minutes"); - AddMenuItem(hMenu, "60", "1 Hour"); - AddMenuItem(hMenu, "240", "4 Hours"); - AddMenuItem(hMenu, "1440", "1 Day"); - AddMenuItem(hMenu, "10080", "1 Week"); - - SetMenuExitBackButton(hMenu, true); - return hMenu; -} - -/** -Build the punishmenu menu -*/ -stock Handle:BuildReasonMenu() -{ - new Handle:hMenu = CreateMenu(Menu_Reason); - SetMenuTitle(hMenu, "Select A Reason:"); - - AddMenuItem(hMenu, "Abusive", "Abusive"); - AddMenuItem(hMenu, "Racism", "Racism"); - AddMenuItem(hMenu, "General cheating/exploits", "General cheating/exploits"); - AddMenuItem(hMenu, "Wallhack", "Wallhack"); - AddMenuItem(hMenu, "Aimbot", "Aimbot"); - AddMenuItem(hMenu, "Speedhacking", "Speedhacking"); - AddMenuItem(hMenu, "Mic spamming", "Mic spamming"); - AddMenuItem(hMenu, "Admin disrepect", "Admin disrepect"); - AddMenuItem(hMenu, "Camping", "Camping"); - AddMenuItem(hMenu, "Team killing", "Team killing"); - AddMenuItem(hMenu, "Unacceptable Spray", "Unacceptable Spray"); - AddMenuItem(hMenu, "Breaking Server Rules", "Breaking Server Rules"); - AddMenuItem(hMenu, "Other", "Other"); - - SetMenuExitBackButton(hMenu, true); - return hMenu; -} - -/** -Build the cheater displays -*/ -stock Handle:BuildAdminCheaterPanel() -{ - - /** - Create the menu and set the menu options. - */ - new Handle:hPanel = CreatePanel(); - SetPanelTitle(hPanel, "Simple Spectator:"); - - DrawPanelText(hPanel, "Are you sure you want to"); - DrawPanelText(hPanel, "flag this player as a cheater?"); - DrawPanelText(hPanel, "They will not be able to damage"); - DrawPanelText(hPanel, "anyone and die on fall damage."); - DrawPanelItem(hPanel, "Yes"); - DrawPanelItem(hPanel, "No"); - - return hPanel; -} - -stock Handle:BuildPublicCheaterPanel() -{ - - /** - Create the menu and set the menu options. - */ - new Handle:hPanel = CreatePanel(); - SetPanelTitle(hPanel, "Simple Spectator:"); - - DrawPanelText(hPanel, "Are you sure you want to"); - DrawPanelText(hPanel, "submit this player as a cheater?"); - DrawPanelItem(hPanel, "Yes (Not Implemented Yet)", ITEMDRAW_DISABLED); - DrawPanelItem(hPanel, "No"); - return hPanel; -} - -/** -Build the hud displays -*/ -stock Handle:BuildPlayerHudMenu(iClient, iTarget) -{ - - /** - Create all the string variables we will need - */ - new String:sTargetName[MAX_NAME_LENGTH + 1], - String:sTargetID[64], - String:sTargetIP[16]; - - new String:sDisplayName[MAX_NAME_LENGTH + 1], - String:sDisplayID[64], - String:sDisplayIP[64], - String:sDisplayFrags[16], - String:sDisplayDeaths[16]; - - new iTargetFrags, - iTargetDeaths; - - /** - Get the targets information - */ - GetClientName(iTarget, sTargetName, sizeof(sTargetName)); - GetClientIP(iTarget, sTargetIP, sizeof(sTargetIP)); - GetClientAuthString(iTarget, sTargetID, sizeof(sTargetID)); - iTargetFrags = GetClientFrags(iTarget); - iTargetDeaths = GetClientDeaths(iTarget); - - /** - Format the strings for the menu - */ - Format(sDisplayName, sizeof(sDisplayName), "Player: %s", sTargetName); - Format(sDisplayID, sizeof(sDisplayID), "Steam ID: %s", sTargetID); - Format(sDisplayIP, sizeof(sDisplayIP), "IP Address: %s", sTargetIP); - Format(sDisplayFrags, sizeof(sDisplayFrags), "Kills: %i", iTargetFrags); - Format(sDisplayDeaths, sizeof(sDisplayDeaths), "Deaths: %i", iTargetDeaths); - - /** - Create the menu and set the menu options. - */ - new Handle:hMenu = CreateMenu(Menu_PlayerHud); - SetMenuExitBackButton(hMenu, false); - SetMenuTitle(hMenu, "Simple Spectator"); - - AddMenuItem(hMenu, "name", sDisplayName, ITEMDRAW_DISABLED); - AddMenuItem(hMenu, "steamid", sDisplayID, ITEMDRAW_DISABLED); - - if (SM_IsValidAdmin(iClient, g_sAdminFlags)) - { - AddMenuItem(hMenu, "ip", sDisplayIP, ITEMDRAW_DISABLED); - } - - AddMenuItem(hMenu, "kills", sDisplayFrags, ITEMDRAW_DISABLED); - AddMenuItem(hMenu, "deaths", sDisplayDeaths, ITEMDRAW_DISABLED); - - if (g_aPlayers[iClient][iTargetIndex]) - { - AddMenuItem(hMenu, "stop", "Stop Following"); - } - else - { - AddMenuItem(hMenu, "start", "Follow Player"); - } - - if ((GetUserFlagBits(iClient) & ADMFLAG_GENERIC) || (GetUserFlagBits(iClient) & ADMFLAG_ROOT)) - { - if (g_aPlayers[iTarget][bIsFlaggedCheater] && (GetUserFlagBits(iClient) & ADMFLAG_ROOT)) - { - AddMenuItem(hMenu, "removecheater", "Remove Cheater Flag"); - } - else - { - if (CanUserTarget(iClient, iTarget)) - { - AddMenuItem(hMenu, "punish", "Punish Player"); - } - else - { - AddMenuItem(hMenu, "punish", "Punish Player (Immune)", ITEMDRAW_DISABLED); - } - } - } - else - { - AddMenuItem(hMenu, "reportcheater", "Report Cheater"); - } - - SetMenuPagination(hMenu, MENU_NO_PAGINATION); - SetMenuExitButton(hMenu, true); - return hMenu; -} - -stock Handle:BuildPlayerHudPanel(iClient, iTarget) -{ - - /** - Create all the string variables we will need - */ - new String:sTargetName[MAX_NAME_LENGTH + 1], - String:sTargetID[64], - String:sTargetIP[16]; - - new String:sDisplayName[MAX_NAME_LENGTH + 1], - String:sDisplayID[64], - String:sDisplayIP[64], - String:sDisplayFrags[16], - String:sDisplayDeaths[16]; - - new iTargetFrags, - iTargetDeaths; - - /** - Get the targets information - */ - GetClientName(iTarget, sTargetName, sizeof(sTargetName)); - GetClientIP(iTarget, sTargetIP, sizeof(sTargetIP)); - GetClientAuthString(iTarget, sTargetID, sizeof(sTargetID)); - iTargetFrags = GetClientFrags(iTarget); - iTargetDeaths = GetClientDeaths(iTarget); - - /** - Format the strings for the menu - */ - Format(sDisplayName, sizeof(sDisplayName), "Player: %s", sTargetName); - Format(sDisplayID, sizeof(sDisplayID), "Steam ID: %s", sTargetID); - Format(sDisplayIP, sizeof(sDisplayIP), "IP Address: %s", sTargetIP); - Format(sDisplayFrags, sizeof(sDisplayFrags), "Kills: %i", iTargetFrags); - Format(sDisplayDeaths, sizeof(sDisplayDeaths), "Deaths: %i", iTargetDeaths); - - /** - Create the menu and set the menu options. - */ - new Handle:hPanel = CreatePanel(); - SetPanelTitle(hPanel, "Simple Spectator"); - - DrawPanelText(hPanel, "Player Information:"); - DrawPanelText(hPanel, sDisplayName); - DrawPanelText(hPanel, sDisplayID); - if (SM_IsValidAdmin(iClient, g_sAdminFlags)) - { - DrawPanelText(hPanel, sDisplayIP); - } - - DrawPanelText(hPanel, sDisplayFrags); - DrawPanelText(hPanel, sDisplayDeaths); - - if (g_aPlayers[iClient][iTargetIndex]) - { - DrawPanelItem(hPanel, "Stop Following"); - } - else - { - DrawPanelItem(hPanel, "Follow Player"); - } - - if ((GetUserFlagBits(iClient) & ADMFLAG_GENERIC) || (GetUserFlagBits(iClient) & ADMFLAG_ROOT)) - { - if (g_aPlayers[iTarget][bIsFlaggedCheater] && (GetUserFlagBits(iClient) & ADMFLAG_ROOT)) - { - DrawPanelItem(hPanel, "Remove Cheater Flag"); - } - else - { - if (CanUserTarget(iClient, iTarget)) - { - DrawPanelItem(hPanel, "Punish Player"); - } - else - { - DrawPanelItem(hPanel, "Punish Player (Immune)", ITEMDRAW_DISABLED); - } - } - } - else - { - DrawPanelItem(hPanel, "Report Cheater"); - } - - DrawPanelItem(hPanel, "Close Hud Panel"); - return hPanel; -} - -/** -Adjust the settings if a convar was changed -*/ -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - for (new iCvar = 0 ; _:iCvar < sizeof(g_aPluginCvarSettings); iCvar++) - { - if (g_aPluginCvar[_:iCvar] == convar) - { - if (StringToInt(newValue) == 1) - { - g_aPluginCvarSettings[_:iCvar] = true; - } - else - { - g_aPluginCvarSettings[_:iCvar] = false; - } - } - } - - /* - ReBuild the global menu that depends on cvars - */ - g_aMenus[hBanTime] = BuildBanTimeMenu(); - - /** - Run a loop to reset the hud - */ - for(new i = 1; i <= MaxClients; i++) - { - StopDisplayingHud(i); - if (IsClientConnected(i) && IsClientInGame(i) && GetClientTeam(i) == g_aCurrentTeams[Spectator]) - { - StartDisplayingHud(i); - } - } -} diff --git a/Simple Chat Colors/addons/sourcemod/scripting/simple-teambalancer.sp b/Simple Chat Colors/addons/sourcemod/scripting/simple-teambalancer.sp deleted file mode 100644 index 3302255..0000000 --- a/Simple Chat Colors/addons/sourcemod/scripting/simple-teambalancer.sp +++ /dev/null @@ -1,1797 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Team Balancer -Description: - Balances teams based upon player count - Player will not be balanced more than once in 5 (default) mins - Buddy system tries to keep buddies together - Ability to prioritize players - Ability to force players to accept the new team - Admins are immune -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include -#include - -#define PLUGIN_VERSION "2.1.$Rev$" - -enum PlayerData -{ - Handle:hBalanceTimer, - Handle:hForcedTimer, - bool:bSwitched, - bool:bFlagCarrier -}; - -/** - Global convar handles - */ -new Handle:stb_enabled = INVALID_HANDLE; -new Handle:stb_buddyenabled = INVALID_HANDLE; -new Handle:stb_logactivity = INVALID_HANDLE; -new Handle:stb_logactivity2 = INVALID_HANDLE; -new Handle:stb_unbalancelimit = INVALID_HANDLE; -new Handle:stb_deadonly = INVALID_HANDLE; -new Handle:stb_priorityenabled = INVALID_HANDLE; -new Handle:stb_uberlevel = INVALID_HANDLE; -new Handle:stb_balancedelay = INVALID_HANDLE; -new Handle:stb_livingplayerswitchdelay = INVALID_HANDLE; -new Handle:stb_livingplayercheckdelay = INVALID_HANDLE; -new Handle:stb_roundstartdelay = INVALID_HANDLE; -new Handle:stb_switchbackforced = INVALID_HANDLE; -new Handle:stb_adminflag = INVALID_HANDLE; -new Handle:stb_buddyrestriction = INVALID_HANDLE; -new Handle:stb_convarcontrol = INVALID_HANDLE; - -/** - Built-in cvars handles - */ -new Handle:stb_mp_autoteambalance = INVALID_HANDLE; -new Handle:stb_mp_teams_unbalance_limit = INVALID_HANDLE; -new Handle:TFGameModeArena = INVALID_HANDLE; - -/** - Timer handles - */ -new Handle:g_hBalanceTimer = INVALID_HANDLE; -new Handle:g_hLivingPlayerCheckTimer = INVALID_HANDLE; - -/** - Player arrays - */ -new g_aPlayers[MAXPLAYERS + 1][PlayerData]; - -/** -Global bools -*/ -new bool:g_bIsEnabled = true; -new bool:g_bPriorityPlayers = true; -new bool:g_bBuddyRestriction = false; -new bool:g_bLogActivity = false; -new bool:g_bLogActivity2 = false; -new bool:g_bDeadOnly = false; -new bool:g_bConVarControl = true; -new bool:g_bBuddyEnabled = true; -new bool:g_bBalanceInProgress = false; -new bool:g_bRoundStart = false; -new bool:g_bRoundEnd = false; -new bool:g_bSuddenDeath = false; -new bool:g_bIsArenaMode = false; - -/** - Global strings/integers/floats - */ -new g_iUnbalanceLimit, g_iLivingPlayerSwitchDelay, g_iLivingPlayerCheckDelay; -new g_iRoundStartDelay, g_iSwitchBackForced, g_iBalanceDelay; -new Float:g_fUberLevel; -new g_iOwnerOffset; -new String:g_sAdminFlag[5]; - -public Plugin:myinfo = -{ - name = "Simple Team Balancer", - author = "Simple Plugins", - description = "Balances teams based upon player count.", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -} - -public OnPluginStart() -{ - - /** - Create console variables - */ - CreateConVar("stb_version", PLUGIN_VERSION, "Simple Team Balancer", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - stb_enabled = CreateConVar("stb_enabled", "1", "Enable or Disable Simple Team Balancer", _, true, 0.0, true, 1.0); - stb_priorityenabled = CreateConVar("stb_priorityenabled", "1", "Enable or Disable the prioritization of living players", _, true, 0.0, true, 1.0); - stb_buddyrestriction = CreateConVar("stb_buddyrestriction", "0", "Enable or Disable Admin Only buddy lists", _, true, 0.0, true, 1.0); - stb_logactivity = CreateConVar("stb_logactivity", "0", "Enable or Disable the disaplying of events in the log", _, true, 0.0, true, 1.0); - stb_logactivity2 = CreateConVar("stb_logactivity2", "0", "Enable or Disable the disaplying of detailed events in the log (WILL SPAM LOG)", _, true, 0.0, true, 1.0); - stb_deadonly = CreateConVar("stb_deadonly", "0", "Enable or Disable the switching of only dead players", _, true, 0.0, true, 1.0); - stb_convarcontrol = CreateConVar("stb_convarcontrol", "1", "Enable or Disable the control of builtin console variables", _, true, 0.0, true, 1.0); - stb_buddyenabled = CreateConVar("stb_buddyenabled", "1", "Enable or Disable the buddy system", _, true, 0.0, true, 1.0); - stb_unbalancelimit = CreateConVar("stb_unbalancelimit", "2", "Amount of players teams are ALLOWED to be unbalanced by", _, true, 1.0, true, 32.0); - stb_balancedelay = CreateConVar("stb_balancedelay", "10", "Delay in seconds to start an autobalance"); - stb_livingplayerswitchdelay = CreateConVar("stb_livingplayerswitchdelay", "20", "Delay in seconds to switch living players once selected"); - stb_livingplayercheckdelay = CreateConVar("stb_livingplayercheckdelay", "10", "Delay in seconds to start checking living players once teams become unbalanced"); - stb_roundstartdelay = CreateConVar("stb_roundstartdelay", "15", "Delay in seconds to start balancing teams after the start of a round"); - stb_switchbackforced = CreateConVar("stb_switchbackforced", "300", "Amount of time in seconds to not switch a player twice and force the team if enabled"); - stb_uberlevel = CreateConVar("stb_uberlevel", "1.0", "Min uber level medic must have to have priority over other living players. Setting to 0 will rarely switch a living medic", _, true, 0.0, true, 1.0); - stb_adminflag = CreateConVar("stb_adminflag", "a", "Admin flag to use for immunity. Must be a in char format."); - stb_mp_autoteambalance = FindConVar("mp_autoteambalance"); - stb_mp_teams_unbalance_limit = FindConVar("mp_teams_unbalance_limit"); - - /** - Removing the notify tags from the built in cvars. We dont want spam. - */ - if (stb_mp_autoteambalance != INVALID_HANDLE) - { - SetConVarFlags(stb_mp_autoteambalance, GetConVarFlags(stb_mp_autoteambalance)^FCVAR_NOTIFY); - } - if (stb_mp_teams_unbalance_limit != INVALID_HANDLE) - { - SetConVarFlags(stb_mp_teams_unbalance_limit, GetConVarFlags(stb_mp_teams_unbalance_limit)^FCVAR_NOTIFY); - } - - /** - Hook console variables - */ - HookConVarChange(stb_enabled, ConVarSettingsChanged); - HookConVarChange(stb_priorityenabled, ConVarSettingsChanged); - HookConVarChange(stb_buddyrestriction, ConVarSettingsChanged); - HookConVarChange(stb_logactivity, ConVarSettingsChanged); - HookConVarChange(stb_logactivity2, ConVarSettingsChanged); - HookConVarChange(stb_deadonly, ConVarSettingsChanged); - HookConVarChange(stb_convarcontrol, ConVarSettingsChanged); - HookConVarChange(stb_buddyenabled, ConVarSettingsChanged); - HookConVarChange(stb_unbalancelimit, ConVarSettingsChanged); - HookConVarChange(stb_balancedelay, ConVarSettingsChanged); - HookConVarChange(stb_livingplayerswitchdelay, ConVarSettingsChanged); - HookConVarChange(stb_livingplayercheckdelay, ConVarSettingsChanged); - HookConVarChange(stb_roundstartdelay, ConVarSettingsChanged); - HookConVarChange(stb_switchbackforced, ConVarSettingsChanged); - HookConVarChange(stb_uberlevel, ConVarSettingsChanged); - HookConVarChange(stb_mp_autoteambalance, ConVarSettingsChanged); - HookConVarChange(stb_mp_teams_unbalance_limit, ConVarSettingsChanged); - - /** - Create console commands - */ - RegConsoleCmd("sm_buddy", Command_AddBalanceBuddy, "Add a balance buddy"); - RegConsoleCmd("sm_lockbuddy", Command_LockBuddy, "Locks your balance buddy selection"); - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook the game events - */ - LogAction(0, -1, "[STB] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_death", HookPlayerDeath, EventHookMode_Post); - HookEvent("player_team", HookPlayerChangeTeam, EventHookMode_Post); - switch (g_CurrentMod) - { - case GameType_TF: - { - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - HookEvent("teamplay_suddendeath_begin", HookSuddenDeathBegin, EventHookMode_PostNoCopy); - HookEvent("teamplay_flag_event", HookFlagEvent, EventHookMode_Post); - TFGameModeArena = FindConVar("tf_gamemode_arena"); - g_iOwnerOffset = FindSendPropInfo("CBaseObject", "m_hBuilder"); - } - case GameType_DOD: - { - HookEvent("dod_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_Post); - } - default: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - } - } - - /** - Load translations and .cfg file - */ - LoadTranslations ("simpleteambalancer.phrases"); - AutoExecConfig(true, "plugin.simpleteambalancer"); - LogAction(0, -1, "[STB] Simple Team Balancer is loaded."); -} - -public OnAllPluginsLoaded() -{ - //something -} - -public OnLibraryRemoved(const String:name[]) -{ - //something -} - -public OnConfigsExecuted() -{ - - /** - Load up global variables - */ - g_bIsEnabled = GetConVarBool(stb_enabled); - g_bBuddyEnabled = GetConVarBool(stb_buddyenabled); - g_bLogActivity = GetConVarBool(stb_logactivity); - g_bLogActivity2 = GetConVarBool(stb_logactivity2); - g_bDeadOnly = GetConVarBool(stb_deadonly); - g_bPriorityPlayers = GetConVarBool(stb_priorityenabled); - g_bBuddyRestriction = GetConVarBool(stb_buddyrestriction); - g_bConVarControl = GetConVarBool(stb_convarcontrol); - g_fUberLevel = GetConVarFloat(stb_uberlevel); - g_iUnbalanceLimit = GetConVarInt(stb_unbalancelimit); - g_iBalanceDelay = GetConVarInt(stb_balancedelay); - g_iLivingPlayerSwitchDelay = GetConVarInt(stb_livingplayerswitchdelay); - g_iLivingPlayerCheckDelay = GetConVarInt(stb_livingplayercheckdelay); - g_iRoundStartDelay = GetConVarInt(stb_roundstartdelay); - g_iSwitchBackForced = GetConVarInt(stb_switchbackforced); - GetConVarString(stb_adminflag, g_sAdminFlag, sizeof(g_sAdminFlag)); - - /** - Report enabled - */ - if (g_bIsEnabled) - { - LogAction(0, -1, "[STB] Simple Team Balancer is ENABLED."); - } - else - { - LogAction(0, -1, "[STB] Simple Team Balancer is DISABLED."); - } - - - /** - Report log activity - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Log Activity ENABLED."); - } - else - { - LogAction(0, -1, "[STB] Log Activity DISABLED."); - } - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Detailed Log Activity ENABLED."); - } - else - { - LogAction(0, -1, "[STB] Detailed Log Activity DISABLED."); - } -} - -public OnMapStart() -{ - - /** - Check for arena mode - */ - if (g_CurrentMod == GameType_TF && GetConVarBool(TFGameModeArena)) - { - g_bIsArenaMode = true; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Simple Team Balancer detected arena mode and will be bypassed"); - } - } - else - { - g_bIsArenaMode = false; - } - - /** - Reset the globals - */ - g_bBalanceInProgress = false; - g_bRoundStart = false; - g_bRoundEnd = false; - g_bSuddenDeath = false; - - /** - Set the built-in convars - */ - SetGameCvars(); -} - -public OnClientPostAdminCheck(client) -{ - - /** - Make sure its a valid connected client and buddy system is enabled - */ - if (client == 0 || !g_bIsEnabled || !IsClientConnected(client) || !g_bBuddyEnabled) - { - return; - } - - /** - Make sure if its set for admins only they have the flags - */ - if (g_bBuddyRestriction && !SM_IsValidAdmin(client, g_sAdminFlag)) - { - return; - } - - /** - Start the advertisement timer - */ - CreateTimer (60.0, Timer_WelcomeAdvert, client); -} - -public OnClientDisconnect(client) -{ - - /** - Call stock function to cleaup - */ - CleanUp(client); -} - -public OnClientDisconnect_Post(client) -{ - - /** - Determine if we need a balance - */ - if (OkToBalance() && IsUnbalanced() && !g_bBalanceInProgress) - { - - /** - No balance in progress but balance is needed - */ - StartABalance(); - } -} - -public SM_OnPlayerMoved(Handle:plugin, client, team) -{ - - /** - Make sure we called the move function - */ - if (plugin != GetMyHandle()) - { - if (g_bLogActivity2) - { - LogAction(0, client, "[STB] Callback was not started with current plugin, bugging out."); - } - return; - } - - /** - Get the players name and report the event - */ - decl String:sPlayerName[64]; - GetClientName(client, sPlayerName, sizeof(sPlayerName)); - if (g_bLogActivity) - { - LogAction(0, client, "[STB] Changed %s to team %i.", sPlayerName, team); - } - - /** - If we are in TF2 fire the bult-in team balance event - */ - if(g_CurrentMod == GameType_TF) - { - new Handle:event = CreateEvent("teamplay_teambalanced_player"); - SetEventInt(event, "player", client); - SetEventInt(event, "team", team); - FireEvent(event); - } - - /** - Notify the players - */ - PrintToChatAll("[SM] %T", "BalanceMessage", LANG_SERVER, sPlayerName); - - /** - Set the players variables and start a timer - */ - g_aPlayers[client][bSwitched] = true; - g_aPlayers[client][hForcedTimer] = CreateTimer(float(g_iSwitchBackForced), Timer_ForcedExpired, client, TIMER_FLAG_NO_MAPCHANGE); - - /** - We are done, log the completion and end the balance - */ - if (g_bLogActivity) - { - LogAction(0, client, "[STB] Balance finished."); - } - g_bBalanceInProgress = false; -} - -/* HOOKED EVENTS */ - -public HookPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get our event variables - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - decl String:sWeapon[64]; - GetEventString(event, "weapon", sWeapon, sizeof(sWeapon)); - - /** - Return if death was not caused by a player - This is the case when the player switches teams - */ - if (StrEqual(sWeapon, "world", false)) - { - return; - } - - - /** - Check if balance is needed - */ - if (IsClientInGame(iClient) && OkToBalance() && IsUnbalanced()) - { - new iSmallerTeam = GetSmallerTeam(); - - /** - Check if balance is in progress - */ - if (g_bBalanceInProgress) - { - - /** - There is a balance in progress - Check the player who died to see if he is supposed to be switched - */ - if (g_aPlayers[iClient][hBalanceTimer] != INVALID_HANDLE) - { - - /** - The player has a timer on him to switch him to other team - Stop the timer - */ - CloseHandle(g_aPlayers[iClient][hBalanceTimer]); - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - if (g_bLogActivity) - { - LogAction(0, iClient, "[STB] With a balance in progress the queued living player died and was switched."); - } - - /** - Call the stock change team function - */ - BalancePlayer(iClient, SM_GetForcedTeam(iClient)); - return; - } - - /** - Before we continue, lets make sure the client is switchable - */ - if (IsSwitchablePlayer(iClient, GetBiggerTeam())) - { - - /** - Now we check the buddy system - */ - if (g_bBuddyEnabled) - { - - /** - Buddy system is enabled, check to see if client has buddy - */ - new iBuddyIndex = SM_GetClientBuddy(iClient); - if (iBuddyIndex != 0 || !IsClientConnected(iBuddyIndex) || !IsClientInGame(iBuddyIndex)) - { - - /** - The client has a buddy, so we check to see if they are on same team - */ - if (GetClientTeam(iClient) == GetClientTeam(iBuddyIndex)) - { - - /** - They are, but we don't bug out, we still need to start a balance - */ - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] With a balance in progress a buddy on the right team was found and skipped."); - } - } - else - { - - /** - They are not on the same team - The buddy could be in spec, and that would make it not matter where he is, or the buddy is on the smaller team - */ - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] With a balance in progress a buddy on the wrong team was switched."); - } - BalancePlayer(iClient, iSmallerTeam); - return; - } - } - else - { - - /** - Client doesn't have a buddy, balance this player - */ - BalancePlayer(iClient, iSmallerTeam); - return; - } - } - else - { - - /** - Buddy system is not enabled, balance this player - */ - BalancePlayer(iClient, iSmallerTeam); - return; - } - } - } - else - { - - /** - If we get to here then we must need to start a balance - */ - StartABalance(); - } - } -} - -public HookPlayerChangeTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get our event variables. - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - new iTeam = GetEventInt(event, "team"); - - /** - Make sure its ok to balance. - */ - if (OkToBalance()) - { - - /** - See if the client that changed teams was set to with a balance. - */ - if (g_aPlayers[iClient][hBalanceTimer] != INVALID_HANDLE - && SM_GetForcedTeam(iClient) == iTeam - && g_bBalanceInProgress) - { - - /** - The client was set to be balanced, so we close the timer. - */ - CloseHandle(g_aPlayers[iClient][hBalanceTimer]); - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - - /** - Stop the balance. - */ - g_bBalanceInProgress = false; - return; - } - - /** - It's not likely that this team change can cause us to need a balance. - If it does, start one with a small dealy to deal with forced switch backs. - */ - if (IsUnbalanced() && !g_bBalanceInProgress) - { - CreateTimer(2.0, Timer_ChangeTeamBalanceDelay, _, TIMER_FLAG_NO_MAPCHANGE); - } - } -} - -public HookRoundStart(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Set the variables we need to start a round - */ - g_bRoundStart = true; - g_bRoundEnd = false; - g_bSuddenDeath = false; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Round Started"); - } - - /** - Start a delayed balance check at the start of the round - */ - CreateTimer(float(g_iRoundStartDelay), Timer_RoundStart); -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Set the variables we need at round end - */ - g_bRoundEnd = true; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Round Ended"); - } -} - -public HookSuddenDeathBegin(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Set the variables we need for sudden death - */ - g_bSuddenDeath = true; -} - -public HookFlagEvent(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get our event variables - */ - new iClient = GetEventInt(event, "player"); - new iFlagStatus = GetEventInt(event, "eventtype"); - - /** - Make sure we have a valid client - */ - if (!IsClientInGame(iClient)) - { - return; - } - - /** - Determine what kind of event this is - */ - switch (iFlagStatus) - { - case 1: - { - - /** - The flag was picked up - */ - g_aPlayers[iClient][bFlagCarrier] = true; - } - case 2: - { - - /** - The flag was capped - */ - g_aPlayers[iClient][bFlagCarrier] = false; - } - case 3: - { - - /** - The flag was defended, we don't have to do anything - */ - } - case 4: - { - - /** - The flag was dropped - */ - g_aPlayers[iClient][bFlagCarrier] = false; - } - } -} - -/* COMMAND EVENTS */ - -public Action:Command_AddBalanceBuddy(client, args) -{ - if (client == 0) - { - ReplyToCommand(client, "[SM] %T", "PlayerLevelCmd", LANG_SERVER); - return Plugin_Handled; - } - if (!g_bIsEnabled || !g_bBuddyEnabled) - { - ReplyToCommand(client, "[SM] %T", "CmdDisabled", LANG_SERVER); - return Plugin_Handled; - } - if (g_bBuddyRestriction) - { - if (!SM_IsValidAdmin(client, g_sAdminFlag)) - { - ReplyToCommand(client, "[SM] %T", "RestrictedBuddy", LANG_SERVER); - return Plugin_Handled; - } - } - decl String:sPlayerUserId[24]; - GetCmdArg(1, sPlayerUserId, sizeof(sPlayerUserId)); - new iPlayer = GetClientOfUserId(StringToInt(sPlayerUserId)); - if (!iPlayer || !IsClientInGame(iPlayer) || client == iPlayer) - { - if (client == iPlayer) - { - PrintHintText(client, "%T", "SelectSelf", LANG_SERVER); - } - ReplyToCommand(client, "[SM] Usage: buddy "); - new Handle:playermenu = BuildPlayerMenu(); - DisplayMenu(playermenu, client, MENU_TIME_FOREVER); - } - else - { - decl String:cName[128]; - decl String:bName[128]; - GetClientName(client, cName, sizeof(cName)); - GetClientName(iPlayer, bName, sizeof(bName)); - if (SM_IsBuddyLocked(iPlayer)) - { - ReplyToCommand(client, "[SM] %T", "PlayerLockedBuddyMsg", LANG_SERVER, bName); - return Plugin_Handled; - } - SM_AssignBuddy(client, iPlayer); - PrintHintText(client, "%T", "BuddyMsg", LANG_SERVER, bName); - PrintHintText(iPlayer, "%T", "BuddyMsg", LANG_SERVER, cName); - } - return Plugin_Handled; -} - -public Action:Command_LockBuddy(client, args) -{ - if (client == 0) - { - ReplyToCommand(client, "[SM] %T", "PlayerLevelCmd", LANG_SERVER); - return Plugin_Handled; - } - if (!g_bIsEnabled) - { - ReplyToCommand(client, "[SM] %T", "CmdDisabled", LANG_SERVER); - return Plugin_Handled; - } - if (g_bBuddyRestriction) - { - if (!SM_IsValidAdmin(client, g_sAdminFlag)) - { - ReplyToCommand(client, "[SM] %T", "RestrictedBuddy", LANG_SERVER); - return Plugin_Handled; - } - } - if (SM_IsBuddyLocked(client)) - { - SM_LockBuddy(client, false); - PrintHintText(client, "%T", "BuddyLockMsgDisabled", LANG_SERVER); - } - else - { - SM_LockBuddy(client, true); - PrintHintText(client, "%T", "BuddyLockMsgEnabled", LANG_SERVER); - } - return Plugin_Handled; -} - -/** -Stock functions . - */ - -stock bool:IsUnbalanced() -{ - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Checking if teams are unbalanced"); - } - new Team1Count = GetTeamClientCount(g_aCurrentTeams[Team1]); - new Team2Count = GetTeamClientCount(g_aCurrentTeams[Team2]); - new ubCount = RoundFloat(FloatAbs(float(Team1Count - Team2Count))); - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Team1:%i Team2:%i Difference:%i", Team1Count, Team2Count, ubCount); - } - if (ubCount > g_iUnbalanceLimit) - { - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Teams are unbalanced"); - } - return true; - } - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Teams are not unbalanced"); - } - return false; -} - -stock bool:OkToBalance() -{ - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Checking if OK to balance."); - } - new bool:bResult = false; - if (g_bIsEnabled && !g_bRoundStart && !g_bRoundEnd && !g_bIsArenaMode && !g_bSuddenDeath) - { - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Passed IF statement"); - LogAction(0, -1, "[STB] Now checking admins"); - } - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientInGame(i) && !SM_IsValidAdmin(i, g_sAdminFlag)) - { - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Found at least 1 non-admin"); - LogAction(0, -1, "[STB] OK to balance"); - } - bResult = true; - break; - } - } - if (!bResult && g_bLogActivity2) - { - LogAction(0, -1, "[STB] All admins online"); - } - } - if (!bResult && g_bLogActivity2) - { - LogAction(0, -1, "[STB] Not OK to balance"); - } - return bResult; -} - -stock bool:IsSwitchablePlayer(iClient, iBiggerTeam) -{ - - /** - Run the client thru some standard checks - */ - if (!IsClientInGame(iClient) - || SM_IsValidAdmin(iClient, g_sAdminFlag) - || g_aPlayers[iClient][bFlagCarrier] - || GetClientTeam(iClient) != iBiggerTeam - || g_aPlayers[iClient][bSwitched]) - { - - /** - The supplied client can't be switched - */ - return false; - } - - /** - The supplied client can be switched - */ - return true; -} - -stock bool:HasUber(iClient) -{ - - /** - First things first, make sure the client is a medic - */ - if(TF2_GetPlayerClass(iClient) == TFClass_Medic) - { - - /** - We can only check the active weapon, so make sure the client is holding the uber gun - */ - decl String:sWeaponName[32]; - GetClientWeapon(iClient, sWeaponName, sizeof(sWeaponName)); - if(StrEqual(sWeaponName, "tf_weapon_medigun")) - { - - /** - They are, so lets check the uber level of the gun - */ - new iEntityIndex = GetEntDataEnt2(iClient, FindSendPropInfo("CTFPlayer", "m_hActiveWeapon")); - new Float:fChargeLevel = GetEntDataFloat(iEntityIndex, FindSendPropInfo("CWeaponMedigun", "m_flChargeLevel")); - if (fChargeLevel >= g_fUberLevel) - { - - /** - The client supplied has an uber above the supplied level, return true - */ - if (g_bLogActivity2) - { - LogAction(0, iClient, "[STB] Found a medic with a uber and skipped him."); - } - return true; - } - } - } - - /** - The client supplied does not have an uber above the supplied level, return false - */ - return false; -} - -stock bool:HasBuildingsBuilt(iClient) -{ - - /** - We have to start a loop to check the owner of all the valid entities - */ - new iMaxEntities = GetMaxEntities(); - for (new i = MaxClients + 1; i <= iMaxEntities; i++) - { - if (!IsValidEntity(i)) - { - - /** - Not valid, continue to next one - */ - continue; - } - - /** - Get the name of the current entity - */ - decl String:sNetClass[32]; - GetEntityNetClass(i, sNetClass, sizeof(sNetClass)); - - /** - See if its something that an engineer would build - */ - if (strcmp(sNetClass, "CObjectSentrygun") == 0 - || strcmp(sNetClass, "CObjectTeleporter") == 0 - || strcmp(sNetClass, "CObjectDispenser") == 0) - { - - /** - It is, so lets check the owner - */ - if (GetEntDataEnt2(i, g_iOwnerOffset) == iClient) - { - - /** - The client supplied is the owner, return true - */ - if (g_bLogActivity2) - { - LogAction(0, iClient, "[STB] Found an engineer with buildings and skipped him."); - } - return true; - } - } - } - - /** - The client supplied didn't have any buildings, return false - */ - return false; -} - -stock StartABalance() -{ - - /** - See if we are already started a balance - */ - if (g_hBalanceTimer != INVALID_HANDLE) - { - - /** - We have, check if we still need to - */ - if (!IsUnbalanced() || !OkToBalance()) - { - - /** - We don't, stop the balance - It's almost impossible to reach this code, but we do it just in case - */ - CloseHandle(g_hBalanceTimer); - g_hBalanceTimer = INVALID_HANDLE; - g_bBalanceInProgress = false; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Balance delay timer was not needed and was killed before the callback."); - } - return; - } - else - { - - /** - We still need to balance - Bug out and wait for the current one to finish - */ - return; - } - } - - /** - Report that teams are unbalanced - */ - PrintToChatAll("[SM] %T", "UnBalanced", LANG_SERVER); - - /** - Check to see if we are supposed to delay the balance - */ - if (g_iBalanceDelay == 0) - { - - /** - Start the balance now - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Balance is now in progress."); - } - g_bBalanceInProgress = true; - g_hBalanceTimer = INVALID_HANDLE; - - /** - Check if we are allowed to scan living players - */ - if (!g_bDeadOnly) - { - - /** - We are allowed to, so we start a timer - */ - StartALivingPlayerTimer(); - - /** - Also report that we are now scanning dead players as well - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Now scanning dead players."); - } - } - else - { - - /** - We are not allowed to, so report that we are only scanning dead players - */ - if (g_bLogActivity) - LogAction(0, -1, "[STB] Only scanning dead players."); - } - - /** - We started the balance, bug out - */ - return; - } - - /** - We are supposed to delay the balance, start a balance timer - */ - g_hBalanceTimer = CreateTimer(float(g_iBalanceDelay), Timer_BalanceTeams, _, TIMER_FLAG_NO_MAPCHANGE); - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Teams are unbalanced. Balance delay timer started."); - } -} - -stock StartALivingPlayerTimer() -{ - - /** - Start a timer to check living players - */ - if (g_hLivingPlayerCheckTimer != INVALID_HANDLE) - { - - /** - If we for some reason already have one started, stop it. - */ - CloseHandle(g_hLivingPlayerCheckTimer); - g_hLivingPlayerCheckTimer = INVALID_HANDLE; - } - - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Living player balance delay timer started."); - } - g_hLivingPlayerCheckTimer = CreateTimer(float(g_iLivingPlayerCheckDelay), Timer_LivingPlayerCheck, _, TIMER_FLAG_NO_MAPCHANGE); -} - -stock FindSwitchablePlayer() -{ - - /** - Start a loop to find a switchable player - */ - new iPlayer; - new iBiggerTeam = GetBiggerTeam(); - for (new i = 1; i <= MaxClients; i++) - { - - /** - Check the stock function to see if we are allows to even switch the player - */ - if (!IsSwitchablePlayer(i, iBiggerTeam)) - { - continue; - } - - /** - If the mod is TF2 and they have Priority Players set check if the client has buildings or an uber - */ - if (g_CurrentMod == GameType_TF && g_bPriorityPlayers) - { - if (HasUber(i) || HasBuildingsBuilt(i)) - { - continue; - } - } - - /** - So far we are able we switch this player - Now we check the buddy system - */ - if (g_bBuddyEnabled) - { - - /** - Buddy system is enabled, check to see if client has buddy - */ - if (SM_GetClientBuddy(i) != 0) - { - - /** - The client has a buddy, so we check to see if they are on same team - */ - if (GetClientTeam(i) == GetClientTeam(SM_GetClientBuddy(i))) - { - - /** - They are, so we continue to next client - */ - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] With a balance in progress a buddy on the right team was found and skipped."); - } - continue; - } - else - { - - /** - They are not on the same team, set this client - The buddy could be in spec, and that would make it not matter where he is, or the buddy is on the smaller team - */ - iPlayer = i; - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] With a balance in progress a buddy on the wrong team was found."); - } - break; - } - } - else - { - - /** - The client does not have a buddy, set this client - */ - iPlayer = i; - break; - } - } - else - { - - /** - Buddy system is not enabled, set this client - */ - iPlayer = i; - break; - } - } - - /** - Return the client we set, this could be 0, but very unlikely - */ - return iPlayer; -} - -stock BalancePlayer(iClient, iTeam) -{ - new Handle:hPack = CreateDataPack(); - WritePackCell(hPack, iClient); - WritePackCell(hPack, iTeam); - CreateTimer(0.1, Timer_BalancePlayer, hPack, TIMER_FLAG_NO_MAPCHANGE); -} - -stock CleanUp(iClient) -{ - g_aPlayers[iClient][bFlagCarrier] = false; - g_aPlayers[iClient][bSwitched] = false; - if (g_aPlayers[iClient][hForcedTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[iClient][hForcedTimer]); - g_aPlayers[iClient][hForcedTimer] = INVALID_HANDLE; - if (g_bLogActivity) - { - LogAction(0, iClient, "[STB] Forced player disconnected, killing timer."); - } - } - if (g_aPlayers[iClient][hBalanceTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[iClient][hBalanceTimer]); - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - if (g_bLogActivity) - { - LogAction(0, iClient, "[STB] Living player set to be balanced disconnected, killing timer."); - } - } -} - -stock GetSmallerTeam() -{ - - /** - Get the count of players on each team - */ - new iCountT1 = GetTeamClientCount(g_aCurrentTeams[Team1]); - new iCountT2 = GetTeamClientCount(g_aCurrentTeams[Team2]); - - /** - Return the smaller team - */ - if (iCountT1 < iCountT2) - { - return g_aCurrentTeams[Team1]; - } - else if (iCountT1 > iCountT2) - { - return g_aCurrentTeams[Team2]; - } - return 0; -} - -stock GetBiggerTeam() -{ - - /** - Get the count of players on each team - */ - new iCountT1 = GetTeamClientCount(g_aCurrentTeams[Team1]); - new iCountT2 = GetTeamClientCount(g_aCurrentTeams[Team2]); - - /** - Return the bigger team - */ - if (iCountT1 > iCountT2) - { - return g_aCurrentTeams[Team1]; - } - else if (iCountT1 < iCountT2) - { - return g_aCurrentTeams[Team2]; - } - return 0; -} - -stock SetGameCvars() -{ - if (g_bConVarControl && g_bIsEnabled) - { - if (stb_mp_autoteambalance != INVALID_HANDLE) - { - SetConVarInt(stb_mp_autoteambalance, 0); - } - if (stb_mp_teams_unbalance_limit != INVALID_HANDLE) - { - SetConVarInt(stb_mp_teams_unbalance_limit, g_iUnbalanceLimit); - } - } -} - -/* TIMER FUNCTIONS */ - -public Action:Timer_ChangeTeamBalanceDelay(Handle:timer, any:data) -{ - - /** - Finally start one if it's still unbalanced - */ - if (IsUnbalanced() && !g_bBalanceInProgress) - { - StartABalance(); - } -} - -public Action:Timer_BalanceTeams(Handle:timer, any:data) -{ - - /** - See if we still need to balance the teams - */ - if (!IsUnbalanced() || !OkToBalance()) - { - - /** - We don't, kill the balance - */ - g_bBalanceInProgress = false; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Balance delay timer was not needed and died."); - } - g_hBalanceTimer = INVALID_HANDLE; - return Plugin_Handled; - } - - /** - We still need to balance the teams - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Teams are still unbalanced. Balance is now in progress."); - } - g_bBalanceInProgress = true; - - - /** - Check if we are allowed to scan living players - */ - if (!g_bDeadOnly) - { - - /** - We are allowed to, so we start a timer - */ - StartALivingPlayerTimer(); - - /** - Also report that we are now scanning dead players as well - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Now scanning dead players."); - } - } - else - { - - /** - We are not allowed to, so report that we are only scanning dead players - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Only scanning dead players."); - } - } - - g_hBalanceTimer = INVALID_HANDLE; - return Plugin_Handled; -} - -public Action:Timer_LivingPlayerCheck(Handle:timer, any:data) -{ - - /** - Check to see if we still need to balance the teams - */ - if (!IsUnbalanced() || !OkToBalance()) - { - - /** - We don't, kill it and bug out - */ - g_bBalanceInProgress = false; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Living player balance delay timer was not needed and died."); - } - g_hLivingPlayerCheckTimer = INVALID_HANDLE; - return Plugin_Handled; - } - - /** - Call the stock function to find a player we can switch - */ - new iPlayer = FindSwitchablePlayer(); - - /** - Check to see if we found a player - */ - if (iPlayer == 0) - { - - /** - In the unlikely event that the stock function didn't return a player - Start a loop to find a random player - */ - new iBiggerTeam = GetBiggerTeam(); - do - { - iPlayer = GetRandomInt(1, MaxClients); - } while (!IsSwitchablePlayer(iPlayer, iBiggerTeam)); - - if (g_bLogActivity) - { - LogAction(0, iPlayer, "[STB] Found a random living player."); - } - } - else - { - if (g_bLogActivity) - { - LogAction(0, iPlayer, "[STB] Found a living player."); - } - } - - /** - Now that we have a player assigned them to the smaller team - */ - new iSmallerTeam = GetSmallerTeam(); - SM_SetForcedTeam(iPlayer, iSmallerTeam, true); - - /** - Let the player know we could be switching him soon - */ - PrintHintText(iPlayer, "%T", "PlayerMessage", LANG_SERVER, g_iLivingPlayerSwitchDelay); - if (g_bLogActivity) - { - LogAction(0, iPlayer, "[STB] Living player placed on a timer."); - } - - /** - Create a timer to switch the player - */ - g_aPlayers[iPlayer][hBalanceTimer] = CreateTimer(float(g_iLivingPlayerSwitchDelay), Timer_LivingPlayerBalance, iPlayer, TIMER_FLAG_NO_MAPCHANGE); - - /** - Reset the timer handle - */ - g_hLivingPlayerCheckTimer = INVALID_HANDLE; - - /** - We are done, bug out - */ - return Plugin_Handled; -} - -public Action:Timer_LivingPlayerBalance(Handle:timer, any:iClient) -{ - - /** - Check to make sure we still need to balance - */ - if (!IsUnbalanced() || !OkToBalance()) - { - - /** - We don't need to balance, bug out - */ - g_bBalanceInProgress = false; - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - SM_ClearForcedTeam(iClient); - return Plugin_Handled; - } - - /** - We still need to balance, lets make sure we can still balance this player - */ - if (!IsClientConnected(iClient) || g_aPlayers[iClient][bFlagCarrier]) - { - g_bBalanceInProgress = false; - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - SM_ClearForcedTeam(iClient); - if (g_bLogActivity) - { - if (g_aPlayers[iClient][bFlagCarrier]) - { - LogAction(0, iClient, "[STB] Living player became flag carrier, balance restarted."); - } - else - { - LogAction(0, iClient, "[STB] Living player timer was not needed and died."); - } - } - return Plugin_Handled; - } - - /** - Clear to balance this player, so do it - */ - BalancePlayer(iClient, SM_GetForcedTeam(iClient)); - if (g_bLogActivity) - { - LogAction(0, iClient, "[STB] Living player was switched."); - } - - /** - We are done, bug out - */ - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - return Plugin_Handled; -} - -public Action:Timer_BalancePlayer(Handle:timer, Handle:pack) -{ - - /** - Rest the datapack and load the variables - */ - ResetPack(pack); - new iClient = ReadPackCell(pack); - new iUnBalancedTeam = ReadPackCell(pack); - - /** - We are done with you now - */ - CloseHandle(pack); - - /** - Check the team and make sure its a valid team - */ - if(!SM_IsValidTeam(iUnBalancedTeam)) - { - if (g_bLogActivity) - { - LogAction(0, iClient, "[STB] Balance failed due to invalid team number %i", iUnBalancedTeam); - } - return Plugin_Handled; - } - - /** - Use our core function to change the clients team - */ - SM_MovePlayer(iClient, iUnBalancedTeam); - - return Plugin_Handled; -} - -public Action:Timer_RoundStart(Handle:timer, any:data) -{ - g_bRoundStart = false; - if (OkToBalance() && IsUnbalanced() && !g_bBalanceInProgress) - { - StartABalance(); - } - return Plugin_Handled; -} - -public Action:Timer_ForcedExpired(Handle:timer, any:iClient) -{ - SM_ClearForcedTeam(iClient); - g_aPlayers[iClient][bSwitched] = false; - g_aPlayers[iClient][hForcedTimer] = INVALID_HANDLE; - return Plugin_Handled; -} - -public Action:Timer_WelcomeAdvert(Handle:timer, any:iClient) -{ - if (IsClientConnected(iClient) && IsClientInGame(iClient)) - { - PrintToChat (iClient, "\x01\x04[STB]\x01 %T", "BuddyWelcomeMsg1", LANG_SERVER); - PrintToChat (iClient, "\x01\x04[STB]\x01 %T", "BuddyWelcomeMsg2", LANG_SERVER); - PrintToChat (iClient, "\x01\x04[STB]\x01 %T", "BuddyWelcomeMsg3", LANG_SERVER); - } - return Plugin_Handled; -} - -/* CONSOLE VARIABLE CHANGE EVENT */ - -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (convar == stb_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsEnabled = false; - PrintToChatAll("[SM] %T", "Disabled", LANG_SERVER); - LogAction(0, -1, "[SimpleTeamBalancer] Disabled"); - } - else - { - g_bIsEnabled = true; - SetGameCvars(); - PrintToChatAll("[SM] %T", "Enabled", LANG_SERVER); - LogAction(0, -1, "[SimpleTeamBalancer] Enabled"); - } - } - else if (convar == stb_logactivity) - { - if (StringToInt(newValue) == 0) - { - g_bLogActivity = false; - LogAction(0, -1, "[STB] Log Activity DISABLED."); - } - else - { - g_bLogActivity = true; - LogAction(0, -1, "[STB] Log Activity ENABLED."); - } - } - else if (convar == stb_logactivity2) - { - if (StringToInt(newValue) == 0) - { - g_bLogActivity2 = false; - LogAction(0, -1, "[STB] Detailed Log Activity DISABLED."); - } - else - { - g_bLogActivity2 = true; - LogAction(0, -1, "[STB] Detailed Log Activity ENABLED."); - } - } - else if (convar == stb_convarcontrol) - { - if (StringToInt(newValue) == 0) - { - g_bConVarControl = false; - } - else - { - g_bConVarControl = true; - SetGameCvars(); - } - } - else if (convar == stb_deadonly) - { - if (StringToInt(newValue) == 0) - { - g_bDeadOnly = false; - } - else - { - g_bDeadOnly = true; - } - } - else if (convar == stb_priorityenabled) - { - if (StringToInt(newValue) == 0) - { - g_bPriorityPlayers = false; - } - else - { - g_bPriorityPlayers = true; - } - } - else if (convar == stb_buddyenabled) - { - if (StringToInt(newValue) == 0) - { - g_bBuddyEnabled = false; - } - else - { - g_bBuddyEnabled = true; - } - } - else if (convar == stb_buddyrestriction) - { - if (StringToInt(newValue) == 0) - { - g_bBuddyRestriction = false; - } - else - { - g_bBuddyRestriction = true; - } - } - else if (convar == stb_unbalancelimit) - { - g_iUnbalanceLimit = StringToInt(newValue); - SetGameCvars(); - } - else if (convar == stb_balancedelay) - { - g_iBalanceDelay = StringToInt(newValue); - } - else if (convar == stb_roundstartdelay) - { - g_iRoundStartDelay = StringToInt(newValue); - } - else if (convar == stb_livingplayerswitchdelay) - { - g_iLivingPlayerSwitchDelay = StringToInt(newValue); - } - else if (convar == stb_livingplayercheckdelay) - { - g_iLivingPlayerCheckDelay = StringToInt(newValue); - } - else if (convar == stb_uberlevel) - { - g_fUberLevel = StringToFloat(newValue); - } - else if (convar == stb_switchbackforced) - { - g_iSwitchBackForced = StringToInt(newValue); - } - else if (convar == stb_adminflag) - { - SetConVarString(stb_adminflag, newValue); - } - else if (convar == stb_mp_autoteambalance) - { - SetGameCvars(); - } - else if (convar == stb_mp_teams_unbalance_limit) - { - SetGameCvars(); - } -} - -/* MENU CODE */ - -stock Handle:BuildPlayerMenu() -{ - new Handle:menu = CreateMenu(Menu_SelectPlayer); - AddTargetsToMenu(menu, 0, true, false); - SetMenuTitle(menu, "Select A Player:"); - SetMenuExitButton(menu, true); - return menu; -} - -public Menu_SelectPlayer(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[24]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - new buddy = GetClientOfUserId(StringToInt(sSelection)); - if (param1 == buddy) { - PrintHintText(param1, "%T", "SelectSelf", LANG_SERVER); - } else if (!IsClientInGame(buddy)) { - PrintHintText(param1, "%T", "BuddyGone", LANG_SERVER); - } else { - decl String:cName[128]; - decl String:bName[128]; - GetClientName(param1, cName, sizeof(cName)); - GetClientName(buddy, bName, sizeof(bName)); - if (!SM_IsBuddyLocked(buddy)) { - SM_AssignBuddy(param1, buddy); - PrintHintText(param1, "%T", "BuddyMsg", LANG_SERVER, bName); - PrintHintText(buddy, "%T", "BuddyMsg", LANG_SERVER, cName); - } else - PrintHintText(param1, "%T", "PlayerLockedBuddyMsg", LANG_SERVER, bName); - } - } else if (action == MenuAction_End) { - CloseHandle(menu); - } -} \ No newline at end of file diff --git a/Simple Chat Colors/addons/sourcemod/scripting/simple-teammanager.sp b/Simple Chat Colors/addons/sourcemod/scripting/simple-teammanager.sp deleted file mode 100644 index 008f443..0000000 --- a/Simple Chat Colors/addons/sourcemod/scripting/simple-teammanager.sp +++ /dev/null @@ -1,1351 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Team Manager -Description: - Manges players and their team - Admin menu integration - Allows admins/donators to swap their teams (clears force)* - Allows admins to move players to a team (forced\unforced)* - Allows admins to scramble the teams* - *Works with Simple Team Balancer (if installed) -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include - -#define PLUGIN_VERSION "2.1.$Rev$" -#define VOTE_YES "##YES##" -#define VOTE_NO "##NO##" - -enum PlayerData -{ - iNewTeam, - bool:bQueue -}; - -new Handle:stm_enabled = INVALID_HANDLE; -new Handle:stm_logactivity = INVALID_HANDLE; -new Handle:stm_adminflag_swapteam = INVALID_HANDLE; -new Handle:stm_adminflag_moveplayer = INVALID_HANDLE; -new Handle:stm_adminflag_scramble = INVALID_HANDLE; -new Handle:stm_scrambledelay = INVALID_HANDLE; -new Handle:stm_voteenabled = INVALID_HANDLE; -new Handle:stm_votewin = INVALID_HANDLE; -new Handle:stm_votedelay = INVALID_HANDLE; -new Handle:stm_mp_bonusroundtime = INVALID_HANDLE; -new Handle:g_hAdminMenu = INVALID_HANDLE; -new Handle:g_hTimerPrepScramble = INVALID_HANDLE; -new Handle:g_hTimerClearScrambleForce = INVALID_HANDLE; - -new g_aPlayers[MAXPLAYERS + 1][PlayerData]; - -new bool:g_bIsEnabled = true; -new bool:g_bVoteEnabled = true; -new bool:g_bLogActivity = true; -new bool:g_bScrambleRoundEnd = false; -new g_iVoteDelay, g_iLastVoteTime, g_iTimeLeft; -new Float:g_fScrambleDelay, Float:g_fVoteWin; - -public Plugin:myinfo = -{ - name = "Simple Team Manager", - author = "Simple Plugins", - description = "Manages players and thier team.", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -}; - -public OnPluginStart() -{ - - /** - Need to create all of our console variables. - */ - CreateConVar("stm_version", PLUGIN_VERSION, "Simple Team Manager Version",FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - stm_enabled = CreateConVar("stm_enabled", "1", "Enable or Disable Simple Team Manager", _, true, 0.0, true, 1.0); - stm_logactivity = CreateConVar("stm_logactivity", "0", "Enable or Disable the disaplying of events in the log", _, true, 0.0, true, 1.0); - stm_adminflag_swapteam = CreateConVar("stm_adminflag_swapteam", "a", "Admin flag to use for the swapteam command. Must be a in char format."); - stm_adminflag_moveplayer = CreateConVar("stm_adminflag_moveplayer", "c", "Admin flag to use for the moveplayer command. Must be a in char format."); - stm_adminflag_scramble = CreateConVar("stm_adminflag_scramble", "c", "Admin flag to use for the scrambleteam command. Must be a in char format."); - stm_scrambledelay = CreateConVar("stm_scrambledelay", "15", "Delay to scramble teams"); - stm_voteenabled = CreateConVar("stm_voteenabled", "1", "Enable or Disable voting to scramble the teams", _, true, 0.0, true, 1.0); - stm_votewin = CreateConVar("stm_votewin", "0.45", "Win percentage vote must win by", _, true, 0.0, true, 1.0); - stm_votedelay = CreateConVar("stm_votedelay", "600", "Delay before another vote can be cast"); - stm_mp_bonusroundtime = FindConVar("mp_bonusroundtime"); - - - /** - Need deal with changes to the console variables after the plugin is loaded. - We could not do this and just call the actual console variable each time we need it, but it's not efficent. - */ - HookConVarChange(stm_enabled, ConVarSettingsChanged); - HookConVarChange(stm_logactivity, ConVarSettingsChanged); - HookConVarChange(stm_scrambledelay, ConVarSettingsChanged); - HookConVarChange(stm_voteenabled, ConVarSettingsChanged); - HookConVarChange(stm_votewin, ConVarSettingsChanged); - HookConVarChange(stm_votedelay, ConVarSettingsChanged); - - /** - Need to register the commands we are going to create and use. - */ - RegConsoleCmd("sm_swapteam", Command_SwapTeam, "sm_swapteam <[0]instant/[1]queued>: Swaps your team to the other team"); - RegConsoleCmd("sm_moveplayer", Command_MovePlayer, "sm_moveplayer <[0]instant/[1]ondeath> <[0]unforced/[1]forced>: Moves a player to the specified team"); - RegConsoleCmd("sm_scrambleteams", Command_ScrambleTeams, "sm_scrambleteams: <[0]now/[1]roundend> <[0]dontrestart/[1]restartround> Scrambles the current teams"); - RegConsoleCmd("sm_votescramble", Command_VoteScramble, "sm_votescramble: Starts a vote to scramble the teams"); - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook the game events - */ - LogAction(0, -1, "[STM] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_death", HookPlayerDeath, EventHookMode_Post); - HookEvent("player_team", HookPlayerChangeTeam, EventHookMode_Post); - switch (g_CurrentMod) - { - case GameType_TF: - { - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - } - case GameType_DOD: - { - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_Post); - } - default: - { - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - } - } - - /** - Now we have to deal with the admin menu. If the admin library is loaded call the function to add our items. - */ - new Handle:gTopMenu; - if (LibraryExists("adminmenu") && ((gTopMenu = GetAdminTopMenu()) != INVALID_HANDLE)) - { - OnAdminMenuReady(gTopMenu); - } - - /** - Load translations and .cfg file - */ - LoadTranslations ("simpleteammanager.phrases"); - AutoExecConfig(true, "plugin.simpleteammanager"); - LogAction(0, -1, "[STM] Simple Team Manager is loaded."); -} - -public OnAllPluginsLoaded() -{ - //something -} - -public OnLibraryRemoved(const String:name[]) -{ - if (StrEqual(name, "adminmenu")) - { - - /** - Looks like the admin menu was removed. Set the global. - */ - g_hAdminMenu = INVALID_HANDLE; - } - else if (StrEqual(name, "simpleplugins")) - { - SetFailState("Required plugin Simple SourceMod Plugins Core was removed."); - } -} - -public OnConfigsExecuted() -{ - - /** - Once we loaded up all the console variables from the config file, lets now set all the global variables we will use. - */ - g_bIsEnabled = GetConVarBool(stm_enabled); - g_bLogActivity = GetConVarBool(stm_logactivity); - g_fScrambleDelay = GetConVarFloat(stm_scrambledelay); - g_iVoteDelay = GetConVarInt(stm_votedelay); - g_fVoteWin = GetConVarFloat(stm_votewin); - g_iLastVoteTime = RoundFloat(GetEngineTime()); - g_bScrambleRoundEnd = false; - g_hTimerClearScrambleForce = INVALID_HANDLE; - - /** - Report enabled - */ - if (g_bIsEnabled) - { - LogAction(0, -1, "[STM] Simple Team Manager is ENABLED."); - } - else - { - LogAction(0, -1, "[STM] Simple Team Manager is DISABLED."); - } - - if (g_bLogActivity) - { - LogAction(0, -1, "[STM] Log Activity ENABLED."); - } - else - { - LogAction(0, -1, "[STM] Log Activity DISABLED."); - } -} - -/* COMMANDS */ - -public Action:Command_SwapTeam(client, args) -{ - - /** - Make sure we are enabled, if not bug out. - */ - if (!g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - If this was ran from the console bug out. - */ - if (client == 0) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "PlayerLevelCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Make sure the client is authorized to run this command. - */ - decl String:sFlags[5]; - GetConVarString(stm_adminflag_swapteam, sFlags, sizeof(sFlags)); - if (!SM_IsValidAdmin(client, sFlags)) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Lets make sure the client is one a team we can swap. - If he is we set the global array to the opposite team. - */ - new iTeam = GetClientTeam(client); - if (iTeam == g_aCurrentTeams[Team1]) - { - g_aPlayers[client][iNewTeam] = g_aCurrentTeams[Team2]; - } - else if (iTeam == g_aCurrentTeams[Team2]) - { - g_aPlayers[client][iNewTeam] = g_aCurrentTeams[Team1]; - } - else - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "InValidTeam", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check to see if we have command arguments. - */ - if (GetCmdArgs()) - { - - /** - We do, so lets get it and see if the client wants to be switched instantly or queued for death. - */ - decl String:sArg[5]; - GetCmdArg(1, sArg, sizeof(sArg)); - new iWantsQue = StringToInt(sArg); - if (iWantsQue && !g_aPlayers[client][bQueue]) - { - - /** - He wants the que and isn't already in it, set the global array. - */ - g_aPlayers[client][bQueue] = true; - ReplyToCommand(client, "\x01\x04[STM]\x01 %T", "PlayerQueue", LANG_SERVER); - } - else if (!iWantsQue) - { - - /** - He wants to be switched right now, lets call the stock function. - */ - SM_MovePlayer(client, g_aPlayers[client][iNewTeam]); - } - } - else - { - - /** - There are no command arguments so we build and display the swap menu. - */ - DisplaySwapModeMenu(client, client); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_MovePlayer(client, args) -{ - - /** - Make sure we are enabled, if not bug out. - */ - if (!g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - Make sure the client is authorized to run this command. - */ - decl String:sFlags[5]; - GetConVarString(stm_adminflag_moveplayer, sFlags, sizeof(sFlags)); - if (!SM_IsValidAdmin(client, sFlags)) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check to see if we have command arguments. - */ - new iCmdArgs = GetCmdArgs(); - if (iCmdArgs == 0) - { - - /** - We don't. Build the player menu, display it, and bug out. - */ - DisplayPlayerMenu(client); - return Plugin_Handled; - } - - /** - Check the first argument - If should be a players name or userid. - */ - decl String:sPlayer[64]; - GetCmdArg(1, sPlayer, sizeof(sPlayer)); - new iPlayerIndex = FindTarget(client, sPlayer, true, true); - if (iPlayerIndex == -1 || !IsClientInGame(iPlayerIndex)) - { - - /** - We don't know who this is. Build the player menu, display it, and bug out. - */ - DisplayPlayerMenu(client); - return Plugin_Handled; - } - - /** - We have figured out the first argument, lets check the second. - If should be the team the client wants to put the player on. - */ - if (iCmdArgs >= 2) - { - - /** - We have a command argument at least, lets see if we can identify the team. - */ - decl String:sTeam[24]; - GetCmdArg(2, sTeam, sizeof(sTeam)); - - new iTeam = StringToInt(sTeam); - if (SM_IsValidTeam(iTeam)) - { - - /** - It's a vaild team so lets set the global array to the new team. - */ - g_aPlayers[iPlayerIndex][iNewTeam] = iTeam; - } - else - { - - /** - It's not a vaild team so set the menu to display to the team menu. - */ - DisplayTeamMenu(client, iPlayerIndex); - return Plugin_Handled; - } - } - else - { - /** - We were not given a team, display the team menu. - */ - DisplayTeamMenu(client, iPlayerIndex); - return Plugin_Handled; - } - - /** - Check to see if we were given any more command arguments and found a team. - */ - if (iCmdArgs < 3) - { - - /** - No more command arguments and found a team. - Now lets check to see if the player is a spectator. If he is there is no reason to ask if it's instant or on death... he can't die. - */ - if (!IsClientObserver(iPlayerIndex)) - { - - /** - Not a spectator so display the swapmode menu. - */ - DisplaySwapModeMenu(client, iPlayerIndex); - } - else - { - - /** - The player is a spectator. - We make sure the player is not set to switch on death, since a spec can't die. - */ - g_aPlayers[iPlayerIndex][bQueue] = false; - } - } - - /** - We have figured out the second argument, lets check the third. - If should be the how the client wants to move the player: instant/on death. - */ - if (iCmdArgs >= 3) - { - - /** - The client gave us a command argument, lets check it. - */ - decl String:sSwapMode[5]; - GetCmdArg(3, sSwapMode, sizeof(sSwapMode)); - new iWantsQue = StringToInt(sSwapMode); - if (iWantsQue) - { - - /** - The client wants to que the player, set the global array. - */ - g_aPlayers[iPlayerIndex][bQueue] = true; - } - else - { - - /** - The client doesn't want to que the player, set the global array. - */ - g_aPlayers[iPlayerIndex][bQueue] = false; - } - } - else - { - /** - No swapmode argument, display the menu - */ - DisplaySwapModeMenu(client, iPlayerIndex); - } - - if (iCmdArgs >= 4) - { - - /** - Since we are compiling for Simple Team Balancer, and given a 4th argument, lets check it. - If should be the if the client wants to force the player to that team. - */ - decl String:sPlayerForced[5]; - GetCmdArg(4, sPlayerForced, sizeof(sPlayerForced)); - new iForceHim = StringToInt(sPlayerForced); - if (iForceHim) - { - - /** - The client wants to force the player - */ - SM_SetForcedTeam(iPlayerIndex, g_aPlayers[iPlayerIndex][iNewTeam]); - } - else - { - - /** - The client doesn't want to force the player - */ - SM_ClearForcedTeam(iPlayerIndex); - } - } - else - { - - } - - /** - We found and processed all the arguments. - */ - if (!IsPlayerAlive(iPlayerIndex)) - { - - /** - The player is not alive or died during this process so we just move him. - */ - SM_MovePlayer(iPlayerIndex, g_aPlayers[iPlayerIndex][iNewTeam]); - } - else - { - if (!g_aPlayers[iPlayerIndex][bQueue]) - { - - /** - The player is alive and is not set to be queued so we just move him. - */ - SM_MovePlayer(iPlayerIndex, g_aPlayers[iPlayerIndex][iNewTeam]); - } - } - - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_ScrambleTeams(client, args) -{ - - /** - Make sure we are enabled, if not bug out. - */ - if (!g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - Make sure the client is authorized to run this command. - */ - decl String:sFlags[5]; - GetConVarString(stm_adminflag_scramble, sFlags, sizeof(sFlags)); - if (!SM_IsValidAdmin(client, sFlags)) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check if a scramble timer was already called, if so close it down. - */ - if (g_hTimerPrepScramble != INVALID_HANDLE) - { - CloseHandle(g_hTimerPrepScramble); - g_hTimerPrepScramble = INVALID_HANDLE; - } - - /** - Check if we have any command arguments. - If we don't we display the scramble menu and bug out. - */ - new iCmdArgs = GetCmdArgs(); - if (iCmdArgs == 0) - { - DisplayScrambleMenu(client); - return Plugin_Handled; - } - - /** - We have a command argument. - It should be whether or not to scramble at round end. - */ - decl String:sRoundEnd[5]; - GetCmdArg(1, sRoundEnd, sizeof(sRoundEnd)); - if (StringToInt(sRoundEnd)) - { - /** - The client wants to scramble at round end so we set the global bool. - */ - g_bScrambleRoundEnd = true; - } - else - { - g_bScrambleRoundEnd = false; - } - - /** - Check for another command argument. - It should be whether or not to restart the round. - */ - decl String:sRestartRound[5]; - new bool:bRestartRound = false; - GetCmdArg(1, sRestartRound, sizeof(sRestartRound)); - if (StringToInt(sRestartRound)) - { - bRestartRound = true; - } - - /** - Now we start the scramble timer. - */ - StartScrambleTimer(_, bRestartRound); - - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_VoteScramble(client, args) -{ - - /** - Make sure we are enabled, if not bug out. - */ - if (!g_bVoteEnabled || !g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - Make sure there is a vote in progress, if so bug out. - */ - if (IsVoteInProgress()) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "VoteInProgress", LANG_SERVER); - return Plugin_Handled; - } - - /** - Make sure enough time has passed since the last vote. - */ - new iVoteTime = RoundFloat(GetEngineTime()); - if (iVoteTime - g_iLastVoteTime <= g_iVoteDelay) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "ScrambleTime", LANG_SERVER); - return Plugin_Handled; - } - - /** - Enough time has passed so reset the global vote time to now. - */ - g_iLastVoteTime = iVoteTime; - - /** - Build the vote menu and send it to everyone. - */ - new Handle:hMenu = CreateMenu(Menu_VoteScramble); - SetMenuTitle(hMenu, "Scramble Teams?"); - AddMenuItem(hMenu, VOTE_YES, "Yes"); - AddMenuItem(hMenu, VOTE_NO, "No"); - SetMenuExitButton(hMenu, false); - VoteMenuToAll(hMenu, 20); - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -/* HOOKED EVENTS */ - -public HookPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Find out who died. - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - - /** - Find out how the client died. - */ - new String:sWeapon[64]; - GetEventString(event, "weapon", sWeapon, sizeof(sWeapon)); - if (StrEqual(sWeapon, "world", false)) - { - - /** - He died because he changed teams so cleanup and bug out. - */ - s_CleanUp(iClient); - return; - } - - /** - Find out if this player was queued to change teams. - */ - if (g_aPlayers[iClient][bQueue]) - { - /** - Looks like he was, so call the stock function to move him. - */ - SM_MovePlayer(iClient, g_aPlayers[iClient][iNewTeam]); - } -} - -public HookPlayerChangeTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Find out who changed teams. - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - - /** - If he was queued to switch teams we cleanup the variables. The client did it themself. - */ - if (g_aPlayers[iClient][bQueue]) - { - s_CleanUp(iClient); - } -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get the amount of time left in the map. - */ - new iTimeLeft; - GetMapTimeLeft(iTimeLeft); - - /** - Check to see if we are supposed to scramble at the end of the round and that there is enough time left in the map. - */ - if (g_bScrambleRoundEnd && iTimeLeft >= 60) - { - - /** - Check to see if there is a scramble timer in action and if so close it down. - */ - if (g_hTimerPrepScramble != INVALID_HANDLE) - { - CloseHandle(g_hTimerPrepScramble); - g_hTimerPrepScramble = INVALID_HANDLE; - } - - /** - Determine the round end chat time and run the scramble 1 second before it ends. - */ - new Float:fDelay = GetConVarFloat(stm_mp_bonusroundtime); - fDelay -= 1.0; - StartScrambleTimer(fDelay); - } -} - -public OnClientPostAdminCheck(client) -{ - - /** - Determine if the client has the flag to use the swapteam command. - */ - decl String:sFlags[5]; - GetConVarString(stm_adminflag_swapteam, sFlags, sizeof(sFlags)); - if (SM_IsValidAdmin(client, sFlags)) - { - /** - The client does so lets create a timer to run an advertise to tell him about it. - */ - CreateTimer (60.0, Timer_WelcomeAdvert, client); - } -} - -public OnClientDisconnect(client) -{ - - /** - Cleanup the clients variables. - */ - s_CleanUp(client); -} - -public SM_OnPlayerMoved(Handle:plugin, client, team) -{ - - /** - Make sure we called the move function - */ - if (plugin != GetMyHandle()) - { - if (g_bLogActivity) - { - LogAction(0, client, "[STM] Callback was not started with current plugin, bugging out."); - } - return; - } - - decl String:sPlayerName[64]; - GetClientName(client, sPlayerName, sizeof(sPlayerName)); - - PrintToChat(client, "\x01\x04[SM]\x01 %T", "PlayerSwitched", LANG_SERVER); - - s_CleanUp(client); -} - -/* TIMER FUNCTIONS */ - -public Action:Timer_PrepTeamScramble(Handle:timer, any:data) -{ - new bool:bRestartRound = data; - /** - Call the scramble the teams stock function. - */ - PrepTeamScramble(bRestartRound); - - /** - Reset the timer handle so we know the timer is done. - */ - g_hTimerPrepScramble = INVALID_HANDLE; - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Timer_ScrambleTheTeams(Handle:timer, any:data) -{ - new iPlayers[MAXPLAYERS + 1]; - new iCount, i, bool:bTeam, bool:bRestartRound = data; - - /** - Get all the client index numbers of valid players - */ - for(i = 1; i <= MaxClients; i++) - { - if(IsClientInGame(i)) // && !IsFakeClient(i)) - { - iPlayers[iCount++] = i; - } - } - - /** - Randomly sort the players - */ - SortIntegers(iPlayers, iCount, Sort_Random); - - /** - Loop through all the players and assign each one to a team, alternating each time - */ - for(i = 0; i < iCount; i++) - { - if (!bRestartRound) - { - /** - We didn't want to restart the round, so we move them to spec 1 at a time. - */ - SM_MovePlayer(iPlayers[i], g_aCurrentTeams[Spectator]); - } - SM_MovePlayer(iPlayers[i], bTeam ? g_aCurrentTeams[Team2] : g_aCurrentTeams[Team1]); - SM_SetForcedTeam(iPlayers[i], bTeam ? g_aCurrentTeams[Team2] : g_aCurrentTeams[Team1], true); - bTeam = !bTeam; - } - - /** - Reset this variable since we completed a scramble - */ - g_bScrambleRoundEnd = false; - - if (g_hTimerClearScrambleForce != INVALID_HANDLE) - { - CloseHandle(g_hTimerClearScrambleForce); - g_hTimerClearScrambleForce = INVALID_HANDLE; - } - - g_hTimerClearScrambleForce = CreateTimer(300.0, Timer_ClearScrambleForce, _, TIMER_FLAG_NO_MAPCHANGE); - - ServerCommand("mp_timelimit %i", g_iTimeLeft / 60); - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Timer_ClearScrambleForce(Handle:timer, any:data) -{ - - for(new i = 1; i <= MaxClients; i++) - { - if(IsClientInGame(i)) // && !IsFakeClient(i)) - { - SM_ClearForcedTeam(i); - PrintToChat(i, "\x01\x04[SM]\x01 Your forced team status has been cleared"); - } - } - - g_hTimerClearScrambleForce = INVALID_HANDLE; - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Timer_WelcomeAdvert(Handle:timer, any:client) -{ - - /** - Lets make sure the client is connected and actually in the game. - */ - if (IsClientConnected(client) && IsClientInGame(client)) - { - - /** - We are good to go so lets tell him about the swapteam command. - */ - PrintToChat (client, "\x01\x04[STM]\x01 %T", "SwapTeamMsg", LANG_SERVER); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -/* STOCK FUNCTIONS */ - -stock s_CleanUp(iClient) -{ - - /** - Reset all the client variables - */ - g_aPlayers[iClient][bQueue] = false; - g_aPlayers[iClient][iNewTeam] = 0; -} - -stock StartScrambleTimer(Float:fdelay = 0.0, bool:bRestartRound = false) -{ - if (fdelay == 0.0) - { - fdelay = g_fScrambleDelay; - } - if (g_hTimerPrepScramble != INVALID_HANDLE) - { - CloseHandle(g_hTimerPrepScramble); - g_hTimerPrepScramble = INVALID_HANDLE; - } - PrintCenterTextAll("%T", "Scramble", LANG_SERVER); - g_hTimerPrepScramble = CreateTimer(fdelay, Timer_PrepTeamScramble, bRestartRound, TIMER_FLAG_NO_MAPCHANGE); -} - -stock PrepTeamScramble(bool:bRestartRound = false) -{ - new iPlayers[MAXPLAYERS + 1]; - new iCount; - - GetMapTimeLeft(g_iTimeLeft); - - if (bRestartRound) - { - - for(new i = 1; i <= MaxClients; i++) - { - if(IsClientInGame(i)) - // && !IsFakeClient(i)) - { - iPlayers[iCount++] = i; - SM_ClearForcedTeam(i); - SM_ClearBuddy(i); - SM_MovePlayer(i, g_aCurrentTeams[Spectator]); - } - } - } - else - { - //Can't move them all to spec at the same time - for(new i = 1; i <= MaxClients; i++) - { - if(IsClientInGame(i)) - // && !IsFakeClient(i)) - { - iPlayers[iCount++] = i; - SM_ClearForcedTeam(i); - SM_ClearBuddy(i); - //SM_MovePlayer(i, g_aCurrentTeams[Spectator]); - } - } - } - CreateTimer(4.0, Timer_ScrambleTheTeams, bRestartRound, TIMER_FLAG_NO_MAPCHANGE); -} - -/* CONSOLE VARIABLE CHANGE EVENT */ - -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (convar == stm_enabled) { - if (StringToInt(newValue) == 0) { - g_bIsEnabled = false; - LogAction(0, -1, "[STM] Simple Team Manager is loaded and disabled."); - } else { - g_bIsEnabled = true; - LogAction(0, -1, "[STM] Simple Team Manager is loaded and enabled."); - } - } - else if (convar == stm_logactivity) { - if (StringToInt(newValue) == 0) { - g_bLogActivity = false; - LogAction(0, -1, "[STM] Log Activity DISABLED."); - } else { - g_bLogActivity = true; - LogAction(0, -1, "[STM] Log Activity ENABLED."); - } - } - else if (convar == stm_scrambledelay) - g_fScrambleDelay = StringToFloat(newValue); - else if (convar == stm_votewin) - g_fVoteWin = StringToFloat(newValue); - else if (convar == stm_votedelay) - g_iVoteDelay = StringToInt(newValue); - else if (convar == stm_voteenabled) { - if (StringToInt(newValue) == 0) - g_bVoteEnabled = false; - else - g_bVoteEnabled = true; - } -} - -/* MENU CODE */ - -public OnAdminMenuReady(Handle:topmenu) -{ - if (topmenu == g_hAdminMenu) - return; - g_hAdminMenu = topmenu; - new TopMenuObject:player_commands = FindTopMenuCategory(g_hAdminMenu, ADMINMENU_PLAYERCOMMANDS); - new TopMenuObject:server_commands = FindTopMenuCategory(g_hAdminMenu, ADMINMENU_SERVERCOMMANDS); - if (player_commands == INVALID_TOPMENUOBJECT) - return; - - AddToTopMenu(g_hAdminMenu, - "moveplayer", - TopMenuObject_Item, - AdminMenu_MovePlayer, - player_commands, - "moveplayer", - ADMFLAG_BAN); - - AddToTopMenu(g_hAdminMenu, - "scrambleteams", - TopMenuObject_Item, - AdminMenu_Scrambleteams, - server_commands, - "scrambleteams", - ADMFLAG_BAN); -} - -public AdminMenu_MovePlayer(Handle:topmenu, TopMenuAction:action, TopMenuObject:object_id, param, String:buffer[], maxlength) -{ - if (action == TopMenuAction_DisplayOption) - Format(buffer, maxlength, "Move Player"); - else if (action == TopMenuAction_SelectOption){ - DisplayPlayerMenu(param); - } -} - -public AdminMenu_Scrambleteams(Handle:topmenu, TopMenuAction:action, TopMenuObject:object_id, param, String:buffer[], maxlength) -{ - if (action == TopMenuAction_DisplayOption) - Format(buffer, maxlength, "Scramble Teams"); - else if (action == TopMenuAction_SelectOption) { - DisplayScrambleMenu(param); - } -} - -public Menu_SelectPlayer(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - DisplayTeamMenu(param1, GetClientOfUserId(StringToInt(sSelection))); - } else if (action == MenuAction_Cancel) { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -public Menu_SelectTeam(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new iTeam; - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - decl String:sIndex[64]; - if (SplitString(sSelection, "A", sIndex, sizeof(sIndex)) != -1) - iTeam = g_aCurrentTeams[Team1]; - else if (SplitString(sSelection, "B", sIndex, sizeof(sIndex)) != -1) - iTeam = g_aCurrentTeams[Team2]; - else { - SplitString(sSelection, "C", sIndex, sizeof(sIndex)); - iTeam = g_aCurrentTeams[Spectator]; - } - new iTarget = StringToInt(sIndex); - g_aPlayers[iTarget][iNewTeam] = iTeam; - DisplaySwapModeMenu(param1, iTarget); - } else if (action == MenuAction_Cancel) { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -public Menu_SwapMode(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - decl String:sIndex[64]; - - if (SplitString(sSelection, "A", sIndex, sizeof(sIndex)) == -1) - { - SplitString(sSelection, "B", sIndex, sizeof(sIndex)); - } - - new iTarget = StringToInt(sIndex); - - if (StrContains(sSelection, "A", true) != -1) - { - g_aPlayers[iTarget][bQueue] = false; - } - else if (StrContains(sSelection, "B", true) != -1) - { - g_aPlayers[iTarget][bQueue] = true; - } - - if (param1 == iTarget && !g_aPlayers[iTarget][bQueue]) - { - SM_MovePlayer(iTarget, g_aPlayers[iTarget][iNewTeam]); - } - else - { - DisplayForceModeMenu(param1, iTarget); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - { - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } - return; -} - -public Menu_ForceMode(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - decl String:sIndex[64]; - if (SplitString(sSelection, "A", sIndex, sizeof(sIndex)) == -1) - { - SplitString(sSelection, "B", sIndex, sizeof(sIndex)); - } - new iTarget = StringToInt(sIndex); - if (StrContains(sSelection, "A", true) != -1) - { - SM_ClearForcedTeam(iTarget); - } - else if (StrContains(sSelection, "B", true) != -1) - { - SM_SetForcedTeam(iTarget, g_aPlayers[iTarget][iNewTeam], true); - } - if (!g_aPlayers[iTarget][bQueue]) - { - SM_MovePlayer(iTarget, g_aPlayers[iTarget][iNewTeam]); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - { - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } - return; -} - -public Menu_VoteScramble(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_VoteEnd) { - new winning_votes, total_votes; - GetMenuVoteInfo(param2, winning_votes, total_votes); - if (param1 == 0) { - if (float(total_votes) / float(winning_votes) < g_fVoteWin) { - PrintToChatAll("\x01\x04[SM]\x01 %T", "VoteScramble2", LANG_SERVER, winning_votes, total_votes); - return; - } - PrintCenterTextAll("[SM] %T", "Scramble", LANG_SERVER); - PrintToChatAll("\x01\x04[SM]\x01 %T", "VoteScramble1", LANG_SERVER, winning_votes, total_votes); - StartScrambleTimer(); - } - if (param1 == 1) { - PrintToChatAll("\x01\x04[SM]\x01 %T", "VoteScramble2", LANG_SERVER, winning_votes, total_votes); - } - } - if (action == MenuAction_End) - CloseHandle(menu); -} - -public Menu_ScrambleTeams(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "NOW", false)) - g_bScrambleRoundEnd = false; - else - g_bScrambleRoundEnd = true; - DisplayScrambleMenu2(param1); - } else if (action == MenuAction_Cancel) { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -public Menu_ScrambleTeams2(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[64]; - new bool:bRestartRound; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "NO", false)) - { - bRestartRound = false; - } - else - { - bRestartRound = true; - } - StartScrambleTimer(_, bRestartRound); - } else if (action == MenuAction_Cancel) { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -stock DisplayScrambleMenu(iClient) -{ - new Handle:hMenu = CreateMenu(Menu_ScrambleTeams); - SetMenuTitle(hMenu, "Select When to Scramble:"); - AddMenuItem(hMenu, "NOW", "Instantly"); - AddMenuItem(hMenu, "END", "At Round End"); - SetMenuExitBackButton(hMenu, false); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} - -stock DisplayScrambleMenu2(iClient) -{ - new Handle:hMenu = CreateMenu(Menu_ScrambleTeams2); - SetMenuTitle(hMenu, "Select When to Scramble:"); - AddMenuItem(hMenu, "NO", "No Round Restart"); - AddMenuItem(hMenu, "YES", "Restart Round"); - SetMenuExitBackButton(hMenu, false); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} - -stock DisplaySwapModeMenu(iClient, iTarget) -{ - new Handle:hMenu = CreateMenu(Menu_SwapMode); - decl String:optionA[64]; - decl String:optionB[64]; - Format(optionA, sizeof(optionA), "%iA", iTarget); - Format(optionB, sizeof(optionB), "%iB", iTarget); - SetMenuTitle(hMenu, "Select When to Swap:"); - AddMenuItem(hMenu, optionA, "Instantly (Kills)"); - if (!IsClientObserver(iTarget)) - AddMenuItem(hMenu, optionB, "Queue on next death"); - SetMenuExitBackButton(hMenu, false); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} - -stock DisplayForceModeMenu(iClient, iTarget) -{ - new Handle:hMenu = CreateMenu(Menu_ForceMode); - decl String:optionA[64]; - decl String:optionB[64]; - Format(optionA, sizeof(optionA), "%iA", iTarget); - Format(optionB, sizeof(optionB), "%iB", iTarget); - SetMenuTitle(hMenu, "Select Force Mode:"); - AddMenuItem(hMenu, optionA, "UnForced"); - AddMenuItem(hMenu, optionB, "Forced"); - SetMenuExitBackButton(hMenu, false); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} - -stock DisplayTeamMenu(iClient, iTarget) -{ - new Handle:hMenu = CreateMenu(Menu_SelectTeam); - decl String:optionA[64]; - decl String:optionB[64]; - decl String:optionC[64]; - Format(optionA, sizeof(optionA), "%iA", iTarget); - Format(optionB, sizeof(optionB), "%iB", iTarget); - Format(optionC, sizeof(optionC), "%iC", iTarget); - SetMenuTitle(hMenu, "Select Team:"); - AddMenuItem(hMenu, optionA, "Team One"); - AddMenuItem(hMenu, optionB, "Team Two"); - AddMenuItem(hMenu, optionC, "Spectator"); - SetMenuExitBackButton(hMenu, false); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} - -stock DisplayPlayerMenu(iClient) -{ - new Handle:hMenu = CreateMenu(Menu_SelectPlayer); - AddTargetsToMenu(hMenu, 0, true, false); - SetMenuTitle(hMenu, "Select A Player:"); - SetMenuExitBackButton(hMenu, true); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} diff --git a/Simple Chat Colors/addons/sourcemod/translations/simpledonatorbenefits.phrases.txt b/Simple Chat Colors/addons/sourcemod/translations/simpledonatorbenefits.phrases.txt deleted file mode 100644 index 3826846..0000000 --- a/Simple Chat Colors/addons/sourcemod/translations/simpledonatorbenefits.phrases.txt +++ /dev/null @@ -1,62 +0,0 @@ -"Phrases" -{ - "PlayerLevelCmd" - { - "en" "Command must be run at the player level" - "fr" "Cette commande doit être tapée en jeu" - "hu" "Ezt a parancsot jatekosi szinten kell futtatni!" - } - "RestrictedCmd" - { - "en" "You must be a donator or admin to run this command" - "fr" "Vous devez être un donateur ou un admin pour lancer cette commande" - "hu" "A parancs futtatasahoz admin, vagy tamogatoi szint szukseges!" - } - "InValidTeam" - { - "en" "You must be on red or blue to swap teams" - "fr" "Vous devez être RED ou BLU pour changer d'équipe" - "hu" "Jatekban kell lenned, hogy megcsereld a csapatokat!" - } - "PlayerQueue" - { - "en" "You have been queued to swap teams on next death" - "fr" "Vous avez été mis en attente pour changer d'équipe lors de votre prochaine mort" - "hu" "A kovetkezo halalnal csapatcsere lesz" - } - "PlayerSwitched" - { - "en" "Your team has been switched as requested" - "fr" "Vous avez changé d'équipe comme demandé" - "hu" "A keresnek eleget teve a csapatod meg lett csererlve" - } - "SwapTeamMsg" - { - "en" "Type /swapteam or !swapteam to swap your team!" - } - "ReachedCount" - { - "en" "You have reached your health limit. You must die before you can use it again" - } - "AtMaxHealth" - { - "en" "You are already at your maximum health!" - } - "ToMaxHealth" - { - "en" "Instant health bonus applied! You are not at your maximun health!" - } - "HealthBonus" - { - "en" "Instant health bonus applied!" - } - "PublicJoinMessage" - { - "#format" "{1:s}" - "en" "{1} a [donator] as joined the server" - } - "PrivateJoinMessage" - { - "en" "Thanks for donating!" - } -} \ No newline at end of file diff --git a/Simple Chat Colors/addons/sourcemod/translations/simplespectate.phrases.txt b/Simple Chat Colors/addons/sourcemod/translations/simplespectate.phrases.txt deleted file mode 100644 index 2d1a096..0000000 --- a/Simple Chat Colors/addons/sourcemod/translations/simplespectate.phrases.txt +++ /dev/null @@ -1,42 +0,0 @@ -"Phrases" -{ - "Stopped spectating" - { - "#format" "{1:s}" - "en" "Stopped tracking player: {1}" - } - "Yourself" - { - "en" "You can't spectate yourself" - } - "Spectator" - { - "en" "You can't spectate another spectator" - } - "Spectating" - { - "#format" "{1:s}" - "en" "Now spectating {1}. Type !stopspec or /stopspec to stop spectating this player" - } - "Invalid Target" - { - "en" "Invalid target" - } - "Cant Target" - { - "en" "Can't target this player" - } - "Must Have Target" - { - "en" "You must be following/tracking a player to punish" - } - "Target Left" - { - "en" "The player you were following/tracking has left" - } - "Punished" - { - "#format" "{1:s}{2:s}{3:s}" - "en" "{1} was punished with a {2} for {3}" - } -} \ No newline at end of file diff --git a/Simple Chat Colors/addons/sourcemod/translations/simpleteambalancer.phrases.txt b/Simple Chat Colors/addons/sourcemod/translations/simpleteambalancer.phrases.txt deleted file mode 100644 index 03595fd..0000000 --- a/Simple Chat Colors/addons/sourcemod/translations/simpleteambalancer.phrases.txt +++ /dev/null @@ -1,130 +0,0 @@ -"Phrases" -{ - "UnBalanced" - { - "en" "Teams are unbalanced and will be balanced shortly" - "fr" "Les équipes ne sont pas équilibrées et le seront bientôt" - "de" "Die Teams sind ungleich und werden in Kürze ausgeglichen" - "hu" "A csapatok nem kiegyenlitettek! Egyensuly beallitas kovetkezik!" - } - "Enabled" - { - "en" "Simple Team Balancer is ENABLED" - "fr" "Simple Team Balancer est ACTIVE" - "de" "Simple Team Balancer ist AKTIV" - "hu" "Az Egyszeru Csapat Egyensulytarto AKTIV!" - } - "Disabled" - { - "en" "Simple Team Balancer is DISABLED" - "fr" "Simple Team Balancer est DESACTIVE" - "de" "Simple Team Balancer ist INAKTIV" - "hu" "Az Egyszeru Csapat Egyensulytarto INAKTIV!" - } - "PlayerMessage" - { - "#format" "{1:i}" - "en" "You are going to be auto balanced in {1} seconds unless a dead player can be found" - "fr" "Vous passerez dans l'autre équipe dans {1} secondes si aucun joueur mort ne peut être trouvé dans cet intervalle" - "de" "Du wirst in {1} Sekunden zum automatischen Ausgleich herangezogen wenn kein toter Spieler gefunden werden kann" - "hu" "{1} masodpercen belul at leszel helyezve a masik csapatba, hacsak nem lesz addig egy halott jatekos!" - } - "BalanceMessage" - { - "#format" "{1:s}" - "en" "{1} was moved to the other team for game balance" - "fr" "{1} est passé dans l'autre équipe pour équilibrer la partie" - "de" "{1} wurde zum anderen Team verschoben um das Spiel auszugleichen" - "hu" "{1} at lett helyezve az egyensuly megtartasa erdekeben." - } - "PlayerLevelCmd" - { - "en" "Command must be run at the player level" - "fr" "La commande doit être lancée au niveau du joueur" - "de" "Das Kommando muss auf Spieler Ebene ausgeführt werden" - "hu" "Jatekosi szinten kell futtatni ezt a parancsot!" - } - "CmdDisabled" - { - "en" "Command is currently disabled" - "fr" "La commande est actuellement désactivée" - "de" "Das Kommando ist momentan inaktiv" - "hu" "A parancs jelenleg inaktiv" - } - "RestrictedBuddy" - { - "en" "You must be a donator or admin to add a balance buddy" - "fr" "Vous devez être un donateur ou un admin pour choisir un partenaire" - "de" "Du musst ein Spender oder Admin sein um einen Partner wählen zu können" - "hu" "Tamogato vagy admin kell hogy legyel, hogy 'Tarsat' jelolhess meg" - } - "SelectSelf" - { - "en" "You cannot be your own buddy" - "fr" "Vous ne pouvez pas être votre propre partenaire" - "de" "Du kannst nicht dein eigener Partner sein" - "hu" "Nem valaszthatod ki onmagad!" - } - "BuddyGone" - { - "en" "Your selected buddy has disconnected" - "fr" "Le partenaire que vous avez sélectionné s'est déconnecté" - "de" "Dein gewählter Partner hat die Verbindung getrennt" - "hu" "A valasztott 'Tarsad' kilepett" - } - "BuddyMsg" - { - "#format" "{1:s}" - "en" "You and {1} are now buddies" - "fr" "Vous et {1} êtes maintenant partenaires" - "de" "Du und {1} seid jetzt Partner" - "hu" "{1} es Te 'Tarsak' vagytok." - } - "BuddyLockMsgDisabled" - { - "en" "You can now be anyone's buddy" - "fr" "Vous pouvez à présent être le partenaire de n'importe qui" - "de" "Du kannst jetzt jedermanns Partner sein" - "hu" "Barkinek lehetsz a 'Tarsa'." - } - "BuddyLockMsgEnabled" - { - "en" "Buddy selection locked. Only you can change your buddy" - "fr" "Sélection de partenaire bloquée. Vous êtes le seul à pouvoir choisir votre partenaire" - "de" "Wahl des Partners gesperrt. Nur du kannst deinen Partner wechseln" - "hu" "Tars-lista lezarva. Csak Te tudod modositani a Tars-listadat." - } - "PlayerLockedBuddyMsg" - { - "#format" "{1:s}" - "en" "{1} has locked his buddy selection. Try again" - "fr" "{1} a bloqué sa sélection de partenaire. Essayez de nouveau." - "de" "{1} hat seine Wahl des Partners gesperrt. Versuche es erneut" - "hu" "{1} lezarta a Tars-listajat. Probald kesobb!" - } - "BuddyWelcomeMsg1" - { - "en" "Select a balance buddy and stay together during an autobalance!" - "fr" "Choisissez un partenaire et restez ensemble durant l'équilibrage automatique!" - "de" "Wähle einen Partner und bleibt zusammen während eines Ausgleichs" - "hu" "Valasz ki egy 'Tarsat' akivel egyuttmaradhatsz a csapatkiegyenlites alatt!" - } - "BuddyWelcomeMsg2" - { - "en" "/buddy or !buddy to select a balance buddy" - "fr" "/buddy or !buddy pour choisir un partenaire" - "de" "/buddy oder !buddy um einen Partner zu wählen" - "hu" "Hasznald a /buddy vagy !buddy parancsokat a 'Tars' kijelolesehez" - } - "BuddyWelcomeMsg3" - { - "en" "/lockbuddy or !lockbuddy to lock your selection" - "fr" "/lockbuddy or !lockbuddy pour bloquer votre sélection" - "de" "/lockbuddy oder !lockbuddy um deine Auswahl zu sperren" - "hu" "Hasznald a /lockbuddy vagy a !lockbuddy parancsokat a Tars-listad lezarasahoz" - } -} - - - - diff --git a/Simple Chat Colors/addons/sourcemod/translations/simpleteammanager.phrases.txt b/Simple Chat Colors/addons/sourcemod/translations/simpleteammanager.phrases.txt deleted file mode 100644 index f2093a7..0000000 --- a/Simple Chat Colors/addons/sourcemod/translations/simpleteammanager.phrases.txt +++ /dev/null @@ -1,92 +0,0 @@ -"Phrases" -{ - "PlayerLevelCmd" - { - "en" "Command must be run at the player level" - "fr" "Cette commande doit être tapée en jeu" - "hu" "Ezt a parancsot jatekosi szinten kell futtatni!" - } - "RestrictedCmd" - { - "en" "You must be a donator or admin to run this command" - "fr" "Vous devez être un donateur ou un admin pour lancer cette commande" - "hu" "A parancs futtatasahoz admin, vagy tamogatoi szint szukseges!" - } - "InValidTeam" - { - "en" "You must be on red or blue to swap teams" - "fr" "Vous devez être RED ou BLU pour changer d'équipe" - "hu" "Jatekban kell lenned, hogy megcsereld a csapatokat!" - } - "PlayerInValidTeam" - { - "en" "Player must be on red or blue to swap teams" - "fr" "Le joueur doit être RED ou BLU pour changer d'équipe" - "hu" "Valamelyik csapatban kell lenni, hogy csere legyen" - } - "PlayerQueue" - { - "en" "You have been queued to swap teams on next death" - "fr" "Vous avez été mis en attente pour changer d'équipe lors de votre prochaine mort" - "hu" "A kovetkezo halalnal csapatcsere lesz" - } - "PlayerSwitched" - { - "en" "Your team has been switched" - } - "PlayerSwitched1" - { - "en" "Your team has been switched as requested" - "fr" "Vous avez changé d'équipe comme demandé" - "hu" "A keresnek eleget teve a csapatod meg lett csererlve" - } - "PlayerSwitched2" - { - "en" "Your team has been switched by an Admin" - "fr" "Vous avez été changé d'équipe par un admin" - "hu" "Az Admin megcserelte a csapatodat!" - } - "SwapTeamMsg" - { - "en" "Type /swapteam or !swapteam to swap your team!" - } - "PlayerSwitched3" - { - "#format" "{1:s}" - "en" "{1}'s team has been switched" - "fr" "{1} a changé d'équipe" - "hu" "{1} csapata meg lett cserelve" - } - "Scramble" - { - "en" "Teams are about to be scrambled!" - "fr" "Les équipes vont être rééquilibrés" - "hu" "A csapatok hamarosan meg lesznek keverve!" - } - "VoteScramble1" - { - "#format" "{1:i}{2:i}" - "en" "Vote Scramble successful with {1} votes out of {2}" - "fr" "Le vote d'équilibrage des équipes a réussi avec {1} votes pour sur {2}" - "hu" "A szavazas sikeres volt, {1} szavazat a keveresre a {2} -bol" - } - "VoteScramble2" - { - "#format" "{1:i}{2:i}" - "en" "Vote Scramble failed with {1} votes out of {2}" - "fr" "Le vote d'équilibrage a échoué avec {1} votes pour sur {2}" - "hu" "A szavazas sikertelen volt, {1} szavazat a keveresre a {2} -bol" - } - "VoteInProgress" - { - "en" "A vote is currently in progress" - "fr" "Un vote est actuellement en cours" - "hu" "Egy szavazas mar fut!" - } - "ScrambleTime" - { - "en" "A vote was recently made, please wait" - "fr" "Un vote a déjà été fait récemment, réessayez plus tard" - "hu" "Nemreg volt szavazas, kerlek varj egy kicsit!" - } -} \ No newline at end of file diff --git a/Simple Donator Benefits/addons/sourcemod/configs/simple-alltalkmanager_events.cfg b/Simple Donator Benefits/addons/sourcemod/configs/simple-alltalkmanager_events.cfg deleted file mode 100644 index b739cf0..0000000 --- a/Simple Donator Benefits/addons/sourcemod/configs/simple-alltalkmanager_events.cfg +++ /dev/null @@ -1,43 +0,0 @@ -"game_events" -{ - "teamplay_round_start" - { - "reason" "Round Start" - "setting" "1" - } - "teamplay_setup_finished" - { - "reason" "Setup Period Ended" - "setting" "0" - } - "teamplay_overtime_begin" - { - "reason" "Overtime Began" - "setting" "1" - } - "teamplay_overtime_end" - { - "reason" "Overtime Ended" - "setting" "1" - } - "teamplay_round_win" - { - "reason" "Round Ended" - "setting" "1" - } - "teamplay_suddendeath_begin" - { - "reason" "Sudden Death Began" - "setting" "1" - } - "teamplay_suddendeath_end" - { - "reason" "Sudden Death Ended" - "setting" "1" - } - "teamplay_round_stalemate" - { - "reason" "Stalemate" - "setting" "1" - } -} \ No newline at end of file diff --git a/Simple Donator Benefits/addons/sourcemod/configs/simple-chatcolors.cfg b/Simple Donator Benefits/addons/sourcemod/configs/simple-chatcolors.cfg deleted file mode 100644 index 14b98c6..0000000 --- a/Simple Donator Benefits/addons/sourcemod/configs/simple-chatcolors.cfg +++ /dev/null @@ -1,15 +0,0 @@ -"admin_colors" -{ - "groupname2" - { - "flag" "z" - "namecolor" "{green}" - "textcolor" "{olive}" - } - "groupname1" - { - "flag" "a" - "namecolor" "{teamcolor}" - "textcolor" "{green}" - } -} \ No newline at end of file diff --git a/Simple Donator Benefits/addons/sourcemod/plugins/simple-alltalkmanager.smx b/Simple Donator Benefits/addons/sourcemod/plugins/simple-alltalkmanager.smx deleted file mode 100644 index 6122756..0000000 Binary files a/Simple Donator Benefits/addons/sourcemod/plugins/simple-alltalkmanager.smx and /dev/null differ diff --git a/Simple Donator Benefits/addons/sourcemod/plugins/simple-messagesuppression.smx b/Simple Donator Benefits/addons/sourcemod/plugins/simple-messagesuppression.smx deleted file mode 100644 index cc20dad..0000000 Binary files a/Simple Donator Benefits/addons/sourcemod/plugins/simple-messagesuppression.smx and /dev/null differ diff --git a/Simple Donator Benefits/addons/sourcemod/plugins/simple-plugins.smx b/Simple Donator Benefits/addons/sourcemod/plugins/simple-plugins.smx deleted file mode 100644 index ac307a3..0000000 Binary files a/Simple Donator Benefits/addons/sourcemod/plugins/simple-plugins.smx and /dev/null differ diff --git a/Simple Donator Benefits/addons/sourcemod/plugins/simple-spectate.smx b/Simple Donator Benefits/addons/sourcemod/plugins/simple-spectate.smx deleted file mode 100644 index c6885b0..0000000 Binary files a/Simple Donator Benefits/addons/sourcemod/plugins/simple-spectate.smx and /dev/null differ diff --git a/Simple Donator Benefits/addons/sourcemod/plugins/simple-teambalancer.smx b/Simple Donator Benefits/addons/sourcemod/plugins/simple-teambalancer.smx deleted file mode 100644 index 95beb01..0000000 Binary files a/Simple Donator Benefits/addons/sourcemod/plugins/simple-teambalancer.smx and /dev/null differ diff --git a/Simple Donator Benefits/addons/sourcemod/plugins/simple-teammanager.smx b/Simple Donator Benefits/addons/sourcemod/plugins/simple-teammanager.smx deleted file mode 100644 index 81905ba..0000000 Binary files a/Simple Donator Benefits/addons/sourcemod/plugins/simple-teammanager.smx and /dev/null differ diff --git a/Simple Donator Benefits/addons/sourcemod/scripting/include/simple-plugins.inc b/Simple Donator Benefits/addons/sourcemod/scripting/include/simple-plugins.inc deleted file mode 100644 index 8f21956..0000000 --- a/Simple Donator Benefits/addons/sourcemod/scripting/include/simple-plugins.inc +++ /dev/null @@ -1,337 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Plugins -Description: - Included file for core plugin in the Simple Plugins project -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -*************************************************************************/ - -#if defined _simpleplugin_included - #endinput -#endif - -#define _simpleplugin_included - -#define CORE_INC_VERSION "1.1.$Rev$" - -#pragma semicolon 1 -#include -#undef REQUIRE_PLUGIN -#include -#define REQUIRE_PLUGIN -#undef REQUIRE_EXTENSIONS -#undef AUTOLOAD_EXTENSIONS -#tryinclude -#tryinclude -#tryinclude -#define AUTOLOAD_EXTENSIONS -#define REQUIRE_EXTENSIONS - -enum e_SupportedMods -{ - GameType_Unknown, - GameType_AOC, - GameType_CSS, - GameType_DOD, - GameType_FF, - GameType_HIDDEN, - GameType_HL2DM, - GameType_INS, - GameType_L4D, - GameType_NEO, - GameType_SGTLS, - GameType_TF, - GameType_ZPS -}; - -enum e_Teams -{ - Unknown, - Spectator, - Team1, - Team2 -}; - -new g_aCurrentTeams[e_Teams]; -new e_SupportedMods:g_CurrentMod; -new String:g_sGameName[e_SupportedMods][32] = { "Unknown", - "Age of Chivalry", - "Counter Strike", - "Day Of Defeat", - "Fortress Forever", - "Hidden: Source", - "Half Life 2: Deathmatch", - "Insurgency", - "Left 4 Dead", - "Neotokyo", - "Stargate TLS", - "Team Fortress 2", - "Zombie Panic: Source" - }; - -public SharedPlugin:_pl_simpleplugin = -{ - name = "simple-plugins", - file = "simple-plugins.smx", -#if defined REQUIRE_PLUGIN - required = 1 -#else - required = 0 -#endif -}; - -#if !defined REQUIRE_PLUGIN -public _pl_simpleplugin_SetNTVOptional() -{ - MarkNativeAsOptional("SM_MovePlayer"); - MarkNativeAsOptional("SM_SetForcedTeam"); - MarkNativeAsOptional("SM_GetForcedTeam"); - MarkNativeAsOptional("SM_ClearForcedTeam"); - MarkNativeAsOptional("SM_GetForcedPlayer"); - MarkNativeAsOptional("SM_AssignBuddy"); - MarkNativeAsOptional("SM_SearchBuddy"); - MarkNativeAsOptional("SM_LockBuddy"); - MarkNativeAsOptional("SM_IsBuddyLocked"); - MarkNativeAsOptional("SM_ClearBuddy"); - MarkNativeAsOptional("SM_IsValidAdmin"); - MarkNativeAsOptional("SM_IsValidTeam"); -} -#endif - -/********************************************************************** - * When a player has to moved - * - * @param plugin Plugin that initiated the move - * @param client The client index of the player that was moved - * @param team The team index the player was moved to - * @noreturn - **********************************************************************/ -forward SM_OnPlayerMoved(Handle:plugin, client, team); - -/********************************************************************** - * Move a player to the supplied team - * - * @param client The client index of the player to be moved - * @param team The team to move the player to - * @noreturn - * @error Invalid client or team index - **********************************************************************/ -native SM_MovePlayer(client, team); - -/********************************************************************** - * Move a player to the supplied team - * - * @param client The client index of the player to set - * @param team The team to move the to set - * @param override Whether or not to override another plugin - * @return True if successful, false if not - * @error Invalid client or team index - **********************************************************************/ -native SM_SetForcedTeam(client, team, bool:override = false); - -/********************************************************************** - * Gets the client's forced team index - * - * @param client The client index of the player to check - * @param plugin Optional: The plugin handle of the plugin - that set the team - * @return The team index of the forced team - Zero if no forced team - * @error Invalid client index - **********************************************************************/ -native SM_GetForcedTeam(client, &Handle:plugin = INVALID_HANDLE); - -/********************************************************************** - * Clears a client's forced team - * - * @param client The client index of the player to check - * @return True if successful, false if not - * @error Invalid client index - **********************************************************************/ -native SM_ClearForcedTeam(client); - -/********************************************************************** - * Gets a forced player on the wrong that is currently on the wrong team - * This will only return a player if the calling plugin assigned the team - * - * @param team The team index the player should be on - * @return The client index of the player - Zero if no player found - * @error Invalid client index - **********************************************************************/ -native SM_GetForcedPlayer(team); - -/********************************************************************** - * Assign a players buddy - * - * @param client The client index of the player to assign - * @param player The player index of the player to assign - * @param override Whether or not to override a player lock - * @return True if successful, false if not - * @error Invalid client or player index - **********************************************************************/ -native bool:SM_AssignBuddy(client, player, bool:override = false); - -/********************************************************************** - * Rturns the client's buddy - * - * @param client The client index of the player to assign - * @return The client index of the player's buddy - Zero if no buddy - * @error Invalid client index - **********************************************************************/ -native SM_GetClientBuddy(client); - -/********************************************************************** - * Set the buddy lock setting for a client - * - * @param client The client index of the player to assign - * @param setting Setting to set, True or False - * @return True if successful, false if not - * @error Invalid client index - **********************************************************************/ -native bool:SM_LockBuddy(client, bool:setting); - -/********************************************************************** - * Returns the buddy lock setting for a client - * - * @param client The client index of the player to assign - * @return True if locked, false if not - * @error Invalid client index - **********************************************************************/ -native bool:SM_IsBuddyLocked(client); - -/********************************************************************** - * Clear a players buddy - * - * @param client The client index of the player to clear - * @param override Whether or not to override a player lock - * @return True if successful, false if not - * @error Invalid client index - **********************************************************************/ -native bool:SM_ClearBuddy(client, bool:override = false); - -/********************************************************************** - * Determine if the player has the supplied flags - * ADMFLAG_ROOT will always return true - * - * @param client The client index of the player to assign - * @param flags The char flag(s) to check against - * @return True if valid, false if not - **********************************************************************/ -native bool:SM_IsValidAdmin(client, const String:flags[]); - - -/********************************************************************** - * Determine if the team is a valid team - * - * @param team The team index to determine if valid for - currently installed/supported mod - * @return True if valid, false if not - **********************************************************************/ -native bool:SM_IsValidTeam(team); - - -public e_SupportedMods:GetCurrentMod() -{ - new String:sGameType[64]; - GetGameFolderName(sGameType, sizeof(sGameType)); - - if (StrEqual(sGameType, "aoc", false)) - { - return GameType_AOC; - } - if (StrEqual(sGameType, "cstrike", false)) - { - return GameType_CSS; - } - if (StrEqual(sGameType, "dod", false)) - { - return GameType_DOD; - } - if (StrEqual(sGameType, "ff", false)) - { - return GameType_FF; - } - if (StrEqual(sGameType, "hidden", false)) - { - return GameType_HIDDEN; - } - if (StrEqual(sGameType, "hl2mp", false)) - { - return GameType_FF; - } - if (StrEqual(sGameType, "insurgency", false) || StrEqual(sGameType, "ins", false)) - { - return GameType_INS; - } - if (StrEqual(sGameType, "l4d", false)) - { - return GameType_L4D; - } - if (StrEqual(sGameType, "nts", false)) - { - return GameType_NEO; - } - if (StrEqual(sGameType, "sgtls", false)) - { - return GameType_SGTLS; - } - if (StrEqual(sGameType, "tf", false)) - { - return GameType_TF; - } - if (StrEqual(sGameType, "zps", false)) - { - return GameType_ZPS; - } - return GameType_Unknown; -} - -public LoadCurrentTeams() -{ - switch (g_CurrentMod) - { - case GameType_INS: - { - g_aCurrentTeams[Unknown] = 0; - g_aCurrentTeams[Spectator] = 3; - g_aCurrentTeams[Team1] = 1; - g_aCurrentTeams[Team2] = 2; - } - case default: - { - g_aCurrentTeams[Unknown] = 0; - g_aCurrentTeams[Spectator] = 1; - g_aCurrentTeams[Team1] = 2; - g_aCurrentTeams[Team2] = 3; - } - } -} diff --git a/Simple Donator Benefits/addons/sourcemod/scripting/simple-alltalkmanager.sp b/Simple Donator Benefits/addons/sourcemod/scripting/simple-alltalkmanager.sp deleted file mode 100644 index c848332..0000000 --- a/Simple Donator Benefits/addons/sourcemod/scripting/simple-alltalkmanager.sp +++ /dev/null @@ -1,515 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple AllTalk Manager -Description: - Allows you to set alltalk at different times -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#pragma semicolon 1 -#include -#include - -#define PLUGIN_VERSION "1.4.$Rev$" - -new Handle:satm_enabled = INVALID_HANDLE; -new Handle:satm_threshold_enabled = INVALID_HANDLE; -new Handle:satm_player_threshold = INVALID_HANDLE; -new Handle:satm_threshold_setting = INVALID_HANDLE; -new Handle:satm_logactivity = INVALID_HANDLE; -new Handle:satm_alltalk = INVALID_HANDLE; - -new Handle:g_aEventNames = INVALID_HANDLE; -new Handle:g_aEventReasons = INVALID_HANDLE; -new Handle:g_aEventSettings = INVALID_HANDLE; - -new bool:g_bLastThreshold = false; -new bool:g_bEnabled = true; -new bool:g_bThresholdEnabled = true; -new bool:g_bIsSetupMap = false; -new bool:g_bIsGameTF2 = false; -new bool:g_bLogActivity = false; - -new g_iLastEventIndex; - -public Plugin:myinfo = -{ - name = "Simple AllTalk Manager", - author = "Simple Plugins", - description = "Allows you to set alltalk at different times", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -} - -/** -Sourcemod callbacks -*/ -public OnPluginStart() -{ - - /** - Need to create all of our console variables. - */ - CreateConVar("satm_version", PLUGIN_VERSION, "Simple AllTalk Manager", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - satm_enabled = CreateConVar("satm_enabled", "1", "Enables/Disables Simple AllTalk Manager", _, true, 0.0, true, 1.0); - satm_threshold_enabled = CreateConVar("satm_threshold_enabled", "1", "Enables/Disables player threshold", _, true, 0.0, true, 1.0); - satm_player_threshold = CreateConVar("satm_player_threshold", "8", "Amount of players for the threshold"); - satm_threshold_setting = CreateConVar("satm_threshold_setting", "1", "Enables/Disables all talk up to player threshold, with the opposite set after the threshold", _, true, 0.0, true, 1.0); - satm_logactivity = CreateConVar("satm_logactivity", "0", "Enables/Disables log activity", _, true, 0.0, true, 1.0); - satm_alltalk = FindConVar("sv_alltalk"); - - /** - Hook console variables - */ - HookConVarChange(satm_enabled, ConVarSettingsChanged); - HookConVarChange(satm_threshold_enabled, ConVarSettingsChanged); - HookConVarChange(satm_player_threshold, ConVarSettingsChanged); - HookConVarChange(satm_logactivity, ConVarSettingsChanged); - - /** - Remove the notify flag from all talk cvar since we do it - */ - SetConVarFlags(satm_alltalk, GetConVarFlags(satm_alltalk)~FCVAR_NOTIFY); - - /** - Get the game type. We only care if it's TF2 - */ - new String:sGameType[64]; - GetGameFolderName(sGameType, sizeof(sGameType)); - if (StrEqual(sGameType, "tf", false)) - { - g_bIsGameTF2 = true; - } - - /** - Create the arrays - */ - g_aEventNames = CreateArray(255, 1); - g_aEventReasons = CreateArray(255, 1); - g_aEventSettings = CreateArray(1, 1); - - /** - Need to register the commands we are going to create and use. - */ - RegAdminCmd("sm_reloadatconfig", Command_Reload, ADMFLAG_GENERIC, "Reloads settings from config file"); - - /** - Create the config file - */ - AutoExecConfig(true); - - /** - Load the events from the config - */ - LoadEventsFromConfig(); -} - -public OnConfigsExecuted() -{ - - /** - Load up the settings - */ - g_bEnabled = GetConVarBool(satm_enabled); - g_bLogActivity = GetConVarBool(satm_logactivity); - g_bThresholdEnabled = GetConVarBool(satm_threshold_enabled); -} - -public OnMapStart() -{ - - /** - Reset the globals - */ - g_iLastEventIndex = 0; - g_bLastThreshold = false; - - /** - Check the map type if we are in TF2 - */ - if (g_bIsGameTF2) - { - g_bIsSetupMap = IsSetupPeriodMap(); - } - - /** - Set AllTalk - */ - if (g_bEnabled) - { - SetConVarBool(satm_alltalk, true); - } -} - -public OnClientDisconnect_Post(client) -{ - if (g_bEnabled) - { - SetAllTalk(-1); - } -} - -public OnClientPostAdminCheck(client) -{ - if (g_bEnabled) - { - SetAllTalk(-1); - } - CreateTimer(2.0, Timer_ShowAllTalkStatus, client, TIMER_FLAG_NO_MAPCHANGE); -} - -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (convar == satm_enabled) - { - if (StringToInt(newValue)) - { - g_bEnabled = true; - } - else - { - g_bEnabled = false; - } - } - else if (convar == satm_threshold_enabled) - { - if (StringToInt(newValue)) - { - g_bThresholdEnabled = true; - } - else - { - g_bThresholdEnabled = false; - } - } - else if (convar == satm_logactivity) - { - if (StringToInt(newValue)) - { - g_bLogActivity = true; - } - else - { - g_bLogActivity = false; - } - } - if (g_bEnabled) - { - SetAllTalk(-1); - } -} - -/** -Commands -*/ -public Action:Command_Reload(client, args) -{ - - /** - Clear the array - */ - ClearArray(g_aEventNames); - ClearArray(g_aEventReasons); - ClearArray(g_aEventSettings); - - /** - Load the events from the config - */ - LoadEventsFromConfig(); - - return Plugin_Handled; -} - -/** -Game Event Hooks -*/ -public Hook_All_Events(Handle:event, const String:name[], bool:dontBroadcast) -{ - if (!g_bIsSetupMap) - { - if (StrEqual(name, "teamplay_round_start")) - { - if (FindStringInArray(g_aEventNames, "teamplay_setup_finished") != -1) - { - g_iLastEventIndex = FindStringInArray(g_aEventNames, "teamplay_setup_finished"); - if (g_bEnabled) - { - SetAllTalk(g_iLastEventIndex); - return; - } - } - } - } - g_iLastEventIndex = FindStringInArray(g_aEventNames, name); - if (g_bEnabled) - { - SetAllTalk(g_iLastEventIndex); - } -} - -/** -Timers -*/ -public Action:Timer_ShowAllTalkStatus(Handle:timer, any:client) -{ - if (IsClientConnected(client) && IsClientInGame(client)) - { - new bool:bSetting = GetConVarBool(satm_alltalk); - if (bSetting) - { - PrintToChat(client, "\x01\x04[SM] AllTalk is \x01[on]"); - } - else - { - PrintToChat(client, "\x01\x04[SM] AllTalk is \x01[off]"); - } - } -} - -/** -Stock Functions -*/ -stock LoadEventsFromConfig() -{ - - /** - Make sure the config file is here and load it up - */ - new String:sConfigFile[256]; - BuildPath(Path_SM, sConfigFile, sizeof(sConfigFile), "configs/simple-alltalkmanager_events.cfg"); - if (!FileExists(sConfigFile)) - { - - /** - Config file doesn't exists, stop the plugin - */ - LogError("[SATM] Simple AllTalk Manager is not running! Could not find file %s", sConfigFile); - SetFailState("Could not find file %s", sConfigFile); - } - - /** - Create the arrays and variables - */ - new String:sGameEventName[256]; - new String:sReason[256]; - new iSetting; - - /** - Load config file as a KeyValues file - */ - new Handle:kvGameEvents = CreateKeyValues("game_events"); - FileToKeyValues(kvGameEvents, sConfigFile); - - if (!KvGotoFirstSubKey(kvGameEvents)) - { - return; - } - - /** - Hook the game events and load the settings - */ - do - { - - /** - Get the section name; this should be the event name - */ - KvGetSectionName(kvGameEvents, sGameEventName, sizeof(sGameEventName)); - if (!HookEventEx(sGameEventName, Hook_All_Events, EventHookMode_PostNoCopy)) - { - - /** - Could not hook this event, stop the plugin - */ - SetFailState("Could not hook event %s", sGameEventName); - } - else - { - if (g_bLogActivity) - { - LogMessage("[SATM] Hooked event: %s", sGameEventName); - } - } - - /** - Get the reason string and setting - */ - KvGetString(kvGameEvents, "reason", sReason, sizeof(sReason)); - iSetting = KvGetNum(kvGameEvents, "setting"); - if (g_bLogActivity) - { - LogMessage("[SATM] Event reason string: %s", sReason); - LogMessage("[SATM] Event setting: %i", iSetting); - } - - /** - Push the values to the arrays - */ - PushArrayString(g_aEventNames, sGameEventName); - PushArrayString(g_aEventReasons, sReason); - PushArrayCell(g_aEventSettings, iSetting); - } while (KvGotoNextKey(kvGameEvents)); - - /** - Close our handle - */ - CloseHandle(kvGameEvents); -} - -stock SetAllTalk(index) -{ - new iPlayerThreshold = GetConVarInt(satm_player_threshold); - new bool:bThresholdMet = ((GetClientCount() >= iPlayerThreshold) ? true : false); - new bool:bSetting; - - if (g_bThresholdEnabled) - { - if (bThresholdMet) - { - if (index == -1) - { - if (bThresholdMet != g_bLastThreshold) - { - g_bLastThreshold = true; - bSetting = !GetConVarBool(satm_threshold_setting); - new bool:bLastSetting = GetArrayCell(g_aEventSettings, g_iLastEventIndex); - if (bLastSetting && !bSetting) - { - bSetting = GetArrayCell(g_aEventSettings, g_iLastEventIndex); - } - } - else - { - bSetting = GetArrayCell(g_aEventSettings, g_iLastEventIndex); - } - } - else - { - bSetting = GetArrayCell(g_aEventSettings, index); - } - } - else - { - g_bLastThreshold = false; - bSetting = GetConVarBool(satm_threshold_setting); - } - } - else - { - if (index != -1) - { - bSetting = GetArrayCell(g_aEventSettings, index); - } - } - - if (GetConVarBool(satm_alltalk) != bSetting) - { - - SetConVarBool(satm_alltalk, bSetting); - - new String:sReason[256]; - if (index == -1) - { - Format(sReason, sizeof(sReason), "Player Threshold"); - } - else - { - if (!g_bIsSetupMap) - { - new String:sCurrentEvent[256]; - GetArrayString(g_aEventNames, index, sCurrentEvent, sizeof(sCurrentEvent)); - if (StrEqual(sCurrentEvent, "teamplay_setup_finished")) - { - new iRoundStartIndex = FindStringInArray(g_aEventNames, "teamplay_round_start"); - if (iRoundStartIndex != -1) - { - GetArrayString(g_aEventReasons, iRoundStartIndex, sReason, sizeof(sReason)); - } - else - { - GetArrayString(g_aEventReasons, index, sReason, sizeof(sReason)); - } - } - else - { - GetArrayString(g_aEventReasons, index, sReason, sizeof(sReason)); - } - } - else - { - GetArrayString(g_aEventReasons, index, sReason, sizeof(sReason)); - } - } - - if (bSetting) - { - PrintToChatAll("\x01\x04[SM] AllTalk turned \x01[on] \x04due to:\x01 %s", sReason); - } - else - { - PrintToChatAll("\x01\x04[SM] AllTalk turned \x01[off] \x04due to:\x01 %s", sReason); - } - } -} - -stock bool:IsSetupPeriodMap() -{ - new iEnt = -1; - new String:sMapName[32]; - - GetCurrentMap(sMapName, sizeof(sMapName)); - - if (strncmp(sMapName, "cp_", 3, false) == 0) - { - new iTeam; - while ((iEnt = FindEntityByClassname(iEnt, "team_control_point")) != -1) - { - iTeam = GetEntProp(iEnt, Prop_Send, "m_iTeamNum"); - - /** - If there is a blu CP or a neutral CP, then it's not an attack/defend map - */ - if (iTeam != 2) - { - //this is a push map - return false; - } - } - //this is a attack/defend map - return true; - } - else if (strncmp(sMapName, "ctf_", 3, false) == 0) - { - //this is a ctf map - return false; - } - return false; -} diff --git a/Simple Donator Benefits/addons/sourcemod/scripting/simple-autoscrambler.sp b/Simple Donator Benefits/addons/sourcemod/scripting/simple-autoscrambler.sp deleted file mode 100644 index 6c6799e..0000000 --- a/Simple Donator Benefits/addons/sourcemod/scripting/simple-autoscrambler.sp +++ /dev/null @@ -1,459 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple AutoScrambler -Description: - Automatically scrambles the teams based upon a number of events. -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include - -#define PLUGIN_VERSION "1.1.$Rev$" - -/** -Different scramble modes: - -1 = Full Scramble, dont restart round. -2 = Admins Immune, dont restart round. -3 = Full Scramble, restart round and reset scores. -4 = Admins Immune, restart round and reset scores. - -*/ - -/** -Different top player modes: - -1 = Divide Top 4 players on the two teams. -2 = Protect the Top 2 players on each team. - -*/ - -enum PlayerData -{ - Handle:hForcedTimer, - bool:bProtected; -}; - -/** -Cvars used for admins -*/ -new Handle: sas_admin_immunity_enabled = INVALID_HANDLE, - Handle: sas_admin_flag_scramblenow = INVALID_HANDLE, - Handle: sas_admin_flag_immunity = INVALID_HANDLE; - -/** -Cvars used for autoscramble -*/ -new Handle: sas_autoscramble_enabled = INVALID_HANDLE, - Handle: sas_autoscramble_minplayers = INVALID_HANDLE, - Handle: sas_autoscramble_mode = INVALID_HANDLE, - Handle: sas_autoscramble_winstreak = INVALID_HANDLE, - Handle: sas_autoscramble_steamroll = INVALID_HANDLE, - Handle: sas_autoscramble_frags = INVALID_HANDLE; - -/** -Cvars used for voting -*/ -new Handle: sas_vote_enabled = INVALID_HANDLE, - Handle: sas_vote_upcount = INVALID_HANDLE, - Handle: sas_vote_winpercent = INVALID_HANDLE, - Handle: sas_vote_mode = INVALID_HANDLE, - Handle: sas_vote_minplayers = INVALID_HANDLE; - -/** -Additional cvars -*/ -new Handle: sas_enabled = INVALID_HANDLE, - Handle: sas_timer_scrambledelay = INVALID_HANDLE, - Handle: TFGameModeArena = INVALID_HANDLE; - -/** -Timers -*/ -new Handle: g_hScrambleTimer = INVALID_HANDLE; - -/** - Player arrays - */ -new g_aPlayers[MAXPLAYERS + 1][PlayerData]; - -/** - Cvar variables - */ -new bool: g_bIsEnabled, - bool: g_bIsAutoScrambleEnabled, - bool: g_bIsVoteEnabled, - bool: g_bIsAdminImmunityEnabled; -new Float: g_fTimer_ScrambleDelay, - Float: g_fVote_UpCount, - Float: g_fVote_WinPercent; -new g_iAutoScramble_Minplayers, - g_iAutoScramble_Mode, - g_iAutoScramble_WinStreak, - g_iAutoScramble_SteamRoll, - g_iAutoScramble_Frags, - g_iVote_Mode, - g_iVote_MinPlayers; -new String: g_sScrambleNowFlag[5], - String: g_sAdminImmunityFlag[5]; - -/** -Other globals -*/ -new g_iMaxEntities, - g_iOwnerOffset; - -public Plugin:myinfo = -{ - name = "Simple AutoScrambler", - author = "Simple Plugins", - description = "Automatically scrambles the teams based upon a number of events.", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -}; - -public OnPluginStart() -{ - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook the game events - */ - LogAction(0, -1, "[SAS] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - switch (g_CurrentMod) - { - case GameType_TF: - { - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - } - case GameType_DOD: - { - HookEvent("dod_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_Post); - } - default: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_Post); - } - } - - /** - Create console variables - */ - CreateConVar("sas_version", PLUGIN_VERSION, "Simple AutoScrambler Version",FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - sas_enabled = CreateConVar("sas_enabled", "1", "Enable/Disable Simple AutoScrambler"); - sas_timer_scrambledelay = CreateConVar("sas_timer_scrambledelay", "5.0", "Delay used after a scramble has been started", _, true, 1.0, true, 30.0); - - /** - Cvars used for admins - */ - sas_admin_immunity_enabled = CreateConVar("sas_admin_immunity_enabled", "1", "Enable/Disable admin immunity for scrambles"); - sas_admin_flag_scramblenow = CreateConVar("sas_admin_flag_scramblenow", "z", "Admin flag to use for scramblenow function/command"); - sas_admin_flag_immunity = CreateConVar("sas_admin_flag_immunity", "z", "Admin flag to use for scramble immunity"); - - /** - Cvars used for autoscramble - */ - sas_autoscramble_enabled = CreateConVar("sas_autoscramble_enabled", "1", "Enable/Disable the autoscramble function"); - sas_autoscramble_minplayers = CreateConVar("sas_autoscramble_minplayers", "16", "Min players needed to start an autoscramble"); - sas_autoscramble_mode = CreateConVar("sas_autoscramble_mode", "1", "Scramble mode used when autoscrambling"); - sas_autoscramble_winstreak = CreateConVar("sas_autoscramble_winstreak", "5", "Max amount of wins in a row a team can achieve before an autoscramble starts"); - sas_autoscramble_steamroll = CreateConVar("sas_autoscramble_steamroll", "120", "Shortest amount of time a team can win by before an autoscramble starts (seconds)"); - sas_autoscramble_frags = CreateConVar("sas_autoscramble_frags", "1", "Min players needed to start a vote and scramble"); - - /** - Cvars used for voting - */ - sas_vote_enabled = CreateConVar("sas_vote_enabled", "1", "Enable/Disable voting for scramble"); - sas_vote_upcount = CreateConVar("sas_vote_upcount", "5", "Amount of people wanting a scramble before a vote starts. If less than 1 it will be considered a percentage. (ie 0.5 = 50% | 1 = 1 Player | 5 = 5 Players)"); - sas_vote_winpercent = CreateConVar("sas_vote_winpercent", "0.6", "Percentage of votes needed to scramble", _, true, 0.0, true, 1.0); - sas_vote_mode = CreateConVar("sas_vote_mode", "1", "Scramble mode used when a vote results in a scramble"); - sas_vote_minplayers = CreateConVar("sas_vote_minplayers", "16", "Min players needed to start a vote and scramble"); - - /** - Hook the console variables if they change - */ - HookConVarChange(sas_enabled, ConVarSettingsChanged); - HookConVarChange(sas_timer_scrambledelay, ConVarSettingsChanged); - HookConVarChange(sas_admin_immunity_enabled, ConVarSettingsChanged); - HookConVarChange(sas_admin_flag_scramblenow, ConVarSettingsChanged); - HookConVarChange(sas_admin_flag_immunity, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_enabled, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_minplayers, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_mode, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_winstreak, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_steamroll, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_frags, ConVarSettingsChanged); - HookConVarChange(sas_vote_enabled, ConVarSettingsChanged); - HookConVarChange(sas_vote_upcount, ConVarSettingsChanged); - HookConVarChange(sas_vote_winpercent, ConVarSettingsChanged); - HookConVarChange(sas_vote_mode, ConVarSettingsChanged); - HookConVarChange(sas_vote_minplayers, ConVarSettingsChanged); - - /** - Register the command - */ - RegConsoleCmd("sm_scramblenow", Command_ScrambleNow, "sm_scramblenow (mode): Scrambles the teams"); - - /** - Load translations and .cfg file - */ - LoadTranslations ("simpleautoscrambler.phrases"); - AutoExecConfig(true, "plugin.simpleautoscrambler"); - LogAction(0, -1, "[SAS] Simple AutoScrambler is loaded."); -} - -public OnAllPluginsLoaded() -{ - //something -} - -public OnLibraryRemoved(const String:name[]) -{ - //something -} - -public OnConfigsExecuted() -{ - - /** - Load up all the variable defaults - */ - LoadUpVariables(); - - /** - Log our activity - */ - if (g_bIsEnabled) - LogAction(0, -1, "Simple AutoScrambler is ENABLED"); - else - LogAction(0, -1, "Simple AutoScrambler is DISABLED"); -} - -public Action:Command_ScrambleNow(client, args) -{ - - /** - Make sure we are enabled - */ - if (!g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - Make sure the client is authorized to run this command. - */ - if (!SM_IsValidAdmin(client, g_sScrambleNowFlag)) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Make sure it's ok to scramble at this time - */ - if (!OkToScramble) - { - return Plugin_Handled; - } - - /** - Make sure it's ok to scramble at this time - */ - LogAction(0, -1, "[SAS] The scramblenow command was used"); - - /** - Scramble the teams - */ - StartAScramble(); - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public HookRoundStart(Handle:event, const String:name[], bool:dontBroadcast) -{ - -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - -} - -public Action:Timer_ScrambleTeams(Handle:timer, any:mode) -{ - - /** - Make sure it's still ok to scramble - */ - if (!OkToScramble) - { - return Plugin_Handled; - } - - - switch (mode) - { - case - - - - } - - - /** - Reset the handle because the timer is over and the callback is done - */ - g_hScrambleTimer = INVALID_HANDLE; - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - -} - -stock StartAScramble(mode) -{ - - /** - See if we are already started a scramble - */ - if (g_hScrambleTimer == INVALID_HANDLE) - { - - /** - There is a scramble in progress - */ - return; - - } - - /** - Report that a scramble is about to start - */ - PrintCenterTextAll("%T", "Scramble", LANG_SERVER); - - /** - Start a timer and log the action - */ - g_hScrambleTimer = CreateTimer(g_fTimer_ScrambleDelay, Timer_ScrambleTeams, mode, TIMER_FLAG_NO_MAPCHANGE); - LogAction(0, -1, "[SAS] A scamble timer was started"); -} - -stock bool:OkToScramble() -{ - -} - -stock LoadUpVariables() -{ - g_bIsEnabled = GetConVarBool(sas_enabled); - g_bIsAutoScrambleEnabled = GetConVarBool(sas_autoscramble_enabled); - g_bIsVoteEnabled = GetConVarBool(sas_vote_enabled); - g_bIsAdminImmunityEnabled = GetConVarBool(sas_admin_immunity_enabled); - g_iAutoScramble_Minplayers = GetConVarInt(sas_autoscramble_minplayers); - g_iAutoScramble_Mode = GetConVarInt(sas_autoscramble_mode); - g_iAutoScramble_WinStreak = GetConVarInt(sas_autoscramble_winstreak); - g_iAutoScramble_SteamRoll = GetConVarInt(sas_autoscramble_steamroll); - g_iAutoScramble_Frags = GetConVarInt(sas_autoscramble_frags); - g_iVote_Mode = GetConVarInt(sas_vote_mode); - g_iVote_MinPlayers = GetConVarInt(sas_vote_minplayers); - GetConVarString(sas_admin_flag_scramblenow, g_sScrambleNowFlag, sizeof(g_sScrambleNowFlag)); - GetConVarString(sas_admin_flag_immunity, g_sAdminImmunityFlag, sizeof(g_sAdminImmunityFlag)); - g_fTimer_ScrambleDelay = GetConVarFloat(sas_timer_scrambledelay); - g_fVote_UpCount = GetConVarFloat(sas_vote_upcount); - g_fVote_WinPercent = GetConVarFloat(sas_vote_winpercent); - g_iMaxEntities = GetMaxEntities(); - g_iOwnerOffset = FindSendPropInfo("CBaseObject", "m_hBuilder"); -} - -stock TF2_DestroyBuildings(client) -{ - - /** - We have to start a loop to check the owner of all the valid entities - */ - for (new i = MaxClients + 1; i <= g_iMaxEntities; i++) - { - if (!IsValidEntity(i)) - { - - /** - Not valid, continue to next one - */ - continue; - } - - /** - Get the name of the current entity - */ - decl String:sNetClass[32]; - GetEntityNetClass(i, sNetClass, sizeof(sNetClass)); - - /** - See if its something that an engineer would build - */ - if (strcmp(sNetClass, "CObjectSentrygun") == 0 - || strcmp(sNetClass, "CObjectTeleporter") == 0 - || strcmp(sNetClass, "CObjectDispenser") == 0) - { - - /** - It is, so lets check the owner - */ - if (GetEntDataEnt2(i, g_iOwnerOffset) == client) - { - - /** - It's the clients building, so we blow it up. - */ - SetVariantInt(9999); - AcceptEntityInput(i, "RemoveHealth"); - } - } - } -} \ No newline at end of file diff --git a/Simple Donator Benefits/addons/sourcemod/scripting/simple-chatcolors.sp b/Simple Donator Benefits/addons/sourcemod/scripting/simple-chatcolors.sp deleted file mode 100644 index 539d057..0000000 --- a/Simple Donator Benefits/addons/sourcemod/scripting/simple-chatcolors.sp +++ /dev/null @@ -1,496 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Chat Colors -Description: - Changes the colors of players chat based on config file -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#pragma semicolon 1 -#include -#include - -#define PLUGIN_VERSION "0.9.0.$Rev$" - -#define CHAT_SYMBOL '@' -#define TRIGGER_SYMBOL1 '!' -#define TRIGGER_SYMBOL2 '/' -#define CHAT_MAX_MESSAGE_LENGTH 1024 - -new Handle:g_hDebugCvar = INVALID_HANDLE; -new Handle:g_aGroupNames = INVALID_HANDLE; -new Handle:g_aGroupFlag = INVALID_HANDLE; -new Handle:g_aGroupNameColor = INVALID_HANDLE; -new Handle:g_aGroupTextColor = INVALID_HANDLE; - -new bool:g_bDebug = false; - -new g_iArraySize; - -new g_aPlayerColorIndex[MAXPLAYERS + 1] = { -1, ... }; - -public Plugin:myinfo = -{ - name = "Simple Chat Colors", - author = "Simple Plugins", - description = "Changes the colors of players chat based on config file.", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -}; - -/** -Sourcemod callbacks -*/ -public OnPluginStart() -{ - - /** - Need to create all of our console variables. - */ - CreateConVar("sm_chatcolors_version", PLUGIN_VERSION, "Simple Chat Colors", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - g_hDebugCvar = CreateConVar("sm_chatcolors_debug", "1", "Enable/Disable debugging information"); - - /** - Hook console variables - */ - HookConVarChange(g_hDebugCvar, ConVarSettingsChanged); - - /** - Need to register the commands we are going to use - */ - RegConsoleCmd("say", Command_Say); - RegConsoleCmd("say_team", Command_SayTeam); - RegAdminCmd("sm_reloadcolorsconfig", Command_Reload, ADMFLAG_GENERIC, "Reloads settings from config file"); - - /** - Create the arrays - */ - g_aGroupNames = CreateArray(256, 1); - g_aGroupFlag = CreateArray(15, 1); - g_aGroupNameColor = CreateArray(15, 1); - g_aGroupTextColor = CreateArray(15, 1); - - /** - Load the admins and colors from the config - */ - LoadAdminsAndColorsFromConfig(); - g_iArraySize = GetArraySize(g_aGroupNames); -} - -public OnConfigsExecuted() -{ - g_bDebug = GetConVarBool(g_hDebugCvar); - ReloadConfigFile(); -} - -public OnClientPostAdminCheck(client) -{ - - /** - Check the client to see if they are a admin - */ - CheckAdmin(client); -} - -public OnClientDisconnect(client) -{ - g_aPlayerColorIndex[client] = -1; -} - -/** -Commands -*/ -public Action:Command_Say(client, args) -{ - - /** - Make sure we are enabled. - */ - if (client == 0 || IsChatTrigger()) - { - return Plugin_Continue; - } - - if (g_aPlayerColorIndex[client] != -1) - { - - /** - The client is, so get the chat message and strip it down. - */ - decl String:sArg[CHAT_MAX_MESSAGE_LENGTH], - String:sChatMsg[CHAT_MAX_MESSAGE_LENGTH]; - - new bool:bAlive = IsPlayerAlive(client); - - GetCmdArgString(sArg, sizeof(sArg)); - StripQuotes(sArg); - TrimString(sArg); - new startidx; - if (sArg[strlen(sArg)-1] == '"') - { - sArg[strlen(sArg)-1] = '\0'; - startidx = 1; - } - - /** - Bug out if they are using the admin chat symbol (admin chat). If we are in CSS it may not find all the triggers, so we double check. - */ - if (sArg[startidx] == CHAT_SYMBOL || sArg[startidx] == TRIGGER_SYMBOL1 || sArg[startidx] == TRIGGER_SYMBOL2) - { - return Plugin_Continue; - } - - /** - Log the message for hlstatsx and other things. - */ - new iUserID = GetClientUserId(client); - decl String:sAuthID[64]; - GetClientAuthString(client, sAuthID, sizeof(sAuthID)); - LogToGame("\"%N<%i><%s><>\" say \"%s\"", client, iUserID, sAuthID, sArg); - - /** - Format the message. - */ - FormatMessage(client, 0, bAlive, sChatMsg, sArg, g_aPlayerColorIndex[client]); - - /** - Send the message. - */ - //SayText2(0, client, sChatMsg); - CPrintToChatAll(sChatMsg); - - /** - We are done, bug out, and stop the original chat message. - */ - return Plugin_Stop; - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -public Action:Command_SayTeam(client, args) -{ - - /** - Make sure we are enabled. - */ - if (client == 0 || IsChatTrigger()) - { - return Plugin_Continue; - } - - /** - Check the client to see if they are a admin - */ - if (g_aPlayerColorIndex[client] != -1) - { - - /** - The client is, so get the chat message and strip it down. - */ - decl String:sArg[CHAT_MAX_MESSAGE_LENGTH], - String:sChatMsg[CHAT_MAX_MESSAGE_LENGTH]; - - new bool:bAlive = IsPlayerAlive(client); - new iCurrentTeam = GetClientTeam(client); - - GetCmdArgString(sArg, sizeof(sArg)); - StripQuotes(sArg); - TrimString(sArg); - new startidx; - if (sArg[strlen(sArg)-1] == '"') - { - sArg[strlen(sArg)-1] = '\0'; - startidx = 1; - } - - /** - Bug out if they are using the admin chat symbol (admin chat). - */ - if (sArg[startidx] == CHAT_SYMBOL || sArg[startidx] == TRIGGER_SYMBOL1 || sArg[startidx] == TRIGGER_SYMBOL2) - { - return Plugin_Continue; - } - - /** - Log the message for hlstatsx and other things. - */ - new iUserID = GetClientUserId(client); - decl String:sAuthID[64]; - GetClientAuthString(client, sAuthID, sizeof(sAuthID)); - LogToGame("\"%N<%i><%s><>\" say_team \"%s\"", client, iUserID, sAuthID, sArg); - - /** - Format the message. - */ - FormatMessage(client, iCurrentTeam, bAlive, sChatMsg, sArg, g_aPlayerColorIndex[client]); - - /** - Send the message to the same team - */ - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientConnected(i) && IsClientInGame(i) && GetClientTeam(i) == iCurrentTeam) - { - CPrintToChat(client, sChatMsg); - } - } - - /** - We are done, bug out, and stop the original chat message. - */ - return Plugin_Stop; - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -public Action:Command_Reload(client, args) -{ - ReloadConfigFile(); - return Plugin_Handled; -} - -/** -Stock Functions -*/ -stock LoadAdminsAndColorsFromConfig() -{ - - /** - Make sure the config file is here and load it up - */ - new String:sConfigFile[256]; - BuildPath(Path_SM, sConfigFile, sizeof(sConfigFile), "configs/simple-chatcolors.cfg"); - if (!FileExists(sConfigFile)) - { - - /** - Config file doesn't exists, stop the plugin - */ - LogError("[SCC] Simple Chat Colors is not running! Could not find file %s", sConfigFile); - SetFailState("Could not find file %s", sConfigFile); - } - - /** - Create the arrays and variables - */ - new String:sGroupName[256]; - new String:sGroupFlag[15]; - new String:sGroupNameColor[15]; - new String:sGroupTextColor[15]; - - - /** - Load config file as a KeyValues file - */ - new Handle:kvChatColors = CreateKeyValues("admin_colors"); - FileToKeyValues(kvChatColors, sConfigFile); - - if (!KvGotoFirstSubKey(kvChatColors)) - { - return; - } - - /** - Load up all the groups in the file - */ - do - { - - /** - Get the section name; should be the "group" name - */ - KvGetSectionName(kvChatColors, sGroupName, sizeof(sGroupName)); - - - /** - Get the flags and colors - */ - KvGetString(kvChatColors, "flag", sGroupFlag, sizeof(sGroupFlag)); - KvGetString(kvChatColors, "namecolor", sGroupNameColor, sizeof(sGroupNameColor)); - KvGetString(kvChatColors, "textcolor", sGroupTextColor, sizeof(sGroupTextColor)); - - if (g_bDebug) - { - LogMessage("Group Name/SteamID: %s", sGroupName); - LogMessage("Flag String: %s", sGroupFlag); - LogMessage("Color on name: %s", sGroupNameColor); - LogMessage("Color of text: %s", sGroupTextColor); - } - - /** - Push the values to the arrays - */ - PushArrayString(g_aGroupNames, sGroupName); - PushArrayString(g_aGroupFlag, sGroupFlag); - PushArrayString(g_aGroupNameColor, sGroupNameColor); - PushArrayString(g_aGroupTextColor, sGroupTextColor); - } while (KvGotoNextKey(kvChatColors)); - - /** - Close our handle - */ - CloseHandle(kvChatColors); -} - -stock ReloadConfigFile() -{ - - /** - Clear the array - */ - ClearArray(g_aGroupNames); - ClearArray(g_aGroupFlag); - ClearArray(g_aGroupNameColor); - ClearArray(g_aGroupTextColor); - - /** - Load the admins, groups, and colors from the config - */ - LoadAdminsAndColorsFromConfig(); - g_iArraySize = GetArraySize(g_aGroupNames); - - /** - Recheck all the online players for assigned colors - */ - for (new index = 1; index <= MaxClients; index++) - { - if (IsClientConnected(index) && IsClientInGame(index)) - { - CheckAdmin(index); - } - } -} - -stock CheckAdmin(client) -{ - new String:sFlags[15]; - new String:sClientSteamID[64]; - new iGroupFlags; - new iFlags; - new iIndex = -1; - - /** - Look for a steamid first - */ - GetClientAuthString(client, sClientSteamID, sizeof(sClientSteamID)); - iIndex = FindStringInArray(g_aGroupNames, sClientSteamID); - if (iIndex != -1) - { - g_aPlayerColorIndex[client] = iIndex; - } - - /** - Didn't find one, check flags - */ - else - { - /** - Search for flag in groups - */ - - iFlags = GetUserFlagBits(client); - for (iIndex = 0; iIndex < g_iArraySize; iIndex++) - { - GetArrayString(g_aGroupFlag, iIndex, sFlags, sizeof(sFlags)); - iGroupFlags = ReadFlagString(sFlags); - if (iFlags & iGroupFlags) - { - g_aPlayerColorIndex[client] = iIndex; - break; - } - } - } - - if (g_bDebug) - { - PrintToChatAll("SteamID: %s", sClientSteamID); - PrintToChatAll("Array Index: %i", iIndex); - PrintToChatAll("Flag String: %s", sFlags); - PrintToChatAll("Flag Bits of Client: %i", iFlags); - PrintToChatAll("Flag Bits of Group: %i", iGroupFlags); - } -} - -stock FormatMessage(iClient, iTeam, bool:bAlive, String:sChatMsg[], const Sting:sMessage[], iArrayIndex) -{ - decl String:sDead[10], - String:sTeam[10], - String:sClientName[64]; - - GetClientName(iClient, sClientName, sizeof(sClientName)); - - if (iTeam != 0) - { - Format(sTeam, sizeof(sTeam), "(TEAM) "); - } - else - { - Format(sTeam, sizeof(sTeam), ""); - } - if (bAlive) - { - Format(sDead, sizeof(sDead), ""); - } - else - { - Format(sDead, sizeof(sDead), "*DEAD* "); - } - - new String:sNameColor[15]; - new String:sTextColor[15]; - GetArrayString(g_aGroupNameColor, iArrayIndex, sNameColor, sizeof(sNameColor)); - GetArrayString(g_aGroupTextColor, iArrayIndex, sTextColor, sizeof(sTextColor)); - - Format(sChatMsg, CHAT_MAX_MESSAGE_LENGTH, "{default}%s%s%s%s {default}: %s%s", sDead, sTeam, sNameColor, sClientName, sTextColor, sMessage); -} - -/** -Adjust the settings if a convar was changed -*/ -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (StringToInt(newValue) == 1) - { - g_bDebug = true; - } - else - { - g_bDebug = false; - } -} \ No newline at end of file diff --git a/Simple Donator Benefits/addons/sourcemod/scripting/simple-messagesuppression.sp b/Simple Donator Benefits/addons/sourcemod/scripting/simple-messagesuppression.sp deleted file mode 100644 index f7725a4..0000000 --- a/Simple Donator Benefits/addons/sourcemod/scripting/simple-messagesuppression.sp +++ /dev/null @@ -1,227 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Message Suppression -Description: - Blocks Specific Message Outputs -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include -#include - -#define SUPPRESS_VERSION "1.1.$Rev$" - -public Plugin:myinfo = -{ - name = "Simple Message Suppression", - author = "FlyingMongoose, psychonic", - description = "Blocks Specific Message Outputs", - version = SUPPRESS_VERSION, - url = "http://www.simple-plugins.com/" -} - -new Handle:cvarBlockSpectateMessage; -new Handle:cvarBlockDisconnectMessage; -new Handle:cvarBlockConnectMessage; -new Handle:cvarAdminShowMessages; -new iSpecTeam = 1; - - -public OnPluginStart() -{ - CreateConVar("suppress_version", SUPPRESS_VERSION, _, FCVAR_PLUGIN|FCVAR_NOTIFY|FCVAR_REPLICATED|FCVAR_SPONLY|FCVAR_DONTRECORD); - cvarBlockSpectateMessage = CreateConVar("sm_blockspectatemessage", "1", "If enabled it blocks the join team message if an administrator joins spectator", FCVAR_PLUGIN, true, 0.0, true, 1.0); - cvarBlockDisconnectMessage = CreateConVar("sm_blockdisconnectmessage", "1", "Blocks the disconnect message", FCVAR_PLUGIN, true, 0.0, true, 1.0); - cvarBlockConnectMessage = CreateConVar("sm_blockconnectmessage", "1", "If enabled it blocks the player connection message.", FCVAR_PLUGIN, true, 0.0, true, 1.0); - cvarAdminShowMessages = CreateConVar("sm_adminshowmessages", "1", "Shows disconnect/connect/team join messages for admins only (if disconnect message is set to be blocked)", FCVAR_PLUGIN, true, 0.0, true, 1.0); - HookEvent("player_team", ev_PlayerTeam, EventHookMode_Pre); - HookEvent("player_disconnect", ev_PlayerDisconnect, EventHookMode_Pre); - HookEvent("player_connect", ev_PlayerConnect, EventHookMode_Pre); - - new String:game_folder[64]; - GetGameFolderName(game_folder, sizeof(game_folder)) - - if (StrContains(game_folder, "insurgency", false) != -1) - { - iSpecTeam = 3; - } - else - { - new String:game_description[64]; - GetGameDescription(game_description, sizeof(game_description), true); - if (StrContains(game_description, "Insurgency", false) != -1) - { - iSpecTeam = 3; - } - } - - AutoExecConfig(true, "suppressmessage", "sourcemod"); -} - -public Action:ev_PlayerTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - if (GetConVarBool(cvarBlockSpectateMessage)) - { - if (!dontBroadcast && !GetEventBool(event, "silent")) - { - new iUserId = GetEventInt(event, "userid"); - new iClient = GetClientOfUserId(iUserId); - new iTeam = GetEventInt(event, "team"); - - if (iTeam == iSpecTeam && GetAdminFlag(GetUserAdmin(iClient), Admin_Kick)) - { - new iOldTeam = GetEventInt(event, "oldteam"); - new bool:bDisconnect = GetEventBool(event, "disconnect"); - new bool:bAutoteam = GetEventBool(event, "autoteam"); - decl String:strName[50]; - GetEventString(event, "name", strName, sizeof(strName)); - - if (iClient != 0) - { - if (GetConVarInt(cvarAdminShowMessages) == 1) - { - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientConnected(i) && IsClientInGame(i) && GetUserAdmin(i) != INVALID_ADMIN_ID) - { - PrintToChat(i,"%N joined team Spectator.", iClient); - PrintToConsole(i,"%N joined team Spectator.", iClient); - } - } - } - } - - new Handle:hEvent = CreateEvent("player_team"); - SetEventInt(hEvent, "userid", iUserId); - SetEventInt(hEvent, "team", iTeam); - SetEventInt(hEvent, "oldteam", iOldTeam); - SetEventBool(hEvent, "disconnect", bDisconnect); - SetEventBool(hEvent, "autoteam", bAutoteam); - SetEventBool(hEvent, "silent", true); - SetEventString(hEvent, "name", strName); - - FireEvent(hEvent, true); - - return Plugin_Handled; - } - } - } - return Plugin_Continue; -} -public Action:ev_PlayerConnect(Handle:event, const String:name[], bool:dontBroadcast) -{ - if (GetConVarBool(cvarBlockConnectMessage)) - { - if (!dontBroadcast) - { - decl String:strName[50]; - GetEventString(event, "name", strName, sizeof(strName)); - new iIndex = GetEventInt(event, "index"); - new iUserId = GetEventInt(event, "userid"); - new iClient = GetClientOfUserId(iUserId); - decl String:strNetworkId[50]; - GetEventString(event, "networkid", strNetworkId, sizeof(strNetworkId)); - decl String:strAddress[50]; - GetEventString(event, "address", strAddress, sizeof(strAddress)); - - if (iClient != 0) - { - if (GetConVarInt(cvarAdminShowMessages) == 1) - { - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientConnected(i) && IsClientInGame(i) && GetUserAdmin(i) != INVALID_ADMIN_ID) - { - PrintToChat(i,"%N has connected.", iClient); - PrintToConsole(i,"%N has connected.", iClient); - } - } - } - } - - new Handle:hEvent = CreateEvent("player_connect"); - SetEventString(hEvent, "name", strName); - SetEventInt(hEvent, "index", iIndex); - SetEventInt(hEvent, "userid", iUserId); - SetEventString(hEvent, "networkid", strNetworkId); - SetEventString(hEvent, "address", strAddress); - - FireEvent(hEvent, true); - - return Plugin_Handled; - } - } - return Plugin_Continue; -} -public Action:ev_PlayerDisconnect(Handle:event, const String:name[], bool:dontBroadcast) -{ - if (GetConVarBool(cvarBlockDisconnectMessage)) - { - if (!dontBroadcast) - { - new iUserId = GetEventInt(event, "userid"); - new iClient = GetClientOfUserId(iUserId); - decl String:strReason[50]; - GetEventString(event, "reason", strReason, sizeof(strReason)); - decl String:strName[50]; - GetEventString(event, "name", strName, sizeof(strName)); - decl String:strNetworkId[50]; - GetEventString(event, "networkid", strNetworkId, sizeof(strNetworkId)); - - if (iClient != 0) - { - if (GetConVarInt(cvarAdminShowMessages) == 1) - { - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientConnected(i) && IsClientInGame(i) && GetUserAdmin(i) != INVALID_ADMIN_ID) - { - PrintToChat(i, "%N has left the server.", iClient); - PrintToConsole(i, "Dropped %N from server (Disconnect by user.)", iClient); - } - } - } - } - - new Handle:hEvent = CreateEvent("player_disconnect"); - SetEventInt(hEvent, "userid", iUserId); - SetEventString(hEvent, "reason", strReason); - SetEventString(hEvent, "name", strName); - SetEventString(hEvent, "networkid", strNetworkId); - - FireEvent(hEvent, true); - - return Plugin_Handled; - } - } - - return Plugin_Continue; -} \ No newline at end of file diff --git a/Simple Donator Benefits/addons/sourcemod/scripting/simple-plugins.sp b/Simple Donator Benefits/addons/sourcemod/scripting/simple-plugins.sp deleted file mode 100644 index 4462b41..0000000 --- a/Simple Donator Benefits/addons/sourcemod/scripting/simple-plugins.sp +++ /dev/null @@ -1,785 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Plugins -Description: - Core plugin for Simple Plugins project -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#define CORE_PLUGIN_VERSION "1.1.$Rev$" - -#include - -enum e_PlayerInfo -{ - Handle:hForcedTeamPlugin = INVALID_HANDLE, - iForcedTeam = 0, - iBuddy = 0, - bool:bBuddyLocked = false -}; - -new Handle:g_fwdPlayerMoved; -new g_aPlayers[MAXPLAYERS + 1][e_PlayerInfo]; -new bool:g_bTeamsSwitched = false; - -/** -Setting our plugin information. -*/ -public Plugin:myinfo = -{ - name = "Simple Plugins Core Plugin", - author = "Simple Plugins", - description = "Core plugin for Simple Plugins", - version = CORE_PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -}; - -public bool:AskPluginLoad(Handle:myself, bool:late, String:error[], err_max) -{ - - /** - Register natives for other plugins - */ - CreateNative("SM_MovePlayer", Native_SM_MovePlayer); - CreateNative("SM_SetForcedTeam", Native_SM_SetForcedTeam); - CreateNative("SM_GetForcedTeam", Native_SM_GetForcedTeam); - CreateNative("SM_ClearForcedTeam", Native_SM_ClearForcedTeam); - CreateNative("SM_GetForcedPlayer", Native_SM_GetForcedPlayer); - CreateNative("SM_AssignBuddy", Native_SM_AssignBuddy); - CreateNative("SM_GetClientBuddy", Native_SM_GetClientBuddy); - CreateNative("SM_LockBuddy", Native_SM_LockBuddy); - CreateNative("SM_IsBuddyLocked", Native_SM_IsBuddyLocked); - CreateNative("SM_ClearBuddy", Native_SM_ClearBuddy); - CreateNative("SM_IsValidAdmin", Native_SM_IsValidAdmin); - CreateNative("SM_IsValidTeam", Native_SM_IsValidTeam); - RegPluginLibrary("simpleplugins"); - return true; -} - -public OnPluginStart() -{ - - CreateConVar("ssm_core_pl_ver", CORE_PLUGIN_VERSION, "Simple SourceMod Plugins Core Plugin Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - CreateConVar("ssm_core_inc_ver", CORE_INC_VERSION, "Simple SourceMod Plugins Core Include Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook some events to control forced players and check extensions - */ - decl String:sExtError[256]; - LogAction(0, -1, "[SSM] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_team", HookPlayerChangeTeam, EventHookMode_Pre); - switch (g_CurrentMod) - { - case GameType_CSS: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - new iExtStatus = GetExtensionFileStatus("game.cstrike.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SSM] Required extension was not found."); - LogAction(0, -1, "[SSM] Plugin FAILED TO LOAD."); - SetFailState("Required extension was not found."); - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SSM] Required extension is loaded with errors."); - LogAction(0, -1, "[SSM] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SSM] Plugin FAILED TO LOAD."); - SetFailState("Required extension is loaded with errors."); - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SSM] Required extension is loaded."); - } - } - case GameType_TF: - { - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_PostNoCopy); - HookUserMessage(GetUserMessageId("TextMsg"), UserMessageHook_Class, true); - new iExtStatus = GetExtensionFileStatus("game.tf2.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SSM] Required extension was not found."); - LogAction(0, -1, "[SSM] Plugin FAILED TO LOAD."); - SetFailState("Required extension was not found."); - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SSM] Required extension is loaded with errors."); - LogAction(0, -1, "[SSM] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SSM] Plugin FAILED TO LOAD."); - SetFailState("Required extension is loaded with errors."); - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SSM] Required extension is loaded."); - } - } - case GameType_DOD: - { - HookEvent("dod_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_PostNoCopy); - } - default: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - } - } - - /** - Load common translations - */ - LoadTranslations ("common.phrases"); - - /** - Create the global forward - */ - g_fwdPlayerMoved = CreateGlobalForward("SM_OnPlayerMoved", ET_Event, Param_Cell, Param_Cell, Param_Cell); -} - -public OnClientDisconnect(client) -{ - - /** - Cleanup clients/players buddy list - */ - if (!IsFakeClient(client)) - { - SM_ClearBuddy(client, true); - SM_LockBuddy(client, false); - } - SM_ClearForcedTeam(client); -} - -public HookRoundStart(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - See if the teams have been switched - */ - if (g_bTeamsSwitched) - { - - /** - Switch the teams the players are forced to - */ - for (new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][iForcedTeam] != 0) - { - if (g_aPlayers[i][iForcedTeam] == g_aCurrentTeams[Team1]) - { - g_aPlayers[i][iForcedTeam] = g_aCurrentTeams[Team2]; - } - else - { - g_aPlayers[i][iForcedTeam] = g_aCurrentTeams[Team1]; - } - } - } - } -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - g_bTeamsSwitched = false; -} - -public HookPlayerChangeTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get our event variables - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - new iTeam = GetEventInt(event, "team"); - - /** - See if the player is on the wrong team - */ - if (g_aPlayers[iClient][iForcedTeam] != 0 && g_aPlayers[iClient][iForcedTeam] != iTeam) - { - - /** - Move the player back to the forced team - */ - CreateTimer(1.0, Timer_ForcePlayerMove, iClient, TIMER_FLAG_NO_MAPCHANGE); - - /** - If the event was going to be broadcasted, we refire it so it is not broadcasted and stop this one - */ - if (!dontBroadcast) - { - new Handle:hEvent = CreateEvent("player_team"); - SetEventInt(hEvent, "userid", GetEventInt(event, "userid")); - SetEventInt(hEvent, "team", GetEventInt(event, "team")); - SetEventInt(hEvent, "oldteam", GetEventInt(event, "oldteam")); - SetEventBool(hEvent, "disconnect", GetEventBool(event, "disconnect")); - - if (g_CurrentMod == GameType_DOD || g_CurrentMod == GameType_L4D || g_CurrentMod == GameType_TF) - { - new String:sClientName[MAX_NAME_LENGTH + 1]; - GetClientName(client, sClientName, sizeof(sClientName)); - SetEventBool(hEvent, "autoteam", GetEventBool(event, "autoteam")); - SetEventBool(hEvent, "silent", true); - SetEventString(hEvent, "name", sClientName); - FireEvent(hEvent, true); - } - else - { - FireEvent(hEvent, true); - } - return Plugin_Handled; - } - } - return Plugin_Continue; -} - -public Action:UserMessageHook_Class(UserMsg:msg_id, Handle:bf, const players[], playersNum, bool:reliable, bool:init) -{ - new String:sMessage[120]; - BfReadString(bf, sMessage, sizeof(sMessage), true); - if (StrContains(sMessage, "#TF_TeamsSwitched", false) != -1) - { - g_bTeamsSwitched = true; - } - return Plugin_Continue; -} - -public Native_SM_MovePlayer(Handle:plugin, numParams) -{ - - /** - Get and check the client and team - */ - new iClient = GetNativeCell(1); - new iTeam = GetNativeCell(2); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (iTeam != g_aCurrentTeams[Spectator] && iTeam != g_aCurrentTeams[Team1] && iTeam != g_aCurrentTeams[Team2]) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid team %d", iTeam); - } - - MovePlayer(iClient, iTeam); - if (!IsClientObserver(iClient)) - { - RespawnPlayer(iClient); - } - - new fResult; - - Call_StartForward(g_fwdPlayerMoved); - Call_PushCell(plugin); - Call_PushCell(iClient); - Call_PushCell(iTeam); - Call_Finish(fResult); - - if (fResult != SP_ERROR_NONE) - { - return ThrowNativeError(fResult, "Forward failed"); - } - - return fResult; -} - -public Native_SM_SetForcedTeam(Handle:plugin, numParams) -{ - - /** - Get and check the client and team - */ - new iClient = GetNativeCell(1); - new iTeam = GetNativeCell(2); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (iTeam != g_aCurrentTeams[Spectator] && iTeam != g_aCurrentTeams[Team1] && iTeam != g_aCurrentTeams[Team2] && iTeam != g_aCurrentTeams[Unknown]) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid team %d", iTeam); - } - - new bool:bOverRide = GetNativeCell(3) ? true : false; - - if (!bOverRide && g_aPlayers[iClient][hForcedTeamPlugin] != INVALID_HANDLE && plugin != g_aPlayers[iClient][hForcedTeamPlugin]) - { - return false; - } - - g_aPlayers[iClient][hForcedTeamPlugin] = plugin; - g_aPlayers[iClient][iForcedTeam] = iTeam; - return true; -} - -public Native_SM_GetForcedTeam(Handle:plugin, numParams) -{ - - /** - Get and check the client - */ - new iClient = GetNativeCell(1); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - - /** - Get and set the plugin if they want it - */ - new Handle:hPlugin = GetNativeCell(2); - if (hPlugin != INVALID_HANDLE) - { - SetNativeCellRef(2, g_aPlayers[iClient][hForcedTeamPlugin]); - } - - /** - Return the forced team, this could be 0 - */ - return g_aPlayers[iClient][iForcedTeam]; -} - -public Native_SM_ClearForcedTeam(Handle:plugin, numParams) -{ - - /** - Get and check the client and team - */ - new iClient = GetNativeCell(1); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - - g_aPlayers[iClient][hForcedTeamPlugin] = INVALID_HANDLE; - g_aPlayers[iClient][iForcedTeam] = 0; - - return true; -} - -public Native_SM_GetForcedPlayer(Handle:plugin, numParams) -{ - - /** - Get and check the team - */ - new iTeam = GetNativeCell(1); - if (iTeam != g_aCurrentTeams[Spectator] && iTeam != g_aCurrentTeams[Team1] && iTeam != g_aCurrentTeams[Team2]) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid team %d", iTeam); - } - - /** - Start a loop to check for a player on the wrong team - Also make sure the plugin that set the forced team is the plugin that asked - */ - new iPlayer = 0; - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientInGame(i) - && GetClientTeam(i) != g_aPlayers[i][iForcedTeam] - && g_aPlayers[i][iForcedTeam] == iTeam - && g_aPlayers[i][hForcedTeamPlugin] == plugin) - { - iPlayer = i; - break; - } - } - - /** - Return the player we found, this could be 0 - */ - return iPlayer; -} - -public Native_SM_AssignBuddy(Handle:plugin, numParams) -{ - - /** - Get and check the client and player - */ - new iClient = GetNativeCell(1); - new iPlayer = GetNativeCell(2); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (iPlayer < 0 || iPlayer > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid player index (%d)", iPlayer); - } - if (!IsClientConnected(iPlayer)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Player %d is not connected", iPlayer); - } - if (!IsClientInGame(iPlayer)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Player %d is not in the game", iClient); - } - if (IsFakeClient(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Bots are not supported"); - } - - /** - See if we can override his setting - */ - new bool:bOverRide = GetNativeCell(3) ? true : false; - if (!bOverRide) - { - - /** - We can't override, so check if they are locked - */ - if (g_aPlayers[iClient][bBuddyLocked] || g_aPlayers[iPlayer][bBuddyLocked]) - { - - /** - We detected at least 1 lock, so we bug out - */ - return false; - } - } - - /** - Ready to set the buddies - */ - g_aPlayers[iClient][iBuddy] = iPlayer; - g_aPlayers[iPlayer][iBuddy] = iClient; - return true; -} - -public Native_SM_GetClientBuddy(Handle:plugin, numParams) -{ - - /** - Get and check the client - */ - new iClient = GetNativeCell(1); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (IsFakeClient(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Bots are not supported"); - } - - /** - Return the players buddy, this could be 0 - */ - return g_aPlayers[iClient][iBuddy]; -} - -public Native_SM_LockBuddy(Handle:plugin, numParams) -{ - - /** - Get and check the client - */ - new iClient = GetNativeCell(1); - new bool:bSetting = GetNativeCell(2) ? true : false; - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (IsFakeClient(iClient)) - { - return ThrowNativeError(SP_ERROR_NATIVE, "Bots are not supported"); - } - - g_aPlayers[iClient][bBuddyLocked] = bSetting; - return true; -} - -public Native_SM_IsBuddyLocked(Handle:plugin, numParams) -{ - - /** - Get and check the client - */ - new iClient = GetNativeCell(1); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (IsFakeClient(iClient)) - { - return ThrowNativeError(SP_ERROR_NATIVE, "Bots are not supported"); - } - - return g_aPlayers[iClient][bBuddyLocked]; -} - -public Native_SM_ClearBuddy(Handle:plugin, numParams) -{ - - /** - Get and check the client - */ - new iClient = GetNativeCell(1); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_NATIVE, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_NATIVE, "Client (%d) is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (IsFakeClient(iClient)) - { - return ThrowNativeError(SP_ERROR_NATIVE, "Bots are not supported"); - } - - /** - Get the clients buddy and see if we can override his setting - */ - new bool:bOverRide = GetNativeCell(2) ? true : false; - new iPlayer = g_aPlayers[iClient][iBuddy]; - - /** - There is no buddy, we don't care about anything else so bug out - */ - if (iPlayer == 0) - { - return true; - } - - /** - We determined he had a buddy, check the override setting - */ - if (!bOverRide) - { - - /** - We can't override, so check if they are locked - */ - if (g_aPlayers[iClient][bBuddyLocked] || g_aPlayers[iPlayer][bBuddyLocked]) - { - - /** - We detected at least 1 lock, so we bug out - */ - return false; - } - } - - /** - Ready to clear the buddies - */ - g_aPlayers[iClient][iBuddy] = 0; - g_aPlayers[iPlayer][iBuddy] = 0; - return true; -} - -public Native_SM_IsValidTeam(Handle:plugin, numParams) -{ - - /** - Get the team - */ - new iTeam = GetNativeCell(1); - - /** - Check the team - */ - if (iTeam == g_aCurrentTeams[Spectator] || iTeam == g_aCurrentTeams[Team1] || iTeam == g_aCurrentTeams[Team2]) - { - return true; - } - return false; -} - -public Native_SM_IsValidAdmin(Handle:plugin, numParams) -{ - /** - Get the client and flags - */ - new iClient = GetNativeCell(1); - decl String:sFlags[15]; - GetNativeString(2, sFlags, sizeof(sFlags)); - new ibFlags = ReadFlagString(sFlags); - - /** - Check the flags - */ - if ((GetUserFlagBits(iClient) & ibFlags) == ibFlags) - { - return true; - } - if (GetUserFlagBits(iClient) & ADMFLAG_ROOT) - { - return true; - } - return false; -} - -public Action:Timer_ForcePlayerMove(Handle:timer, any:iClient) -{ - - MovePlayer(iClient, g_aPlayers[iClient][iForcedTeam]); - - if (g_aPlayers[iClient][iForcedTeam] != g_aCurrentTeams[Spectator]) - { - RespawnPlayer(iClient); - } - - PrintToChat(iClient, "\x01\x04----------------------------------"); - PrintToChat(iClient, "\x01\x04You have been forced to this team."); - PrintToChat(iClient, "\x01\x04----------------------------------"); - - return Plugin_Handled; -} - -stock MovePlayer(iClient, iTeam) -{ - - /** - Change the client's team based on the mod - */ - switch (g_CurrentMod) - { - case GameType_CSS: - { - CS_SwitchTeam(iClient, iTeam); - } - default: - { - ChangeClientTeam(iClient, iTeam); - } - } -} - -stock RespawnPlayer(iClient) -{ - - /** - Respawn the client based on the mod - */ - switch (g_CurrentMod) - { - case GameType_CSS: - { - CS_RespawnPlayer(iClient); - } - case GameType_TF: - { - TF2_RespawnPlayer(iClient); - } - case GameType_INS: - { - FakeClientCommand(iClient, "kill"); - } - default: - { - // - } - } -} diff --git a/Simple Donator Benefits/addons/sourcemod/scripting/simple-roundimmunity.sp b/Simple Donator Benefits/addons/sourcemod/scripting/simple-roundimmunity.sp deleted file mode 100644 index 5f0bca3..0000000 --- a/Simple Donator Benefits/addons/sourcemod/scripting/simple-roundimmunity.sp +++ /dev/null @@ -1,947 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Round Immunity -Description: - Gives admins immunity during certain rounds -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or any later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#pragma semicolon 1 -#include -#include -#undef REQUIRE_EXTENSIONS -#undef AUTOLOAD_EXTENSIONS -#include -#include -#define REQUIRE_EXTENSIONS -#define AUTOLOAD_EXTENSIONS - -#define PLUGIN_VERSION "1.1.$Rev$" -#define SPECTATOR 1 -#define TEAM_RED 2 -#define TEAM_BLUE 3 - -#define COLOR_GREEN 0 -#define COLOR_BLACK 1 -#define COLOR_RED 2 -#define COLOR_BLUE 3 -#define COLOR_TEAM 4 -#define COLOR_RAINBOW 5 -#define COLOR_NONE 6 - -#define PLAYERCOND_SLOWED (1<<0) //1 -#define PLAYERCOND_ZOOMED (1<<1) //2 -#define PLAYERCOND_DISGUISING (1<<2) //4 -#define PLAYERCOND_DISGUISED (1<<3) //8 -#define PLAYERCOND_SPYCLOAK (1<<4) //16 -#define PLAYERCOND_UBERED (1<<5) //32 -#define PLAYERCOND_TELEPORTTRAIL (1<<6) //64 -#define PLAYERCOND_TAUNT (1<<7) //128 -// (1<<8) //256 -// (1<<9) //512 -#define PLAYERCOND_TELEPORTFLASH (1<<10) //1024 -#define PLAYERCOND_KRUBER (1<<11) //2048 -// (1<<12) //4096 -// (1<<13) //8192 -#define PLAYERCOND_BONKED (1<<14) //16384 (blame Neph if it doesn't work) -#define PLAYERCOND_BONKEDORDRINKSLOWDOWN (1<<15) //32768 -#define PLAYERCOND_HEALING (1<<16) //65536 -#define PLAYERCOND_BURNING (1<<17) //131072 -#define PLAYERCOND_FULLYCHARGEDBYMEDIC (1<<18) //262144 - -enum e_Cookies -{ - bEnabled, - iColor, - iMode -}; - -enum e_ColorNames -{ - Green, - Black, - Red, - Blue -}; - -enum e_ColorValues -{ - iRed, - iGreen, - iBlue -}; - -enum e_PlayerData -{ - Handle:hGodModeTimer, - Handle:hColorTimer, - bool:bIsAdmin, - bool:bIsImmune, - iCycleColor -}; - -/** - Global convar handles - */ -new Handle:sri_charadminflag = INVALID_HANDLE; -new Handle:sri_enabled = INVALID_HANDLE; -new Handle:sri_cookie_enabled = INVALID_HANDLE; -new Handle:sri_cookie_color = INVALID_HANDLE; -new Handle:sri_cookie_mode = INVALID_HANDLE; - -/** - Player arrays - */ -new g_aPlayers[MAXPLAYERS + 1][e_PlayerData]; -new g_aClientCookies[MAXPLAYERS + 1][e_Cookies]; - -/** - Global bools - */ -new bool:g_bLoadedLate = false; -new bool:g_bIsEnabled = true; -new bool:g_bRoundEnd = false; -new bool:g_bUseDukehacks = false; -new bool:g_bUseClientprefs = false; - -/** - Global strings/integers/floats - */ -new String:g_sCharAdminFlag[32]; -new g_iColors[e_ColorNames][e_ColorValues]; -new g_iClassMaxHealth[TFClassType] = {0, 125, 125, 200, 175, 150, 300, 175, 125, 125}; - -public Plugin:myinfo = -{ - name = "Simple Round Immunity", - author = "Simple Plugins", - description = "Gives admins immunity during certain rounds", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -} - -bool:AskPluginLoad(Handle:myself, bool:late, String:error[], err_max) -{ - g_bLoadedLate = late; - return true; -} - -public OnPluginStart() -{ - - /** - Create console variables - */ - CreateConVar("sri_version", PLUGIN_VERSION, "Simple Round Immunity", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - sri_enabled = CreateConVar("sri_enabled", "1", "Enable/Disable Admin immunity during certain round."); - sri_charadminflag = CreateConVar("sri_charadminflag", "a", "Admin flag to use for immunity (only one). Must be a in char format."); - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook some events and check extensions - */ - decl String:sExtError[256]; - LogAction(0, -1, "[SRI] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_spawn", HookPlayerSpawn, EventHookMode_Post); - HookEvent("player_hurt", HookPlayerHurt, EventHookMode_Pre); - switch (g_CurrentMod) - { - case GameType_CSS: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - new iExtStatus = GetExtensionFileStatus("game.cstrike.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SRI] Required extension was not found."); - LogAction(0, -1, "[SRI] Plugin FAILED TO LOAD."); - SetFailState("Required extension was not found."); - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SRI] Required extension is loaded with errors."); - LogAction(0, -1, "[SRI] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SRI] Plugin FAILED TO LOAD."); - SetFailState("Required extension is loaded with errors."); - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SRI] Required css extension is loaded."); - } - } - case GameType_TF: - { - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_PostNoCopy); - HookUserMessage(GetUserMessageId("TextMsg"), UserMessageHook_Class, true); - new iExtStatus = GetExtensionFileStatus("game.tf2.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SRI] Required extension was not found."); - LogAction(0, -1, "[SRI] Plugin FAILED TO LOAD."); - SetFailState("Required extension was not found."); - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SRI] Required extension is loaded with errors."); - LogAction(0, -1, "[SRI] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SRI] Plugin FAILED TO LOAD."); - SetFailState("Required extension is loaded with errors."); - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SRI] Required tf2 extension is loaded."); - } - iExtStatus = GetExtensionFileStatus("dukehacks.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SRI] Dukehacks extension was not found."); - LogAction(0, -1, "[SRI] Plugin continued to load, but that feature will not be used."); - g_bUseDukehacks = false; - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SRI] Dukehacks extension is loaded with errors."); - LogAction(0, -1, "[SRI] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SRI] Plugin continued to load, but that feature will not be used."); - g_bUseDukehacks = false; - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SRI] Dukehacks extension is loaded and will be used."); - g_bUseDukehacks = true; - dhAddClientHook(CHK_TakeDamage, Hacks_TakeDamageHook); - } - } - case GameType_DOD: - { - HookEvent("dod_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_PostNoCopy); - } - default: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - } - } - /** - Now lets check for client prefs extension - */ - new iExtStatus = GetExtensionFileStatus("clientprefs.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SRI] Client Preferences extension was not found."); - LogAction(0, -1, "[SRI] Plugin continued to load, but that feature will not be used."); - g_bUseClientprefs = false; - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SRI] Client Preferences extension is loaded with errors."); - LogAction(0, -1, "[SRI] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SRI] Plugin continued to load, but that feature will not be used."); - g_bUseClientprefs = false; - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SRI] Client Preferences extension is loaded, checking database."); - if (!SQL_CheckConfig(clientprefs)) - { - LogAction(0, -1, "[SRI] No 'clientprefs' database found. Check your database.cfg file."); - LogAction(0, -1, "[SRI] Plugin continued to load, but Client Preferences will not be used."); - g_bUseClientprefs = false; - } - g_bUseClientprefs = true; - - /** - Deal with client cookies - */ - sri_cookie_enabled = RegClientCookie("bri_client_enabled", "Enable/Disable your immunity during the bonus round.", CookieAccess_Public); - sri_cookie_color = RegClientCookie("bri_client_color", "Color to render when immune.", CookieAccess_Public); - sri_cookie_mode = RegClientCookie("bri_client_mode", "God mode to select", CookieAccess_Public); - SetCookieMenuItem(CookieMenu_TopMenu, sri_cookie_enabled, "Bonus Round Immunity"); - } - - HookConVarChange(sri_enabled, EnabledChanged); - - RegAdminCmd("sm_immunity", Command_Immunity, ADMFLAG_ROOT, "sm_immunity: Gives you immunity"); - - LoadColors(); - - AutoExecConfig(true, "plugin.simpleroundimmunity"); -} - -public OnAllPluginsLoaded() -{ - //something - // need to deal with the unloading of dukehacks, clientprefs, and simpleplugins - // should move hooking the client prefs cookies to a function to make sure they are done post plugin start if ext is loaded late -} - -public OnLibraryRemoved(const String:name[]) -{ - //something - // need to deal with the loading of dukehacks, clientprefs, and simpleplugins -} - -public OnConfigsExecuted() -{ - GetConVarString(sri_charadminflag, g_sCharAdminFlag, sizeof(g_sCharAdminFlag)); - g_bIsEnabled = GetConVarBool(sri_enabled); - g_bRoundEnd = false; -} - -/** - Client events - */ - -public OnClientPostAdminCheck(client) -{ - if (SM_IsValidAdmin(client, g_sCharAdminFlag)) - g_aPlayers[client][bIsAdmin] = true; - else - g_aPlayers[client][bIsAdmin] = false; -} - -public OnClientCookiesCached(client) -{ - decl String:sEnabled[2], String:sColor[4], String:sMode[2]; - GetClientCookie(client, sri_cookie_enabled, sEnabled, sizeof(sEnabled)); - GetClientCookie(client, sri_cookie_color, sColor, sizeof(sColor)); - GetClientCookie(client, sri_cookie_mode, sMode, sizeof(sMode)); - g_aClientCookies[client][bEnabled] = StringToInt(sEnabled); - g_aClientCookies[client][iColor] = StringToInt(sColor); - g_aClientCookies[client][iMode] = StringToInt(sMode); -} - -public OnClientDisconnect(client) -{ - CleanUp(client); -} - -/** - Commands - */ - -public Action:Command_Immunity(client, args) -{ - if (g_aPlayers[client][IsImmune]) - { - DisableImmunity(client); - } - else - { - EnableImmunity(client); - } - return Plugin_Handled; -} - -/** - Event hooks - */ - -public Action:Hacks_TakeDamageHook(client, attacker, inflictor, Float:damage, &Float:multiplier, damagetype) -{ - if (attacker == 0 || attacker >= MaxClients) - { - return Plugin_Continue; - } - if (g_aPlayers[client][IsImmune]) - { - new TFClassType:PlayerClass = TF2_GetPlayerClass(attacker); - if (PlayerClass == TFClass_Spy) - { - multiplier *= 0.0; - return Plugin_Changed; - } - } - return Plugin_Continue; -} - -public HookRoundStart(Handle:event, const String:name[], bool:dontBroadcast) -{ - g_bRoundEnd = false; - if (g_bIsEnabled) - { - for (new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][IsImmune]) - { - DisableImmunity(i); - } - } - } -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - g_bRoundEnd = true; - if (g_bIsEnabled) - { - for (new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][bIsAdmin]) - { - EnableImmunity(i); - } - } - } -} - -public HookPlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast) -{ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - if (g_bIsEnabled && g_aPlayers[iClient][bIsAdmin] && g_bRoundEnd) - { - EnableImmunity(iClient); - } -} - -public Action:HookPlayerHurt(Handle:event, const String:name[], bool:dontBroadcast) -{ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - if (g_aPlayers[iClient][IsImmune]) - { - SetEntityHealth(iClient, 2000); - return Plugin_Continue; - } - return Plugin_Continue; -} - -/** - Cookie menus - */ - -public CookieMenu_TopMenu(client, CookieMenuAction:action, any:info, String:buffer[], maxlen) -{ - if (action == CookieMenuAction_DisplayOption) - { - //don't think we need to do anything - } - else - { - new Handle:hMenu = CreateMenu(Menu_CookieSettings); - SetMenuTitle(hMenu, "Options (Current Setting)"); - if (g_aClientCookies[client][bEnabled]) - { - AddMenuItem(hMenu, "enable", "Enabled/Disable (Enabled)"); - } - else - { - AddMenuItem(hMenu, "enable", "Enabled/Disable (Disabled)"); - } - if (g_aClientCookies[client][iMode]) - { - AddMenuItem(hMenu, "mode", "Immunity Mode Setting (God Mode)"); - } - else - { - AddMenuItem(hMenu, "mode", "Immunity Mode Setting (Health)"); - } - switch (g_aClientCookies[client][iColor]) - { - case COLOR_GREEN: - { - AddMenuItem(hMenu, "color", "Color (Green)"); - } - case COLOR_BLACK: - { - AddMenuItem(hMenu, "color", "Color (Black)"); - } - case COLOR_RED: - { - AddMenuItem(hMenu, "color", "Color (Red)"); - } - case COLOR_BLUE: - { - AddMenuItem(hMenu, "color", "Color (Blue)"); - } - case COLOR_TEAM: - { - AddMenuItem(hMenu, "color", "Color (Team)"); - } - case COLOR_RAINBOW: - { - AddMenuItem(hMenu, "color", "Color (Rainbow)"); - } - case COLOR_NONE: - { - AddMenuItem(hMenu, "color", "Color (None)"); - } - } - SetMenuExitBackButton(hMenu, true); - DisplayMenu(hMenu, client, MENU_TIME_FOREVER); - } -} - -public Menu_CookieSettings(Handle:menu, MenuAction:action, param1, param2) -{ - new client = param1; - if (action == MenuAction_Select) - { - new String:sSelection[24]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "enable", false)) - { - new Handle:hMenu = CreateMenu(Menu_CookieSettingsEnable); - SetMenuTitle(hMenu, "Enable/Disable Round End Immunity"); - - if (g_aClientCookies[client][bEnabled]) - { - AddMenuItem(hMenu, "enable", "Enable (Set)"); - AddMenuItem(hMenu, "disable", "Disable"); - } - else - { - AddMenuItem(hMenu, "enable", "Enabled"); - AddMenuItem(hMenu, "disable", "Disable (Set)"); - } - - SetMenuExitBackButton(hMenu, true); - DisplayMenu(hMenu, client, MENU_TIME_FOREVER); - } - else if (StrEqual(sSelection, "mode", false)) - { - new Handle:hMenu = CreateMenu(Menu_CookieSettingsMode); - SetMenuTitle(hMenu, "Set Immunity Mode"); - - if (g_aClientCookies[client][iMode]) - { - AddMenuItem(hMenu, "god", "God Mode (Set)"); - AddMenuItem(hMenu, "health", "Health"); - } - else - { - AddMenuItem(hMenu, "god", "God Mode"); - AddMenuItem(hMenu, "health", "Health (Set)"); - } - - SetMenuExitBackButton(hMenu, true); - DisplayMenu(hMenu, client, MENU_TIME_FOREVER); - } - else - { - new Handle:hMenu = CreateMenu(Menu_CookieSettingsColors); - SetMenuTitle(hMenu, "Select Immunity Color"); - switch (g_aClientCookies[client][iColor]) - { - case COLOR_GREEN: - { - AddMenuItem(hMenu, "Green", "Green (Set)"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_BLACK: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black (Set)"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_RED: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red (Set)"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_BLUE: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue (Set)"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_TEAM: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color (Set)"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_RAINBOW: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow (Set)"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_NONE: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None (Set)"); - } - } - SetMenuExitBackButton(hMenu, true); - DisplayMenu(hMenu, client, MENU_TIME_FOREVER); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - ShowCookieMenu(client); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } -} - -public Menu_CookieSettingsEnable(Handle:menu, MenuAction:action, param1, param2) -{ - new client = param1; - if (action == MenuAction_Select) - { - new String:sSelection[24]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "enable", false)) - { - SetClientCookie(client, sri_cookie_enabled, "1"); - g_aClientCookies[client][bEnabled] = 1; - PrintToChat(client, "[SM] Bonus Round Immunity is ENABLED"); - } - else - { - SetClientCookie(client, sri_cookie_enabled, "0"); - g_aClientCookies[client][bEnabled] = 0; - PrintToChat(client, "[SM] Bonus Round Immunity is DISABLED"); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - ShowCookieMenu(client); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } -} - -public Menu_CookieSettingsColors(Handle:menu, MenuAction:action, param1, param2) -{ - new client = param1; - if (action == MenuAction_Select) - { - new String:sSelection[24]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "Green", false)) - { - SetClientCookie(client, sri_cookie_color, "0"); - g_aClientCookies[client][iColor] = COLOR_GREEN; - PrintToChat(client, "[SM] Bonus Round Immunity color set to GREEN"); - } - else if (StrEqual(sSelection, "Black", false)) - { - SetClientCookie(client, sri_cookie_color, "1"); - g_aClientCookies[client][iColor] = COLOR_BLACK; - PrintToChat(client, "[SM] Bonus Round Immunity color set to BLACK"); - } - else if (StrEqual(sSelection, "Red", false)) - { - SetClientCookie(client, sri_cookie_color, "2"); - g_aClientCookies[client][iColor] = COLOR_RED; - PrintToChat(client, "[SM] Bonus Round Immunity color set to RED"); - } - else if (StrEqual(sSelection, "Blue", false)) - { - SetClientCookie(client, sri_cookie_color, "3"); - g_aClientCookies[client][iColor] = COLOR_BLUE; - PrintToChat(client, "[SM] Bonus Round Immunity color set to BLUE"); - } - else if (StrEqual(sSelection, "Team", false)) - { - SetClientCookie(client, sri_cookie_color, "4"); - g_aClientCookies[client][iColor] = COLOR_TEAM; - PrintToChat(client, "[SM] Bonus Round Immunity color set to TEAM COLOR"); - } - else if (StrEqual(sSelection, "Rain", false)) - { - SetClientCookie(client, sri_cookie_color, "5"); - g_aClientCookies[client][iColor] = COLOR_RAINBOW; - PrintToChat(client, "[SM] Bonus Round Immunity color set to RAINBOW"); - } - else if (StrEqual(sSelection, "None", false)) - { - SetClientCookie(client, sri_cookie_color, "6"); - g_aClientCookies[client][iColor] = COLOR_NONE; - PrintToChat(client, "[SM] Bonus Round Immunity color set to NONE"); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - ShowCookieMenu(client); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } -} - -public Menu_CookieSettingsMode(Handle:menu, MenuAction:action, param1, param2) -{ - new client = param1; - if (action == MenuAction_Select) - { - new String:sSelection[24]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "god", false)) - { - SetClientCookie(client, sri_cookie_mode, "1"); - g_aClientCookies[client][iMode] = 1; - PrintToChat(client, "[SM] Bonus Round Immunity set to GOD MODE"); - } - else - { - SetClientCookie(client, sri_cookie_mode, "0"); - g_aClientCookies[client][iMode] = 0; - PrintToChat(client, "[SM] Bonus Round Immunity set to HEALTH BONUS"); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - ShowCookieMenu(client); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } -} - -/** -Timer functions - */ - -public Action:Timer_ChangeColor(Handle:timer, any:client) -{ - if (g_aPlayers[client][CycleColor]++ == 3) - { - g_aPlayers[client][CycleColor] = 0; - } - SetEntityRenderMode(client, RENDER_TRANSCOLOR); - SetEntityRenderColor(client, g_iColors[g_aPlayers[client][CycleColor]][iRed], g_iColors[g_aPlayers[client][CycleColor]][iGreen], g_iColors[g_aPlayers[client][CycleColor]][iBlue], 255); - return Plugin_Continue; -} - -public Action:Timer_UndoGodMode(Handle:timer, any:client) -{ - if (IsClientInGame(client)) - { - SetEntProp(client, Prop_Data, "m_takedamage", 2, 1); - } - g_aPlayers[iClient][hGodModeTimer] = INVALID_HANDLE; - return Plugin_Handled; -} - -/** -Stock functions . - */ - -stock CleanUp(iClient) -{ - g_aPlayers[iClient][bIsAdmin] = false; - DisableImmunity(iClient); -} - -stock EnableImmunity(iClient) -{ - SetEntityRenderMode(iClient, RENDER_TRANSCOLOR); - switch (g_aClientCookies[iClient][iColor]) - { - case COLOR_TEAM: - { - new iTeam = GetClientTeam(iClient); - SetEntityRenderColor(iClient, g_iColors[e_ColorNames:iTeam][iRed], g_iColors[e_ColorNames:iTeam][iGreen], g_iColors[e_ColorNames:iTeam][iBlue], 255); - } - case COLOR_RAINBOW: - { - if (g_aPlayers[iClient][hColorTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[iClient][hColorTimer]); - g_aPlayers[iClient][hColorTimer] = INVALID_HANDLE; - } - g_aPlayers[iClient][hColorTimer] = CreateTimer(0.2, Timer_ChangeColor, iClient, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); - } - case COLOR_NONE: - { - //We dont have to set a color - } - default: - { - SetEntityRenderColor(iClient, g_iColors[e_ColorNames:g_aClientCookies[iClient][iColor]][iRed], g_iColors[e_ColorNames:g_aClientCookies[iClient][iColor]][iGreen], g_iColors[e_ColorNames:g_aClientCookies[iClient][iColor]][iBlue], 255); - } - } - SetEntityHealth(iClient, 2000); - SetEntProp(iClient, Prop_Data, "m_takedamage", 0, 1); - g_aPlayers[iClient][hGodModeTimer] = CreateTimer(2.0, Timer_UndoGodMode, iClient); - g_aPlayers[iClient][IsImmune] = true; -} - -stock DisableImmunity(iClient) -{ - if (g_aPlayers[iClient][hGodModeTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[iClient][hGodModeTimer]); - g_aPlayers[iClient][hGodModeTimer] = INVALID_HANDLE; - } - if (g_aPlayers[iClient][hColorTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[iClient][hColorTimer]); - g_aPlayers[iClient][hColorTimer] = INVALID_HANDLE; - } - if (IsClientInGame(iClient)) - { - SetEntityRenderMode(iClient, RENDER_TRANSCOLOR); - SetEntityRenderColor(iClient, 255, 255, 255, 255); - new TFClassType:PlayerClass = TF2_GetPlayerClass(iClient); - new iMaxHealth = g_iClassMaxHealth[PlayerClass]; - SetEntityHealth(iClient, iMaxHealth); - } - g_aPlayers[iClient][CycleColor] = 0; - g_aPlayers[iClient][IsImmune] = false; -} - -stock LoadColors() -{ - g_iColors[Green][iRed] = 0; - g_iColors[Green][iGreen] = 255; - g_iColors[Green][iBlue] = 0; - - g_iColors[Black][iRed] = 10; - g_iColors[Black][iGreen] = 10; - g_iColors[Black][iBlue] = 0; - - g_iColors[Red][iRed] = 255; - g_iColors[Red][iGreen] = 0; - g_iColors[Red][iBlue] = 0; - - g_iColors[Blue][iRed] = 0; - g_iColors[Blue][iGreen] = 0; - g_iColors[Blue][iBlue] = 255; -} - -stock TF2_AddCond(client, cond) -{ - new Handle:cvar = FindConVar("sv_cheats"), bool:enabled = GetConVarBool(cvar), flags = GetConVarFlags(cvar); - if(!enabled) - { - SetConVarFlags(cvar, flags^FCVAR_NOTIFY); - SetConVarBool(cvar, true); - } - FakeClientCommand(client, "addcond %i", cond); - if(!enabled) - { - SetConVarBool(cvar, false); - SetConVarFlags(cvar, flags); - } -} - -stock TF2_RemoveCond(client, cond) -{ - new Handle:cvar = FindConVar("sv_cheats"), bool:enabled = GetConVarBool(cvar), flags = GetConVarFlags(cvar); - if(!enabled) - { - SetConVarFlags(cvar, flags^FCVAR_NOTIFY); - SetConVarBool(cvar, true); - } - FakeClientCommand(client, "removecond %i", cond); - if(!enabled) - { - SetConVarBool(cvar, false); - SetConVarFlags(cvar, flags); - } -} - -/** -Enabled hook - */ - -public EnabledChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (StringToInt(newValue) == 0) - { - UnhookEvent("player_spawn", HookPlayerSpawn, EventHookMode_Post); - UnhookEvent("teamplay_round_start", HookRoundStart, EventHookMode_Post); - UnhookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - for (new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][bIsAdmin] && g_aPlayers[i][IsImmune]) - { - DisableImmunity(i); - } - } - g_bIsEnabled = false; - } - else - { - HookEvent("player_spawn", HookPlayerSpawn, EventHookMode_Post); - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_Post); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - g_bIsEnabled = true; - } -} diff --git a/Simple Donator Benefits/addons/sourcemod/scripting/simple-spectate.sp b/Simple Donator Benefits/addons/sourcemod/scripting/simple-spectate.sp deleted file mode 100644 index 4108f8f..0000000 --- a/Simple Donator Benefits/addons/sourcemod/scripting/simple-spectate.sp +++ /dev/null @@ -1,2022 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Spectate -Description: - Spectate a player and follow them through death. -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include -#undef REQUIRE_EXTENSIONS -#undef AUTOLOAD_EXTENSIONS -#tryinclude -#define AUTOLOAD_EXTENSIONS -#define REQUIRE_EXTENSIONS - -#define PLUGIN_VERSION "1.2.1.$Rev$" - -#define SPECMODE_NONE 0 -#define SPECMODE_FIRSTPERSON 4 -#define SPECMODE_3RDPERSON 5 -#define SPECMODE_FREELOOK 6 -#define SPECMODE_CSS_FIRSTPERSON 3 -#define SPECMODE_CSS_3RDPERSON 4 -#define SPECMODE_CSS_FREELOOK 5 - -enum e_CvarHandles -{ - Handle:hHudMode, - Handle:hMenuType, - Handle:hRestrictHud, - Handle:hBan, - Handle:hBanPerm, - Handle:hBeacon, - Handle:hBlind, - Handle:hCheater, - Handle:hDrug, - Handle:hFreeze, - Handle:hFreezeBomb, - Handle:hKick, - Handle:hSlap, - Handle:hSlay, - Handle:hTimeBomb -}; - -enum e_CvarSettings -{ - bool:bHudMode, - bool:bMenuType, - bool:bRestrictHud, - bool:bBan, - bool:bBanPerm, - bool:bBeacon, - bool:bBlind, - bool:bCheater, - bool:bDrug, - bool:bFreeze, - bool:bFreezebomb, - bool:bKick, - bool:bSlap, - bool:bSlay, - bool:bTimeBomb -}; - -enum e_PluginSettings -{ - bool:bUseSteamBans, - bool:bUseSourceBans, - bool:bUseMySQLBans, - bool:bCanHUD, - bool:bUseDukehacks -}; - -enum e_Menus -{ - Handle:hSelectPlayer, - Handle:hBanTime, - Handle:hReason -}; - -enum e_Punishments -{ - Punish_None, - Punish_Ban, - Punish_Beacon, - Punish_Blind, - Punish_Cheater, - Punish_Drug, - Punish_Freeze, - Punish_FreezeBomb, - Punish_Kick, - Punish_Slap, - Punish_Slay, - Punish_TimeBomb -}; - -enum e_PlayerData -{ - bool:bIsDisplayingHud, - bool:bIsFlaggedCheater, - Handle:hHudTimer, - Handle:hTargetTimer, - iTargetIndex, - e_Punishments:TargetPunishment, - iBanTime -}; - -new Handle:sm_spectate_adminflag = INVALID_HANDLE; -new Handle:g_hAdminMenu = INVALID_HANDLE; -new Handle:g_hHud = INVALID_HANDLE; -new Handle:g_aPluginCvar[e_CvarHandles]; -new g_aPluginCvarSettings[e_CvarSettings]; -new g_aPluginSettings[e_PluginSettings]; -new g_aMenus[e_Menus]; -new g_aPlayers[MAXPLAYERS + 1][e_PlayerData]; -new String:g_sAdminFlags[16]; -new String:g_sPunishments[e_Punishments][15] = { "None", "Ban", "Beacon", "Blind", "Cheater", "Drug", "Freeze", "FreezeBomb", "Kick", "Slap", "Slay", "TimeBomb" }; - -public Plugin:myinfo = -{ - name = "Simple Spectate", - author = "Simple Plugins", - description = "Spectate a player and follow them through death.", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -}; - -/** -Sourcemod callbacks -*/ -public OnPluginStart() -{ - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook the game events - */ - LogAction(0, -1, "[SSPEC] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_team", HookPlayerChangeTeam, EventHookMode_Pre); - - /** - Need to create all of our console variables. - */ - CreateConVar("sm_spectate_version", PLUGIN_VERSION, "Sourcemod Spectate", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - g_aPluginCvar[hHudMode] = CreateConVar("sm_spectate_hudmode", "1", "Hud Mode: 0 = Hud Text | 1 = Panel/Menu (NOTE: The panel/menu will override other menus until canceled)"); - g_aPluginCvar[hMenuType] = CreateConVar("sm_spectate_menutype", "0", "Menu Mode: 0 = Panel | 1 = Menu"); - g_aPluginCvar[hRestrictHud] = CreateConVar("sm_spectate_restricthud", "0", "Restrict the hud to the admin flag provided"); - g_aPluginCvar[hBan] = CreateConVar("sm_spectate_ban", "1", "Enable/Disable ban option"); - g_aPluginCvar[hBanPerm] = CreateConVar("sm_spectate_banperm", "1", "Enable/Disable permanent ban option"); - g_aPluginCvar[hBeacon] = CreateConVar("sm_spectate_beacon", "1", "Enable/Disable beacon option"); - g_aPluginCvar[hBlind] = CreateConVar("sm_spectate_blind", "1", "Enable/Disable blind option"); - g_aPluginCvar[hCheater] = CreateConVar("sm_spectate_cheater", "1", "Enable/Disable cheater option"); - g_aPluginCvar[hDrug] = CreateConVar("sm_spectate_drug", "1", "Enable/Disable drug option"); - g_aPluginCvar[hFreeze] = CreateConVar("sm_spectate_freeze", "1", "Enable/Disable freeze option"); - g_aPluginCvar[hFreezeBomb] = CreateConVar("sm_spectate_freezebomb", "1", "Enable/Disable freezebomb option"); - g_aPluginCvar[hKick] = CreateConVar("sm_spectate_kick", "1", "Enable/Disable kick option"); - g_aPluginCvar[hSlap] = CreateConVar("sm_spectate_slap", "1", "Enable/Disable slap option"); - g_aPluginCvar[hSlay] = CreateConVar("sm_spectate_slay", "1", "Enable/Disable slay option"); - g_aPluginCvar[hTimeBomb] = CreateConVar("sm_spectate_timebomb", "1", "Enable/Disable timebomb option"); - - sm_spectate_adminflag = CreateConVar("sm_spectate_adminflag", "d", "Admin Flag to use for admin hud"); - - /** - Hook console variables - */ - new e_CvarHandles:iCvar; - for ( ; _:iCvar < sizeof(g_aPluginCvar); iCvar++) - { - HookConVarChange(g_aPluginCvar[iCvar], ConVarSettingsChanged); - } - - /** - Need to register the commands we are going to create and use. - */ - RegConsoleCmd("sm_spectate", Command_Spectate, "Spectate a player"); - RegConsoleCmd("sm_spec", Command_Spectate, "Spectate a player"); - RegConsoleCmd("sm_observe", Command_Spectate, "Spectate a player"); - RegConsoleCmd("sm_stopspec", Command_StopSpectate, "Stop Spectating a player"); - RegConsoleCmd("sm_endobserve", Command_StopSpectate, "Stop Spectating a player"); - RegConsoleCmd("sm_specinfo", Command_ToggleHud, "Toggles the hud display if in spectator"); - - /** - Now we have to deal with the admin menu. If the admin library is loaded call the function to add our items. - */ - new Handle:gTopMenu; - if (LibraryExists("adminmenu") && ((gTopMenu = GetAdminTopMenu()) != INVALID_HANDLE)) - { - OnAdminMenuReady(gTopMenu); - } - - /** - Deal with the hud - Thanks to Spray Trace plugin (http://forums.alliedmods.net/showthread.php?p=665448) - */ - new String:sHudGames[32]; - GetGameFolderName(sHudGames, sizeof(sHudGames)); - g_aPluginSettings[bCanHUD] = StrEqual(sHudGames,"tf",false) - || StrEqual(sHudGames,"hl2mp",false) - || StrEqual(sHudGames,"sourceforts",false) - || StrEqual(sHudGames,"obsidian",false) - || StrEqual(sHudGames,"left4dead",false) - || StrEqual(sHudGames,"l4d",false); - - if (g_aPluginSettings[bCanHUD]) - { - g_hHud = CreateHudSynchronizer(); - } - - /** - Load translations - */ - LoadTranslations ("common.phrases"); - LoadTranslations ("simplespectate.phrases"); - - /** - Create the config file - */ - AutoExecConfig(true); -} - -public OnConfigsExecuted() -{ - new e_CvarHandles:iCvar; - for ( ; _:iCvar < sizeof(g_aPluginCvarSettings); iCvar++) - { - g_aPluginCvarSettings[iCvar] = GetConVarBool(g_aPluginCvar[iCvar]); - } - - /* - Build the global menus - */ - g_aMenus[hSelectPlayer] = BuildSelectPlayerMenu(); - g_aMenus[hBanTime] = BuildBanTimeMenu(); - g_aMenus[hReason] = BuildReasonMenu(); - - GetConVarString(sm_spectate_adminflag, g_sAdminFlags, sizeof(g_sAdminFlags)); -} - -public OnAllPluginsLoaded() -{ - - /* - Check for steambans - */ - if (FindConVar("sbsrc_version") != INVALID_HANDLE) - { - g_aPluginSettings[bUseSteamBans] = true; - } - else - { - g_aPluginSettings[bUseSteamBans] = false; - } - - /* - Check for sourcebans - */ - if (FindConVar("sb_version") != INVALID_HANDLE) - { - g_aPluginSettings[bUseSourceBans] = true; - } - else - { - g_aPluginSettings[bUseSourceBans] = false; - } - - /* - Check for mysql bans - */ - if (FindConVar("mysql_bans_version") != INVALID_HANDLE) - { - g_aPluginSettings[bUseMySQLBans] = true; - } - else - { - g_aPluginSettings[bUseMySQLBans] = false; - } - - /* - Check for dukehacks - */ - new String:sExtError[256]; - new iExtStatus = GetExtensionFileStatus("dukehacks.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SSPEC] Dukehacks extension was not found."); - LogAction(0, -1, "[SSPEC] Plugin continued to load, but that feature will not be used."); - g_aPluginSettings[bUseDukehacks] = false; - } - else if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SSPEC] Dukehacks extension is loaded with errors."); - LogAction(0, -1, "[SSPEC] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SSPEC] Plugin continued to load, but that feature will not be used."); - g_aPluginSettings[bUseDukehacks] = false; - } - else if (iExtStatus == 1) - { - LogAction(0, -1, "[SSPEC] Dukehacks extension is loaded and will be used."); - g_aPluginSettings[bUseDukehacks] = true; - dhAddClientHook(CHK_TakeDamage, Hacks_TakeDamageHook); - } - - /* - Deal with some known plugin conflicts - */ - new Handle:hObserveClient = FindConVar("observe_version"); - if (hObserveClient != INVALID_HANDLE) - { - new String:sNewFile[PLATFORM_MAX_PATH + 1], String:sOldFile[PLATFORM_MAX_PATH + 1]; - BuildPath(Path_SM, sNewFile, sizeof(sNewFile), "plugins/disabled/observe.smx"); - BuildPath(Path_SM, sOldFile, sizeof(sOldFile), "plugins/observe.smx"); - - /** - Check if plugins/observe.smx exists, and if not, ignore - */ - if(!FileExists(sOldFile)) - { - return; - } - - /** - Check if plugins/disabled/observe.smx already exists, and if so, delete it - */ - if(FileExists(sNewFile)) - { - DeleteFile(sNewFile); - } - - /** - Unload plugins/observe.smx and move it to plugins/disabled/observe.smx - */ - LogAction(0, -1, "Detected the plugin ObserveClient"); - LogAction(0, -1, "ObserveClient plugin conflicts with Simple Spectate"); - LogAction(0, -1, "Unloading plugin and disabling ObserveClient plugin"); - ServerCommand("sm plugins unload observe"); - RenameFile(sNewFile, sOldFile); - } -} - -public OnLibraryRemoved(const String:name[]) -{ - if (StrEqual(name, "adminmenu")) - { - - /** - Looks like the admin menu was removed. Set the global. - */ - g_hAdminMenu = INVALID_HANDLE; - } - else if (StrEqual(name, "simpleplugins")) - { - //something - } -} - -public OnClientDisconnect(client) -{ - - /** - Cleanup the clients variables. - */ - ResetClient(client); - - /** - Run a loop and see if we are supposed to spectate this person (is a target) - */ - for(new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][iTargetIndex] == client) - { - - /** - Cleanup the clients variables. - */ - StopFollowingPlayer(i); - g_aPlayers[i][TargetPunishment] = Punish_None; - g_aPlayers[i][iBanTime] = 0; - } - } -} - -/** -Thirdparty callbacks -*/ -public SM_OnPlayerMoved(Handle:plugin, client, team) -{ - - /** - Make sure we called the move function - */ - if (plugin != GetMyHandle()) - { - return; - } - - //Nothing -} - -public Action:Hacks_TakeDamageHook(client, attacker, inflictor, Float:damage, &Float:multiplier, damagetype) -{ - - /** - Check for a valid client - */ - if (client > 0 && client <= MaxClients) - { - - /** - Check if the client taking damage is flagged as a cheater - */ - if (g_aPlayers[client][bIsFlaggedCheater]) - { - - /** - Check for fall damage and increase it - */ - if (damagetype & DMG_FALL) - { - multiplier *= 1000.0; - return Plugin_Changed; - } - } - } - - /** - Check for a valid attacker - */ - if (attacker > 0 && attacker <= MaxClients) - { - - /** - Check if the attacker causing the damage is flagged as a cheater - */ - if (g_aPlayers[attacker][bIsFlaggedCheater]) - { - - /** - Make sure they are not hurting themselves - */ - if (client != attacker) - { - - /** - Stop the damage - */ - multiplier *= 0.0; - return Plugin_Changed; - } - } - } - return Plugin_Continue; -} - -/** -Events -*/ -public Action:HookPlayerChangeTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get the client and team - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - new iTeam = GetEventInt(event, "team"); - - /** - Make sure it's a valid client - */ - if (iClient == 0) - { - return Plugin_Continue; - } - - /** - If it's a move to spectator start displaying the hud - */ - else if ((iTeam == g_aCurrentTeams[Spectator]) && (GetUserFlagBits(iClient) & ADMFLAG_GENERIC)) - { - StartDisplayingHud(iClient); - - /** - If the event was going to be broadcasted, we refire it so it is not broadcasted and stop this one - */ - if (!dontBroadcast) - { - new Handle:hEvent = CreateEvent("player_team"); - SetEventInt(hEvent, "userid", GetEventInt(event, "userid")); - SetEventInt(hEvent, "team", GetEventInt(event, "team")); - SetEventInt(hEvent, "oldteam", GetEventInt(event, "oldteam")); - SetEventBool(hEvent, "disconnect", GetEventBool(event, "disconnect")); - - if (g_CurrentMod == GameType_DOD || g_CurrentMod == GameType_L4D || g_CurrentMod == GameType_TF) - { - new String:sClientName[MAX_NAME_LENGTH + 1]; - GetClientName(client, sClientName, sizeof(sClientName)); - SetEventBool(hEvent, "autoteam", GetEventBool(event, "autoteam")); - SetEventBool(hEvent, "silent", true); - SetEventString(hEvent, "name", sClientName); - FireEvent(hEvent, true); - } - else - { - FireEvent(hEvent, true); - } - return Plugin_Handled; - } - } - - /** - Otherwise cleanup the client - */ - else - { - StopDisplayingHud(iClient); - StopFollowingPlayer(iClient); - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -/** -Commands -*/ -public Action:Command_Spectate(client, args) -{ - - /** - See if we already have a target (for toggling of command) - */ - if (g_aPlayers[client][iTargetIndex]) - { - - /** - We do, toggle it off - */ - StopFollowingPlayer(client); - - /** - We are done, bug out. - */ - return Plugin_Handled; - } - - /** - We don't... must want to enable it - See if we have some command arguments. - */ - new iCmdArgs = GetCmdArgs(); - if (iCmdArgs == 0) - { - - /** - We don't have any. Display the player menu. - */ - if (g_aPlayers[client][bIsDisplayingHud]) - { - StopDisplayingHud(client); - } - - DisplayMenu(BuildPlayerListMenu(), client, MENU_TIME_FOREVER); - return Plugin_Handled; - } - - /** - We have an argument. - Try to find the target. - */ - new String:sPlayer[128]; - GetCmdArg(1, sPlayer, sizeof(sPlayer)); - new iTarget = FindTarget(client, sPlayer, true, true); - if (iTarget == -1 || !IsClientInGame(iTarget)) - { - - /** - We couldn't find the target. Display the player menu. - */ - if (g_aPlayers[client][bIsDisplayingHud]) - { - StopDisplayingHud(client); - } - - DisplayMenu(BuildPlayerListMenu(), client, MENU_TIME_FOREVER); - return Plugin_Handled; - } - - /** - We found the target. - Call the stock function to spectate the target. - */ - StartFollowingPlayer(client, iTarget); - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_StopSpectate(client, args) -{ - - /** - Cleanup the clients variables. - */ - StopFollowingPlayer(client); - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_ToggleHud(client, args) -{ - - /** - Toggle the hud - */ - if (g_aPlayers[client][bIsDisplayingHud]) - { - StopDisplayingHud(client); - } - else - { - StartDisplayingHud(client); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -/** -Timers -*/ -public Action:Timer_ResetTarget(Handle:timer, any:client) -{ - - new iTargetID = GetEntPropEnt(client, Prop_Send, "m_hObserverTarget"); - - if (iTargetID != g_aPlayers[client][iTargetIndex] && IsPlayerAlive(g_aPlayers[client][iTargetIndex])) - { - - /** - Run the command to spectate the target from the clients prospectative. - */ - FakeClientCommandEx(client, "spec_player \"%N\"", g_aPlayers[client][iTargetIndex]); - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -public Action:Timer_UpdateHud(Handle:timer, any:client) -{ - - /** - Make sure the client is still in game and a spectator - */ - if (!IsClientConnected(client) || !IsClientInGame(client) || GetClientTeam(client) != g_aCurrentTeams[Spectator] || !g_aPlayers[client][bIsDisplayingHud]) - { - - /** - We are done, bug out - */ - g_aPlayers[client][hHudTimer] = INVALID_HANDLE; - g_aPlayers[client][bIsDisplayingHud] = false; - return Plugin_Stop; - } - /** - Get the target - */ - new iTarget = GetEntPropEnt(client, Prop_Send, "m_hObserverTarget"); - - /** - Check to make sure the target is valid - */ - if (iTarget <= 0 || iTarget > MaxClients) - { - return Plugin_Continue; - } - - /** - Get the spectator mode - */ - new iSpecMode = GetEntProp(client, Prop_Send, "m_iObserverMode"); - - /** - This is a double check to make sure we are in spec - If we are on a regular team, specmod would = none or zero - */ - if (iSpecMode == SPECMODE_NONE) - { - - /** - We are done, bug out - */ - g_aPlayers[client][hHudTimer] = INVALID_HANDLE; - g_aPlayers[client][bIsDisplayingHud] = false; - return Plugin_Stop; - } - - /** - Check the spectator mode - CSS has different index's so we have to check game type first - */ - if (g_CurrentMod == GameType_CSS) - { - switch (iSpecMode) - { - case SPECMODE_CSS_FIRSTPERSON: - { - //Do Nothing - } - case SPECMODE_CSS_3RDPERSON: - { - //Do Nothing - } - case SPECMODE_CSS_FREELOOK: - { - return Plugin_Continue; - } - } - } - else - { - switch (iSpecMode) - { - case SPECMODE_FIRSTPERSON: - { - //Do Nothing - } - case SPECMODE_3RDPERSON: - { - //Do Nothing - } - case SPECMODE_FREELOOK: - { - return Plugin_Continue; - } - } - } - - - /** - Display with the hud - */ - if (g_aPluginSettings[bCanHUD] && !g_aPluginCvarSettings[bHudMode]) - { - new String:sSteamID[64]; - GetClientAuthString(iTarget, sSteamID, sizeof(sSteamID)); - SetHudTextParams(0.04, 0.6, 0.5, 255, 50, 50, 255); - ShowSyncHudText(client, g_hHud, "%N [%s]", iTarget, sSteamID); - } - else if (g_aPluginCvarSettings[bHudMode]) - { - if (g_aPluginCvarSettings[bMenuType]) - { - DisplayMenu(BuildPlayerHudMenu(client, iTarget), client, 1); - } - else - { - new Handle:hPanel = BuildPlayerHudPanel(client, iTarget); - SendPanelToClient(hPanel, client, Panel_PlayerHud, 1); - CloseHandle(hPanel); - } - } - - /** - We are done, keep going! - */ - return Plugin_Continue; -} - -/** -Admin Menu Callbacks -*/ -public OnAdminMenuReady(Handle:topmenu) -{ - if (topmenu == g_hAdminMenu) - { - return; - } - g_hAdminMenu = topmenu; - new TopMenuObject:player_commands = FindTopMenuCategory(g_hAdminMenu, ADMINMENU_PLAYERCOMMANDS); - if (player_commands == INVALID_TOPMENUOBJECT) - { - return; - } - AddToTopMenu(g_hAdminMenu, - "sm_spectate", - TopMenuObject_Item, - AdminMenu_SpecPlayer, - player_commands, - "sm_spectate", - ADMFLAG_GENERIC); -} - -public AdminMenu_SpecPlayer(Handle:topmenu, TopMenuAction:action, TopMenuObject:object_id, param, String:buffer[], maxlength) -{ - if (action == TopMenuAction_DisplayOption) - { - - if (g_aPlayers[param][bIsDisplayingHud]) - { - StopDisplayingHud(param); - } - /** - See if we already have a target - */ - if (g_aPlayers[param][iTargetIndex]) - { - Format(buffer, maxlength, "Spectate(Disable)"); - } - else - { - Format(buffer, maxlength, "Spectate(Select Player)"); - } - } - else if (action == TopMenuAction_SelectOption) - { - - /** - See if we already have a target - */ - if (g_aPlayers[param][iTargetIndex]) - { - - /** - We do, toggle it off - */ - StopFollowingPlayer(param); - - /** - We are done, bug out. - */ - return; - } - else - { - DisplayMenu(BuildPlayerListMenu(), param, MENU_TIME_FOREVER); - } - } -} - -/** -Select Player Menu Callbacks -*/ -public Menu_PlayerList(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - /** - Get the selected player - */ - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - new iTarget = GetClientOfUserId(StringToInt(sSelection)); - - /** - Start following the player - */ - StartFollowingPlayer(param1, iTarget); - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_GENERIC) - { - - /** - Display the last admin menu - */ - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } - else if (param2 == MenuCancel_Exit && GetClientTeam(param1) == g_aCurrentTeams[Spectator]) - { - /** - They canceled the current menu, start the hud back up - */ - StartDisplayingHud(param1); - } - } - else if (action == MenuAction_End) - { - - /** - Not a global menu, close it - */ - CloseHandle(menu); - } -} - -public Menu_SelectPlayer(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - - /** - Get the selected player - */ - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (strcmp(sSelection, "Current", false) == 0) - { - /** - Get the current target - */ - new iTarget = GetEntPropEnt(param1, Prop_Send, "m_hObserverTarget"); - - /** - Check to make sure the target is valid - */ - if (iTarget <= 0 || iTarget > MaxClients) - { - PrintToChat(param1, "\x03[SM-SPEC]\x01 %t", "Invalid Target"); - DisplayMenu(BuildPlayerListMenu(), param1, MENU_TIME_FOREVER); - } - - /** - Start following the player - */ - StartFollowingPlayer(param1, iTarget); - } - else - { - - /** - They want to select a player, show the player list - */ - DisplayMenu(BuildPlayerListMenu(), param1, MENU_TIME_FOREVER); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - - /** - They canceled the current menu, start the hud back up - */ - StartDisplayingHud(param1); - } - } - else if (action == MenuAction_End) - { - /** - Its a global menu, leave it alive - */ - } -} - -/** -Punishment Menu Callbacks -*/ -public Menu_Punishments(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - - /** - Get the menu selection - */ - new String:sSelection[15]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - - /** - Search for the correct index - */ - new e_Punishments:Index = Punish_None; - for ( ; _:Index <= sizeof(g_sPunishments); Index++) - { - if (StrEqual(sSelection, g_sPunishments[Index])) - { - break; - } - } - - /** - Display the next menu - */ - if (Index == Punish_Ban) - { - - /** - Set the punishment index and display ban time menu - */ - g_aPlayers[param1][TargetPunishment] = Index; - DisplayMenu(g_aMenus[hBanTime], param1, MENU_TIME_FOREVER); - } - else if (Index == Punish_Cheater) - { - - /** - Ask for confirmation before we set punishment index - */ - new Handle:hPanel = BuildAdminCheaterPanel(); - SendPanelToClient(hPanel, param1, Panel_AdminCheater, MENU_TIME_FOREVER); - CloseHandle(hPanel); - } - else - { - - /** - Set the punishment index and display reason menu - */ - g_aPlayers[param1][TargetPunishment] = Index; - DisplayMenu(g_aMenus[hReason], param1, MENU_TIME_FOREVER); - } - } - else if (action == MenuAction_Cancel) - { - - /** - They canceled the current menu, start the hud back up - */ - StartDisplayingHud(param1); - } - else if (action == MenuAction_End) - { - - /** - Not a global menu, close it - */ - CloseHandle(menu); - } -} - -public Menu_BanTime(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - - /** - Get the menu selection - */ - new String:sSelection[15]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - - /** - Set the ban time global - */ - g_aPlayers[param1][iBanTime] = StringToInt(sSelection); - - /** - Display the reason menu - */ - DisplayMenu(g_aMenus[hReason], param1, MENU_TIME_FOREVER); - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - - /** - They canceled the current menu, start the hud back up - */ - StartDisplayingHud(param1); - } - } - else if (action == MenuAction_End) - { - /** - Its a global menu, leave it alive - */ - } -} - -public Menu_Reason(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - - /** - Get the menu selection - */ - new String:sSelection[15]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - - /** - Perform the punishment - */ - PerformPunishment(param1, g_aPlayers[param1][iTargetIndex], g_aPlayers[param1][TargetPunishment], sSelection, g_aPlayers[param1][iBanTime]); - - /** - Reactivate the hud if still in spectator - */ - if (GetClientTeam(param1) == g_aCurrentTeams[Spectator]) - { - StartDisplayingHud(param1); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - - /** - They canceled the current menu, start the hud back up - */ - StartDisplayingHud(param1); - } - } - else if (action == MenuAction_End) - { - /** - Its a global menu, leave it alive - */ - } -} - -public Panel_AdminCheater(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - if (param2 == 1) - { - - /** - Set the punishment index and display reason menu - */ - g_aPlayers[param1][TargetPunishment] = Punish_Cheater; - DisplayMenu(g_aMenus[hReason], param1, MENU_TIME_FOREVER); - } - else - { - - /** - Reactivate the hud if still in spectator - */ - if (GetClientTeam(param1) == g_aCurrentTeams[Spectator]) - { - StartDisplayingHud(param1); - } - } - } -} - -public Panel_PublicCheater(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - if (param2 == 1) - { - //Waiting for SB 2.0 and sb_submission to be published - } - else - { - - /** - Reactivate the hud if still in spectator - */ - if (GetClientTeam(param1) == g_aCurrentTeams[Spectator]) - { - StartDisplayingHud(param1); - } - } - } -} - -/** -Hud Menu/Panel Callbacks -*/ -public Menu_PlayerHud(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "stop", false)) - { - StopFollowingPlayer(param1); - } - else if (StrEqual(sSelection, "start", false)) - { - StopDisplayingHud(param1); - DisplayMenu(g_aMenus[hSelectPlayer], param1, MENU_TIME_FOREVER); - } - else if (StrEqual(sSelection, "removecheater", false)) - { - g_aPlayers[g_aPlayers[param1][iTargetIndex]][bIsFlaggedCheater] = false; - } - else if (StrEqual(sSelection, "punish", false)) - { - if (g_aPlayers[param1][iTargetIndex]) - { - StopDisplayingHud(param1); - DisplayMenu(BuildPunishmentMenu(param1), param1, MENU_TIME_FOREVER); - } - else - { - StopDisplayingHud(param1); - PrintToChat(param1, "\x03[SM-SPEC]\x01 %t", "Must Have Target"); - DisplayMenu(g_aMenus[hSelectPlayer], param1, MENU_TIME_FOREVER); - } - } - else if (StrEqual(sSelection, "reportcheater", false)) - { - if (g_aPlayers[param1][iTargetIndex]) - { - StopDisplayingHud(param1); - new Handle:hPanel = BuildPublicCheaterPanel(); - SendPanelToClient(hPanel, param1, Panel_PublicCheater, MENU_TIME_FOREVER); - CloseHandle(hPanel); - } - else - { - StopDisplayingHud(param1); - PrintToChat(param1, "\x03[SM-SPEC]\x01 %t", "Must Have Target"); - DisplayMenu(g_aMenus[hSelectPlayer], param1, MENU_TIME_FOREVER); - } - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_Interrupted) - { - if (GetClientMenu(param1) == MenuSource_External) - { - StopDisplayingHud(param1); - } - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } -} - -public Panel_PlayerHud(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - switch (param2) - { - case 1: - { - if (g_aPlayers[param1][iTargetIndex]) - { - StopFollowingPlayer(param1); - } - else - { - StopDisplayingHud(param1); - DisplayMenu(BuildSelectPlayerMenu(), param1, MENU_TIME_FOREVER); - } - } - case 2: - { - if (!g_aPlayers[param1][iTargetIndex]) - { - StopDisplayingHud(param1); - PrintToChat(param1, "\x03[SM-SPEC]\x01 %t", "Must Have Target"); - DisplayMenu(g_aMenus[hSelectPlayer], param1, MENU_TIME_FOREVER); - return; - } - - if ((GetUserFlagBits(param1) & ADMFLAG_GENERIC) || (GetUserFlagBits(param1) & ADMFLAG_ROOT)) - { - if (g_aPlayers[g_aPlayers[param1][iTargetIndex]][bIsFlaggedCheater] && (GetUserFlagBits(param1) & ADMFLAG_ROOT)) - { - //Remove cheater flag - g_aPlayers[g_aPlayers[param1][iTargetIndex]][bIsFlaggedCheater] = false; - } - else - { - //Punish menu - StopDisplayingHud(param1); - DisplayMenu(BuildPunishmentMenu(param1), param1, MENU_TIME_FOREVER); - } - } - else - { - //Report Cheater - new Handle:hPanel = BuildPublicCheaterPanel(); - SendPanelToClient(hPanel, param1, Panel_PublicCheater, MENU_TIME_FOREVER); - CloseHandle(hPanel); - } - } - case 3: - { - StopDisplayingHud(param1); - } - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_Interrupted) - { - if (GetClientMenu(param1) == MenuSource_External) - { - StopDisplayingHud(param1); - } - } - } -} - - -/** -Stock functions -*/ -stock StartFollowingPlayer(client, target) -{ - - /** - If we have an open timer, close it. - */ - if (g_aPlayers[client][hTargetTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[client][hTargetTimer]); - g_aPlayers[client][hTargetTimer] = INVALID_HANDLE; - } - - /** - Make sure the target is on a non spectator team, and the client != target - */ - if (client == target) - { - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Yourself"); - return; - } - new iTargetTeam = GetClientTeam(target); - if (iTargetTeam == g_aCurrentTeams[Spectator] || iTargetTeam == g_aCurrentTeams[Unknown]) - { - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Spectator"); - return; - } - - /** - Check to see if client is already a spectator - */ - if (GetClientTeam(client) != g_aCurrentTeams[Spectator]) - { - - /** - Client is not a spectator, lets move them to spec. - */ - SM_MovePlayer(client, g_aCurrentTeams[Spectator]); - } - - /** - If we are using steambans call sb_status - */ - if (g_aPluginSettings[bUseSteamBans]) - { - FakeClientCommandEx(client, "sb_status"); - } - - - /** - Set the global and start to spectate the target. - Making sure it's long enough to deal with moving the client to spec if we had to. - */ - new String:sTargetName[MAX_NAME_LENGTH + 1]; - GetClientName(target, sTargetName, sizeof(sTargetName)); - g_aPlayers[client][iTargetIndex] = target; - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Spectating", sTargetName); - g_aPlayers[client][hTargetTimer] = CreateTimer(0.5, Timer_ResetTarget, client, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); - if (!g_aPlayers[client][bIsDisplayingHud] && GetClientTeam(client) == g_aCurrentTeams[Spectator]) - { - StartDisplayingHud(client); - } -} - -stock StopFollowingPlayer(client) -{ - - /** - If we have an open timer, close it. - */ - if (g_aPlayers[client][hTargetTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[client][hTargetTimer]); - } - - /** - Tell the client we can't spec his target anymore... if they are in game. - */ - if (IsClientInGame(client) && g_aPlayers[client][iTargetIndex] != 0) - { - new String:sTargetName[MAX_NAME_LENGTH + 1]; - GetClientName(g_aPlayers[client][iTargetIndex], sTargetName, sizeof(sTargetName)); - if (!IsClientConnected(g_aPlayers[client][iTargetIndex]) || !IsClientInGame(g_aPlayers[client][iTargetIndex])) - { - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Target Left"); - } - else - { - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Stopped spectating", sTargetName); - } - } - - /** - Null the globals. - */ - g_aPlayers[client][iTargetIndex] = 0; - g_aPlayers[client][hTargetTimer] = INVALID_HANDLE; -} - -stock StartDisplayingHud(client) -{ - if (g_aPluginCvarSettings[bRestrictHud] && !SM_IsValidAdmin(client, g_sAdminFlags)) - { - return; - } - else - { - /** - Double check the hud timer - We should not have one, but if we do, lets cancel it for the current callback - */ - StopDisplayingHud(client); - - /** - Now we can safely display the hud and make sure the current stored handle is the current timer - */ - g_aPlayers[client][bIsDisplayingHud] = true; - g_aPlayers[client][hHudTimer] = CreateTimer(0.5, Timer_UpdateHud, client, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); - } -} - -stock StopDisplayingHud(client) -{ - if (g_aPlayers[client][hHudTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[client][hHudTimer]); - } - g_aPlayers[client][hHudTimer] = INVALID_HANDLE; - g_aPlayers[client][bIsDisplayingHud] = false; -} - -stock ResetClient(client) -{ - StopFollowingPlayer(client); - StopDisplayingHud(client); - - g_aPlayers[client][bIsFlaggedCheater] = false; - g_aPlayers[client][TargetPunishment] = Punish_None; - g_aPlayers[client][iBanTime] = -1; -} - -stock PerformPunishment(client, target, e_Punishments:punishment, const String:reason[], time = 300) -{ - new String:sTargetName[MAX_NAME_LENGTH + 1], - String:sTargetID[64]; - - /** - The target could have left the game by the time we get here - Check for a valid target - */ - if (!IsClientConnected(target) || !IsClientInGame(target)) - { - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Target Left"); - return; - } - - GetClientName(target, sTargetName, sizeof(sTargetName)); - GetClientAuthString(target, sTargetID, sizeof(sTargetID)); - - switch (punishment) - { - case Punish_Kick: - { - KickClient(g_aPlayers[client][iTargetIndex], "%s", reason); - } - case Punish_Ban: - { - if (g_aPluginSettings[bUseSourceBans]) - { - ClientCommand(client, "sm_ban #%d %d \"%s\"", GetClientUserId(target), time, reason); - } - else if (g_aPluginSettings[bUseMySQLBans]) - { - ClientCommand(client, "mysql_ban #%d %d \"%s\"", GetClientUserId(target), time, reason); - } - else - { - BanClient(target, time, BANFLAG_AUTHID, reason, reason); - } - } - case Punish_Cheater: - { - g_aPlayers[target][bIsFlaggedCheater] = true; - } - case Punish_Beacon: - { - ClientCommand(client, "sm_beacon \"%s\"", sTargetName); - } - case Punish_Blind: - { - ClientCommand(client, "sm_blind \"%s\"", sTargetName); - } - case Punish_Drug: - { - ClientCommand(client, "sm_drug \"%s\"", sTargetName); - } - case Punish_Freeze: - { - ClientCommand(client, "sm_freeze \"%s\"", sTargetName); - } - case Punish_FreezeBomb: - { - ClientCommand(client, "sm_freezebomb \"%s\"", sTargetName); - } - case Punish_Slap: - { - ClientCommand(client, "sm_slap \"%s\" 10", sTargetName); - } - case Punish_Slay: - { - ClientCommand(client, "sm_slay \"%s\"", sTargetName); - } - case Punish_TimeBomb: - { - ClientCommand(client, "sm_timebomb \"%s\"", sTargetName); - } - } - - if (punishment == Punish_Cheater) - { - LogAction(client, target, "[SM SPEC] %N marked %N(%s) with a %s flag for %s", client, target, sTargetID, g_sPunishments[punishment], reason); - } - else - { - ShowActivity(client, "%t", "Punished", sTargetName, g_sPunishments[punishment], reason); - LogAction(client, target, "[SM SPEC] %N punished %N(%s) with a %s for %s", client, target, sTargetID, g_sPunishments[punishment], reason); - } - - /** - Null the globals. - */ - g_aPlayers[client][TargetPunishment] = Punish_None; - g_aPlayers[client][iBanTime] = -1; -} - -/** -Build the menu of player names -*/ -stock Handle:BuildPlayerListMenu() -{ - new Handle:hMenu = CreateMenu(Menu_PlayerList); - AddTargetsToMenu(hMenu, 0, true, false); - SetMenuTitle(hMenu, "Select A Player:"); - SetMenuExitBackButton(hMenu, true); - return hMenu; -} - -/** -Build the select player menu (current or list of players) -*/ -stock Handle:BuildSelectPlayerMenu() -{ - new Handle:hMenu = CreateMenu(Menu_SelectPlayer); - SetMenuTitle(hMenu, "Select A Player:"); - AddMenuItem(hMenu, "Current", "Current Target"); - AddMenuItem(hMenu, "List", "Player List"); - SetMenuExitBackButton(hMenu, true); - return hMenu; -} - -/** -Build the punishmenu menu -*/ -stock Handle:BuildPunishmentMenu(iClient) -{ - new Handle:hMenu = CreateMenu(Menu_Punishments); - SetMenuTitle(hMenu, "Select A Punishment:"); - SetMenuExitBackButton(hMenu, true); - SetMenuExitButton(hMenu, true); - - if (g_aPluginCvarSettings[bKick] && ((GetUserFlagBits(iClient) & ADMFLAG_GENERIC) || (GetUserFlagBits(iClient) & ADMFLAG_ROOT))) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Kick], "Kick"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Kick], "Kick", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bBan] && ((GetUserFlagBits(iClient) & ADMFLAG_GENERIC) || (GetUserFlagBits(iClient) & ADMFLAG_ROOT))) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Ban], "Ban"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Ban], "Ban", ITEMDRAW_DISABLED); - } - - if (g_aPluginSettings[bUseDukehacks] && g_aPluginCvarSettings[bCheater] && (GetUserFlagBits(iClient) & ADMFLAG_ROOT)) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Cheater], "Flag As Cheater"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Cheater], "Flag As Cheater", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bBeacon]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Beacon], "Beacon"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Beacon], "Beacon", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bBlind]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Blind], "Blind"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Blind], "Blind", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bDrug]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Drug], "Drug"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Drug], "Drug", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bFreeze]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Freeze], "Freeze"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Freeze], "Freeze", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bFreezebomb]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_FreezeBomb], "Freeze Bomb"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_FreezeBomb], "Freeze Bomb", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bSlap]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Slap], "Slap"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Slap], "Slap", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bSlay]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Slay], "Slay"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Slay], "Slay", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bTimeBomb]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_TimeBomb], "Time Bomb"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_TimeBomb], "Time Bomb", ITEMDRAW_DISABLED); - } - - return hMenu; -} - -/** -Build the punishmenu menu -*/ -stock Handle:BuildBanTimeMenu() -{ - new Handle:hMenu = CreateMenu(Menu_BanTime); - SetMenuTitle(hMenu, "Select Ban Type:"); - - if (g_aPluginCvarSettings[bBanPerm]) - { - AddMenuItem(hMenu, "permban", "Permanent"); - } - else - { - AddMenuItem(hMenu, "permban", "Permanent", ITEMDRAW_DISABLED); - } - - AddMenuItem(hMenu, "10", "10 Minutes"); - AddMenuItem(hMenu, "30", "30 Minutes"); - AddMenuItem(hMenu, "60", "1 Hour"); - AddMenuItem(hMenu, "240", "4 Hours"); - AddMenuItem(hMenu, "1440", "1 Day"); - AddMenuItem(hMenu, "10080", "1 Week"); - - SetMenuExitBackButton(hMenu, true); - return hMenu; -} - -/** -Build the punishmenu menu -*/ -stock Handle:BuildReasonMenu() -{ - new Handle:hMenu = CreateMenu(Menu_Reason); - SetMenuTitle(hMenu, "Select A Reason:"); - - AddMenuItem(hMenu, "Abusive", "Abusive"); - AddMenuItem(hMenu, "Racism", "Racism"); - AddMenuItem(hMenu, "General cheating/exploits", "General cheating/exploits"); - AddMenuItem(hMenu, "Wallhack", "Wallhack"); - AddMenuItem(hMenu, "Aimbot", "Aimbot"); - AddMenuItem(hMenu, "Speedhacking", "Speedhacking"); - AddMenuItem(hMenu, "Mic spamming", "Mic spamming"); - AddMenuItem(hMenu, "Admin disrepect", "Admin disrepect"); - AddMenuItem(hMenu, "Camping", "Camping"); - AddMenuItem(hMenu, "Team killing", "Team killing"); - AddMenuItem(hMenu, "Unacceptable Spray", "Unacceptable Spray"); - AddMenuItem(hMenu, "Breaking Server Rules", "Breaking Server Rules"); - AddMenuItem(hMenu, "Other", "Other"); - - SetMenuExitBackButton(hMenu, true); - return hMenu; -} - -/** -Build the cheater displays -*/ -stock Handle:BuildAdminCheaterPanel() -{ - - /** - Create the menu and set the menu options. - */ - new Handle:hPanel = CreatePanel(); - SetPanelTitle(hPanel, "Simple Spectator:"); - - DrawPanelText(hPanel, "Are you sure you want to"); - DrawPanelText(hPanel, "flag this player as a cheater?"); - DrawPanelText(hPanel, "They will not be able to damage"); - DrawPanelText(hPanel, "anyone and die on fall damage."); - DrawPanelItem(hPanel, "Yes"); - DrawPanelItem(hPanel, "No"); - - return hPanel; -} - -stock Handle:BuildPublicCheaterPanel() -{ - - /** - Create the menu and set the menu options. - */ - new Handle:hPanel = CreatePanel(); - SetPanelTitle(hPanel, "Simple Spectator:"); - - DrawPanelText(hPanel, "Are you sure you want to"); - DrawPanelText(hPanel, "submit this player as a cheater?"); - DrawPanelItem(hPanel, "Yes (Not Implemented Yet)", ITEMDRAW_DISABLED); - DrawPanelItem(hPanel, "No"); - return hPanel; -} - -/** -Build the hud displays -*/ -stock Handle:BuildPlayerHudMenu(iClient, iTarget) -{ - - /** - Create all the string variables we will need - */ - new String:sTargetName[MAX_NAME_LENGTH + 1], - String:sTargetID[64], - String:sTargetIP[16]; - - new String:sDisplayName[MAX_NAME_LENGTH + 1], - String:sDisplayID[64], - String:sDisplayIP[64], - String:sDisplayFrags[16], - String:sDisplayDeaths[16]; - - new iTargetFrags, - iTargetDeaths; - - /** - Get the targets information - */ - GetClientName(iTarget, sTargetName, sizeof(sTargetName)); - GetClientIP(iTarget, sTargetIP, sizeof(sTargetIP)); - GetClientAuthString(iTarget, sTargetID, sizeof(sTargetID)); - iTargetFrags = GetClientFrags(iTarget); - iTargetDeaths = GetClientDeaths(iTarget); - - /** - Format the strings for the menu - */ - Format(sDisplayName, sizeof(sDisplayName), "Player: %s", sTargetName); - Format(sDisplayID, sizeof(sDisplayID), "Steam ID: %s", sTargetID); - Format(sDisplayIP, sizeof(sDisplayIP), "IP Address: %s", sTargetIP); - Format(sDisplayFrags, sizeof(sDisplayFrags), "Kills: %i", iTargetFrags); - Format(sDisplayDeaths, sizeof(sDisplayDeaths), "Deaths: %i", iTargetDeaths); - - /** - Create the menu and set the menu options. - */ - new Handle:hMenu = CreateMenu(Menu_PlayerHud); - SetMenuExitBackButton(hMenu, false); - SetMenuTitle(hMenu, "Simple Spectator"); - - AddMenuItem(hMenu, "name", sDisplayName, ITEMDRAW_DISABLED); - AddMenuItem(hMenu, "steamid", sDisplayID, ITEMDRAW_DISABLED); - - if (SM_IsValidAdmin(iClient, g_sAdminFlags)) - { - AddMenuItem(hMenu, "ip", sDisplayIP, ITEMDRAW_DISABLED); - } - - AddMenuItem(hMenu, "kills", sDisplayFrags, ITEMDRAW_DISABLED); - AddMenuItem(hMenu, "deaths", sDisplayDeaths, ITEMDRAW_DISABLED); - - if (g_aPlayers[iClient][iTargetIndex]) - { - AddMenuItem(hMenu, "stop", "Stop Following"); - } - else - { - AddMenuItem(hMenu, "start", "Follow Player"); - } - - if ((GetUserFlagBits(iClient) & ADMFLAG_GENERIC) || (GetUserFlagBits(iClient) & ADMFLAG_ROOT)) - { - if (g_aPlayers[iTarget][bIsFlaggedCheater] && (GetUserFlagBits(iClient) & ADMFLAG_ROOT)) - { - AddMenuItem(hMenu, "removecheater", "Remove Cheater Flag"); - } - else - { - if (CanUserTarget(iClient, iTarget)) - { - AddMenuItem(hMenu, "punish", "Punish Player"); - } - else - { - AddMenuItem(hMenu, "punish", "Punish Player (Immune)", ITEMDRAW_DISABLED); - } - } - } - else - { - AddMenuItem(hMenu, "reportcheater", "Report Cheater"); - } - - SetMenuPagination(hMenu, MENU_NO_PAGINATION); - SetMenuExitButton(hMenu, true); - return hMenu; -} - -stock Handle:BuildPlayerHudPanel(iClient, iTarget) -{ - - /** - Create all the string variables we will need - */ - new String:sTargetName[MAX_NAME_LENGTH + 1], - String:sTargetID[64], - String:sTargetIP[16]; - - new String:sDisplayName[MAX_NAME_LENGTH + 1], - String:sDisplayID[64], - String:sDisplayIP[64], - String:sDisplayFrags[16], - String:sDisplayDeaths[16]; - - new iTargetFrags, - iTargetDeaths; - - /** - Get the targets information - */ - GetClientName(iTarget, sTargetName, sizeof(sTargetName)); - GetClientIP(iTarget, sTargetIP, sizeof(sTargetIP)); - GetClientAuthString(iTarget, sTargetID, sizeof(sTargetID)); - iTargetFrags = GetClientFrags(iTarget); - iTargetDeaths = GetClientDeaths(iTarget); - - /** - Format the strings for the menu - */ - Format(sDisplayName, sizeof(sDisplayName), "Player: %s", sTargetName); - Format(sDisplayID, sizeof(sDisplayID), "Steam ID: %s", sTargetID); - Format(sDisplayIP, sizeof(sDisplayIP), "IP Address: %s", sTargetIP); - Format(sDisplayFrags, sizeof(sDisplayFrags), "Kills: %i", iTargetFrags); - Format(sDisplayDeaths, sizeof(sDisplayDeaths), "Deaths: %i", iTargetDeaths); - - /** - Create the menu and set the menu options. - */ - new Handle:hPanel = CreatePanel(); - SetPanelTitle(hPanel, "Simple Spectator"); - - DrawPanelText(hPanel, "Player Information:"); - DrawPanelText(hPanel, sDisplayName); - DrawPanelText(hPanel, sDisplayID); - if (SM_IsValidAdmin(iClient, g_sAdminFlags)) - { - DrawPanelText(hPanel, sDisplayIP); - } - - DrawPanelText(hPanel, sDisplayFrags); - DrawPanelText(hPanel, sDisplayDeaths); - - if (g_aPlayers[iClient][iTargetIndex]) - { - DrawPanelItem(hPanel, "Stop Following"); - } - else - { - DrawPanelItem(hPanel, "Follow Player"); - } - - if ((GetUserFlagBits(iClient) & ADMFLAG_GENERIC) || (GetUserFlagBits(iClient) & ADMFLAG_ROOT)) - { - if (g_aPlayers[iTarget][bIsFlaggedCheater] && (GetUserFlagBits(iClient) & ADMFLAG_ROOT)) - { - DrawPanelItem(hPanel, "Remove Cheater Flag"); - } - else - { - if (CanUserTarget(iClient, iTarget)) - { - DrawPanelItem(hPanel, "Punish Player"); - } - else - { - DrawPanelItem(hPanel, "Punish Player (Immune)", ITEMDRAW_DISABLED); - } - } - } - else - { - DrawPanelItem(hPanel, "Report Cheater"); - } - - DrawPanelItem(hPanel, "Close Hud Panel"); - return hPanel; -} - -/** -Adjust the settings if a convar was changed -*/ -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - for (new iCvar = 0 ; _:iCvar < sizeof(g_aPluginCvarSettings); iCvar++) - { - if (g_aPluginCvar[_:iCvar] == convar) - { - if (StringToInt(newValue) == 1) - { - g_aPluginCvarSettings[_:iCvar] = true; - } - else - { - g_aPluginCvarSettings[_:iCvar] = false; - } - } - } - - /* - ReBuild the global menu that depends on cvars - */ - g_aMenus[hBanTime] = BuildBanTimeMenu(); - - /** - Run a loop to reset the hud - */ - for(new i = 1; i <= MaxClients; i++) - { - StopDisplayingHud(i); - if (IsClientConnected(i) && IsClientInGame(i) && GetClientTeam(i) == g_aCurrentTeams[Spectator]) - { - StartDisplayingHud(i); - } - } -} diff --git a/Simple Donator Benefits/addons/sourcemod/scripting/simple-teambalancer.sp b/Simple Donator Benefits/addons/sourcemod/scripting/simple-teambalancer.sp deleted file mode 100644 index 3302255..0000000 --- a/Simple Donator Benefits/addons/sourcemod/scripting/simple-teambalancer.sp +++ /dev/null @@ -1,1797 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Team Balancer -Description: - Balances teams based upon player count - Player will not be balanced more than once in 5 (default) mins - Buddy system tries to keep buddies together - Ability to prioritize players - Ability to force players to accept the new team - Admins are immune -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include -#include - -#define PLUGIN_VERSION "2.1.$Rev$" - -enum PlayerData -{ - Handle:hBalanceTimer, - Handle:hForcedTimer, - bool:bSwitched, - bool:bFlagCarrier -}; - -/** - Global convar handles - */ -new Handle:stb_enabled = INVALID_HANDLE; -new Handle:stb_buddyenabled = INVALID_HANDLE; -new Handle:stb_logactivity = INVALID_HANDLE; -new Handle:stb_logactivity2 = INVALID_HANDLE; -new Handle:stb_unbalancelimit = INVALID_HANDLE; -new Handle:stb_deadonly = INVALID_HANDLE; -new Handle:stb_priorityenabled = INVALID_HANDLE; -new Handle:stb_uberlevel = INVALID_HANDLE; -new Handle:stb_balancedelay = INVALID_HANDLE; -new Handle:stb_livingplayerswitchdelay = INVALID_HANDLE; -new Handle:stb_livingplayercheckdelay = INVALID_HANDLE; -new Handle:stb_roundstartdelay = INVALID_HANDLE; -new Handle:stb_switchbackforced = INVALID_HANDLE; -new Handle:stb_adminflag = INVALID_HANDLE; -new Handle:stb_buddyrestriction = INVALID_HANDLE; -new Handle:stb_convarcontrol = INVALID_HANDLE; - -/** - Built-in cvars handles - */ -new Handle:stb_mp_autoteambalance = INVALID_HANDLE; -new Handle:stb_mp_teams_unbalance_limit = INVALID_HANDLE; -new Handle:TFGameModeArena = INVALID_HANDLE; - -/** - Timer handles - */ -new Handle:g_hBalanceTimer = INVALID_HANDLE; -new Handle:g_hLivingPlayerCheckTimer = INVALID_HANDLE; - -/** - Player arrays - */ -new g_aPlayers[MAXPLAYERS + 1][PlayerData]; - -/** -Global bools -*/ -new bool:g_bIsEnabled = true; -new bool:g_bPriorityPlayers = true; -new bool:g_bBuddyRestriction = false; -new bool:g_bLogActivity = false; -new bool:g_bLogActivity2 = false; -new bool:g_bDeadOnly = false; -new bool:g_bConVarControl = true; -new bool:g_bBuddyEnabled = true; -new bool:g_bBalanceInProgress = false; -new bool:g_bRoundStart = false; -new bool:g_bRoundEnd = false; -new bool:g_bSuddenDeath = false; -new bool:g_bIsArenaMode = false; - -/** - Global strings/integers/floats - */ -new g_iUnbalanceLimit, g_iLivingPlayerSwitchDelay, g_iLivingPlayerCheckDelay; -new g_iRoundStartDelay, g_iSwitchBackForced, g_iBalanceDelay; -new Float:g_fUberLevel; -new g_iOwnerOffset; -new String:g_sAdminFlag[5]; - -public Plugin:myinfo = -{ - name = "Simple Team Balancer", - author = "Simple Plugins", - description = "Balances teams based upon player count.", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -} - -public OnPluginStart() -{ - - /** - Create console variables - */ - CreateConVar("stb_version", PLUGIN_VERSION, "Simple Team Balancer", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - stb_enabled = CreateConVar("stb_enabled", "1", "Enable or Disable Simple Team Balancer", _, true, 0.0, true, 1.0); - stb_priorityenabled = CreateConVar("stb_priorityenabled", "1", "Enable or Disable the prioritization of living players", _, true, 0.0, true, 1.0); - stb_buddyrestriction = CreateConVar("stb_buddyrestriction", "0", "Enable or Disable Admin Only buddy lists", _, true, 0.0, true, 1.0); - stb_logactivity = CreateConVar("stb_logactivity", "0", "Enable or Disable the disaplying of events in the log", _, true, 0.0, true, 1.0); - stb_logactivity2 = CreateConVar("stb_logactivity2", "0", "Enable or Disable the disaplying of detailed events in the log (WILL SPAM LOG)", _, true, 0.0, true, 1.0); - stb_deadonly = CreateConVar("stb_deadonly", "0", "Enable or Disable the switching of only dead players", _, true, 0.0, true, 1.0); - stb_convarcontrol = CreateConVar("stb_convarcontrol", "1", "Enable or Disable the control of builtin console variables", _, true, 0.0, true, 1.0); - stb_buddyenabled = CreateConVar("stb_buddyenabled", "1", "Enable or Disable the buddy system", _, true, 0.0, true, 1.0); - stb_unbalancelimit = CreateConVar("stb_unbalancelimit", "2", "Amount of players teams are ALLOWED to be unbalanced by", _, true, 1.0, true, 32.0); - stb_balancedelay = CreateConVar("stb_balancedelay", "10", "Delay in seconds to start an autobalance"); - stb_livingplayerswitchdelay = CreateConVar("stb_livingplayerswitchdelay", "20", "Delay in seconds to switch living players once selected"); - stb_livingplayercheckdelay = CreateConVar("stb_livingplayercheckdelay", "10", "Delay in seconds to start checking living players once teams become unbalanced"); - stb_roundstartdelay = CreateConVar("stb_roundstartdelay", "15", "Delay in seconds to start balancing teams after the start of a round"); - stb_switchbackforced = CreateConVar("stb_switchbackforced", "300", "Amount of time in seconds to not switch a player twice and force the team if enabled"); - stb_uberlevel = CreateConVar("stb_uberlevel", "1.0", "Min uber level medic must have to have priority over other living players. Setting to 0 will rarely switch a living medic", _, true, 0.0, true, 1.0); - stb_adminflag = CreateConVar("stb_adminflag", "a", "Admin flag to use for immunity. Must be a in char format."); - stb_mp_autoteambalance = FindConVar("mp_autoteambalance"); - stb_mp_teams_unbalance_limit = FindConVar("mp_teams_unbalance_limit"); - - /** - Removing the notify tags from the built in cvars. We dont want spam. - */ - if (stb_mp_autoteambalance != INVALID_HANDLE) - { - SetConVarFlags(stb_mp_autoteambalance, GetConVarFlags(stb_mp_autoteambalance)^FCVAR_NOTIFY); - } - if (stb_mp_teams_unbalance_limit != INVALID_HANDLE) - { - SetConVarFlags(stb_mp_teams_unbalance_limit, GetConVarFlags(stb_mp_teams_unbalance_limit)^FCVAR_NOTIFY); - } - - /** - Hook console variables - */ - HookConVarChange(stb_enabled, ConVarSettingsChanged); - HookConVarChange(stb_priorityenabled, ConVarSettingsChanged); - HookConVarChange(stb_buddyrestriction, ConVarSettingsChanged); - HookConVarChange(stb_logactivity, ConVarSettingsChanged); - HookConVarChange(stb_logactivity2, ConVarSettingsChanged); - HookConVarChange(stb_deadonly, ConVarSettingsChanged); - HookConVarChange(stb_convarcontrol, ConVarSettingsChanged); - HookConVarChange(stb_buddyenabled, ConVarSettingsChanged); - HookConVarChange(stb_unbalancelimit, ConVarSettingsChanged); - HookConVarChange(stb_balancedelay, ConVarSettingsChanged); - HookConVarChange(stb_livingplayerswitchdelay, ConVarSettingsChanged); - HookConVarChange(stb_livingplayercheckdelay, ConVarSettingsChanged); - HookConVarChange(stb_roundstartdelay, ConVarSettingsChanged); - HookConVarChange(stb_switchbackforced, ConVarSettingsChanged); - HookConVarChange(stb_uberlevel, ConVarSettingsChanged); - HookConVarChange(stb_mp_autoteambalance, ConVarSettingsChanged); - HookConVarChange(stb_mp_teams_unbalance_limit, ConVarSettingsChanged); - - /** - Create console commands - */ - RegConsoleCmd("sm_buddy", Command_AddBalanceBuddy, "Add a balance buddy"); - RegConsoleCmd("sm_lockbuddy", Command_LockBuddy, "Locks your balance buddy selection"); - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook the game events - */ - LogAction(0, -1, "[STB] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_death", HookPlayerDeath, EventHookMode_Post); - HookEvent("player_team", HookPlayerChangeTeam, EventHookMode_Post); - switch (g_CurrentMod) - { - case GameType_TF: - { - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - HookEvent("teamplay_suddendeath_begin", HookSuddenDeathBegin, EventHookMode_PostNoCopy); - HookEvent("teamplay_flag_event", HookFlagEvent, EventHookMode_Post); - TFGameModeArena = FindConVar("tf_gamemode_arena"); - g_iOwnerOffset = FindSendPropInfo("CBaseObject", "m_hBuilder"); - } - case GameType_DOD: - { - HookEvent("dod_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_Post); - } - default: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - } - } - - /** - Load translations and .cfg file - */ - LoadTranslations ("simpleteambalancer.phrases"); - AutoExecConfig(true, "plugin.simpleteambalancer"); - LogAction(0, -1, "[STB] Simple Team Balancer is loaded."); -} - -public OnAllPluginsLoaded() -{ - //something -} - -public OnLibraryRemoved(const String:name[]) -{ - //something -} - -public OnConfigsExecuted() -{ - - /** - Load up global variables - */ - g_bIsEnabled = GetConVarBool(stb_enabled); - g_bBuddyEnabled = GetConVarBool(stb_buddyenabled); - g_bLogActivity = GetConVarBool(stb_logactivity); - g_bLogActivity2 = GetConVarBool(stb_logactivity2); - g_bDeadOnly = GetConVarBool(stb_deadonly); - g_bPriorityPlayers = GetConVarBool(stb_priorityenabled); - g_bBuddyRestriction = GetConVarBool(stb_buddyrestriction); - g_bConVarControl = GetConVarBool(stb_convarcontrol); - g_fUberLevel = GetConVarFloat(stb_uberlevel); - g_iUnbalanceLimit = GetConVarInt(stb_unbalancelimit); - g_iBalanceDelay = GetConVarInt(stb_balancedelay); - g_iLivingPlayerSwitchDelay = GetConVarInt(stb_livingplayerswitchdelay); - g_iLivingPlayerCheckDelay = GetConVarInt(stb_livingplayercheckdelay); - g_iRoundStartDelay = GetConVarInt(stb_roundstartdelay); - g_iSwitchBackForced = GetConVarInt(stb_switchbackforced); - GetConVarString(stb_adminflag, g_sAdminFlag, sizeof(g_sAdminFlag)); - - /** - Report enabled - */ - if (g_bIsEnabled) - { - LogAction(0, -1, "[STB] Simple Team Balancer is ENABLED."); - } - else - { - LogAction(0, -1, "[STB] Simple Team Balancer is DISABLED."); - } - - - /** - Report log activity - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Log Activity ENABLED."); - } - else - { - LogAction(0, -1, "[STB] Log Activity DISABLED."); - } - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Detailed Log Activity ENABLED."); - } - else - { - LogAction(0, -1, "[STB] Detailed Log Activity DISABLED."); - } -} - -public OnMapStart() -{ - - /** - Check for arena mode - */ - if (g_CurrentMod == GameType_TF && GetConVarBool(TFGameModeArena)) - { - g_bIsArenaMode = true; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Simple Team Balancer detected arena mode and will be bypassed"); - } - } - else - { - g_bIsArenaMode = false; - } - - /** - Reset the globals - */ - g_bBalanceInProgress = false; - g_bRoundStart = false; - g_bRoundEnd = false; - g_bSuddenDeath = false; - - /** - Set the built-in convars - */ - SetGameCvars(); -} - -public OnClientPostAdminCheck(client) -{ - - /** - Make sure its a valid connected client and buddy system is enabled - */ - if (client == 0 || !g_bIsEnabled || !IsClientConnected(client) || !g_bBuddyEnabled) - { - return; - } - - /** - Make sure if its set for admins only they have the flags - */ - if (g_bBuddyRestriction && !SM_IsValidAdmin(client, g_sAdminFlag)) - { - return; - } - - /** - Start the advertisement timer - */ - CreateTimer (60.0, Timer_WelcomeAdvert, client); -} - -public OnClientDisconnect(client) -{ - - /** - Call stock function to cleaup - */ - CleanUp(client); -} - -public OnClientDisconnect_Post(client) -{ - - /** - Determine if we need a balance - */ - if (OkToBalance() && IsUnbalanced() && !g_bBalanceInProgress) - { - - /** - No balance in progress but balance is needed - */ - StartABalance(); - } -} - -public SM_OnPlayerMoved(Handle:plugin, client, team) -{ - - /** - Make sure we called the move function - */ - if (plugin != GetMyHandle()) - { - if (g_bLogActivity2) - { - LogAction(0, client, "[STB] Callback was not started with current plugin, bugging out."); - } - return; - } - - /** - Get the players name and report the event - */ - decl String:sPlayerName[64]; - GetClientName(client, sPlayerName, sizeof(sPlayerName)); - if (g_bLogActivity) - { - LogAction(0, client, "[STB] Changed %s to team %i.", sPlayerName, team); - } - - /** - If we are in TF2 fire the bult-in team balance event - */ - if(g_CurrentMod == GameType_TF) - { - new Handle:event = CreateEvent("teamplay_teambalanced_player"); - SetEventInt(event, "player", client); - SetEventInt(event, "team", team); - FireEvent(event); - } - - /** - Notify the players - */ - PrintToChatAll("[SM] %T", "BalanceMessage", LANG_SERVER, sPlayerName); - - /** - Set the players variables and start a timer - */ - g_aPlayers[client][bSwitched] = true; - g_aPlayers[client][hForcedTimer] = CreateTimer(float(g_iSwitchBackForced), Timer_ForcedExpired, client, TIMER_FLAG_NO_MAPCHANGE); - - /** - We are done, log the completion and end the balance - */ - if (g_bLogActivity) - { - LogAction(0, client, "[STB] Balance finished."); - } - g_bBalanceInProgress = false; -} - -/* HOOKED EVENTS */ - -public HookPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get our event variables - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - decl String:sWeapon[64]; - GetEventString(event, "weapon", sWeapon, sizeof(sWeapon)); - - /** - Return if death was not caused by a player - This is the case when the player switches teams - */ - if (StrEqual(sWeapon, "world", false)) - { - return; - } - - - /** - Check if balance is needed - */ - if (IsClientInGame(iClient) && OkToBalance() && IsUnbalanced()) - { - new iSmallerTeam = GetSmallerTeam(); - - /** - Check if balance is in progress - */ - if (g_bBalanceInProgress) - { - - /** - There is a balance in progress - Check the player who died to see if he is supposed to be switched - */ - if (g_aPlayers[iClient][hBalanceTimer] != INVALID_HANDLE) - { - - /** - The player has a timer on him to switch him to other team - Stop the timer - */ - CloseHandle(g_aPlayers[iClient][hBalanceTimer]); - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - if (g_bLogActivity) - { - LogAction(0, iClient, "[STB] With a balance in progress the queued living player died and was switched."); - } - - /** - Call the stock change team function - */ - BalancePlayer(iClient, SM_GetForcedTeam(iClient)); - return; - } - - /** - Before we continue, lets make sure the client is switchable - */ - if (IsSwitchablePlayer(iClient, GetBiggerTeam())) - { - - /** - Now we check the buddy system - */ - if (g_bBuddyEnabled) - { - - /** - Buddy system is enabled, check to see if client has buddy - */ - new iBuddyIndex = SM_GetClientBuddy(iClient); - if (iBuddyIndex != 0 || !IsClientConnected(iBuddyIndex) || !IsClientInGame(iBuddyIndex)) - { - - /** - The client has a buddy, so we check to see if they are on same team - */ - if (GetClientTeam(iClient) == GetClientTeam(iBuddyIndex)) - { - - /** - They are, but we don't bug out, we still need to start a balance - */ - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] With a balance in progress a buddy on the right team was found and skipped."); - } - } - else - { - - /** - They are not on the same team - The buddy could be in spec, and that would make it not matter where he is, or the buddy is on the smaller team - */ - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] With a balance in progress a buddy on the wrong team was switched."); - } - BalancePlayer(iClient, iSmallerTeam); - return; - } - } - else - { - - /** - Client doesn't have a buddy, balance this player - */ - BalancePlayer(iClient, iSmallerTeam); - return; - } - } - else - { - - /** - Buddy system is not enabled, balance this player - */ - BalancePlayer(iClient, iSmallerTeam); - return; - } - } - } - else - { - - /** - If we get to here then we must need to start a balance - */ - StartABalance(); - } - } -} - -public HookPlayerChangeTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get our event variables. - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - new iTeam = GetEventInt(event, "team"); - - /** - Make sure its ok to balance. - */ - if (OkToBalance()) - { - - /** - See if the client that changed teams was set to with a balance. - */ - if (g_aPlayers[iClient][hBalanceTimer] != INVALID_HANDLE - && SM_GetForcedTeam(iClient) == iTeam - && g_bBalanceInProgress) - { - - /** - The client was set to be balanced, so we close the timer. - */ - CloseHandle(g_aPlayers[iClient][hBalanceTimer]); - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - - /** - Stop the balance. - */ - g_bBalanceInProgress = false; - return; - } - - /** - It's not likely that this team change can cause us to need a balance. - If it does, start one with a small dealy to deal with forced switch backs. - */ - if (IsUnbalanced() && !g_bBalanceInProgress) - { - CreateTimer(2.0, Timer_ChangeTeamBalanceDelay, _, TIMER_FLAG_NO_MAPCHANGE); - } - } -} - -public HookRoundStart(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Set the variables we need to start a round - */ - g_bRoundStart = true; - g_bRoundEnd = false; - g_bSuddenDeath = false; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Round Started"); - } - - /** - Start a delayed balance check at the start of the round - */ - CreateTimer(float(g_iRoundStartDelay), Timer_RoundStart); -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Set the variables we need at round end - */ - g_bRoundEnd = true; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Round Ended"); - } -} - -public HookSuddenDeathBegin(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Set the variables we need for sudden death - */ - g_bSuddenDeath = true; -} - -public HookFlagEvent(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get our event variables - */ - new iClient = GetEventInt(event, "player"); - new iFlagStatus = GetEventInt(event, "eventtype"); - - /** - Make sure we have a valid client - */ - if (!IsClientInGame(iClient)) - { - return; - } - - /** - Determine what kind of event this is - */ - switch (iFlagStatus) - { - case 1: - { - - /** - The flag was picked up - */ - g_aPlayers[iClient][bFlagCarrier] = true; - } - case 2: - { - - /** - The flag was capped - */ - g_aPlayers[iClient][bFlagCarrier] = false; - } - case 3: - { - - /** - The flag was defended, we don't have to do anything - */ - } - case 4: - { - - /** - The flag was dropped - */ - g_aPlayers[iClient][bFlagCarrier] = false; - } - } -} - -/* COMMAND EVENTS */ - -public Action:Command_AddBalanceBuddy(client, args) -{ - if (client == 0) - { - ReplyToCommand(client, "[SM] %T", "PlayerLevelCmd", LANG_SERVER); - return Plugin_Handled; - } - if (!g_bIsEnabled || !g_bBuddyEnabled) - { - ReplyToCommand(client, "[SM] %T", "CmdDisabled", LANG_SERVER); - return Plugin_Handled; - } - if (g_bBuddyRestriction) - { - if (!SM_IsValidAdmin(client, g_sAdminFlag)) - { - ReplyToCommand(client, "[SM] %T", "RestrictedBuddy", LANG_SERVER); - return Plugin_Handled; - } - } - decl String:sPlayerUserId[24]; - GetCmdArg(1, sPlayerUserId, sizeof(sPlayerUserId)); - new iPlayer = GetClientOfUserId(StringToInt(sPlayerUserId)); - if (!iPlayer || !IsClientInGame(iPlayer) || client == iPlayer) - { - if (client == iPlayer) - { - PrintHintText(client, "%T", "SelectSelf", LANG_SERVER); - } - ReplyToCommand(client, "[SM] Usage: buddy "); - new Handle:playermenu = BuildPlayerMenu(); - DisplayMenu(playermenu, client, MENU_TIME_FOREVER); - } - else - { - decl String:cName[128]; - decl String:bName[128]; - GetClientName(client, cName, sizeof(cName)); - GetClientName(iPlayer, bName, sizeof(bName)); - if (SM_IsBuddyLocked(iPlayer)) - { - ReplyToCommand(client, "[SM] %T", "PlayerLockedBuddyMsg", LANG_SERVER, bName); - return Plugin_Handled; - } - SM_AssignBuddy(client, iPlayer); - PrintHintText(client, "%T", "BuddyMsg", LANG_SERVER, bName); - PrintHintText(iPlayer, "%T", "BuddyMsg", LANG_SERVER, cName); - } - return Plugin_Handled; -} - -public Action:Command_LockBuddy(client, args) -{ - if (client == 0) - { - ReplyToCommand(client, "[SM] %T", "PlayerLevelCmd", LANG_SERVER); - return Plugin_Handled; - } - if (!g_bIsEnabled) - { - ReplyToCommand(client, "[SM] %T", "CmdDisabled", LANG_SERVER); - return Plugin_Handled; - } - if (g_bBuddyRestriction) - { - if (!SM_IsValidAdmin(client, g_sAdminFlag)) - { - ReplyToCommand(client, "[SM] %T", "RestrictedBuddy", LANG_SERVER); - return Plugin_Handled; - } - } - if (SM_IsBuddyLocked(client)) - { - SM_LockBuddy(client, false); - PrintHintText(client, "%T", "BuddyLockMsgDisabled", LANG_SERVER); - } - else - { - SM_LockBuddy(client, true); - PrintHintText(client, "%T", "BuddyLockMsgEnabled", LANG_SERVER); - } - return Plugin_Handled; -} - -/** -Stock functions . - */ - -stock bool:IsUnbalanced() -{ - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Checking if teams are unbalanced"); - } - new Team1Count = GetTeamClientCount(g_aCurrentTeams[Team1]); - new Team2Count = GetTeamClientCount(g_aCurrentTeams[Team2]); - new ubCount = RoundFloat(FloatAbs(float(Team1Count - Team2Count))); - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Team1:%i Team2:%i Difference:%i", Team1Count, Team2Count, ubCount); - } - if (ubCount > g_iUnbalanceLimit) - { - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Teams are unbalanced"); - } - return true; - } - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Teams are not unbalanced"); - } - return false; -} - -stock bool:OkToBalance() -{ - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Checking if OK to balance."); - } - new bool:bResult = false; - if (g_bIsEnabled && !g_bRoundStart && !g_bRoundEnd && !g_bIsArenaMode && !g_bSuddenDeath) - { - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Passed IF statement"); - LogAction(0, -1, "[STB] Now checking admins"); - } - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientInGame(i) && !SM_IsValidAdmin(i, g_sAdminFlag)) - { - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Found at least 1 non-admin"); - LogAction(0, -1, "[STB] OK to balance"); - } - bResult = true; - break; - } - } - if (!bResult && g_bLogActivity2) - { - LogAction(0, -1, "[STB] All admins online"); - } - } - if (!bResult && g_bLogActivity2) - { - LogAction(0, -1, "[STB] Not OK to balance"); - } - return bResult; -} - -stock bool:IsSwitchablePlayer(iClient, iBiggerTeam) -{ - - /** - Run the client thru some standard checks - */ - if (!IsClientInGame(iClient) - || SM_IsValidAdmin(iClient, g_sAdminFlag) - || g_aPlayers[iClient][bFlagCarrier] - || GetClientTeam(iClient) != iBiggerTeam - || g_aPlayers[iClient][bSwitched]) - { - - /** - The supplied client can't be switched - */ - return false; - } - - /** - The supplied client can be switched - */ - return true; -} - -stock bool:HasUber(iClient) -{ - - /** - First things first, make sure the client is a medic - */ - if(TF2_GetPlayerClass(iClient) == TFClass_Medic) - { - - /** - We can only check the active weapon, so make sure the client is holding the uber gun - */ - decl String:sWeaponName[32]; - GetClientWeapon(iClient, sWeaponName, sizeof(sWeaponName)); - if(StrEqual(sWeaponName, "tf_weapon_medigun")) - { - - /** - They are, so lets check the uber level of the gun - */ - new iEntityIndex = GetEntDataEnt2(iClient, FindSendPropInfo("CTFPlayer", "m_hActiveWeapon")); - new Float:fChargeLevel = GetEntDataFloat(iEntityIndex, FindSendPropInfo("CWeaponMedigun", "m_flChargeLevel")); - if (fChargeLevel >= g_fUberLevel) - { - - /** - The client supplied has an uber above the supplied level, return true - */ - if (g_bLogActivity2) - { - LogAction(0, iClient, "[STB] Found a medic with a uber and skipped him."); - } - return true; - } - } - } - - /** - The client supplied does not have an uber above the supplied level, return false - */ - return false; -} - -stock bool:HasBuildingsBuilt(iClient) -{ - - /** - We have to start a loop to check the owner of all the valid entities - */ - new iMaxEntities = GetMaxEntities(); - for (new i = MaxClients + 1; i <= iMaxEntities; i++) - { - if (!IsValidEntity(i)) - { - - /** - Not valid, continue to next one - */ - continue; - } - - /** - Get the name of the current entity - */ - decl String:sNetClass[32]; - GetEntityNetClass(i, sNetClass, sizeof(sNetClass)); - - /** - See if its something that an engineer would build - */ - if (strcmp(sNetClass, "CObjectSentrygun") == 0 - || strcmp(sNetClass, "CObjectTeleporter") == 0 - || strcmp(sNetClass, "CObjectDispenser") == 0) - { - - /** - It is, so lets check the owner - */ - if (GetEntDataEnt2(i, g_iOwnerOffset) == iClient) - { - - /** - The client supplied is the owner, return true - */ - if (g_bLogActivity2) - { - LogAction(0, iClient, "[STB] Found an engineer with buildings and skipped him."); - } - return true; - } - } - } - - /** - The client supplied didn't have any buildings, return false - */ - return false; -} - -stock StartABalance() -{ - - /** - See if we are already started a balance - */ - if (g_hBalanceTimer != INVALID_HANDLE) - { - - /** - We have, check if we still need to - */ - if (!IsUnbalanced() || !OkToBalance()) - { - - /** - We don't, stop the balance - It's almost impossible to reach this code, but we do it just in case - */ - CloseHandle(g_hBalanceTimer); - g_hBalanceTimer = INVALID_HANDLE; - g_bBalanceInProgress = false; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Balance delay timer was not needed and was killed before the callback."); - } - return; - } - else - { - - /** - We still need to balance - Bug out and wait for the current one to finish - */ - return; - } - } - - /** - Report that teams are unbalanced - */ - PrintToChatAll("[SM] %T", "UnBalanced", LANG_SERVER); - - /** - Check to see if we are supposed to delay the balance - */ - if (g_iBalanceDelay == 0) - { - - /** - Start the balance now - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Balance is now in progress."); - } - g_bBalanceInProgress = true; - g_hBalanceTimer = INVALID_HANDLE; - - /** - Check if we are allowed to scan living players - */ - if (!g_bDeadOnly) - { - - /** - We are allowed to, so we start a timer - */ - StartALivingPlayerTimer(); - - /** - Also report that we are now scanning dead players as well - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Now scanning dead players."); - } - } - else - { - - /** - We are not allowed to, so report that we are only scanning dead players - */ - if (g_bLogActivity) - LogAction(0, -1, "[STB] Only scanning dead players."); - } - - /** - We started the balance, bug out - */ - return; - } - - /** - We are supposed to delay the balance, start a balance timer - */ - g_hBalanceTimer = CreateTimer(float(g_iBalanceDelay), Timer_BalanceTeams, _, TIMER_FLAG_NO_MAPCHANGE); - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Teams are unbalanced. Balance delay timer started."); - } -} - -stock StartALivingPlayerTimer() -{ - - /** - Start a timer to check living players - */ - if (g_hLivingPlayerCheckTimer != INVALID_HANDLE) - { - - /** - If we for some reason already have one started, stop it. - */ - CloseHandle(g_hLivingPlayerCheckTimer); - g_hLivingPlayerCheckTimer = INVALID_HANDLE; - } - - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Living player balance delay timer started."); - } - g_hLivingPlayerCheckTimer = CreateTimer(float(g_iLivingPlayerCheckDelay), Timer_LivingPlayerCheck, _, TIMER_FLAG_NO_MAPCHANGE); -} - -stock FindSwitchablePlayer() -{ - - /** - Start a loop to find a switchable player - */ - new iPlayer; - new iBiggerTeam = GetBiggerTeam(); - for (new i = 1; i <= MaxClients; i++) - { - - /** - Check the stock function to see if we are allows to even switch the player - */ - if (!IsSwitchablePlayer(i, iBiggerTeam)) - { - continue; - } - - /** - If the mod is TF2 and they have Priority Players set check if the client has buildings or an uber - */ - if (g_CurrentMod == GameType_TF && g_bPriorityPlayers) - { - if (HasUber(i) || HasBuildingsBuilt(i)) - { - continue; - } - } - - /** - So far we are able we switch this player - Now we check the buddy system - */ - if (g_bBuddyEnabled) - { - - /** - Buddy system is enabled, check to see if client has buddy - */ - if (SM_GetClientBuddy(i) != 0) - { - - /** - The client has a buddy, so we check to see if they are on same team - */ - if (GetClientTeam(i) == GetClientTeam(SM_GetClientBuddy(i))) - { - - /** - They are, so we continue to next client - */ - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] With a balance in progress a buddy on the right team was found and skipped."); - } - continue; - } - else - { - - /** - They are not on the same team, set this client - The buddy could be in spec, and that would make it not matter where he is, or the buddy is on the smaller team - */ - iPlayer = i; - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] With a balance in progress a buddy on the wrong team was found."); - } - break; - } - } - else - { - - /** - The client does not have a buddy, set this client - */ - iPlayer = i; - break; - } - } - else - { - - /** - Buddy system is not enabled, set this client - */ - iPlayer = i; - break; - } - } - - /** - Return the client we set, this could be 0, but very unlikely - */ - return iPlayer; -} - -stock BalancePlayer(iClient, iTeam) -{ - new Handle:hPack = CreateDataPack(); - WritePackCell(hPack, iClient); - WritePackCell(hPack, iTeam); - CreateTimer(0.1, Timer_BalancePlayer, hPack, TIMER_FLAG_NO_MAPCHANGE); -} - -stock CleanUp(iClient) -{ - g_aPlayers[iClient][bFlagCarrier] = false; - g_aPlayers[iClient][bSwitched] = false; - if (g_aPlayers[iClient][hForcedTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[iClient][hForcedTimer]); - g_aPlayers[iClient][hForcedTimer] = INVALID_HANDLE; - if (g_bLogActivity) - { - LogAction(0, iClient, "[STB] Forced player disconnected, killing timer."); - } - } - if (g_aPlayers[iClient][hBalanceTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[iClient][hBalanceTimer]); - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - if (g_bLogActivity) - { - LogAction(0, iClient, "[STB] Living player set to be balanced disconnected, killing timer."); - } - } -} - -stock GetSmallerTeam() -{ - - /** - Get the count of players on each team - */ - new iCountT1 = GetTeamClientCount(g_aCurrentTeams[Team1]); - new iCountT2 = GetTeamClientCount(g_aCurrentTeams[Team2]); - - /** - Return the smaller team - */ - if (iCountT1 < iCountT2) - { - return g_aCurrentTeams[Team1]; - } - else if (iCountT1 > iCountT2) - { - return g_aCurrentTeams[Team2]; - } - return 0; -} - -stock GetBiggerTeam() -{ - - /** - Get the count of players on each team - */ - new iCountT1 = GetTeamClientCount(g_aCurrentTeams[Team1]); - new iCountT2 = GetTeamClientCount(g_aCurrentTeams[Team2]); - - /** - Return the bigger team - */ - if (iCountT1 > iCountT2) - { - return g_aCurrentTeams[Team1]; - } - else if (iCountT1 < iCountT2) - { - return g_aCurrentTeams[Team2]; - } - return 0; -} - -stock SetGameCvars() -{ - if (g_bConVarControl && g_bIsEnabled) - { - if (stb_mp_autoteambalance != INVALID_HANDLE) - { - SetConVarInt(stb_mp_autoteambalance, 0); - } - if (stb_mp_teams_unbalance_limit != INVALID_HANDLE) - { - SetConVarInt(stb_mp_teams_unbalance_limit, g_iUnbalanceLimit); - } - } -} - -/* TIMER FUNCTIONS */ - -public Action:Timer_ChangeTeamBalanceDelay(Handle:timer, any:data) -{ - - /** - Finally start one if it's still unbalanced - */ - if (IsUnbalanced() && !g_bBalanceInProgress) - { - StartABalance(); - } -} - -public Action:Timer_BalanceTeams(Handle:timer, any:data) -{ - - /** - See if we still need to balance the teams - */ - if (!IsUnbalanced() || !OkToBalance()) - { - - /** - We don't, kill the balance - */ - g_bBalanceInProgress = false; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Balance delay timer was not needed and died."); - } - g_hBalanceTimer = INVALID_HANDLE; - return Plugin_Handled; - } - - /** - We still need to balance the teams - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Teams are still unbalanced. Balance is now in progress."); - } - g_bBalanceInProgress = true; - - - /** - Check if we are allowed to scan living players - */ - if (!g_bDeadOnly) - { - - /** - We are allowed to, so we start a timer - */ - StartALivingPlayerTimer(); - - /** - Also report that we are now scanning dead players as well - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Now scanning dead players."); - } - } - else - { - - /** - We are not allowed to, so report that we are only scanning dead players - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Only scanning dead players."); - } - } - - g_hBalanceTimer = INVALID_HANDLE; - return Plugin_Handled; -} - -public Action:Timer_LivingPlayerCheck(Handle:timer, any:data) -{ - - /** - Check to see if we still need to balance the teams - */ - if (!IsUnbalanced() || !OkToBalance()) - { - - /** - We don't, kill it and bug out - */ - g_bBalanceInProgress = false; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Living player balance delay timer was not needed and died."); - } - g_hLivingPlayerCheckTimer = INVALID_HANDLE; - return Plugin_Handled; - } - - /** - Call the stock function to find a player we can switch - */ - new iPlayer = FindSwitchablePlayer(); - - /** - Check to see if we found a player - */ - if (iPlayer == 0) - { - - /** - In the unlikely event that the stock function didn't return a player - Start a loop to find a random player - */ - new iBiggerTeam = GetBiggerTeam(); - do - { - iPlayer = GetRandomInt(1, MaxClients); - } while (!IsSwitchablePlayer(iPlayer, iBiggerTeam)); - - if (g_bLogActivity) - { - LogAction(0, iPlayer, "[STB] Found a random living player."); - } - } - else - { - if (g_bLogActivity) - { - LogAction(0, iPlayer, "[STB] Found a living player."); - } - } - - /** - Now that we have a player assigned them to the smaller team - */ - new iSmallerTeam = GetSmallerTeam(); - SM_SetForcedTeam(iPlayer, iSmallerTeam, true); - - /** - Let the player know we could be switching him soon - */ - PrintHintText(iPlayer, "%T", "PlayerMessage", LANG_SERVER, g_iLivingPlayerSwitchDelay); - if (g_bLogActivity) - { - LogAction(0, iPlayer, "[STB] Living player placed on a timer."); - } - - /** - Create a timer to switch the player - */ - g_aPlayers[iPlayer][hBalanceTimer] = CreateTimer(float(g_iLivingPlayerSwitchDelay), Timer_LivingPlayerBalance, iPlayer, TIMER_FLAG_NO_MAPCHANGE); - - /** - Reset the timer handle - */ - g_hLivingPlayerCheckTimer = INVALID_HANDLE; - - /** - We are done, bug out - */ - return Plugin_Handled; -} - -public Action:Timer_LivingPlayerBalance(Handle:timer, any:iClient) -{ - - /** - Check to make sure we still need to balance - */ - if (!IsUnbalanced() || !OkToBalance()) - { - - /** - We don't need to balance, bug out - */ - g_bBalanceInProgress = false; - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - SM_ClearForcedTeam(iClient); - return Plugin_Handled; - } - - /** - We still need to balance, lets make sure we can still balance this player - */ - if (!IsClientConnected(iClient) || g_aPlayers[iClient][bFlagCarrier]) - { - g_bBalanceInProgress = false; - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - SM_ClearForcedTeam(iClient); - if (g_bLogActivity) - { - if (g_aPlayers[iClient][bFlagCarrier]) - { - LogAction(0, iClient, "[STB] Living player became flag carrier, balance restarted."); - } - else - { - LogAction(0, iClient, "[STB] Living player timer was not needed and died."); - } - } - return Plugin_Handled; - } - - /** - Clear to balance this player, so do it - */ - BalancePlayer(iClient, SM_GetForcedTeam(iClient)); - if (g_bLogActivity) - { - LogAction(0, iClient, "[STB] Living player was switched."); - } - - /** - We are done, bug out - */ - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - return Plugin_Handled; -} - -public Action:Timer_BalancePlayer(Handle:timer, Handle:pack) -{ - - /** - Rest the datapack and load the variables - */ - ResetPack(pack); - new iClient = ReadPackCell(pack); - new iUnBalancedTeam = ReadPackCell(pack); - - /** - We are done with you now - */ - CloseHandle(pack); - - /** - Check the team and make sure its a valid team - */ - if(!SM_IsValidTeam(iUnBalancedTeam)) - { - if (g_bLogActivity) - { - LogAction(0, iClient, "[STB] Balance failed due to invalid team number %i", iUnBalancedTeam); - } - return Plugin_Handled; - } - - /** - Use our core function to change the clients team - */ - SM_MovePlayer(iClient, iUnBalancedTeam); - - return Plugin_Handled; -} - -public Action:Timer_RoundStart(Handle:timer, any:data) -{ - g_bRoundStart = false; - if (OkToBalance() && IsUnbalanced() && !g_bBalanceInProgress) - { - StartABalance(); - } - return Plugin_Handled; -} - -public Action:Timer_ForcedExpired(Handle:timer, any:iClient) -{ - SM_ClearForcedTeam(iClient); - g_aPlayers[iClient][bSwitched] = false; - g_aPlayers[iClient][hForcedTimer] = INVALID_HANDLE; - return Plugin_Handled; -} - -public Action:Timer_WelcomeAdvert(Handle:timer, any:iClient) -{ - if (IsClientConnected(iClient) && IsClientInGame(iClient)) - { - PrintToChat (iClient, "\x01\x04[STB]\x01 %T", "BuddyWelcomeMsg1", LANG_SERVER); - PrintToChat (iClient, "\x01\x04[STB]\x01 %T", "BuddyWelcomeMsg2", LANG_SERVER); - PrintToChat (iClient, "\x01\x04[STB]\x01 %T", "BuddyWelcomeMsg3", LANG_SERVER); - } - return Plugin_Handled; -} - -/* CONSOLE VARIABLE CHANGE EVENT */ - -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (convar == stb_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsEnabled = false; - PrintToChatAll("[SM] %T", "Disabled", LANG_SERVER); - LogAction(0, -1, "[SimpleTeamBalancer] Disabled"); - } - else - { - g_bIsEnabled = true; - SetGameCvars(); - PrintToChatAll("[SM] %T", "Enabled", LANG_SERVER); - LogAction(0, -1, "[SimpleTeamBalancer] Enabled"); - } - } - else if (convar == stb_logactivity) - { - if (StringToInt(newValue) == 0) - { - g_bLogActivity = false; - LogAction(0, -1, "[STB] Log Activity DISABLED."); - } - else - { - g_bLogActivity = true; - LogAction(0, -1, "[STB] Log Activity ENABLED."); - } - } - else if (convar == stb_logactivity2) - { - if (StringToInt(newValue) == 0) - { - g_bLogActivity2 = false; - LogAction(0, -1, "[STB] Detailed Log Activity DISABLED."); - } - else - { - g_bLogActivity2 = true; - LogAction(0, -1, "[STB] Detailed Log Activity ENABLED."); - } - } - else if (convar == stb_convarcontrol) - { - if (StringToInt(newValue) == 0) - { - g_bConVarControl = false; - } - else - { - g_bConVarControl = true; - SetGameCvars(); - } - } - else if (convar == stb_deadonly) - { - if (StringToInt(newValue) == 0) - { - g_bDeadOnly = false; - } - else - { - g_bDeadOnly = true; - } - } - else if (convar == stb_priorityenabled) - { - if (StringToInt(newValue) == 0) - { - g_bPriorityPlayers = false; - } - else - { - g_bPriorityPlayers = true; - } - } - else if (convar == stb_buddyenabled) - { - if (StringToInt(newValue) == 0) - { - g_bBuddyEnabled = false; - } - else - { - g_bBuddyEnabled = true; - } - } - else if (convar == stb_buddyrestriction) - { - if (StringToInt(newValue) == 0) - { - g_bBuddyRestriction = false; - } - else - { - g_bBuddyRestriction = true; - } - } - else if (convar == stb_unbalancelimit) - { - g_iUnbalanceLimit = StringToInt(newValue); - SetGameCvars(); - } - else if (convar == stb_balancedelay) - { - g_iBalanceDelay = StringToInt(newValue); - } - else if (convar == stb_roundstartdelay) - { - g_iRoundStartDelay = StringToInt(newValue); - } - else if (convar == stb_livingplayerswitchdelay) - { - g_iLivingPlayerSwitchDelay = StringToInt(newValue); - } - else if (convar == stb_livingplayercheckdelay) - { - g_iLivingPlayerCheckDelay = StringToInt(newValue); - } - else if (convar == stb_uberlevel) - { - g_fUberLevel = StringToFloat(newValue); - } - else if (convar == stb_switchbackforced) - { - g_iSwitchBackForced = StringToInt(newValue); - } - else if (convar == stb_adminflag) - { - SetConVarString(stb_adminflag, newValue); - } - else if (convar == stb_mp_autoteambalance) - { - SetGameCvars(); - } - else if (convar == stb_mp_teams_unbalance_limit) - { - SetGameCvars(); - } -} - -/* MENU CODE */ - -stock Handle:BuildPlayerMenu() -{ - new Handle:menu = CreateMenu(Menu_SelectPlayer); - AddTargetsToMenu(menu, 0, true, false); - SetMenuTitle(menu, "Select A Player:"); - SetMenuExitButton(menu, true); - return menu; -} - -public Menu_SelectPlayer(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[24]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - new buddy = GetClientOfUserId(StringToInt(sSelection)); - if (param1 == buddy) { - PrintHintText(param1, "%T", "SelectSelf", LANG_SERVER); - } else if (!IsClientInGame(buddy)) { - PrintHintText(param1, "%T", "BuddyGone", LANG_SERVER); - } else { - decl String:cName[128]; - decl String:bName[128]; - GetClientName(param1, cName, sizeof(cName)); - GetClientName(buddy, bName, sizeof(bName)); - if (!SM_IsBuddyLocked(buddy)) { - SM_AssignBuddy(param1, buddy); - PrintHintText(param1, "%T", "BuddyMsg", LANG_SERVER, bName); - PrintHintText(buddy, "%T", "BuddyMsg", LANG_SERVER, cName); - } else - PrintHintText(param1, "%T", "PlayerLockedBuddyMsg", LANG_SERVER, bName); - } - } else if (action == MenuAction_End) { - CloseHandle(menu); - } -} \ No newline at end of file diff --git a/Simple Donator Benefits/addons/sourcemod/scripting/simple-teammanager.sp b/Simple Donator Benefits/addons/sourcemod/scripting/simple-teammanager.sp deleted file mode 100644 index 008f443..0000000 --- a/Simple Donator Benefits/addons/sourcemod/scripting/simple-teammanager.sp +++ /dev/null @@ -1,1351 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Team Manager -Description: - Manges players and their team - Admin menu integration - Allows admins/donators to swap their teams (clears force)* - Allows admins to move players to a team (forced\unforced)* - Allows admins to scramble the teams* - *Works with Simple Team Balancer (if installed) -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include - -#define PLUGIN_VERSION "2.1.$Rev$" -#define VOTE_YES "##YES##" -#define VOTE_NO "##NO##" - -enum PlayerData -{ - iNewTeam, - bool:bQueue -}; - -new Handle:stm_enabled = INVALID_HANDLE; -new Handle:stm_logactivity = INVALID_HANDLE; -new Handle:stm_adminflag_swapteam = INVALID_HANDLE; -new Handle:stm_adminflag_moveplayer = INVALID_HANDLE; -new Handle:stm_adminflag_scramble = INVALID_HANDLE; -new Handle:stm_scrambledelay = INVALID_HANDLE; -new Handle:stm_voteenabled = INVALID_HANDLE; -new Handle:stm_votewin = INVALID_HANDLE; -new Handle:stm_votedelay = INVALID_HANDLE; -new Handle:stm_mp_bonusroundtime = INVALID_HANDLE; -new Handle:g_hAdminMenu = INVALID_HANDLE; -new Handle:g_hTimerPrepScramble = INVALID_HANDLE; -new Handle:g_hTimerClearScrambleForce = INVALID_HANDLE; - -new g_aPlayers[MAXPLAYERS + 1][PlayerData]; - -new bool:g_bIsEnabled = true; -new bool:g_bVoteEnabled = true; -new bool:g_bLogActivity = true; -new bool:g_bScrambleRoundEnd = false; -new g_iVoteDelay, g_iLastVoteTime, g_iTimeLeft; -new Float:g_fScrambleDelay, Float:g_fVoteWin; - -public Plugin:myinfo = -{ - name = "Simple Team Manager", - author = "Simple Plugins", - description = "Manages players and thier team.", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -}; - -public OnPluginStart() -{ - - /** - Need to create all of our console variables. - */ - CreateConVar("stm_version", PLUGIN_VERSION, "Simple Team Manager Version",FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - stm_enabled = CreateConVar("stm_enabled", "1", "Enable or Disable Simple Team Manager", _, true, 0.0, true, 1.0); - stm_logactivity = CreateConVar("stm_logactivity", "0", "Enable or Disable the disaplying of events in the log", _, true, 0.0, true, 1.0); - stm_adminflag_swapteam = CreateConVar("stm_adminflag_swapteam", "a", "Admin flag to use for the swapteam command. Must be a in char format."); - stm_adminflag_moveplayer = CreateConVar("stm_adminflag_moveplayer", "c", "Admin flag to use for the moveplayer command. Must be a in char format."); - stm_adminflag_scramble = CreateConVar("stm_adminflag_scramble", "c", "Admin flag to use for the scrambleteam command. Must be a in char format."); - stm_scrambledelay = CreateConVar("stm_scrambledelay", "15", "Delay to scramble teams"); - stm_voteenabled = CreateConVar("stm_voteenabled", "1", "Enable or Disable voting to scramble the teams", _, true, 0.0, true, 1.0); - stm_votewin = CreateConVar("stm_votewin", "0.45", "Win percentage vote must win by", _, true, 0.0, true, 1.0); - stm_votedelay = CreateConVar("stm_votedelay", "600", "Delay before another vote can be cast"); - stm_mp_bonusroundtime = FindConVar("mp_bonusroundtime"); - - - /** - Need deal with changes to the console variables after the plugin is loaded. - We could not do this and just call the actual console variable each time we need it, but it's not efficent. - */ - HookConVarChange(stm_enabled, ConVarSettingsChanged); - HookConVarChange(stm_logactivity, ConVarSettingsChanged); - HookConVarChange(stm_scrambledelay, ConVarSettingsChanged); - HookConVarChange(stm_voteenabled, ConVarSettingsChanged); - HookConVarChange(stm_votewin, ConVarSettingsChanged); - HookConVarChange(stm_votedelay, ConVarSettingsChanged); - - /** - Need to register the commands we are going to create and use. - */ - RegConsoleCmd("sm_swapteam", Command_SwapTeam, "sm_swapteam <[0]instant/[1]queued>: Swaps your team to the other team"); - RegConsoleCmd("sm_moveplayer", Command_MovePlayer, "sm_moveplayer <[0]instant/[1]ondeath> <[0]unforced/[1]forced>: Moves a player to the specified team"); - RegConsoleCmd("sm_scrambleteams", Command_ScrambleTeams, "sm_scrambleteams: <[0]now/[1]roundend> <[0]dontrestart/[1]restartround> Scrambles the current teams"); - RegConsoleCmd("sm_votescramble", Command_VoteScramble, "sm_votescramble: Starts a vote to scramble the teams"); - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook the game events - */ - LogAction(0, -1, "[STM] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_death", HookPlayerDeath, EventHookMode_Post); - HookEvent("player_team", HookPlayerChangeTeam, EventHookMode_Post); - switch (g_CurrentMod) - { - case GameType_TF: - { - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - } - case GameType_DOD: - { - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_Post); - } - default: - { - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - } - } - - /** - Now we have to deal with the admin menu. If the admin library is loaded call the function to add our items. - */ - new Handle:gTopMenu; - if (LibraryExists("adminmenu") && ((gTopMenu = GetAdminTopMenu()) != INVALID_HANDLE)) - { - OnAdminMenuReady(gTopMenu); - } - - /** - Load translations and .cfg file - */ - LoadTranslations ("simpleteammanager.phrases"); - AutoExecConfig(true, "plugin.simpleteammanager"); - LogAction(0, -1, "[STM] Simple Team Manager is loaded."); -} - -public OnAllPluginsLoaded() -{ - //something -} - -public OnLibraryRemoved(const String:name[]) -{ - if (StrEqual(name, "adminmenu")) - { - - /** - Looks like the admin menu was removed. Set the global. - */ - g_hAdminMenu = INVALID_HANDLE; - } - else if (StrEqual(name, "simpleplugins")) - { - SetFailState("Required plugin Simple SourceMod Plugins Core was removed."); - } -} - -public OnConfigsExecuted() -{ - - /** - Once we loaded up all the console variables from the config file, lets now set all the global variables we will use. - */ - g_bIsEnabled = GetConVarBool(stm_enabled); - g_bLogActivity = GetConVarBool(stm_logactivity); - g_fScrambleDelay = GetConVarFloat(stm_scrambledelay); - g_iVoteDelay = GetConVarInt(stm_votedelay); - g_fVoteWin = GetConVarFloat(stm_votewin); - g_iLastVoteTime = RoundFloat(GetEngineTime()); - g_bScrambleRoundEnd = false; - g_hTimerClearScrambleForce = INVALID_HANDLE; - - /** - Report enabled - */ - if (g_bIsEnabled) - { - LogAction(0, -1, "[STM] Simple Team Manager is ENABLED."); - } - else - { - LogAction(0, -1, "[STM] Simple Team Manager is DISABLED."); - } - - if (g_bLogActivity) - { - LogAction(0, -1, "[STM] Log Activity ENABLED."); - } - else - { - LogAction(0, -1, "[STM] Log Activity DISABLED."); - } -} - -/* COMMANDS */ - -public Action:Command_SwapTeam(client, args) -{ - - /** - Make sure we are enabled, if not bug out. - */ - if (!g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - If this was ran from the console bug out. - */ - if (client == 0) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "PlayerLevelCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Make sure the client is authorized to run this command. - */ - decl String:sFlags[5]; - GetConVarString(stm_adminflag_swapteam, sFlags, sizeof(sFlags)); - if (!SM_IsValidAdmin(client, sFlags)) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Lets make sure the client is one a team we can swap. - If he is we set the global array to the opposite team. - */ - new iTeam = GetClientTeam(client); - if (iTeam == g_aCurrentTeams[Team1]) - { - g_aPlayers[client][iNewTeam] = g_aCurrentTeams[Team2]; - } - else if (iTeam == g_aCurrentTeams[Team2]) - { - g_aPlayers[client][iNewTeam] = g_aCurrentTeams[Team1]; - } - else - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "InValidTeam", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check to see if we have command arguments. - */ - if (GetCmdArgs()) - { - - /** - We do, so lets get it and see if the client wants to be switched instantly or queued for death. - */ - decl String:sArg[5]; - GetCmdArg(1, sArg, sizeof(sArg)); - new iWantsQue = StringToInt(sArg); - if (iWantsQue && !g_aPlayers[client][bQueue]) - { - - /** - He wants the que and isn't already in it, set the global array. - */ - g_aPlayers[client][bQueue] = true; - ReplyToCommand(client, "\x01\x04[STM]\x01 %T", "PlayerQueue", LANG_SERVER); - } - else if (!iWantsQue) - { - - /** - He wants to be switched right now, lets call the stock function. - */ - SM_MovePlayer(client, g_aPlayers[client][iNewTeam]); - } - } - else - { - - /** - There are no command arguments so we build and display the swap menu. - */ - DisplaySwapModeMenu(client, client); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_MovePlayer(client, args) -{ - - /** - Make sure we are enabled, if not bug out. - */ - if (!g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - Make sure the client is authorized to run this command. - */ - decl String:sFlags[5]; - GetConVarString(stm_adminflag_moveplayer, sFlags, sizeof(sFlags)); - if (!SM_IsValidAdmin(client, sFlags)) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check to see if we have command arguments. - */ - new iCmdArgs = GetCmdArgs(); - if (iCmdArgs == 0) - { - - /** - We don't. Build the player menu, display it, and bug out. - */ - DisplayPlayerMenu(client); - return Plugin_Handled; - } - - /** - Check the first argument - If should be a players name or userid. - */ - decl String:sPlayer[64]; - GetCmdArg(1, sPlayer, sizeof(sPlayer)); - new iPlayerIndex = FindTarget(client, sPlayer, true, true); - if (iPlayerIndex == -1 || !IsClientInGame(iPlayerIndex)) - { - - /** - We don't know who this is. Build the player menu, display it, and bug out. - */ - DisplayPlayerMenu(client); - return Plugin_Handled; - } - - /** - We have figured out the first argument, lets check the second. - If should be the team the client wants to put the player on. - */ - if (iCmdArgs >= 2) - { - - /** - We have a command argument at least, lets see if we can identify the team. - */ - decl String:sTeam[24]; - GetCmdArg(2, sTeam, sizeof(sTeam)); - - new iTeam = StringToInt(sTeam); - if (SM_IsValidTeam(iTeam)) - { - - /** - It's a vaild team so lets set the global array to the new team. - */ - g_aPlayers[iPlayerIndex][iNewTeam] = iTeam; - } - else - { - - /** - It's not a vaild team so set the menu to display to the team menu. - */ - DisplayTeamMenu(client, iPlayerIndex); - return Plugin_Handled; - } - } - else - { - /** - We were not given a team, display the team menu. - */ - DisplayTeamMenu(client, iPlayerIndex); - return Plugin_Handled; - } - - /** - Check to see if we were given any more command arguments and found a team. - */ - if (iCmdArgs < 3) - { - - /** - No more command arguments and found a team. - Now lets check to see if the player is a spectator. If he is there is no reason to ask if it's instant or on death... he can't die. - */ - if (!IsClientObserver(iPlayerIndex)) - { - - /** - Not a spectator so display the swapmode menu. - */ - DisplaySwapModeMenu(client, iPlayerIndex); - } - else - { - - /** - The player is a spectator. - We make sure the player is not set to switch on death, since a spec can't die. - */ - g_aPlayers[iPlayerIndex][bQueue] = false; - } - } - - /** - We have figured out the second argument, lets check the third. - If should be the how the client wants to move the player: instant/on death. - */ - if (iCmdArgs >= 3) - { - - /** - The client gave us a command argument, lets check it. - */ - decl String:sSwapMode[5]; - GetCmdArg(3, sSwapMode, sizeof(sSwapMode)); - new iWantsQue = StringToInt(sSwapMode); - if (iWantsQue) - { - - /** - The client wants to que the player, set the global array. - */ - g_aPlayers[iPlayerIndex][bQueue] = true; - } - else - { - - /** - The client doesn't want to que the player, set the global array. - */ - g_aPlayers[iPlayerIndex][bQueue] = false; - } - } - else - { - /** - No swapmode argument, display the menu - */ - DisplaySwapModeMenu(client, iPlayerIndex); - } - - if (iCmdArgs >= 4) - { - - /** - Since we are compiling for Simple Team Balancer, and given a 4th argument, lets check it. - If should be the if the client wants to force the player to that team. - */ - decl String:sPlayerForced[5]; - GetCmdArg(4, sPlayerForced, sizeof(sPlayerForced)); - new iForceHim = StringToInt(sPlayerForced); - if (iForceHim) - { - - /** - The client wants to force the player - */ - SM_SetForcedTeam(iPlayerIndex, g_aPlayers[iPlayerIndex][iNewTeam]); - } - else - { - - /** - The client doesn't want to force the player - */ - SM_ClearForcedTeam(iPlayerIndex); - } - } - else - { - - } - - /** - We found and processed all the arguments. - */ - if (!IsPlayerAlive(iPlayerIndex)) - { - - /** - The player is not alive or died during this process so we just move him. - */ - SM_MovePlayer(iPlayerIndex, g_aPlayers[iPlayerIndex][iNewTeam]); - } - else - { - if (!g_aPlayers[iPlayerIndex][bQueue]) - { - - /** - The player is alive and is not set to be queued so we just move him. - */ - SM_MovePlayer(iPlayerIndex, g_aPlayers[iPlayerIndex][iNewTeam]); - } - } - - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_ScrambleTeams(client, args) -{ - - /** - Make sure we are enabled, if not bug out. - */ - if (!g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - Make sure the client is authorized to run this command. - */ - decl String:sFlags[5]; - GetConVarString(stm_adminflag_scramble, sFlags, sizeof(sFlags)); - if (!SM_IsValidAdmin(client, sFlags)) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check if a scramble timer was already called, if so close it down. - */ - if (g_hTimerPrepScramble != INVALID_HANDLE) - { - CloseHandle(g_hTimerPrepScramble); - g_hTimerPrepScramble = INVALID_HANDLE; - } - - /** - Check if we have any command arguments. - If we don't we display the scramble menu and bug out. - */ - new iCmdArgs = GetCmdArgs(); - if (iCmdArgs == 0) - { - DisplayScrambleMenu(client); - return Plugin_Handled; - } - - /** - We have a command argument. - It should be whether or not to scramble at round end. - */ - decl String:sRoundEnd[5]; - GetCmdArg(1, sRoundEnd, sizeof(sRoundEnd)); - if (StringToInt(sRoundEnd)) - { - /** - The client wants to scramble at round end so we set the global bool. - */ - g_bScrambleRoundEnd = true; - } - else - { - g_bScrambleRoundEnd = false; - } - - /** - Check for another command argument. - It should be whether or not to restart the round. - */ - decl String:sRestartRound[5]; - new bool:bRestartRound = false; - GetCmdArg(1, sRestartRound, sizeof(sRestartRound)); - if (StringToInt(sRestartRound)) - { - bRestartRound = true; - } - - /** - Now we start the scramble timer. - */ - StartScrambleTimer(_, bRestartRound); - - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_VoteScramble(client, args) -{ - - /** - Make sure we are enabled, if not bug out. - */ - if (!g_bVoteEnabled || !g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - Make sure there is a vote in progress, if so bug out. - */ - if (IsVoteInProgress()) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "VoteInProgress", LANG_SERVER); - return Plugin_Handled; - } - - /** - Make sure enough time has passed since the last vote. - */ - new iVoteTime = RoundFloat(GetEngineTime()); - if (iVoteTime - g_iLastVoteTime <= g_iVoteDelay) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "ScrambleTime", LANG_SERVER); - return Plugin_Handled; - } - - /** - Enough time has passed so reset the global vote time to now. - */ - g_iLastVoteTime = iVoteTime; - - /** - Build the vote menu and send it to everyone. - */ - new Handle:hMenu = CreateMenu(Menu_VoteScramble); - SetMenuTitle(hMenu, "Scramble Teams?"); - AddMenuItem(hMenu, VOTE_YES, "Yes"); - AddMenuItem(hMenu, VOTE_NO, "No"); - SetMenuExitButton(hMenu, false); - VoteMenuToAll(hMenu, 20); - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -/* HOOKED EVENTS */ - -public HookPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Find out who died. - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - - /** - Find out how the client died. - */ - new String:sWeapon[64]; - GetEventString(event, "weapon", sWeapon, sizeof(sWeapon)); - if (StrEqual(sWeapon, "world", false)) - { - - /** - He died because he changed teams so cleanup and bug out. - */ - s_CleanUp(iClient); - return; - } - - /** - Find out if this player was queued to change teams. - */ - if (g_aPlayers[iClient][bQueue]) - { - /** - Looks like he was, so call the stock function to move him. - */ - SM_MovePlayer(iClient, g_aPlayers[iClient][iNewTeam]); - } -} - -public HookPlayerChangeTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Find out who changed teams. - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - - /** - If he was queued to switch teams we cleanup the variables. The client did it themself. - */ - if (g_aPlayers[iClient][bQueue]) - { - s_CleanUp(iClient); - } -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get the amount of time left in the map. - */ - new iTimeLeft; - GetMapTimeLeft(iTimeLeft); - - /** - Check to see if we are supposed to scramble at the end of the round and that there is enough time left in the map. - */ - if (g_bScrambleRoundEnd && iTimeLeft >= 60) - { - - /** - Check to see if there is a scramble timer in action and if so close it down. - */ - if (g_hTimerPrepScramble != INVALID_HANDLE) - { - CloseHandle(g_hTimerPrepScramble); - g_hTimerPrepScramble = INVALID_HANDLE; - } - - /** - Determine the round end chat time and run the scramble 1 second before it ends. - */ - new Float:fDelay = GetConVarFloat(stm_mp_bonusroundtime); - fDelay -= 1.0; - StartScrambleTimer(fDelay); - } -} - -public OnClientPostAdminCheck(client) -{ - - /** - Determine if the client has the flag to use the swapteam command. - */ - decl String:sFlags[5]; - GetConVarString(stm_adminflag_swapteam, sFlags, sizeof(sFlags)); - if (SM_IsValidAdmin(client, sFlags)) - { - /** - The client does so lets create a timer to run an advertise to tell him about it. - */ - CreateTimer (60.0, Timer_WelcomeAdvert, client); - } -} - -public OnClientDisconnect(client) -{ - - /** - Cleanup the clients variables. - */ - s_CleanUp(client); -} - -public SM_OnPlayerMoved(Handle:plugin, client, team) -{ - - /** - Make sure we called the move function - */ - if (plugin != GetMyHandle()) - { - if (g_bLogActivity) - { - LogAction(0, client, "[STM] Callback was not started with current plugin, bugging out."); - } - return; - } - - decl String:sPlayerName[64]; - GetClientName(client, sPlayerName, sizeof(sPlayerName)); - - PrintToChat(client, "\x01\x04[SM]\x01 %T", "PlayerSwitched", LANG_SERVER); - - s_CleanUp(client); -} - -/* TIMER FUNCTIONS */ - -public Action:Timer_PrepTeamScramble(Handle:timer, any:data) -{ - new bool:bRestartRound = data; - /** - Call the scramble the teams stock function. - */ - PrepTeamScramble(bRestartRound); - - /** - Reset the timer handle so we know the timer is done. - */ - g_hTimerPrepScramble = INVALID_HANDLE; - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Timer_ScrambleTheTeams(Handle:timer, any:data) -{ - new iPlayers[MAXPLAYERS + 1]; - new iCount, i, bool:bTeam, bool:bRestartRound = data; - - /** - Get all the client index numbers of valid players - */ - for(i = 1; i <= MaxClients; i++) - { - if(IsClientInGame(i)) // && !IsFakeClient(i)) - { - iPlayers[iCount++] = i; - } - } - - /** - Randomly sort the players - */ - SortIntegers(iPlayers, iCount, Sort_Random); - - /** - Loop through all the players and assign each one to a team, alternating each time - */ - for(i = 0; i < iCount; i++) - { - if (!bRestartRound) - { - /** - We didn't want to restart the round, so we move them to spec 1 at a time. - */ - SM_MovePlayer(iPlayers[i], g_aCurrentTeams[Spectator]); - } - SM_MovePlayer(iPlayers[i], bTeam ? g_aCurrentTeams[Team2] : g_aCurrentTeams[Team1]); - SM_SetForcedTeam(iPlayers[i], bTeam ? g_aCurrentTeams[Team2] : g_aCurrentTeams[Team1], true); - bTeam = !bTeam; - } - - /** - Reset this variable since we completed a scramble - */ - g_bScrambleRoundEnd = false; - - if (g_hTimerClearScrambleForce != INVALID_HANDLE) - { - CloseHandle(g_hTimerClearScrambleForce); - g_hTimerClearScrambleForce = INVALID_HANDLE; - } - - g_hTimerClearScrambleForce = CreateTimer(300.0, Timer_ClearScrambleForce, _, TIMER_FLAG_NO_MAPCHANGE); - - ServerCommand("mp_timelimit %i", g_iTimeLeft / 60); - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Timer_ClearScrambleForce(Handle:timer, any:data) -{ - - for(new i = 1; i <= MaxClients; i++) - { - if(IsClientInGame(i)) // && !IsFakeClient(i)) - { - SM_ClearForcedTeam(i); - PrintToChat(i, "\x01\x04[SM]\x01 Your forced team status has been cleared"); - } - } - - g_hTimerClearScrambleForce = INVALID_HANDLE; - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Timer_WelcomeAdvert(Handle:timer, any:client) -{ - - /** - Lets make sure the client is connected and actually in the game. - */ - if (IsClientConnected(client) && IsClientInGame(client)) - { - - /** - We are good to go so lets tell him about the swapteam command. - */ - PrintToChat (client, "\x01\x04[STM]\x01 %T", "SwapTeamMsg", LANG_SERVER); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -/* STOCK FUNCTIONS */ - -stock s_CleanUp(iClient) -{ - - /** - Reset all the client variables - */ - g_aPlayers[iClient][bQueue] = false; - g_aPlayers[iClient][iNewTeam] = 0; -} - -stock StartScrambleTimer(Float:fdelay = 0.0, bool:bRestartRound = false) -{ - if (fdelay == 0.0) - { - fdelay = g_fScrambleDelay; - } - if (g_hTimerPrepScramble != INVALID_HANDLE) - { - CloseHandle(g_hTimerPrepScramble); - g_hTimerPrepScramble = INVALID_HANDLE; - } - PrintCenterTextAll("%T", "Scramble", LANG_SERVER); - g_hTimerPrepScramble = CreateTimer(fdelay, Timer_PrepTeamScramble, bRestartRound, TIMER_FLAG_NO_MAPCHANGE); -} - -stock PrepTeamScramble(bool:bRestartRound = false) -{ - new iPlayers[MAXPLAYERS + 1]; - new iCount; - - GetMapTimeLeft(g_iTimeLeft); - - if (bRestartRound) - { - - for(new i = 1; i <= MaxClients; i++) - { - if(IsClientInGame(i)) - // && !IsFakeClient(i)) - { - iPlayers[iCount++] = i; - SM_ClearForcedTeam(i); - SM_ClearBuddy(i); - SM_MovePlayer(i, g_aCurrentTeams[Spectator]); - } - } - } - else - { - //Can't move them all to spec at the same time - for(new i = 1; i <= MaxClients; i++) - { - if(IsClientInGame(i)) - // && !IsFakeClient(i)) - { - iPlayers[iCount++] = i; - SM_ClearForcedTeam(i); - SM_ClearBuddy(i); - //SM_MovePlayer(i, g_aCurrentTeams[Spectator]); - } - } - } - CreateTimer(4.0, Timer_ScrambleTheTeams, bRestartRound, TIMER_FLAG_NO_MAPCHANGE); -} - -/* CONSOLE VARIABLE CHANGE EVENT */ - -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (convar == stm_enabled) { - if (StringToInt(newValue) == 0) { - g_bIsEnabled = false; - LogAction(0, -1, "[STM] Simple Team Manager is loaded and disabled."); - } else { - g_bIsEnabled = true; - LogAction(0, -1, "[STM] Simple Team Manager is loaded and enabled."); - } - } - else if (convar == stm_logactivity) { - if (StringToInt(newValue) == 0) { - g_bLogActivity = false; - LogAction(0, -1, "[STM] Log Activity DISABLED."); - } else { - g_bLogActivity = true; - LogAction(0, -1, "[STM] Log Activity ENABLED."); - } - } - else if (convar == stm_scrambledelay) - g_fScrambleDelay = StringToFloat(newValue); - else if (convar == stm_votewin) - g_fVoteWin = StringToFloat(newValue); - else if (convar == stm_votedelay) - g_iVoteDelay = StringToInt(newValue); - else if (convar == stm_voteenabled) { - if (StringToInt(newValue) == 0) - g_bVoteEnabled = false; - else - g_bVoteEnabled = true; - } -} - -/* MENU CODE */ - -public OnAdminMenuReady(Handle:topmenu) -{ - if (topmenu == g_hAdminMenu) - return; - g_hAdminMenu = topmenu; - new TopMenuObject:player_commands = FindTopMenuCategory(g_hAdminMenu, ADMINMENU_PLAYERCOMMANDS); - new TopMenuObject:server_commands = FindTopMenuCategory(g_hAdminMenu, ADMINMENU_SERVERCOMMANDS); - if (player_commands == INVALID_TOPMENUOBJECT) - return; - - AddToTopMenu(g_hAdminMenu, - "moveplayer", - TopMenuObject_Item, - AdminMenu_MovePlayer, - player_commands, - "moveplayer", - ADMFLAG_BAN); - - AddToTopMenu(g_hAdminMenu, - "scrambleteams", - TopMenuObject_Item, - AdminMenu_Scrambleteams, - server_commands, - "scrambleteams", - ADMFLAG_BAN); -} - -public AdminMenu_MovePlayer(Handle:topmenu, TopMenuAction:action, TopMenuObject:object_id, param, String:buffer[], maxlength) -{ - if (action == TopMenuAction_DisplayOption) - Format(buffer, maxlength, "Move Player"); - else if (action == TopMenuAction_SelectOption){ - DisplayPlayerMenu(param); - } -} - -public AdminMenu_Scrambleteams(Handle:topmenu, TopMenuAction:action, TopMenuObject:object_id, param, String:buffer[], maxlength) -{ - if (action == TopMenuAction_DisplayOption) - Format(buffer, maxlength, "Scramble Teams"); - else if (action == TopMenuAction_SelectOption) { - DisplayScrambleMenu(param); - } -} - -public Menu_SelectPlayer(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - DisplayTeamMenu(param1, GetClientOfUserId(StringToInt(sSelection))); - } else if (action == MenuAction_Cancel) { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -public Menu_SelectTeam(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new iTeam; - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - decl String:sIndex[64]; - if (SplitString(sSelection, "A", sIndex, sizeof(sIndex)) != -1) - iTeam = g_aCurrentTeams[Team1]; - else if (SplitString(sSelection, "B", sIndex, sizeof(sIndex)) != -1) - iTeam = g_aCurrentTeams[Team2]; - else { - SplitString(sSelection, "C", sIndex, sizeof(sIndex)); - iTeam = g_aCurrentTeams[Spectator]; - } - new iTarget = StringToInt(sIndex); - g_aPlayers[iTarget][iNewTeam] = iTeam; - DisplaySwapModeMenu(param1, iTarget); - } else if (action == MenuAction_Cancel) { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -public Menu_SwapMode(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - decl String:sIndex[64]; - - if (SplitString(sSelection, "A", sIndex, sizeof(sIndex)) == -1) - { - SplitString(sSelection, "B", sIndex, sizeof(sIndex)); - } - - new iTarget = StringToInt(sIndex); - - if (StrContains(sSelection, "A", true) != -1) - { - g_aPlayers[iTarget][bQueue] = false; - } - else if (StrContains(sSelection, "B", true) != -1) - { - g_aPlayers[iTarget][bQueue] = true; - } - - if (param1 == iTarget && !g_aPlayers[iTarget][bQueue]) - { - SM_MovePlayer(iTarget, g_aPlayers[iTarget][iNewTeam]); - } - else - { - DisplayForceModeMenu(param1, iTarget); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - { - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } - return; -} - -public Menu_ForceMode(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - decl String:sIndex[64]; - if (SplitString(sSelection, "A", sIndex, sizeof(sIndex)) == -1) - { - SplitString(sSelection, "B", sIndex, sizeof(sIndex)); - } - new iTarget = StringToInt(sIndex); - if (StrContains(sSelection, "A", true) != -1) - { - SM_ClearForcedTeam(iTarget); - } - else if (StrContains(sSelection, "B", true) != -1) - { - SM_SetForcedTeam(iTarget, g_aPlayers[iTarget][iNewTeam], true); - } - if (!g_aPlayers[iTarget][bQueue]) - { - SM_MovePlayer(iTarget, g_aPlayers[iTarget][iNewTeam]); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - { - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } - return; -} - -public Menu_VoteScramble(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_VoteEnd) { - new winning_votes, total_votes; - GetMenuVoteInfo(param2, winning_votes, total_votes); - if (param1 == 0) { - if (float(total_votes) / float(winning_votes) < g_fVoteWin) { - PrintToChatAll("\x01\x04[SM]\x01 %T", "VoteScramble2", LANG_SERVER, winning_votes, total_votes); - return; - } - PrintCenterTextAll("[SM] %T", "Scramble", LANG_SERVER); - PrintToChatAll("\x01\x04[SM]\x01 %T", "VoteScramble1", LANG_SERVER, winning_votes, total_votes); - StartScrambleTimer(); - } - if (param1 == 1) { - PrintToChatAll("\x01\x04[SM]\x01 %T", "VoteScramble2", LANG_SERVER, winning_votes, total_votes); - } - } - if (action == MenuAction_End) - CloseHandle(menu); -} - -public Menu_ScrambleTeams(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "NOW", false)) - g_bScrambleRoundEnd = false; - else - g_bScrambleRoundEnd = true; - DisplayScrambleMenu2(param1); - } else if (action == MenuAction_Cancel) { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -public Menu_ScrambleTeams2(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[64]; - new bool:bRestartRound; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "NO", false)) - { - bRestartRound = false; - } - else - { - bRestartRound = true; - } - StartScrambleTimer(_, bRestartRound); - } else if (action == MenuAction_Cancel) { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -stock DisplayScrambleMenu(iClient) -{ - new Handle:hMenu = CreateMenu(Menu_ScrambleTeams); - SetMenuTitle(hMenu, "Select When to Scramble:"); - AddMenuItem(hMenu, "NOW", "Instantly"); - AddMenuItem(hMenu, "END", "At Round End"); - SetMenuExitBackButton(hMenu, false); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} - -stock DisplayScrambleMenu2(iClient) -{ - new Handle:hMenu = CreateMenu(Menu_ScrambleTeams2); - SetMenuTitle(hMenu, "Select When to Scramble:"); - AddMenuItem(hMenu, "NO", "No Round Restart"); - AddMenuItem(hMenu, "YES", "Restart Round"); - SetMenuExitBackButton(hMenu, false); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} - -stock DisplaySwapModeMenu(iClient, iTarget) -{ - new Handle:hMenu = CreateMenu(Menu_SwapMode); - decl String:optionA[64]; - decl String:optionB[64]; - Format(optionA, sizeof(optionA), "%iA", iTarget); - Format(optionB, sizeof(optionB), "%iB", iTarget); - SetMenuTitle(hMenu, "Select When to Swap:"); - AddMenuItem(hMenu, optionA, "Instantly (Kills)"); - if (!IsClientObserver(iTarget)) - AddMenuItem(hMenu, optionB, "Queue on next death"); - SetMenuExitBackButton(hMenu, false); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} - -stock DisplayForceModeMenu(iClient, iTarget) -{ - new Handle:hMenu = CreateMenu(Menu_ForceMode); - decl String:optionA[64]; - decl String:optionB[64]; - Format(optionA, sizeof(optionA), "%iA", iTarget); - Format(optionB, sizeof(optionB), "%iB", iTarget); - SetMenuTitle(hMenu, "Select Force Mode:"); - AddMenuItem(hMenu, optionA, "UnForced"); - AddMenuItem(hMenu, optionB, "Forced"); - SetMenuExitBackButton(hMenu, false); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} - -stock DisplayTeamMenu(iClient, iTarget) -{ - new Handle:hMenu = CreateMenu(Menu_SelectTeam); - decl String:optionA[64]; - decl String:optionB[64]; - decl String:optionC[64]; - Format(optionA, sizeof(optionA), "%iA", iTarget); - Format(optionB, sizeof(optionB), "%iB", iTarget); - Format(optionC, sizeof(optionC), "%iC", iTarget); - SetMenuTitle(hMenu, "Select Team:"); - AddMenuItem(hMenu, optionA, "Team One"); - AddMenuItem(hMenu, optionB, "Team Two"); - AddMenuItem(hMenu, optionC, "Spectator"); - SetMenuExitBackButton(hMenu, false); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} - -stock DisplayPlayerMenu(iClient) -{ - new Handle:hMenu = CreateMenu(Menu_SelectPlayer); - AddTargetsToMenu(hMenu, 0, true, false); - SetMenuTitle(hMenu, "Select A Player:"); - SetMenuExitBackButton(hMenu, true); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} diff --git a/Simple Donator Benefits/addons/sourcemod/translations/simplespectate.phrases.txt b/Simple Donator Benefits/addons/sourcemod/translations/simplespectate.phrases.txt deleted file mode 100644 index 2d1a096..0000000 --- a/Simple Donator Benefits/addons/sourcemod/translations/simplespectate.phrases.txt +++ /dev/null @@ -1,42 +0,0 @@ -"Phrases" -{ - "Stopped spectating" - { - "#format" "{1:s}" - "en" "Stopped tracking player: {1}" - } - "Yourself" - { - "en" "You can't spectate yourself" - } - "Spectator" - { - "en" "You can't spectate another spectator" - } - "Spectating" - { - "#format" "{1:s}" - "en" "Now spectating {1}. Type !stopspec or /stopspec to stop spectating this player" - } - "Invalid Target" - { - "en" "Invalid target" - } - "Cant Target" - { - "en" "Can't target this player" - } - "Must Have Target" - { - "en" "You must be following/tracking a player to punish" - } - "Target Left" - { - "en" "The player you were following/tracking has left" - } - "Punished" - { - "#format" "{1:s}{2:s}{3:s}" - "en" "{1} was punished with a {2} for {3}" - } -} \ No newline at end of file diff --git a/Simple Donator Benefits/addons/sourcemod/translations/simpleteambalancer.phrases.txt b/Simple Donator Benefits/addons/sourcemod/translations/simpleteambalancer.phrases.txt deleted file mode 100644 index 03595fd..0000000 --- a/Simple Donator Benefits/addons/sourcemod/translations/simpleteambalancer.phrases.txt +++ /dev/null @@ -1,130 +0,0 @@ -"Phrases" -{ - "UnBalanced" - { - "en" "Teams are unbalanced and will be balanced shortly" - "fr" "Les équipes ne sont pas équilibrées et le seront bientôt" - "de" "Die Teams sind ungleich und werden in Kürze ausgeglichen" - "hu" "A csapatok nem kiegyenlitettek! Egyensuly beallitas kovetkezik!" - } - "Enabled" - { - "en" "Simple Team Balancer is ENABLED" - "fr" "Simple Team Balancer est ACTIVE" - "de" "Simple Team Balancer ist AKTIV" - "hu" "Az Egyszeru Csapat Egyensulytarto AKTIV!" - } - "Disabled" - { - "en" "Simple Team Balancer is DISABLED" - "fr" "Simple Team Balancer est DESACTIVE" - "de" "Simple Team Balancer ist INAKTIV" - "hu" "Az Egyszeru Csapat Egyensulytarto INAKTIV!" - } - "PlayerMessage" - { - "#format" "{1:i}" - "en" "You are going to be auto balanced in {1} seconds unless a dead player can be found" - "fr" "Vous passerez dans l'autre équipe dans {1} secondes si aucun joueur mort ne peut être trouvé dans cet intervalle" - "de" "Du wirst in {1} Sekunden zum automatischen Ausgleich herangezogen wenn kein toter Spieler gefunden werden kann" - "hu" "{1} masodpercen belul at leszel helyezve a masik csapatba, hacsak nem lesz addig egy halott jatekos!" - } - "BalanceMessage" - { - "#format" "{1:s}" - "en" "{1} was moved to the other team for game balance" - "fr" "{1} est passé dans l'autre équipe pour équilibrer la partie" - "de" "{1} wurde zum anderen Team verschoben um das Spiel auszugleichen" - "hu" "{1} at lett helyezve az egyensuly megtartasa erdekeben." - } - "PlayerLevelCmd" - { - "en" "Command must be run at the player level" - "fr" "La commande doit être lancée au niveau du joueur" - "de" "Das Kommando muss auf Spieler Ebene ausgeführt werden" - "hu" "Jatekosi szinten kell futtatni ezt a parancsot!" - } - "CmdDisabled" - { - "en" "Command is currently disabled" - "fr" "La commande est actuellement désactivée" - "de" "Das Kommando ist momentan inaktiv" - "hu" "A parancs jelenleg inaktiv" - } - "RestrictedBuddy" - { - "en" "You must be a donator or admin to add a balance buddy" - "fr" "Vous devez être un donateur ou un admin pour choisir un partenaire" - "de" "Du musst ein Spender oder Admin sein um einen Partner wählen zu können" - "hu" "Tamogato vagy admin kell hogy legyel, hogy 'Tarsat' jelolhess meg" - } - "SelectSelf" - { - "en" "You cannot be your own buddy" - "fr" "Vous ne pouvez pas être votre propre partenaire" - "de" "Du kannst nicht dein eigener Partner sein" - "hu" "Nem valaszthatod ki onmagad!" - } - "BuddyGone" - { - "en" "Your selected buddy has disconnected" - "fr" "Le partenaire que vous avez sélectionné s'est déconnecté" - "de" "Dein gewählter Partner hat die Verbindung getrennt" - "hu" "A valasztott 'Tarsad' kilepett" - } - "BuddyMsg" - { - "#format" "{1:s}" - "en" "You and {1} are now buddies" - "fr" "Vous et {1} êtes maintenant partenaires" - "de" "Du und {1} seid jetzt Partner" - "hu" "{1} es Te 'Tarsak' vagytok." - } - "BuddyLockMsgDisabled" - { - "en" "You can now be anyone's buddy" - "fr" "Vous pouvez à présent être le partenaire de n'importe qui" - "de" "Du kannst jetzt jedermanns Partner sein" - "hu" "Barkinek lehetsz a 'Tarsa'." - } - "BuddyLockMsgEnabled" - { - "en" "Buddy selection locked. Only you can change your buddy" - "fr" "Sélection de partenaire bloquée. Vous êtes le seul à pouvoir choisir votre partenaire" - "de" "Wahl des Partners gesperrt. Nur du kannst deinen Partner wechseln" - "hu" "Tars-lista lezarva. Csak Te tudod modositani a Tars-listadat." - } - "PlayerLockedBuddyMsg" - { - "#format" "{1:s}" - "en" "{1} has locked his buddy selection. Try again" - "fr" "{1} a bloqué sa sélection de partenaire. Essayez de nouveau." - "de" "{1} hat seine Wahl des Partners gesperrt. Versuche es erneut" - "hu" "{1} lezarta a Tars-listajat. Probald kesobb!" - } - "BuddyWelcomeMsg1" - { - "en" "Select a balance buddy and stay together during an autobalance!" - "fr" "Choisissez un partenaire et restez ensemble durant l'équilibrage automatique!" - "de" "Wähle einen Partner und bleibt zusammen während eines Ausgleichs" - "hu" "Valasz ki egy 'Tarsat' akivel egyuttmaradhatsz a csapatkiegyenlites alatt!" - } - "BuddyWelcomeMsg2" - { - "en" "/buddy or !buddy to select a balance buddy" - "fr" "/buddy or !buddy pour choisir un partenaire" - "de" "/buddy oder !buddy um einen Partner zu wählen" - "hu" "Hasznald a /buddy vagy !buddy parancsokat a 'Tars' kijelolesehez" - } - "BuddyWelcomeMsg3" - { - "en" "/lockbuddy or !lockbuddy to lock your selection" - "fr" "/lockbuddy or !lockbuddy pour bloquer votre sélection" - "de" "/lockbuddy oder !lockbuddy um deine Auswahl zu sperren" - "hu" "Hasznald a /lockbuddy vagy a !lockbuddy parancsokat a Tars-listad lezarasahoz" - } -} - - - - diff --git a/Simple Donator Benefits/addons/sourcemod/translations/simpleteammanager.phrases.txt b/Simple Donator Benefits/addons/sourcemod/translations/simpleteammanager.phrases.txt deleted file mode 100644 index f2093a7..0000000 --- a/Simple Donator Benefits/addons/sourcemod/translations/simpleteammanager.phrases.txt +++ /dev/null @@ -1,92 +0,0 @@ -"Phrases" -{ - "PlayerLevelCmd" - { - "en" "Command must be run at the player level" - "fr" "Cette commande doit être tapée en jeu" - "hu" "Ezt a parancsot jatekosi szinten kell futtatni!" - } - "RestrictedCmd" - { - "en" "You must be a donator or admin to run this command" - "fr" "Vous devez être un donateur ou un admin pour lancer cette commande" - "hu" "A parancs futtatasahoz admin, vagy tamogatoi szint szukseges!" - } - "InValidTeam" - { - "en" "You must be on red or blue to swap teams" - "fr" "Vous devez être RED ou BLU pour changer d'équipe" - "hu" "Jatekban kell lenned, hogy megcsereld a csapatokat!" - } - "PlayerInValidTeam" - { - "en" "Player must be on red or blue to swap teams" - "fr" "Le joueur doit être RED ou BLU pour changer d'équipe" - "hu" "Valamelyik csapatban kell lenni, hogy csere legyen" - } - "PlayerQueue" - { - "en" "You have been queued to swap teams on next death" - "fr" "Vous avez été mis en attente pour changer d'équipe lors de votre prochaine mort" - "hu" "A kovetkezo halalnal csapatcsere lesz" - } - "PlayerSwitched" - { - "en" "Your team has been switched" - } - "PlayerSwitched1" - { - "en" "Your team has been switched as requested" - "fr" "Vous avez changé d'équipe comme demandé" - "hu" "A keresnek eleget teve a csapatod meg lett csererlve" - } - "PlayerSwitched2" - { - "en" "Your team has been switched by an Admin" - "fr" "Vous avez été changé d'équipe par un admin" - "hu" "Az Admin megcserelte a csapatodat!" - } - "SwapTeamMsg" - { - "en" "Type /swapteam or !swapteam to swap your team!" - } - "PlayerSwitched3" - { - "#format" "{1:s}" - "en" "{1}'s team has been switched" - "fr" "{1} a changé d'équipe" - "hu" "{1} csapata meg lett cserelve" - } - "Scramble" - { - "en" "Teams are about to be scrambled!" - "fr" "Les équipes vont être rééquilibrés" - "hu" "A csapatok hamarosan meg lesznek keverve!" - } - "VoteScramble1" - { - "#format" "{1:i}{2:i}" - "en" "Vote Scramble successful with {1} votes out of {2}" - "fr" "Le vote d'équilibrage des équipes a réussi avec {1} votes pour sur {2}" - "hu" "A szavazas sikeres volt, {1} szavazat a keveresre a {2} -bol" - } - "VoteScramble2" - { - "#format" "{1:i}{2:i}" - "en" "Vote Scramble failed with {1} votes out of {2}" - "fr" "Le vote d'équilibrage a échoué avec {1} votes pour sur {2}" - "hu" "A szavazas sikertelen volt, {1} szavazat a keveresre a {2} -bol" - } - "VoteInProgress" - { - "en" "A vote is currently in progress" - "fr" "Un vote est actuellement en cours" - "hu" "Egy szavazas mar fut!" - } - "ScrambleTime" - { - "en" "A vote was recently made, please wait" - "fr" "Un vote a déjà été fait récemment, réessayez plus tard" - "hu" "Nemreg volt szavazas, kerlek varj egy kicsit!" - } -} \ No newline at end of file diff --git a/Simple Message Suppression/addons/sourcemod/configs/simple-alltalkmanager_events.cfg b/Simple Message Suppression/addons/sourcemod/configs/simple-alltalkmanager_events.cfg deleted file mode 100644 index b739cf0..0000000 --- a/Simple Message Suppression/addons/sourcemod/configs/simple-alltalkmanager_events.cfg +++ /dev/null @@ -1,43 +0,0 @@ -"game_events" -{ - "teamplay_round_start" - { - "reason" "Round Start" - "setting" "1" - } - "teamplay_setup_finished" - { - "reason" "Setup Period Ended" - "setting" "0" - } - "teamplay_overtime_begin" - { - "reason" "Overtime Began" - "setting" "1" - } - "teamplay_overtime_end" - { - "reason" "Overtime Ended" - "setting" "1" - } - "teamplay_round_win" - { - "reason" "Round Ended" - "setting" "1" - } - "teamplay_suddendeath_begin" - { - "reason" "Sudden Death Began" - "setting" "1" - } - "teamplay_suddendeath_end" - { - "reason" "Sudden Death Ended" - "setting" "1" - } - "teamplay_round_stalemate" - { - "reason" "Stalemate" - "setting" "1" - } -} \ No newline at end of file diff --git a/Simple Message Suppression/addons/sourcemod/configs/simple-chatcolors.cfg b/Simple Message Suppression/addons/sourcemod/configs/simple-chatcolors.cfg deleted file mode 100644 index 14b98c6..0000000 --- a/Simple Message Suppression/addons/sourcemod/configs/simple-chatcolors.cfg +++ /dev/null @@ -1,15 +0,0 @@ -"admin_colors" -{ - "groupname2" - { - "flag" "z" - "namecolor" "{green}" - "textcolor" "{olive}" - } - "groupname1" - { - "flag" "a" - "namecolor" "{teamcolor}" - "textcolor" "{green}" - } -} \ No newline at end of file diff --git a/Simple Message Suppression/addons/sourcemod/plugins/simple-alltalkmanager.smx b/Simple Message Suppression/addons/sourcemod/plugins/simple-alltalkmanager.smx deleted file mode 100644 index 6122756..0000000 Binary files a/Simple Message Suppression/addons/sourcemod/plugins/simple-alltalkmanager.smx and /dev/null differ diff --git a/Simple Message Suppression/addons/sourcemod/plugins/simple-donatorbenefits.smx b/Simple Message Suppression/addons/sourcemod/plugins/simple-donatorbenefits.smx deleted file mode 100644 index 821d61d..0000000 Binary files a/Simple Message Suppression/addons/sourcemod/plugins/simple-donatorbenefits.smx and /dev/null differ diff --git a/Simple Message Suppression/addons/sourcemod/plugins/simple-plugins.smx b/Simple Message Suppression/addons/sourcemod/plugins/simple-plugins.smx deleted file mode 100644 index ac307a3..0000000 Binary files a/Simple Message Suppression/addons/sourcemod/plugins/simple-plugins.smx and /dev/null differ diff --git a/Simple Message Suppression/addons/sourcemod/plugins/simple-spectate.smx b/Simple Message Suppression/addons/sourcemod/plugins/simple-spectate.smx deleted file mode 100644 index c6885b0..0000000 Binary files a/Simple Message Suppression/addons/sourcemod/plugins/simple-spectate.smx and /dev/null differ diff --git a/Simple Message Suppression/addons/sourcemod/plugins/simple-teambalancer.smx b/Simple Message Suppression/addons/sourcemod/plugins/simple-teambalancer.smx deleted file mode 100644 index 95beb01..0000000 Binary files a/Simple Message Suppression/addons/sourcemod/plugins/simple-teambalancer.smx and /dev/null differ diff --git a/Simple Message Suppression/addons/sourcemod/plugins/simple-teammanager.smx b/Simple Message Suppression/addons/sourcemod/plugins/simple-teammanager.smx deleted file mode 100644 index 81905ba..0000000 Binary files a/Simple Message Suppression/addons/sourcemod/plugins/simple-teammanager.smx and /dev/null differ diff --git a/Simple Message Suppression/addons/sourcemod/scripting/include/simple-plugins.inc b/Simple Message Suppression/addons/sourcemod/scripting/include/simple-plugins.inc deleted file mode 100644 index 8f21956..0000000 --- a/Simple Message Suppression/addons/sourcemod/scripting/include/simple-plugins.inc +++ /dev/null @@ -1,337 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Plugins -Description: - Included file for core plugin in the Simple Plugins project -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -*************************************************************************/ - -#if defined _simpleplugin_included - #endinput -#endif - -#define _simpleplugin_included - -#define CORE_INC_VERSION "1.1.$Rev$" - -#pragma semicolon 1 -#include -#undef REQUIRE_PLUGIN -#include -#define REQUIRE_PLUGIN -#undef REQUIRE_EXTENSIONS -#undef AUTOLOAD_EXTENSIONS -#tryinclude -#tryinclude -#tryinclude -#define AUTOLOAD_EXTENSIONS -#define REQUIRE_EXTENSIONS - -enum e_SupportedMods -{ - GameType_Unknown, - GameType_AOC, - GameType_CSS, - GameType_DOD, - GameType_FF, - GameType_HIDDEN, - GameType_HL2DM, - GameType_INS, - GameType_L4D, - GameType_NEO, - GameType_SGTLS, - GameType_TF, - GameType_ZPS -}; - -enum e_Teams -{ - Unknown, - Spectator, - Team1, - Team2 -}; - -new g_aCurrentTeams[e_Teams]; -new e_SupportedMods:g_CurrentMod; -new String:g_sGameName[e_SupportedMods][32] = { "Unknown", - "Age of Chivalry", - "Counter Strike", - "Day Of Defeat", - "Fortress Forever", - "Hidden: Source", - "Half Life 2: Deathmatch", - "Insurgency", - "Left 4 Dead", - "Neotokyo", - "Stargate TLS", - "Team Fortress 2", - "Zombie Panic: Source" - }; - -public SharedPlugin:_pl_simpleplugin = -{ - name = "simple-plugins", - file = "simple-plugins.smx", -#if defined REQUIRE_PLUGIN - required = 1 -#else - required = 0 -#endif -}; - -#if !defined REQUIRE_PLUGIN -public _pl_simpleplugin_SetNTVOptional() -{ - MarkNativeAsOptional("SM_MovePlayer"); - MarkNativeAsOptional("SM_SetForcedTeam"); - MarkNativeAsOptional("SM_GetForcedTeam"); - MarkNativeAsOptional("SM_ClearForcedTeam"); - MarkNativeAsOptional("SM_GetForcedPlayer"); - MarkNativeAsOptional("SM_AssignBuddy"); - MarkNativeAsOptional("SM_SearchBuddy"); - MarkNativeAsOptional("SM_LockBuddy"); - MarkNativeAsOptional("SM_IsBuddyLocked"); - MarkNativeAsOptional("SM_ClearBuddy"); - MarkNativeAsOptional("SM_IsValidAdmin"); - MarkNativeAsOptional("SM_IsValidTeam"); -} -#endif - -/********************************************************************** - * When a player has to moved - * - * @param plugin Plugin that initiated the move - * @param client The client index of the player that was moved - * @param team The team index the player was moved to - * @noreturn - **********************************************************************/ -forward SM_OnPlayerMoved(Handle:plugin, client, team); - -/********************************************************************** - * Move a player to the supplied team - * - * @param client The client index of the player to be moved - * @param team The team to move the player to - * @noreturn - * @error Invalid client or team index - **********************************************************************/ -native SM_MovePlayer(client, team); - -/********************************************************************** - * Move a player to the supplied team - * - * @param client The client index of the player to set - * @param team The team to move the to set - * @param override Whether or not to override another plugin - * @return True if successful, false if not - * @error Invalid client or team index - **********************************************************************/ -native SM_SetForcedTeam(client, team, bool:override = false); - -/********************************************************************** - * Gets the client's forced team index - * - * @param client The client index of the player to check - * @param plugin Optional: The plugin handle of the plugin - that set the team - * @return The team index of the forced team - Zero if no forced team - * @error Invalid client index - **********************************************************************/ -native SM_GetForcedTeam(client, &Handle:plugin = INVALID_HANDLE); - -/********************************************************************** - * Clears a client's forced team - * - * @param client The client index of the player to check - * @return True if successful, false if not - * @error Invalid client index - **********************************************************************/ -native SM_ClearForcedTeam(client); - -/********************************************************************** - * Gets a forced player on the wrong that is currently on the wrong team - * This will only return a player if the calling plugin assigned the team - * - * @param team The team index the player should be on - * @return The client index of the player - Zero if no player found - * @error Invalid client index - **********************************************************************/ -native SM_GetForcedPlayer(team); - -/********************************************************************** - * Assign a players buddy - * - * @param client The client index of the player to assign - * @param player The player index of the player to assign - * @param override Whether or not to override a player lock - * @return True if successful, false if not - * @error Invalid client or player index - **********************************************************************/ -native bool:SM_AssignBuddy(client, player, bool:override = false); - -/********************************************************************** - * Rturns the client's buddy - * - * @param client The client index of the player to assign - * @return The client index of the player's buddy - Zero if no buddy - * @error Invalid client index - **********************************************************************/ -native SM_GetClientBuddy(client); - -/********************************************************************** - * Set the buddy lock setting for a client - * - * @param client The client index of the player to assign - * @param setting Setting to set, True or False - * @return True if successful, false if not - * @error Invalid client index - **********************************************************************/ -native bool:SM_LockBuddy(client, bool:setting); - -/********************************************************************** - * Returns the buddy lock setting for a client - * - * @param client The client index of the player to assign - * @return True if locked, false if not - * @error Invalid client index - **********************************************************************/ -native bool:SM_IsBuddyLocked(client); - -/********************************************************************** - * Clear a players buddy - * - * @param client The client index of the player to clear - * @param override Whether or not to override a player lock - * @return True if successful, false if not - * @error Invalid client index - **********************************************************************/ -native bool:SM_ClearBuddy(client, bool:override = false); - -/********************************************************************** - * Determine if the player has the supplied flags - * ADMFLAG_ROOT will always return true - * - * @param client The client index of the player to assign - * @param flags The char flag(s) to check against - * @return True if valid, false if not - **********************************************************************/ -native bool:SM_IsValidAdmin(client, const String:flags[]); - - -/********************************************************************** - * Determine if the team is a valid team - * - * @param team The team index to determine if valid for - currently installed/supported mod - * @return True if valid, false if not - **********************************************************************/ -native bool:SM_IsValidTeam(team); - - -public e_SupportedMods:GetCurrentMod() -{ - new String:sGameType[64]; - GetGameFolderName(sGameType, sizeof(sGameType)); - - if (StrEqual(sGameType, "aoc", false)) - { - return GameType_AOC; - } - if (StrEqual(sGameType, "cstrike", false)) - { - return GameType_CSS; - } - if (StrEqual(sGameType, "dod", false)) - { - return GameType_DOD; - } - if (StrEqual(sGameType, "ff", false)) - { - return GameType_FF; - } - if (StrEqual(sGameType, "hidden", false)) - { - return GameType_HIDDEN; - } - if (StrEqual(sGameType, "hl2mp", false)) - { - return GameType_FF; - } - if (StrEqual(sGameType, "insurgency", false) || StrEqual(sGameType, "ins", false)) - { - return GameType_INS; - } - if (StrEqual(sGameType, "l4d", false)) - { - return GameType_L4D; - } - if (StrEqual(sGameType, "nts", false)) - { - return GameType_NEO; - } - if (StrEqual(sGameType, "sgtls", false)) - { - return GameType_SGTLS; - } - if (StrEqual(sGameType, "tf", false)) - { - return GameType_TF; - } - if (StrEqual(sGameType, "zps", false)) - { - return GameType_ZPS; - } - return GameType_Unknown; -} - -public LoadCurrentTeams() -{ - switch (g_CurrentMod) - { - case GameType_INS: - { - g_aCurrentTeams[Unknown] = 0; - g_aCurrentTeams[Spectator] = 3; - g_aCurrentTeams[Team1] = 1; - g_aCurrentTeams[Team2] = 2; - } - case default: - { - g_aCurrentTeams[Unknown] = 0; - g_aCurrentTeams[Spectator] = 1; - g_aCurrentTeams[Team1] = 2; - g_aCurrentTeams[Team2] = 3; - } - } -} diff --git a/Simple Message Suppression/addons/sourcemod/scripting/simple-alltalkmanager.sp b/Simple Message Suppression/addons/sourcemod/scripting/simple-alltalkmanager.sp deleted file mode 100644 index c848332..0000000 --- a/Simple Message Suppression/addons/sourcemod/scripting/simple-alltalkmanager.sp +++ /dev/null @@ -1,515 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple AllTalk Manager -Description: - Allows you to set alltalk at different times -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#pragma semicolon 1 -#include -#include - -#define PLUGIN_VERSION "1.4.$Rev$" - -new Handle:satm_enabled = INVALID_HANDLE; -new Handle:satm_threshold_enabled = INVALID_HANDLE; -new Handle:satm_player_threshold = INVALID_HANDLE; -new Handle:satm_threshold_setting = INVALID_HANDLE; -new Handle:satm_logactivity = INVALID_HANDLE; -new Handle:satm_alltalk = INVALID_HANDLE; - -new Handle:g_aEventNames = INVALID_HANDLE; -new Handle:g_aEventReasons = INVALID_HANDLE; -new Handle:g_aEventSettings = INVALID_HANDLE; - -new bool:g_bLastThreshold = false; -new bool:g_bEnabled = true; -new bool:g_bThresholdEnabled = true; -new bool:g_bIsSetupMap = false; -new bool:g_bIsGameTF2 = false; -new bool:g_bLogActivity = false; - -new g_iLastEventIndex; - -public Plugin:myinfo = -{ - name = "Simple AllTalk Manager", - author = "Simple Plugins", - description = "Allows you to set alltalk at different times", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -} - -/** -Sourcemod callbacks -*/ -public OnPluginStart() -{ - - /** - Need to create all of our console variables. - */ - CreateConVar("satm_version", PLUGIN_VERSION, "Simple AllTalk Manager", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - satm_enabled = CreateConVar("satm_enabled", "1", "Enables/Disables Simple AllTalk Manager", _, true, 0.0, true, 1.0); - satm_threshold_enabled = CreateConVar("satm_threshold_enabled", "1", "Enables/Disables player threshold", _, true, 0.0, true, 1.0); - satm_player_threshold = CreateConVar("satm_player_threshold", "8", "Amount of players for the threshold"); - satm_threshold_setting = CreateConVar("satm_threshold_setting", "1", "Enables/Disables all talk up to player threshold, with the opposite set after the threshold", _, true, 0.0, true, 1.0); - satm_logactivity = CreateConVar("satm_logactivity", "0", "Enables/Disables log activity", _, true, 0.0, true, 1.0); - satm_alltalk = FindConVar("sv_alltalk"); - - /** - Hook console variables - */ - HookConVarChange(satm_enabled, ConVarSettingsChanged); - HookConVarChange(satm_threshold_enabled, ConVarSettingsChanged); - HookConVarChange(satm_player_threshold, ConVarSettingsChanged); - HookConVarChange(satm_logactivity, ConVarSettingsChanged); - - /** - Remove the notify flag from all talk cvar since we do it - */ - SetConVarFlags(satm_alltalk, GetConVarFlags(satm_alltalk)~FCVAR_NOTIFY); - - /** - Get the game type. We only care if it's TF2 - */ - new String:sGameType[64]; - GetGameFolderName(sGameType, sizeof(sGameType)); - if (StrEqual(sGameType, "tf", false)) - { - g_bIsGameTF2 = true; - } - - /** - Create the arrays - */ - g_aEventNames = CreateArray(255, 1); - g_aEventReasons = CreateArray(255, 1); - g_aEventSettings = CreateArray(1, 1); - - /** - Need to register the commands we are going to create and use. - */ - RegAdminCmd("sm_reloadatconfig", Command_Reload, ADMFLAG_GENERIC, "Reloads settings from config file"); - - /** - Create the config file - */ - AutoExecConfig(true); - - /** - Load the events from the config - */ - LoadEventsFromConfig(); -} - -public OnConfigsExecuted() -{ - - /** - Load up the settings - */ - g_bEnabled = GetConVarBool(satm_enabled); - g_bLogActivity = GetConVarBool(satm_logactivity); - g_bThresholdEnabled = GetConVarBool(satm_threshold_enabled); -} - -public OnMapStart() -{ - - /** - Reset the globals - */ - g_iLastEventIndex = 0; - g_bLastThreshold = false; - - /** - Check the map type if we are in TF2 - */ - if (g_bIsGameTF2) - { - g_bIsSetupMap = IsSetupPeriodMap(); - } - - /** - Set AllTalk - */ - if (g_bEnabled) - { - SetConVarBool(satm_alltalk, true); - } -} - -public OnClientDisconnect_Post(client) -{ - if (g_bEnabled) - { - SetAllTalk(-1); - } -} - -public OnClientPostAdminCheck(client) -{ - if (g_bEnabled) - { - SetAllTalk(-1); - } - CreateTimer(2.0, Timer_ShowAllTalkStatus, client, TIMER_FLAG_NO_MAPCHANGE); -} - -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (convar == satm_enabled) - { - if (StringToInt(newValue)) - { - g_bEnabled = true; - } - else - { - g_bEnabled = false; - } - } - else if (convar == satm_threshold_enabled) - { - if (StringToInt(newValue)) - { - g_bThresholdEnabled = true; - } - else - { - g_bThresholdEnabled = false; - } - } - else if (convar == satm_logactivity) - { - if (StringToInt(newValue)) - { - g_bLogActivity = true; - } - else - { - g_bLogActivity = false; - } - } - if (g_bEnabled) - { - SetAllTalk(-1); - } -} - -/** -Commands -*/ -public Action:Command_Reload(client, args) -{ - - /** - Clear the array - */ - ClearArray(g_aEventNames); - ClearArray(g_aEventReasons); - ClearArray(g_aEventSettings); - - /** - Load the events from the config - */ - LoadEventsFromConfig(); - - return Plugin_Handled; -} - -/** -Game Event Hooks -*/ -public Hook_All_Events(Handle:event, const String:name[], bool:dontBroadcast) -{ - if (!g_bIsSetupMap) - { - if (StrEqual(name, "teamplay_round_start")) - { - if (FindStringInArray(g_aEventNames, "teamplay_setup_finished") != -1) - { - g_iLastEventIndex = FindStringInArray(g_aEventNames, "teamplay_setup_finished"); - if (g_bEnabled) - { - SetAllTalk(g_iLastEventIndex); - return; - } - } - } - } - g_iLastEventIndex = FindStringInArray(g_aEventNames, name); - if (g_bEnabled) - { - SetAllTalk(g_iLastEventIndex); - } -} - -/** -Timers -*/ -public Action:Timer_ShowAllTalkStatus(Handle:timer, any:client) -{ - if (IsClientConnected(client) && IsClientInGame(client)) - { - new bool:bSetting = GetConVarBool(satm_alltalk); - if (bSetting) - { - PrintToChat(client, "\x01\x04[SM] AllTalk is \x01[on]"); - } - else - { - PrintToChat(client, "\x01\x04[SM] AllTalk is \x01[off]"); - } - } -} - -/** -Stock Functions -*/ -stock LoadEventsFromConfig() -{ - - /** - Make sure the config file is here and load it up - */ - new String:sConfigFile[256]; - BuildPath(Path_SM, sConfigFile, sizeof(sConfigFile), "configs/simple-alltalkmanager_events.cfg"); - if (!FileExists(sConfigFile)) - { - - /** - Config file doesn't exists, stop the plugin - */ - LogError("[SATM] Simple AllTalk Manager is not running! Could not find file %s", sConfigFile); - SetFailState("Could not find file %s", sConfigFile); - } - - /** - Create the arrays and variables - */ - new String:sGameEventName[256]; - new String:sReason[256]; - new iSetting; - - /** - Load config file as a KeyValues file - */ - new Handle:kvGameEvents = CreateKeyValues("game_events"); - FileToKeyValues(kvGameEvents, sConfigFile); - - if (!KvGotoFirstSubKey(kvGameEvents)) - { - return; - } - - /** - Hook the game events and load the settings - */ - do - { - - /** - Get the section name; this should be the event name - */ - KvGetSectionName(kvGameEvents, sGameEventName, sizeof(sGameEventName)); - if (!HookEventEx(sGameEventName, Hook_All_Events, EventHookMode_PostNoCopy)) - { - - /** - Could not hook this event, stop the plugin - */ - SetFailState("Could not hook event %s", sGameEventName); - } - else - { - if (g_bLogActivity) - { - LogMessage("[SATM] Hooked event: %s", sGameEventName); - } - } - - /** - Get the reason string and setting - */ - KvGetString(kvGameEvents, "reason", sReason, sizeof(sReason)); - iSetting = KvGetNum(kvGameEvents, "setting"); - if (g_bLogActivity) - { - LogMessage("[SATM] Event reason string: %s", sReason); - LogMessage("[SATM] Event setting: %i", iSetting); - } - - /** - Push the values to the arrays - */ - PushArrayString(g_aEventNames, sGameEventName); - PushArrayString(g_aEventReasons, sReason); - PushArrayCell(g_aEventSettings, iSetting); - } while (KvGotoNextKey(kvGameEvents)); - - /** - Close our handle - */ - CloseHandle(kvGameEvents); -} - -stock SetAllTalk(index) -{ - new iPlayerThreshold = GetConVarInt(satm_player_threshold); - new bool:bThresholdMet = ((GetClientCount() >= iPlayerThreshold) ? true : false); - new bool:bSetting; - - if (g_bThresholdEnabled) - { - if (bThresholdMet) - { - if (index == -1) - { - if (bThresholdMet != g_bLastThreshold) - { - g_bLastThreshold = true; - bSetting = !GetConVarBool(satm_threshold_setting); - new bool:bLastSetting = GetArrayCell(g_aEventSettings, g_iLastEventIndex); - if (bLastSetting && !bSetting) - { - bSetting = GetArrayCell(g_aEventSettings, g_iLastEventIndex); - } - } - else - { - bSetting = GetArrayCell(g_aEventSettings, g_iLastEventIndex); - } - } - else - { - bSetting = GetArrayCell(g_aEventSettings, index); - } - } - else - { - g_bLastThreshold = false; - bSetting = GetConVarBool(satm_threshold_setting); - } - } - else - { - if (index != -1) - { - bSetting = GetArrayCell(g_aEventSettings, index); - } - } - - if (GetConVarBool(satm_alltalk) != bSetting) - { - - SetConVarBool(satm_alltalk, bSetting); - - new String:sReason[256]; - if (index == -1) - { - Format(sReason, sizeof(sReason), "Player Threshold"); - } - else - { - if (!g_bIsSetupMap) - { - new String:sCurrentEvent[256]; - GetArrayString(g_aEventNames, index, sCurrentEvent, sizeof(sCurrentEvent)); - if (StrEqual(sCurrentEvent, "teamplay_setup_finished")) - { - new iRoundStartIndex = FindStringInArray(g_aEventNames, "teamplay_round_start"); - if (iRoundStartIndex != -1) - { - GetArrayString(g_aEventReasons, iRoundStartIndex, sReason, sizeof(sReason)); - } - else - { - GetArrayString(g_aEventReasons, index, sReason, sizeof(sReason)); - } - } - else - { - GetArrayString(g_aEventReasons, index, sReason, sizeof(sReason)); - } - } - else - { - GetArrayString(g_aEventReasons, index, sReason, sizeof(sReason)); - } - } - - if (bSetting) - { - PrintToChatAll("\x01\x04[SM] AllTalk turned \x01[on] \x04due to:\x01 %s", sReason); - } - else - { - PrintToChatAll("\x01\x04[SM] AllTalk turned \x01[off] \x04due to:\x01 %s", sReason); - } - } -} - -stock bool:IsSetupPeriodMap() -{ - new iEnt = -1; - new String:sMapName[32]; - - GetCurrentMap(sMapName, sizeof(sMapName)); - - if (strncmp(sMapName, "cp_", 3, false) == 0) - { - new iTeam; - while ((iEnt = FindEntityByClassname(iEnt, "team_control_point")) != -1) - { - iTeam = GetEntProp(iEnt, Prop_Send, "m_iTeamNum"); - - /** - If there is a blu CP or a neutral CP, then it's not an attack/defend map - */ - if (iTeam != 2) - { - //this is a push map - return false; - } - } - //this is a attack/defend map - return true; - } - else if (strncmp(sMapName, "ctf_", 3, false) == 0) - { - //this is a ctf map - return false; - } - return false; -} diff --git a/Simple Message Suppression/addons/sourcemod/scripting/simple-autoscrambler.sp b/Simple Message Suppression/addons/sourcemod/scripting/simple-autoscrambler.sp deleted file mode 100644 index 6c6799e..0000000 --- a/Simple Message Suppression/addons/sourcemod/scripting/simple-autoscrambler.sp +++ /dev/null @@ -1,459 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple AutoScrambler -Description: - Automatically scrambles the teams based upon a number of events. -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include - -#define PLUGIN_VERSION "1.1.$Rev$" - -/** -Different scramble modes: - -1 = Full Scramble, dont restart round. -2 = Admins Immune, dont restart round. -3 = Full Scramble, restart round and reset scores. -4 = Admins Immune, restart round and reset scores. - -*/ - -/** -Different top player modes: - -1 = Divide Top 4 players on the two teams. -2 = Protect the Top 2 players on each team. - -*/ - -enum PlayerData -{ - Handle:hForcedTimer, - bool:bProtected; -}; - -/** -Cvars used for admins -*/ -new Handle: sas_admin_immunity_enabled = INVALID_HANDLE, - Handle: sas_admin_flag_scramblenow = INVALID_HANDLE, - Handle: sas_admin_flag_immunity = INVALID_HANDLE; - -/** -Cvars used for autoscramble -*/ -new Handle: sas_autoscramble_enabled = INVALID_HANDLE, - Handle: sas_autoscramble_minplayers = INVALID_HANDLE, - Handle: sas_autoscramble_mode = INVALID_HANDLE, - Handle: sas_autoscramble_winstreak = INVALID_HANDLE, - Handle: sas_autoscramble_steamroll = INVALID_HANDLE, - Handle: sas_autoscramble_frags = INVALID_HANDLE; - -/** -Cvars used for voting -*/ -new Handle: sas_vote_enabled = INVALID_HANDLE, - Handle: sas_vote_upcount = INVALID_HANDLE, - Handle: sas_vote_winpercent = INVALID_HANDLE, - Handle: sas_vote_mode = INVALID_HANDLE, - Handle: sas_vote_minplayers = INVALID_HANDLE; - -/** -Additional cvars -*/ -new Handle: sas_enabled = INVALID_HANDLE, - Handle: sas_timer_scrambledelay = INVALID_HANDLE, - Handle: TFGameModeArena = INVALID_HANDLE; - -/** -Timers -*/ -new Handle: g_hScrambleTimer = INVALID_HANDLE; - -/** - Player arrays - */ -new g_aPlayers[MAXPLAYERS + 1][PlayerData]; - -/** - Cvar variables - */ -new bool: g_bIsEnabled, - bool: g_bIsAutoScrambleEnabled, - bool: g_bIsVoteEnabled, - bool: g_bIsAdminImmunityEnabled; -new Float: g_fTimer_ScrambleDelay, - Float: g_fVote_UpCount, - Float: g_fVote_WinPercent; -new g_iAutoScramble_Minplayers, - g_iAutoScramble_Mode, - g_iAutoScramble_WinStreak, - g_iAutoScramble_SteamRoll, - g_iAutoScramble_Frags, - g_iVote_Mode, - g_iVote_MinPlayers; -new String: g_sScrambleNowFlag[5], - String: g_sAdminImmunityFlag[5]; - -/** -Other globals -*/ -new g_iMaxEntities, - g_iOwnerOffset; - -public Plugin:myinfo = -{ - name = "Simple AutoScrambler", - author = "Simple Plugins", - description = "Automatically scrambles the teams based upon a number of events.", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -}; - -public OnPluginStart() -{ - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook the game events - */ - LogAction(0, -1, "[SAS] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - switch (g_CurrentMod) - { - case GameType_TF: - { - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - } - case GameType_DOD: - { - HookEvent("dod_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_Post); - } - default: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_Post); - } - } - - /** - Create console variables - */ - CreateConVar("sas_version", PLUGIN_VERSION, "Simple AutoScrambler Version",FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - sas_enabled = CreateConVar("sas_enabled", "1", "Enable/Disable Simple AutoScrambler"); - sas_timer_scrambledelay = CreateConVar("sas_timer_scrambledelay", "5.0", "Delay used after a scramble has been started", _, true, 1.0, true, 30.0); - - /** - Cvars used for admins - */ - sas_admin_immunity_enabled = CreateConVar("sas_admin_immunity_enabled", "1", "Enable/Disable admin immunity for scrambles"); - sas_admin_flag_scramblenow = CreateConVar("sas_admin_flag_scramblenow", "z", "Admin flag to use for scramblenow function/command"); - sas_admin_flag_immunity = CreateConVar("sas_admin_flag_immunity", "z", "Admin flag to use for scramble immunity"); - - /** - Cvars used for autoscramble - */ - sas_autoscramble_enabled = CreateConVar("sas_autoscramble_enabled", "1", "Enable/Disable the autoscramble function"); - sas_autoscramble_minplayers = CreateConVar("sas_autoscramble_minplayers", "16", "Min players needed to start an autoscramble"); - sas_autoscramble_mode = CreateConVar("sas_autoscramble_mode", "1", "Scramble mode used when autoscrambling"); - sas_autoscramble_winstreak = CreateConVar("sas_autoscramble_winstreak", "5", "Max amount of wins in a row a team can achieve before an autoscramble starts"); - sas_autoscramble_steamroll = CreateConVar("sas_autoscramble_steamroll", "120", "Shortest amount of time a team can win by before an autoscramble starts (seconds)"); - sas_autoscramble_frags = CreateConVar("sas_autoscramble_frags", "1", "Min players needed to start a vote and scramble"); - - /** - Cvars used for voting - */ - sas_vote_enabled = CreateConVar("sas_vote_enabled", "1", "Enable/Disable voting for scramble"); - sas_vote_upcount = CreateConVar("sas_vote_upcount", "5", "Amount of people wanting a scramble before a vote starts. If less than 1 it will be considered a percentage. (ie 0.5 = 50% | 1 = 1 Player | 5 = 5 Players)"); - sas_vote_winpercent = CreateConVar("sas_vote_winpercent", "0.6", "Percentage of votes needed to scramble", _, true, 0.0, true, 1.0); - sas_vote_mode = CreateConVar("sas_vote_mode", "1", "Scramble mode used when a vote results in a scramble"); - sas_vote_minplayers = CreateConVar("sas_vote_minplayers", "16", "Min players needed to start a vote and scramble"); - - /** - Hook the console variables if they change - */ - HookConVarChange(sas_enabled, ConVarSettingsChanged); - HookConVarChange(sas_timer_scrambledelay, ConVarSettingsChanged); - HookConVarChange(sas_admin_immunity_enabled, ConVarSettingsChanged); - HookConVarChange(sas_admin_flag_scramblenow, ConVarSettingsChanged); - HookConVarChange(sas_admin_flag_immunity, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_enabled, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_minplayers, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_mode, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_winstreak, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_steamroll, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_frags, ConVarSettingsChanged); - HookConVarChange(sas_vote_enabled, ConVarSettingsChanged); - HookConVarChange(sas_vote_upcount, ConVarSettingsChanged); - HookConVarChange(sas_vote_winpercent, ConVarSettingsChanged); - HookConVarChange(sas_vote_mode, ConVarSettingsChanged); - HookConVarChange(sas_vote_minplayers, ConVarSettingsChanged); - - /** - Register the command - */ - RegConsoleCmd("sm_scramblenow", Command_ScrambleNow, "sm_scramblenow (mode): Scrambles the teams"); - - /** - Load translations and .cfg file - */ - LoadTranslations ("simpleautoscrambler.phrases"); - AutoExecConfig(true, "plugin.simpleautoscrambler"); - LogAction(0, -1, "[SAS] Simple AutoScrambler is loaded."); -} - -public OnAllPluginsLoaded() -{ - //something -} - -public OnLibraryRemoved(const String:name[]) -{ - //something -} - -public OnConfigsExecuted() -{ - - /** - Load up all the variable defaults - */ - LoadUpVariables(); - - /** - Log our activity - */ - if (g_bIsEnabled) - LogAction(0, -1, "Simple AutoScrambler is ENABLED"); - else - LogAction(0, -1, "Simple AutoScrambler is DISABLED"); -} - -public Action:Command_ScrambleNow(client, args) -{ - - /** - Make sure we are enabled - */ - if (!g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - Make sure the client is authorized to run this command. - */ - if (!SM_IsValidAdmin(client, g_sScrambleNowFlag)) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Make sure it's ok to scramble at this time - */ - if (!OkToScramble) - { - return Plugin_Handled; - } - - /** - Make sure it's ok to scramble at this time - */ - LogAction(0, -1, "[SAS] The scramblenow command was used"); - - /** - Scramble the teams - */ - StartAScramble(); - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public HookRoundStart(Handle:event, const String:name[], bool:dontBroadcast) -{ - -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - -} - -public Action:Timer_ScrambleTeams(Handle:timer, any:mode) -{ - - /** - Make sure it's still ok to scramble - */ - if (!OkToScramble) - { - return Plugin_Handled; - } - - - switch (mode) - { - case - - - - } - - - /** - Reset the handle because the timer is over and the callback is done - */ - g_hScrambleTimer = INVALID_HANDLE; - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - -} - -stock StartAScramble(mode) -{ - - /** - See if we are already started a scramble - */ - if (g_hScrambleTimer == INVALID_HANDLE) - { - - /** - There is a scramble in progress - */ - return; - - } - - /** - Report that a scramble is about to start - */ - PrintCenterTextAll("%T", "Scramble", LANG_SERVER); - - /** - Start a timer and log the action - */ - g_hScrambleTimer = CreateTimer(g_fTimer_ScrambleDelay, Timer_ScrambleTeams, mode, TIMER_FLAG_NO_MAPCHANGE); - LogAction(0, -1, "[SAS] A scamble timer was started"); -} - -stock bool:OkToScramble() -{ - -} - -stock LoadUpVariables() -{ - g_bIsEnabled = GetConVarBool(sas_enabled); - g_bIsAutoScrambleEnabled = GetConVarBool(sas_autoscramble_enabled); - g_bIsVoteEnabled = GetConVarBool(sas_vote_enabled); - g_bIsAdminImmunityEnabled = GetConVarBool(sas_admin_immunity_enabled); - g_iAutoScramble_Minplayers = GetConVarInt(sas_autoscramble_minplayers); - g_iAutoScramble_Mode = GetConVarInt(sas_autoscramble_mode); - g_iAutoScramble_WinStreak = GetConVarInt(sas_autoscramble_winstreak); - g_iAutoScramble_SteamRoll = GetConVarInt(sas_autoscramble_steamroll); - g_iAutoScramble_Frags = GetConVarInt(sas_autoscramble_frags); - g_iVote_Mode = GetConVarInt(sas_vote_mode); - g_iVote_MinPlayers = GetConVarInt(sas_vote_minplayers); - GetConVarString(sas_admin_flag_scramblenow, g_sScrambleNowFlag, sizeof(g_sScrambleNowFlag)); - GetConVarString(sas_admin_flag_immunity, g_sAdminImmunityFlag, sizeof(g_sAdminImmunityFlag)); - g_fTimer_ScrambleDelay = GetConVarFloat(sas_timer_scrambledelay); - g_fVote_UpCount = GetConVarFloat(sas_vote_upcount); - g_fVote_WinPercent = GetConVarFloat(sas_vote_winpercent); - g_iMaxEntities = GetMaxEntities(); - g_iOwnerOffset = FindSendPropInfo("CBaseObject", "m_hBuilder"); -} - -stock TF2_DestroyBuildings(client) -{ - - /** - We have to start a loop to check the owner of all the valid entities - */ - for (new i = MaxClients + 1; i <= g_iMaxEntities; i++) - { - if (!IsValidEntity(i)) - { - - /** - Not valid, continue to next one - */ - continue; - } - - /** - Get the name of the current entity - */ - decl String:sNetClass[32]; - GetEntityNetClass(i, sNetClass, sizeof(sNetClass)); - - /** - See if its something that an engineer would build - */ - if (strcmp(sNetClass, "CObjectSentrygun") == 0 - || strcmp(sNetClass, "CObjectTeleporter") == 0 - || strcmp(sNetClass, "CObjectDispenser") == 0) - { - - /** - It is, so lets check the owner - */ - if (GetEntDataEnt2(i, g_iOwnerOffset) == client) - { - - /** - It's the clients building, so we blow it up. - */ - SetVariantInt(9999); - AcceptEntityInput(i, "RemoveHealth"); - } - } - } -} \ No newline at end of file diff --git a/Simple Message Suppression/addons/sourcemod/scripting/simple-chatcolors.sp b/Simple Message Suppression/addons/sourcemod/scripting/simple-chatcolors.sp deleted file mode 100644 index 539d057..0000000 --- a/Simple Message Suppression/addons/sourcemod/scripting/simple-chatcolors.sp +++ /dev/null @@ -1,496 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Chat Colors -Description: - Changes the colors of players chat based on config file -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#pragma semicolon 1 -#include -#include - -#define PLUGIN_VERSION "0.9.0.$Rev$" - -#define CHAT_SYMBOL '@' -#define TRIGGER_SYMBOL1 '!' -#define TRIGGER_SYMBOL2 '/' -#define CHAT_MAX_MESSAGE_LENGTH 1024 - -new Handle:g_hDebugCvar = INVALID_HANDLE; -new Handle:g_aGroupNames = INVALID_HANDLE; -new Handle:g_aGroupFlag = INVALID_HANDLE; -new Handle:g_aGroupNameColor = INVALID_HANDLE; -new Handle:g_aGroupTextColor = INVALID_HANDLE; - -new bool:g_bDebug = false; - -new g_iArraySize; - -new g_aPlayerColorIndex[MAXPLAYERS + 1] = { -1, ... }; - -public Plugin:myinfo = -{ - name = "Simple Chat Colors", - author = "Simple Plugins", - description = "Changes the colors of players chat based on config file.", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -}; - -/** -Sourcemod callbacks -*/ -public OnPluginStart() -{ - - /** - Need to create all of our console variables. - */ - CreateConVar("sm_chatcolors_version", PLUGIN_VERSION, "Simple Chat Colors", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - g_hDebugCvar = CreateConVar("sm_chatcolors_debug", "1", "Enable/Disable debugging information"); - - /** - Hook console variables - */ - HookConVarChange(g_hDebugCvar, ConVarSettingsChanged); - - /** - Need to register the commands we are going to use - */ - RegConsoleCmd("say", Command_Say); - RegConsoleCmd("say_team", Command_SayTeam); - RegAdminCmd("sm_reloadcolorsconfig", Command_Reload, ADMFLAG_GENERIC, "Reloads settings from config file"); - - /** - Create the arrays - */ - g_aGroupNames = CreateArray(256, 1); - g_aGroupFlag = CreateArray(15, 1); - g_aGroupNameColor = CreateArray(15, 1); - g_aGroupTextColor = CreateArray(15, 1); - - /** - Load the admins and colors from the config - */ - LoadAdminsAndColorsFromConfig(); - g_iArraySize = GetArraySize(g_aGroupNames); -} - -public OnConfigsExecuted() -{ - g_bDebug = GetConVarBool(g_hDebugCvar); - ReloadConfigFile(); -} - -public OnClientPostAdminCheck(client) -{ - - /** - Check the client to see if they are a admin - */ - CheckAdmin(client); -} - -public OnClientDisconnect(client) -{ - g_aPlayerColorIndex[client] = -1; -} - -/** -Commands -*/ -public Action:Command_Say(client, args) -{ - - /** - Make sure we are enabled. - */ - if (client == 0 || IsChatTrigger()) - { - return Plugin_Continue; - } - - if (g_aPlayerColorIndex[client] != -1) - { - - /** - The client is, so get the chat message and strip it down. - */ - decl String:sArg[CHAT_MAX_MESSAGE_LENGTH], - String:sChatMsg[CHAT_MAX_MESSAGE_LENGTH]; - - new bool:bAlive = IsPlayerAlive(client); - - GetCmdArgString(sArg, sizeof(sArg)); - StripQuotes(sArg); - TrimString(sArg); - new startidx; - if (sArg[strlen(sArg)-1] == '"') - { - sArg[strlen(sArg)-1] = '\0'; - startidx = 1; - } - - /** - Bug out if they are using the admin chat symbol (admin chat). If we are in CSS it may not find all the triggers, so we double check. - */ - if (sArg[startidx] == CHAT_SYMBOL || sArg[startidx] == TRIGGER_SYMBOL1 || sArg[startidx] == TRIGGER_SYMBOL2) - { - return Plugin_Continue; - } - - /** - Log the message for hlstatsx and other things. - */ - new iUserID = GetClientUserId(client); - decl String:sAuthID[64]; - GetClientAuthString(client, sAuthID, sizeof(sAuthID)); - LogToGame("\"%N<%i><%s><>\" say \"%s\"", client, iUserID, sAuthID, sArg); - - /** - Format the message. - */ - FormatMessage(client, 0, bAlive, sChatMsg, sArg, g_aPlayerColorIndex[client]); - - /** - Send the message. - */ - //SayText2(0, client, sChatMsg); - CPrintToChatAll(sChatMsg); - - /** - We are done, bug out, and stop the original chat message. - */ - return Plugin_Stop; - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -public Action:Command_SayTeam(client, args) -{ - - /** - Make sure we are enabled. - */ - if (client == 0 || IsChatTrigger()) - { - return Plugin_Continue; - } - - /** - Check the client to see if they are a admin - */ - if (g_aPlayerColorIndex[client] != -1) - { - - /** - The client is, so get the chat message and strip it down. - */ - decl String:sArg[CHAT_MAX_MESSAGE_LENGTH], - String:sChatMsg[CHAT_MAX_MESSAGE_LENGTH]; - - new bool:bAlive = IsPlayerAlive(client); - new iCurrentTeam = GetClientTeam(client); - - GetCmdArgString(sArg, sizeof(sArg)); - StripQuotes(sArg); - TrimString(sArg); - new startidx; - if (sArg[strlen(sArg)-1] == '"') - { - sArg[strlen(sArg)-1] = '\0'; - startidx = 1; - } - - /** - Bug out if they are using the admin chat symbol (admin chat). - */ - if (sArg[startidx] == CHAT_SYMBOL || sArg[startidx] == TRIGGER_SYMBOL1 || sArg[startidx] == TRIGGER_SYMBOL2) - { - return Plugin_Continue; - } - - /** - Log the message for hlstatsx and other things. - */ - new iUserID = GetClientUserId(client); - decl String:sAuthID[64]; - GetClientAuthString(client, sAuthID, sizeof(sAuthID)); - LogToGame("\"%N<%i><%s><>\" say_team \"%s\"", client, iUserID, sAuthID, sArg); - - /** - Format the message. - */ - FormatMessage(client, iCurrentTeam, bAlive, sChatMsg, sArg, g_aPlayerColorIndex[client]); - - /** - Send the message to the same team - */ - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientConnected(i) && IsClientInGame(i) && GetClientTeam(i) == iCurrentTeam) - { - CPrintToChat(client, sChatMsg); - } - } - - /** - We are done, bug out, and stop the original chat message. - */ - return Plugin_Stop; - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -public Action:Command_Reload(client, args) -{ - ReloadConfigFile(); - return Plugin_Handled; -} - -/** -Stock Functions -*/ -stock LoadAdminsAndColorsFromConfig() -{ - - /** - Make sure the config file is here and load it up - */ - new String:sConfigFile[256]; - BuildPath(Path_SM, sConfigFile, sizeof(sConfigFile), "configs/simple-chatcolors.cfg"); - if (!FileExists(sConfigFile)) - { - - /** - Config file doesn't exists, stop the plugin - */ - LogError("[SCC] Simple Chat Colors is not running! Could not find file %s", sConfigFile); - SetFailState("Could not find file %s", sConfigFile); - } - - /** - Create the arrays and variables - */ - new String:sGroupName[256]; - new String:sGroupFlag[15]; - new String:sGroupNameColor[15]; - new String:sGroupTextColor[15]; - - - /** - Load config file as a KeyValues file - */ - new Handle:kvChatColors = CreateKeyValues("admin_colors"); - FileToKeyValues(kvChatColors, sConfigFile); - - if (!KvGotoFirstSubKey(kvChatColors)) - { - return; - } - - /** - Load up all the groups in the file - */ - do - { - - /** - Get the section name; should be the "group" name - */ - KvGetSectionName(kvChatColors, sGroupName, sizeof(sGroupName)); - - - /** - Get the flags and colors - */ - KvGetString(kvChatColors, "flag", sGroupFlag, sizeof(sGroupFlag)); - KvGetString(kvChatColors, "namecolor", sGroupNameColor, sizeof(sGroupNameColor)); - KvGetString(kvChatColors, "textcolor", sGroupTextColor, sizeof(sGroupTextColor)); - - if (g_bDebug) - { - LogMessage("Group Name/SteamID: %s", sGroupName); - LogMessage("Flag String: %s", sGroupFlag); - LogMessage("Color on name: %s", sGroupNameColor); - LogMessage("Color of text: %s", sGroupTextColor); - } - - /** - Push the values to the arrays - */ - PushArrayString(g_aGroupNames, sGroupName); - PushArrayString(g_aGroupFlag, sGroupFlag); - PushArrayString(g_aGroupNameColor, sGroupNameColor); - PushArrayString(g_aGroupTextColor, sGroupTextColor); - } while (KvGotoNextKey(kvChatColors)); - - /** - Close our handle - */ - CloseHandle(kvChatColors); -} - -stock ReloadConfigFile() -{ - - /** - Clear the array - */ - ClearArray(g_aGroupNames); - ClearArray(g_aGroupFlag); - ClearArray(g_aGroupNameColor); - ClearArray(g_aGroupTextColor); - - /** - Load the admins, groups, and colors from the config - */ - LoadAdminsAndColorsFromConfig(); - g_iArraySize = GetArraySize(g_aGroupNames); - - /** - Recheck all the online players for assigned colors - */ - for (new index = 1; index <= MaxClients; index++) - { - if (IsClientConnected(index) && IsClientInGame(index)) - { - CheckAdmin(index); - } - } -} - -stock CheckAdmin(client) -{ - new String:sFlags[15]; - new String:sClientSteamID[64]; - new iGroupFlags; - new iFlags; - new iIndex = -1; - - /** - Look for a steamid first - */ - GetClientAuthString(client, sClientSteamID, sizeof(sClientSteamID)); - iIndex = FindStringInArray(g_aGroupNames, sClientSteamID); - if (iIndex != -1) - { - g_aPlayerColorIndex[client] = iIndex; - } - - /** - Didn't find one, check flags - */ - else - { - /** - Search for flag in groups - */ - - iFlags = GetUserFlagBits(client); - for (iIndex = 0; iIndex < g_iArraySize; iIndex++) - { - GetArrayString(g_aGroupFlag, iIndex, sFlags, sizeof(sFlags)); - iGroupFlags = ReadFlagString(sFlags); - if (iFlags & iGroupFlags) - { - g_aPlayerColorIndex[client] = iIndex; - break; - } - } - } - - if (g_bDebug) - { - PrintToChatAll("SteamID: %s", sClientSteamID); - PrintToChatAll("Array Index: %i", iIndex); - PrintToChatAll("Flag String: %s", sFlags); - PrintToChatAll("Flag Bits of Client: %i", iFlags); - PrintToChatAll("Flag Bits of Group: %i", iGroupFlags); - } -} - -stock FormatMessage(iClient, iTeam, bool:bAlive, String:sChatMsg[], const Sting:sMessage[], iArrayIndex) -{ - decl String:sDead[10], - String:sTeam[10], - String:sClientName[64]; - - GetClientName(iClient, sClientName, sizeof(sClientName)); - - if (iTeam != 0) - { - Format(sTeam, sizeof(sTeam), "(TEAM) "); - } - else - { - Format(sTeam, sizeof(sTeam), ""); - } - if (bAlive) - { - Format(sDead, sizeof(sDead), ""); - } - else - { - Format(sDead, sizeof(sDead), "*DEAD* "); - } - - new String:sNameColor[15]; - new String:sTextColor[15]; - GetArrayString(g_aGroupNameColor, iArrayIndex, sNameColor, sizeof(sNameColor)); - GetArrayString(g_aGroupTextColor, iArrayIndex, sTextColor, sizeof(sTextColor)); - - Format(sChatMsg, CHAT_MAX_MESSAGE_LENGTH, "{default}%s%s%s%s {default}: %s%s", sDead, sTeam, sNameColor, sClientName, sTextColor, sMessage); -} - -/** -Adjust the settings if a convar was changed -*/ -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (StringToInt(newValue) == 1) - { - g_bDebug = true; - } - else - { - g_bDebug = false; - } -} \ No newline at end of file diff --git a/Simple Message Suppression/addons/sourcemod/scripting/simple-donatorbenefits.sp b/Simple Message Suppression/addons/sourcemod/scripting/simple-donatorbenefits.sp deleted file mode 100644 index e3f6845..0000000 --- a/Simple Message Suppression/addons/sourcemod/scripting/simple-donatorbenefits.sp +++ /dev/null @@ -1,1312 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Donator Benefits -Description: - Provides donator benefits to players -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include -#include - -#define PLUGIN_VERSION "1.1.$Rev$" - -#define CHAT_SYMBOL '@' -#define CHAT_MAX_MESSAGE_LENGTH 1024 - -enum PlayerData -{ - bool:bIsDonator, - bool:bQueue, - bool:bImmune, - iHealthCount, - iNewTeam -}; - -/** - Public convar handles - */ -new Handle:sdb_enabled = INVALID_HANDLE; -new Handle:sdb_donationflag = INVALID_HANDLE; -new Handle:sdb_soundfile = INVALID_HANDLE; -new Handle:sdb_joinsound_enabled = INVALID_HANDLE; -new Handle:sdb_joinpubmsg_enabled = INVALID_HANDLE; -new Handle:sdb_joinprivmsg_enabled = INVALID_HANDLE; -new Handle:sdb_chatcolors_enabled = INVALID_HANDLE; -new Handle:sdb_immunity_enabled = INVALID_HANDLE; -new Handle:sdb_ubercharge_enabled = INVALID_HANDLE; -new Handle:sdb_givehealth_enabled = INVALID_HANDLE; -new Handle:sdb_nofalldmg_enabled = INVALID_HANDLE; -new Handle:sdb_fastheavy_enabled = INVALID_HANDLE; -new Handle:sdb_swapteam_enabled = INVALID_HANDLE; -new Handle:sdb_chatcolor = INVALID_HANDLE; -new Handle:sdb_uberlevel = INVALID_HANDLE; -new Handle:sdb_healthcount = INVALID_HANDLE; -new Handle:sdb_healthbonus = INVALID_HANDLE; -new Handle:sdb_heavymultiplier = INVALID_HANDLE; - -/** -Create global enable/disable bools so we don't have to check the console variable on every call -*/ -new bool:g_bIsEnabled = true; -new bool:g_bIsJoinSoundEnabled = true; -new bool:g_bIsJoinPubMsgEnabled = true; -new bool:g_bIsJoinPrivMsgEnabled = true; -new bool:g_bIsChatColorsEnabled = true; -new bool:g_bIsImmuntyEnabled = true; -new bool:g_bIsUberChargeEnabled = true; -new bool:g_bIsGiveHealthEnabled = true; -new bool:g_bIsNoFallDmgEnabled = true; -new bool:g_bIsFastHeayEnabled = true; -new bool:g_bIsSwapTeamEnabled = true; - -/** - Player arrays - */ -new g_aPlayers[MAXPLAYERS + 1][PlayerData]; - - -/** -Rest of the globals -*/ -new bool:g_bRoundEnd = false; -new String:g_sCharDonatorFlag[5]; -new String:g_sSoundFile[PLATFORM_MAX_PATH]; -new String:g_sChatColor[11]; -new g_iHealthBonus; -new g_iHealthCount; -new g_iClassMaxHealth[TFClassType] = {0, 125, 125, 200, 175, 150, 300, 175, 125, 125}; -new g_fClassMaxSpeed[TFClassType] = {0, 400, 300, 240, 280, 320, 230, 300, 300, 300}; -new Float:g_fHeavyMultiplier = 0.0; -new Float:g_fUberLevel = 0.0; - -public Plugin:myinfo = -{ - name = "Simple Donation Benefits", - author = "Simple Plugins", - description = "Gives donators benefits to players", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -} - -public OnPluginStart() -{ - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook the game events - */ - LogAction(0, -1, "[SDB] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_connect", HookPlayerSpawn, EventHookMode_Pre); - HookEvent("player_spawn", HookPlayerSpawn, EventHookMode_Post); - HookEvent("player_death", HookPlayerDeath, EventHookMode_Post); - HookEvent("player_team", HookPlayerChangeTeam, EventHookMode_Post); - switch (g_CurrentMod) - { - case GameType_TF: - { - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - HookEvent("player_changeclass", HookPlayerClass, EventHookMode_Post); - } - case GameType_DOD: - { - HookEvent("dod_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_Post); - } - default: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - } - } - - /** - Create console variables - */ - CreateConVar("sdb_version", PLUGIN_VERSION, "Simple Donation Benefits", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - sdb_enabled = CreateConVar("sdb_enabled", "1", "Enable/Disable Simple Donation Benefits"); - sdb_donationflag = CreateConVar("sdb_donationflag", "a", "Flag ALREADY given to donators. Must be in char format"); - - /** - Create the enable/disable donator console variables - */ - sdb_joinsound_enabled = CreateConVar("sdb_joinsound_enabled", "1", "Enable/Disable donator join sound"); - sdb_joinpubmsg_enabled = CreateConVar("sdb_joinpubmsg_enabled", "1", "Enable/Disable public donator join message (replaces: as connected)"); - sdb_joinprivmsg_enabled = CreateConVar("sdb_joinprivmsg_enabled", "1", "Enable/Disable private donator join message (sent only to donator)"); - sdb_chatcolors_enabled = CreateConVar("sdb_chatcolors_enabled", "1", "Enable/Disable donator chat colors"); - sdb_immunity_enabled = CreateConVar("sdb_immunity_enabled", "1", "Enable/Disable donator round end immunity"); - sdb_ubercharge_enabled = CreateConVar("sdb_ubercharge_enabled", "1", "Enable/Disable donator medics starting with ubercharge"); - sdb_givehealth_enabled = CreateConVar("sdb_givehealth_enabled", "1", "Enable/Disable donator instant health bonus"); - sdb_nofalldmg_enabled = CreateConVar("sdb_nofalldmg_enabled", "1", "Enable/Disable no fall damage for donators"); - sdb_fastheavy_enabled = CreateConVar("sdb_fastheavy_enabled", "1", "Enable/Disable donator heavies moving faster while spinning"); - sdb_swapteam_enabled = CreateConVar("sdb_swampteam_enabled", "1", "Enable/Disable donator swap team ability"); - - /** - Create the donator setting console variables - */ - sdb_soundfile = CreateConVar("sdb_soundfile", "custom/donatorjoin.mp3", "The location of sound file"); - sdb_chatcolor = CreateConVar("sdb_chatcolor", "green", "Color to use for donator chat. Valid colors are green and lightgreen"); - sdb_uberlevel = CreateConVar("sdb_uberlevel", "0.5", "Uberlevel to give donator medic at spawn. 1.0 = full uber", _, true, 0.0, true, 1.0); - sdb_healthcount = CreateConVar("sdb_healthcount", "1", "Number of times a donator can use use instant health per life"); - sdb_healthbonus = CreateConVar("sdb_healthbonus", "100", "The amount of health to heal the donator"); - sdb_heavymultiplier = CreateConVar("sdb_heavyspeed", "0.5", "The speed multiplier for the fast heavy. Based on running speed. 1.0 = running speed. (Game Default is 0.20)", _, true, 0.0, true, 1.0); - - /** - Hook dukehacks calls - */ - dhAddClientHook(CHK_TakeDamage, Hacks_TakeDamageHook); - dhAddClientHook(CHK_PreThink, Hacks_PreThinkHook); - - /** - Hook the console variables if they change - */ - HookConVarChange(sdb_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_donationflag, ConVarSettingsChanged); - HookConVarChange(sdb_joinsound_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_joinpubmsg_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_joinprivmsg_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_chatcolors_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_immunity_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_ubercharge_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_givehealth_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_nofalldmg_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_swapteam_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_fastheavy_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_soundfile, ConVarSettingsChanged); - HookConVarChange(sdb_chatcolor, ConVarSettingsChanged); - HookConVarChange(sdb_uberlevel, ConVarSettingsChanged); - HookConVarChange(sdb_healthcount, ConVarSettingsChanged); - HookConVarChange(sdb_healthbonus, ConVarSettingsChanged); - HookConVarChange(sdb_heavymultiplier, ConVarSettingsChanged); - - /** - Register the commands - */ - RegConsoleCmd("sm_swapteams", Command_SwapTeam, "sm_swapteams <[0]instant/[1]queued>: Swaps your team to the other team"); - RegConsoleCmd("sm_ihealth", Command_InstantHealth, "sm_ihealth: Gives you a instant health pack"); - RegAdminCmd("sm_teaser", Command_Teaser, ADMFLAG_GENERIC,"sm_teaser <[0]add/[1]remove>: Gives temporary donator privilages to a player"); - RegConsoleCmd("say", Command_Say); - - RegConsoleCmd("sm_test", Command_TEST); - - /** - Load the translations - */ - LoadTranslations("common.phrases"); - LoadTranslations("simpledonatorbenefits.phrases"); - - /** - Load or create the config file - */ - AutoExecConfig(true, "plugin.simpledonatorbenefits"); - LogAction(0, -1, "[SDB] Simple Donator Benefits is loaded."); -} - -public OnAllPluginsLoaded() -{ - //something -} - -public OnLibraryRemoved(const String:name[]) -{ - //something -} - -public OnConfigsExecuted() -{ - /** - Load up all the variable defaults - */ - LoadUpVariables(); - - /** - If the join sound is enabled, prep the sound files - */ - if (g_bIsJoinSoundEnabled) - PrepSoundFile(); - - /** - Log our activity - */ - if (g_bIsEnabled) - LogAction(0, -1, "Simple Donation Benefits is ENABLED"); - else - LogAction(0, -1, "Simple Donation Benefits is DISABLED"); -} - -public OnClientPostAdminCheck(client) -{ - - /** - Check if the client is a donator - */ - if (SM_IsValidAdmin(client, g_sCharDonatorFlag)) - { - - /** - They are, so we set the player array to true and start a timer for the sound or add - */ - g_aPlayers[client][bIsDonator] = true; - if (g_bIsJoinSoundEnabled || g_bIsJoinPrivMsgEnabled) - { - CreateTimer(10.0, Timer_DonatorJoined, client, TIMER_FLAG_NO_MAPCHANGE); - } - } - else - { - /** - They aren't, so we set the player array to false - */ - g_aPlayers[client][bIsDonator] = false; - } -} - -public OnClientDisconnect_Post(client) -{ - - /** - Clean up the player variables - */ - CleanUpPlayer(client); -} - -public Action:Command_SwapTeam(client, args) -{ - - /** - Make sure we are enabled - */ - if (!g_bIsEnabled || !g_bIsSwapTeamEnabled) - { - return Plugin_Handled; - } - - /** - Make sure the command is not started by the server - */ - if (client == 0) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "PlayerLevelCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Make sure the player is a donator - */ - if (!g_aPlayers[client][bIsDonator]) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Lets make sure the client is one a team we can swap. - If he is we set the global array to the opposite team. - */ - new iTeam = GetClientTeam(client); - if (iTeam == g_aCurrentTeams[Team1]) - { - g_aPlayers[client][iNewTeam] = g_aCurrentTeams[Team2]; - } - else if (iTeam == g_aCurrentTeams[Team2]) - { - g_aPlayers[client][iNewTeam] = g_aCurrentTeams[Team1]; - } - else - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "InValidTeam", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check to see if we have command arguments. - */ - if (GetCmdArgs()) - { - - /** - We do, so lets get it and see if the client wants to be switched instantly or queued for death. - */ - decl String:sArg[5]; - GetCmdArg(1, sArg, sizeof(sArg)); - new iWantsQue = StringToInt(sArg); - if (iWantsQue && !g_aPlayers[client][bQueue]) - { - - /** - He wants the que and isn't already in it, set the global array. - */ - g_aPlayers[client][bQueue] = true; - ReplyToCommand(client, "\x01\x04[STM]\x01 %T", "PlayerQueue", LANG_SERVER); - } - else if (!iWantsQue) - { - - /** - He wants to be switched right now, lets call the stock function. - */ - SM_MovePlayer(client, g_aPlayers[client][iNewTeam]); - } - } - else - { - - /** - There are no command arguments so we build and display the swap menu. - */ - new Handle:hPlayerMenu = BuildSwapModeMenu(); - DisplayMenu(hPlayerMenu, client, MENU_TIME_FOREVER); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_InstantHealth(client, args) -{ - - /** - Make sure we are enabled - */ - if (!g_bIsEnabled || !g_bIsGiveHealthEnabled) - { - return Plugin_Handled; - } - - /** - Make sure the command is not started by the server - */ - if (client == 0) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "PlayerLevelCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Make sure the player is a donator - */ - if (!g_aPlayers[client][bIsDonator]) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check health count to see if the player has reached the max - */ - if (g_aPlayers[client][iHealthCount] >= g_iHealthCount) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "ReachedCount", LANG_SERVER); - return Plugin_Handled; - } - - /** - Get the class of the player and the max health for that class - */ - new iHealth = GetClientHealth(client); - new TFClassType:PlayerClass = TF2_GetPlayerClass(client); - new iMaxHealth = g_iClassMaxHealth[PlayerClass]; - - /** - Check to see if the player is at the max health of the class - */ - if (iHealth >= iMaxHealth) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "AtMaxHealth", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check the current health - */ - if (iHealth + g_iHealthBonus >= iMaxHealth) - { - - /** - Raise them to max health if the current health + bonus would go above it - */ - SetEntityHealth(client, iMaxHealth); - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "ToMaxHealth", LANG_SERVER); - } - else - { - - /** - Give them the instant health bonus - */ - SetEntityHealth(client, iHealth + g_iHealthBonus); - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "HealthBonus", LANG_SERVER); - } - - /** - Increase the count - */ - g_aPlayers[client][iHealthCount] += 1; - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_Teaser(client, args) -{ - - /** - Make sure we are enabled - */ - if (!g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - Check to see if we have command arguments. - */ - new iCmdArgs = GetCmdArgs(); - if (iCmdArgs == 0) - { - - /** - We don't so display the player menu. - */ - new Handle:hPlayerMenu = BuildPlayerMenu(); - DisplayMenu(hPlayerMenu, client, MENU_TIME_FOREVER); - return Plugin_Handled; - } - - /** - We have some arguments, see if we can find the player - */ - decl String:sPlayer[64]; - GetCmdArg(1, sPlayer, sizeof(sPlayer)); - new iTarget = FindTarget(client, sPlayer, true, true); - if (iTarget == -1 || !IsClientInGame(iTarget)) - { - - /** - We don't know who this is, so display the player menu. - */ - new Handle:hPlayerMenu = BuildPlayerMenu(); - DisplayMenu(hPlayerMenu, client, MENU_TIME_FOREVER); - } - else - { - /** - We found the player, see if we are supposed to turn it on or off. - */ - if (iCmdArgs >= 2) - { - decl String:sOn[3]; - GetCmdArg(2, sOn, sizeof(sOn)); - if (StringToInt(sOn)) - { - - /** - Turn temp benefits on. - */ - g_aPlayers[iTarget][bIsDonator] = true; - } - else - { - - /** - Turn temp benefits on. - */ - g_aPlayers[iTarget][bIsDonator] = false; - } - } - else - { - - /** - We don't know what to do, so just turn it on. - */ - g_aPlayers[iTarget][bIsDonator] = true; - } - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_Say(client, args) -{ - - /** - Make sure we are enabled. - */ - if (client == 0 || IsChatTrigger() || !g_bIsChatColorsEnabled || !g_bIsEnabled) - { - return Plugin_Continue; - } - - /** - Check the client to see if they are a donator. - */ - if (g_aPlayers[client][bIsDonator]) - { - - /** - The client is, so get the chat message and strip it down. - */ - decl String:sArg[CHAT_MAX_MESSAGE_LENGTH], - String:sChatMsg[CHAT_MAX_MESSAGE_LENGTH]; - new bool:bAlive = IsPlayerAlive(client); - GetCmdArgString(sArg, sizeof(sArg)); - StripQuotes(sArg); - TrimString(sArg); - new startidx; - if (sArg[strlen(sArg)-1] == '"') - { - sArg[strlen(sArg)-1] = '\0'; - startidx = 1; - } - - /** - Bug out if they are using the admin chat symbol (admin chat). - */ - if (sArg[startidx] == CHAT_SYMBOL) - { - return Plugin_Continue; - } - - /** - Format the message. - */ - FormatMessage(client, 0, bAlive, sChatMsg, sArg); - - /** - Send the message. - */ - SayText2(0, client, sChatMsg); - - /** - We are done, bug out, and stop the original chat message. - */ - return Plugin_Stop; - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -public Action:Hacks_TakeDamageHook(client, attacker, inflictor, Float:damage, &Float:multiplier, damagetype) -{ - - /** - Make sure we are enabled and the client is a donator. - */ - if (g_bIsEnabled && g_bIsNoFallDmgEnabled && g_aPlayers[client][bIsDonator]) - { - - /** - Check for fall damage. - */ - if (damagetype & DMG_FALL) - { - - /** - Cancel the fall damage and bug out. - */ - multiplier *= 0.0; - return Plugin_Changed; - } - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -public Action:Hacks_PreThinkHook(client) -{ - - /** - Make sure we are enabled and the client is a donator. - */ - if (!g_bIsEnabled || !g_bIsFastHeayEnabled || !g_aPlayers[client][bIsDonator]) - { - return Plugin_Continue; - } - - /** - Check the players class. We are looking for the heavy. - */ - new TFClassType:PlayerClass = TF2_GetPlayerClass(client); - if (PlayerClass == TFClass_Heavy) - { - - /** - We have a heavy, lets check the weapon. - */ - decl String:sWeaponCurrent[64]; - GetClientWeapon(client, sWeaponCurrent, sizeof(sWeaponCurrent)); - if (StrEqual(sWeaponCurrent, "tf_weapon_minigun", false)) - { - - /** - We have a minigun, check the heavies current weapon state to see if it's spinning. - */ - new iWeapon = GetPlayerWeaponSlot(client, 0); - new iWeaponState = GetEntProp(iWeapon, Prop_Send, "m_iWeaponState"); - if (iWeaponState > 0) - { - - /** - He is spinning, so lets change the heavies speed. - */ - new Float:fMaxSpeed = FloatMul(g_fHeavyMultiplier, float(g_fClassMaxSpeed[PlayerClass])); - SetEntPropFloat(client, Prop_Send, "m_flMaxspeed", fMaxSpeed); - } - } - } - - /** - We are done, bug out. - */ - // use Plugin_Continue (other options are ignored on PreThink hook) - return Plugin_Continue; -} - -public Action:HookPlayerConnect(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Make sure we are enabled. - */ - if (!g_bIsEnabled || !g_bIsJoinPubMsgEnabled || !dontBroadcast) - { - return Plugin_Continue; - } - - /** - Get our event variables and check the client. - */ - new iUserId = GetEventInt(event,"userid"); - new iClient = GetClientOfUserId(iUserId); - if (iClient != 0) - { - - /** - Get the info on the client and format the message. - */ - decl String:sClientName[255], - String:sAuthID[255], - String:sMsg[1024]; - - GetEventString(event, "name", sClientName, sizeof(sClientName)); - GetClientAuthString(iClient, sAuthID, sizeof(sAuthID)); - Format(sMsg, sizeof(sMsg), "%T", "PublicJoinMessage", LANG_SERVER, sClientName); - - /** - Print the message to the clients and do the normal functions. - */ - for (new i = 1; i <= MaxClients; i++) - { - if(IsClientConnected(i) && IsClientInGame(i)) - { - PrintToChat(i,"\x01\x05%s", sMsg); - PrintToConsole(i,"%s has connected.", sClientName); - } - } - LogToGame("\"%s<%d><%s><>\" entered the game", sClientName, iUserId, sAuthID); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public HookPlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled && g_bIsUberChargeEnabled) - { - - /** - Get the event variables and check the class for medic - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - if (TF2_GetPlayerClass(iClient) == TFClass_Medic) - { - - /** - Start a timer to get the medic the uber boost - */ - CreateTimer(0.25, Timer_PlayerUberDelay, iClient, TIMER_FLAG_NO_MAPCHANGE); - } - } -} - -public HookPlayerClass(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled && g_bIsUberChargeEnabled) - { - - /** - Get the event variables and check the class for medic - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - if (TF2_GetPlayerClass(iClient) == TFClass_Medic) - { - - /** - Start a timer to get the medic the uber boost - */ - CreateTimer(0.25, Timer_PlayerUberDelay, iClient, TIMER_FLAG_NO_MAPCHANGE); - } - } -} - -public HookPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled || g_bIsSwapTeamEnabled) - { - - /** - Get the event variables - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - new String:sWeapon[256]; - GetEventString(event, "weapon", sWeapon, sizeof(sWeapon)); - - /** - Bug out if world killed him. Means he changed team or something - */ - if (StrEqual(sWeapon, "world", false)) - { - g_aPlayers[iClient][bQueue] = false; - return; - } - - /** - If he is queued up, swap him - */ - if (g_aPlayers[iClient][bQueue]) - { - SM_MovePlayer(iClient, g_aPlayers[iClient][iNewTeam]); - } - } -} - -public HookPlayerChangeTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled || g_bIsSwapTeamEnabled) - { - - /** - Get the event variables - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - - /** - If he is queued up, clear the status - */ - if (g_aPlayers[iClient][bQueue]) - { - g_aPlayers[iClient][bQueue] = false; - } - } -} - -public HookRoundStart(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Set our variables. - */ - g_bRoundEnd = false; - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled && g_bIsImmuntyEnabled) - { - - /** - Get rid of their immunity. - */ - ProcessRoundEndImmunity(false); - } -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Set our variables. - */ - g_bRoundEnd = true; - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled && g_bIsImmuntyEnabled) - { - - /** - Give them their immunity. - */ - ProcessRoundEndImmunity(true); - } -} - -public Action:Timer_DonatorJoined(Handle:timer, any:client) -{ - - /** - Make sure sounds are enabled. - */ - if (g_bIsEnabled && g_bIsJoinSoundEnabled) - { - EmitSoundToClient(client, g_sSoundFile); - } - - /** - Make sure private messages are enabled. - */ - if (g_bIsJoinPrivMsgEnabled) - { - - /** - Send messages to the client. - */ - decl String:sMsg[1024]; - Format(sMsg, sizeof(sMsg), "%T", "PrivateJoinMessage", LANG_SERVER); - PrintToChat(client,"\x01\x05%s", sMsg); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Timer_PlayerUberDelay(Handle:timer, any:client) -{ - - /** - Make sure the client is still in game. - */ - if (IsClientInGame(client)) - { - - /** - Make sure the client is still a medic. - */ - if (TF2_GetPlayerClass(client) == TFClass_Medic) - { - - /** - Get the medgun weapon index - */ - new iIndex = GetPlayerWeaponSlot(client, 1); - if (iIndex > 0) - { - - /** - Set the uber level with the bonus. - */ - SetEntPropFloat(iIndex, Prop_Send, "m_flChargeLevel", g_fUberLevel); - } - } - } -} - -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (convar == sdb_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsEnabled = false; - } - else - { - g_bIsEnabled = true; - } - } - else if (convar == sdb_donationflag) - { - Format(g_sCharDonatorFlag, sizeof(g_sCharDonatorFlag), "%s", newValue); - } - else if (convar == sdb_soundfile) - { - Format(g_sSoundFile, sizeof(g_sSoundFile), "%s", newValue); - } - else if (convar == sdb_joinsound_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsJoinSoundEnabled = false; - } - else - { - g_bIsJoinSoundEnabled = true; - } - } - else if (convar == sdb_joinpubmsg_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsJoinPubMsgEnabled = false; - } - else - { - g_bIsJoinPubMsgEnabled = true; - } - } - else if (convar == sdb_joinprivmsg_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsJoinPrivMsgEnabled = false; - } - else - { - g_bIsJoinPrivMsgEnabled = true; - } - } - else if (convar == sdb_chatcolors_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsChatColorsEnabled = false; - } - else - { - g_bIsChatColorsEnabled = true; - } - } - else if (convar == sdb_immunity_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsImmuntyEnabled = false; - } - else - { - g_bIsImmuntyEnabled = true; - } - } - else if (convar == sdb_ubercharge_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsUberChargeEnabled = false; - } - else - { - g_bIsUberChargeEnabled = true; - } - } - else if (convar == sdb_givehealth_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsGiveHealthEnabled = false; - } - else - { - g_bIsGiveHealthEnabled = true; - } - } - else if (convar == sdb_nofalldmg_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsNoFallDmgEnabled = false; - } - else - { - g_bIsNoFallDmgEnabled = true; - } - } - else if (convar == sdb_fastheavy_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsFastHeayEnabled = false; - } - else - { - g_bIsFastHeayEnabled = true; - } - } - else if (convar == sdb_swapteam_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsSwapTeamEnabled = false; - } - else - { - g_bIsSwapTeamEnabled = true; - } - } - else if (convar == sdb_chatcolor) - { - Format(g_sChatColor, sizeof(g_sChatColor), "%s", newValue); - } - else if (convar == sdb_uberlevel) - { - g_fUberLevel = StringToFloat(newValue); - } - else if (convar == sdb_healthcount) - { - g_iHealthCount = StringToInt(newValue); - } - else if (convar == sdb_healthbonus) - { - g_iHealthBonus = StringToInt(newValue); - } - else if (convar == sdb_heavymultiplier) - { - g_fHeavyMultiplier = StringToFloat(newValue); - } -} - -stock LoadUpVariables() -{ - g_bIsEnabled = GetConVarBool(sdb_enabled); - g_bIsJoinSoundEnabled = GetConVarBool(sdb_enabled); - g_bIsJoinPubMsgEnabled = GetConVarBool(sdb_enabled); - g_bIsJoinPrivMsgEnabled = GetConVarBool(sdb_enabled); - g_bIsChatColorsEnabled = GetConVarBool(sdb_enabled); - g_bIsImmuntyEnabled = GetConVarBool(sdb_enabled); - g_bIsUberChargeEnabled = GetConVarBool(sdb_enabled); - g_bIsGiveHealthEnabled = GetConVarBool(sdb_enabled); - g_bIsNoFallDmgEnabled = GetConVarBool(sdb_enabled); - g_bIsFastHeayEnabled = GetConVarBool(sdb_enabled); - g_bIsSwapTeamEnabled = GetConVarBool(sdb_enabled); - GetConVarString(sdb_donationflag, g_sCharDonatorFlag, sizeof(g_sCharDonatorFlag)); - GetConVarString(sdb_soundfile, g_sSoundFile, sizeof(g_sSoundFile)); - GetConVarString(sdb_chatcolor, g_sChatColor, sizeof(g_sChatColor)); - g_bRoundEnd = false; - g_iHealthBonus = GetConVarInt(sdb_healthbonus); - g_iHealthCount = GetConVarInt(sdb_healthcount); - g_fHeavyMultiplier = GetConVarFloat(sdb_heavymultiplier); - g_fUberLevel = GetConVarFloat(sdb_uberlevel); -} - -stock PrepSoundFile() -{ - decl String:buffer[PLATFORM_MAX_PATH]; - PrecacheSound(g_sSoundFile, true); - Format(buffer, sizeof(buffer), "sound/%s", g_sSoundFile); - AddFileToDownloadsTable(buffer); -} - -stock CleanUpPlayer(client) -{ - g_aPlayers[client][bIsDonator] = false; - g_aPlayers[client][bQueue] = false; - g_aPlayers[client][bImmune] = false; - g_aPlayers[client][iNewTeam] = 0; - g_aPlayers[client][iHealthCount] = 0; -} - -stock ProcessRoundEndImmunity(bool:give) -{ - for (new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][bIsDonator]) - { - if (give) - { - SetEntProp(i, Prop_Data, "m_takedamage", 0, 1); - g_aPlayers[i][bImmune] = true; - } - else - { - SetEntProp(i, Prop_Data, "m_takedamage", 2, 1); - g_aPlayers[i][bImmune] = false; - } - } - } -} - -stock FormatMessage(iClient, iTeam, bool:bAlive, String:sChatMsg[], const Sting:sMessage[]) -{ - decl String:sDead[10], - String:sTeam[10], - String:sClientName[64]; - GetClientName(iClient, sClientName, sizeof(sClientName)); - if (iTeam != 0) - Format(sTeam, sizeof(sTeam), "(TEAM) "); - else - Format(sTeam, sizeof(sTeam), ""); - if (bAlive) - Format(sDead, sizeof(sDead), ""); - else - Format(sDead, sizeof(sDead), "*DEAD* "); - if (StrContains(g_sChatColor, "light", false) == -1) - Format(sChatMsg, CHAT_MAX_MESSAGE_LENGTH, "\x01%s%s\x03%s \x01: \x05%s", sDead, sTeam, sClientName, sMessage); - else - Format(sChatMsg, CHAT_MAX_MESSAGE_LENGTH, "\x01%s%s\x03%s \x01: \x04%s", sDead, sTeam, sClientName, sMessage); -} - -stock SayText2(target, author, const String:message[]) -{ - new Handle:hBf; - if (target == 0) - hBf = StartMessageAll("SayText2"); - else - hBf = StartMessageOne("SayText2", target); - if (hBf != INVALID_HANDLE) - { - BfWriteByte(hBf, author); - BfWriteByte(hBf, true); - BfWriteString(hBf, message); - EndMessage(); - } -} - -stock ProcessAdmins() -{ - for (new i = 1; i <= MaxClients; i++) - { - if (SM_IsValidAdmin(i, g_sCharDonatorFlag)) - { - g_aPlayers[i][bDonator] = true; - } - else - { - g_aPlayers[i][bDonator] = false; - } - } -} - -stock ProcessLate() -{ - if (g_bIsEnabled) - { - ProcessAdmins(); - PrepSoundFile(); - if (g_bRoundEnd && g_bIsImmuntyEnabled) - { - ProcessRoundEndImmunity(true); - } - if (!g_bIsImmuntyEnabled) - { - ProcessRoundEndImmunity(false); - } - } - else - { - ProcessRoundEndImmunity(false); - } -} - -public Menu_SwapMode(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, 64); - if (StringToInt(sSelection)) - g_aPlayers[param1][bQueue] = false; - else - g_aPlayers[param1][bQueue] = true; - if (!g_aPlayers[param1][bQueue]) - SM_MovePlayer(param1, g_aPlayers[param1][iNewTeam]); - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -public Menu_SelectPlayer(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[256]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - new iTarget = GetClientOfUserId(StringToInt(sSelection)); - if (g_aPlayers[iTarget][bIsDonator]) - g_aPlayers[iTarget][bIsDonator] = false; - else - g_aPlayers[iTarget][bIsDonator] = true; - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -stock Handle:BuildSwapModeMenu() -{ - new Handle:menu = CreateMenu(Menu_SwapMode); - SetMenuTitle(menu, "Select When to Swap:"); - AddMenuItem(menu, "0", "Instantly (Kills)"); - AddMenuItem(menu, "1", "Queue on next death"); - SetMenuExitBackButton(menu, false); - return menu; -} - -stock Handle:BuildPlayerMenu() -{ - new Handle:menu = CreateMenu(Menu_SelectPlayer); - AddTargetsToMenu(menu, 0, true, false); - SetMenuTitle(menu, "Select A Player:"); - SetMenuExitBackButton(menu, true); - return menu; -} - -public Action:Command_TEST(client, args) -{ - -} \ No newline at end of file diff --git a/Simple Message Suppression/addons/sourcemod/scripting/simple-plugins.sp b/Simple Message Suppression/addons/sourcemod/scripting/simple-plugins.sp deleted file mode 100644 index 4462b41..0000000 --- a/Simple Message Suppression/addons/sourcemod/scripting/simple-plugins.sp +++ /dev/null @@ -1,785 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Plugins -Description: - Core plugin for Simple Plugins project -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#define CORE_PLUGIN_VERSION "1.1.$Rev$" - -#include - -enum e_PlayerInfo -{ - Handle:hForcedTeamPlugin = INVALID_HANDLE, - iForcedTeam = 0, - iBuddy = 0, - bool:bBuddyLocked = false -}; - -new Handle:g_fwdPlayerMoved; -new g_aPlayers[MAXPLAYERS + 1][e_PlayerInfo]; -new bool:g_bTeamsSwitched = false; - -/** -Setting our plugin information. -*/ -public Plugin:myinfo = -{ - name = "Simple Plugins Core Plugin", - author = "Simple Plugins", - description = "Core plugin for Simple Plugins", - version = CORE_PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -}; - -public bool:AskPluginLoad(Handle:myself, bool:late, String:error[], err_max) -{ - - /** - Register natives for other plugins - */ - CreateNative("SM_MovePlayer", Native_SM_MovePlayer); - CreateNative("SM_SetForcedTeam", Native_SM_SetForcedTeam); - CreateNative("SM_GetForcedTeam", Native_SM_GetForcedTeam); - CreateNative("SM_ClearForcedTeam", Native_SM_ClearForcedTeam); - CreateNative("SM_GetForcedPlayer", Native_SM_GetForcedPlayer); - CreateNative("SM_AssignBuddy", Native_SM_AssignBuddy); - CreateNative("SM_GetClientBuddy", Native_SM_GetClientBuddy); - CreateNative("SM_LockBuddy", Native_SM_LockBuddy); - CreateNative("SM_IsBuddyLocked", Native_SM_IsBuddyLocked); - CreateNative("SM_ClearBuddy", Native_SM_ClearBuddy); - CreateNative("SM_IsValidAdmin", Native_SM_IsValidAdmin); - CreateNative("SM_IsValidTeam", Native_SM_IsValidTeam); - RegPluginLibrary("simpleplugins"); - return true; -} - -public OnPluginStart() -{ - - CreateConVar("ssm_core_pl_ver", CORE_PLUGIN_VERSION, "Simple SourceMod Plugins Core Plugin Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - CreateConVar("ssm_core_inc_ver", CORE_INC_VERSION, "Simple SourceMod Plugins Core Include Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook some events to control forced players and check extensions - */ - decl String:sExtError[256]; - LogAction(0, -1, "[SSM] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_team", HookPlayerChangeTeam, EventHookMode_Pre); - switch (g_CurrentMod) - { - case GameType_CSS: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - new iExtStatus = GetExtensionFileStatus("game.cstrike.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SSM] Required extension was not found."); - LogAction(0, -1, "[SSM] Plugin FAILED TO LOAD."); - SetFailState("Required extension was not found."); - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SSM] Required extension is loaded with errors."); - LogAction(0, -1, "[SSM] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SSM] Plugin FAILED TO LOAD."); - SetFailState("Required extension is loaded with errors."); - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SSM] Required extension is loaded."); - } - } - case GameType_TF: - { - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_PostNoCopy); - HookUserMessage(GetUserMessageId("TextMsg"), UserMessageHook_Class, true); - new iExtStatus = GetExtensionFileStatus("game.tf2.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SSM] Required extension was not found."); - LogAction(0, -1, "[SSM] Plugin FAILED TO LOAD."); - SetFailState("Required extension was not found."); - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SSM] Required extension is loaded with errors."); - LogAction(0, -1, "[SSM] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SSM] Plugin FAILED TO LOAD."); - SetFailState("Required extension is loaded with errors."); - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SSM] Required extension is loaded."); - } - } - case GameType_DOD: - { - HookEvent("dod_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_PostNoCopy); - } - default: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - } - } - - /** - Load common translations - */ - LoadTranslations ("common.phrases"); - - /** - Create the global forward - */ - g_fwdPlayerMoved = CreateGlobalForward("SM_OnPlayerMoved", ET_Event, Param_Cell, Param_Cell, Param_Cell); -} - -public OnClientDisconnect(client) -{ - - /** - Cleanup clients/players buddy list - */ - if (!IsFakeClient(client)) - { - SM_ClearBuddy(client, true); - SM_LockBuddy(client, false); - } - SM_ClearForcedTeam(client); -} - -public HookRoundStart(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - See if the teams have been switched - */ - if (g_bTeamsSwitched) - { - - /** - Switch the teams the players are forced to - */ - for (new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][iForcedTeam] != 0) - { - if (g_aPlayers[i][iForcedTeam] == g_aCurrentTeams[Team1]) - { - g_aPlayers[i][iForcedTeam] = g_aCurrentTeams[Team2]; - } - else - { - g_aPlayers[i][iForcedTeam] = g_aCurrentTeams[Team1]; - } - } - } - } -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - g_bTeamsSwitched = false; -} - -public HookPlayerChangeTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get our event variables - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - new iTeam = GetEventInt(event, "team"); - - /** - See if the player is on the wrong team - */ - if (g_aPlayers[iClient][iForcedTeam] != 0 && g_aPlayers[iClient][iForcedTeam] != iTeam) - { - - /** - Move the player back to the forced team - */ - CreateTimer(1.0, Timer_ForcePlayerMove, iClient, TIMER_FLAG_NO_MAPCHANGE); - - /** - If the event was going to be broadcasted, we refire it so it is not broadcasted and stop this one - */ - if (!dontBroadcast) - { - new Handle:hEvent = CreateEvent("player_team"); - SetEventInt(hEvent, "userid", GetEventInt(event, "userid")); - SetEventInt(hEvent, "team", GetEventInt(event, "team")); - SetEventInt(hEvent, "oldteam", GetEventInt(event, "oldteam")); - SetEventBool(hEvent, "disconnect", GetEventBool(event, "disconnect")); - - if (g_CurrentMod == GameType_DOD || g_CurrentMod == GameType_L4D || g_CurrentMod == GameType_TF) - { - new String:sClientName[MAX_NAME_LENGTH + 1]; - GetClientName(client, sClientName, sizeof(sClientName)); - SetEventBool(hEvent, "autoteam", GetEventBool(event, "autoteam")); - SetEventBool(hEvent, "silent", true); - SetEventString(hEvent, "name", sClientName); - FireEvent(hEvent, true); - } - else - { - FireEvent(hEvent, true); - } - return Plugin_Handled; - } - } - return Plugin_Continue; -} - -public Action:UserMessageHook_Class(UserMsg:msg_id, Handle:bf, const players[], playersNum, bool:reliable, bool:init) -{ - new String:sMessage[120]; - BfReadString(bf, sMessage, sizeof(sMessage), true); - if (StrContains(sMessage, "#TF_TeamsSwitched", false) != -1) - { - g_bTeamsSwitched = true; - } - return Plugin_Continue; -} - -public Native_SM_MovePlayer(Handle:plugin, numParams) -{ - - /** - Get and check the client and team - */ - new iClient = GetNativeCell(1); - new iTeam = GetNativeCell(2); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (iTeam != g_aCurrentTeams[Spectator] && iTeam != g_aCurrentTeams[Team1] && iTeam != g_aCurrentTeams[Team2]) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid team %d", iTeam); - } - - MovePlayer(iClient, iTeam); - if (!IsClientObserver(iClient)) - { - RespawnPlayer(iClient); - } - - new fResult; - - Call_StartForward(g_fwdPlayerMoved); - Call_PushCell(plugin); - Call_PushCell(iClient); - Call_PushCell(iTeam); - Call_Finish(fResult); - - if (fResult != SP_ERROR_NONE) - { - return ThrowNativeError(fResult, "Forward failed"); - } - - return fResult; -} - -public Native_SM_SetForcedTeam(Handle:plugin, numParams) -{ - - /** - Get and check the client and team - */ - new iClient = GetNativeCell(1); - new iTeam = GetNativeCell(2); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (iTeam != g_aCurrentTeams[Spectator] && iTeam != g_aCurrentTeams[Team1] && iTeam != g_aCurrentTeams[Team2] && iTeam != g_aCurrentTeams[Unknown]) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid team %d", iTeam); - } - - new bool:bOverRide = GetNativeCell(3) ? true : false; - - if (!bOverRide && g_aPlayers[iClient][hForcedTeamPlugin] != INVALID_HANDLE && plugin != g_aPlayers[iClient][hForcedTeamPlugin]) - { - return false; - } - - g_aPlayers[iClient][hForcedTeamPlugin] = plugin; - g_aPlayers[iClient][iForcedTeam] = iTeam; - return true; -} - -public Native_SM_GetForcedTeam(Handle:plugin, numParams) -{ - - /** - Get and check the client - */ - new iClient = GetNativeCell(1); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - - /** - Get and set the plugin if they want it - */ - new Handle:hPlugin = GetNativeCell(2); - if (hPlugin != INVALID_HANDLE) - { - SetNativeCellRef(2, g_aPlayers[iClient][hForcedTeamPlugin]); - } - - /** - Return the forced team, this could be 0 - */ - return g_aPlayers[iClient][iForcedTeam]; -} - -public Native_SM_ClearForcedTeam(Handle:plugin, numParams) -{ - - /** - Get and check the client and team - */ - new iClient = GetNativeCell(1); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - - g_aPlayers[iClient][hForcedTeamPlugin] = INVALID_HANDLE; - g_aPlayers[iClient][iForcedTeam] = 0; - - return true; -} - -public Native_SM_GetForcedPlayer(Handle:plugin, numParams) -{ - - /** - Get and check the team - */ - new iTeam = GetNativeCell(1); - if (iTeam != g_aCurrentTeams[Spectator] && iTeam != g_aCurrentTeams[Team1] && iTeam != g_aCurrentTeams[Team2]) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid team %d", iTeam); - } - - /** - Start a loop to check for a player on the wrong team - Also make sure the plugin that set the forced team is the plugin that asked - */ - new iPlayer = 0; - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientInGame(i) - && GetClientTeam(i) != g_aPlayers[i][iForcedTeam] - && g_aPlayers[i][iForcedTeam] == iTeam - && g_aPlayers[i][hForcedTeamPlugin] == plugin) - { - iPlayer = i; - break; - } - } - - /** - Return the player we found, this could be 0 - */ - return iPlayer; -} - -public Native_SM_AssignBuddy(Handle:plugin, numParams) -{ - - /** - Get and check the client and player - */ - new iClient = GetNativeCell(1); - new iPlayer = GetNativeCell(2); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (iPlayer < 0 || iPlayer > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid player index (%d)", iPlayer); - } - if (!IsClientConnected(iPlayer)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Player %d is not connected", iPlayer); - } - if (!IsClientInGame(iPlayer)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Player %d is not in the game", iClient); - } - if (IsFakeClient(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Bots are not supported"); - } - - /** - See if we can override his setting - */ - new bool:bOverRide = GetNativeCell(3) ? true : false; - if (!bOverRide) - { - - /** - We can't override, so check if they are locked - */ - if (g_aPlayers[iClient][bBuddyLocked] || g_aPlayers[iPlayer][bBuddyLocked]) - { - - /** - We detected at least 1 lock, so we bug out - */ - return false; - } - } - - /** - Ready to set the buddies - */ - g_aPlayers[iClient][iBuddy] = iPlayer; - g_aPlayers[iPlayer][iBuddy] = iClient; - return true; -} - -public Native_SM_GetClientBuddy(Handle:plugin, numParams) -{ - - /** - Get and check the client - */ - new iClient = GetNativeCell(1); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (IsFakeClient(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Bots are not supported"); - } - - /** - Return the players buddy, this could be 0 - */ - return g_aPlayers[iClient][iBuddy]; -} - -public Native_SM_LockBuddy(Handle:plugin, numParams) -{ - - /** - Get and check the client - */ - new iClient = GetNativeCell(1); - new bool:bSetting = GetNativeCell(2) ? true : false; - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (IsFakeClient(iClient)) - { - return ThrowNativeError(SP_ERROR_NATIVE, "Bots are not supported"); - } - - g_aPlayers[iClient][bBuddyLocked] = bSetting; - return true; -} - -public Native_SM_IsBuddyLocked(Handle:plugin, numParams) -{ - - /** - Get and check the client - */ - new iClient = GetNativeCell(1); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (IsFakeClient(iClient)) - { - return ThrowNativeError(SP_ERROR_NATIVE, "Bots are not supported"); - } - - return g_aPlayers[iClient][bBuddyLocked]; -} - -public Native_SM_ClearBuddy(Handle:plugin, numParams) -{ - - /** - Get and check the client - */ - new iClient = GetNativeCell(1); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_NATIVE, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_NATIVE, "Client (%d) is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (IsFakeClient(iClient)) - { - return ThrowNativeError(SP_ERROR_NATIVE, "Bots are not supported"); - } - - /** - Get the clients buddy and see if we can override his setting - */ - new bool:bOverRide = GetNativeCell(2) ? true : false; - new iPlayer = g_aPlayers[iClient][iBuddy]; - - /** - There is no buddy, we don't care about anything else so bug out - */ - if (iPlayer == 0) - { - return true; - } - - /** - We determined he had a buddy, check the override setting - */ - if (!bOverRide) - { - - /** - We can't override, so check if they are locked - */ - if (g_aPlayers[iClient][bBuddyLocked] || g_aPlayers[iPlayer][bBuddyLocked]) - { - - /** - We detected at least 1 lock, so we bug out - */ - return false; - } - } - - /** - Ready to clear the buddies - */ - g_aPlayers[iClient][iBuddy] = 0; - g_aPlayers[iPlayer][iBuddy] = 0; - return true; -} - -public Native_SM_IsValidTeam(Handle:plugin, numParams) -{ - - /** - Get the team - */ - new iTeam = GetNativeCell(1); - - /** - Check the team - */ - if (iTeam == g_aCurrentTeams[Spectator] || iTeam == g_aCurrentTeams[Team1] || iTeam == g_aCurrentTeams[Team2]) - { - return true; - } - return false; -} - -public Native_SM_IsValidAdmin(Handle:plugin, numParams) -{ - /** - Get the client and flags - */ - new iClient = GetNativeCell(1); - decl String:sFlags[15]; - GetNativeString(2, sFlags, sizeof(sFlags)); - new ibFlags = ReadFlagString(sFlags); - - /** - Check the flags - */ - if ((GetUserFlagBits(iClient) & ibFlags) == ibFlags) - { - return true; - } - if (GetUserFlagBits(iClient) & ADMFLAG_ROOT) - { - return true; - } - return false; -} - -public Action:Timer_ForcePlayerMove(Handle:timer, any:iClient) -{ - - MovePlayer(iClient, g_aPlayers[iClient][iForcedTeam]); - - if (g_aPlayers[iClient][iForcedTeam] != g_aCurrentTeams[Spectator]) - { - RespawnPlayer(iClient); - } - - PrintToChat(iClient, "\x01\x04----------------------------------"); - PrintToChat(iClient, "\x01\x04You have been forced to this team."); - PrintToChat(iClient, "\x01\x04----------------------------------"); - - return Plugin_Handled; -} - -stock MovePlayer(iClient, iTeam) -{ - - /** - Change the client's team based on the mod - */ - switch (g_CurrentMod) - { - case GameType_CSS: - { - CS_SwitchTeam(iClient, iTeam); - } - default: - { - ChangeClientTeam(iClient, iTeam); - } - } -} - -stock RespawnPlayer(iClient) -{ - - /** - Respawn the client based on the mod - */ - switch (g_CurrentMod) - { - case GameType_CSS: - { - CS_RespawnPlayer(iClient); - } - case GameType_TF: - { - TF2_RespawnPlayer(iClient); - } - case GameType_INS: - { - FakeClientCommand(iClient, "kill"); - } - default: - { - // - } - } -} diff --git a/Simple Message Suppression/addons/sourcemod/scripting/simple-roundimmunity.sp b/Simple Message Suppression/addons/sourcemod/scripting/simple-roundimmunity.sp deleted file mode 100644 index 5f0bca3..0000000 --- a/Simple Message Suppression/addons/sourcemod/scripting/simple-roundimmunity.sp +++ /dev/null @@ -1,947 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Round Immunity -Description: - Gives admins immunity during certain rounds -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or any later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#pragma semicolon 1 -#include -#include -#undef REQUIRE_EXTENSIONS -#undef AUTOLOAD_EXTENSIONS -#include -#include -#define REQUIRE_EXTENSIONS -#define AUTOLOAD_EXTENSIONS - -#define PLUGIN_VERSION "1.1.$Rev$" -#define SPECTATOR 1 -#define TEAM_RED 2 -#define TEAM_BLUE 3 - -#define COLOR_GREEN 0 -#define COLOR_BLACK 1 -#define COLOR_RED 2 -#define COLOR_BLUE 3 -#define COLOR_TEAM 4 -#define COLOR_RAINBOW 5 -#define COLOR_NONE 6 - -#define PLAYERCOND_SLOWED (1<<0) //1 -#define PLAYERCOND_ZOOMED (1<<1) //2 -#define PLAYERCOND_DISGUISING (1<<2) //4 -#define PLAYERCOND_DISGUISED (1<<3) //8 -#define PLAYERCOND_SPYCLOAK (1<<4) //16 -#define PLAYERCOND_UBERED (1<<5) //32 -#define PLAYERCOND_TELEPORTTRAIL (1<<6) //64 -#define PLAYERCOND_TAUNT (1<<7) //128 -// (1<<8) //256 -// (1<<9) //512 -#define PLAYERCOND_TELEPORTFLASH (1<<10) //1024 -#define PLAYERCOND_KRUBER (1<<11) //2048 -// (1<<12) //4096 -// (1<<13) //8192 -#define PLAYERCOND_BONKED (1<<14) //16384 (blame Neph if it doesn't work) -#define PLAYERCOND_BONKEDORDRINKSLOWDOWN (1<<15) //32768 -#define PLAYERCOND_HEALING (1<<16) //65536 -#define PLAYERCOND_BURNING (1<<17) //131072 -#define PLAYERCOND_FULLYCHARGEDBYMEDIC (1<<18) //262144 - -enum e_Cookies -{ - bEnabled, - iColor, - iMode -}; - -enum e_ColorNames -{ - Green, - Black, - Red, - Blue -}; - -enum e_ColorValues -{ - iRed, - iGreen, - iBlue -}; - -enum e_PlayerData -{ - Handle:hGodModeTimer, - Handle:hColorTimer, - bool:bIsAdmin, - bool:bIsImmune, - iCycleColor -}; - -/** - Global convar handles - */ -new Handle:sri_charadminflag = INVALID_HANDLE; -new Handle:sri_enabled = INVALID_HANDLE; -new Handle:sri_cookie_enabled = INVALID_HANDLE; -new Handle:sri_cookie_color = INVALID_HANDLE; -new Handle:sri_cookie_mode = INVALID_HANDLE; - -/** - Player arrays - */ -new g_aPlayers[MAXPLAYERS + 1][e_PlayerData]; -new g_aClientCookies[MAXPLAYERS + 1][e_Cookies]; - -/** - Global bools - */ -new bool:g_bLoadedLate = false; -new bool:g_bIsEnabled = true; -new bool:g_bRoundEnd = false; -new bool:g_bUseDukehacks = false; -new bool:g_bUseClientprefs = false; - -/** - Global strings/integers/floats - */ -new String:g_sCharAdminFlag[32]; -new g_iColors[e_ColorNames][e_ColorValues]; -new g_iClassMaxHealth[TFClassType] = {0, 125, 125, 200, 175, 150, 300, 175, 125, 125}; - -public Plugin:myinfo = -{ - name = "Simple Round Immunity", - author = "Simple Plugins", - description = "Gives admins immunity during certain rounds", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -} - -bool:AskPluginLoad(Handle:myself, bool:late, String:error[], err_max) -{ - g_bLoadedLate = late; - return true; -} - -public OnPluginStart() -{ - - /** - Create console variables - */ - CreateConVar("sri_version", PLUGIN_VERSION, "Simple Round Immunity", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - sri_enabled = CreateConVar("sri_enabled", "1", "Enable/Disable Admin immunity during certain round."); - sri_charadminflag = CreateConVar("sri_charadminflag", "a", "Admin flag to use for immunity (only one). Must be a in char format."); - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook some events and check extensions - */ - decl String:sExtError[256]; - LogAction(0, -1, "[SRI] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_spawn", HookPlayerSpawn, EventHookMode_Post); - HookEvent("player_hurt", HookPlayerHurt, EventHookMode_Pre); - switch (g_CurrentMod) - { - case GameType_CSS: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - new iExtStatus = GetExtensionFileStatus("game.cstrike.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SRI] Required extension was not found."); - LogAction(0, -1, "[SRI] Plugin FAILED TO LOAD."); - SetFailState("Required extension was not found."); - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SRI] Required extension is loaded with errors."); - LogAction(0, -1, "[SRI] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SRI] Plugin FAILED TO LOAD."); - SetFailState("Required extension is loaded with errors."); - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SRI] Required css extension is loaded."); - } - } - case GameType_TF: - { - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_PostNoCopy); - HookUserMessage(GetUserMessageId("TextMsg"), UserMessageHook_Class, true); - new iExtStatus = GetExtensionFileStatus("game.tf2.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SRI] Required extension was not found."); - LogAction(0, -1, "[SRI] Plugin FAILED TO LOAD."); - SetFailState("Required extension was not found."); - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SRI] Required extension is loaded with errors."); - LogAction(0, -1, "[SRI] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SRI] Plugin FAILED TO LOAD."); - SetFailState("Required extension is loaded with errors."); - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SRI] Required tf2 extension is loaded."); - } - iExtStatus = GetExtensionFileStatus("dukehacks.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SRI] Dukehacks extension was not found."); - LogAction(0, -1, "[SRI] Plugin continued to load, but that feature will not be used."); - g_bUseDukehacks = false; - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SRI] Dukehacks extension is loaded with errors."); - LogAction(0, -1, "[SRI] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SRI] Plugin continued to load, but that feature will not be used."); - g_bUseDukehacks = false; - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SRI] Dukehacks extension is loaded and will be used."); - g_bUseDukehacks = true; - dhAddClientHook(CHK_TakeDamage, Hacks_TakeDamageHook); - } - } - case GameType_DOD: - { - HookEvent("dod_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_PostNoCopy); - } - default: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - } - } - /** - Now lets check for client prefs extension - */ - new iExtStatus = GetExtensionFileStatus("clientprefs.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SRI] Client Preferences extension was not found."); - LogAction(0, -1, "[SRI] Plugin continued to load, but that feature will not be used."); - g_bUseClientprefs = false; - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SRI] Client Preferences extension is loaded with errors."); - LogAction(0, -1, "[SRI] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SRI] Plugin continued to load, but that feature will not be used."); - g_bUseClientprefs = false; - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SRI] Client Preferences extension is loaded, checking database."); - if (!SQL_CheckConfig(clientprefs)) - { - LogAction(0, -1, "[SRI] No 'clientprefs' database found. Check your database.cfg file."); - LogAction(0, -1, "[SRI] Plugin continued to load, but Client Preferences will not be used."); - g_bUseClientprefs = false; - } - g_bUseClientprefs = true; - - /** - Deal with client cookies - */ - sri_cookie_enabled = RegClientCookie("bri_client_enabled", "Enable/Disable your immunity during the bonus round.", CookieAccess_Public); - sri_cookie_color = RegClientCookie("bri_client_color", "Color to render when immune.", CookieAccess_Public); - sri_cookie_mode = RegClientCookie("bri_client_mode", "God mode to select", CookieAccess_Public); - SetCookieMenuItem(CookieMenu_TopMenu, sri_cookie_enabled, "Bonus Round Immunity"); - } - - HookConVarChange(sri_enabled, EnabledChanged); - - RegAdminCmd("sm_immunity", Command_Immunity, ADMFLAG_ROOT, "sm_immunity: Gives you immunity"); - - LoadColors(); - - AutoExecConfig(true, "plugin.simpleroundimmunity"); -} - -public OnAllPluginsLoaded() -{ - //something - // need to deal with the unloading of dukehacks, clientprefs, and simpleplugins - // should move hooking the client prefs cookies to a function to make sure they are done post plugin start if ext is loaded late -} - -public OnLibraryRemoved(const String:name[]) -{ - //something - // need to deal with the loading of dukehacks, clientprefs, and simpleplugins -} - -public OnConfigsExecuted() -{ - GetConVarString(sri_charadminflag, g_sCharAdminFlag, sizeof(g_sCharAdminFlag)); - g_bIsEnabled = GetConVarBool(sri_enabled); - g_bRoundEnd = false; -} - -/** - Client events - */ - -public OnClientPostAdminCheck(client) -{ - if (SM_IsValidAdmin(client, g_sCharAdminFlag)) - g_aPlayers[client][bIsAdmin] = true; - else - g_aPlayers[client][bIsAdmin] = false; -} - -public OnClientCookiesCached(client) -{ - decl String:sEnabled[2], String:sColor[4], String:sMode[2]; - GetClientCookie(client, sri_cookie_enabled, sEnabled, sizeof(sEnabled)); - GetClientCookie(client, sri_cookie_color, sColor, sizeof(sColor)); - GetClientCookie(client, sri_cookie_mode, sMode, sizeof(sMode)); - g_aClientCookies[client][bEnabled] = StringToInt(sEnabled); - g_aClientCookies[client][iColor] = StringToInt(sColor); - g_aClientCookies[client][iMode] = StringToInt(sMode); -} - -public OnClientDisconnect(client) -{ - CleanUp(client); -} - -/** - Commands - */ - -public Action:Command_Immunity(client, args) -{ - if (g_aPlayers[client][IsImmune]) - { - DisableImmunity(client); - } - else - { - EnableImmunity(client); - } - return Plugin_Handled; -} - -/** - Event hooks - */ - -public Action:Hacks_TakeDamageHook(client, attacker, inflictor, Float:damage, &Float:multiplier, damagetype) -{ - if (attacker == 0 || attacker >= MaxClients) - { - return Plugin_Continue; - } - if (g_aPlayers[client][IsImmune]) - { - new TFClassType:PlayerClass = TF2_GetPlayerClass(attacker); - if (PlayerClass == TFClass_Spy) - { - multiplier *= 0.0; - return Plugin_Changed; - } - } - return Plugin_Continue; -} - -public HookRoundStart(Handle:event, const String:name[], bool:dontBroadcast) -{ - g_bRoundEnd = false; - if (g_bIsEnabled) - { - for (new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][IsImmune]) - { - DisableImmunity(i); - } - } - } -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - g_bRoundEnd = true; - if (g_bIsEnabled) - { - for (new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][bIsAdmin]) - { - EnableImmunity(i); - } - } - } -} - -public HookPlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast) -{ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - if (g_bIsEnabled && g_aPlayers[iClient][bIsAdmin] && g_bRoundEnd) - { - EnableImmunity(iClient); - } -} - -public Action:HookPlayerHurt(Handle:event, const String:name[], bool:dontBroadcast) -{ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - if (g_aPlayers[iClient][IsImmune]) - { - SetEntityHealth(iClient, 2000); - return Plugin_Continue; - } - return Plugin_Continue; -} - -/** - Cookie menus - */ - -public CookieMenu_TopMenu(client, CookieMenuAction:action, any:info, String:buffer[], maxlen) -{ - if (action == CookieMenuAction_DisplayOption) - { - //don't think we need to do anything - } - else - { - new Handle:hMenu = CreateMenu(Menu_CookieSettings); - SetMenuTitle(hMenu, "Options (Current Setting)"); - if (g_aClientCookies[client][bEnabled]) - { - AddMenuItem(hMenu, "enable", "Enabled/Disable (Enabled)"); - } - else - { - AddMenuItem(hMenu, "enable", "Enabled/Disable (Disabled)"); - } - if (g_aClientCookies[client][iMode]) - { - AddMenuItem(hMenu, "mode", "Immunity Mode Setting (God Mode)"); - } - else - { - AddMenuItem(hMenu, "mode", "Immunity Mode Setting (Health)"); - } - switch (g_aClientCookies[client][iColor]) - { - case COLOR_GREEN: - { - AddMenuItem(hMenu, "color", "Color (Green)"); - } - case COLOR_BLACK: - { - AddMenuItem(hMenu, "color", "Color (Black)"); - } - case COLOR_RED: - { - AddMenuItem(hMenu, "color", "Color (Red)"); - } - case COLOR_BLUE: - { - AddMenuItem(hMenu, "color", "Color (Blue)"); - } - case COLOR_TEAM: - { - AddMenuItem(hMenu, "color", "Color (Team)"); - } - case COLOR_RAINBOW: - { - AddMenuItem(hMenu, "color", "Color (Rainbow)"); - } - case COLOR_NONE: - { - AddMenuItem(hMenu, "color", "Color (None)"); - } - } - SetMenuExitBackButton(hMenu, true); - DisplayMenu(hMenu, client, MENU_TIME_FOREVER); - } -} - -public Menu_CookieSettings(Handle:menu, MenuAction:action, param1, param2) -{ - new client = param1; - if (action == MenuAction_Select) - { - new String:sSelection[24]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "enable", false)) - { - new Handle:hMenu = CreateMenu(Menu_CookieSettingsEnable); - SetMenuTitle(hMenu, "Enable/Disable Round End Immunity"); - - if (g_aClientCookies[client][bEnabled]) - { - AddMenuItem(hMenu, "enable", "Enable (Set)"); - AddMenuItem(hMenu, "disable", "Disable"); - } - else - { - AddMenuItem(hMenu, "enable", "Enabled"); - AddMenuItem(hMenu, "disable", "Disable (Set)"); - } - - SetMenuExitBackButton(hMenu, true); - DisplayMenu(hMenu, client, MENU_TIME_FOREVER); - } - else if (StrEqual(sSelection, "mode", false)) - { - new Handle:hMenu = CreateMenu(Menu_CookieSettingsMode); - SetMenuTitle(hMenu, "Set Immunity Mode"); - - if (g_aClientCookies[client][iMode]) - { - AddMenuItem(hMenu, "god", "God Mode (Set)"); - AddMenuItem(hMenu, "health", "Health"); - } - else - { - AddMenuItem(hMenu, "god", "God Mode"); - AddMenuItem(hMenu, "health", "Health (Set)"); - } - - SetMenuExitBackButton(hMenu, true); - DisplayMenu(hMenu, client, MENU_TIME_FOREVER); - } - else - { - new Handle:hMenu = CreateMenu(Menu_CookieSettingsColors); - SetMenuTitle(hMenu, "Select Immunity Color"); - switch (g_aClientCookies[client][iColor]) - { - case COLOR_GREEN: - { - AddMenuItem(hMenu, "Green", "Green (Set)"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_BLACK: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black (Set)"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_RED: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red (Set)"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_BLUE: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue (Set)"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_TEAM: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color (Set)"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_RAINBOW: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow (Set)"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_NONE: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None (Set)"); - } - } - SetMenuExitBackButton(hMenu, true); - DisplayMenu(hMenu, client, MENU_TIME_FOREVER); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - ShowCookieMenu(client); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } -} - -public Menu_CookieSettingsEnable(Handle:menu, MenuAction:action, param1, param2) -{ - new client = param1; - if (action == MenuAction_Select) - { - new String:sSelection[24]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "enable", false)) - { - SetClientCookie(client, sri_cookie_enabled, "1"); - g_aClientCookies[client][bEnabled] = 1; - PrintToChat(client, "[SM] Bonus Round Immunity is ENABLED"); - } - else - { - SetClientCookie(client, sri_cookie_enabled, "0"); - g_aClientCookies[client][bEnabled] = 0; - PrintToChat(client, "[SM] Bonus Round Immunity is DISABLED"); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - ShowCookieMenu(client); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } -} - -public Menu_CookieSettingsColors(Handle:menu, MenuAction:action, param1, param2) -{ - new client = param1; - if (action == MenuAction_Select) - { - new String:sSelection[24]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "Green", false)) - { - SetClientCookie(client, sri_cookie_color, "0"); - g_aClientCookies[client][iColor] = COLOR_GREEN; - PrintToChat(client, "[SM] Bonus Round Immunity color set to GREEN"); - } - else if (StrEqual(sSelection, "Black", false)) - { - SetClientCookie(client, sri_cookie_color, "1"); - g_aClientCookies[client][iColor] = COLOR_BLACK; - PrintToChat(client, "[SM] Bonus Round Immunity color set to BLACK"); - } - else if (StrEqual(sSelection, "Red", false)) - { - SetClientCookie(client, sri_cookie_color, "2"); - g_aClientCookies[client][iColor] = COLOR_RED; - PrintToChat(client, "[SM] Bonus Round Immunity color set to RED"); - } - else if (StrEqual(sSelection, "Blue", false)) - { - SetClientCookie(client, sri_cookie_color, "3"); - g_aClientCookies[client][iColor] = COLOR_BLUE; - PrintToChat(client, "[SM] Bonus Round Immunity color set to BLUE"); - } - else if (StrEqual(sSelection, "Team", false)) - { - SetClientCookie(client, sri_cookie_color, "4"); - g_aClientCookies[client][iColor] = COLOR_TEAM; - PrintToChat(client, "[SM] Bonus Round Immunity color set to TEAM COLOR"); - } - else if (StrEqual(sSelection, "Rain", false)) - { - SetClientCookie(client, sri_cookie_color, "5"); - g_aClientCookies[client][iColor] = COLOR_RAINBOW; - PrintToChat(client, "[SM] Bonus Round Immunity color set to RAINBOW"); - } - else if (StrEqual(sSelection, "None", false)) - { - SetClientCookie(client, sri_cookie_color, "6"); - g_aClientCookies[client][iColor] = COLOR_NONE; - PrintToChat(client, "[SM] Bonus Round Immunity color set to NONE"); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - ShowCookieMenu(client); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } -} - -public Menu_CookieSettingsMode(Handle:menu, MenuAction:action, param1, param2) -{ - new client = param1; - if (action == MenuAction_Select) - { - new String:sSelection[24]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "god", false)) - { - SetClientCookie(client, sri_cookie_mode, "1"); - g_aClientCookies[client][iMode] = 1; - PrintToChat(client, "[SM] Bonus Round Immunity set to GOD MODE"); - } - else - { - SetClientCookie(client, sri_cookie_mode, "0"); - g_aClientCookies[client][iMode] = 0; - PrintToChat(client, "[SM] Bonus Round Immunity set to HEALTH BONUS"); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - ShowCookieMenu(client); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } -} - -/** -Timer functions - */ - -public Action:Timer_ChangeColor(Handle:timer, any:client) -{ - if (g_aPlayers[client][CycleColor]++ == 3) - { - g_aPlayers[client][CycleColor] = 0; - } - SetEntityRenderMode(client, RENDER_TRANSCOLOR); - SetEntityRenderColor(client, g_iColors[g_aPlayers[client][CycleColor]][iRed], g_iColors[g_aPlayers[client][CycleColor]][iGreen], g_iColors[g_aPlayers[client][CycleColor]][iBlue], 255); - return Plugin_Continue; -} - -public Action:Timer_UndoGodMode(Handle:timer, any:client) -{ - if (IsClientInGame(client)) - { - SetEntProp(client, Prop_Data, "m_takedamage", 2, 1); - } - g_aPlayers[iClient][hGodModeTimer] = INVALID_HANDLE; - return Plugin_Handled; -} - -/** -Stock functions . - */ - -stock CleanUp(iClient) -{ - g_aPlayers[iClient][bIsAdmin] = false; - DisableImmunity(iClient); -} - -stock EnableImmunity(iClient) -{ - SetEntityRenderMode(iClient, RENDER_TRANSCOLOR); - switch (g_aClientCookies[iClient][iColor]) - { - case COLOR_TEAM: - { - new iTeam = GetClientTeam(iClient); - SetEntityRenderColor(iClient, g_iColors[e_ColorNames:iTeam][iRed], g_iColors[e_ColorNames:iTeam][iGreen], g_iColors[e_ColorNames:iTeam][iBlue], 255); - } - case COLOR_RAINBOW: - { - if (g_aPlayers[iClient][hColorTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[iClient][hColorTimer]); - g_aPlayers[iClient][hColorTimer] = INVALID_HANDLE; - } - g_aPlayers[iClient][hColorTimer] = CreateTimer(0.2, Timer_ChangeColor, iClient, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); - } - case COLOR_NONE: - { - //We dont have to set a color - } - default: - { - SetEntityRenderColor(iClient, g_iColors[e_ColorNames:g_aClientCookies[iClient][iColor]][iRed], g_iColors[e_ColorNames:g_aClientCookies[iClient][iColor]][iGreen], g_iColors[e_ColorNames:g_aClientCookies[iClient][iColor]][iBlue], 255); - } - } - SetEntityHealth(iClient, 2000); - SetEntProp(iClient, Prop_Data, "m_takedamage", 0, 1); - g_aPlayers[iClient][hGodModeTimer] = CreateTimer(2.0, Timer_UndoGodMode, iClient); - g_aPlayers[iClient][IsImmune] = true; -} - -stock DisableImmunity(iClient) -{ - if (g_aPlayers[iClient][hGodModeTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[iClient][hGodModeTimer]); - g_aPlayers[iClient][hGodModeTimer] = INVALID_HANDLE; - } - if (g_aPlayers[iClient][hColorTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[iClient][hColorTimer]); - g_aPlayers[iClient][hColorTimer] = INVALID_HANDLE; - } - if (IsClientInGame(iClient)) - { - SetEntityRenderMode(iClient, RENDER_TRANSCOLOR); - SetEntityRenderColor(iClient, 255, 255, 255, 255); - new TFClassType:PlayerClass = TF2_GetPlayerClass(iClient); - new iMaxHealth = g_iClassMaxHealth[PlayerClass]; - SetEntityHealth(iClient, iMaxHealth); - } - g_aPlayers[iClient][CycleColor] = 0; - g_aPlayers[iClient][IsImmune] = false; -} - -stock LoadColors() -{ - g_iColors[Green][iRed] = 0; - g_iColors[Green][iGreen] = 255; - g_iColors[Green][iBlue] = 0; - - g_iColors[Black][iRed] = 10; - g_iColors[Black][iGreen] = 10; - g_iColors[Black][iBlue] = 0; - - g_iColors[Red][iRed] = 255; - g_iColors[Red][iGreen] = 0; - g_iColors[Red][iBlue] = 0; - - g_iColors[Blue][iRed] = 0; - g_iColors[Blue][iGreen] = 0; - g_iColors[Blue][iBlue] = 255; -} - -stock TF2_AddCond(client, cond) -{ - new Handle:cvar = FindConVar("sv_cheats"), bool:enabled = GetConVarBool(cvar), flags = GetConVarFlags(cvar); - if(!enabled) - { - SetConVarFlags(cvar, flags^FCVAR_NOTIFY); - SetConVarBool(cvar, true); - } - FakeClientCommand(client, "addcond %i", cond); - if(!enabled) - { - SetConVarBool(cvar, false); - SetConVarFlags(cvar, flags); - } -} - -stock TF2_RemoveCond(client, cond) -{ - new Handle:cvar = FindConVar("sv_cheats"), bool:enabled = GetConVarBool(cvar), flags = GetConVarFlags(cvar); - if(!enabled) - { - SetConVarFlags(cvar, flags^FCVAR_NOTIFY); - SetConVarBool(cvar, true); - } - FakeClientCommand(client, "removecond %i", cond); - if(!enabled) - { - SetConVarBool(cvar, false); - SetConVarFlags(cvar, flags); - } -} - -/** -Enabled hook - */ - -public EnabledChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (StringToInt(newValue) == 0) - { - UnhookEvent("player_spawn", HookPlayerSpawn, EventHookMode_Post); - UnhookEvent("teamplay_round_start", HookRoundStart, EventHookMode_Post); - UnhookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - for (new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][bIsAdmin] && g_aPlayers[i][IsImmune]) - { - DisableImmunity(i); - } - } - g_bIsEnabled = false; - } - else - { - HookEvent("player_spawn", HookPlayerSpawn, EventHookMode_Post); - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_Post); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - g_bIsEnabled = true; - } -} diff --git a/Simple Message Suppression/addons/sourcemod/scripting/simple-spectate.sp b/Simple Message Suppression/addons/sourcemod/scripting/simple-spectate.sp deleted file mode 100644 index 4108f8f..0000000 --- a/Simple Message Suppression/addons/sourcemod/scripting/simple-spectate.sp +++ /dev/null @@ -1,2022 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Spectate -Description: - Spectate a player and follow them through death. -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include -#undef REQUIRE_EXTENSIONS -#undef AUTOLOAD_EXTENSIONS -#tryinclude -#define AUTOLOAD_EXTENSIONS -#define REQUIRE_EXTENSIONS - -#define PLUGIN_VERSION "1.2.1.$Rev$" - -#define SPECMODE_NONE 0 -#define SPECMODE_FIRSTPERSON 4 -#define SPECMODE_3RDPERSON 5 -#define SPECMODE_FREELOOK 6 -#define SPECMODE_CSS_FIRSTPERSON 3 -#define SPECMODE_CSS_3RDPERSON 4 -#define SPECMODE_CSS_FREELOOK 5 - -enum e_CvarHandles -{ - Handle:hHudMode, - Handle:hMenuType, - Handle:hRestrictHud, - Handle:hBan, - Handle:hBanPerm, - Handle:hBeacon, - Handle:hBlind, - Handle:hCheater, - Handle:hDrug, - Handle:hFreeze, - Handle:hFreezeBomb, - Handle:hKick, - Handle:hSlap, - Handle:hSlay, - Handle:hTimeBomb -}; - -enum e_CvarSettings -{ - bool:bHudMode, - bool:bMenuType, - bool:bRestrictHud, - bool:bBan, - bool:bBanPerm, - bool:bBeacon, - bool:bBlind, - bool:bCheater, - bool:bDrug, - bool:bFreeze, - bool:bFreezebomb, - bool:bKick, - bool:bSlap, - bool:bSlay, - bool:bTimeBomb -}; - -enum e_PluginSettings -{ - bool:bUseSteamBans, - bool:bUseSourceBans, - bool:bUseMySQLBans, - bool:bCanHUD, - bool:bUseDukehacks -}; - -enum e_Menus -{ - Handle:hSelectPlayer, - Handle:hBanTime, - Handle:hReason -}; - -enum e_Punishments -{ - Punish_None, - Punish_Ban, - Punish_Beacon, - Punish_Blind, - Punish_Cheater, - Punish_Drug, - Punish_Freeze, - Punish_FreezeBomb, - Punish_Kick, - Punish_Slap, - Punish_Slay, - Punish_TimeBomb -}; - -enum e_PlayerData -{ - bool:bIsDisplayingHud, - bool:bIsFlaggedCheater, - Handle:hHudTimer, - Handle:hTargetTimer, - iTargetIndex, - e_Punishments:TargetPunishment, - iBanTime -}; - -new Handle:sm_spectate_adminflag = INVALID_HANDLE; -new Handle:g_hAdminMenu = INVALID_HANDLE; -new Handle:g_hHud = INVALID_HANDLE; -new Handle:g_aPluginCvar[e_CvarHandles]; -new g_aPluginCvarSettings[e_CvarSettings]; -new g_aPluginSettings[e_PluginSettings]; -new g_aMenus[e_Menus]; -new g_aPlayers[MAXPLAYERS + 1][e_PlayerData]; -new String:g_sAdminFlags[16]; -new String:g_sPunishments[e_Punishments][15] = { "None", "Ban", "Beacon", "Blind", "Cheater", "Drug", "Freeze", "FreezeBomb", "Kick", "Slap", "Slay", "TimeBomb" }; - -public Plugin:myinfo = -{ - name = "Simple Spectate", - author = "Simple Plugins", - description = "Spectate a player and follow them through death.", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -}; - -/** -Sourcemod callbacks -*/ -public OnPluginStart() -{ - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook the game events - */ - LogAction(0, -1, "[SSPEC] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_team", HookPlayerChangeTeam, EventHookMode_Pre); - - /** - Need to create all of our console variables. - */ - CreateConVar("sm_spectate_version", PLUGIN_VERSION, "Sourcemod Spectate", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - g_aPluginCvar[hHudMode] = CreateConVar("sm_spectate_hudmode", "1", "Hud Mode: 0 = Hud Text | 1 = Panel/Menu (NOTE: The panel/menu will override other menus until canceled)"); - g_aPluginCvar[hMenuType] = CreateConVar("sm_spectate_menutype", "0", "Menu Mode: 0 = Panel | 1 = Menu"); - g_aPluginCvar[hRestrictHud] = CreateConVar("sm_spectate_restricthud", "0", "Restrict the hud to the admin flag provided"); - g_aPluginCvar[hBan] = CreateConVar("sm_spectate_ban", "1", "Enable/Disable ban option"); - g_aPluginCvar[hBanPerm] = CreateConVar("sm_spectate_banperm", "1", "Enable/Disable permanent ban option"); - g_aPluginCvar[hBeacon] = CreateConVar("sm_spectate_beacon", "1", "Enable/Disable beacon option"); - g_aPluginCvar[hBlind] = CreateConVar("sm_spectate_blind", "1", "Enable/Disable blind option"); - g_aPluginCvar[hCheater] = CreateConVar("sm_spectate_cheater", "1", "Enable/Disable cheater option"); - g_aPluginCvar[hDrug] = CreateConVar("sm_spectate_drug", "1", "Enable/Disable drug option"); - g_aPluginCvar[hFreeze] = CreateConVar("sm_spectate_freeze", "1", "Enable/Disable freeze option"); - g_aPluginCvar[hFreezeBomb] = CreateConVar("sm_spectate_freezebomb", "1", "Enable/Disable freezebomb option"); - g_aPluginCvar[hKick] = CreateConVar("sm_spectate_kick", "1", "Enable/Disable kick option"); - g_aPluginCvar[hSlap] = CreateConVar("sm_spectate_slap", "1", "Enable/Disable slap option"); - g_aPluginCvar[hSlay] = CreateConVar("sm_spectate_slay", "1", "Enable/Disable slay option"); - g_aPluginCvar[hTimeBomb] = CreateConVar("sm_spectate_timebomb", "1", "Enable/Disable timebomb option"); - - sm_spectate_adminflag = CreateConVar("sm_spectate_adminflag", "d", "Admin Flag to use for admin hud"); - - /** - Hook console variables - */ - new e_CvarHandles:iCvar; - for ( ; _:iCvar < sizeof(g_aPluginCvar); iCvar++) - { - HookConVarChange(g_aPluginCvar[iCvar], ConVarSettingsChanged); - } - - /** - Need to register the commands we are going to create and use. - */ - RegConsoleCmd("sm_spectate", Command_Spectate, "Spectate a player"); - RegConsoleCmd("sm_spec", Command_Spectate, "Spectate a player"); - RegConsoleCmd("sm_observe", Command_Spectate, "Spectate a player"); - RegConsoleCmd("sm_stopspec", Command_StopSpectate, "Stop Spectating a player"); - RegConsoleCmd("sm_endobserve", Command_StopSpectate, "Stop Spectating a player"); - RegConsoleCmd("sm_specinfo", Command_ToggleHud, "Toggles the hud display if in spectator"); - - /** - Now we have to deal with the admin menu. If the admin library is loaded call the function to add our items. - */ - new Handle:gTopMenu; - if (LibraryExists("adminmenu") && ((gTopMenu = GetAdminTopMenu()) != INVALID_HANDLE)) - { - OnAdminMenuReady(gTopMenu); - } - - /** - Deal with the hud - Thanks to Spray Trace plugin (http://forums.alliedmods.net/showthread.php?p=665448) - */ - new String:sHudGames[32]; - GetGameFolderName(sHudGames, sizeof(sHudGames)); - g_aPluginSettings[bCanHUD] = StrEqual(sHudGames,"tf",false) - || StrEqual(sHudGames,"hl2mp",false) - || StrEqual(sHudGames,"sourceforts",false) - || StrEqual(sHudGames,"obsidian",false) - || StrEqual(sHudGames,"left4dead",false) - || StrEqual(sHudGames,"l4d",false); - - if (g_aPluginSettings[bCanHUD]) - { - g_hHud = CreateHudSynchronizer(); - } - - /** - Load translations - */ - LoadTranslations ("common.phrases"); - LoadTranslations ("simplespectate.phrases"); - - /** - Create the config file - */ - AutoExecConfig(true); -} - -public OnConfigsExecuted() -{ - new e_CvarHandles:iCvar; - for ( ; _:iCvar < sizeof(g_aPluginCvarSettings); iCvar++) - { - g_aPluginCvarSettings[iCvar] = GetConVarBool(g_aPluginCvar[iCvar]); - } - - /* - Build the global menus - */ - g_aMenus[hSelectPlayer] = BuildSelectPlayerMenu(); - g_aMenus[hBanTime] = BuildBanTimeMenu(); - g_aMenus[hReason] = BuildReasonMenu(); - - GetConVarString(sm_spectate_adminflag, g_sAdminFlags, sizeof(g_sAdminFlags)); -} - -public OnAllPluginsLoaded() -{ - - /* - Check for steambans - */ - if (FindConVar("sbsrc_version") != INVALID_HANDLE) - { - g_aPluginSettings[bUseSteamBans] = true; - } - else - { - g_aPluginSettings[bUseSteamBans] = false; - } - - /* - Check for sourcebans - */ - if (FindConVar("sb_version") != INVALID_HANDLE) - { - g_aPluginSettings[bUseSourceBans] = true; - } - else - { - g_aPluginSettings[bUseSourceBans] = false; - } - - /* - Check for mysql bans - */ - if (FindConVar("mysql_bans_version") != INVALID_HANDLE) - { - g_aPluginSettings[bUseMySQLBans] = true; - } - else - { - g_aPluginSettings[bUseMySQLBans] = false; - } - - /* - Check for dukehacks - */ - new String:sExtError[256]; - new iExtStatus = GetExtensionFileStatus("dukehacks.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SSPEC] Dukehacks extension was not found."); - LogAction(0, -1, "[SSPEC] Plugin continued to load, but that feature will not be used."); - g_aPluginSettings[bUseDukehacks] = false; - } - else if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SSPEC] Dukehacks extension is loaded with errors."); - LogAction(0, -1, "[SSPEC] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SSPEC] Plugin continued to load, but that feature will not be used."); - g_aPluginSettings[bUseDukehacks] = false; - } - else if (iExtStatus == 1) - { - LogAction(0, -1, "[SSPEC] Dukehacks extension is loaded and will be used."); - g_aPluginSettings[bUseDukehacks] = true; - dhAddClientHook(CHK_TakeDamage, Hacks_TakeDamageHook); - } - - /* - Deal with some known plugin conflicts - */ - new Handle:hObserveClient = FindConVar("observe_version"); - if (hObserveClient != INVALID_HANDLE) - { - new String:sNewFile[PLATFORM_MAX_PATH + 1], String:sOldFile[PLATFORM_MAX_PATH + 1]; - BuildPath(Path_SM, sNewFile, sizeof(sNewFile), "plugins/disabled/observe.smx"); - BuildPath(Path_SM, sOldFile, sizeof(sOldFile), "plugins/observe.smx"); - - /** - Check if plugins/observe.smx exists, and if not, ignore - */ - if(!FileExists(sOldFile)) - { - return; - } - - /** - Check if plugins/disabled/observe.smx already exists, and if so, delete it - */ - if(FileExists(sNewFile)) - { - DeleteFile(sNewFile); - } - - /** - Unload plugins/observe.smx and move it to plugins/disabled/observe.smx - */ - LogAction(0, -1, "Detected the plugin ObserveClient"); - LogAction(0, -1, "ObserveClient plugin conflicts with Simple Spectate"); - LogAction(0, -1, "Unloading plugin and disabling ObserveClient plugin"); - ServerCommand("sm plugins unload observe"); - RenameFile(sNewFile, sOldFile); - } -} - -public OnLibraryRemoved(const String:name[]) -{ - if (StrEqual(name, "adminmenu")) - { - - /** - Looks like the admin menu was removed. Set the global. - */ - g_hAdminMenu = INVALID_HANDLE; - } - else if (StrEqual(name, "simpleplugins")) - { - //something - } -} - -public OnClientDisconnect(client) -{ - - /** - Cleanup the clients variables. - */ - ResetClient(client); - - /** - Run a loop and see if we are supposed to spectate this person (is a target) - */ - for(new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][iTargetIndex] == client) - { - - /** - Cleanup the clients variables. - */ - StopFollowingPlayer(i); - g_aPlayers[i][TargetPunishment] = Punish_None; - g_aPlayers[i][iBanTime] = 0; - } - } -} - -/** -Thirdparty callbacks -*/ -public SM_OnPlayerMoved(Handle:plugin, client, team) -{ - - /** - Make sure we called the move function - */ - if (plugin != GetMyHandle()) - { - return; - } - - //Nothing -} - -public Action:Hacks_TakeDamageHook(client, attacker, inflictor, Float:damage, &Float:multiplier, damagetype) -{ - - /** - Check for a valid client - */ - if (client > 0 && client <= MaxClients) - { - - /** - Check if the client taking damage is flagged as a cheater - */ - if (g_aPlayers[client][bIsFlaggedCheater]) - { - - /** - Check for fall damage and increase it - */ - if (damagetype & DMG_FALL) - { - multiplier *= 1000.0; - return Plugin_Changed; - } - } - } - - /** - Check for a valid attacker - */ - if (attacker > 0 && attacker <= MaxClients) - { - - /** - Check if the attacker causing the damage is flagged as a cheater - */ - if (g_aPlayers[attacker][bIsFlaggedCheater]) - { - - /** - Make sure they are not hurting themselves - */ - if (client != attacker) - { - - /** - Stop the damage - */ - multiplier *= 0.0; - return Plugin_Changed; - } - } - } - return Plugin_Continue; -} - -/** -Events -*/ -public Action:HookPlayerChangeTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get the client and team - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - new iTeam = GetEventInt(event, "team"); - - /** - Make sure it's a valid client - */ - if (iClient == 0) - { - return Plugin_Continue; - } - - /** - If it's a move to spectator start displaying the hud - */ - else if ((iTeam == g_aCurrentTeams[Spectator]) && (GetUserFlagBits(iClient) & ADMFLAG_GENERIC)) - { - StartDisplayingHud(iClient); - - /** - If the event was going to be broadcasted, we refire it so it is not broadcasted and stop this one - */ - if (!dontBroadcast) - { - new Handle:hEvent = CreateEvent("player_team"); - SetEventInt(hEvent, "userid", GetEventInt(event, "userid")); - SetEventInt(hEvent, "team", GetEventInt(event, "team")); - SetEventInt(hEvent, "oldteam", GetEventInt(event, "oldteam")); - SetEventBool(hEvent, "disconnect", GetEventBool(event, "disconnect")); - - if (g_CurrentMod == GameType_DOD || g_CurrentMod == GameType_L4D || g_CurrentMod == GameType_TF) - { - new String:sClientName[MAX_NAME_LENGTH + 1]; - GetClientName(client, sClientName, sizeof(sClientName)); - SetEventBool(hEvent, "autoteam", GetEventBool(event, "autoteam")); - SetEventBool(hEvent, "silent", true); - SetEventString(hEvent, "name", sClientName); - FireEvent(hEvent, true); - } - else - { - FireEvent(hEvent, true); - } - return Plugin_Handled; - } - } - - /** - Otherwise cleanup the client - */ - else - { - StopDisplayingHud(iClient); - StopFollowingPlayer(iClient); - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -/** -Commands -*/ -public Action:Command_Spectate(client, args) -{ - - /** - See if we already have a target (for toggling of command) - */ - if (g_aPlayers[client][iTargetIndex]) - { - - /** - We do, toggle it off - */ - StopFollowingPlayer(client); - - /** - We are done, bug out. - */ - return Plugin_Handled; - } - - /** - We don't... must want to enable it - See if we have some command arguments. - */ - new iCmdArgs = GetCmdArgs(); - if (iCmdArgs == 0) - { - - /** - We don't have any. Display the player menu. - */ - if (g_aPlayers[client][bIsDisplayingHud]) - { - StopDisplayingHud(client); - } - - DisplayMenu(BuildPlayerListMenu(), client, MENU_TIME_FOREVER); - return Plugin_Handled; - } - - /** - We have an argument. - Try to find the target. - */ - new String:sPlayer[128]; - GetCmdArg(1, sPlayer, sizeof(sPlayer)); - new iTarget = FindTarget(client, sPlayer, true, true); - if (iTarget == -1 || !IsClientInGame(iTarget)) - { - - /** - We couldn't find the target. Display the player menu. - */ - if (g_aPlayers[client][bIsDisplayingHud]) - { - StopDisplayingHud(client); - } - - DisplayMenu(BuildPlayerListMenu(), client, MENU_TIME_FOREVER); - return Plugin_Handled; - } - - /** - We found the target. - Call the stock function to spectate the target. - */ - StartFollowingPlayer(client, iTarget); - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_StopSpectate(client, args) -{ - - /** - Cleanup the clients variables. - */ - StopFollowingPlayer(client); - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_ToggleHud(client, args) -{ - - /** - Toggle the hud - */ - if (g_aPlayers[client][bIsDisplayingHud]) - { - StopDisplayingHud(client); - } - else - { - StartDisplayingHud(client); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -/** -Timers -*/ -public Action:Timer_ResetTarget(Handle:timer, any:client) -{ - - new iTargetID = GetEntPropEnt(client, Prop_Send, "m_hObserverTarget"); - - if (iTargetID != g_aPlayers[client][iTargetIndex] && IsPlayerAlive(g_aPlayers[client][iTargetIndex])) - { - - /** - Run the command to spectate the target from the clients prospectative. - */ - FakeClientCommandEx(client, "spec_player \"%N\"", g_aPlayers[client][iTargetIndex]); - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -public Action:Timer_UpdateHud(Handle:timer, any:client) -{ - - /** - Make sure the client is still in game and a spectator - */ - if (!IsClientConnected(client) || !IsClientInGame(client) || GetClientTeam(client) != g_aCurrentTeams[Spectator] || !g_aPlayers[client][bIsDisplayingHud]) - { - - /** - We are done, bug out - */ - g_aPlayers[client][hHudTimer] = INVALID_HANDLE; - g_aPlayers[client][bIsDisplayingHud] = false; - return Plugin_Stop; - } - /** - Get the target - */ - new iTarget = GetEntPropEnt(client, Prop_Send, "m_hObserverTarget"); - - /** - Check to make sure the target is valid - */ - if (iTarget <= 0 || iTarget > MaxClients) - { - return Plugin_Continue; - } - - /** - Get the spectator mode - */ - new iSpecMode = GetEntProp(client, Prop_Send, "m_iObserverMode"); - - /** - This is a double check to make sure we are in spec - If we are on a regular team, specmod would = none or zero - */ - if (iSpecMode == SPECMODE_NONE) - { - - /** - We are done, bug out - */ - g_aPlayers[client][hHudTimer] = INVALID_HANDLE; - g_aPlayers[client][bIsDisplayingHud] = false; - return Plugin_Stop; - } - - /** - Check the spectator mode - CSS has different index's so we have to check game type first - */ - if (g_CurrentMod == GameType_CSS) - { - switch (iSpecMode) - { - case SPECMODE_CSS_FIRSTPERSON: - { - //Do Nothing - } - case SPECMODE_CSS_3RDPERSON: - { - //Do Nothing - } - case SPECMODE_CSS_FREELOOK: - { - return Plugin_Continue; - } - } - } - else - { - switch (iSpecMode) - { - case SPECMODE_FIRSTPERSON: - { - //Do Nothing - } - case SPECMODE_3RDPERSON: - { - //Do Nothing - } - case SPECMODE_FREELOOK: - { - return Plugin_Continue; - } - } - } - - - /** - Display with the hud - */ - if (g_aPluginSettings[bCanHUD] && !g_aPluginCvarSettings[bHudMode]) - { - new String:sSteamID[64]; - GetClientAuthString(iTarget, sSteamID, sizeof(sSteamID)); - SetHudTextParams(0.04, 0.6, 0.5, 255, 50, 50, 255); - ShowSyncHudText(client, g_hHud, "%N [%s]", iTarget, sSteamID); - } - else if (g_aPluginCvarSettings[bHudMode]) - { - if (g_aPluginCvarSettings[bMenuType]) - { - DisplayMenu(BuildPlayerHudMenu(client, iTarget), client, 1); - } - else - { - new Handle:hPanel = BuildPlayerHudPanel(client, iTarget); - SendPanelToClient(hPanel, client, Panel_PlayerHud, 1); - CloseHandle(hPanel); - } - } - - /** - We are done, keep going! - */ - return Plugin_Continue; -} - -/** -Admin Menu Callbacks -*/ -public OnAdminMenuReady(Handle:topmenu) -{ - if (topmenu == g_hAdminMenu) - { - return; - } - g_hAdminMenu = topmenu; - new TopMenuObject:player_commands = FindTopMenuCategory(g_hAdminMenu, ADMINMENU_PLAYERCOMMANDS); - if (player_commands == INVALID_TOPMENUOBJECT) - { - return; - } - AddToTopMenu(g_hAdminMenu, - "sm_spectate", - TopMenuObject_Item, - AdminMenu_SpecPlayer, - player_commands, - "sm_spectate", - ADMFLAG_GENERIC); -} - -public AdminMenu_SpecPlayer(Handle:topmenu, TopMenuAction:action, TopMenuObject:object_id, param, String:buffer[], maxlength) -{ - if (action == TopMenuAction_DisplayOption) - { - - if (g_aPlayers[param][bIsDisplayingHud]) - { - StopDisplayingHud(param); - } - /** - See if we already have a target - */ - if (g_aPlayers[param][iTargetIndex]) - { - Format(buffer, maxlength, "Spectate(Disable)"); - } - else - { - Format(buffer, maxlength, "Spectate(Select Player)"); - } - } - else if (action == TopMenuAction_SelectOption) - { - - /** - See if we already have a target - */ - if (g_aPlayers[param][iTargetIndex]) - { - - /** - We do, toggle it off - */ - StopFollowingPlayer(param); - - /** - We are done, bug out. - */ - return; - } - else - { - DisplayMenu(BuildPlayerListMenu(), param, MENU_TIME_FOREVER); - } - } -} - -/** -Select Player Menu Callbacks -*/ -public Menu_PlayerList(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - /** - Get the selected player - */ - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - new iTarget = GetClientOfUserId(StringToInt(sSelection)); - - /** - Start following the player - */ - StartFollowingPlayer(param1, iTarget); - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_GENERIC) - { - - /** - Display the last admin menu - */ - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } - else if (param2 == MenuCancel_Exit && GetClientTeam(param1) == g_aCurrentTeams[Spectator]) - { - /** - They canceled the current menu, start the hud back up - */ - StartDisplayingHud(param1); - } - } - else if (action == MenuAction_End) - { - - /** - Not a global menu, close it - */ - CloseHandle(menu); - } -} - -public Menu_SelectPlayer(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - - /** - Get the selected player - */ - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (strcmp(sSelection, "Current", false) == 0) - { - /** - Get the current target - */ - new iTarget = GetEntPropEnt(param1, Prop_Send, "m_hObserverTarget"); - - /** - Check to make sure the target is valid - */ - if (iTarget <= 0 || iTarget > MaxClients) - { - PrintToChat(param1, "\x03[SM-SPEC]\x01 %t", "Invalid Target"); - DisplayMenu(BuildPlayerListMenu(), param1, MENU_TIME_FOREVER); - } - - /** - Start following the player - */ - StartFollowingPlayer(param1, iTarget); - } - else - { - - /** - They want to select a player, show the player list - */ - DisplayMenu(BuildPlayerListMenu(), param1, MENU_TIME_FOREVER); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - - /** - They canceled the current menu, start the hud back up - */ - StartDisplayingHud(param1); - } - } - else if (action == MenuAction_End) - { - /** - Its a global menu, leave it alive - */ - } -} - -/** -Punishment Menu Callbacks -*/ -public Menu_Punishments(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - - /** - Get the menu selection - */ - new String:sSelection[15]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - - /** - Search for the correct index - */ - new e_Punishments:Index = Punish_None; - for ( ; _:Index <= sizeof(g_sPunishments); Index++) - { - if (StrEqual(sSelection, g_sPunishments[Index])) - { - break; - } - } - - /** - Display the next menu - */ - if (Index == Punish_Ban) - { - - /** - Set the punishment index and display ban time menu - */ - g_aPlayers[param1][TargetPunishment] = Index; - DisplayMenu(g_aMenus[hBanTime], param1, MENU_TIME_FOREVER); - } - else if (Index == Punish_Cheater) - { - - /** - Ask for confirmation before we set punishment index - */ - new Handle:hPanel = BuildAdminCheaterPanel(); - SendPanelToClient(hPanel, param1, Panel_AdminCheater, MENU_TIME_FOREVER); - CloseHandle(hPanel); - } - else - { - - /** - Set the punishment index and display reason menu - */ - g_aPlayers[param1][TargetPunishment] = Index; - DisplayMenu(g_aMenus[hReason], param1, MENU_TIME_FOREVER); - } - } - else if (action == MenuAction_Cancel) - { - - /** - They canceled the current menu, start the hud back up - */ - StartDisplayingHud(param1); - } - else if (action == MenuAction_End) - { - - /** - Not a global menu, close it - */ - CloseHandle(menu); - } -} - -public Menu_BanTime(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - - /** - Get the menu selection - */ - new String:sSelection[15]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - - /** - Set the ban time global - */ - g_aPlayers[param1][iBanTime] = StringToInt(sSelection); - - /** - Display the reason menu - */ - DisplayMenu(g_aMenus[hReason], param1, MENU_TIME_FOREVER); - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - - /** - They canceled the current menu, start the hud back up - */ - StartDisplayingHud(param1); - } - } - else if (action == MenuAction_End) - { - /** - Its a global menu, leave it alive - */ - } -} - -public Menu_Reason(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - - /** - Get the menu selection - */ - new String:sSelection[15]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - - /** - Perform the punishment - */ - PerformPunishment(param1, g_aPlayers[param1][iTargetIndex], g_aPlayers[param1][TargetPunishment], sSelection, g_aPlayers[param1][iBanTime]); - - /** - Reactivate the hud if still in spectator - */ - if (GetClientTeam(param1) == g_aCurrentTeams[Spectator]) - { - StartDisplayingHud(param1); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - - /** - They canceled the current menu, start the hud back up - */ - StartDisplayingHud(param1); - } - } - else if (action == MenuAction_End) - { - /** - Its a global menu, leave it alive - */ - } -} - -public Panel_AdminCheater(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - if (param2 == 1) - { - - /** - Set the punishment index and display reason menu - */ - g_aPlayers[param1][TargetPunishment] = Punish_Cheater; - DisplayMenu(g_aMenus[hReason], param1, MENU_TIME_FOREVER); - } - else - { - - /** - Reactivate the hud if still in spectator - */ - if (GetClientTeam(param1) == g_aCurrentTeams[Spectator]) - { - StartDisplayingHud(param1); - } - } - } -} - -public Panel_PublicCheater(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - if (param2 == 1) - { - //Waiting for SB 2.0 and sb_submission to be published - } - else - { - - /** - Reactivate the hud if still in spectator - */ - if (GetClientTeam(param1) == g_aCurrentTeams[Spectator]) - { - StartDisplayingHud(param1); - } - } - } -} - -/** -Hud Menu/Panel Callbacks -*/ -public Menu_PlayerHud(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "stop", false)) - { - StopFollowingPlayer(param1); - } - else if (StrEqual(sSelection, "start", false)) - { - StopDisplayingHud(param1); - DisplayMenu(g_aMenus[hSelectPlayer], param1, MENU_TIME_FOREVER); - } - else if (StrEqual(sSelection, "removecheater", false)) - { - g_aPlayers[g_aPlayers[param1][iTargetIndex]][bIsFlaggedCheater] = false; - } - else if (StrEqual(sSelection, "punish", false)) - { - if (g_aPlayers[param1][iTargetIndex]) - { - StopDisplayingHud(param1); - DisplayMenu(BuildPunishmentMenu(param1), param1, MENU_TIME_FOREVER); - } - else - { - StopDisplayingHud(param1); - PrintToChat(param1, "\x03[SM-SPEC]\x01 %t", "Must Have Target"); - DisplayMenu(g_aMenus[hSelectPlayer], param1, MENU_TIME_FOREVER); - } - } - else if (StrEqual(sSelection, "reportcheater", false)) - { - if (g_aPlayers[param1][iTargetIndex]) - { - StopDisplayingHud(param1); - new Handle:hPanel = BuildPublicCheaterPanel(); - SendPanelToClient(hPanel, param1, Panel_PublicCheater, MENU_TIME_FOREVER); - CloseHandle(hPanel); - } - else - { - StopDisplayingHud(param1); - PrintToChat(param1, "\x03[SM-SPEC]\x01 %t", "Must Have Target"); - DisplayMenu(g_aMenus[hSelectPlayer], param1, MENU_TIME_FOREVER); - } - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_Interrupted) - { - if (GetClientMenu(param1) == MenuSource_External) - { - StopDisplayingHud(param1); - } - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } -} - -public Panel_PlayerHud(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - switch (param2) - { - case 1: - { - if (g_aPlayers[param1][iTargetIndex]) - { - StopFollowingPlayer(param1); - } - else - { - StopDisplayingHud(param1); - DisplayMenu(BuildSelectPlayerMenu(), param1, MENU_TIME_FOREVER); - } - } - case 2: - { - if (!g_aPlayers[param1][iTargetIndex]) - { - StopDisplayingHud(param1); - PrintToChat(param1, "\x03[SM-SPEC]\x01 %t", "Must Have Target"); - DisplayMenu(g_aMenus[hSelectPlayer], param1, MENU_TIME_FOREVER); - return; - } - - if ((GetUserFlagBits(param1) & ADMFLAG_GENERIC) || (GetUserFlagBits(param1) & ADMFLAG_ROOT)) - { - if (g_aPlayers[g_aPlayers[param1][iTargetIndex]][bIsFlaggedCheater] && (GetUserFlagBits(param1) & ADMFLAG_ROOT)) - { - //Remove cheater flag - g_aPlayers[g_aPlayers[param1][iTargetIndex]][bIsFlaggedCheater] = false; - } - else - { - //Punish menu - StopDisplayingHud(param1); - DisplayMenu(BuildPunishmentMenu(param1), param1, MENU_TIME_FOREVER); - } - } - else - { - //Report Cheater - new Handle:hPanel = BuildPublicCheaterPanel(); - SendPanelToClient(hPanel, param1, Panel_PublicCheater, MENU_TIME_FOREVER); - CloseHandle(hPanel); - } - } - case 3: - { - StopDisplayingHud(param1); - } - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_Interrupted) - { - if (GetClientMenu(param1) == MenuSource_External) - { - StopDisplayingHud(param1); - } - } - } -} - - -/** -Stock functions -*/ -stock StartFollowingPlayer(client, target) -{ - - /** - If we have an open timer, close it. - */ - if (g_aPlayers[client][hTargetTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[client][hTargetTimer]); - g_aPlayers[client][hTargetTimer] = INVALID_HANDLE; - } - - /** - Make sure the target is on a non spectator team, and the client != target - */ - if (client == target) - { - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Yourself"); - return; - } - new iTargetTeam = GetClientTeam(target); - if (iTargetTeam == g_aCurrentTeams[Spectator] || iTargetTeam == g_aCurrentTeams[Unknown]) - { - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Spectator"); - return; - } - - /** - Check to see if client is already a spectator - */ - if (GetClientTeam(client) != g_aCurrentTeams[Spectator]) - { - - /** - Client is not a spectator, lets move them to spec. - */ - SM_MovePlayer(client, g_aCurrentTeams[Spectator]); - } - - /** - If we are using steambans call sb_status - */ - if (g_aPluginSettings[bUseSteamBans]) - { - FakeClientCommandEx(client, "sb_status"); - } - - - /** - Set the global and start to spectate the target. - Making sure it's long enough to deal with moving the client to spec if we had to. - */ - new String:sTargetName[MAX_NAME_LENGTH + 1]; - GetClientName(target, sTargetName, sizeof(sTargetName)); - g_aPlayers[client][iTargetIndex] = target; - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Spectating", sTargetName); - g_aPlayers[client][hTargetTimer] = CreateTimer(0.5, Timer_ResetTarget, client, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); - if (!g_aPlayers[client][bIsDisplayingHud] && GetClientTeam(client) == g_aCurrentTeams[Spectator]) - { - StartDisplayingHud(client); - } -} - -stock StopFollowingPlayer(client) -{ - - /** - If we have an open timer, close it. - */ - if (g_aPlayers[client][hTargetTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[client][hTargetTimer]); - } - - /** - Tell the client we can't spec his target anymore... if they are in game. - */ - if (IsClientInGame(client) && g_aPlayers[client][iTargetIndex] != 0) - { - new String:sTargetName[MAX_NAME_LENGTH + 1]; - GetClientName(g_aPlayers[client][iTargetIndex], sTargetName, sizeof(sTargetName)); - if (!IsClientConnected(g_aPlayers[client][iTargetIndex]) || !IsClientInGame(g_aPlayers[client][iTargetIndex])) - { - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Target Left"); - } - else - { - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Stopped spectating", sTargetName); - } - } - - /** - Null the globals. - */ - g_aPlayers[client][iTargetIndex] = 0; - g_aPlayers[client][hTargetTimer] = INVALID_HANDLE; -} - -stock StartDisplayingHud(client) -{ - if (g_aPluginCvarSettings[bRestrictHud] && !SM_IsValidAdmin(client, g_sAdminFlags)) - { - return; - } - else - { - /** - Double check the hud timer - We should not have one, but if we do, lets cancel it for the current callback - */ - StopDisplayingHud(client); - - /** - Now we can safely display the hud and make sure the current stored handle is the current timer - */ - g_aPlayers[client][bIsDisplayingHud] = true; - g_aPlayers[client][hHudTimer] = CreateTimer(0.5, Timer_UpdateHud, client, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); - } -} - -stock StopDisplayingHud(client) -{ - if (g_aPlayers[client][hHudTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[client][hHudTimer]); - } - g_aPlayers[client][hHudTimer] = INVALID_HANDLE; - g_aPlayers[client][bIsDisplayingHud] = false; -} - -stock ResetClient(client) -{ - StopFollowingPlayer(client); - StopDisplayingHud(client); - - g_aPlayers[client][bIsFlaggedCheater] = false; - g_aPlayers[client][TargetPunishment] = Punish_None; - g_aPlayers[client][iBanTime] = -1; -} - -stock PerformPunishment(client, target, e_Punishments:punishment, const String:reason[], time = 300) -{ - new String:sTargetName[MAX_NAME_LENGTH + 1], - String:sTargetID[64]; - - /** - The target could have left the game by the time we get here - Check for a valid target - */ - if (!IsClientConnected(target) || !IsClientInGame(target)) - { - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Target Left"); - return; - } - - GetClientName(target, sTargetName, sizeof(sTargetName)); - GetClientAuthString(target, sTargetID, sizeof(sTargetID)); - - switch (punishment) - { - case Punish_Kick: - { - KickClient(g_aPlayers[client][iTargetIndex], "%s", reason); - } - case Punish_Ban: - { - if (g_aPluginSettings[bUseSourceBans]) - { - ClientCommand(client, "sm_ban #%d %d \"%s\"", GetClientUserId(target), time, reason); - } - else if (g_aPluginSettings[bUseMySQLBans]) - { - ClientCommand(client, "mysql_ban #%d %d \"%s\"", GetClientUserId(target), time, reason); - } - else - { - BanClient(target, time, BANFLAG_AUTHID, reason, reason); - } - } - case Punish_Cheater: - { - g_aPlayers[target][bIsFlaggedCheater] = true; - } - case Punish_Beacon: - { - ClientCommand(client, "sm_beacon \"%s\"", sTargetName); - } - case Punish_Blind: - { - ClientCommand(client, "sm_blind \"%s\"", sTargetName); - } - case Punish_Drug: - { - ClientCommand(client, "sm_drug \"%s\"", sTargetName); - } - case Punish_Freeze: - { - ClientCommand(client, "sm_freeze \"%s\"", sTargetName); - } - case Punish_FreezeBomb: - { - ClientCommand(client, "sm_freezebomb \"%s\"", sTargetName); - } - case Punish_Slap: - { - ClientCommand(client, "sm_slap \"%s\" 10", sTargetName); - } - case Punish_Slay: - { - ClientCommand(client, "sm_slay \"%s\"", sTargetName); - } - case Punish_TimeBomb: - { - ClientCommand(client, "sm_timebomb \"%s\"", sTargetName); - } - } - - if (punishment == Punish_Cheater) - { - LogAction(client, target, "[SM SPEC] %N marked %N(%s) with a %s flag for %s", client, target, sTargetID, g_sPunishments[punishment], reason); - } - else - { - ShowActivity(client, "%t", "Punished", sTargetName, g_sPunishments[punishment], reason); - LogAction(client, target, "[SM SPEC] %N punished %N(%s) with a %s for %s", client, target, sTargetID, g_sPunishments[punishment], reason); - } - - /** - Null the globals. - */ - g_aPlayers[client][TargetPunishment] = Punish_None; - g_aPlayers[client][iBanTime] = -1; -} - -/** -Build the menu of player names -*/ -stock Handle:BuildPlayerListMenu() -{ - new Handle:hMenu = CreateMenu(Menu_PlayerList); - AddTargetsToMenu(hMenu, 0, true, false); - SetMenuTitle(hMenu, "Select A Player:"); - SetMenuExitBackButton(hMenu, true); - return hMenu; -} - -/** -Build the select player menu (current or list of players) -*/ -stock Handle:BuildSelectPlayerMenu() -{ - new Handle:hMenu = CreateMenu(Menu_SelectPlayer); - SetMenuTitle(hMenu, "Select A Player:"); - AddMenuItem(hMenu, "Current", "Current Target"); - AddMenuItem(hMenu, "List", "Player List"); - SetMenuExitBackButton(hMenu, true); - return hMenu; -} - -/** -Build the punishmenu menu -*/ -stock Handle:BuildPunishmentMenu(iClient) -{ - new Handle:hMenu = CreateMenu(Menu_Punishments); - SetMenuTitle(hMenu, "Select A Punishment:"); - SetMenuExitBackButton(hMenu, true); - SetMenuExitButton(hMenu, true); - - if (g_aPluginCvarSettings[bKick] && ((GetUserFlagBits(iClient) & ADMFLAG_GENERIC) || (GetUserFlagBits(iClient) & ADMFLAG_ROOT))) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Kick], "Kick"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Kick], "Kick", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bBan] && ((GetUserFlagBits(iClient) & ADMFLAG_GENERIC) || (GetUserFlagBits(iClient) & ADMFLAG_ROOT))) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Ban], "Ban"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Ban], "Ban", ITEMDRAW_DISABLED); - } - - if (g_aPluginSettings[bUseDukehacks] && g_aPluginCvarSettings[bCheater] && (GetUserFlagBits(iClient) & ADMFLAG_ROOT)) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Cheater], "Flag As Cheater"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Cheater], "Flag As Cheater", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bBeacon]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Beacon], "Beacon"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Beacon], "Beacon", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bBlind]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Blind], "Blind"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Blind], "Blind", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bDrug]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Drug], "Drug"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Drug], "Drug", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bFreeze]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Freeze], "Freeze"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Freeze], "Freeze", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bFreezebomb]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_FreezeBomb], "Freeze Bomb"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_FreezeBomb], "Freeze Bomb", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bSlap]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Slap], "Slap"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Slap], "Slap", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bSlay]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Slay], "Slay"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Slay], "Slay", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bTimeBomb]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_TimeBomb], "Time Bomb"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_TimeBomb], "Time Bomb", ITEMDRAW_DISABLED); - } - - return hMenu; -} - -/** -Build the punishmenu menu -*/ -stock Handle:BuildBanTimeMenu() -{ - new Handle:hMenu = CreateMenu(Menu_BanTime); - SetMenuTitle(hMenu, "Select Ban Type:"); - - if (g_aPluginCvarSettings[bBanPerm]) - { - AddMenuItem(hMenu, "permban", "Permanent"); - } - else - { - AddMenuItem(hMenu, "permban", "Permanent", ITEMDRAW_DISABLED); - } - - AddMenuItem(hMenu, "10", "10 Minutes"); - AddMenuItem(hMenu, "30", "30 Minutes"); - AddMenuItem(hMenu, "60", "1 Hour"); - AddMenuItem(hMenu, "240", "4 Hours"); - AddMenuItem(hMenu, "1440", "1 Day"); - AddMenuItem(hMenu, "10080", "1 Week"); - - SetMenuExitBackButton(hMenu, true); - return hMenu; -} - -/** -Build the punishmenu menu -*/ -stock Handle:BuildReasonMenu() -{ - new Handle:hMenu = CreateMenu(Menu_Reason); - SetMenuTitle(hMenu, "Select A Reason:"); - - AddMenuItem(hMenu, "Abusive", "Abusive"); - AddMenuItem(hMenu, "Racism", "Racism"); - AddMenuItem(hMenu, "General cheating/exploits", "General cheating/exploits"); - AddMenuItem(hMenu, "Wallhack", "Wallhack"); - AddMenuItem(hMenu, "Aimbot", "Aimbot"); - AddMenuItem(hMenu, "Speedhacking", "Speedhacking"); - AddMenuItem(hMenu, "Mic spamming", "Mic spamming"); - AddMenuItem(hMenu, "Admin disrepect", "Admin disrepect"); - AddMenuItem(hMenu, "Camping", "Camping"); - AddMenuItem(hMenu, "Team killing", "Team killing"); - AddMenuItem(hMenu, "Unacceptable Spray", "Unacceptable Spray"); - AddMenuItem(hMenu, "Breaking Server Rules", "Breaking Server Rules"); - AddMenuItem(hMenu, "Other", "Other"); - - SetMenuExitBackButton(hMenu, true); - return hMenu; -} - -/** -Build the cheater displays -*/ -stock Handle:BuildAdminCheaterPanel() -{ - - /** - Create the menu and set the menu options. - */ - new Handle:hPanel = CreatePanel(); - SetPanelTitle(hPanel, "Simple Spectator:"); - - DrawPanelText(hPanel, "Are you sure you want to"); - DrawPanelText(hPanel, "flag this player as a cheater?"); - DrawPanelText(hPanel, "They will not be able to damage"); - DrawPanelText(hPanel, "anyone and die on fall damage."); - DrawPanelItem(hPanel, "Yes"); - DrawPanelItem(hPanel, "No"); - - return hPanel; -} - -stock Handle:BuildPublicCheaterPanel() -{ - - /** - Create the menu and set the menu options. - */ - new Handle:hPanel = CreatePanel(); - SetPanelTitle(hPanel, "Simple Spectator:"); - - DrawPanelText(hPanel, "Are you sure you want to"); - DrawPanelText(hPanel, "submit this player as a cheater?"); - DrawPanelItem(hPanel, "Yes (Not Implemented Yet)", ITEMDRAW_DISABLED); - DrawPanelItem(hPanel, "No"); - return hPanel; -} - -/** -Build the hud displays -*/ -stock Handle:BuildPlayerHudMenu(iClient, iTarget) -{ - - /** - Create all the string variables we will need - */ - new String:sTargetName[MAX_NAME_LENGTH + 1], - String:sTargetID[64], - String:sTargetIP[16]; - - new String:sDisplayName[MAX_NAME_LENGTH + 1], - String:sDisplayID[64], - String:sDisplayIP[64], - String:sDisplayFrags[16], - String:sDisplayDeaths[16]; - - new iTargetFrags, - iTargetDeaths; - - /** - Get the targets information - */ - GetClientName(iTarget, sTargetName, sizeof(sTargetName)); - GetClientIP(iTarget, sTargetIP, sizeof(sTargetIP)); - GetClientAuthString(iTarget, sTargetID, sizeof(sTargetID)); - iTargetFrags = GetClientFrags(iTarget); - iTargetDeaths = GetClientDeaths(iTarget); - - /** - Format the strings for the menu - */ - Format(sDisplayName, sizeof(sDisplayName), "Player: %s", sTargetName); - Format(sDisplayID, sizeof(sDisplayID), "Steam ID: %s", sTargetID); - Format(sDisplayIP, sizeof(sDisplayIP), "IP Address: %s", sTargetIP); - Format(sDisplayFrags, sizeof(sDisplayFrags), "Kills: %i", iTargetFrags); - Format(sDisplayDeaths, sizeof(sDisplayDeaths), "Deaths: %i", iTargetDeaths); - - /** - Create the menu and set the menu options. - */ - new Handle:hMenu = CreateMenu(Menu_PlayerHud); - SetMenuExitBackButton(hMenu, false); - SetMenuTitle(hMenu, "Simple Spectator"); - - AddMenuItem(hMenu, "name", sDisplayName, ITEMDRAW_DISABLED); - AddMenuItem(hMenu, "steamid", sDisplayID, ITEMDRAW_DISABLED); - - if (SM_IsValidAdmin(iClient, g_sAdminFlags)) - { - AddMenuItem(hMenu, "ip", sDisplayIP, ITEMDRAW_DISABLED); - } - - AddMenuItem(hMenu, "kills", sDisplayFrags, ITEMDRAW_DISABLED); - AddMenuItem(hMenu, "deaths", sDisplayDeaths, ITEMDRAW_DISABLED); - - if (g_aPlayers[iClient][iTargetIndex]) - { - AddMenuItem(hMenu, "stop", "Stop Following"); - } - else - { - AddMenuItem(hMenu, "start", "Follow Player"); - } - - if ((GetUserFlagBits(iClient) & ADMFLAG_GENERIC) || (GetUserFlagBits(iClient) & ADMFLAG_ROOT)) - { - if (g_aPlayers[iTarget][bIsFlaggedCheater] && (GetUserFlagBits(iClient) & ADMFLAG_ROOT)) - { - AddMenuItem(hMenu, "removecheater", "Remove Cheater Flag"); - } - else - { - if (CanUserTarget(iClient, iTarget)) - { - AddMenuItem(hMenu, "punish", "Punish Player"); - } - else - { - AddMenuItem(hMenu, "punish", "Punish Player (Immune)", ITEMDRAW_DISABLED); - } - } - } - else - { - AddMenuItem(hMenu, "reportcheater", "Report Cheater"); - } - - SetMenuPagination(hMenu, MENU_NO_PAGINATION); - SetMenuExitButton(hMenu, true); - return hMenu; -} - -stock Handle:BuildPlayerHudPanel(iClient, iTarget) -{ - - /** - Create all the string variables we will need - */ - new String:sTargetName[MAX_NAME_LENGTH + 1], - String:sTargetID[64], - String:sTargetIP[16]; - - new String:sDisplayName[MAX_NAME_LENGTH + 1], - String:sDisplayID[64], - String:sDisplayIP[64], - String:sDisplayFrags[16], - String:sDisplayDeaths[16]; - - new iTargetFrags, - iTargetDeaths; - - /** - Get the targets information - */ - GetClientName(iTarget, sTargetName, sizeof(sTargetName)); - GetClientIP(iTarget, sTargetIP, sizeof(sTargetIP)); - GetClientAuthString(iTarget, sTargetID, sizeof(sTargetID)); - iTargetFrags = GetClientFrags(iTarget); - iTargetDeaths = GetClientDeaths(iTarget); - - /** - Format the strings for the menu - */ - Format(sDisplayName, sizeof(sDisplayName), "Player: %s", sTargetName); - Format(sDisplayID, sizeof(sDisplayID), "Steam ID: %s", sTargetID); - Format(sDisplayIP, sizeof(sDisplayIP), "IP Address: %s", sTargetIP); - Format(sDisplayFrags, sizeof(sDisplayFrags), "Kills: %i", iTargetFrags); - Format(sDisplayDeaths, sizeof(sDisplayDeaths), "Deaths: %i", iTargetDeaths); - - /** - Create the menu and set the menu options. - */ - new Handle:hPanel = CreatePanel(); - SetPanelTitle(hPanel, "Simple Spectator"); - - DrawPanelText(hPanel, "Player Information:"); - DrawPanelText(hPanel, sDisplayName); - DrawPanelText(hPanel, sDisplayID); - if (SM_IsValidAdmin(iClient, g_sAdminFlags)) - { - DrawPanelText(hPanel, sDisplayIP); - } - - DrawPanelText(hPanel, sDisplayFrags); - DrawPanelText(hPanel, sDisplayDeaths); - - if (g_aPlayers[iClient][iTargetIndex]) - { - DrawPanelItem(hPanel, "Stop Following"); - } - else - { - DrawPanelItem(hPanel, "Follow Player"); - } - - if ((GetUserFlagBits(iClient) & ADMFLAG_GENERIC) || (GetUserFlagBits(iClient) & ADMFLAG_ROOT)) - { - if (g_aPlayers[iTarget][bIsFlaggedCheater] && (GetUserFlagBits(iClient) & ADMFLAG_ROOT)) - { - DrawPanelItem(hPanel, "Remove Cheater Flag"); - } - else - { - if (CanUserTarget(iClient, iTarget)) - { - DrawPanelItem(hPanel, "Punish Player"); - } - else - { - DrawPanelItem(hPanel, "Punish Player (Immune)", ITEMDRAW_DISABLED); - } - } - } - else - { - DrawPanelItem(hPanel, "Report Cheater"); - } - - DrawPanelItem(hPanel, "Close Hud Panel"); - return hPanel; -} - -/** -Adjust the settings if a convar was changed -*/ -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - for (new iCvar = 0 ; _:iCvar < sizeof(g_aPluginCvarSettings); iCvar++) - { - if (g_aPluginCvar[_:iCvar] == convar) - { - if (StringToInt(newValue) == 1) - { - g_aPluginCvarSettings[_:iCvar] = true; - } - else - { - g_aPluginCvarSettings[_:iCvar] = false; - } - } - } - - /* - ReBuild the global menu that depends on cvars - */ - g_aMenus[hBanTime] = BuildBanTimeMenu(); - - /** - Run a loop to reset the hud - */ - for(new i = 1; i <= MaxClients; i++) - { - StopDisplayingHud(i); - if (IsClientConnected(i) && IsClientInGame(i) && GetClientTeam(i) == g_aCurrentTeams[Spectator]) - { - StartDisplayingHud(i); - } - } -} diff --git a/Simple Message Suppression/addons/sourcemod/scripting/simple-teambalancer.sp b/Simple Message Suppression/addons/sourcemod/scripting/simple-teambalancer.sp deleted file mode 100644 index 3302255..0000000 --- a/Simple Message Suppression/addons/sourcemod/scripting/simple-teambalancer.sp +++ /dev/null @@ -1,1797 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Team Balancer -Description: - Balances teams based upon player count - Player will not be balanced more than once in 5 (default) mins - Buddy system tries to keep buddies together - Ability to prioritize players - Ability to force players to accept the new team - Admins are immune -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include -#include - -#define PLUGIN_VERSION "2.1.$Rev$" - -enum PlayerData -{ - Handle:hBalanceTimer, - Handle:hForcedTimer, - bool:bSwitched, - bool:bFlagCarrier -}; - -/** - Global convar handles - */ -new Handle:stb_enabled = INVALID_HANDLE; -new Handle:stb_buddyenabled = INVALID_HANDLE; -new Handle:stb_logactivity = INVALID_HANDLE; -new Handle:stb_logactivity2 = INVALID_HANDLE; -new Handle:stb_unbalancelimit = INVALID_HANDLE; -new Handle:stb_deadonly = INVALID_HANDLE; -new Handle:stb_priorityenabled = INVALID_HANDLE; -new Handle:stb_uberlevel = INVALID_HANDLE; -new Handle:stb_balancedelay = INVALID_HANDLE; -new Handle:stb_livingplayerswitchdelay = INVALID_HANDLE; -new Handle:stb_livingplayercheckdelay = INVALID_HANDLE; -new Handle:stb_roundstartdelay = INVALID_HANDLE; -new Handle:stb_switchbackforced = INVALID_HANDLE; -new Handle:stb_adminflag = INVALID_HANDLE; -new Handle:stb_buddyrestriction = INVALID_HANDLE; -new Handle:stb_convarcontrol = INVALID_HANDLE; - -/** - Built-in cvars handles - */ -new Handle:stb_mp_autoteambalance = INVALID_HANDLE; -new Handle:stb_mp_teams_unbalance_limit = INVALID_HANDLE; -new Handle:TFGameModeArena = INVALID_HANDLE; - -/** - Timer handles - */ -new Handle:g_hBalanceTimer = INVALID_HANDLE; -new Handle:g_hLivingPlayerCheckTimer = INVALID_HANDLE; - -/** - Player arrays - */ -new g_aPlayers[MAXPLAYERS + 1][PlayerData]; - -/** -Global bools -*/ -new bool:g_bIsEnabled = true; -new bool:g_bPriorityPlayers = true; -new bool:g_bBuddyRestriction = false; -new bool:g_bLogActivity = false; -new bool:g_bLogActivity2 = false; -new bool:g_bDeadOnly = false; -new bool:g_bConVarControl = true; -new bool:g_bBuddyEnabled = true; -new bool:g_bBalanceInProgress = false; -new bool:g_bRoundStart = false; -new bool:g_bRoundEnd = false; -new bool:g_bSuddenDeath = false; -new bool:g_bIsArenaMode = false; - -/** - Global strings/integers/floats - */ -new g_iUnbalanceLimit, g_iLivingPlayerSwitchDelay, g_iLivingPlayerCheckDelay; -new g_iRoundStartDelay, g_iSwitchBackForced, g_iBalanceDelay; -new Float:g_fUberLevel; -new g_iOwnerOffset; -new String:g_sAdminFlag[5]; - -public Plugin:myinfo = -{ - name = "Simple Team Balancer", - author = "Simple Plugins", - description = "Balances teams based upon player count.", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -} - -public OnPluginStart() -{ - - /** - Create console variables - */ - CreateConVar("stb_version", PLUGIN_VERSION, "Simple Team Balancer", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - stb_enabled = CreateConVar("stb_enabled", "1", "Enable or Disable Simple Team Balancer", _, true, 0.0, true, 1.0); - stb_priorityenabled = CreateConVar("stb_priorityenabled", "1", "Enable or Disable the prioritization of living players", _, true, 0.0, true, 1.0); - stb_buddyrestriction = CreateConVar("stb_buddyrestriction", "0", "Enable or Disable Admin Only buddy lists", _, true, 0.0, true, 1.0); - stb_logactivity = CreateConVar("stb_logactivity", "0", "Enable or Disable the disaplying of events in the log", _, true, 0.0, true, 1.0); - stb_logactivity2 = CreateConVar("stb_logactivity2", "0", "Enable or Disable the disaplying of detailed events in the log (WILL SPAM LOG)", _, true, 0.0, true, 1.0); - stb_deadonly = CreateConVar("stb_deadonly", "0", "Enable or Disable the switching of only dead players", _, true, 0.0, true, 1.0); - stb_convarcontrol = CreateConVar("stb_convarcontrol", "1", "Enable or Disable the control of builtin console variables", _, true, 0.0, true, 1.0); - stb_buddyenabled = CreateConVar("stb_buddyenabled", "1", "Enable or Disable the buddy system", _, true, 0.0, true, 1.0); - stb_unbalancelimit = CreateConVar("stb_unbalancelimit", "2", "Amount of players teams are ALLOWED to be unbalanced by", _, true, 1.0, true, 32.0); - stb_balancedelay = CreateConVar("stb_balancedelay", "10", "Delay in seconds to start an autobalance"); - stb_livingplayerswitchdelay = CreateConVar("stb_livingplayerswitchdelay", "20", "Delay in seconds to switch living players once selected"); - stb_livingplayercheckdelay = CreateConVar("stb_livingplayercheckdelay", "10", "Delay in seconds to start checking living players once teams become unbalanced"); - stb_roundstartdelay = CreateConVar("stb_roundstartdelay", "15", "Delay in seconds to start balancing teams after the start of a round"); - stb_switchbackforced = CreateConVar("stb_switchbackforced", "300", "Amount of time in seconds to not switch a player twice and force the team if enabled"); - stb_uberlevel = CreateConVar("stb_uberlevel", "1.0", "Min uber level medic must have to have priority over other living players. Setting to 0 will rarely switch a living medic", _, true, 0.0, true, 1.0); - stb_adminflag = CreateConVar("stb_adminflag", "a", "Admin flag to use for immunity. Must be a in char format."); - stb_mp_autoteambalance = FindConVar("mp_autoteambalance"); - stb_mp_teams_unbalance_limit = FindConVar("mp_teams_unbalance_limit"); - - /** - Removing the notify tags from the built in cvars. We dont want spam. - */ - if (stb_mp_autoteambalance != INVALID_HANDLE) - { - SetConVarFlags(stb_mp_autoteambalance, GetConVarFlags(stb_mp_autoteambalance)^FCVAR_NOTIFY); - } - if (stb_mp_teams_unbalance_limit != INVALID_HANDLE) - { - SetConVarFlags(stb_mp_teams_unbalance_limit, GetConVarFlags(stb_mp_teams_unbalance_limit)^FCVAR_NOTIFY); - } - - /** - Hook console variables - */ - HookConVarChange(stb_enabled, ConVarSettingsChanged); - HookConVarChange(stb_priorityenabled, ConVarSettingsChanged); - HookConVarChange(stb_buddyrestriction, ConVarSettingsChanged); - HookConVarChange(stb_logactivity, ConVarSettingsChanged); - HookConVarChange(stb_logactivity2, ConVarSettingsChanged); - HookConVarChange(stb_deadonly, ConVarSettingsChanged); - HookConVarChange(stb_convarcontrol, ConVarSettingsChanged); - HookConVarChange(stb_buddyenabled, ConVarSettingsChanged); - HookConVarChange(stb_unbalancelimit, ConVarSettingsChanged); - HookConVarChange(stb_balancedelay, ConVarSettingsChanged); - HookConVarChange(stb_livingplayerswitchdelay, ConVarSettingsChanged); - HookConVarChange(stb_livingplayercheckdelay, ConVarSettingsChanged); - HookConVarChange(stb_roundstartdelay, ConVarSettingsChanged); - HookConVarChange(stb_switchbackforced, ConVarSettingsChanged); - HookConVarChange(stb_uberlevel, ConVarSettingsChanged); - HookConVarChange(stb_mp_autoteambalance, ConVarSettingsChanged); - HookConVarChange(stb_mp_teams_unbalance_limit, ConVarSettingsChanged); - - /** - Create console commands - */ - RegConsoleCmd("sm_buddy", Command_AddBalanceBuddy, "Add a balance buddy"); - RegConsoleCmd("sm_lockbuddy", Command_LockBuddy, "Locks your balance buddy selection"); - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook the game events - */ - LogAction(0, -1, "[STB] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_death", HookPlayerDeath, EventHookMode_Post); - HookEvent("player_team", HookPlayerChangeTeam, EventHookMode_Post); - switch (g_CurrentMod) - { - case GameType_TF: - { - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - HookEvent("teamplay_suddendeath_begin", HookSuddenDeathBegin, EventHookMode_PostNoCopy); - HookEvent("teamplay_flag_event", HookFlagEvent, EventHookMode_Post); - TFGameModeArena = FindConVar("tf_gamemode_arena"); - g_iOwnerOffset = FindSendPropInfo("CBaseObject", "m_hBuilder"); - } - case GameType_DOD: - { - HookEvent("dod_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_Post); - } - default: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - } - } - - /** - Load translations and .cfg file - */ - LoadTranslations ("simpleteambalancer.phrases"); - AutoExecConfig(true, "plugin.simpleteambalancer"); - LogAction(0, -1, "[STB] Simple Team Balancer is loaded."); -} - -public OnAllPluginsLoaded() -{ - //something -} - -public OnLibraryRemoved(const String:name[]) -{ - //something -} - -public OnConfigsExecuted() -{ - - /** - Load up global variables - */ - g_bIsEnabled = GetConVarBool(stb_enabled); - g_bBuddyEnabled = GetConVarBool(stb_buddyenabled); - g_bLogActivity = GetConVarBool(stb_logactivity); - g_bLogActivity2 = GetConVarBool(stb_logactivity2); - g_bDeadOnly = GetConVarBool(stb_deadonly); - g_bPriorityPlayers = GetConVarBool(stb_priorityenabled); - g_bBuddyRestriction = GetConVarBool(stb_buddyrestriction); - g_bConVarControl = GetConVarBool(stb_convarcontrol); - g_fUberLevel = GetConVarFloat(stb_uberlevel); - g_iUnbalanceLimit = GetConVarInt(stb_unbalancelimit); - g_iBalanceDelay = GetConVarInt(stb_balancedelay); - g_iLivingPlayerSwitchDelay = GetConVarInt(stb_livingplayerswitchdelay); - g_iLivingPlayerCheckDelay = GetConVarInt(stb_livingplayercheckdelay); - g_iRoundStartDelay = GetConVarInt(stb_roundstartdelay); - g_iSwitchBackForced = GetConVarInt(stb_switchbackforced); - GetConVarString(stb_adminflag, g_sAdminFlag, sizeof(g_sAdminFlag)); - - /** - Report enabled - */ - if (g_bIsEnabled) - { - LogAction(0, -1, "[STB] Simple Team Balancer is ENABLED."); - } - else - { - LogAction(0, -1, "[STB] Simple Team Balancer is DISABLED."); - } - - - /** - Report log activity - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Log Activity ENABLED."); - } - else - { - LogAction(0, -1, "[STB] Log Activity DISABLED."); - } - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Detailed Log Activity ENABLED."); - } - else - { - LogAction(0, -1, "[STB] Detailed Log Activity DISABLED."); - } -} - -public OnMapStart() -{ - - /** - Check for arena mode - */ - if (g_CurrentMod == GameType_TF && GetConVarBool(TFGameModeArena)) - { - g_bIsArenaMode = true; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Simple Team Balancer detected arena mode and will be bypassed"); - } - } - else - { - g_bIsArenaMode = false; - } - - /** - Reset the globals - */ - g_bBalanceInProgress = false; - g_bRoundStart = false; - g_bRoundEnd = false; - g_bSuddenDeath = false; - - /** - Set the built-in convars - */ - SetGameCvars(); -} - -public OnClientPostAdminCheck(client) -{ - - /** - Make sure its a valid connected client and buddy system is enabled - */ - if (client == 0 || !g_bIsEnabled || !IsClientConnected(client) || !g_bBuddyEnabled) - { - return; - } - - /** - Make sure if its set for admins only they have the flags - */ - if (g_bBuddyRestriction && !SM_IsValidAdmin(client, g_sAdminFlag)) - { - return; - } - - /** - Start the advertisement timer - */ - CreateTimer (60.0, Timer_WelcomeAdvert, client); -} - -public OnClientDisconnect(client) -{ - - /** - Call stock function to cleaup - */ - CleanUp(client); -} - -public OnClientDisconnect_Post(client) -{ - - /** - Determine if we need a balance - */ - if (OkToBalance() && IsUnbalanced() && !g_bBalanceInProgress) - { - - /** - No balance in progress but balance is needed - */ - StartABalance(); - } -} - -public SM_OnPlayerMoved(Handle:plugin, client, team) -{ - - /** - Make sure we called the move function - */ - if (plugin != GetMyHandle()) - { - if (g_bLogActivity2) - { - LogAction(0, client, "[STB] Callback was not started with current plugin, bugging out."); - } - return; - } - - /** - Get the players name and report the event - */ - decl String:sPlayerName[64]; - GetClientName(client, sPlayerName, sizeof(sPlayerName)); - if (g_bLogActivity) - { - LogAction(0, client, "[STB] Changed %s to team %i.", sPlayerName, team); - } - - /** - If we are in TF2 fire the bult-in team balance event - */ - if(g_CurrentMod == GameType_TF) - { - new Handle:event = CreateEvent("teamplay_teambalanced_player"); - SetEventInt(event, "player", client); - SetEventInt(event, "team", team); - FireEvent(event); - } - - /** - Notify the players - */ - PrintToChatAll("[SM] %T", "BalanceMessage", LANG_SERVER, sPlayerName); - - /** - Set the players variables and start a timer - */ - g_aPlayers[client][bSwitched] = true; - g_aPlayers[client][hForcedTimer] = CreateTimer(float(g_iSwitchBackForced), Timer_ForcedExpired, client, TIMER_FLAG_NO_MAPCHANGE); - - /** - We are done, log the completion and end the balance - */ - if (g_bLogActivity) - { - LogAction(0, client, "[STB] Balance finished."); - } - g_bBalanceInProgress = false; -} - -/* HOOKED EVENTS */ - -public HookPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get our event variables - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - decl String:sWeapon[64]; - GetEventString(event, "weapon", sWeapon, sizeof(sWeapon)); - - /** - Return if death was not caused by a player - This is the case when the player switches teams - */ - if (StrEqual(sWeapon, "world", false)) - { - return; - } - - - /** - Check if balance is needed - */ - if (IsClientInGame(iClient) && OkToBalance() && IsUnbalanced()) - { - new iSmallerTeam = GetSmallerTeam(); - - /** - Check if balance is in progress - */ - if (g_bBalanceInProgress) - { - - /** - There is a balance in progress - Check the player who died to see if he is supposed to be switched - */ - if (g_aPlayers[iClient][hBalanceTimer] != INVALID_HANDLE) - { - - /** - The player has a timer on him to switch him to other team - Stop the timer - */ - CloseHandle(g_aPlayers[iClient][hBalanceTimer]); - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - if (g_bLogActivity) - { - LogAction(0, iClient, "[STB] With a balance in progress the queued living player died and was switched."); - } - - /** - Call the stock change team function - */ - BalancePlayer(iClient, SM_GetForcedTeam(iClient)); - return; - } - - /** - Before we continue, lets make sure the client is switchable - */ - if (IsSwitchablePlayer(iClient, GetBiggerTeam())) - { - - /** - Now we check the buddy system - */ - if (g_bBuddyEnabled) - { - - /** - Buddy system is enabled, check to see if client has buddy - */ - new iBuddyIndex = SM_GetClientBuddy(iClient); - if (iBuddyIndex != 0 || !IsClientConnected(iBuddyIndex) || !IsClientInGame(iBuddyIndex)) - { - - /** - The client has a buddy, so we check to see if they are on same team - */ - if (GetClientTeam(iClient) == GetClientTeam(iBuddyIndex)) - { - - /** - They are, but we don't bug out, we still need to start a balance - */ - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] With a balance in progress a buddy on the right team was found and skipped."); - } - } - else - { - - /** - They are not on the same team - The buddy could be in spec, and that would make it not matter where he is, or the buddy is on the smaller team - */ - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] With a balance in progress a buddy on the wrong team was switched."); - } - BalancePlayer(iClient, iSmallerTeam); - return; - } - } - else - { - - /** - Client doesn't have a buddy, balance this player - */ - BalancePlayer(iClient, iSmallerTeam); - return; - } - } - else - { - - /** - Buddy system is not enabled, balance this player - */ - BalancePlayer(iClient, iSmallerTeam); - return; - } - } - } - else - { - - /** - If we get to here then we must need to start a balance - */ - StartABalance(); - } - } -} - -public HookPlayerChangeTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get our event variables. - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - new iTeam = GetEventInt(event, "team"); - - /** - Make sure its ok to balance. - */ - if (OkToBalance()) - { - - /** - See if the client that changed teams was set to with a balance. - */ - if (g_aPlayers[iClient][hBalanceTimer] != INVALID_HANDLE - && SM_GetForcedTeam(iClient) == iTeam - && g_bBalanceInProgress) - { - - /** - The client was set to be balanced, so we close the timer. - */ - CloseHandle(g_aPlayers[iClient][hBalanceTimer]); - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - - /** - Stop the balance. - */ - g_bBalanceInProgress = false; - return; - } - - /** - It's not likely that this team change can cause us to need a balance. - If it does, start one with a small dealy to deal with forced switch backs. - */ - if (IsUnbalanced() && !g_bBalanceInProgress) - { - CreateTimer(2.0, Timer_ChangeTeamBalanceDelay, _, TIMER_FLAG_NO_MAPCHANGE); - } - } -} - -public HookRoundStart(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Set the variables we need to start a round - */ - g_bRoundStart = true; - g_bRoundEnd = false; - g_bSuddenDeath = false; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Round Started"); - } - - /** - Start a delayed balance check at the start of the round - */ - CreateTimer(float(g_iRoundStartDelay), Timer_RoundStart); -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Set the variables we need at round end - */ - g_bRoundEnd = true; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Round Ended"); - } -} - -public HookSuddenDeathBegin(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Set the variables we need for sudden death - */ - g_bSuddenDeath = true; -} - -public HookFlagEvent(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get our event variables - */ - new iClient = GetEventInt(event, "player"); - new iFlagStatus = GetEventInt(event, "eventtype"); - - /** - Make sure we have a valid client - */ - if (!IsClientInGame(iClient)) - { - return; - } - - /** - Determine what kind of event this is - */ - switch (iFlagStatus) - { - case 1: - { - - /** - The flag was picked up - */ - g_aPlayers[iClient][bFlagCarrier] = true; - } - case 2: - { - - /** - The flag was capped - */ - g_aPlayers[iClient][bFlagCarrier] = false; - } - case 3: - { - - /** - The flag was defended, we don't have to do anything - */ - } - case 4: - { - - /** - The flag was dropped - */ - g_aPlayers[iClient][bFlagCarrier] = false; - } - } -} - -/* COMMAND EVENTS */ - -public Action:Command_AddBalanceBuddy(client, args) -{ - if (client == 0) - { - ReplyToCommand(client, "[SM] %T", "PlayerLevelCmd", LANG_SERVER); - return Plugin_Handled; - } - if (!g_bIsEnabled || !g_bBuddyEnabled) - { - ReplyToCommand(client, "[SM] %T", "CmdDisabled", LANG_SERVER); - return Plugin_Handled; - } - if (g_bBuddyRestriction) - { - if (!SM_IsValidAdmin(client, g_sAdminFlag)) - { - ReplyToCommand(client, "[SM] %T", "RestrictedBuddy", LANG_SERVER); - return Plugin_Handled; - } - } - decl String:sPlayerUserId[24]; - GetCmdArg(1, sPlayerUserId, sizeof(sPlayerUserId)); - new iPlayer = GetClientOfUserId(StringToInt(sPlayerUserId)); - if (!iPlayer || !IsClientInGame(iPlayer) || client == iPlayer) - { - if (client == iPlayer) - { - PrintHintText(client, "%T", "SelectSelf", LANG_SERVER); - } - ReplyToCommand(client, "[SM] Usage: buddy "); - new Handle:playermenu = BuildPlayerMenu(); - DisplayMenu(playermenu, client, MENU_TIME_FOREVER); - } - else - { - decl String:cName[128]; - decl String:bName[128]; - GetClientName(client, cName, sizeof(cName)); - GetClientName(iPlayer, bName, sizeof(bName)); - if (SM_IsBuddyLocked(iPlayer)) - { - ReplyToCommand(client, "[SM] %T", "PlayerLockedBuddyMsg", LANG_SERVER, bName); - return Plugin_Handled; - } - SM_AssignBuddy(client, iPlayer); - PrintHintText(client, "%T", "BuddyMsg", LANG_SERVER, bName); - PrintHintText(iPlayer, "%T", "BuddyMsg", LANG_SERVER, cName); - } - return Plugin_Handled; -} - -public Action:Command_LockBuddy(client, args) -{ - if (client == 0) - { - ReplyToCommand(client, "[SM] %T", "PlayerLevelCmd", LANG_SERVER); - return Plugin_Handled; - } - if (!g_bIsEnabled) - { - ReplyToCommand(client, "[SM] %T", "CmdDisabled", LANG_SERVER); - return Plugin_Handled; - } - if (g_bBuddyRestriction) - { - if (!SM_IsValidAdmin(client, g_sAdminFlag)) - { - ReplyToCommand(client, "[SM] %T", "RestrictedBuddy", LANG_SERVER); - return Plugin_Handled; - } - } - if (SM_IsBuddyLocked(client)) - { - SM_LockBuddy(client, false); - PrintHintText(client, "%T", "BuddyLockMsgDisabled", LANG_SERVER); - } - else - { - SM_LockBuddy(client, true); - PrintHintText(client, "%T", "BuddyLockMsgEnabled", LANG_SERVER); - } - return Plugin_Handled; -} - -/** -Stock functions . - */ - -stock bool:IsUnbalanced() -{ - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Checking if teams are unbalanced"); - } - new Team1Count = GetTeamClientCount(g_aCurrentTeams[Team1]); - new Team2Count = GetTeamClientCount(g_aCurrentTeams[Team2]); - new ubCount = RoundFloat(FloatAbs(float(Team1Count - Team2Count))); - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Team1:%i Team2:%i Difference:%i", Team1Count, Team2Count, ubCount); - } - if (ubCount > g_iUnbalanceLimit) - { - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Teams are unbalanced"); - } - return true; - } - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Teams are not unbalanced"); - } - return false; -} - -stock bool:OkToBalance() -{ - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Checking if OK to balance."); - } - new bool:bResult = false; - if (g_bIsEnabled && !g_bRoundStart && !g_bRoundEnd && !g_bIsArenaMode && !g_bSuddenDeath) - { - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Passed IF statement"); - LogAction(0, -1, "[STB] Now checking admins"); - } - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientInGame(i) && !SM_IsValidAdmin(i, g_sAdminFlag)) - { - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Found at least 1 non-admin"); - LogAction(0, -1, "[STB] OK to balance"); - } - bResult = true; - break; - } - } - if (!bResult && g_bLogActivity2) - { - LogAction(0, -1, "[STB] All admins online"); - } - } - if (!bResult && g_bLogActivity2) - { - LogAction(0, -1, "[STB] Not OK to balance"); - } - return bResult; -} - -stock bool:IsSwitchablePlayer(iClient, iBiggerTeam) -{ - - /** - Run the client thru some standard checks - */ - if (!IsClientInGame(iClient) - || SM_IsValidAdmin(iClient, g_sAdminFlag) - || g_aPlayers[iClient][bFlagCarrier] - || GetClientTeam(iClient) != iBiggerTeam - || g_aPlayers[iClient][bSwitched]) - { - - /** - The supplied client can't be switched - */ - return false; - } - - /** - The supplied client can be switched - */ - return true; -} - -stock bool:HasUber(iClient) -{ - - /** - First things first, make sure the client is a medic - */ - if(TF2_GetPlayerClass(iClient) == TFClass_Medic) - { - - /** - We can only check the active weapon, so make sure the client is holding the uber gun - */ - decl String:sWeaponName[32]; - GetClientWeapon(iClient, sWeaponName, sizeof(sWeaponName)); - if(StrEqual(sWeaponName, "tf_weapon_medigun")) - { - - /** - They are, so lets check the uber level of the gun - */ - new iEntityIndex = GetEntDataEnt2(iClient, FindSendPropInfo("CTFPlayer", "m_hActiveWeapon")); - new Float:fChargeLevel = GetEntDataFloat(iEntityIndex, FindSendPropInfo("CWeaponMedigun", "m_flChargeLevel")); - if (fChargeLevel >= g_fUberLevel) - { - - /** - The client supplied has an uber above the supplied level, return true - */ - if (g_bLogActivity2) - { - LogAction(0, iClient, "[STB] Found a medic with a uber and skipped him."); - } - return true; - } - } - } - - /** - The client supplied does not have an uber above the supplied level, return false - */ - return false; -} - -stock bool:HasBuildingsBuilt(iClient) -{ - - /** - We have to start a loop to check the owner of all the valid entities - */ - new iMaxEntities = GetMaxEntities(); - for (new i = MaxClients + 1; i <= iMaxEntities; i++) - { - if (!IsValidEntity(i)) - { - - /** - Not valid, continue to next one - */ - continue; - } - - /** - Get the name of the current entity - */ - decl String:sNetClass[32]; - GetEntityNetClass(i, sNetClass, sizeof(sNetClass)); - - /** - See if its something that an engineer would build - */ - if (strcmp(sNetClass, "CObjectSentrygun") == 0 - || strcmp(sNetClass, "CObjectTeleporter") == 0 - || strcmp(sNetClass, "CObjectDispenser") == 0) - { - - /** - It is, so lets check the owner - */ - if (GetEntDataEnt2(i, g_iOwnerOffset) == iClient) - { - - /** - The client supplied is the owner, return true - */ - if (g_bLogActivity2) - { - LogAction(0, iClient, "[STB] Found an engineer with buildings and skipped him."); - } - return true; - } - } - } - - /** - The client supplied didn't have any buildings, return false - */ - return false; -} - -stock StartABalance() -{ - - /** - See if we are already started a balance - */ - if (g_hBalanceTimer != INVALID_HANDLE) - { - - /** - We have, check if we still need to - */ - if (!IsUnbalanced() || !OkToBalance()) - { - - /** - We don't, stop the balance - It's almost impossible to reach this code, but we do it just in case - */ - CloseHandle(g_hBalanceTimer); - g_hBalanceTimer = INVALID_HANDLE; - g_bBalanceInProgress = false; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Balance delay timer was not needed and was killed before the callback."); - } - return; - } - else - { - - /** - We still need to balance - Bug out and wait for the current one to finish - */ - return; - } - } - - /** - Report that teams are unbalanced - */ - PrintToChatAll("[SM] %T", "UnBalanced", LANG_SERVER); - - /** - Check to see if we are supposed to delay the balance - */ - if (g_iBalanceDelay == 0) - { - - /** - Start the balance now - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Balance is now in progress."); - } - g_bBalanceInProgress = true; - g_hBalanceTimer = INVALID_HANDLE; - - /** - Check if we are allowed to scan living players - */ - if (!g_bDeadOnly) - { - - /** - We are allowed to, so we start a timer - */ - StartALivingPlayerTimer(); - - /** - Also report that we are now scanning dead players as well - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Now scanning dead players."); - } - } - else - { - - /** - We are not allowed to, so report that we are only scanning dead players - */ - if (g_bLogActivity) - LogAction(0, -1, "[STB] Only scanning dead players."); - } - - /** - We started the balance, bug out - */ - return; - } - - /** - We are supposed to delay the balance, start a balance timer - */ - g_hBalanceTimer = CreateTimer(float(g_iBalanceDelay), Timer_BalanceTeams, _, TIMER_FLAG_NO_MAPCHANGE); - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Teams are unbalanced. Balance delay timer started."); - } -} - -stock StartALivingPlayerTimer() -{ - - /** - Start a timer to check living players - */ - if (g_hLivingPlayerCheckTimer != INVALID_HANDLE) - { - - /** - If we for some reason already have one started, stop it. - */ - CloseHandle(g_hLivingPlayerCheckTimer); - g_hLivingPlayerCheckTimer = INVALID_HANDLE; - } - - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Living player balance delay timer started."); - } - g_hLivingPlayerCheckTimer = CreateTimer(float(g_iLivingPlayerCheckDelay), Timer_LivingPlayerCheck, _, TIMER_FLAG_NO_MAPCHANGE); -} - -stock FindSwitchablePlayer() -{ - - /** - Start a loop to find a switchable player - */ - new iPlayer; - new iBiggerTeam = GetBiggerTeam(); - for (new i = 1; i <= MaxClients; i++) - { - - /** - Check the stock function to see if we are allows to even switch the player - */ - if (!IsSwitchablePlayer(i, iBiggerTeam)) - { - continue; - } - - /** - If the mod is TF2 and they have Priority Players set check if the client has buildings or an uber - */ - if (g_CurrentMod == GameType_TF && g_bPriorityPlayers) - { - if (HasUber(i) || HasBuildingsBuilt(i)) - { - continue; - } - } - - /** - So far we are able we switch this player - Now we check the buddy system - */ - if (g_bBuddyEnabled) - { - - /** - Buddy system is enabled, check to see if client has buddy - */ - if (SM_GetClientBuddy(i) != 0) - { - - /** - The client has a buddy, so we check to see if they are on same team - */ - if (GetClientTeam(i) == GetClientTeam(SM_GetClientBuddy(i))) - { - - /** - They are, so we continue to next client - */ - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] With a balance in progress a buddy on the right team was found and skipped."); - } - continue; - } - else - { - - /** - They are not on the same team, set this client - The buddy could be in spec, and that would make it not matter where he is, or the buddy is on the smaller team - */ - iPlayer = i; - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] With a balance in progress a buddy on the wrong team was found."); - } - break; - } - } - else - { - - /** - The client does not have a buddy, set this client - */ - iPlayer = i; - break; - } - } - else - { - - /** - Buddy system is not enabled, set this client - */ - iPlayer = i; - break; - } - } - - /** - Return the client we set, this could be 0, but very unlikely - */ - return iPlayer; -} - -stock BalancePlayer(iClient, iTeam) -{ - new Handle:hPack = CreateDataPack(); - WritePackCell(hPack, iClient); - WritePackCell(hPack, iTeam); - CreateTimer(0.1, Timer_BalancePlayer, hPack, TIMER_FLAG_NO_MAPCHANGE); -} - -stock CleanUp(iClient) -{ - g_aPlayers[iClient][bFlagCarrier] = false; - g_aPlayers[iClient][bSwitched] = false; - if (g_aPlayers[iClient][hForcedTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[iClient][hForcedTimer]); - g_aPlayers[iClient][hForcedTimer] = INVALID_HANDLE; - if (g_bLogActivity) - { - LogAction(0, iClient, "[STB] Forced player disconnected, killing timer."); - } - } - if (g_aPlayers[iClient][hBalanceTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[iClient][hBalanceTimer]); - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - if (g_bLogActivity) - { - LogAction(0, iClient, "[STB] Living player set to be balanced disconnected, killing timer."); - } - } -} - -stock GetSmallerTeam() -{ - - /** - Get the count of players on each team - */ - new iCountT1 = GetTeamClientCount(g_aCurrentTeams[Team1]); - new iCountT2 = GetTeamClientCount(g_aCurrentTeams[Team2]); - - /** - Return the smaller team - */ - if (iCountT1 < iCountT2) - { - return g_aCurrentTeams[Team1]; - } - else if (iCountT1 > iCountT2) - { - return g_aCurrentTeams[Team2]; - } - return 0; -} - -stock GetBiggerTeam() -{ - - /** - Get the count of players on each team - */ - new iCountT1 = GetTeamClientCount(g_aCurrentTeams[Team1]); - new iCountT2 = GetTeamClientCount(g_aCurrentTeams[Team2]); - - /** - Return the bigger team - */ - if (iCountT1 > iCountT2) - { - return g_aCurrentTeams[Team1]; - } - else if (iCountT1 < iCountT2) - { - return g_aCurrentTeams[Team2]; - } - return 0; -} - -stock SetGameCvars() -{ - if (g_bConVarControl && g_bIsEnabled) - { - if (stb_mp_autoteambalance != INVALID_HANDLE) - { - SetConVarInt(stb_mp_autoteambalance, 0); - } - if (stb_mp_teams_unbalance_limit != INVALID_HANDLE) - { - SetConVarInt(stb_mp_teams_unbalance_limit, g_iUnbalanceLimit); - } - } -} - -/* TIMER FUNCTIONS */ - -public Action:Timer_ChangeTeamBalanceDelay(Handle:timer, any:data) -{ - - /** - Finally start one if it's still unbalanced - */ - if (IsUnbalanced() && !g_bBalanceInProgress) - { - StartABalance(); - } -} - -public Action:Timer_BalanceTeams(Handle:timer, any:data) -{ - - /** - See if we still need to balance the teams - */ - if (!IsUnbalanced() || !OkToBalance()) - { - - /** - We don't, kill the balance - */ - g_bBalanceInProgress = false; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Balance delay timer was not needed and died."); - } - g_hBalanceTimer = INVALID_HANDLE; - return Plugin_Handled; - } - - /** - We still need to balance the teams - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Teams are still unbalanced. Balance is now in progress."); - } - g_bBalanceInProgress = true; - - - /** - Check if we are allowed to scan living players - */ - if (!g_bDeadOnly) - { - - /** - We are allowed to, so we start a timer - */ - StartALivingPlayerTimer(); - - /** - Also report that we are now scanning dead players as well - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Now scanning dead players."); - } - } - else - { - - /** - We are not allowed to, so report that we are only scanning dead players - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Only scanning dead players."); - } - } - - g_hBalanceTimer = INVALID_HANDLE; - return Plugin_Handled; -} - -public Action:Timer_LivingPlayerCheck(Handle:timer, any:data) -{ - - /** - Check to see if we still need to balance the teams - */ - if (!IsUnbalanced() || !OkToBalance()) - { - - /** - We don't, kill it and bug out - */ - g_bBalanceInProgress = false; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Living player balance delay timer was not needed and died."); - } - g_hLivingPlayerCheckTimer = INVALID_HANDLE; - return Plugin_Handled; - } - - /** - Call the stock function to find a player we can switch - */ - new iPlayer = FindSwitchablePlayer(); - - /** - Check to see if we found a player - */ - if (iPlayer == 0) - { - - /** - In the unlikely event that the stock function didn't return a player - Start a loop to find a random player - */ - new iBiggerTeam = GetBiggerTeam(); - do - { - iPlayer = GetRandomInt(1, MaxClients); - } while (!IsSwitchablePlayer(iPlayer, iBiggerTeam)); - - if (g_bLogActivity) - { - LogAction(0, iPlayer, "[STB] Found a random living player."); - } - } - else - { - if (g_bLogActivity) - { - LogAction(0, iPlayer, "[STB] Found a living player."); - } - } - - /** - Now that we have a player assigned them to the smaller team - */ - new iSmallerTeam = GetSmallerTeam(); - SM_SetForcedTeam(iPlayer, iSmallerTeam, true); - - /** - Let the player know we could be switching him soon - */ - PrintHintText(iPlayer, "%T", "PlayerMessage", LANG_SERVER, g_iLivingPlayerSwitchDelay); - if (g_bLogActivity) - { - LogAction(0, iPlayer, "[STB] Living player placed on a timer."); - } - - /** - Create a timer to switch the player - */ - g_aPlayers[iPlayer][hBalanceTimer] = CreateTimer(float(g_iLivingPlayerSwitchDelay), Timer_LivingPlayerBalance, iPlayer, TIMER_FLAG_NO_MAPCHANGE); - - /** - Reset the timer handle - */ - g_hLivingPlayerCheckTimer = INVALID_HANDLE; - - /** - We are done, bug out - */ - return Plugin_Handled; -} - -public Action:Timer_LivingPlayerBalance(Handle:timer, any:iClient) -{ - - /** - Check to make sure we still need to balance - */ - if (!IsUnbalanced() || !OkToBalance()) - { - - /** - We don't need to balance, bug out - */ - g_bBalanceInProgress = false; - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - SM_ClearForcedTeam(iClient); - return Plugin_Handled; - } - - /** - We still need to balance, lets make sure we can still balance this player - */ - if (!IsClientConnected(iClient) || g_aPlayers[iClient][bFlagCarrier]) - { - g_bBalanceInProgress = false; - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - SM_ClearForcedTeam(iClient); - if (g_bLogActivity) - { - if (g_aPlayers[iClient][bFlagCarrier]) - { - LogAction(0, iClient, "[STB] Living player became flag carrier, balance restarted."); - } - else - { - LogAction(0, iClient, "[STB] Living player timer was not needed and died."); - } - } - return Plugin_Handled; - } - - /** - Clear to balance this player, so do it - */ - BalancePlayer(iClient, SM_GetForcedTeam(iClient)); - if (g_bLogActivity) - { - LogAction(0, iClient, "[STB] Living player was switched."); - } - - /** - We are done, bug out - */ - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - return Plugin_Handled; -} - -public Action:Timer_BalancePlayer(Handle:timer, Handle:pack) -{ - - /** - Rest the datapack and load the variables - */ - ResetPack(pack); - new iClient = ReadPackCell(pack); - new iUnBalancedTeam = ReadPackCell(pack); - - /** - We are done with you now - */ - CloseHandle(pack); - - /** - Check the team and make sure its a valid team - */ - if(!SM_IsValidTeam(iUnBalancedTeam)) - { - if (g_bLogActivity) - { - LogAction(0, iClient, "[STB] Balance failed due to invalid team number %i", iUnBalancedTeam); - } - return Plugin_Handled; - } - - /** - Use our core function to change the clients team - */ - SM_MovePlayer(iClient, iUnBalancedTeam); - - return Plugin_Handled; -} - -public Action:Timer_RoundStart(Handle:timer, any:data) -{ - g_bRoundStart = false; - if (OkToBalance() && IsUnbalanced() && !g_bBalanceInProgress) - { - StartABalance(); - } - return Plugin_Handled; -} - -public Action:Timer_ForcedExpired(Handle:timer, any:iClient) -{ - SM_ClearForcedTeam(iClient); - g_aPlayers[iClient][bSwitched] = false; - g_aPlayers[iClient][hForcedTimer] = INVALID_HANDLE; - return Plugin_Handled; -} - -public Action:Timer_WelcomeAdvert(Handle:timer, any:iClient) -{ - if (IsClientConnected(iClient) && IsClientInGame(iClient)) - { - PrintToChat (iClient, "\x01\x04[STB]\x01 %T", "BuddyWelcomeMsg1", LANG_SERVER); - PrintToChat (iClient, "\x01\x04[STB]\x01 %T", "BuddyWelcomeMsg2", LANG_SERVER); - PrintToChat (iClient, "\x01\x04[STB]\x01 %T", "BuddyWelcomeMsg3", LANG_SERVER); - } - return Plugin_Handled; -} - -/* CONSOLE VARIABLE CHANGE EVENT */ - -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (convar == stb_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsEnabled = false; - PrintToChatAll("[SM] %T", "Disabled", LANG_SERVER); - LogAction(0, -1, "[SimpleTeamBalancer] Disabled"); - } - else - { - g_bIsEnabled = true; - SetGameCvars(); - PrintToChatAll("[SM] %T", "Enabled", LANG_SERVER); - LogAction(0, -1, "[SimpleTeamBalancer] Enabled"); - } - } - else if (convar == stb_logactivity) - { - if (StringToInt(newValue) == 0) - { - g_bLogActivity = false; - LogAction(0, -1, "[STB] Log Activity DISABLED."); - } - else - { - g_bLogActivity = true; - LogAction(0, -1, "[STB] Log Activity ENABLED."); - } - } - else if (convar == stb_logactivity2) - { - if (StringToInt(newValue) == 0) - { - g_bLogActivity2 = false; - LogAction(0, -1, "[STB] Detailed Log Activity DISABLED."); - } - else - { - g_bLogActivity2 = true; - LogAction(0, -1, "[STB] Detailed Log Activity ENABLED."); - } - } - else if (convar == stb_convarcontrol) - { - if (StringToInt(newValue) == 0) - { - g_bConVarControl = false; - } - else - { - g_bConVarControl = true; - SetGameCvars(); - } - } - else if (convar == stb_deadonly) - { - if (StringToInt(newValue) == 0) - { - g_bDeadOnly = false; - } - else - { - g_bDeadOnly = true; - } - } - else if (convar == stb_priorityenabled) - { - if (StringToInt(newValue) == 0) - { - g_bPriorityPlayers = false; - } - else - { - g_bPriorityPlayers = true; - } - } - else if (convar == stb_buddyenabled) - { - if (StringToInt(newValue) == 0) - { - g_bBuddyEnabled = false; - } - else - { - g_bBuddyEnabled = true; - } - } - else if (convar == stb_buddyrestriction) - { - if (StringToInt(newValue) == 0) - { - g_bBuddyRestriction = false; - } - else - { - g_bBuddyRestriction = true; - } - } - else if (convar == stb_unbalancelimit) - { - g_iUnbalanceLimit = StringToInt(newValue); - SetGameCvars(); - } - else if (convar == stb_balancedelay) - { - g_iBalanceDelay = StringToInt(newValue); - } - else if (convar == stb_roundstartdelay) - { - g_iRoundStartDelay = StringToInt(newValue); - } - else if (convar == stb_livingplayerswitchdelay) - { - g_iLivingPlayerSwitchDelay = StringToInt(newValue); - } - else if (convar == stb_livingplayercheckdelay) - { - g_iLivingPlayerCheckDelay = StringToInt(newValue); - } - else if (convar == stb_uberlevel) - { - g_fUberLevel = StringToFloat(newValue); - } - else if (convar == stb_switchbackforced) - { - g_iSwitchBackForced = StringToInt(newValue); - } - else if (convar == stb_adminflag) - { - SetConVarString(stb_adminflag, newValue); - } - else if (convar == stb_mp_autoteambalance) - { - SetGameCvars(); - } - else if (convar == stb_mp_teams_unbalance_limit) - { - SetGameCvars(); - } -} - -/* MENU CODE */ - -stock Handle:BuildPlayerMenu() -{ - new Handle:menu = CreateMenu(Menu_SelectPlayer); - AddTargetsToMenu(menu, 0, true, false); - SetMenuTitle(menu, "Select A Player:"); - SetMenuExitButton(menu, true); - return menu; -} - -public Menu_SelectPlayer(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[24]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - new buddy = GetClientOfUserId(StringToInt(sSelection)); - if (param1 == buddy) { - PrintHintText(param1, "%T", "SelectSelf", LANG_SERVER); - } else if (!IsClientInGame(buddy)) { - PrintHintText(param1, "%T", "BuddyGone", LANG_SERVER); - } else { - decl String:cName[128]; - decl String:bName[128]; - GetClientName(param1, cName, sizeof(cName)); - GetClientName(buddy, bName, sizeof(bName)); - if (!SM_IsBuddyLocked(buddy)) { - SM_AssignBuddy(param1, buddy); - PrintHintText(param1, "%T", "BuddyMsg", LANG_SERVER, bName); - PrintHintText(buddy, "%T", "BuddyMsg", LANG_SERVER, cName); - } else - PrintHintText(param1, "%T", "PlayerLockedBuddyMsg", LANG_SERVER, bName); - } - } else if (action == MenuAction_End) { - CloseHandle(menu); - } -} \ No newline at end of file diff --git a/Simple Message Suppression/addons/sourcemod/scripting/simple-teammanager.sp b/Simple Message Suppression/addons/sourcemod/scripting/simple-teammanager.sp deleted file mode 100644 index 008f443..0000000 --- a/Simple Message Suppression/addons/sourcemod/scripting/simple-teammanager.sp +++ /dev/null @@ -1,1351 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Team Manager -Description: - Manges players and their team - Admin menu integration - Allows admins/donators to swap their teams (clears force)* - Allows admins to move players to a team (forced\unforced)* - Allows admins to scramble the teams* - *Works with Simple Team Balancer (if installed) -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include - -#define PLUGIN_VERSION "2.1.$Rev$" -#define VOTE_YES "##YES##" -#define VOTE_NO "##NO##" - -enum PlayerData -{ - iNewTeam, - bool:bQueue -}; - -new Handle:stm_enabled = INVALID_HANDLE; -new Handle:stm_logactivity = INVALID_HANDLE; -new Handle:stm_adminflag_swapteam = INVALID_HANDLE; -new Handle:stm_adminflag_moveplayer = INVALID_HANDLE; -new Handle:stm_adminflag_scramble = INVALID_HANDLE; -new Handle:stm_scrambledelay = INVALID_HANDLE; -new Handle:stm_voteenabled = INVALID_HANDLE; -new Handle:stm_votewin = INVALID_HANDLE; -new Handle:stm_votedelay = INVALID_HANDLE; -new Handle:stm_mp_bonusroundtime = INVALID_HANDLE; -new Handle:g_hAdminMenu = INVALID_HANDLE; -new Handle:g_hTimerPrepScramble = INVALID_HANDLE; -new Handle:g_hTimerClearScrambleForce = INVALID_HANDLE; - -new g_aPlayers[MAXPLAYERS + 1][PlayerData]; - -new bool:g_bIsEnabled = true; -new bool:g_bVoteEnabled = true; -new bool:g_bLogActivity = true; -new bool:g_bScrambleRoundEnd = false; -new g_iVoteDelay, g_iLastVoteTime, g_iTimeLeft; -new Float:g_fScrambleDelay, Float:g_fVoteWin; - -public Plugin:myinfo = -{ - name = "Simple Team Manager", - author = "Simple Plugins", - description = "Manages players and thier team.", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -}; - -public OnPluginStart() -{ - - /** - Need to create all of our console variables. - */ - CreateConVar("stm_version", PLUGIN_VERSION, "Simple Team Manager Version",FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - stm_enabled = CreateConVar("stm_enabled", "1", "Enable or Disable Simple Team Manager", _, true, 0.0, true, 1.0); - stm_logactivity = CreateConVar("stm_logactivity", "0", "Enable or Disable the disaplying of events in the log", _, true, 0.0, true, 1.0); - stm_adminflag_swapteam = CreateConVar("stm_adminflag_swapteam", "a", "Admin flag to use for the swapteam command. Must be a in char format."); - stm_adminflag_moveplayer = CreateConVar("stm_adminflag_moveplayer", "c", "Admin flag to use for the moveplayer command. Must be a in char format."); - stm_adminflag_scramble = CreateConVar("stm_adminflag_scramble", "c", "Admin flag to use for the scrambleteam command. Must be a in char format."); - stm_scrambledelay = CreateConVar("stm_scrambledelay", "15", "Delay to scramble teams"); - stm_voteenabled = CreateConVar("stm_voteenabled", "1", "Enable or Disable voting to scramble the teams", _, true, 0.0, true, 1.0); - stm_votewin = CreateConVar("stm_votewin", "0.45", "Win percentage vote must win by", _, true, 0.0, true, 1.0); - stm_votedelay = CreateConVar("stm_votedelay", "600", "Delay before another vote can be cast"); - stm_mp_bonusroundtime = FindConVar("mp_bonusroundtime"); - - - /** - Need deal with changes to the console variables after the plugin is loaded. - We could not do this and just call the actual console variable each time we need it, but it's not efficent. - */ - HookConVarChange(stm_enabled, ConVarSettingsChanged); - HookConVarChange(stm_logactivity, ConVarSettingsChanged); - HookConVarChange(stm_scrambledelay, ConVarSettingsChanged); - HookConVarChange(stm_voteenabled, ConVarSettingsChanged); - HookConVarChange(stm_votewin, ConVarSettingsChanged); - HookConVarChange(stm_votedelay, ConVarSettingsChanged); - - /** - Need to register the commands we are going to create and use. - */ - RegConsoleCmd("sm_swapteam", Command_SwapTeam, "sm_swapteam <[0]instant/[1]queued>: Swaps your team to the other team"); - RegConsoleCmd("sm_moveplayer", Command_MovePlayer, "sm_moveplayer <[0]instant/[1]ondeath> <[0]unforced/[1]forced>: Moves a player to the specified team"); - RegConsoleCmd("sm_scrambleteams", Command_ScrambleTeams, "sm_scrambleteams: <[0]now/[1]roundend> <[0]dontrestart/[1]restartround> Scrambles the current teams"); - RegConsoleCmd("sm_votescramble", Command_VoteScramble, "sm_votescramble: Starts a vote to scramble the teams"); - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook the game events - */ - LogAction(0, -1, "[STM] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_death", HookPlayerDeath, EventHookMode_Post); - HookEvent("player_team", HookPlayerChangeTeam, EventHookMode_Post); - switch (g_CurrentMod) - { - case GameType_TF: - { - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - } - case GameType_DOD: - { - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_Post); - } - default: - { - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - } - } - - /** - Now we have to deal with the admin menu. If the admin library is loaded call the function to add our items. - */ - new Handle:gTopMenu; - if (LibraryExists("adminmenu") && ((gTopMenu = GetAdminTopMenu()) != INVALID_HANDLE)) - { - OnAdminMenuReady(gTopMenu); - } - - /** - Load translations and .cfg file - */ - LoadTranslations ("simpleteammanager.phrases"); - AutoExecConfig(true, "plugin.simpleteammanager"); - LogAction(0, -1, "[STM] Simple Team Manager is loaded."); -} - -public OnAllPluginsLoaded() -{ - //something -} - -public OnLibraryRemoved(const String:name[]) -{ - if (StrEqual(name, "adminmenu")) - { - - /** - Looks like the admin menu was removed. Set the global. - */ - g_hAdminMenu = INVALID_HANDLE; - } - else if (StrEqual(name, "simpleplugins")) - { - SetFailState("Required plugin Simple SourceMod Plugins Core was removed."); - } -} - -public OnConfigsExecuted() -{ - - /** - Once we loaded up all the console variables from the config file, lets now set all the global variables we will use. - */ - g_bIsEnabled = GetConVarBool(stm_enabled); - g_bLogActivity = GetConVarBool(stm_logactivity); - g_fScrambleDelay = GetConVarFloat(stm_scrambledelay); - g_iVoteDelay = GetConVarInt(stm_votedelay); - g_fVoteWin = GetConVarFloat(stm_votewin); - g_iLastVoteTime = RoundFloat(GetEngineTime()); - g_bScrambleRoundEnd = false; - g_hTimerClearScrambleForce = INVALID_HANDLE; - - /** - Report enabled - */ - if (g_bIsEnabled) - { - LogAction(0, -1, "[STM] Simple Team Manager is ENABLED."); - } - else - { - LogAction(0, -1, "[STM] Simple Team Manager is DISABLED."); - } - - if (g_bLogActivity) - { - LogAction(0, -1, "[STM] Log Activity ENABLED."); - } - else - { - LogAction(0, -1, "[STM] Log Activity DISABLED."); - } -} - -/* COMMANDS */ - -public Action:Command_SwapTeam(client, args) -{ - - /** - Make sure we are enabled, if not bug out. - */ - if (!g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - If this was ran from the console bug out. - */ - if (client == 0) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "PlayerLevelCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Make sure the client is authorized to run this command. - */ - decl String:sFlags[5]; - GetConVarString(stm_adminflag_swapteam, sFlags, sizeof(sFlags)); - if (!SM_IsValidAdmin(client, sFlags)) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Lets make sure the client is one a team we can swap. - If he is we set the global array to the opposite team. - */ - new iTeam = GetClientTeam(client); - if (iTeam == g_aCurrentTeams[Team1]) - { - g_aPlayers[client][iNewTeam] = g_aCurrentTeams[Team2]; - } - else if (iTeam == g_aCurrentTeams[Team2]) - { - g_aPlayers[client][iNewTeam] = g_aCurrentTeams[Team1]; - } - else - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "InValidTeam", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check to see if we have command arguments. - */ - if (GetCmdArgs()) - { - - /** - We do, so lets get it and see if the client wants to be switched instantly or queued for death. - */ - decl String:sArg[5]; - GetCmdArg(1, sArg, sizeof(sArg)); - new iWantsQue = StringToInt(sArg); - if (iWantsQue && !g_aPlayers[client][bQueue]) - { - - /** - He wants the que and isn't already in it, set the global array. - */ - g_aPlayers[client][bQueue] = true; - ReplyToCommand(client, "\x01\x04[STM]\x01 %T", "PlayerQueue", LANG_SERVER); - } - else if (!iWantsQue) - { - - /** - He wants to be switched right now, lets call the stock function. - */ - SM_MovePlayer(client, g_aPlayers[client][iNewTeam]); - } - } - else - { - - /** - There are no command arguments so we build and display the swap menu. - */ - DisplaySwapModeMenu(client, client); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_MovePlayer(client, args) -{ - - /** - Make sure we are enabled, if not bug out. - */ - if (!g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - Make sure the client is authorized to run this command. - */ - decl String:sFlags[5]; - GetConVarString(stm_adminflag_moveplayer, sFlags, sizeof(sFlags)); - if (!SM_IsValidAdmin(client, sFlags)) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check to see if we have command arguments. - */ - new iCmdArgs = GetCmdArgs(); - if (iCmdArgs == 0) - { - - /** - We don't. Build the player menu, display it, and bug out. - */ - DisplayPlayerMenu(client); - return Plugin_Handled; - } - - /** - Check the first argument - If should be a players name or userid. - */ - decl String:sPlayer[64]; - GetCmdArg(1, sPlayer, sizeof(sPlayer)); - new iPlayerIndex = FindTarget(client, sPlayer, true, true); - if (iPlayerIndex == -1 || !IsClientInGame(iPlayerIndex)) - { - - /** - We don't know who this is. Build the player menu, display it, and bug out. - */ - DisplayPlayerMenu(client); - return Plugin_Handled; - } - - /** - We have figured out the first argument, lets check the second. - If should be the team the client wants to put the player on. - */ - if (iCmdArgs >= 2) - { - - /** - We have a command argument at least, lets see if we can identify the team. - */ - decl String:sTeam[24]; - GetCmdArg(2, sTeam, sizeof(sTeam)); - - new iTeam = StringToInt(sTeam); - if (SM_IsValidTeam(iTeam)) - { - - /** - It's a vaild team so lets set the global array to the new team. - */ - g_aPlayers[iPlayerIndex][iNewTeam] = iTeam; - } - else - { - - /** - It's not a vaild team so set the menu to display to the team menu. - */ - DisplayTeamMenu(client, iPlayerIndex); - return Plugin_Handled; - } - } - else - { - /** - We were not given a team, display the team menu. - */ - DisplayTeamMenu(client, iPlayerIndex); - return Plugin_Handled; - } - - /** - Check to see if we were given any more command arguments and found a team. - */ - if (iCmdArgs < 3) - { - - /** - No more command arguments and found a team. - Now lets check to see if the player is a spectator. If he is there is no reason to ask if it's instant or on death... he can't die. - */ - if (!IsClientObserver(iPlayerIndex)) - { - - /** - Not a spectator so display the swapmode menu. - */ - DisplaySwapModeMenu(client, iPlayerIndex); - } - else - { - - /** - The player is a spectator. - We make sure the player is not set to switch on death, since a spec can't die. - */ - g_aPlayers[iPlayerIndex][bQueue] = false; - } - } - - /** - We have figured out the second argument, lets check the third. - If should be the how the client wants to move the player: instant/on death. - */ - if (iCmdArgs >= 3) - { - - /** - The client gave us a command argument, lets check it. - */ - decl String:sSwapMode[5]; - GetCmdArg(3, sSwapMode, sizeof(sSwapMode)); - new iWantsQue = StringToInt(sSwapMode); - if (iWantsQue) - { - - /** - The client wants to que the player, set the global array. - */ - g_aPlayers[iPlayerIndex][bQueue] = true; - } - else - { - - /** - The client doesn't want to que the player, set the global array. - */ - g_aPlayers[iPlayerIndex][bQueue] = false; - } - } - else - { - /** - No swapmode argument, display the menu - */ - DisplaySwapModeMenu(client, iPlayerIndex); - } - - if (iCmdArgs >= 4) - { - - /** - Since we are compiling for Simple Team Balancer, and given a 4th argument, lets check it. - If should be the if the client wants to force the player to that team. - */ - decl String:sPlayerForced[5]; - GetCmdArg(4, sPlayerForced, sizeof(sPlayerForced)); - new iForceHim = StringToInt(sPlayerForced); - if (iForceHim) - { - - /** - The client wants to force the player - */ - SM_SetForcedTeam(iPlayerIndex, g_aPlayers[iPlayerIndex][iNewTeam]); - } - else - { - - /** - The client doesn't want to force the player - */ - SM_ClearForcedTeam(iPlayerIndex); - } - } - else - { - - } - - /** - We found and processed all the arguments. - */ - if (!IsPlayerAlive(iPlayerIndex)) - { - - /** - The player is not alive or died during this process so we just move him. - */ - SM_MovePlayer(iPlayerIndex, g_aPlayers[iPlayerIndex][iNewTeam]); - } - else - { - if (!g_aPlayers[iPlayerIndex][bQueue]) - { - - /** - The player is alive and is not set to be queued so we just move him. - */ - SM_MovePlayer(iPlayerIndex, g_aPlayers[iPlayerIndex][iNewTeam]); - } - } - - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_ScrambleTeams(client, args) -{ - - /** - Make sure we are enabled, if not bug out. - */ - if (!g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - Make sure the client is authorized to run this command. - */ - decl String:sFlags[5]; - GetConVarString(stm_adminflag_scramble, sFlags, sizeof(sFlags)); - if (!SM_IsValidAdmin(client, sFlags)) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check if a scramble timer was already called, if so close it down. - */ - if (g_hTimerPrepScramble != INVALID_HANDLE) - { - CloseHandle(g_hTimerPrepScramble); - g_hTimerPrepScramble = INVALID_HANDLE; - } - - /** - Check if we have any command arguments. - If we don't we display the scramble menu and bug out. - */ - new iCmdArgs = GetCmdArgs(); - if (iCmdArgs == 0) - { - DisplayScrambleMenu(client); - return Plugin_Handled; - } - - /** - We have a command argument. - It should be whether or not to scramble at round end. - */ - decl String:sRoundEnd[5]; - GetCmdArg(1, sRoundEnd, sizeof(sRoundEnd)); - if (StringToInt(sRoundEnd)) - { - /** - The client wants to scramble at round end so we set the global bool. - */ - g_bScrambleRoundEnd = true; - } - else - { - g_bScrambleRoundEnd = false; - } - - /** - Check for another command argument. - It should be whether or not to restart the round. - */ - decl String:sRestartRound[5]; - new bool:bRestartRound = false; - GetCmdArg(1, sRestartRound, sizeof(sRestartRound)); - if (StringToInt(sRestartRound)) - { - bRestartRound = true; - } - - /** - Now we start the scramble timer. - */ - StartScrambleTimer(_, bRestartRound); - - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_VoteScramble(client, args) -{ - - /** - Make sure we are enabled, if not bug out. - */ - if (!g_bVoteEnabled || !g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - Make sure there is a vote in progress, if so bug out. - */ - if (IsVoteInProgress()) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "VoteInProgress", LANG_SERVER); - return Plugin_Handled; - } - - /** - Make sure enough time has passed since the last vote. - */ - new iVoteTime = RoundFloat(GetEngineTime()); - if (iVoteTime - g_iLastVoteTime <= g_iVoteDelay) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "ScrambleTime", LANG_SERVER); - return Plugin_Handled; - } - - /** - Enough time has passed so reset the global vote time to now. - */ - g_iLastVoteTime = iVoteTime; - - /** - Build the vote menu and send it to everyone. - */ - new Handle:hMenu = CreateMenu(Menu_VoteScramble); - SetMenuTitle(hMenu, "Scramble Teams?"); - AddMenuItem(hMenu, VOTE_YES, "Yes"); - AddMenuItem(hMenu, VOTE_NO, "No"); - SetMenuExitButton(hMenu, false); - VoteMenuToAll(hMenu, 20); - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -/* HOOKED EVENTS */ - -public HookPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Find out who died. - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - - /** - Find out how the client died. - */ - new String:sWeapon[64]; - GetEventString(event, "weapon", sWeapon, sizeof(sWeapon)); - if (StrEqual(sWeapon, "world", false)) - { - - /** - He died because he changed teams so cleanup and bug out. - */ - s_CleanUp(iClient); - return; - } - - /** - Find out if this player was queued to change teams. - */ - if (g_aPlayers[iClient][bQueue]) - { - /** - Looks like he was, so call the stock function to move him. - */ - SM_MovePlayer(iClient, g_aPlayers[iClient][iNewTeam]); - } -} - -public HookPlayerChangeTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Find out who changed teams. - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - - /** - If he was queued to switch teams we cleanup the variables. The client did it themself. - */ - if (g_aPlayers[iClient][bQueue]) - { - s_CleanUp(iClient); - } -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get the amount of time left in the map. - */ - new iTimeLeft; - GetMapTimeLeft(iTimeLeft); - - /** - Check to see if we are supposed to scramble at the end of the round and that there is enough time left in the map. - */ - if (g_bScrambleRoundEnd && iTimeLeft >= 60) - { - - /** - Check to see if there is a scramble timer in action and if so close it down. - */ - if (g_hTimerPrepScramble != INVALID_HANDLE) - { - CloseHandle(g_hTimerPrepScramble); - g_hTimerPrepScramble = INVALID_HANDLE; - } - - /** - Determine the round end chat time and run the scramble 1 second before it ends. - */ - new Float:fDelay = GetConVarFloat(stm_mp_bonusroundtime); - fDelay -= 1.0; - StartScrambleTimer(fDelay); - } -} - -public OnClientPostAdminCheck(client) -{ - - /** - Determine if the client has the flag to use the swapteam command. - */ - decl String:sFlags[5]; - GetConVarString(stm_adminflag_swapteam, sFlags, sizeof(sFlags)); - if (SM_IsValidAdmin(client, sFlags)) - { - /** - The client does so lets create a timer to run an advertise to tell him about it. - */ - CreateTimer (60.0, Timer_WelcomeAdvert, client); - } -} - -public OnClientDisconnect(client) -{ - - /** - Cleanup the clients variables. - */ - s_CleanUp(client); -} - -public SM_OnPlayerMoved(Handle:plugin, client, team) -{ - - /** - Make sure we called the move function - */ - if (plugin != GetMyHandle()) - { - if (g_bLogActivity) - { - LogAction(0, client, "[STM] Callback was not started with current plugin, bugging out."); - } - return; - } - - decl String:sPlayerName[64]; - GetClientName(client, sPlayerName, sizeof(sPlayerName)); - - PrintToChat(client, "\x01\x04[SM]\x01 %T", "PlayerSwitched", LANG_SERVER); - - s_CleanUp(client); -} - -/* TIMER FUNCTIONS */ - -public Action:Timer_PrepTeamScramble(Handle:timer, any:data) -{ - new bool:bRestartRound = data; - /** - Call the scramble the teams stock function. - */ - PrepTeamScramble(bRestartRound); - - /** - Reset the timer handle so we know the timer is done. - */ - g_hTimerPrepScramble = INVALID_HANDLE; - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Timer_ScrambleTheTeams(Handle:timer, any:data) -{ - new iPlayers[MAXPLAYERS + 1]; - new iCount, i, bool:bTeam, bool:bRestartRound = data; - - /** - Get all the client index numbers of valid players - */ - for(i = 1; i <= MaxClients; i++) - { - if(IsClientInGame(i)) // && !IsFakeClient(i)) - { - iPlayers[iCount++] = i; - } - } - - /** - Randomly sort the players - */ - SortIntegers(iPlayers, iCount, Sort_Random); - - /** - Loop through all the players and assign each one to a team, alternating each time - */ - for(i = 0; i < iCount; i++) - { - if (!bRestartRound) - { - /** - We didn't want to restart the round, so we move them to spec 1 at a time. - */ - SM_MovePlayer(iPlayers[i], g_aCurrentTeams[Spectator]); - } - SM_MovePlayer(iPlayers[i], bTeam ? g_aCurrentTeams[Team2] : g_aCurrentTeams[Team1]); - SM_SetForcedTeam(iPlayers[i], bTeam ? g_aCurrentTeams[Team2] : g_aCurrentTeams[Team1], true); - bTeam = !bTeam; - } - - /** - Reset this variable since we completed a scramble - */ - g_bScrambleRoundEnd = false; - - if (g_hTimerClearScrambleForce != INVALID_HANDLE) - { - CloseHandle(g_hTimerClearScrambleForce); - g_hTimerClearScrambleForce = INVALID_HANDLE; - } - - g_hTimerClearScrambleForce = CreateTimer(300.0, Timer_ClearScrambleForce, _, TIMER_FLAG_NO_MAPCHANGE); - - ServerCommand("mp_timelimit %i", g_iTimeLeft / 60); - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Timer_ClearScrambleForce(Handle:timer, any:data) -{ - - for(new i = 1; i <= MaxClients; i++) - { - if(IsClientInGame(i)) // && !IsFakeClient(i)) - { - SM_ClearForcedTeam(i); - PrintToChat(i, "\x01\x04[SM]\x01 Your forced team status has been cleared"); - } - } - - g_hTimerClearScrambleForce = INVALID_HANDLE; - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Timer_WelcomeAdvert(Handle:timer, any:client) -{ - - /** - Lets make sure the client is connected and actually in the game. - */ - if (IsClientConnected(client) && IsClientInGame(client)) - { - - /** - We are good to go so lets tell him about the swapteam command. - */ - PrintToChat (client, "\x01\x04[STM]\x01 %T", "SwapTeamMsg", LANG_SERVER); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -/* STOCK FUNCTIONS */ - -stock s_CleanUp(iClient) -{ - - /** - Reset all the client variables - */ - g_aPlayers[iClient][bQueue] = false; - g_aPlayers[iClient][iNewTeam] = 0; -} - -stock StartScrambleTimer(Float:fdelay = 0.0, bool:bRestartRound = false) -{ - if (fdelay == 0.0) - { - fdelay = g_fScrambleDelay; - } - if (g_hTimerPrepScramble != INVALID_HANDLE) - { - CloseHandle(g_hTimerPrepScramble); - g_hTimerPrepScramble = INVALID_HANDLE; - } - PrintCenterTextAll("%T", "Scramble", LANG_SERVER); - g_hTimerPrepScramble = CreateTimer(fdelay, Timer_PrepTeamScramble, bRestartRound, TIMER_FLAG_NO_MAPCHANGE); -} - -stock PrepTeamScramble(bool:bRestartRound = false) -{ - new iPlayers[MAXPLAYERS + 1]; - new iCount; - - GetMapTimeLeft(g_iTimeLeft); - - if (bRestartRound) - { - - for(new i = 1; i <= MaxClients; i++) - { - if(IsClientInGame(i)) - // && !IsFakeClient(i)) - { - iPlayers[iCount++] = i; - SM_ClearForcedTeam(i); - SM_ClearBuddy(i); - SM_MovePlayer(i, g_aCurrentTeams[Spectator]); - } - } - } - else - { - //Can't move them all to spec at the same time - for(new i = 1; i <= MaxClients; i++) - { - if(IsClientInGame(i)) - // && !IsFakeClient(i)) - { - iPlayers[iCount++] = i; - SM_ClearForcedTeam(i); - SM_ClearBuddy(i); - //SM_MovePlayer(i, g_aCurrentTeams[Spectator]); - } - } - } - CreateTimer(4.0, Timer_ScrambleTheTeams, bRestartRound, TIMER_FLAG_NO_MAPCHANGE); -} - -/* CONSOLE VARIABLE CHANGE EVENT */ - -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (convar == stm_enabled) { - if (StringToInt(newValue) == 0) { - g_bIsEnabled = false; - LogAction(0, -1, "[STM] Simple Team Manager is loaded and disabled."); - } else { - g_bIsEnabled = true; - LogAction(0, -1, "[STM] Simple Team Manager is loaded and enabled."); - } - } - else if (convar == stm_logactivity) { - if (StringToInt(newValue) == 0) { - g_bLogActivity = false; - LogAction(0, -1, "[STM] Log Activity DISABLED."); - } else { - g_bLogActivity = true; - LogAction(0, -1, "[STM] Log Activity ENABLED."); - } - } - else if (convar == stm_scrambledelay) - g_fScrambleDelay = StringToFloat(newValue); - else if (convar == stm_votewin) - g_fVoteWin = StringToFloat(newValue); - else if (convar == stm_votedelay) - g_iVoteDelay = StringToInt(newValue); - else if (convar == stm_voteenabled) { - if (StringToInt(newValue) == 0) - g_bVoteEnabled = false; - else - g_bVoteEnabled = true; - } -} - -/* MENU CODE */ - -public OnAdminMenuReady(Handle:topmenu) -{ - if (topmenu == g_hAdminMenu) - return; - g_hAdminMenu = topmenu; - new TopMenuObject:player_commands = FindTopMenuCategory(g_hAdminMenu, ADMINMENU_PLAYERCOMMANDS); - new TopMenuObject:server_commands = FindTopMenuCategory(g_hAdminMenu, ADMINMENU_SERVERCOMMANDS); - if (player_commands == INVALID_TOPMENUOBJECT) - return; - - AddToTopMenu(g_hAdminMenu, - "moveplayer", - TopMenuObject_Item, - AdminMenu_MovePlayer, - player_commands, - "moveplayer", - ADMFLAG_BAN); - - AddToTopMenu(g_hAdminMenu, - "scrambleteams", - TopMenuObject_Item, - AdminMenu_Scrambleteams, - server_commands, - "scrambleteams", - ADMFLAG_BAN); -} - -public AdminMenu_MovePlayer(Handle:topmenu, TopMenuAction:action, TopMenuObject:object_id, param, String:buffer[], maxlength) -{ - if (action == TopMenuAction_DisplayOption) - Format(buffer, maxlength, "Move Player"); - else if (action == TopMenuAction_SelectOption){ - DisplayPlayerMenu(param); - } -} - -public AdminMenu_Scrambleteams(Handle:topmenu, TopMenuAction:action, TopMenuObject:object_id, param, String:buffer[], maxlength) -{ - if (action == TopMenuAction_DisplayOption) - Format(buffer, maxlength, "Scramble Teams"); - else if (action == TopMenuAction_SelectOption) { - DisplayScrambleMenu(param); - } -} - -public Menu_SelectPlayer(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - DisplayTeamMenu(param1, GetClientOfUserId(StringToInt(sSelection))); - } else if (action == MenuAction_Cancel) { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -public Menu_SelectTeam(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new iTeam; - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - decl String:sIndex[64]; - if (SplitString(sSelection, "A", sIndex, sizeof(sIndex)) != -1) - iTeam = g_aCurrentTeams[Team1]; - else if (SplitString(sSelection, "B", sIndex, sizeof(sIndex)) != -1) - iTeam = g_aCurrentTeams[Team2]; - else { - SplitString(sSelection, "C", sIndex, sizeof(sIndex)); - iTeam = g_aCurrentTeams[Spectator]; - } - new iTarget = StringToInt(sIndex); - g_aPlayers[iTarget][iNewTeam] = iTeam; - DisplaySwapModeMenu(param1, iTarget); - } else if (action == MenuAction_Cancel) { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -public Menu_SwapMode(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - decl String:sIndex[64]; - - if (SplitString(sSelection, "A", sIndex, sizeof(sIndex)) == -1) - { - SplitString(sSelection, "B", sIndex, sizeof(sIndex)); - } - - new iTarget = StringToInt(sIndex); - - if (StrContains(sSelection, "A", true) != -1) - { - g_aPlayers[iTarget][bQueue] = false; - } - else if (StrContains(sSelection, "B", true) != -1) - { - g_aPlayers[iTarget][bQueue] = true; - } - - if (param1 == iTarget && !g_aPlayers[iTarget][bQueue]) - { - SM_MovePlayer(iTarget, g_aPlayers[iTarget][iNewTeam]); - } - else - { - DisplayForceModeMenu(param1, iTarget); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - { - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } - return; -} - -public Menu_ForceMode(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - decl String:sIndex[64]; - if (SplitString(sSelection, "A", sIndex, sizeof(sIndex)) == -1) - { - SplitString(sSelection, "B", sIndex, sizeof(sIndex)); - } - new iTarget = StringToInt(sIndex); - if (StrContains(sSelection, "A", true) != -1) - { - SM_ClearForcedTeam(iTarget); - } - else if (StrContains(sSelection, "B", true) != -1) - { - SM_SetForcedTeam(iTarget, g_aPlayers[iTarget][iNewTeam], true); - } - if (!g_aPlayers[iTarget][bQueue]) - { - SM_MovePlayer(iTarget, g_aPlayers[iTarget][iNewTeam]); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - { - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } - return; -} - -public Menu_VoteScramble(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_VoteEnd) { - new winning_votes, total_votes; - GetMenuVoteInfo(param2, winning_votes, total_votes); - if (param1 == 0) { - if (float(total_votes) / float(winning_votes) < g_fVoteWin) { - PrintToChatAll("\x01\x04[SM]\x01 %T", "VoteScramble2", LANG_SERVER, winning_votes, total_votes); - return; - } - PrintCenterTextAll("[SM] %T", "Scramble", LANG_SERVER); - PrintToChatAll("\x01\x04[SM]\x01 %T", "VoteScramble1", LANG_SERVER, winning_votes, total_votes); - StartScrambleTimer(); - } - if (param1 == 1) { - PrintToChatAll("\x01\x04[SM]\x01 %T", "VoteScramble2", LANG_SERVER, winning_votes, total_votes); - } - } - if (action == MenuAction_End) - CloseHandle(menu); -} - -public Menu_ScrambleTeams(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "NOW", false)) - g_bScrambleRoundEnd = false; - else - g_bScrambleRoundEnd = true; - DisplayScrambleMenu2(param1); - } else if (action == MenuAction_Cancel) { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -public Menu_ScrambleTeams2(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[64]; - new bool:bRestartRound; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "NO", false)) - { - bRestartRound = false; - } - else - { - bRestartRound = true; - } - StartScrambleTimer(_, bRestartRound); - } else if (action == MenuAction_Cancel) { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -stock DisplayScrambleMenu(iClient) -{ - new Handle:hMenu = CreateMenu(Menu_ScrambleTeams); - SetMenuTitle(hMenu, "Select When to Scramble:"); - AddMenuItem(hMenu, "NOW", "Instantly"); - AddMenuItem(hMenu, "END", "At Round End"); - SetMenuExitBackButton(hMenu, false); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} - -stock DisplayScrambleMenu2(iClient) -{ - new Handle:hMenu = CreateMenu(Menu_ScrambleTeams2); - SetMenuTitle(hMenu, "Select When to Scramble:"); - AddMenuItem(hMenu, "NO", "No Round Restart"); - AddMenuItem(hMenu, "YES", "Restart Round"); - SetMenuExitBackButton(hMenu, false); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} - -stock DisplaySwapModeMenu(iClient, iTarget) -{ - new Handle:hMenu = CreateMenu(Menu_SwapMode); - decl String:optionA[64]; - decl String:optionB[64]; - Format(optionA, sizeof(optionA), "%iA", iTarget); - Format(optionB, sizeof(optionB), "%iB", iTarget); - SetMenuTitle(hMenu, "Select When to Swap:"); - AddMenuItem(hMenu, optionA, "Instantly (Kills)"); - if (!IsClientObserver(iTarget)) - AddMenuItem(hMenu, optionB, "Queue on next death"); - SetMenuExitBackButton(hMenu, false); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} - -stock DisplayForceModeMenu(iClient, iTarget) -{ - new Handle:hMenu = CreateMenu(Menu_ForceMode); - decl String:optionA[64]; - decl String:optionB[64]; - Format(optionA, sizeof(optionA), "%iA", iTarget); - Format(optionB, sizeof(optionB), "%iB", iTarget); - SetMenuTitle(hMenu, "Select Force Mode:"); - AddMenuItem(hMenu, optionA, "UnForced"); - AddMenuItem(hMenu, optionB, "Forced"); - SetMenuExitBackButton(hMenu, false); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} - -stock DisplayTeamMenu(iClient, iTarget) -{ - new Handle:hMenu = CreateMenu(Menu_SelectTeam); - decl String:optionA[64]; - decl String:optionB[64]; - decl String:optionC[64]; - Format(optionA, sizeof(optionA), "%iA", iTarget); - Format(optionB, sizeof(optionB), "%iB", iTarget); - Format(optionC, sizeof(optionC), "%iC", iTarget); - SetMenuTitle(hMenu, "Select Team:"); - AddMenuItem(hMenu, optionA, "Team One"); - AddMenuItem(hMenu, optionB, "Team Two"); - AddMenuItem(hMenu, optionC, "Spectator"); - SetMenuExitBackButton(hMenu, false); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} - -stock DisplayPlayerMenu(iClient) -{ - new Handle:hMenu = CreateMenu(Menu_SelectPlayer); - AddTargetsToMenu(hMenu, 0, true, false); - SetMenuTitle(hMenu, "Select A Player:"); - SetMenuExitBackButton(hMenu, true); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} diff --git a/Simple Message Suppression/addons/sourcemod/translations/simpledonatorbenefits.phrases.txt b/Simple Message Suppression/addons/sourcemod/translations/simpledonatorbenefits.phrases.txt deleted file mode 100644 index 3826846..0000000 --- a/Simple Message Suppression/addons/sourcemod/translations/simpledonatorbenefits.phrases.txt +++ /dev/null @@ -1,62 +0,0 @@ -"Phrases" -{ - "PlayerLevelCmd" - { - "en" "Command must be run at the player level" - "fr" "Cette commande doit être tapée en jeu" - "hu" "Ezt a parancsot jatekosi szinten kell futtatni!" - } - "RestrictedCmd" - { - "en" "You must be a donator or admin to run this command" - "fr" "Vous devez être un donateur ou un admin pour lancer cette commande" - "hu" "A parancs futtatasahoz admin, vagy tamogatoi szint szukseges!" - } - "InValidTeam" - { - "en" "You must be on red or blue to swap teams" - "fr" "Vous devez être RED ou BLU pour changer d'équipe" - "hu" "Jatekban kell lenned, hogy megcsereld a csapatokat!" - } - "PlayerQueue" - { - "en" "You have been queued to swap teams on next death" - "fr" "Vous avez été mis en attente pour changer d'équipe lors de votre prochaine mort" - "hu" "A kovetkezo halalnal csapatcsere lesz" - } - "PlayerSwitched" - { - "en" "Your team has been switched as requested" - "fr" "Vous avez changé d'équipe comme demandé" - "hu" "A keresnek eleget teve a csapatod meg lett csererlve" - } - "SwapTeamMsg" - { - "en" "Type /swapteam or !swapteam to swap your team!" - } - "ReachedCount" - { - "en" "You have reached your health limit. You must die before you can use it again" - } - "AtMaxHealth" - { - "en" "You are already at your maximum health!" - } - "ToMaxHealth" - { - "en" "Instant health bonus applied! You are not at your maximun health!" - } - "HealthBonus" - { - "en" "Instant health bonus applied!" - } - "PublicJoinMessage" - { - "#format" "{1:s}" - "en" "{1} a [donator] as joined the server" - } - "PrivateJoinMessage" - { - "en" "Thanks for donating!" - } -} \ No newline at end of file diff --git a/Simple Message Suppression/addons/sourcemod/translations/simplespectate.phrases.txt b/Simple Message Suppression/addons/sourcemod/translations/simplespectate.phrases.txt deleted file mode 100644 index 2d1a096..0000000 --- a/Simple Message Suppression/addons/sourcemod/translations/simplespectate.phrases.txt +++ /dev/null @@ -1,42 +0,0 @@ -"Phrases" -{ - "Stopped spectating" - { - "#format" "{1:s}" - "en" "Stopped tracking player: {1}" - } - "Yourself" - { - "en" "You can't spectate yourself" - } - "Spectator" - { - "en" "You can't spectate another spectator" - } - "Spectating" - { - "#format" "{1:s}" - "en" "Now spectating {1}. Type !stopspec or /stopspec to stop spectating this player" - } - "Invalid Target" - { - "en" "Invalid target" - } - "Cant Target" - { - "en" "Can't target this player" - } - "Must Have Target" - { - "en" "You must be following/tracking a player to punish" - } - "Target Left" - { - "en" "The player you were following/tracking has left" - } - "Punished" - { - "#format" "{1:s}{2:s}{3:s}" - "en" "{1} was punished with a {2} for {3}" - } -} \ No newline at end of file diff --git a/Simple Message Suppression/addons/sourcemod/translations/simpleteambalancer.phrases.txt b/Simple Message Suppression/addons/sourcemod/translations/simpleteambalancer.phrases.txt deleted file mode 100644 index 03595fd..0000000 --- a/Simple Message Suppression/addons/sourcemod/translations/simpleteambalancer.phrases.txt +++ /dev/null @@ -1,130 +0,0 @@ -"Phrases" -{ - "UnBalanced" - { - "en" "Teams are unbalanced and will be balanced shortly" - "fr" "Les équipes ne sont pas équilibrées et le seront bientôt" - "de" "Die Teams sind ungleich und werden in Kürze ausgeglichen" - "hu" "A csapatok nem kiegyenlitettek! Egyensuly beallitas kovetkezik!" - } - "Enabled" - { - "en" "Simple Team Balancer is ENABLED" - "fr" "Simple Team Balancer est ACTIVE" - "de" "Simple Team Balancer ist AKTIV" - "hu" "Az Egyszeru Csapat Egyensulytarto AKTIV!" - } - "Disabled" - { - "en" "Simple Team Balancer is DISABLED" - "fr" "Simple Team Balancer est DESACTIVE" - "de" "Simple Team Balancer ist INAKTIV" - "hu" "Az Egyszeru Csapat Egyensulytarto INAKTIV!" - } - "PlayerMessage" - { - "#format" "{1:i}" - "en" "You are going to be auto balanced in {1} seconds unless a dead player can be found" - "fr" "Vous passerez dans l'autre équipe dans {1} secondes si aucun joueur mort ne peut être trouvé dans cet intervalle" - "de" "Du wirst in {1} Sekunden zum automatischen Ausgleich herangezogen wenn kein toter Spieler gefunden werden kann" - "hu" "{1} masodpercen belul at leszel helyezve a masik csapatba, hacsak nem lesz addig egy halott jatekos!" - } - "BalanceMessage" - { - "#format" "{1:s}" - "en" "{1} was moved to the other team for game balance" - "fr" "{1} est passé dans l'autre équipe pour équilibrer la partie" - "de" "{1} wurde zum anderen Team verschoben um das Spiel auszugleichen" - "hu" "{1} at lett helyezve az egyensuly megtartasa erdekeben." - } - "PlayerLevelCmd" - { - "en" "Command must be run at the player level" - "fr" "La commande doit être lancée au niveau du joueur" - "de" "Das Kommando muss auf Spieler Ebene ausgeführt werden" - "hu" "Jatekosi szinten kell futtatni ezt a parancsot!" - } - "CmdDisabled" - { - "en" "Command is currently disabled" - "fr" "La commande est actuellement désactivée" - "de" "Das Kommando ist momentan inaktiv" - "hu" "A parancs jelenleg inaktiv" - } - "RestrictedBuddy" - { - "en" "You must be a donator or admin to add a balance buddy" - "fr" "Vous devez être un donateur ou un admin pour choisir un partenaire" - "de" "Du musst ein Spender oder Admin sein um einen Partner wählen zu können" - "hu" "Tamogato vagy admin kell hogy legyel, hogy 'Tarsat' jelolhess meg" - } - "SelectSelf" - { - "en" "You cannot be your own buddy" - "fr" "Vous ne pouvez pas être votre propre partenaire" - "de" "Du kannst nicht dein eigener Partner sein" - "hu" "Nem valaszthatod ki onmagad!" - } - "BuddyGone" - { - "en" "Your selected buddy has disconnected" - "fr" "Le partenaire que vous avez sélectionné s'est déconnecté" - "de" "Dein gewählter Partner hat die Verbindung getrennt" - "hu" "A valasztott 'Tarsad' kilepett" - } - "BuddyMsg" - { - "#format" "{1:s}" - "en" "You and {1} are now buddies" - "fr" "Vous et {1} êtes maintenant partenaires" - "de" "Du und {1} seid jetzt Partner" - "hu" "{1} es Te 'Tarsak' vagytok." - } - "BuddyLockMsgDisabled" - { - "en" "You can now be anyone's buddy" - "fr" "Vous pouvez à présent être le partenaire de n'importe qui" - "de" "Du kannst jetzt jedermanns Partner sein" - "hu" "Barkinek lehetsz a 'Tarsa'." - } - "BuddyLockMsgEnabled" - { - "en" "Buddy selection locked. Only you can change your buddy" - "fr" "Sélection de partenaire bloquée. Vous êtes le seul à pouvoir choisir votre partenaire" - "de" "Wahl des Partners gesperrt. Nur du kannst deinen Partner wechseln" - "hu" "Tars-lista lezarva. Csak Te tudod modositani a Tars-listadat." - } - "PlayerLockedBuddyMsg" - { - "#format" "{1:s}" - "en" "{1} has locked his buddy selection. Try again" - "fr" "{1} a bloqué sa sélection de partenaire. Essayez de nouveau." - "de" "{1} hat seine Wahl des Partners gesperrt. Versuche es erneut" - "hu" "{1} lezarta a Tars-listajat. Probald kesobb!" - } - "BuddyWelcomeMsg1" - { - "en" "Select a balance buddy and stay together during an autobalance!" - "fr" "Choisissez un partenaire et restez ensemble durant l'équilibrage automatique!" - "de" "Wähle einen Partner und bleibt zusammen während eines Ausgleichs" - "hu" "Valasz ki egy 'Tarsat' akivel egyuttmaradhatsz a csapatkiegyenlites alatt!" - } - "BuddyWelcomeMsg2" - { - "en" "/buddy or !buddy to select a balance buddy" - "fr" "/buddy or !buddy pour choisir un partenaire" - "de" "/buddy oder !buddy um einen Partner zu wählen" - "hu" "Hasznald a /buddy vagy !buddy parancsokat a 'Tars' kijelolesehez" - } - "BuddyWelcomeMsg3" - { - "en" "/lockbuddy or !lockbuddy to lock your selection" - "fr" "/lockbuddy or !lockbuddy pour bloquer votre sélection" - "de" "/lockbuddy oder !lockbuddy um deine Auswahl zu sperren" - "hu" "Hasznald a /lockbuddy vagy a !lockbuddy parancsokat a Tars-listad lezarasahoz" - } -} - - - - diff --git a/Simple Message Suppression/addons/sourcemod/translations/simpleteammanager.phrases.txt b/Simple Message Suppression/addons/sourcemod/translations/simpleteammanager.phrases.txt deleted file mode 100644 index f2093a7..0000000 --- a/Simple Message Suppression/addons/sourcemod/translations/simpleteammanager.phrases.txt +++ /dev/null @@ -1,92 +0,0 @@ -"Phrases" -{ - "PlayerLevelCmd" - { - "en" "Command must be run at the player level" - "fr" "Cette commande doit être tapée en jeu" - "hu" "Ezt a parancsot jatekosi szinten kell futtatni!" - } - "RestrictedCmd" - { - "en" "You must be a donator or admin to run this command" - "fr" "Vous devez être un donateur ou un admin pour lancer cette commande" - "hu" "A parancs futtatasahoz admin, vagy tamogatoi szint szukseges!" - } - "InValidTeam" - { - "en" "You must be on red or blue to swap teams" - "fr" "Vous devez être RED ou BLU pour changer d'équipe" - "hu" "Jatekban kell lenned, hogy megcsereld a csapatokat!" - } - "PlayerInValidTeam" - { - "en" "Player must be on red or blue to swap teams" - "fr" "Le joueur doit être RED ou BLU pour changer d'équipe" - "hu" "Valamelyik csapatban kell lenni, hogy csere legyen" - } - "PlayerQueue" - { - "en" "You have been queued to swap teams on next death" - "fr" "Vous avez été mis en attente pour changer d'équipe lors de votre prochaine mort" - "hu" "A kovetkezo halalnal csapatcsere lesz" - } - "PlayerSwitched" - { - "en" "Your team has been switched" - } - "PlayerSwitched1" - { - "en" "Your team has been switched as requested" - "fr" "Vous avez changé d'équipe comme demandé" - "hu" "A keresnek eleget teve a csapatod meg lett csererlve" - } - "PlayerSwitched2" - { - "en" "Your team has been switched by an Admin" - "fr" "Vous avez été changé d'équipe par un admin" - "hu" "Az Admin megcserelte a csapatodat!" - } - "SwapTeamMsg" - { - "en" "Type /swapteam or !swapteam to swap your team!" - } - "PlayerSwitched3" - { - "#format" "{1:s}" - "en" "{1}'s team has been switched" - "fr" "{1} a changé d'équipe" - "hu" "{1} csapata meg lett cserelve" - } - "Scramble" - { - "en" "Teams are about to be scrambled!" - "fr" "Les équipes vont être rééquilibrés" - "hu" "A csapatok hamarosan meg lesznek keverve!" - } - "VoteScramble1" - { - "#format" "{1:i}{2:i}" - "en" "Vote Scramble successful with {1} votes out of {2}" - "fr" "Le vote d'équilibrage des équipes a réussi avec {1} votes pour sur {2}" - "hu" "A szavazas sikeres volt, {1} szavazat a keveresre a {2} -bol" - } - "VoteScramble2" - { - "#format" "{1:i}{2:i}" - "en" "Vote Scramble failed with {1} votes out of {2}" - "fr" "Le vote d'équilibrage a échoué avec {1} votes pour sur {2}" - "hu" "A szavazas sikertelen volt, {1} szavazat a keveresre a {2} -bol" - } - "VoteInProgress" - { - "en" "A vote is currently in progress" - "fr" "Un vote est actuellement en cours" - "hu" "Egy szavazas mar fut!" - } - "ScrambleTime" - { - "en" "A vote was recently made, please wait" - "fr" "Un vote a déjà été fait récemment, réessayez plus tard" - "hu" "Nemreg volt szavazas, kerlek varj egy kicsit!" - } -} \ No newline at end of file diff --git a/Simple Plugins Core/addons/sourcemod/configs/simple-alltalkmanager_events.cfg b/Simple Plugins Core/addons/sourcemod/configs/simple-alltalkmanager_events.cfg deleted file mode 100644 index b739cf0..0000000 --- a/Simple Plugins Core/addons/sourcemod/configs/simple-alltalkmanager_events.cfg +++ /dev/null @@ -1,43 +0,0 @@ -"game_events" -{ - "teamplay_round_start" - { - "reason" "Round Start" - "setting" "1" - } - "teamplay_setup_finished" - { - "reason" "Setup Period Ended" - "setting" "0" - } - "teamplay_overtime_begin" - { - "reason" "Overtime Began" - "setting" "1" - } - "teamplay_overtime_end" - { - "reason" "Overtime Ended" - "setting" "1" - } - "teamplay_round_win" - { - "reason" "Round Ended" - "setting" "1" - } - "teamplay_suddendeath_begin" - { - "reason" "Sudden Death Began" - "setting" "1" - } - "teamplay_suddendeath_end" - { - "reason" "Sudden Death Ended" - "setting" "1" - } - "teamplay_round_stalemate" - { - "reason" "Stalemate" - "setting" "1" - } -} \ No newline at end of file diff --git a/Simple Plugins Core/addons/sourcemod/configs/simple-chatcolors.cfg b/Simple Plugins Core/addons/sourcemod/configs/simple-chatcolors.cfg deleted file mode 100644 index 14b98c6..0000000 --- a/Simple Plugins Core/addons/sourcemod/configs/simple-chatcolors.cfg +++ /dev/null @@ -1,15 +0,0 @@ -"admin_colors" -{ - "groupname2" - { - "flag" "z" - "namecolor" "{green}" - "textcolor" "{olive}" - } - "groupname1" - { - "flag" "a" - "namecolor" "{teamcolor}" - "textcolor" "{green}" - } -} \ No newline at end of file diff --git a/Simple Plugins Core/addons/sourcemod/plugins/simple-alltalkmanager.smx b/Simple Plugins Core/addons/sourcemod/plugins/simple-alltalkmanager.smx deleted file mode 100644 index 6122756..0000000 Binary files a/Simple Plugins Core/addons/sourcemod/plugins/simple-alltalkmanager.smx and /dev/null differ diff --git a/Simple Plugins Core/addons/sourcemod/plugins/simple-donatorbenefits.smx b/Simple Plugins Core/addons/sourcemod/plugins/simple-donatorbenefits.smx deleted file mode 100644 index 821d61d..0000000 Binary files a/Simple Plugins Core/addons/sourcemod/plugins/simple-donatorbenefits.smx and /dev/null differ diff --git a/Simple Plugins Core/addons/sourcemod/plugins/simple-messagesuppression.smx b/Simple Plugins Core/addons/sourcemod/plugins/simple-messagesuppression.smx deleted file mode 100644 index cc20dad..0000000 Binary files a/Simple Plugins Core/addons/sourcemod/plugins/simple-messagesuppression.smx and /dev/null differ diff --git a/Simple Plugins Core/addons/sourcemod/plugins/simple-plugins.smx b/Simple Plugins Core/addons/sourcemod/plugins/simple-plugins.smx index ac307a3..36061d7 100644 Binary files a/Simple Plugins Core/addons/sourcemod/plugins/simple-plugins.smx and b/Simple Plugins Core/addons/sourcemod/plugins/simple-plugins.smx differ diff --git a/Simple Plugins Core/addons/sourcemod/plugins/simple-spectate.smx b/Simple Plugins Core/addons/sourcemod/plugins/simple-spectate.smx deleted file mode 100644 index c6885b0..0000000 Binary files a/Simple Plugins Core/addons/sourcemod/plugins/simple-spectate.smx and /dev/null differ diff --git a/Simple Plugins Core/addons/sourcemod/plugins/simple-teambalancer.smx b/Simple Plugins Core/addons/sourcemod/plugins/simple-teambalancer.smx deleted file mode 100644 index 95beb01..0000000 Binary files a/Simple Plugins Core/addons/sourcemod/plugins/simple-teambalancer.smx and /dev/null differ diff --git a/Simple Plugins Core/addons/sourcemod/plugins/simple-teammanager.smx b/Simple Plugins Core/addons/sourcemod/plugins/simple-teammanager.smx deleted file mode 100644 index 81905ba..0000000 Binary files a/Simple Plugins Core/addons/sourcemod/plugins/simple-teammanager.smx and /dev/null differ diff --git a/Simple Plugins Core/addons/sourcemod/scripting/include/simple-plugins.inc b/Simple Plugins Core/addons/sourcemod/scripting/include/simple-plugins.inc index 8f21956..3a9cf4b 100644 --- a/Simple Plugins Core/addons/sourcemod/scripting/include/simple-plugins.inc +++ b/Simple Plugins Core/addons/sourcemod/scripting/include/simple-plugins.inc @@ -326,7 +326,7 @@ public LoadCurrentTeams() g_aCurrentTeams[Team1] = 1; g_aCurrentTeams[Team2] = 2; } - case default: + default: { g_aCurrentTeams[Unknown] = 0; g_aCurrentTeams[Spectator] = 1; diff --git a/Simple Plugins Core/addons/sourcemod/scripting/simple-alltalkmanager.sp b/Simple Plugins Core/addons/sourcemod/scripting/simple-alltalkmanager.sp deleted file mode 100644 index c848332..0000000 --- a/Simple Plugins Core/addons/sourcemod/scripting/simple-alltalkmanager.sp +++ /dev/null @@ -1,515 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple AllTalk Manager -Description: - Allows you to set alltalk at different times -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#pragma semicolon 1 -#include -#include - -#define PLUGIN_VERSION "1.4.$Rev$" - -new Handle:satm_enabled = INVALID_HANDLE; -new Handle:satm_threshold_enabled = INVALID_HANDLE; -new Handle:satm_player_threshold = INVALID_HANDLE; -new Handle:satm_threshold_setting = INVALID_HANDLE; -new Handle:satm_logactivity = INVALID_HANDLE; -new Handle:satm_alltalk = INVALID_HANDLE; - -new Handle:g_aEventNames = INVALID_HANDLE; -new Handle:g_aEventReasons = INVALID_HANDLE; -new Handle:g_aEventSettings = INVALID_HANDLE; - -new bool:g_bLastThreshold = false; -new bool:g_bEnabled = true; -new bool:g_bThresholdEnabled = true; -new bool:g_bIsSetupMap = false; -new bool:g_bIsGameTF2 = false; -new bool:g_bLogActivity = false; - -new g_iLastEventIndex; - -public Plugin:myinfo = -{ - name = "Simple AllTalk Manager", - author = "Simple Plugins", - description = "Allows you to set alltalk at different times", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -} - -/** -Sourcemod callbacks -*/ -public OnPluginStart() -{ - - /** - Need to create all of our console variables. - */ - CreateConVar("satm_version", PLUGIN_VERSION, "Simple AllTalk Manager", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - satm_enabled = CreateConVar("satm_enabled", "1", "Enables/Disables Simple AllTalk Manager", _, true, 0.0, true, 1.0); - satm_threshold_enabled = CreateConVar("satm_threshold_enabled", "1", "Enables/Disables player threshold", _, true, 0.0, true, 1.0); - satm_player_threshold = CreateConVar("satm_player_threshold", "8", "Amount of players for the threshold"); - satm_threshold_setting = CreateConVar("satm_threshold_setting", "1", "Enables/Disables all talk up to player threshold, with the opposite set after the threshold", _, true, 0.0, true, 1.0); - satm_logactivity = CreateConVar("satm_logactivity", "0", "Enables/Disables log activity", _, true, 0.0, true, 1.0); - satm_alltalk = FindConVar("sv_alltalk"); - - /** - Hook console variables - */ - HookConVarChange(satm_enabled, ConVarSettingsChanged); - HookConVarChange(satm_threshold_enabled, ConVarSettingsChanged); - HookConVarChange(satm_player_threshold, ConVarSettingsChanged); - HookConVarChange(satm_logactivity, ConVarSettingsChanged); - - /** - Remove the notify flag from all talk cvar since we do it - */ - SetConVarFlags(satm_alltalk, GetConVarFlags(satm_alltalk)~FCVAR_NOTIFY); - - /** - Get the game type. We only care if it's TF2 - */ - new String:sGameType[64]; - GetGameFolderName(sGameType, sizeof(sGameType)); - if (StrEqual(sGameType, "tf", false)) - { - g_bIsGameTF2 = true; - } - - /** - Create the arrays - */ - g_aEventNames = CreateArray(255, 1); - g_aEventReasons = CreateArray(255, 1); - g_aEventSettings = CreateArray(1, 1); - - /** - Need to register the commands we are going to create and use. - */ - RegAdminCmd("sm_reloadatconfig", Command_Reload, ADMFLAG_GENERIC, "Reloads settings from config file"); - - /** - Create the config file - */ - AutoExecConfig(true); - - /** - Load the events from the config - */ - LoadEventsFromConfig(); -} - -public OnConfigsExecuted() -{ - - /** - Load up the settings - */ - g_bEnabled = GetConVarBool(satm_enabled); - g_bLogActivity = GetConVarBool(satm_logactivity); - g_bThresholdEnabled = GetConVarBool(satm_threshold_enabled); -} - -public OnMapStart() -{ - - /** - Reset the globals - */ - g_iLastEventIndex = 0; - g_bLastThreshold = false; - - /** - Check the map type if we are in TF2 - */ - if (g_bIsGameTF2) - { - g_bIsSetupMap = IsSetupPeriodMap(); - } - - /** - Set AllTalk - */ - if (g_bEnabled) - { - SetConVarBool(satm_alltalk, true); - } -} - -public OnClientDisconnect_Post(client) -{ - if (g_bEnabled) - { - SetAllTalk(-1); - } -} - -public OnClientPostAdminCheck(client) -{ - if (g_bEnabled) - { - SetAllTalk(-1); - } - CreateTimer(2.0, Timer_ShowAllTalkStatus, client, TIMER_FLAG_NO_MAPCHANGE); -} - -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (convar == satm_enabled) - { - if (StringToInt(newValue)) - { - g_bEnabled = true; - } - else - { - g_bEnabled = false; - } - } - else if (convar == satm_threshold_enabled) - { - if (StringToInt(newValue)) - { - g_bThresholdEnabled = true; - } - else - { - g_bThresholdEnabled = false; - } - } - else if (convar == satm_logactivity) - { - if (StringToInt(newValue)) - { - g_bLogActivity = true; - } - else - { - g_bLogActivity = false; - } - } - if (g_bEnabled) - { - SetAllTalk(-1); - } -} - -/** -Commands -*/ -public Action:Command_Reload(client, args) -{ - - /** - Clear the array - */ - ClearArray(g_aEventNames); - ClearArray(g_aEventReasons); - ClearArray(g_aEventSettings); - - /** - Load the events from the config - */ - LoadEventsFromConfig(); - - return Plugin_Handled; -} - -/** -Game Event Hooks -*/ -public Hook_All_Events(Handle:event, const String:name[], bool:dontBroadcast) -{ - if (!g_bIsSetupMap) - { - if (StrEqual(name, "teamplay_round_start")) - { - if (FindStringInArray(g_aEventNames, "teamplay_setup_finished") != -1) - { - g_iLastEventIndex = FindStringInArray(g_aEventNames, "teamplay_setup_finished"); - if (g_bEnabled) - { - SetAllTalk(g_iLastEventIndex); - return; - } - } - } - } - g_iLastEventIndex = FindStringInArray(g_aEventNames, name); - if (g_bEnabled) - { - SetAllTalk(g_iLastEventIndex); - } -} - -/** -Timers -*/ -public Action:Timer_ShowAllTalkStatus(Handle:timer, any:client) -{ - if (IsClientConnected(client) && IsClientInGame(client)) - { - new bool:bSetting = GetConVarBool(satm_alltalk); - if (bSetting) - { - PrintToChat(client, "\x01\x04[SM] AllTalk is \x01[on]"); - } - else - { - PrintToChat(client, "\x01\x04[SM] AllTalk is \x01[off]"); - } - } -} - -/** -Stock Functions -*/ -stock LoadEventsFromConfig() -{ - - /** - Make sure the config file is here and load it up - */ - new String:sConfigFile[256]; - BuildPath(Path_SM, sConfigFile, sizeof(sConfigFile), "configs/simple-alltalkmanager_events.cfg"); - if (!FileExists(sConfigFile)) - { - - /** - Config file doesn't exists, stop the plugin - */ - LogError("[SATM] Simple AllTalk Manager is not running! Could not find file %s", sConfigFile); - SetFailState("Could not find file %s", sConfigFile); - } - - /** - Create the arrays and variables - */ - new String:sGameEventName[256]; - new String:sReason[256]; - new iSetting; - - /** - Load config file as a KeyValues file - */ - new Handle:kvGameEvents = CreateKeyValues("game_events"); - FileToKeyValues(kvGameEvents, sConfigFile); - - if (!KvGotoFirstSubKey(kvGameEvents)) - { - return; - } - - /** - Hook the game events and load the settings - */ - do - { - - /** - Get the section name; this should be the event name - */ - KvGetSectionName(kvGameEvents, sGameEventName, sizeof(sGameEventName)); - if (!HookEventEx(sGameEventName, Hook_All_Events, EventHookMode_PostNoCopy)) - { - - /** - Could not hook this event, stop the plugin - */ - SetFailState("Could not hook event %s", sGameEventName); - } - else - { - if (g_bLogActivity) - { - LogMessage("[SATM] Hooked event: %s", sGameEventName); - } - } - - /** - Get the reason string and setting - */ - KvGetString(kvGameEvents, "reason", sReason, sizeof(sReason)); - iSetting = KvGetNum(kvGameEvents, "setting"); - if (g_bLogActivity) - { - LogMessage("[SATM] Event reason string: %s", sReason); - LogMessage("[SATM] Event setting: %i", iSetting); - } - - /** - Push the values to the arrays - */ - PushArrayString(g_aEventNames, sGameEventName); - PushArrayString(g_aEventReasons, sReason); - PushArrayCell(g_aEventSettings, iSetting); - } while (KvGotoNextKey(kvGameEvents)); - - /** - Close our handle - */ - CloseHandle(kvGameEvents); -} - -stock SetAllTalk(index) -{ - new iPlayerThreshold = GetConVarInt(satm_player_threshold); - new bool:bThresholdMet = ((GetClientCount() >= iPlayerThreshold) ? true : false); - new bool:bSetting; - - if (g_bThresholdEnabled) - { - if (bThresholdMet) - { - if (index == -1) - { - if (bThresholdMet != g_bLastThreshold) - { - g_bLastThreshold = true; - bSetting = !GetConVarBool(satm_threshold_setting); - new bool:bLastSetting = GetArrayCell(g_aEventSettings, g_iLastEventIndex); - if (bLastSetting && !bSetting) - { - bSetting = GetArrayCell(g_aEventSettings, g_iLastEventIndex); - } - } - else - { - bSetting = GetArrayCell(g_aEventSettings, g_iLastEventIndex); - } - } - else - { - bSetting = GetArrayCell(g_aEventSettings, index); - } - } - else - { - g_bLastThreshold = false; - bSetting = GetConVarBool(satm_threshold_setting); - } - } - else - { - if (index != -1) - { - bSetting = GetArrayCell(g_aEventSettings, index); - } - } - - if (GetConVarBool(satm_alltalk) != bSetting) - { - - SetConVarBool(satm_alltalk, bSetting); - - new String:sReason[256]; - if (index == -1) - { - Format(sReason, sizeof(sReason), "Player Threshold"); - } - else - { - if (!g_bIsSetupMap) - { - new String:sCurrentEvent[256]; - GetArrayString(g_aEventNames, index, sCurrentEvent, sizeof(sCurrentEvent)); - if (StrEqual(sCurrentEvent, "teamplay_setup_finished")) - { - new iRoundStartIndex = FindStringInArray(g_aEventNames, "teamplay_round_start"); - if (iRoundStartIndex != -1) - { - GetArrayString(g_aEventReasons, iRoundStartIndex, sReason, sizeof(sReason)); - } - else - { - GetArrayString(g_aEventReasons, index, sReason, sizeof(sReason)); - } - } - else - { - GetArrayString(g_aEventReasons, index, sReason, sizeof(sReason)); - } - } - else - { - GetArrayString(g_aEventReasons, index, sReason, sizeof(sReason)); - } - } - - if (bSetting) - { - PrintToChatAll("\x01\x04[SM] AllTalk turned \x01[on] \x04due to:\x01 %s", sReason); - } - else - { - PrintToChatAll("\x01\x04[SM] AllTalk turned \x01[off] \x04due to:\x01 %s", sReason); - } - } -} - -stock bool:IsSetupPeriodMap() -{ - new iEnt = -1; - new String:sMapName[32]; - - GetCurrentMap(sMapName, sizeof(sMapName)); - - if (strncmp(sMapName, "cp_", 3, false) == 0) - { - new iTeam; - while ((iEnt = FindEntityByClassname(iEnt, "team_control_point")) != -1) - { - iTeam = GetEntProp(iEnt, Prop_Send, "m_iTeamNum"); - - /** - If there is a blu CP or a neutral CP, then it's not an attack/defend map - */ - if (iTeam != 2) - { - //this is a push map - return false; - } - } - //this is a attack/defend map - return true; - } - else if (strncmp(sMapName, "ctf_", 3, false) == 0) - { - //this is a ctf map - return false; - } - return false; -} diff --git a/Simple Plugins Core/addons/sourcemod/scripting/simple-autoscrambler.sp b/Simple Plugins Core/addons/sourcemod/scripting/simple-autoscrambler.sp deleted file mode 100644 index 6c6799e..0000000 --- a/Simple Plugins Core/addons/sourcemod/scripting/simple-autoscrambler.sp +++ /dev/null @@ -1,459 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple AutoScrambler -Description: - Automatically scrambles the teams based upon a number of events. -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include - -#define PLUGIN_VERSION "1.1.$Rev$" - -/** -Different scramble modes: - -1 = Full Scramble, dont restart round. -2 = Admins Immune, dont restart round. -3 = Full Scramble, restart round and reset scores. -4 = Admins Immune, restart round and reset scores. - -*/ - -/** -Different top player modes: - -1 = Divide Top 4 players on the two teams. -2 = Protect the Top 2 players on each team. - -*/ - -enum PlayerData -{ - Handle:hForcedTimer, - bool:bProtected; -}; - -/** -Cvars used for admins -*/ -new Handle: sas_admin_immunity_enabled = INVALID_HANDLE, - Handle: sas_admin_flag_scramblenow = INVALID_HANDLE, - Handle: sas_admin_flag_immunity = INVALID_HANDLE; - -/** -Cvars used for autoscramble -*/ -new Handle: sas_autoscramble_enabled = INVALID_HANDLE, - Handle: sas_autoscramble_minplayers = INVALID_HANDLE, - Handle: sas_autoscramble_mode = INVALID_HANDLE, - Handle: sas_autoscramble_winstreak = INVALID_HANDLE, - Handle: sas_autoscramble_steamroll = INVALID_HANDLE, - Handle: sas_autoscramble_frags = INVALID_HANDLE; - -/** -Cvars used for voting -*/ -new Handle: sas_vote_enabled = INVALID_HANDLE, - Handle: sas_vote_upcount = INVALID_HANDLE, - Handle: sas_vote_winpercent = INVALID_HANDLE, - Handle: sas_vote_mode = INVALID_HANDLE, - Handle: sas_vote_minplayers = INVALID_HANDLE; - -/** -Additional cvars -*/ -new Handle: sas_enabled = INVALID_HANDLE, - Handle: sas_timer_scrambledelay = INVALID_HANDLE, - Handle: TFGameModeArena = INVALID_HANDLE; - -/** -Timers -*/ -new Handle: g_hScrambleTimer = INVALID_HANDLE; - -/** - Player arrays - */ -new g_aPlayers[MAXPLAYERS + 1][PlayerData]; - -/** - Cvar variables - */ -new bool: g_bIsEnabled, - bool: g_bIsAutoScrambleEnabled, - bool: g_bIsVoteEnabled, - bool: g_bIsAdminImmunityEnabled; -new Float: g_fTimer_ScrambleDelay, - Float: g_fVote_UpCount, - Float: g_fVote_WinPercent; -new g_iAutoScramble_Minplayers, - g_iAutoScramble_Mode, - g_iAutoScramble_WinStreak, - g_iAutoScramble_SteamRoll, - g_iAutoScramble_Frags, - g_iVote_Mode, - g_iVote_MinPlayers; -new String: g_sScrambleNowFlag[5], - String: g_sAdminImmunityFlag[5]; - -/** -Other globals -*/ -new g_iMaxEntities, - g_iOwnerOffset; - -public Plugin:myinfo = -{ - name = "Simple AutoScrambler", - author = "Simple Plugins", - description = "Automatically scrambles the teams based upon a number of events.", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -}; - -public OnPluginStart() -{ - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook the game events - */ - LogAction(0, -1, "[SAS] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - switch (g_CurrentMod) - { - case GameType_TF: - { - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - } - case GameType_DOD: - { - HookEvent("dod_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_Post); - } - default: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_Post); - } - } - - /** - Create console variables - */ - CreateConVar("sas_version", PLUGIN_VERSION, "Simple AutoScrambler Version",FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - sas_enabled = CreateConVar("sas_enabled", "1", "Enable/Disable Simple AutoScrambler"); - sas_timer_scrambledelay = CreateConVar("sas_timer_scrambledelay", "5.0", "Delay used after a scramble has been started", _, true, 1.0, true, 30.0); - - /** - Cvars used for admins - */ - sas_admin_immunity_enabled = CreateConVar("sas_admin_immunity_enabled", "1", "Enable/Disable admin immunity for scrambles"); - sas_admin_flag_scramblenow = CreateConVar("sas_admin_flag_scramblenow", "z", "Admin flag to use for scramblenow function/command"); - sas_admin_flag_immunity = CreateConVar("sas_admin_flag_immunity", "z", "Admin flag to use for scramble immunity"); - - /** - Cvars used for autoscramble - */ - sas_autoscramble_enabled = CreateConVar("sas_autoscramble_enabled", "1", "Enable/Disable the autoscramble function"); - sas_autoscramble_minplayers = CreateConVar("sas_autoscramble_minplayers", "16", "Min players needed to start an autoscramble"); - sas_autoscramble_mode = CreateConVar("sas_autoscramble_mode", "1", "Scramble mode used when autoscrambling"); - sas_autoscramble_winstreak = CreateConVar("sas_autoscramble_winstreak", "5", "Max amount of wins in a row a team can achieve before an autoscramble starts"); - sas_autoscramble_steamroll = CreateConVar("sas_autoscramble_steamroll", "120", "Shortest amount of time a team can win by before an autoscramble starts (seconds)"); - sas_autoscramble_frags = CreateConVar("sas_autoscramble_frags", "1", "Min players needed to start a vote and scramble"); - - /** - Cvars used for voting - */ - sas_vote_enabled = CreateConVar("sas_vote_enabled", "1", "Enable/Disable voting for scramble"); - sas_vote_upcount = CreateConVar("sas_vote_upcount", "5", "Amount of people wanting a scramble before a vote starts. If less than 1 it will be considered a percentage. (ie 0.5 = 50% | 1 = 1 Player | 5 = 5 Players)"); - sas_vote_winpercent = CreateConVar("sas_vote_winpercent", "0.6", "Percentage of votes needed to scramble", _, true, 0.0, true, 1.0); - sas_vote_mode = CreateConVar("sas_vote_mode", "1", "Scramble mode used when a vote results in a scramble"); - sas_vote_minplayers = CreateConVar("sas_vote_minplayers", "16", "Min players needed to start a vote and scramble"); - - /** - Hook the console variables if they change - */ - HookConVarChange(sas_enabled, ConVarSettingsChanged); - HookConVarChange(sas_timer_scrambledelay, ConVarSettingsChanged); - HookConVarChange(sas_admin_immunity_enabled, ConVarSettingsChanged); - HookConVarChange(sas_admin_flag_scramblenow, ConVarSettingsChanged); - HookConVarChange(sas_admin_flag_immunity, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_enabled, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_minplayers, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_mode, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_winstreak, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_steamroll, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_frags, ConVarSettingsChanged); - HookConVarChange(sas_vote_enabled, ConVarSettingsChanged); - HookConVarChange(sas_vote_upcount, ConVarSettingsChanged); - HookConVarChange(sas_vote_winpercent, ConVarSettingsChanged); - HookConVarChange(sas_vote_mode, ConVarSettingsChanged); - HookConVarChange(sas_vote_minplayers, ConVarSettingsChanged); - - /** - Register the command - */ - RegConsoleCmd("sm_scramblenow", Command_ScrambleNow, "sm_scramblenow (mode): Scrambles the teams"); - - /** - Load translations and .cfg file - */ - LoadTranslations ("simpleautoscrambler.phrases"); - AutoExecConfig(true, "plugin.simpleautoscrambler"); - LogAction(0, -1, "[SAS] Simple AutoScrambler is loaded."); -} - -public OnAllPluginsLoaded() -{ - //something -} - -public OnLibraryRemoved(const String:name[]) -{ - //something -} - -public OnConfigsExecuted() -{ - - /** - Load up all the variable defaults - */ - LoadUpVariables(); - - /** - Log our activity - */ - if (g_bIsEnabled) - LogAction(0, -1, "Simple AutoScrambler is ENABLED"); - else - LogAction(0, -1, "Simple AutoScrambler is DISABLED"); -} - -public Action:Command_ScrambleNow(client, args) -{ - - /** - Make sure we are enabled - */ - if (!g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - Make sure the client is authorized to run this command. - */ - if (!SM_IsValidAdmin(client, g_sScrambleNowFlag)) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Make sure it's ok to scramble at this time - */ - if (!OkToScramble) - { - return Plugin_Handled; - } - - /** - Make sure it's ok to scramble at this time - */ - LogAction(0, -1, "[SAS] The scramblenow command was used"); - - /** - Scramble the teams - */ - StartAScramble(); - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public HookRoundStart(Handle:event, const String:name[], bool:dontBroadcast) -{ - -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - -} - -public Action:Timer_ScrambleTeams(Handle:timer, any:mode) -{ - - /** - Make sure it's still ok to scramble - */ - if (!OkToScramble) - { - return Plugin_Handled; - } - - - switch (mode) - { - case - - - - } - - - /** - Reset the handle because the timer is over and the callback is done - */ - g_hScrambleTimer = INVALID_HANDLE; - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - -} - -stock StartAScramble(mode) -{ - - /** - See if we are already started a scramble - */ - if (g_hScrambleTimer == INVALID_HANDLE) - { - - /** - There is a scramble in progress - */ - return; - - } - - /** - Report that a scramble is about to start - */ - PrintCenterTextAll("%T", "Scramble", LANG_SERVER); - - /** - Start a timer and log the action - */ - g_hScrambleTimer = CreateTimer(g_fTimer_ScrambleDelay, Timer_ScrambleTeams, mode, TIMER_FLAG_NO_MAPCHANGE); - LogAction(0, -1, "[SAS] A scamble timer was started"); -} - -stock bool:OkToScramble() -{ - -} - -stock LoadUpVariables() -{ - g_bIsEnabled = GetConVarBool(sas_enabled); - g_bIsAutoScrambleEnabled = GetConVarBool(sas_autoscramble_enabled); - g_bIsVoteEnabled = GetConVarBool(sas_vote_enabled); - g_bIsAdminImmunityEnabled = GetConVarBool(sas_admin_immunity_enabled); - g_iAutoScramble_Minplayers = GetConVarInt(sas_autoscramble_minplayers); - g_iAutoScramble_Mode = GetConVarInt(sas_autoscramble_mode); - g_iAutoScramble_WinStreak = GetConVarInt(sas_autoscramble_winstreak); - g_iAutoScramble_SteamRoll = GetConVarInt(sas_autoscramble_steamroll); - g_iAutoScramble_Frags = GetConVarInt(sas_autoscramble_frags); - g_iVote_Mode = GetConVarInt(sas_vote_mode); - g_iVote_MinPlayers = GetConVarInt(sas_vote_minplayers); - GetConVarString(sas_admin_flag_scramblenow, g_sScrambleNowFlag, sizeof(g_sScrambleNowFlag)); - GetConVarString(sas_admin_flag_immunity, g_sAdminImmunityFlag, sizeof(g_sAdminImmunityFlag)); - g_fTimer_ScrambleDelay = GetConVarFloat(sas_timer_scrambledelay); - g_fVote_UpCount = GetConVarFloat(sas_vote_upcount); - g_fVote_WinPercent = GetConVarFloat(sas_vote_winpercent); - g_iMaxEntities = GetMaxEntities(); - g_iOwnerOffset = FindSendPropInfo("CBaseObject", "m_hBuilder"); -} - -stock TF2_DestroyBuildings(client) -{ - - /** - We have to start a loop to check the owner of all the valid entities - */ - for (new i = MaxClients + 1; i <= g_iMaxEntities; i++) - { - if (!IsValidEntity(i)) - { - - /** - Not valid, continue to next one - */ - continue; - } - - /** - Get the name of the current entity - */ - decl String:sNetClass[32]; - GetEntityNetClass(i, sNetClass, sizeof(sNetClass)); - - /** - See if its something that an engineer would build - */ - if (strcmp(sNetClass, "CObjectSentrygun") == 0 - || strcmp(sNetClass, "CObjectTeleporter") == 0 - || strcmp(sNetClass, "CObjectDispenser") == 0) - { - - /** - It is, so lets check the owner - */ - if (GetEntDataEnt2(i, g_iOwnerOffset) == client) - { - - /** - It's the clients building, so we blow it up. - */ - SetVariantInt(9999); - AcceptEntityInput(i, "RemoveHealth"); - } - } - } -} \ No newline at end of file diff --git a/Simple Plugins Core/addons/sourcemod/scripting/simple-chatcolors.sp b/Simple Plugins Core/addons/sourcemod/scripting/simple-chatcolors.sp deleted file mode 100644 index 539d057..0000000 --- a/Simple Plugins Core/addons/sourcemod/scripting/simple-chatcolors.sp +++ /dev/null @@ -1,496 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Chat Colors -Description: - Changes the colors of players chat based on config file -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#pragma semicolon 1 -#include -#include - -#define PLUGIN_VERSION "0.9.0.$Rev$" - -#define CHAT_SYMBOL '@' -#define TRIGGER_SYMBOL1 '!' -#define TRIGGER_SYMBOL2 '/' -#define CHAT_MAX_MESSAGE_LENGTH 1024 - -new Handle:g_hDebugCvar = INVALID_HANDLE; -new Handle:g_aGroupNames = INVALID_HANDLE; -new Handle:g_aGroupFlag = INVALID_HANDLE; -new Handle:g_aGroupNameColor = INVALID_HANDLE; -new Handle:g_aGroupTextColor = INVALID_HANDLE; - -new bool:g_bDebug = false; - -new g_iArraySize; - -new g_aPlayerColorIndex[MAXPLAYERS + 1] = { -1, ... }; - -public Plugin:myinfo = -{ - name = "Simple Chat Colors", - author = "Simple Plugins", - description = "Changes the colors of players chat based on config file.", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -}; - -/** -Sourcemod callbacks -*/ -public OnPluginStart() -{ - - /** - Need to create all of our console variables. - */ - CreateConVar("sm_chatcolors_version", PLUGIN_VERSION, "Simple Chat Colors", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - g_hDebugCvar = CreateConVar("sm_chatcolors_debug", "1", "Enable/Disable debugging information"); - - /** - Hook console variables - */ - HookConVarChange(g_hDebugCvar, ConVarSettingsChanged); - - /** - Need to register the commands we are going to use - */ - RegConsoleCmd("say", Command_Say); - RegConsoleCmd("say_team", Command_SayTeam); - RegAdminCmd("sm_reloadcolorsconfig", Command_Reload, ADMFLAG_GENERIC, "Reloads settings from config file"); - - /** - Create the arrays - */ - g_aGroupNames = CreateArray(256, 1); - g_aGroupFlag = CreateArray(15, 1); - g_aGroupNameColor = CreateArray(15, 1); - g_aGroupTextColor = CreateArray(15, 1); - - /** - Load the admins and colors from the config - */ - LoadAdminsAndColorsFromConfig(); - g_iArraySize = GetArraySize(g_aGroupNames); -} - -public OnConfigsExecuted() -{ - g_bDebug = GetConVarBool(g_hDebugCvar); - ReloadConfigFile(); -} - -public OnClientPostAdminCheck(client) -{ - - /** - Check the client to see if they are a admin - */ - CheckAdmin(client); -} - -public OnClientDisconnect(client) -{ - g_aPlayerColorIndex[client] = -1; -} - -/** -Commands -*/ -public Action:Command_Say(client, args) -{ - - /** - Make sure we are enabled. - */ - if (client == 0 || IsChatTrigger()) - { - return Plugin_Continue; - } - - if (g_aPlayerColorIndex[client] != -1) - { - - /** - The client is, so get the chat message and strip it down. - */ - decl String:sArg[CHAT_MAX_MESSAGE_LENGTH], - String:sChatMsg[CHAT_MAX_MESSAGE_LENGTH]; - - new bool:bAlive = IsPlayerAlive(client); - - GetCmdArgString(sArg, sizeof(sArg)); - StripQuotes(sArg); - TrimString(sArg); - new startidx; - if (sArg[strlen(sArg)-1] == '"') - { - sArg[strlen(sArg)-1] = '\0'; - startidx = 1; - } - - /** - Bug out if they are using the admin chat symbol (admin chat). If we are in CSS it may not find all the triggers, so we double check. - */ - if (sArg[startidx] == CHAT_SYMBOL || sArg[startidx] == TRIGGER_SYMBOL1 || sArg[startidx] == TRIGGER_SYMBOL2) - { - return Plugin_Continue; - } - - /** - Log the message for hlstatsx and other things. - */ - new iUserID = GetClientUserId(client); - decl String:sAuthID[64]; - GetClientAuthString(client, sAuthID, sizeof(sAuthID)); - LogToGame("\"%N<%i><%s><>\" say \"%s\"", client, iUserID, sAuthID, sArg); - - /** - Format the message. - */ - FormatMessage(client, 0, bAlive, sChatMsg, sArg, g_aPlayerColorIndex[client]); - - /** - Send the message. - */ - //SayText2(0, client, sChatMsg); - CPrintToChatAll(sChatMsg); - - /** - We are done, bug out, and stop the original chat message. - */ - return Plugin_Stop; - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -public Action:Command_SayTeam(client, args) -{ - - /** - Make sure we are enabled. - */ - if (client == 0 || IsChatTrigger()) - { - return Plugin_Continue; - } - - /** - Check the client to see if they are a admin - */ - if (g_aPlayerColorIndex[client] != -1) - { - - /** - The client is, so get the chat message and strip it down. - */ - decl String:sArg[CHAT_MAX_MESSAGE_LENGTH], - String:sChatMsg[CHAT_MAX_MESSAGE_LENGTH]; - - new bool:bAlive = IsPlayerAlive(client); - new iCurrentTeam = GetClientTeam(client); - - GetCmdArgString(sArg, sizeof(sArg)); - StripQuotes(sArg); - TrimString(sArg); - new startidx; - if (sArg[strlen(sArg)-1] == '"') - { - sArg[strlen(sArg)-1] = '\0'; - startidx = 1; - } - - /** - Bug out if they are using the admin chat symbol (admin chat). - */ - if (sArg[startidx] == CHAT_SYMBOL || sArg[startidx] == TRIGGER_SYMBOL1 || sArg[startidx] == TRIGGER_SYMBOL2) - { - return Plugin_Continue; - } - - /** - Log the message for hlstatsx and other things. - */ - new iUserID = GetClientUserId(client); - decl String:sAuthID[64]; - GetClientAuthString(client, sAuthID, sizeof(sAuthID)); - LogToGame("\"%N<%i><%s><>\" say_team \"%s\"", client, iUserID, sAuthID, sArg); - - /** - Format the message. - */ - FormatMessage(client, iCurrentTeam, bAlive, sChatMsg, sArg, g_aPlayerColorIndex[client]); - - /** - Send the message to the same team - */ - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientConnected(i) && IsClientInGame(i) && GetClientTeam(i) == iCurrentTeam) - { - CPrintToChat(client, sChatMsg); - } - } - - /** - We are done, bug out, and stop the original chat message. - */ - return Plugin_Stop; - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -public Action:Command_Reload(client, args) -{ - ReloadConfigFile(); - return Plugin_Handled; -} - -/** -Stock Functions -*/ -stock LoadAdminsAndColorsFromConfig() -{ - - /** - Make sure the config file is here and load it up - */ - new String:sConfigFile[256]; - BuildPath(Path_SM, sConfigFile, sizeof(sConfigFile), "configs/simple-chatcolors.cfg"); - if (!FileExists(sConfigFile)) - { - - /** - Config file doesn't exists, stop the plugin - */ - LogError("[SCC] Simple Chat Colors is not running! Could not find file %s", sConfigFile); - SetFailState("Could not find file %s", sConfigFile); - } - - /** - Create the arrays and variables - */ - new String:sGroupName[256]; - new String:sGroupFlag[15]; - new String:sGroupNameColor[15]; - new String:sGroupTextColor[15]; - - - /** - Load config file as a KeyValues file - */ - new Handle:kvChatColors = CreateKeyValues("admin_colors"); - FileToKeyValues(kvChatColors, sConfigFile); - - if (!KvGotoFirstSubKey(kvChatColors)) - { - return; - } - - /** - Load up all the groups in the file - */ - do - { - - /** - Get the section name; should be the "group" name - */ - KvGetSectionName(kvChatColors, sGroupName, sizeof(sGroupName)); - - - /** - Get the flags and colors - */ - KvGetString(kvChatColors, "flag", sGroupFlag, sizeof(sGroupFlag)); - KvGetString(kvChatColors, "namecolor", sGroupNameColor, sizeof(sGroupNameColor)); - KvGetString(kvChatColors, "textcolor", sGroupTextColor, sizeof(sGroupTextColor)); - - if (g_bDebug) - { - LogMessage("Group Name/SteamID: %s", sGroupName); - LogMessage("Flag String: %s", sGroupFlag); - LogMessage("Color on name: %s", sGroupNameColor); - LogMessage("Color of text: %s", sGroupTextColor); - } - - /** - Push the values to the arrays - */ - PushArrayString(g_aGroupNames, sGroupName); - PushArrayString(g_aGroupFlag, sGroupFlag); - PushArrayString(g_aGroupNameColor, sGroupNameColor); - PushArrayString(g_aGroupTextColor, sGroupTextColor); - } while (KvGotoNextKey(kvChatColors)); - - /** - Close our handle - */ - CloseHandle(kvChatColors); -} - -stock ReloadConfigFile() -{ - - /** - Clear the array - */ - ClearArray(g_aGroupNames); - ClearArray(g_aGroupFlag); - ClearArray(g_aGroupNameColor); - ClearArray(g_aGroupTextColor); - - /** - Load the admins, groups, and colors from the config - */ - LoadAdminsAndColorsFromConfig(); - g_iArraySize = GetArraySize(g_aGroupNames); - - /** - Recheck all the online players for assigned colors - */ - for (new index = 1; index <= MaxClients; index++) - { - if (IsClientConnected(index) && IsClientInGame(index)) - { - CheckAdmin(index); - } - } -} - -stock CheckAdmin(client) -{ - new String:sFlags[15]; - new String:sClientSteamID[64]; - new iGroupFlags; - new iFlags; - new iIndex = -1; - - /** - Look for a steamid first - */ - GetClientAuthString(client, sClientSteamID, sizeof(sClientSteamID)); - iIndex = FindStringInArray(g_aGroupNames, sClientSteamID); - if (iIndex != -1) - { - g_aPlayerColorIndex[client] = iIndex; - } - - /** - Didn't find one, check flags - */ - else - { - /** - Search for flag in groups - */ - - iFlags = GetUserFlagBits(client); - for (iIndex = 0; iIndex < g_iArraySize; iIndex++) - { - GetArrayString(g_aGroupFlag, iIndex, sFlags, sizeof(sFlags)); - iGroupFlags = ReadFlagString(sFlags); - if (iFlags & iGroupFlags) - { - g_aPlayerColorIndex[client] = iIndex; - break; - } - } - } - - if (g_bDebug) - { - PrintToChatAll("SteamID: %s", sClientSteamID); - PrintToChatAll("Array Index: %i", iIndex); - PrintToChatAll("Flag String: %s", sFlags); - PrintToChatAll("Flag Bits of Client: %i", iFlags); - PrintToChatAll("Flag Bits of Group: %i", iGroupFlags); - } -} - -stock FormatMessage(iClient, iTeam, bool:bAlive, String:sChatMsg[], const Sting:sMessage[], iArrayIndex) -{ - decl String:sDead[10], - String:sTeam[10], - String:sClientName[64]; - - GetClientName(iClient, sClientName, sizeof(sClientName)); - - if (iTeam != 0) - { - Format(sTeam, sizeof(sTeam), "(TEAM) "); - } - else - { - Format(sTeam, sizeof(sTeam), ""); - } - if (bAlive) - { - Format(sDead, sizeof(sDead), ""); - } - else - { - Format(sDead, sizeof(sDead), "*DEAD* "); - } - - new String:sNameColor[15]; - new String:sTextColor[15]; - GetArrayString(g_aGroupNameColor, iArrayIndex, sNameColor, sizeof(sNameColor)); - GetArrayString(g_aGroupTextColor, iArrayIndex, sTextColor, sizeof(sTextColor)); - - Format(sChatMsg, CHAT_MAX_MESSAGE_LENGTH, "{default}%s%s%s%s {default}: %s%s", sDead, sTeam, sNameColor, sClientName, sTextColor, sMessage); -} - -/** -Adjust the settings if a convar was changed -*/ -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (StringToInt(newValue) == 1) - { - g_bDebug = true; - } - else - { - g_bDebug = false; - } -} \ No newline at end of file diff --git a/Simple Plugins Core/addons/sourcemod/scripting/simple-donatorbenefits.sp b/Simple Plugins Core/addons/sourcemod/scripting/simple-donatorbenefits.sp deleted file mode 100644 index e3f6845..0000000 --- a/Simple Plugins Core/addons/sourcemod/scripting/simple-donatorbenefits.sp +++ /dev/null @@ -1,1312 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Donator Benefits -Description: - Provides donator benefits to players -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include -#include - -#define PLUGIN_VERSION "1.1.$Rev$" - -#define CHAT_SYMBOL '@' -#define CHAT_MAX_MESSAGE_LENGTH 1024 - -enum PlayerData -{ - bool:bIsDonator, - bool:bQueue, - bool:bImmune, - iHealthCount, - iNewTeam -}; - -/** - Public convar handles - */ -new Handle:sdb_enabled = INVALID_HANDLE; -new Handle:sdb_donationflag = INVALID_HANDLE; -new Handle:sdb_soundfile = INVALID_HANDLE; -new Handle:sdb_joinsound_enabled = INVALID_HANDLE; -new Handle:sdb_joinpubmsg_enabled = INVALID_HANDLE; -new Handle:sdb_joinprivmsg_enabled = INVALID_HANDLE; -new Handle:sdb_chatcolors_enabled = INVALID_HANDLE; -new Handle:sdb_immunity_enabled = INVALID_HANDLE; -new Handle:sdb_ubercharge_enabled = INVALID_HANDLE; -new Handle:sdb_givehealth_enabled = INVALID_HANDLE; -new Handle:sdb_nofalldmg_enabled = INVALID_HANDLE; -new Handle:sdb_fastheavy_enabled = INVALID_HANDLE; -new Handle:sdb_swapteam_enabled = INVALID_HANDLE; -new Handle:sdb_chatcolor = INVALID_HANDLE; -new Handle:sdb_uberlevel = INVALID_HANDLE; -new Handle:sdb_healthcount = INVALID_HANDLE; -new Handle:sdb_healthbonus = INVALID_HANDLE; -new Handle:sdb_heavymultiplier = INVALID_HANDLE; - -/** -Create global enable/disable bools so we don't have to check the console variable on every call -*/ -new bool:g_bIsEnabled = true; -new bool:g_bIsJoinSoundEnabled = true; -new bool:g_bIsJoinPubMsgEnabled = true; -new bool:g_bIsJoinPrivMsgEnabled = true; -new bool:g_bIsChatColorsEnabled = true; -new bool:g_bIsImmuntyEnabled = true; -new bool:g_bIsUberChargeEnabled = true; -new bool:g_bIsGiveHealthEnabled = true; -new bool:g_bIsNoFallDmgEnabled = true; -new bool:g_bIsFastHeayEnabled = true; -new bool:g_bIsSwapTeamEnabled = true; - -/** - Player arrays - */ -new g_aPlayers[MAXPLAYERS + 1][PlayerData]; - - -/** -Rest of the globals -*/ -new bool:g_bRoundEnd = false; -new String:g_sCharDonatorFlag[5]; -new String:g_sSoundFile[PLATFORM_MAX_PATH]; -new String:g_sChatColor[11]; -new g_iHealthBonus; -new g_iHealthCount; -new g_iClassMaxHealth[TFClassType] = {0, 125, 125, 200, 175, 150, 300, 175, 125, 125}; -new g_fClassMaxSpeed[TFClassType] = {0, 400, 300, 240, 280, 320, 230, 300, 300, 300}; -new Float:g_fHeavyMultiplier = 0.0; -new Float:g_fUberLevel = 0.0; - -public Plugin:myinfo = -{ - name = "Simple Donation Benefits", - author = "Simple Plugins", - description = "Gives donators benefits to players", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -} - -public OnPluginStart() -{ - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook the game events - */ - LogAction(0, -1, "[SDB] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_connect", HookPlayerSpawn, EventHookMode_Pre); - HookEvent("player_spawn", HookPlayerSpawn, EventHookMode_Post); - HookEvent("player_death", HookPlayerDeath, EventHookMode_Post); - HookEvent("player_team", HookPlayerChangeTeam, EventHookMode_Post); - switch (g_CurrentMod) - { - case GameType_TF: - { - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - HookEvent("player_changeclass", HookPlayerClass, EventHookMode_Post); - } - case GameType_DOD: - { - HookEvent("dod_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_Post); - } - default: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - } - } - - /** - Create console variables - */ - CreateConVar("sdb_version", PLUGIN_VERSION, "Simple Donation Benefits", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - sdb_enabled = CreateConVar("sdb_enabled", "1", "Enable/Disable Simple Donation Benefits"); - sdb_donationflag = CreateConVar("sdb_donationflag", "a", "Flag ALREADY given to donators. Must be in char format"); - - /** - Create the enable/disable donator console variables - */ - sdb_joinsound_enabled = CreateConVar("sdb_joinsound_enabled", "1", "Enable/Disable donator join sound"); - sdb_joinpubmsg_enabled = CreateConVar("sdb_joinpubmsg_enabled", "1", "Enable/Disable public donator join message (replaces: as connected)"); - sdb_joinprivmsg_enabled = CreateConVar("sdb_joinprivmsg_enabled", "1", "Enable/Disable private donator join message (sent only to donator)"); - sdb_chatcolors_enabled = CreateConVar("sdb_chatcolors_enabled", "1", "Enable/Disable donator chat colors"); - sdb_immunity_enabled = CreateConVar("sdb_immunity_enabled", "1", "Enable/Disable donator round end immunity"); - sdb_ubercharge_enabled = CreateConVar("sdb_ubercharge_enabled", "1", "Enable/Disable donator medics starting with ubercharge"); - sdb_givehealth_enabled = CreateConVar("sdb_givehealth_enabled", "1", "Enable/Disable donator instant health bonus"); - sdb_nofalldmg_enabled = CreateConVar("sdb_nofalldmg_enabled", "1", "Enable/Disable no fall damage for donators"); - sdb_fastheavy_enabled = CreateConVar("sdb_fastheavy_enabled", "1", "Enable/Disable donator heavies moving faster while spinning"); - sdb_swapteam_enabled = CreateConVar("sdb_swampteam_enabled", "1", "Enable/Disable donator swap team ability"); - - /** - Create the donator setting console variables - */ - sdb_soundfile = CreateConVar("sdb_soundfile", "custom/donatorjoin.mp3", "The location of sound file"); - sdb_chatcolor = CreateConVar("sdb_chatcolor", "green", "Color to use for donator chat. Valid colors are green and lightgreen"); - sdb_uberlevel = CreateConVar("sdb_uberlevel", "0.5", "Uberlevel to give donator medic at spawn. 1.0 = full uber", _, true, 0.0, true, 1.0); - sdb_healthcount = CreateConVar("sdb_healthcount", "1", "Number of times a donator can use use instant health per life"); - sdb_healthbonus = CreateConVar("sdb_healthbonus", "100", "The amount of health to heal the donator"); - sdb_heavymultiplier = CreateConVar("sdb_heavyspeed", "0.5", "The speed multiplier for the fast heavy. Based on running speed. 1.0 = running speed. (Game Default is 0.20)", _, true, 0.0, true, 1.0); - - /** - Hook dukehacks calls - */ - dhAddClientHook(CHK_TakeDamage, Hacks_TakeDamageHook); - dhAddClientHook(CHK_PreThink, Hacks_PreThinkHook); - - /** - Hook the console variables if they change - */ - HookConVarChange(sdb_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_donationflag, ConVarSettingsChanged); - HookConVarChange(sdb_joinsound_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_joinpubmsg_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_joinprivmsg_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_chatcolors_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_immunity_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_ubercharge_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_givehealth_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_nofalldmg_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_swapteam_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_fastheavy_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_soundfile, ConVarSettingsChanged); - HookConVarChange(sdb_chatcolor, ConVarSettingsChanged); - HookConVarChange(sdb_uberlevel, ConVarSettingsChanged); - HookConVarChange(sdb_healthcount, ConVarSettingsChanged); - HookConVarChange(sdb_healthbonus, ConVarSettingsChanged); - HookConVarChange(sdb_heavymultiplier, ConVarSettingsChanged); - - /** - Register the commands - */ - RegConsoleCmd("sm_swapteams", Command_SwapTeam, "sm_swapteams <[0]instant/[1]queued>: Swaps your team to the other team"); - RegConsoleCmd("sm_ihealth", Command_InstantHealth, "sm_ihealth: Gives you a instant health pack"); - RegAdminCmd("sm_teaser", Command_Teaser, ADMFLAG_GENERIC,"sm_teaser <[0]add/[1]remove>: Gives temporary donator privilages to a player"); - RegConsoleCmd("say", Command_Say); - - RegConsoleCmd("sm_test", Command_TEST); - - /** - Load the translations - */ - LoadTranslations("common.phrases"); - LoadTranslations("simpledonatorbenefits.phrases"); - - /** - Load or create the config file - */ - AutoExecConfig(true, "plugin.simpledonatorbenefits"); - LogAction(0, -1, "[SDB] Simple Donator Benefits is loaded."); -} - -public OnAllPluginsLoaded() -{ - //something -} - -public OnLibraryRemoved(const String:name[]) -{ - //something -} - -public OnConfigsExecuted() -{ - /** - Load up all the variable defaults - */ - LoadUpVariables(); - - /** - If the join sound is enabled, prep the sound files - */ - if (g_bIsJoinSoundEnabled) - PrepSoundFile(); - - /** - Log our activity - */ - if (g_bIsEnabled) - LogAction(0, -1, "Simple Donation Benefits is ENABLED"); - else - LogAction(0, -1, "Simple Donation Benefits is DISABLED"); -} - -public OnClientPostAdminCheck(client) -{ - - /** - Check if the client is a donator - */ - if (SM_IsValidAdmin(client, g_sCharDonatorFlag)) - { - - /** - They are, so we set the player array to true and start a timer for the sound or add - */ - g_aPlayers[client][bIsDonator] = true; - if (g_bIsJoinSoundEnabled || g_bIsJoinPrivMsgEnabled) - { - CreateTimer(10.0, Timer_DonatorJoined, client, TIMER_FLAG_NO_MAPCHANGE); - } - } - else - { - /** - They aren't, so we set the player array to false - */ - g_aPlayers[client][bIsDonator] = false; - } -} - -public OnClientDisconnect_Post(client) -{ - - /** - Clean up the player variables - */ - CleanUpPlayer(client); -} - -public Action:Command_SwapTeam(client, args) -{ - - /** - Make sure we are enabled - */ - if (!g_bIsEnabled || !g_bIsSwapTeamEnabled) - { - return Plugin_Handled; - } - - /** - Make sure the command is not started by the server - */ - if (client == 0) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "PlayerLevelCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Make sure the player is a donator - */ - if (!g_aPlayers[client][bIsDonator]) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Lets make sure the client is one a team we can swap. - If he is we set the global array to the opposite team. - */ - new iTeam = GetClientTeam(client); - if (iTeam == g_aCurrentTeams[Team1]) - { - g_aPlayers[client][iNewTeam] = g_aCurrentTeams[Team2]; - } - else if (iTeam == g_aCurrentTeams[Team2]) - { - g_aPlayers[client][iNewTeam] = g_aCurrentTeams[Team1]; - } - else - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "InValidTeam", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check to see if we have command arguments. - */ - if (GetCmdArgs()) - { - - /** - We do, so lets get it and see if the client wants to be switched instantly or queued for death. - */ - decl String:sArg[5]; - GetCmdArg(1, sArg, sizeof(sArg)); - new iWantsQue = StringToInt(sArg); - if (iWantsQue && !g_aPlayers[client][bQueue]) - { - - /** - He wants the que and isn't already in it, set the global array. - */ - g_aPlayers[client][bQueue] = true; - ReplyToCommand(client, "\x01\x04[STM]\x01 %T", "PlayerQueue", LANG_SERVER); - } - else if (!iWantsQue) - { - - /** - He wants to be switched right now, lets call the stock function. - */ - SM_MovePlayer(client, g_aPlayers[client][iNewTeam]); - } - } - else - { - - /** - There are no command arguments so we build and display the swap menu. - */ - new Handle:hPlayerMenu = BuildSwapModeMenu(); - DisplayMenu(hPlayerMenu, client, MENU_TIME_FOREVER); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_InstantHealth(client, args) -{ - - /** - Make sure we are enabled - */ - if (!g_bIsEnabled || !g_bIsGiveHealthEnabled) - { - return Plugin_Handled; - } - - /** - Make sure the command is not started by the server - */ - if (client == 0) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "PlayerLevelCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Make sure the player is a donator - */ - if (!g_aPlayers[client][bIsDonator]) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check health count to see if the player has reached the max - */ - if (g_aPlayers[client][iHealthCount] >= g_iHealthCount) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "ReachedCount", LANG_SERVER); - return Plugin_Handled; - } - - /** - Get the class of the player and the max health for that class - */ - new iHealth = GetClientHealth(client); - new TFClassType:PlayerClass = TF2_GetPlayerClass(client); - new iMaxHealth = g_iClassMaxHealth[PlayerClass]; - - /** - Check to see if the player is at the max health of the class - */ - if (iHealth >= iMaxHealth) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "AtMaxHealth", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check the current health - */ - if (iHealth + g_iHealthBonus >= iMaxHealth) - { - - /** - Raise them to max health if the current health + bonus would go above it - */ - SetEntityHealth(client, iMaxHealth); - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "ToMaxHealth", LANG_SERVER); - } - else - { - - /** - Give them the instant health bonus - */ - SetEntityHealth(client, iHealth + g_iHealthBonus); - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "HealthBonus", LANG_SERVER); - } - - /** - Increase the count - */ - g_aPlayers[client][iHealthCount] += 1; - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_Teaser(client, args) -{ - - /** - Make sure we are enabled - */ - if (!g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - Check to see if we have command arguments. - */ - new iCmdArgs = GetCmdArgs(); - if (iCmdArgs == 0) - { - - /** - We don't so display the player menu. - */ - new Handle:hPlayerMenu = BuildPlayerMenu(); - DisplayMenu(hPlayerMenu, client, MENU_TIME_FOREVER); - return Plugin_Handled; - } - - /** - We have some arguments, see if we can find the player - */ - decl String:sPlayer[64]; - GetCmdArg(1, sPlayer, sizeof(sPlayer)); - new iTarget = FindTarget(client, sPlayer, true, true); - if (iTarget == -1 || !IsClientInGame(iTarget)) - { - - /** - We don't know who this is, so display the player menu. - */ - new Handle:hPlayerMenu = BuildPlayerMenu(); - DisplayMenu(hPlayerMenu, client, MENU_TIME_FOREVER); - } - else - { - /** - We found the player, see if we are supposed to turn it on or off. - */ - if (iCmdArgs >= 2) - { - decl String:sOn[3]; - GetCmdArg(2, sOn, sizeof(sOn)); - if (StringToInt(sOn)) - { - - /** - Turn temp benefits on. - */ - g_aPlayers[iTarget][bIsDonator] = true; - } - else - { - - /** - Turn temp benefits on. - */ - g_aPlayers[iTarget][bIsDonator] = false; - } - } - else - { - - /** - We don't know what to do, so just turn it on. - */ - g_aPlayers[iTarget][bIsDonator] = true; - } - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_Say(client, args) -{ - - /** - Make sure we are enabled. - */ - if (client == 0 || IsChatTrigger() || !g_bIsChatColorsEnabled || !g_bIsEnabled) - { - return Plugin_Continue; - } - - /** - Check the client to see if they are a donator. - */ - if (g_aPlayers[client][bIsDonator]) - { - - /** - The client is, so get the chat message and strip it down. - */ - decl String:sArg[CHAT_MAX_MESSAGE_LENGTH], - String:sChatMsg[CHAT_MAX_MESSAGE_LENGTH]; - new bool:bAlive = IsPlayerAlive(client); - GetCmdArgString(sArg, sizeof(sArg)); - StripQuotes(sArg); - TrimString(sArg); - new startidx; - if (sArg[strlen(sArg)-1] == '"') - { - sArg[strlen(sArg)-1] = '\0'; - startidx = 1; - } - - /** - Bug out if they are using the admin chat symbol (admin chat). - */ - if (sArg[startidx] == CHAT_SYMBOL) - { - return Plugin_Continue; - } - - /** - Format the message. - */ - FormatMessage(client, 0, bAlive, sChatMsg, sArg); - - /** - Send the message. - */ - SayText2(0, client, sChatMsg); - - /** - We are done, bug out, and stop the original chat message. - */ - return Plugin_Stop; - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -public Action:Hacks_TakeDamageHook(client, attacker, inflictor, Float:damage, &Float:multiplier, damagetype) -{ - - /** - Make sure we are enabled and the client is a donator. - */ - if (g_bIsEnabled && g_bIsNoFallDmgEnabled && g_aPlayers[client][bIsDonator]) - { - - /** - Check for fall damage. - */ - if (damagetype & DMG_FALL) - { - - /** - Cancel the fall damage and bug out. - */ - multiplier *= 0.0; - return Plugin_Changed; - } - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -public Action:Hacks_PreThinkHook(client) -{ - - /** - Make sure we are enabled and the client is a donator. - */ - if (!g_bIsEnabled || !g_bIsFastHeayEnabled || !g_aPlayers[client][bIsDonator]) - { - return Plugin_Continue; - } - - /** - Check the players class. We are looking for the heavy. - */ - new TFClassType:PlayerClass = TF2_GetPlayerClass(client); - if (PlayerClass == TFClass_Heavy) - { - - /** - We have a heavy, lets check the weapon. - */ - decl String:sWeaponCurrent[64]; - GetClientWeapon(client, sWeaponCurrent, sizeof(sWeaponCurrent)); - if (StrEqual(sWeaponCurrent, "tf_weapon_minigun", false)) - { - - /** - We have a minigun, check the heavies current weapon state to see if it's spinning. - */ - new iWeapon = GetPlayerWeaponSlot(client, 0); - new iWeaponState = GetEntProp(iWeapon, Prop_Send, "m_iWeaponState"); - if (iWeaponState > 0) - { - - /** - He is spinning, so lets change the heavies speed. - */ - new Float:fMaxSpeed = FloatMul(g_fHeavyMultiplier, float(g_fClassMaxSpeed[PlayerClass])); - SetEntPropFloat(client, Prop_Send, "m_flMaxspeed", fMaxSpeed); - } - } - } - - /** - We are done, bug out. - */ - // use Plugin_Continue (other options are ignored on PreThink hook) - return Plugin_Continue; -} - -public Action:HookPlayerConnect(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Make sure we are enabled. - */ - if (!g_bIsEnabled || !g_bIsJoinPubMsgEnabled || !dontBroadcast) - { - return Plugin_Continue; - } - - /** - Get our event variables and check the client. - */ - new iUserId = GetEventInt(event,"userid"); - new iClient = GetClientOfUserId(iUserId); - if (iClient != 0) - { - - /** - Get the info on the client and format the message. - */ - decl String:sClientName[255], - String:sAuthID[255], - String:sMsg[1024]; - - GetEventString(event, "name", sClientName, sizeof(sClientName)); - GetClientAuthString(iClient, sAuthID, sizeof(sAuthID)); - Format(sMsg, sizeof(sMsg), "%T", "PublicJoinMessage", LANG_SERVER, sClientName); - - /** - Print the message to the clients and do the normal functions. - */ - for (new i = 1; i <= MaxClients; i++) - { - if(IsClientConnected(i) && IsClientInGame(i)) - { - PrintToChat(i,"\x01\x05%s", sMsg); - PrintToConsole(i,"%s has connected.", sClientName); - } - } - LogToGame("\"%s<%d><%s><>\" entered the game", sClientName, iUserId, sAuthID); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public HookPlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled && g_bIsUberChargeEnabled) - { - - /** - Get the event variables and check the class for medic - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - if (TF2_GetPlayerClass(iClient) == TFClass_Medic) - { - - /** - Start a timer to get the medic the uber boost - */ - CreateTimer(0.25, Timer_PlayerUberDelay, iClient, TIMER_FLAG_NO_MAPCHANGE); - } - } -} - -public HookPlayerClass(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled && g_bIsUberChargeEnabled) - { - - /** - Get the event variables and check the class for medic - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - if (TF2_GetPlayerClass(iClient) == TFClass_Medic) - { - - /** - Start a timer to get the medic the uber boost - */ - CreateTimer(0.25, Timer_PlayerUberDelay, iClient, TIMER_FLAG_NO_MAPCHANGE); - } - } -} - -public HookPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled || g_bIsSwapTeamEnabled) - { - - /** - Get the event variables - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - new String:sWeapon[256]; - GetEventString(event, "weapon", sWeapon, sizeof(sWeapon)); - - /** - Bug out if world killed him. Means he changed team or something - */ - if (StrEqual(sWeapon, "world", false)) - { - g_aPlayers[iClient][bQueue] = false; - return; - } - - /** - If he is queued up, swap him - */ - if (g_aPlayers[iClient][bQueue]) - { - SM_MovePlayer(iClient, g_aPlayers[iClient][iNewTeam]); - } - } -} - -public HookPlayerChangeTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled || g_bIsSwapTeamEnabled) - { - - /** - Get the event variables - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - - /** - If he is queued up, clear the status - */ - if (g_aPlayers[iClient][bQueue]) - { - g_aPlayers[iClient][bQueue] = false; - } - } -} - -public HookRoundStart(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Set our variables. - */ - g_bRoundEnd = false; - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled && g_bIsImmuntyEnabled) - { - - /** - Get rid of their immunity. - */ - ProcessRoundEndImmunity(false); - } -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Set our variables. - */ - g_bRoundEnd = true; - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled && g_bIsImmuntyEnabled) - { - - /** - Give them their immunity. - */ - ProcessRoundEndImmunity(true); - } -} - -public Action:Timer_DonatorJoined(Handle:timer, any:client) -{ - - /** - Make sure sounds are enabled. - */ - if (g_bIsEnabled && g_bIsJoinSoundEnabled) - { - EmitSoundToClient(client, g_sSoundFile); - } - - /** - Make sure private messages are enabled. - */ - if (g_bIsJoinPrivMsgEnabled) - { - - /** - Send messages to the client. - */ - decl String:sMsg[1024]; - Format(sMsg, sizeof(sMsg), "%T", "PrivateJoinMessage", LANG_SERVER); - PrintToChat(client,"\x01\x05%s", sMsg); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Timer_PlayerUberDelay(Handle:timer, any:client) -{ - - /** - Make sure the client is still in game. - */ - if (IsClientInGame(client)) - { - - /** - Make sure the client is still a medic. - */ - if (TF2_GetPlayerClass(client) == TFClass_Medic) - { - - /** - Get the medgun weapon index - */ - new iIndex = GetPlayerWeaponSlot(client, 1); - if (iIndex > 0) - { - - /** - Set the uber level with the bonus. - */ - SetEntPropFloat(iIndex, Prop_Send, "m_flChargeLevel", g_fUberLevel); - } - } - } -} - -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (convar == sdb_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsEnabled = false; - } - else - { - g_bIsEnabled = true; - } - } - else if (convar == sdb_donationflag) - { - Format(g_sCharDonatorFlag, sizeof(g_sCharDonatorFlag), "%s", newValue); - } - else if (convar == sdb_soundfile) - { - Format(g_sSoundFile, sizeof(g_sSoundFile), "%s", newValue); - } - else if (convar == sdb_joinsound_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsJoinSoundEnabled = false; - } - else - { - g_bIsJoinSoundEnabled = true; - } - } - else if (convar == sdb_joinpubmsg_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsJoinPubMsgEnabled = false; - } - else - { - g_bIsJoinPubMsgEnabled = true; - } - } - else if (convar == sdb_joinprivmsg_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsJoinPrivMsgEnabled = false; - } - else - { - g_bIsJoinPrivMsgEnabled = true; - } - } - else if (convar == sdb_chatcolors_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsChatColorsEnabled = false; - } - else - { - g_bIsChatColorsEnabled = true; - } - } - else if (convar == sdb_immunity_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsImmuntyEnabled = false; - } - else - { - g_bIsImmuntyEnabled = true; - } - } - else if (convar == sdb_ubercharge_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsUberChargeEnabled = false; - } - else - { - g_bIsUberChargeEnabled = true; - } - } - else if (convar == sdb_givehealth_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsGiveHealthEnabled = false; - } - else - { - g_bIsGiveHealthEnabled = true; - } - } - else if (convar == sdb_nofalldmg_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsNoFallDmgEnabled = false; - } - else - { - g_bIsNoFallDmgEnabled = true; - } - } - else if (convar == sdb_fastheavy_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsFastHeayEnabled = false; - } - else - { - g_bIsFastHeayEnabled = true; - } - } - else if (convar == sdb_swapteam_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsSwapTeamEnabled = false; - } - else - { - g_bIsSwapTeamEnabled = true; - } - } - else if (convar == sdb_chatcolor) - { - Format(g_sChatColor, sizeof(g_sChatColor), "%s", newValue); - } - else if (convar == sdb_uberlevel) - { - g_fUberLevel = StringToFloat(newValue); - } - else if (convar == sdb_healthcount) - { - g_iHealthCount = StringToInt(newValue); - } - else if (convar == sdb_healthbonus) - { - g_iHealthBonus = StringToInt(newValue); - } - else if (convar == sdb_heavymultiplier) - { - g_fHeavyMultiplier = StringToFloat(newValue); - } -} - -stock LoadUpVariables() -{ - g_bIsEnabled = GetConVarBool(sdb_enabled); - g_bIsJoinSoundEnabled = GetConVarBool(sdb_enabled); - g_bIsJoinPubMsgEnabled = GetConVarBool(sdb_enabled); - g_bIsJoinPrivMsgEnabled = GetConVarBool(sdb_enabled); - g_bIsChatColorsEnabled = GetConVarBool(sdb_enabled); - g_bIsImmuntyEnabled = GetConVarBool(sdb_enabled); - g_bIsUberChargeEnabled = GetConVarBool(sdb_enabled); - g_bIsGiveHealthEnabled = GetConVarBool(sdb_enabled); - g_bIsNoFallDmgEnabled = GetConVarBool(sdb_enabled); - g_bIsFastHeayEnabled = GetConVarBool(sdb_enabled); - g_bIsSwapTeamEnabled = GetConVarBool(sdb_enabled); - GetConVarString(sdb_donationflag, g_sCharDonatorFlag, sizeof(g_sCharDonatorFlag)); - GetConVarString(sdb_soundfile, g_sSoundFile, sizeof(g_sSoundFile)); - GetConVarString(sdb_chatcolor, g_sChatColor, sizeof(g_sChatColor)); - g_bRoundEnd = false; - g_iHealthBonus = GetConVarInt(sdb_healthbonus); - g_iHealthCount = GetConVarInt(sdb_healthcount); - g_fHeavyMultiplier = GetConVarFloat(sdb_heavymultiplier); - g_fUberLevel = GetConVarFloat(sdb_uberlevel); -} - -stock PrepSoundFile() -{ - decl String:buffer[PLATFORM_MAX_PATH]; - PrecacheSound(g_sSoundFile, true); - Format(buffer, sizeof(buffer), "sound/%s", g_sSoundFile); - AddFileToDownloadsTable(buffer); -} - -stock CleanUpPlayer(client) -{ - g_aPlayers[client][bIsDonator] = false; - g_aPlayers[client][bQueue] = false; - g_aPlayers[client][bImmune] = false; - g_aPlayers[client][iNewTeam] = 0; - g_aPlayers[client][iHealthCount] = 0; -} - -stock ProcessRoundEndImmunity(bool:give) -{ - for (new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][bIsDonator]) - { - if (give) - { - SetEntProp(i, Prop_Data, "m_takedamage", 0, 1); - g_aPlayers[i][bImmune] = true; - } - else - { - SetEntProp(i, Prop_Data, "m_takedamage", 2, 1); - g_aPlayers[i][bImmune] = false; - } - } - } -} - -stock FormatMessage(iClient, iTeam, bool:bAlive, String:sChatMsg[], const Sting:sMessage[]) -{ - decl String:sDead[10], - String:sTeam[10], - String:sClientName[64]; - GetClientName(iClient, sClientName, sizeof(sClientName)); - if (iTeam != 0) - Format(sTeam, sizeof(sTeam), "(TEAM) "); - else - Format(sTeam, sizeof(sTeam), ""); - if (bAlive) - Format(sDead, sizeof(sDead), ""); - else - Format(sDead, sizeof(sDead), "*DEAD* "); - if (StrContains(g_sChatColor, "light", false) == -1) - Format(sChatMsg, CHAT_MAX_MESSAGE_LENGTH, "\x01%s%s\x03%s \x01: \x05%s", sDead, sTeam, sClientName, sMessage); - else - Format(sChatMsg, CHAT_MAX_MESSAGE_LENGTH, "\x01%s%s\x03%s \x01: \x04%s", sDead, sTeam, sClientName, sMessage); -} - -stock SayText2(target, author, const String:message[]) -{ - new Handle:hBf; - if (target == 0) - hBf = StartMessageAll("SayText2"); - else - hBf = StartMessageOne("SayText2", target); - if (hBf != INVALID_HANDLE) - { - BfWriteByte(hBf, author); - BfWriteByte(hBf, true); - BfWriteString(hBf, message); - EndMessage(); - } -} - -stock ProcessAdmins() -{ - for (new i = 1; i <= MaxClients; i++) - { - if (SM_IsValidAdmin(i, g_sCharDonatorFlag)) - { - g_aPlayers[i][bDonator] = true; - } - else - { - g_aPlayers[i][bDonator] = false; - } - } -} - -stock ProcessLate() -{ - if (g_bIsEnabled) - { - ProcessAdmins(); - PrepSoundFile(); - if (g_bRoundEnd && g_bIsImmuntyEnabled) - { - ProcessRoundEndImmunity(true); - } - if (!g_bIsImmuntyEnabled) - { - ProcessRoundEndImmunity(false); - } - } - else - { - ProcessRoundEndImmunity(false); - } -} - -public Menu_SwapMode(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, 64); - if (StringToInt(sSelection)) - g_aPlayers[param1][bQueue] = false; - else - g_aPlayers[param1][bQueue] = true; - if (!g_aPlayers[param1][bQueue]) - SM_MovePlayer(param1, g_aPlayers[param1][iNewTeam]); - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -public Menu_SelectPlayer(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[256]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - new iTarget = GetClientOfUserId(StringToInt(sSelection)); - if (g_aPlayers[iTarget][bIsDonator]) - g_aPlayers[iTarget][bIsDonator] = false; - else - g_aPlayers[iTarget][bIsDonator] = true; - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -stock Handle:BuildSwapModeMenu() -{ - new Handle:menu = CreateMenu(Menu_SwapMode); - SetMenuTitle(menu, "Select When to Swap:"); - AddMenuItem(menu, "0", "Instantly (Kills)"); - AddMenuItem(menu, "1", "Queue on next death"); - SetMenuExitBackButton(menu, false); - return menu; -} - -stock Handle:BuildPlayerMenu() -{ - new Handle:menu = CreateMenu(Menu_SelectPlayer); - AddTargetsToMenu(menu, 0, true, false); - SetMenuTitle(menu, "Select A Player:"); - SetMenuExitBackButton(menu, true); - return menu; -} - -public Action:Command_TEST(client, args) -{ - -} \ No newline at end of file diff --git a/Simple Plugins Core/addons/sourcemod/scripting/simple-messagesuppression.sp b/Simple Plugins Core/addons/sourcemod/scripting/simple-messagesuppression.sp deleted file mode 100644 index f7725a4..0000000 --- a/Simple Plugins Core/addons/sourcemod/scripting/simple-messagesuppression.sp +++ /dev/null @@ -1,227 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Message Suppression -Description: - Blocks Specific Message Outputs -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include -#include - -#define SUPPRESS_VERSION "1.1.$Rev$" - -public Plugin:myinfo = -{ - name = "Simple Message Suppression", - author = "FlyingMongoose, psychonic", - description = "Blocks Specific Message Outputs", - version = SUPPRESS_VERSION, - url = "http://www.simple-plugins.com/" -} - -new Handle:cvarBlockSpectateMessage; -new Handle:cvarBlockDisconnectMessage; -new Handle:cvarBlockConnectMessage; -new Handle:cvarAdminShowMessages; -new iSpecTeam = 1; - - -public OnPluginStart() -{ - CreateConVar("suppress_version", SUPPRESS_VERSION, _, FCVAR_PLUGIN|FCVAR_NOTIFY|FCVAR_REPLICATED|FCVAR_SPONLY|FCVAR_DONTRECORD); - cvarBlockSpectateMessage = CreateConVar("sm_blockspectatemessage", "1", "If enabled it blocks the join team message if an administrator joins spectator", FCVAR_PLUGIN, true, 0.0, true, 1.0); - cvarBlockDisconnectMessage = CreateConVar("sm_blockdisconnectmessage", "1", "Blocks the disconnect message", FCVAR_PLUGIN, true, 0.0, true, 1.0); - cvarBlockConnectMessage = CreateConVar("sm_blockconnectmessage", "1", "If enabled it blocks the player connection message.", FCVAR_PLUGIN, true, 0.0, true, 1.0); - cvarAdminShowMessages = CreateConVar("sm_adminshowmessages", "1", "Shows disconnect/connect/team join messages for admins only (if disconnect message is set to be blocked)", FCVAR_PLUGIN, true, 0.0, true, 1.0); - HookEvent("player_team", ev_PlayerTeam, EventHookMode_Pre); - HookEvent("player_disconnect", ev_PlayerDisconnect, EventHookMode_Pre); - HookEvent("player_connect", ev_PlayerConnect, EventHookMode_Pre); - - new String:game_folder[64]; - GetGameFolderName(game_folder, sizeof(game_folder)) - - if (StrContains(game_folder, "insurgency", false) != -1) - { - iSpecTeam = 3; - } - else - { - new String:game_description[64]; - GetGameDescription(game_description, sizeof(game_description), true); - if (StrContains(game_description, "Insurgency", false) != -1) - { - iSpecTeam = 3; - } - } - - AutoExecConfig(true, "suppressmessage", "sourcemod"); -} - -public Action:ev_PlayerTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - if (GetConVarBool(cvarBlockSpectateMessage)) - { - if (!dontBroadcast && !GetEventBool(event, "silent")) - { - new iUserId = GetEventInt(event, "userid"); - new iClient = GetClientOfUserId(iUserId); - new iTeam = GetEventInt(event, "team"); - - if (iTeam == iSpecTeam && GetAdminFlag(GetUserAdmin(iClient), Admin_Kick)) - { - new iOldTeam = GetEventInt(event, "oldteam"); - new bool:bDisconnect = GetEventBool(event, "disconnect"); - new bool:bAutoteam = GetEventBool(event, "autoteam"); - decl String:strName[50]; - GetEventString(event, "name", strName, sizeof(strName)); - - if (iClient != 0) - { - if (GetConVarInt(cvarAdminShowMessages) == 1) - { - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientConnected(i) && IsClientInGame(i) && GetUserAdmin(i) != INVALID_ADMIN_ID) - { - PrintToChat(i,"%N joined team Spectator.", iClient); - PrintToConsole(i,"%N joined team Spectator.", iClient); - } - } - } - } - - new Handle:hEvent = CreateEvent("player_team"); - SetEventInt(hEvent, "userid", iUserId); - SetEventInt(hEvent, "team", iTeam); - SetEventInt(hEvent, "oldteam", iOldTeam); - SetEventBool(hEvent, "disconnect", bDisconnect); - SetEventBool(hEvent, "autoteam", bAutoteam); - SetEventBool(hEvent, "silent", true); - SetEventString(hEvent, "name", strName); - - FireEvent(hEvent, true); - - return Plugin_Handled; - } - } - } - return Plugin_Continue; -} -public Action:ev_PlayerConnect(Handle:event, const String:name[], bool:dontBroadcast) -{ - if (GetConVarBool(cvarBlockConnectMessage)) - { - if (!dontBroadcast) - { - decl String:strName[50]; - GetEventString(event, "name", strName, sizeof(strName)); - new iIndex = GetEventInt(event, "index"); - new iUserId = GetEventInt(event, "userid"); - new iClient = GetClientOfUserId(iUserId); - decl String:strNetworkId[50]; - GetEventString(event, "networkid", strNetworkId, sizeof(strNetworkId)); - decl String:strAddress[50]; - GetEventString(event, "address", strAddress, sizeof(strAddress)); - - if (iClient != 0) - { - if (GetConVarInt(cvarAdminShowMessages) == 1) - { - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientConnected(i) && IsClientInGame(i) && GetUserAdmin(i) != INVALID_ADMIN_ID) - { - PrintToChat(i,"%N has connected.", iClient); - PrintToConsole(i,"%N has connected.", iClient); - } - } - } - } - - new Handle:hEvent = CreateEvent("player_connect"); - SetEventString(hEvent, "name", strName); - SetEventInt(hEvent, "index", iIndex); - SetEventInt(hEvent, "userid", iUserId); - SetEventString(hEvent, "networkid", strNetworkId); - SetEventString(hEvent, "address", strAddress); - - FireEvent(hEvent, true); - - return Plugin_Handled; - } - } - return Plugin_Continue; -} -public Action:ev_PlayerDisconnect(Handle:event, const String:name[], bool:dontBroadcast) -{ - if (GetConVarBool(cvarBlockDisconnectMessage)) - { - if (!dontBroadcast) - { - new iUserId = GetEventInt(event, "userid"); - new iClient = GetClientOfUserId(iUserId); - decl String:strReason[50]; - GetEventString(event, "reason", strReason, sizeof(strReason)); - decl String:strName[50]; - GetEventString(event, "name", strName, sizeof(strName)); - decl String:strNetworkId[50]; - GetEventString(event, "networkid", strNetworkId, sizeof(strNetworkId)); - - if (iClient != 0) - { - if (GetConVarInt(cvarAdminShowMessages) == 1) - { - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientConnected(i) && IsClientInGame(i) && GetUserAdmin(i) != INVALID_ADMIN_ID) - { - PrintToChat(i, "%N has left the server.", iClient); - PrintToConsole(i, "Dropped %N from server (Disconnect by user.)", iClient); - } - } - } - } - - new Handle:hEvent = CreateEvent("player_disconnect"); - SetEventInt(hEvent, "userid", iUserId); - SetEventString(hEvent, "reason", strReason); - SetEventString(hEvent, "name", strName); - SetEventString(hEvent, "networkid", strNetworkId); - - FireEvent(hEvent, true); - - return Plugin_Handled; - } - } - - return Plugin_Continue; -} \ No newline at end of file diff --git a/Simple Plugins Core/addons/sourcemod/scripting/simple-plugins.sp b/Simple Plugins Core/addons/sourcemod/scripting/simple-plugins.sp index 4462b41..32aa5c7 100644 --- a/Simple Plugins Core/addons/sourcemod/scripting/simple-plugins.sp +++ b/Simple Plugins Core/addons/sourcemod/scripting/simple-plugins.sp @@ -222,7 +222,7 @@ public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) g_bTeamsSwitched = false; } -public HookPlayerChangeTeam(Handle:event, const String:name[], bool:dontBroadcast) +public Action:HookPlayerChangeTeam(Handle:event, const String:name[], bool:dontBroadcast) { /** @@ -256,7 +256,7 @@ public HookPlayerChangeTeam(Handle:event, const String:name[], bool:dontBroadcas if (g_CurrentMod == GameType_DOD || g_CurrentMod == GameType_L4D || g_CurrentMod == GameType_TF) { new String:sClientName[MAX_NAME_LENGTH + 1]; - GetClientName(client, sClientName, sizeof(sClientName)); + GetClientName(iClient, sClientName, sizeof(sClientName)); SetEventBool(hEvent, "autoteam", GetEventBool(event, "autoteam")); SetEventBool(hEvent, "silent", true); SetEventString(hEvent, "name", sClientName); diff --git a/Simple Plugins Core/addons/sourcemod/scripting/simple-roundimmunity.sp b/Simple Plugins Core/addons/sourcemod/scripting/simple-roundimmunity.sp deleted file mode 100644 index 5f0bca3..0000000 --- a/Simple Plugins Core/addons/sourcemod/scripting/simple-roundimmunity.sp +++ /dev/null @@ -1,947 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Round Immunity -Description: - Gives admins immunity during certain rounds -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or any later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#pragma semicolon 1 -#include -#include -#undef REQUIRE_EXTENSIONS -#undef AUTOLOAD_EXTENSIONS -#include -#include -#define REQUIRE_EXTENSIONS -#define AUTOLOAD_EXTENSIONS - -#define PLUGIN_VERSION "1.1.$Rev$" -#define SPECTATOR 1 -#define TEAM_RED 2 -#define TEAM_BLUE 3 - -#define COLOR_GREEN 0 -#define COLOR_BLACK 1 -#define COLOR_RED 2 -#define COLOR_BLUE 3 -#define COLOR_TEAM 4 -#define COLOR_RAINBOW 5 -#define COLOR_NONE 6 - -#define PLAYERCOND_SLOWED (1<<0) //1 -#define PLAYERCOND_ZOOMED (1<<1) //2 -#define PLAYERCOND_DISGUISING (1<<2) //4 -#define PLAYERCOND_DISGUISED (1<<3) //8 -#define PLAYERCOND_SPYCLOAK (1<<4) //16 -#define PLAYERCOND_UBERED (1<<5) //32 -#define PLAYERCOND_TELEPORTTRAIL (1<<6) //64 -#define PLAYERCOND_TAUNT (1<<7) //128 -// (1<<8) //256 -// (1<<9) //512 -#define PLAYERCOND_TELEPORTFLASH (1<<10) //1024 -#define PLAYERCOND_KRUBER (1<<11) //2048 -// (1<<12) //4096 -// (1<<13) //8192 -#define PLAYERCOND_BONKED (1<<14) //16384 (blame Neph if it doesn't work) -#define PLAYERCOND_BONKEDORDRINKSLOWDOWN (1<<15) //32768 -#define PLAYERCOND_HEALING (1<<16) //65536 -#define PLAYERCOND_BURNING (1<<17) //131072 -#define PLAYERCOND_FULLYCHARGEDBYMEDIC (1<<18) //262144 - -enum e_Cookies -{ - bEnabled, - iColor, - iMode -}; - -enum e_ColorNames -{ - Green, - Black, - Red, - Blue -}; - -enum e_ColorValues -{ - iRed, - iGreen, - iBlue -}; - -enum e_PlayerData -{ - Handle:hGodModeTimer, - Handle:hColorTimer, - bool:bIsAdmin, - bool:bIsImmune, - iCycleColor -}; - -/** - Global convar handles - */ -new Handle:sri_charadminflag = INVALID_HANDLE; -new Handle:sri_enabled = INVALID_HANDLE; -new Handle:sri_cookie_enabled = INVALID_HANDLE; -new Handle:sri_cookie_color = INVALID_HANDLE; -new Handle:sri_cookie_mode = INVALID_HANDLE; - -/** - Player arrays - */ -new g_aPlayers[MAXPLAYERS + 1][e_PlayerData]; -new g_aClientCookies[MAXPLAYERS + 1][e_Cookies]; - -/** - Global bools - */ -new bool:g_bLoadedLate = false; -new bool:g_bIsEnabled = true; -new bool:g_bRoundEnd = false; -new bool:g_bUseDukehacks = false; -new bool:g_bUseClientprefs = false; - -/** - Global strings/integers/floats - */ -new String:g_sCharAdminFlag[32]; -new g_iColors[e_ColorNames][e_ColorValues]; -new g_iClassMaxHealth[TFClassType] = {0, 125, 125, 200, 175, 150, 300, 175, 125, 125}; - -public Plugin:myinfo = -{ - name = "Simple Round Immunity", - author = "Simple Plugins", - description = "Gives admins immunity during certain rounds", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -} - -bool:AskPluginLoad(Handle:myself, bool:late, String:error[], err_max) -{ - g_bLoadedLate = late; - return true; -} - -public OnPluginStart() -{ - - /** - Create console variables - */ - CreateConVar("sri_version", PLUGIN_VERSION, "Simple Round Immunity", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - sri_enabled = CreateConVar("sri_enabled", "1", "Enable/Disable Admin immunity during certain round."); - sri_charadminflag = CreateConVar("sri_charadminflag", "a", "Admin flag to use for immunity (only one). Must be a in char format."); - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook some events and check extensions - */ - decl String:sExtError[256]; - LogAction(0, -1, "[SRI] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_spawn", HookPlayerSpawn, EventHookMode_Post); - HookEvent("player_hurt", HookPlayerHurt, EventHookMode_Pre); - switch (g_CurrentMod) - { - case GameType_CSS: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - new iExtStatus = GetExtensionFileStatus("game.cstrike.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SRI] Required extension was not found."); - LogAction(0, -1, "[SRI] Plugin FAILED TO LOAD."); - SetFailState("Required extension was not found."); - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SRI] Required extension is loaded with errors."); - LogAction(0, -1, "[SRI] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SRI] Plugin FAILED TO LOAD."); - SetFailState("Required extension is loaded with errors."); - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SRI] Required css extension is loaded."); - } - } - case GameType_TF: - { - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_PostNoCopy); - HookUserMessage(GetUserMessageId("TextMsg"), UserMessageHook_Class, true); - new iExtStatus = GetExtensionFileStatus("game.tf2.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SRI] Required extension was not found."); - LogAction(0, -1, "[SRI] Plugin FAILED TO LOAD."); - SetFailState("Required extension was not found."); - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SRI] Required extension is loaded with errors."); - LogAction(0, -1, "[SRI] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SRI] Plugin FAILED TO LOAD."); - SetFailState("Required extension is loaded with errors."); - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SRI] Required tf2 extension is loaded."); - } - iExtStatus = GetExtensionFileStatus("dukehacks.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SRI] Dukehacks extension was not found."); - LogAction(0, -1, "[SRI] Plugin continued to load, but that feature will not be used."); - g_bUseDukehacks = false; - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SRI] Dukehacks extension is loaded with errors."); - LogAction(0, -1, "[SRI] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SRI] Plugin continued to load, but that feature will not be used."); - g_bUseDukehacks = false; - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SRI] Dukehacks extension is loaded and will be used."); - g_bUseDukehacks = true; - dhAddClientHook(CHK_TakeDamage, Hacks_TakeDamageHook); - } - } - case GameType_DOD: - { - HookEvent("dod_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_PostNoCopy); - } - default: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - } - } - /** - Now lets check for client prefs extension - */ - new iExtStatus = GetExtensionFileStatus("clientprefs.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SRI] Client Preferences extension was not found."); - LogAction(0, -1, "[SRI] Plugin continued to load, but that feature will not be used."); - g_bUseClientprefs = false; - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SRI] Client Preferences extension is loaded with errors."); - LogAction(0, -1, "[SRI] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SRI] Plugin continued to load, but that feature will not be used."); - g_bUseClientprefs = false; - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SRI] Client Preferences extension is loaded, checking database."); - if (!SQL_CheckConfig(clientprefs)) - { - LogAction(0, -1, "[SRI] No 'clientprefs' database found. Check your database.cfg file."); - LogAction(0, -1, "[SRI] Plugin continued to load, but Client Preferences will not be used."); - g_bUseClientprefs = false; - } - g_bUseClientprefs = true; - - /** - Deal with client cookies - */ - sri_cookie_enabled = RegClientCookie("bri_client_enabled", "Enable/Disable your immunity during the bonus round.", CookieAccess_Public); - sri_cookie_color = RegClientCookie("bri_client_color", "Color to render when immune.", CookieAccess_Public); - sri_cookie_mode = RegClientCookie("bri_client_mode", "God mode to select", CookieAccess_Public); - SetCookieMenuItem(CookieMenu_TopMenu, sri_cookie_enabled, "Bonus Round Immunity"); - } - - HookConVarChange(sri_enabled, EnabledChanged); - - RegAdminCmd("sm_immunity", Command_Immunity, ADMFLAG_ROOT, "sm_immunity: Gives you immunity"); - - LoadColors(); - - AutoExecConfig(true, "plugin.simpleroundimmunity"); -} - -public OnAllPluginsLoaded() -{ - //something - // need to deal with the unloading of dukehacks, clientprefs, and simpleplugins - // should move hooking the client prefs cookies to a function to make sure they are done post plugin start if ext is loaded late -} - -public OnLibraryRemoved(const String:name[]) -{ - //something - // need to deal with the loading of dukehacks, clientprefs, and simpleplugins -} - -public OnConfigsExecuted() -{ - GetConVarString(sri_charadminflag, g_sCharAdminFlag, sizeof(g_sCharAdminFlag)); - g_bIsEnabled = GetConVarBool(sri_enabled); - g_bRoundEnd = false; -} - -/** - Client events - */ - -public OnClientPostAdminCheck(client) -{ - if (SM_IsValidAdmin(client, g_sCharAdminFlag)) - g_aPlayers[client][bIsAdmin] = true; - else - g_aPlayers[client][bIsAdmin] = false; -} - -public OnClientCookiesCached(client) -{ - decl String:sEnabled[2], String:sColor[4], String:sMode[2]; - GetClientCookie(client, sri_cookie_enabled, sEnabled, sizeof(sEnabled)); - GetClientCookie(client, sri_cookie_color, sColor, sizeof(sColor)); - GetClientCookie(client, sri_cookie_mode, sMode, sizeof(sMode)); - g_aClientCookies[client][bEnabled] = StringToInt(sEnabled); - g_aClientCookies[client][iColor] = StringToInt(sColor); - g_aClientCookies[client][iMode] = StringToInt(sMode); -} - -public OnClientDisconnect(client) -{ - CleanUp(client); -} - -/** - Commands - */ - -public Action:Command_Immunity(client, args) -{ - if (g_aPlayers[client][IsImmune]) - { - DisableImmunity(client); - } - else - { - EnableImmunity(client); - } - return Plugin_Handled; -} - -/** - Event hooks - */ - -public Action:Hacks_TakeDamageHook(client, attacker, inflictor, Float:damage, &Float:multiplier, damagetype) -{ - if (attacker == 0 || attacker >= MaxClients) - { - return Plugin_Continue; - } - if (g_aPlayers[client][IsImmune]) - { - new TFClassType:PlayerClass = TF2_GetPlayerClass(attacker); - if (PlayerClass == TFClass_Spy) - { - multiplier *= 0.0; - return Plugin_Changed; - } - } - return Plugin_Continue; -} - -public HookRoundStart(Handle:event, const String:name[], bool:dontBroadcast) -{ - g_bRoundEnd = false; - if (g_bIsEnabled) - { - for (new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][IsImmune]) - { - DisableImmunity(i); - } - } - } -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - g_bRoundEnd = true; - if (g_bIsEnabled) - { - for (new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][bIsAdmin]) - { - EnableImmunity(i); - } - } - } -} - -public HookPlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast) -{ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - if (g_bIsEnabled && g_aPlayers[iClient][bIsAdmin] && g_bRoundEnd) - { - EnableImmunity(iClient); - } -} - -public Action:HookPlayerHurt(Handle:event, const String:name[], bool:dontBroadcast) -{ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - if (g_aPlayers[iClient][IsImmune]) - { - SetEntityHealth(iClient, 2000); - return Plugin_Continue; - } - return Plugin_Continue; -} - -/** - Cookie menus - */ - -public CookieMenu_TopMenu(client, CookieMenuAction:action, any:info, String:buffer[], maxlen) -{ - if (action == CookieMenuAction_DisplayOption) - { - //don't think we need to do anything - } - else - { - new Handle:hMenu = CreateMenu(Menu_CookieSettings); - SetMenuTitle(hMenu, "Options (Current Setting)"); - if (g_aClientCookies[client][bEnabled]) - { - AddMenuItem(hMenu, "enable", "Enabled/Disable (Enabled)"); - } - else - { - AddMenuItem(hMenu, "enable", "Enabled/Disable (Disabled)"); - } - if (g_aClientCookies[client][iMode]) - { - AddMenuItem(hMenu, "mode", "Immunity Mode Setting (God Mode)"); - } - else - { - AddMenuItem(hMenu, "mode", "Immunity Mode Setting (Health)"); - } - switch (g_aClientCookies[client][iColor]) - { - case COLOR_GREEN: - { - AddMenuItem(hMenu, "color", "Color (Green)"); - } - case COLOR_BLACK: - { - AddMenuItem(hMenu, "color", "Color (Black)"); - } - case COLOR_RED: - { - AddMenuItem(hMenu, "color", "Color (Red)"); - } - case COLOR_BLUE: - { - AddMenuItem(hMenu, "color", "Color (Blue)"); - } - case COLOR_TEAM: - { - AddMenuItem(hMenu, "color", "Color (Team)"); - } - case COLOR_RAINBOW: - { - AddMenuItem(hMenu, "color", "Color (Rainbow)"); - } - case COLOR_NONE: - { - AddMenuItem(hMenu, "color", "Color (None)"); - } - } - SetMenuExitBackButton(hMenu, true); - DisplayMenu(hMenu, client, MENU_TIME_FOREVER); - } -} - -public Menu_CookieSettings(Handle:menu, MenuAction:action, param1, param2) -{ - new client = param1; - if (action == MenuAction_Select) - { - new String:sSelection[24]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "enable", false)) - { - new Handle:hMenu = CreateMenu(Menu_CookieSettingsEnable); - SetMenuTitle(hMenu, "Enable/Disable Round End Immunity"); - - if (g_aClientCookies[client][bEnabled]) - { - AddMenuItem(hMenu, "enable", "Enable (Set)"); - AddMenuItem(hMenu, "disable", "Disable"); - } - else - { - AddMenuItem(hMenu, "enable", "Enabled"); - AddMenuItem(hMenu, "disable", "Disable (Set)"); - } - - SetMenuExitBackButton(hMenu, true); - DisplayMenu(hMenu, client, MENU_TIME_FOREVER); - } - else if (StrEqual(sSelection, "mode", false)) - { - new Handle:hMenu = CreateMenu(Menu_CookieSettingsMode); - SetMenuTitle(hMenu, "Set Immunity Mode"); - - if (g_aClientCookies[client][iMode]) - { - AddMenuItem(hMenu, "god", "God Mode (Set)"); - AddMenuItem(hMenu, "health", "Health"); - } - else - { - AddMenuItem(hMenu, "god", "God Mode"); - AddMenuItem(hMenu, "health", "Health (Set)"); - } - - SetMenuExitBackButton(hMenu, true); - DisplayMenu(hMenu, client, MENU_TIME_FOREVER); - } - else - { - new Handle:hMenu = CreateMenu(Menu_CookieSettingsColors); - SetMenuTitle(hMenu, "Select Immunity Color"); - switch (g_aClientCookies[client][iColor]) - { - case COLOR_GREEN: - { - AddMenuItem(hMenu, "Green", "Green (Set)"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_BLACK: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black (Set)"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_RED: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red (Set)"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_BLUE: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue (Set)"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_TEAM: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color (Set)"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_RAINBOW: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow (Set)"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_NONE: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None (Set)"); - } - } - SetMenuExitBackButton(hMenu, true); - DisplayMenu(hMenu, client, MENU_TIME_FOREVER); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - ShowCookieMenu(client); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } -} - -public Menu_CookieSettingsEnable(Handle:menu, MenuAction:action, param1, param2) -{ - new client = param1; - if (action == MenuAction_Select) - { - new String:sSelection[24]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "enable", false)) - { - SetClientCookie(client, sri_cookie_enabled, "1"); - g_aClientCookies[client][bEnabled] = 1; - PrintToChat(client, "[SM] Bonus Round Immunity is ENABLED"); - } - else - { - SetClientCookie(client, sri_cookie_enabled, "0"); - g_aClientCookies[client][bEnabled] = 0; - PrintToChat(client, "[SM] Bonus Round Immunity is DISABLED"); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - ShowCookieMenu(client); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } -} - -public Menu_CookieSettingsColors(Handle:menu, MenuAction:action, param1, param2) -{ - new client = param1; - if (action == MenuAction_Select) - { - new String:sSelection[24]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "Green", false)) - { - SetClientCookie(client, sri_cookie_color, "0"); - g_aClientCookies[client][iColor] = COLOR_GREEN; - PrintToChat(client, "[SM] Bonus Round Immunity color set to GREEN"); - } - else if (StrEqual(sSelection, "Black", false)) - { - SetClientCookie(client, sri_cookie_color, "1"); - g_aClientCookies[client][iColor] = COLOR_BLACK; - PrintToChat(client, "[SM] Bonus Round Immunity color set to BLACK"); - } - else if (StrEqual(sSelection, "Red", false)) - { - SetClientCookie(client, sri_cookie_color, "2"); - g_aClientCookies[client][iColor] = COLOR_RED; - PrintToChat(client, "[SM] Bonus Round Immunity color set to RED"); - } - else if (StrEqual(sSelection, "Blue", false)) - { - SetClientCookie(client, sri_cookie_color, "3"); - g_aClientCookies[client][iColor] = COLOR_BLUE; - PrintToChat(client, "[SM] Bonus Round Immunity color set to BLUE"); - } - else if (StrEqual(sSelection, "Team", false)) - { - SetClientCookie(client, sri_cookie_color, "4"); - g_aClientCookies[client][iColor] = COLOR_TEAM; - PrintToChat(client, "[SM] Bonus Round Immunity color set to TEAM COLOR"); - } - else if (StrEqual(sSelection, "Rain", false)) - { - SetClientCookie(client, sri_cookie_color, "5"); - g_aClientCookies[client][iColor] = COLOR_RAINBOW; - PrintToChat(client, "[SM] Bonus Round Immunity color set to RAINBOW"); - } - else if (StrEqual(sSelection, "None", false)) - { - SetClientCookie(client, sri_cookie_color, "6"); - g_aClientCookies[client][iColor] = COLOR_NONE; - PrintToChat(client, "[SM] Bonus Round Immunity color set to NONE"); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - ShowCookieMenu(client); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } -} - -public Menu_CookieSettingsMode(Handle:menu, MenuAction:action, param1, param2) -{ - new client = param1; - if (action == MenuAction_Select) - { - new String:sSelection[24]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "god", false)) - { - SetClientCookie(client, sri_cookie_mode, "1"); - g_aClientCookies[client][iMode] = 1; - PrintToChat(client, "[SM] Bonus Round Immunity set to GOD MODE"); - } - else - { - SetClientCookie(client, sri_cookie_mode, "0"); - g_aClientCookies[client][iMode] = 0; - PrintToChat(client, "[SM] Bonus Round Immunity set to HEALTH BONUS"); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - ShowCookieMenu(client); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } -} - -/** -Timer functions - */ - -public Action:Timer_ChangeColor(Handle:timer, any:client) -{ - if (g_aPlayers[client][CycleColor]++ == 3) - { - g_aPlayers[client][CycleColor] = 0; - } - SetEntityRenderMode(client, RENDER_TRANSCOLOR); - SetEntityRenderColor(client, g_iColors[g_aPlayers[client][CycleColor]][iRed], g_iColors[g_aPlayers[client][CycleColor]][iGreen], g_iColors[g_aPlayers[client][CycleColor]][iBlue], 255); - return Plugin_Continue; -} - -public Action:Timer_UndoGodMode(Handle:timer, any:client) -{ - if (IsClientInGame(client)) - { - SetEntProp(client, Prop_Data, "m_takedamage", 2, 1); - } - g_aPlayers[iClient][hGodModeTimer] = INVALID_HANDLE; - return Plugin_Handled; -} - -/** -Stock functions . - */ - -stock CleanUp(iClient) -{ - g_aPlayers[iClient][bIsAdmin] = false; - DisableImmunity(iClient); -} - -stock EnableImmunity(iClient) -{ - SetEntityRenderMode(iClient, RENDER_TRANSCOLOR); - switch (g_aClientCookies[iClient][iColor]) - { - case COLOR_TEAM: - { - new iTeam = GetClientTeam(iClient); - SetEntityRenderColor(iClient, g_iColors[e_ColorNames:iTeam][iRed], g_iColors[e_ColorNames:iTeam][iGreen], g_iColors[e_ColorNames:iTeam][iBlue], 255); - } - case COLOR_RAINBOW: - { - if (g_aPlayers[iClient][hColorTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[iClient][hColorTimer]); - g_aPlayers[iClient][hColorTimer] = INVALID_HANDLE; - } - g_aPlayers[iClient][hColorTimer] = CreateTimer(0.2, Timer_ChangeColor, iClient, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); - } - case COLOR_NONE: - { - //We dont have to set a color - } - default: - { - SetEntityRenderColor(iClient, g_iColors[e_ColorNames:g_aClientCookies[iClient][iColor]][iRed], g_iColors[e_ColorNames:g_aClientCookies[iClient][iColor]][iGreen], g_iColors[e_ColorNames:g_aClientCookies[iClient][iColor]][iBlue], 255); - } - } - SetEntityHealth(iClient, 2000); - SetEntProp(iClient, Prop_Data, "m_takedamage", 0, 1); - g_aPlayers[iClient][hGodModeTimer] = CreateTimer(2.0, Timer_UndoGodMode, iClient); - g_aPlayers[iClient][IsImmune] = true; -} - -stock DisableImmunity(iClient) -{ - if (g_aPlayers[iClient][hGodModeTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[iClient][hGodModeTimer]); - g_aPlayers[iClient][hGodModeTimer] = INVALID_HANDLE; - } - if (g_aPlayers[iClient][hColorTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[iClient][hColorTimer]); - g_aPlayers[iClient][hColorTimer] = INVALID_HANDLE; - } - if (IsClientInGame(iClient)) - { - SetEntityRenderMode(iClient, RENDER_TRANSCOLOR); - SetEntityRenderColor(iClient, 255, 255, 255, 255); - new TFClassType:PlayerClass = TF2_GetPlayerClass(iClient); - new iMaxHealth = g_iClassMaxHealth[PlayerClass]; - SetEntityHealth(iClient, iMaxHealth); - } - g_aPlayers[iClient][CycleColor] = 0; - g_aPlayers[iClient][IsImmune] = false; -} - -stock LoadColors() -{ - g_iColors[Green][iRed] = 0; - g_iColors[Green][iGreen] = 255; - g_iColors[Green][iBlue] = 0; - - g_iColors[Black][iRed] = 10; - g_iColors[Black][iGreen] = 10; - g_iColors[Black][iBlue] = 0; - - g_iColors[Red][iRed] = 255; - g_iColors[Red][iGreen] = 0; - g_iColors[Red][iBlue] = 0; - - g_iColors[Blue][iRed] = 0; - g_iColors[Blue][iGreen] = 0; - g_iColors[Blue][iBlue] = 255; -} - -stock TF2_AddCond(client, cond) -{ - new Handle:cvar = FindConVar("sv_cheats"), bool:enabled = GetConVarBool(cvar), flags = GetConVarFlags(cvar); - if(!enabled) - { - SetConVarFlags(cvar, flags^FCVAR_NOTIFY); - SetConVarBool(cvar, true); - } - FakeClientCommand(client, "addcond %i", cond); - if(!enabled) - { - SetConVarBool(cvar, false); - SetConVarFlags(cvar, flags); - } -} - -stock TF2_RemoveCond(client, cond) -{ - new Handle:cvar = FindConVar("sv_cheats"), bool:enabled = GetConVarBool(cvar), flags = GetConVarFlags(cvar); - if(!enabled) - { - SetConVarFlags(cvar, flags^FCVAR_NOTIFY); - SetConVarBool(cvar, true); - } - FakeClientCommand(client, "removecond %i", cond); - if(!enabled) - { - SetConVarBool(cvar, false); - SetConVarFlags(cvar, flags); - } -} - -/** -Enabled hook - */ - -public EnabledChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (StringToInt(newValue) == 0) - { - UnhookEvent("player_spawn", HookPlayerSpawn, EventHookMode_Post); - UnhookEvent("teamplay_round_start", HookRoundStart, EventHookMode_Post); - UnhookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - for (new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][bIsAdmin] && g_aPlayers[i][IsImmune]) - { - DisableImmunity(i); - } - } - g_bIsEnabled = false; - } - else - { - HookEvent("player_spawn", HookPlayerSpawn, EventHookMode_Post); - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_Post); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - g_bIsEnabled = true; - } -} diff --git a/Simple Plugins Core/addons/sourcemod/scripting/simple-spectate.sp b/Simple Plugins Core/addons/sourcemod/scripting/simple-spectate.sp deleted file mode 100644 index 4108f8f..0000000 --- a/Simple Plugins Core/addons/sourcemod/scripting/simple-spectate.sp +++ /dev/null @@ -1,2022 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Spectate -Description: - Spectate a player and follow them through death. -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include -#undef REQUIRE_EXTENSIONS -#undef AUTOLOAD_EXTENSIONS -#tryinclude -#define AUTOLOAD_EXTENSIONS -#define REQUIRE_EXTENSIONS - -#define PLUGIN_VERSION "1.2.1.$Rev$" - -#define SPECMODE_NONE 0 -#define SPECMODE_FIRSTPERSON 4 -#define SPECMODE_3RDPERSON 5 -#define SPECMODE_FREELOOK 6 -#define SPECMODE_CSS_FIRSTPERSON 3 -#define SPECMODE_CSS_3RDPERSON 4 -#define SPECMODE_CSS_FREELOOK 5 - -enum e_CvarHandles -{ - Handle:hHudMode, - Handle:hMenuType, - Handle:hRestrictHud, - Handle:hBan, - Handle:hBanPerm, - Handle:hBeacon, - Handle:hBlind, - Handle:hCheater, - Handle:hDrug, - Handle:hFreeze, - Handle:hFreezeBomb, - Handle:hKick, - Handle:hSlap, - Handle:hSlay, - Handle:hTimeBomb -}; - -enum e_CvarSettings -{ - bool:bHudMode, - bool:bMenuType, - bool:bRestrictHud, - bool:bBan, - bool:bBanPerm, - bool:bBeacon, - bool:bBlind, - bool:bCheater, - bool:bDrug, - bool:bFreeze, - bool:bFreezebomb, - bool:bKick, - bool:bSlap, - bool:bSlay, - bool:bTimeBomb -}; - -enum e_PluginSettings -{ - bool:bUseSteamBans, - bool:bUseSourceBans, - bool:bUseMySQLBans, - bool:bCanHUD, - bool:bUseDukehacks -}; - -enum e_Menus -{ - Handle:hSelectPlayer, - Handle:hBanTime, - Handle:hReason -}; - -enum e_Punishments -{ - Punish_None, - Punish_Ban, - Punish_Beacon, - Punish_Blind, - Punish_Cheater, - Punish_Drug, - Punish_Freeze, - Punish_FreezeBomb, - Punish_Kick, - Punish_Slap, - Punish_Slay, - Punish_TimeBomb -}; - -enum e_PlayerData -{ - bool:bIsDisplayingHud, - bool:bIsFlaggedCheater, - Handle:hHudTimer, - Handle:hTargetTimer, - iTargetIndex, - e_Punishments:TargetPunishment, - iBanTime -}; - -new Handle:sm_spectate_adminflag = INVALID_HANDLE; -new Handle:g_hAdminMenu = INVALID_HANDLE; -new Handle:g_hHud = INVALID_HANDLE; -new Handle:g_aPluginCvar[e_CvarHandles]; -new g_aPluginCvarSettings[e_CvarSettings]; -new g_aPluginSettings[e_PluginSettings]; -new g_aMenus[e_Menus]; -new g_aPlayers[MAXPLAYERS + 1][e_PlayerData]; -new String:g_sAdminFlags[16]; -new String:g_sPunishments[e_Punishments][15] = { "None", "Ban", "Beacon", "Blind", "Cheater", "Drug", "Freeze", "FreezeBomb", "Kick", "Slap", "Slay", "TimeBomb" }; - -public Plugin:myinfo = -{ - name = "Simple Spectate", - author = "Simple Plugins", - description = "Spectate a player and follow them through death.", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -}; - -/** -Sourcemod callbacks -*/ -public OnPluginStart() -{ - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook the game events - */ - LogAction(0, -1, "[SSPEC] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_team", HookPlayerChangeTeam, EventHookMode_Pre); - - /** - Need to create all of our console variables. - */ - CreateConVar("sm_spectate_version", PLUGIN_VERSION, "Sourcemod Spectate", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - g_aPluginCvar[hHudMode] = CreateConVar("sm_spectate_hudmode", "1", "Hud Mode: 0 = Hud Text | 1 = Panel/Menu (NOTE: The panel/menu will override other menus until canceled)"); - g_aPluginCvar[hMenuType] = CreateConVar("sm_spectate_menutype", "0", "Menu Mode: 0 = Panel | 1 = Menu"); - g_aPluginCvar[hRestrictHud] = CreateConVar("sm_spectate_restricthud", "0", "Restrict the hud to the admin flag provided"); - g_aPluginCvar[hBan] = CreateConVar("sm_spectate_ban", "1", "Enable/Disable ban option"); - g_aPluginCvar[hBanPerm] = CreateConVar("sm_spectate_banperm", "1", "Enable/Disable permanent ban option"); - g_aPluginCvar[hBeacon] = CreateConVar("sm_spectate_beacon", "1", "Enable/Disable beacon option"); - g_aPluginCvar[hBlind] = CreateConVar("sm_spectate_blind", "1", "Enable/Disable blind option"); - g_aPluginCvar[hCheater] = CreateConVar("sm_spectate_cheater", "1", "Enable/Disable cheater option"); - g_aPluginCvar[hDrug] = CreateConVar("sm_spectate_drug", "1", "Enable/Disable drug option"); - g_aPluginCvar[hFreeze] = CreateConVar("sm_spectate_freeze", "1", "Enable/Disable freeze option"); - g_aPluginCvar[hFreezeBomb] = CreateConVar("sm_spectate_freezebomb", "1", "Enable/Disable freezebomb option"); - g_aPluginCvar[hKick] = CreateConVar("sm_spectate_kick", "1", "Enable/Disable kick option"); - g_aPluginCvar[hSlap] = CreateConVar("sm_spectate_slap", "1", "Enable/Disable slap option"); - g_aPluginCvar[hSlay] = CreateConVar("sm_spectate_slay", "1", "Enable/Disable slay option"); - g_aPluginCvar[hTimeBomb] = CreateConVar("sm_spectate_timebomb", "1", "Enable/Disable timebomb option"); - - sm_spectate_adminflag = CreateConVar("sm_spectate_adminflag", "d", "Admin Flag to use for admin hud"); - - /** - Hook console variables - */ - new e_CvarHandles:iCvar; - for ( ; _:iCvar < sizeof(g_aPluginCvar); iCvar++) - { - HookConVarChange(g_aPluginCvar[iCvar], ConVarSettingsChanged); - } - - /** - Need to register the commands we are going to create and use. - */ - RegConsoleCmd("sm_spectate", Command_Spectate, "Spectate a player"); - RegConsoleCmd("sm_spec", Command_Spectate, "Spectate a player"); - RegConsoleCmd("sm_observe", Command_Spectate, "Spectate a player"); - RegConsoleCmd("sm_stopspec", Command_StopSpectate, "Stop Spectating a player"); - RegConsoleCmd("sm_endobserve", Command_StopSpectate, "Stop Spectating a player"); - RegConsoleCmd("sm_specinfo", Command_ToggleHud, "Toggles the hud display if in spectator"); - - /** - Now we have to deal with the admin menu. If the admin library is loaded call the function to add our items. - */ - new Handle:gTopMenu; - if (LibraryExists("adminmenu") && ((gTopMenu = GetAdminTopMenu()) != INVALID_HANDLE)) - { - OnAdminMenuReady(gTopMenu); - } - - /** - Deal with the hud - Thanks to Spray Trace plugin (http://forums.alliedmods.net/showthread.php?p=665448) - */ - new String:sHudGames[32]; - GetGameFolderName(sHudGames, sizeof(sHudGames)); - g_aPluginSettings[bCanHUD] = StrEqual(sHudGames,"tf",false) - || StrEqual(sHudGames,"hl2mp",false) - || StrEqual(sHudGames,"sourceforts",false) - || StrEqual(sHudGames,"obsidian",false) - || StrEqual(sHudGames,"left4dead",false) - || StrEqual(sHudGames,"l4d",false); - - if (g_aPluginSettings[bCanHUD]) - { - g_hHud = CreateHudSynchronizer(); - } - - /** - Load translations - */ - LoadTranslations ("common.phrases"); - LoadTranslations ("simplespectate.phrases"); - - /** - Create the config file - */ - AutoExecConfig(true); -} - -public OnConfigsExecuted() -{ - new e_CvarHandles:iCvar; - for ( ; _:iCvar < sizeof(g_aPluginCvarSettings); iCvar++) - { - g_aPluginCvarSettings[iCvar] = GetConVarBool(g_aPluginCvar[iCvar]); - } - - /* - Build the global menus - */ - g_aMenus[hSelectPlayer] = BuildSelectPlayerMenu(); - g_aMenus[hBanTime] = BuildBanTimeMenu(); - g_aMenus[hReason] = BuildReasonMenu(); - - GetConVarString(sm_spectate_adminflag, g_sAdminFlags, sizeof(g_sAdminFlags)); -} - -public OnAllPluginsLoaded() -{ - - /* - Check for steambans - */ - if (FindConVar("sbsrc_version") != INVALID_HANDLE) - { - g_aPluginSettings[bUseSteamBans] = true; - } - else - { - g_aPluginSettings[bUseSteamBans] = false; - } - - /* - Check for sourcebans - */ - if (FindConVar("sb_version") != INVALID_HANDLE) - { - g_aPluginSettings[bUseSourceBans] = true; - } - else - { - g_aPluginSettings[bUseSourceBans] = false; - } - - /* - Check for mysql bans - */ - if (FindConVar("mysql_bans_version") != INVALID_HANDLE) - { - g_aPluginSettings[bUseMySQLBans] = true; - } - else - { - g_aPluginSettings[bUseMySQLBans] = false; - } - - /* - Check for dukehacks - */ - new String:sExtError[256]; - new iExtStatus = GetExtensionFileStatus("dukehacks.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SSPEC] Dukehacks extension was not found."); - LogAction(0, -1, "[SSPEC] Plugin continued to load, but that feature will not be used."); - g_aPluginSettings[bUseDukehacks] = false; - } - else if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SSPEC] Dukehacks extension is loaded with errors."); - LogAction(0, -1, "[SSPEC] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SSPEC] Plugin continued to load, but that feature will not be used."); - g_aPluginSettings[bUseDukehacks] = false; - } - else if (iExtStatus == 1) - { - LogAction(0, -1, "[SSPEC] Dukehacks extension is loaded and will be used."); - g_aPluginSettings[bUseDukehacks] = true; - dhAddClientHook(CHK_TakeDamage, Hacks_TakeDamageHook); - } - - /* - Deal with some known plugin conflicts - */ - new Handle:hObserveClient = FindConVar("observe_version"); - if (hObserveClient != INVALID_HANDLE) - { - new String:sNewFile[PLATFORM_MAX_PATH + 1], String:sOldFile[PLATFORM_MAX_PATH + 1]; - BuildPath(Path_SM, sNewFile, sizeof(sNewFile), "plugins/disabled/observe.smx"); - BuildPath(Path_SM, sOldFile, sizeof(sOldFile), "plugins/observe.smx"); - - /** - Check if plugins/observe.smx exists, and if not, ignore - */ - if(!FileExists(sOldFile)) - { - return; - } - - /** - Check if plugins/disabled/observe.smx already exists, and if so, delete it - */ - if(FileExists(sNewFile)) - { - DeleteFile(sNewFile); - } - - /** - Unload plugins/observe.smx and move it to plugins/disabled/observe.smx - */ - LogAction(0, -1, "Detected the plugin ObserveClient"); - LogAction(0, -1, "ObserveClient plugin conflicts with Simple Spectate"); - LogAction(0, -1, "Unloading plugin and disabling ObserveClient plugin"); - ServerCommand("sm plugins unload observe"); - RenameFile(sNewFile, sOldFile); - } -} - -public OnLibraryRemoved(const String:name[]) -{ - if (StrEqual(name, "adminmenu")) - { - - /** - Looks like the admin menu was removed. Set the global. - */ - g_hAdminMenu = INVALID_HANDLE; - } - else if (StrEqual(name, "simpleplugins")) - { - //something - } -} - -public OnClientDisconnect(client) -{ - - /** - Cleanup the clients variables. - */ - ResetClient(client); - - /** - Run a loop and see if we are supposed to spectate this person (is a target) - */ - for(new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][iTargetIndex] == client) - { - - /** - Cleanup the clients variables. - */ - StopFollowingPlayer(i); - g_aPlayers[i][TargetPunishment] = Punish_None; - g_aPlayers[i][iBanTime] = 0; - } - } -} - -/** -Thirdparty callbacks -*/ -public SM_OnPlayerMoved(Handle:plugin, client, team) -{ - - /** - Make sure we called the move function - */ - if (plugin != GetMyHandle()) - { - return; - } - - //Nothing -} - -public Action:Hacks_TakeDamageHook(client, attacker, inflictor, Float:damage, &Float:multiplier, damagetype) -{ - - /** - Check for a valid client - */ - if (client > 0 && client <= MaxClients) - { - - /** - Check if the client taking damage is flagged as a cheater - */ - if (g_aPlayers[client][bIsFlaggedCheater]) - { - - /** - Check for fall damage and increase it - */ - if (damagetype & DMG_FALL) - { - multiplier *= 1000.0; - return Plugin_Changed; - } - } - } - - /** - Check for a valid attacker - */ - if (attacker > 0 && attacker <= MaxClients) - { - - /** - Check if the attacker causing the damage is flagged as a cheater - */ - if (g_aPlayers[attacker][bIsFlaggedCheater]) - { - - /** - Make sure they are not hurting themselves - */ - if (client != attacker) - { - - /** - Stop the damage - */ - multiplier *= 0.0; - return Plugin_Changed; - } - } - } - return Plugin_Continue; -} - -/** -Events -*/ -public Action:HookPlayerChangeTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get the client and team - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - new iTeam = GetEventInt(event, "team"); - - /** - Make sure it's a valid client - */ - if (iClient == 0) - { - return Plugin_Continue; - } - - /** - If it's a move to spectator start displaying the hud - */ - else if ((iTeam == g_aCurrentTeams[Spectator]) && (GetUserFlagBits(iClient) & ADMFLAG_GENERIC)) - { - StartDisplayingHud(iClient); - - /** - If the event was going to be broadcasted, we refire it so it is not broadcasted and stop this one - */ - if (!dontBroadcast) - { - new Handle:hEvent = CreateEvent("player_team"); - SetEventInt(hEvent, "userid", GetEventInt(event, "userid")); - SetEventInt(hEvent, "team", GetEventInt(event, "team")); - SetEventInt(hEvent, "oldteam", GetEventInt(event, "oldteam")); - SetEventBool(hEvent, "disconnect", GetEventBool(event, "disconnect")); - - if (g_CurrentMod == GameType_DOD || g_CurrentMod == GameType_L4D || g_CurrentMod == GameType_TF) - { - new String:sClientName[MAX_NAME_LENGTH + 1]; - GetClientName(client, sClientName, sizeof(sClientName)); - SetEventBool(hEvent, "autoteam", GetEventBool(event, "autoteam")); - SetEventBool(hEvent, "silent", true); - SetEventString(hEvent, "name", sClientName); - FireEvent(hEvent, true); - } - else - { - FireEvent(hEvent, true); - } - return Plugin_Handled; - } - } - - /** - Otherwise cleanup the client - */ - else - { - StopDisplayingHud(iClient); - StopFollowingPlayer(iClient); - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -/** -Commands -*/ -public Action:Command_Spectate(client, args) -{ - - /** - See if we already have a target (for toggling of command) - */ - if (g_aPlayers[client][iTargetIndex]) - { - - /** - We do, toggle it off - */ - StopFollowingPlayer(client); - - /** - We are done, bug out. - */ - return Plugin_Handled; - } - - /** - We don't... must want to enable it - See if we have some command arguments. - */ - new iCmdArgs = GetCmdArgs(); - if (iCmdArgs == 0) - { - - /** - We don't have any. Display the player menu. - */ - if (g_aPlayers[client][bIsDisplayingHud]) - { - StopDisplayingHud(client); - } - - DisplayMenu(BuildPlayerListMenu(), client, MENU_TIME_FOREVER); - return Plugin_Handled; - } - - /** - We have an argument. - Try to find the target. - */ - new String:sPlayer[128]; - GetCmdArg(1, sPlayer, sizeof(sPlayer)); - new iTarget = FindTarget(client, sPlayer, true, true); - if (iTarget == -1 || !IsClientInGame(iTarget)) - { - - /** - We couldn't find the target. Display the player menu. - */ - if (g_aPlayers[client][bIsDisplayingHud]) - { - StopDisplayingHud(client); - } - - DisplayMenu(BuildPlayerListMenu(), client, MENU_TIME_FOREVER); - return Plugin_Handled; - } - - /** - We found the target. - Call the stock function to spectate the target. - */ - StartFollowingPlayer(client, iTarget); - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_StopSpectate(client, args) -{ - - /** - Cleanup the clients variables. - */ - StopFollowingPlayer(client); - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_ToggleHud(client, args) -{ - - /** - Toggle the hud - */ - if (g_aPlayers[client][bIsDisplayingHud]) - { - StopDisplayingHud(client); - } - else - { - StartDisplayingHud(client); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -/** -Timers -*/ -public Action:Timer_ResetTarget(Handle:timer, any:client) -{ - - new iTargetID = GetEntPropEnt(client, Prop_Send, "m_hObserverTarget"); - - if (iTargetID != g_aPlayers[client][iTargetIndex] && IsPlayerAlive(g_aPlayers[client][iTargetIndex])) - { - - /** - Run the command to spectate the target from the clients prospectative. - */ - FakeClientCommandEx(client, "spec_player \"%N\"", g_aPlayers[client][iTargetIndex]); - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -public Action:Timer_UpdateHud(Handle:timer, any:client) -{ - - /** - Make sure the client is still in game and a spectator - */ - if (!IsClientConnected(client) || !IsClientInGame(client) || GetClientTeam(client) != g_aCurrentTeams[Spectator] || !g_aPlayers[client][bIsDisplayingHud]) - { - - /** - We are done, bug out - */ - g_aPlayers[client][hHudTimer] = INVALID_HANDLE; - g_aPlayers[client][bIsDisplayingHud] = false; - return Plugin_Stop; - } - /** - Get the target - */ - new iTarget = GetEntPropEnt(client, Prop_Send, "m_hObserverTarget"); - - /** - Check to make sure the target is valid - */ - if (iTarget <= 0 || iTarget > MaxClients) - { - return Plugin_Continue; - } - - /** - Get the spectator mode - */ - new iSpecMode = GetEntProp(client, Prop_Send, "m_iObserverMode"); - - /** - This is a double check to make sure we are in spec - If we are on a regular team, specmod would = none or zero - */ - if (iSpecMode == SPECMODE_NONE) - { - - /** - We are done, bug out - */ - g_aPlayers[client][hHudTimer] = INVALID_HANDLE; - g_aPlayers[client][bIsDisplayingHud] = false; - return Plugin_Stop; - } - - /** - Check the spectator mode - CSS has different index's so we have to check game type first - */ - if (g_CurrentMod == GameType_CSS) - { - switch (iSpecMode) - { - case SPECMODE_CSS_FIRSTPERSON: - { - //Do Nothing - } - case SPECMODE_CSS_3RDPERSON: - { - //Do Nothing - } - case SPECMODE_CSS_FREELOOK: - { - return Plugin_Continue; - } - } - } - else - { - switch (iSpecMode) - { - case SPECMODE_FIRSTPERSON: - { - //Do Nothing - } - case SPECMODE_3RDPERSON: - { - //Do Nothing - } - case SPECMODE_FREELOOK: - { - return Plugin_Continue; - } - } - } - - - /** - Display with the hud - */ - if (g_aPluginSettings[bCanHUD] && !g_aPluginCvarSettings[bHudMode]) - { - new String:sSteamID[64]; - GetClientAuthString(iTarget, sSteamID, sizeof(sSteamID)); - SetHudTextParams(0.04, 0.6, 0.5, 255, 50, 50, 255); - ShowSyncHudText(client, g_hHud, "%N [%s]", iTarget, sSteamID); - } - else if (g_aPluginCvarSettings[bHudMode]) - { - if (g_aPluginCvarSettings[bMenuType]) - { - DisplayMenu(BuildPlayerHudMenu(client, iTarget), client, 1); - } - else - { - new Handle:hPanel = BuildPlayerHudPanel(client, iTarget); - SendPanelToClient(hPanel, client, Panel_PlayerHud, 1); - CloseHandle(hPanel); - } - } - - /** - We are done, keep going! - */ - return Plugin_Continue; -} - -/** -Admin Menu Callbacks -*/ -public OnAdminMenuReady(Handle:topmenu) -{ - if (topmenu == g_hAdminMenu) - { - return; - } - g_hAdminMenu = topmenu; - new TopMenuObject:player_commands = FindTopMenuCategory(g_hAdminMenu, ADMINMENU_PLAYERCOMMANDS); - if (player_commands == INVALID_TOPMENUOBJECT) - { - return; - } - AddToTopMenu(g_hAdminMenu, - "sm_spectate", - TopMenuObject_Item, - AdminMenu_SpecPlayer, - player_commands, - "sm_spectate", - ADMFLAG_GENERIC); -} - -public AdminMenu_SpecPlayer(Handle:topmenu, TopMenuAction:action, TopMenuObject:object_id, param, String:buffer[], maxlength) -{ - if (action == TopMenuAction_DisplayOption) - { - - if (g_aPlayers[param][bIsDisplayingHud]) - { - StopDisplayingHud(param); - } - /** - See if we already have a target - */ - if (g_aPlayers[param][iTargetIndex]) - { - Format(buffer, maxlength, "Spectate(Disable)"); - } - else - { - Format(buffer, maxlength, "Spectate(Select Player)"); - } - } - else if (action == TopMenuAction_SelectOption) - { - - /** - See if we already have a target - */ - if (g_aPlayers[param][iTargetIndex]) - { - - /** - We do, toggle it off - */ - StopFollowingPlayer(param); - - /** - We are done, bug out. - */ - return; - } - else - { - DisplayMenu(BuildPlayerListMenu(), param, MENU_TIME_FOREVER); - } - } -} - -/** -Select Player Menu Callbacks -*/ -public Menu_PlayerList(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - /** - Get the selected player - */ - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - new iTarget = GetClientOfUserId(StringToInt(sSelection)); - - /** - Start following the player - */ - StartFollowingPlayer(param1, iTarget); - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_GENERIC) - { - - /** - Display the last admin menu - */ - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } - else if (param2 == MenuCancel_Exit && GetClientTeam(param1) == g_aCurrentTeams[Spectator]) - { - /** - They canceled the current menu, start the hud back up - */ - StartDisplayingHud(param1); - } - } - else if (action == MenuAction_End) - { - - /** - Not a global menu, close it - */ - CloseHandle(menu); - } -} - -public Menu_SelectPlayer(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - - /** - Get the selected player - */ - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (strcmp(sSelection, "Current", false) == 0) - { - /** - Get the current target - */ - new iTarget = GetEntPropEnt(param1, Prop_Send, "m_hObserverTarget"); - - /** - Check to make sure the target is valid - */ - if (iTarget <= 0 || iTarget > MaxClients) - { - PrintToChat(param1, "\x03[SM-SPEC]\x01 %t", "Invalid Target"); - DisplayMenu(BuildPlayerListMenu(), param1, MENU_TIME_FOREVER); - } - - /** - Start following the player - */ - StartFollowingPlayer(param1, iTarget); - } - else - { - - /** - They want to select a player, show the player list - */ - DisplayMenu(BuildPlayerListMenu(), param1, MENU_TIME_FOREVER); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - - /** - They canceled the current menu, start the hud back up - */ - StartDisplayingHud(param1); - } - } - else if (action == MenuAction_End) - { - /** - Its a global menu, leave it alive - */ - } -} - -/** -Punishment Menu Callbacks -*/ -public Menu_Punishments(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - - /** - Get the menu selection - */ - new String:sSelection[15]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - - /** - Search for the correct index - */ - new e_Punishments:Index = Punish_None; - for ( ; _:Index <= sizeof(g_sPunishments); Index++) - { - if (StrEqual(sSelection, g_sPunishments[Index])) - { - break; - } - } - - /** - Display the next menu - */ - if (Index == Punish_Ban) - { - - /** - Set the punishment index and display ban time menu - */ - g_aPlayers[param1][TargetPunishment] = Index; - DisplayMenu(g_aMenus[hBanTime], param1, MENU_TIME_FOREVER); - } - else if (Index == Punish_Cheater) - { - - /** - Ask for confirmation before we set punishment index - */ - new Handle:hPanel = BuildAdminCheaterPanel(); - SendPanelToClient(hPanel, param1, Panel_AdminCheater, MENU_TIME_FOREVER); - CloseHandle(hPanel); - } - else - { - - /** - Set the punishment index and display reason menu - */ - g_aPlayers[param1][TargetPunishment] = Index; - DisplayMenu(g_aMenus[hReason], param1, MENU_TIME_FOREVER); - } - } - else if (action == MenuAction_Cancel) - { - - /** - They canceled the current menu, start the hud back up - */ - StartDisplayingHud(param1); - } - else if (action == MenuAction_End) - { - - /** - Not a global menu, close it - */ - CloseHandle(menu); - } -} - -public Menu_BanTime(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - - /** - Get the menu selection - */ - new String:sSelection[15]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - - /** - Set the ban time global - */ - g_aPlayers[param1][iBanTime] = StringToInt(sSelection); - - /** - Display the reason menu - */ - DisplayMenu(g_aMenus[hReason], param1, MENU_TIME_FOREVER); - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - - /** - They canceled the current menu, start the hud back up - */ - StartDisplayingHud(param1); - } - } - else if (action == MenuAction_End) - { - /** - Its a global menu, leave it alive - */ - } -} - -public Menu_Reason(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - - /** - Get the menu selection - */ - new String:sSelection[15]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - - /** - Perform the punishment - */ - PerformPunishment(param1, g_aPlayers[param1][iTargetIndex], g_aPlayers[param1][TargetPunishment], sSelection, g_aPlayers[param1][iBanTime]); - - /** - Reactivate the hud if still in spectator - */ - if (GetClientTeam(param1) == g_aCurrentTeams[Spectator]) - { - StartDisplayingHud(param1); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - - /** - They canceled the current menu, start the hud back up - */ - StartDisplayingHud(param1); - } - } - else if (action == MenuAction_End) - { - /** - Its a global menu, leave it alive - */ - } -} - -public Panel_AdminCheater(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - if (param2 == 1) - { - - /** - Set the punishment index and display reason menu - */ - g_aPlayers[param1][TargetPunishment] = Punish_Cheater; - DisplayMenu(g_aMenus[hReason], param1, MENU_TIME_FOREVER); - } - else - { - - /** - Reactivate the hud if still in spectator - */ - if (GetClientTeam(param1) == g_aCurrentTeams[Spectator]) - { - StartDisplayingHud(param1); - } - } - } -} - -public Panel_PublicCheater(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - if (param2 == 1) - { - //Waiting for SB 2.0 and sb_submission to be published - } - else - { - - /** - Reactivate the hud if still in spectator - */ - if (GetClientTeam(param1) == g_aCurrentTeams[Spectator]) - { - StartDisplayingHud(param1); - } - } - } -} - -/** -Hud Menu/Panel Callbacks -*/ -public Menu_PlayerHud(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "stop", false)) - { - StopFollowingPlayer(param1); - } - else if (StrEqual(sSelection, "start", false)) - { - StopDisplayingHud(param1); - DisplayMenu(g_aMenus[hSelectPlayer], param1, MENU_TIME_FOREVER); - } - else if (StrEqual(sSelection, "removecheater", false)) - { - g_aPlayers[g_aPlayers[param1][iTargetIndex]][bIsFlaggedCheater] = false; - } - else if (StrEqual(sSelection, "punish", false)) - { - if (g_aPlayers[param1][iTargetIndex]) - { - StopDisplayingHud(param1); - DisplayMenu(BuildPunishmentMenu(param1), param1, MENU_TIME_FOREVER); - } - else - { - StopDisplayingHud(param1); - PrintToChat(param1, "\x03[SM-SPEC]\x01 %t", "Must Have Target"); - DisplayMenu(g_aMenus[hSelectPlayer], param1, MENU_TIME_FOREVER); - } - } - else if (StrEqual(sSelection, "reportcheater", false)) - { - if (g_aPlayers[param1][iTargetIndex]) - { - StopDisplayingHud(param1); - new Handle:hPanel = BuildPublicCheaterPanel(); - SendPanelToClient(hPanel, param1, Panel_PublicCheater, MENU_TIME_FOREVER); - CloseHandle(hPanel); - } - else - { - StopDisplayingHud(param1); - PrintToChat(param1, "\x03[SM-SPEC]\x01 %t", "Must Have Target"); - DisplayMenu(g_aMenus[hSelectPlayer], param1, MENU_TIME_FOREVER); - } - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_Interrupted) - { - if (GetClientMenu(param1) == MenuSource_External) - { - StopDisplayingHud(param1); - } - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } -} - -public Panel_PlayerHud(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - switch (param2) - { - case 1: - { - if (g_aPlayers[param1][iTargetIndex]) - { - StopFollowingPlayer(param1); - } - else - { - StopDisplayingHud(param1); - DisplayMenu(BuildSelectPlayerMenu(), param1, MENU_TIME_FOREVER); - } - } - case 2: - { - if (!g_aPlayers[param1][iTargetIndex]) - { - StopDisplayingHud(param1); - PrintToChat(param1, "\x03[SM-SPEC]\x01 %t", "Must Have Target"); - DisplayMenu(g_aMenus[hSelectPlayer], param1, MENU_TIME_FOREVER); - return; - } - - if ((GetUserFlagBits(param1) & ADMFLAG_GENERIC) || (GetUserFlagBits(param1) & ADMFLAG_ROOT)) - { - if (g_aPlayers[g_aPlayers[param1][iTargetIndex]][bIsFlaggedCheater] && (GetUserFlagBits(param1) & ADMFLAG_ROOT)) - { - //Remove cheater flag - g_aPlayers[g_aPlayers[param1][iTargetIndex]][bIsFlaggedCheater] = false; - } - else - { - //Punish menu - StopDisplayingHud(param1); - DisplayMenu(BuildPunishmentMenu(param1), param1, MENU_TIME_FOREVER); - } - } - else - { - //Report Cheater - new Handle:hPanel = BuildPublicCheaterPanel(); - SendPanelToClient(hPanel, param1, Panel_PublicCheater, MENU_TIME_FOREVER); - CloseHandle(hPanel); - } - } - case 3: - { - StopDisplayingHud(param1); - } - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_Interrupted) - { - if (GetClientMenu(param1) == MenuSource_External) - { - StopDisplayingHud(param1); - } - } - } -} - - -/** -Stock functions -*/ -stock StartFollowingPlayer(client, target) -{ - - /** - If we have an open timer, close it. - */ - if (g_aPlayers[client][hTargetTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[client][hTargetTimer]); - g_aPlayers[client][hTargetTimer] = INVALID_HANDLE; - } - - /** - Make sure the target is on a non spectator team, and the client != target - */ - if (client == target) - { - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Yourself"); - return; - } - new iTargetTeam = GetClientTeam(target); - if (iTargetTeam == g_aCurrentTeams[Spectator] || iTargetTeam == g_aCurrentTeams[Unknown]) - { - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Spectator"); - return; - } - - /** - Check to see if client is already a spectator - */ - if (GetClientTeam(client) != g_aCurrentTeams[Spectator]) - { - - /** - Client is not a spectator, lets move them to spec. - */ - SM_MovePlayer(client, g_aCurrentTeams[Spectator]); - } - - /** - If we are using steambans call sb_status - */ - if (g_aPluginSettings[bUseSteamBans]) - { - FakeClientCommandEx(client, "sb_status"); - } - - - /** - Set the global and start to spectate the target. - Making sure it's long enough to deal with moving the client to spec if we had to. - */ - new String:sTargetName[MAX_NAME_LENGTH + 1]; - GetClientName(target, sTargetName, sizeof(sTargetName)); - g_aPlayers[client][iTargetIndex] = target; - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Spectating", sTargetName); - g_aPlayers[client][hTargetTimer] = CreateTimer(0.5, Timer_ResetTarget, client, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); - if (!g_aPlayers[client][bIsDisplayingHud] && GetClientTeam(client) == g_aCurrentTeams[Spectator]) - { - StartDisplayingHud(client); - } -} - -stock StopFollowingPlayer(client) -{ - - /** - If we have an open timer, close it. - */ - if (g_aPlayers[client][hTargetTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[client][hTargetTimer]); - } - - /** - Tell the client we can't spec his target anymore... if they are in game. - */ - if (IsClientInGame(client) && g_aPlayers[client][iTargetIndex] != 0) - { - new String:sTargetName[MAX_NAME_LENGTH + 1]; - GetClientName(g_aPlayers[client][iTargetIndex], sTargetName, sizeof(sTargetName)); - if (!IsClientConnected(g_aPlayers[client][iTargetIndex]) || !IsClientInGame(g_aPlayers[client][iTargetIndex])) - { - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Target Left"); - } - else - { - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Stopped spectating", sTargetName); - } - } - - /** - Null the globals. - */ - g_aPlayers[client][iTargetIndex] = 0; - g_aPlayers[client][hTargetTimer] = INVALID_HANDLE; -} - -stock StartDisplayingHud(client) -{ - if (g_aPluginCvarSettings[bRestrictHud] && !SM_IsValidAdmin(client, g_sAdminFlags)) - { - return; - } - else - { - /** - Double check the hud timer - We should not have one, but if we do, lets cancel it for the current callback - */ - StopDisplayingHud(client); - - /** - Now we can safely display the hud and make sure the current stored handle is the current timer - */ - g_aPlayers[client][bIsDisplayingHud] = true; - g_aPlayers[client][hHudTimer] = CreateTimer(0.5, Timer_UpdateHud, client, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); - } -} - -stock StopDisplayingHud(client) -{ - if (g_aPlayers[client][hHudTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[client][hHudTimer]); - } - g_aPlayers[client][hHudTimer] = INVALID_HANDLE; - g_aPlayers[client][bIsDisplayingHud] = false; -} - -stock ResetClient(client) -{ - StopFollowingPlayer(client); - StopDisplayingHud(client); - - g_aPlayers[client][bIsFlaggedCheater] = false; - g_aPlayers[client][TargetPunishment] = Punish_None; - g_aPlayers[client][iBanTime] = -1; -} - -stock PerformPunishment(client, target, e_Punishments:punishment, const String:reason[], time = 300) -{ - new String:sTargetName[MAX_NAME_LENGTH + 1], - String:sTargetID[64]; - - /** - The target could have left the game by the time we get here - Check for a valid target - */ - if (!IsClientConnected(target) || !IsClientInGame(target)) - { - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Target Left"); - return; - } - - GetClientName(target, sTargetName, sizeof(sTargetName)); - GetClientAuthString(target, sTargetID, sizeof(sTargetID)); - - switch (punishment) - { - case Punish_Kick: - { - KickClient(g_aPlayers[client][iTargetIndex], "%s", reason); - } - case Punish_Ban: - { - if (g_aPluginSettings[bUseSourceBans]) - { - ClientCommand(client, "sm_ban #%d %d \"%s\"", GetClientUserId(target), time, reason); - } - else if (g_aPluginSettings[bUseMySQLBans]) - { - ClientCommand(client, "mysql_ban #%d %d \"%s\"", GetClientUserId(target), time, reason); - } - else - { - BanClient(target, time, BANFLAG_AUTHID, reason, reason); - } - } - case Punish_Cheater: - { - g_aPlayers[target][bIsFlaggedCheater] = true; - } - case Punish_Beacon: - { - ClientCommand(client, "sm_beacon \"%s\"", sTargetName); - } - case Punish_Blind: - { - ClientCommand(client, "sm_blind \"%s\"", sTargetName); - } - case Punish_Drug: - { - ClientCommand(client, "sm_drug \"%s\"", sTargetName); - } - case Punish_Freeze: - { - ClientCommand(client, "sm_freeze \"%s\"", sTargetName); - } - case Punish_FreezeBomb: - { - ClientCommand(client, "sm_freezebomb \"%s\"", sTargetName); - } - case Punish_Slap: - { - ClientCommand(client, "sm_slap \"%s\" 10", sTargetName); - } - case Punish_Slay: - { - ClientCommand(client, "sm_slay \"%s\"", sTargetName); - } - case Punish_TimeBomb: - { - ClientCommand(client, "sm_timebomb \"%s\"", sTargetName); - } - } - - if (punishment == Punish_Cheater) - { - LogAction(client, target, "[SM SPEC] %N marked %N(%s) with a %s flag for %s", client, target, sTargetID, g_sPunishments[punishment], reason); - } - else - { - ShowActivity(client, "%t", "Punished", sTargetName, g_sPunishments[punishment], reason); - LogAction(client, target, "[SM SPEC] %N punished %N(%s) with a %s for %s", client, target, sTargetID, g_sPunishments[punishment], reason); - } - - /** - Null the globals. - */ - g_aPlayers[client][TargetPunishment] = Punish_None; - g_aPlayers[client][iBanTime] = -1; -} - -/** -Build the menu of player names -*/ -stock Handle:BuildPlayerListMenu() -{ - new Handle:hMenu = CreateMenu(Menu_PlayerList); - AddTargetsToMenu(hMenu, 0, true, false); - SetMenuTitle(hMenu, "Select A Player:"); - SetMenuExitBackButton(hMenu, true); - return hMenu; -} - -/** -Build the select player menu (current or list of players) -*/ -stock Handle:BuildSelectPlayerMenu() -{ - new Handle:hMenu = CreateMenu(Menu_SelectPlayer); - SetMenuTitle(hMenu, "Select A Player:"); - AddMenuItem(hMenu, "Current", "Current Target"); - AddMenuItem(hMenu, "List", "Player List"); - SetMenuExitBackButton(hMenu, true); - return hMenu; -} - -/** -Build the punishmenu menu -*/ -stock Handle:BuildPunishmentMenu(iClient) -{ - new Handle:hMenu = CreateMenu(Menu_Punishments); - SetMenuTitle(hMenu, "Select A Punishment:"); - SetMenuExitBackButton(hMenu, true); - SetMenuExitButton(hMenu, true); - - if (g_aPluginCvarSettings[bKick] && ((GetUserFlagBits(iClient) & ADMFLAG_GENERIC) || (GetUserFlagBits(iClient) & ADMFLAG_ROOT))) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Kick], "Kick"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Kick], "Kick", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bBan] && ((GetUserFlagBits(iClient) & ADMFLAG_GENERIC) || (GetUserFlagBits(iClient) & ADMFLAG_ROOT))) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Ban], "Ban"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Ban], "Ban", ITEMDRAW_DISABLED); - } - - if (g_aPluginSettings[bUseDukehacks] && g_aPluginCvarSettings[bCheater] && (GetUserFlagBits(iClient) & ADMFLAG_ROOT)) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Cheater], "Flag As Cheater"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Cheater], "Flag As Cheater", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bBeacon]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Beacon], "Beacon"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Beacon], "Beacon", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bBlind]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Blind], "Blind"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Blind], "Blind", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bDrug]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Drug], "Drug"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Drug], "Drug", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bFreeze]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Freeze], "Freeze"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Freeze], "Freeze", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bFreezebomb]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_FreezeBomb], "Freeze Bomb"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_FreezeBomb], "Freeze Bomb", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bSlap]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Slap], "Slap"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Slap], "Slap", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bSlay]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Slay], "Slay"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Slay], "Slay", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bTimeBomb]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_TimeBomb], "Time Bomb"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_TimeBomb], "Time Bomb", ITEMDRAW_DISABLED); - } - - return hMenu; -} - -/** -Build the punishmenu menu -*/ -stock Handle:BuildBanTimeMenu() -{ - new Handle:hMenu = CreateMenu(Menu_BanTime); - SetMenuTitle(hMenu, "Select Ban Type:"); - - if (g_aPluginCvarSettings[bBanPerm]) - { - AddMenuItem(hMenu, "permban", "Permanent"); - } - else - { - AddMenuItem(hMenu, "permban", "Permanent", ITEMDRAW_DISABLED); - } - - AddMenuItem(hMenu, "10", "10 Minutes"); - AddMenuItem(hMenu, "30", "30 Minutes"); - AddMenuItem(hMenu, "60", "1 Hour"); - AddMenuItem(hMenu, "240", "4 Hours"); - AddMenuItem(hMenu, "1440", "1 Day"); - AddMenuItem(hMenu, "10080", "1 Week"); - - SetMenuExitBackButton(hMenu, true); - return hMenu; -} - -/** -Build the punishmenu menu -*/ -stock Handle:BuildReasonMenu() -{ - new Handle:hMenu = CreateMenu(Menu_Reason); - SetMenuTitle(hMenu, "Select A Reason:"); - - AddMenuItem(hMenu, "Abusive", "Abusive"); - AddMenuItem(hMenu, "Racism", "Racism"); - AddMenuItem(hMenu, "General cheating/exploits", "General cheating/exploits"); - AddMenuItem(hMenu, "Wallhack", "Wallhack"); - AddMenuItem(hMenu, "Aimbot", "Aimbot"); - AddMenuItem(hMenu, "Speedhacking", "Speedhacking"); - AddMenuItem(hMenu, "Mic spamming", "Mic spamming"); - AddMenuItem(hMenu, "Admin disrepect", "Admin disrepect"); - AddMenuItem(hMenu, "Camping", "Camping"); - AddMenuItem(hMenu, "Team killing", "Team killing"); - AddMenuItem(hMenu, "Unacceptable Spray", "Unacceptable Spray"); - AddMenuItem(hMenu, "Breaking Server Rules", "Breaking Server Rules"); - AddMenuItem(hMenu, "Other", "Other"); - - SetMenuExitBackButton(hMenu, true); - return hMenu; -} - -/** -Build the cheater displays -*/ -stock Handle:BuildAdminCheaterPanel() -{ - - /** - Create the menu and set the menu options. - */ - new Handle:hPanel = CreatePanel(); - SetPanelTitle(hPanel, "Simple Spectator:"); - - DrawPanelText(hPanel, "Are you sure you want to"); - DrawPanelText(hPanel, "flag this player as a cheater?"); - DrawPanelText(hPanel, "They will not be able to damage"); - DrawPanelText(hPanel, "anyone and die on fall damage."); - DrawPanelItem(hPanel, "Yes"); - DrawPanelItem(hPanel, "No"); - - return hPanel; -} - -stock Handle:BuildPublicCheaterPanel() -{ - - /** - Create the menu and set the menu options. - */ - new Handle:hPanel = CreatePanel(); - SetPanelTitle(hPanel, "Simple Spectator:"); - - DrawPanelText(hPanel, "Are you sure you want to"); - DrawPanelText(hPanel, "submit this player as a cheater?"); - DrawPanelItem(hPanel, "Yes (Not Implemented Yet)", ITEMDRAW_DISABLED); - DrawPanelItem(hPanel, "No"); - return hPanel; -} - -/** -Build the hud displays -*/ -stock Handle:BuildPlayerHudMenu(iClient, iTarget) -{ - - /** - Create all the string variables we will need - */ - new String:sTargetName[MAX_NAME_LENGTH + 1], - String:sTargetID[64], - String:sTargetIP[16]; - - new String:sDisplayName[MAX_NAME_LENGTH + 1], - String:sDisplayID[64], - String:sDisplayIP[64], - String:sDisplayFrags[16], - String:sDisplayDeaths[16]; - - new iTargetFrags, - iTargetDeaths; - - /** - Get the targets information - */ - GetClientName(iTarget, sTargetName, sizeof(sTargetName)); - GetClientIP(iTarget, sTargetIP, sizeof(sTargetIP)); - GetClientAuthString(iTarget, sTargetID, sizeof(sTargetID)); - iTargetFrags = GetClientFrags(iTarget); - iTargetDeaths = GetClientDeaths(iTarget); - - /** - Format the strings for the menu - */ - Format(sDisplayName, sizeof(sDisplayName), "Player: %s", sTargetName); - Format(sDisplayID, sizeof(sDisplayID), "Steam ID: %s", sTargetID); - Format(sDisplayIP, sizeof(sDisplayIP), "IP Address: %s", sTargetIP); - Format(sDisplayFrags, sizeof(sDisplayFrags), "Kills: %i", iTargetFrags); - Format(sDisplayDeaths, sizeof(sDisplayDeaths), "Deaths: %i", iTargetDeaths); - - /** - Create the menu and set the menu options. - */ - new Handle:hMenu = CreateMenu(Menu_PlayerHud); - SetMenuExitBackButton(hMenu, false); - SetMenuTitle(hMenu, "Simple Spectator"); - - AddMenuItem(hMenu, "name", sDisplayName, ITEMDRAW_DISABLED); - AddMenuItem(hMenu, "steamid", sDisplayID, ITEMDRAW_DISABLED); - - if (SM_IsValidAdmin(iClient, g_sAdminFlags)) - { - AddMenuItem(hMenu, "ip", sDisplayIP, ITEMDRAW_DISABLED); - } - - AddMenuItem(hMenu, "kills", sDisplayFrags, ITEMDRAW_DISABLED); - AddMenuItem(hMenu, "deaths", sDisplayDeaths, ITEMDRAW_DISABLED); - - if (g_aPlayers[iClient][iTargetIndex]) - { - AddMenuItem(hMenu, "stop", "Stop Following"); - } - else - { - AddMenuItem(hMenu, "start", "Follow Player"); - } - - if ((GetUserFlagBits(iClient) & ADMFLAG_GENERIC) || (GetUserFlagBits(iClient) & ADMFLAG_ROOT)) - { - if (g_aPlayers[iTarget][bIsFlaggedCheater] && (GetUserFlagBits(iClient) & ADMFLAG_ROOT)) - { - AddMenuItem(hMenu, "removecheater", "Remove Cheater Flag"); - } - else - { - if (CanUserTarget(iClient, iTarget)) - { - AddMenuItem(hMenu, "punish", "Punish Player"); - } - else - { - AddMenuItem(hMenu, "punish", "Punish Player (Immune)", ITEMDRAW_DISABLED); - } - } - } - else - { - AddMenuItem(hMenu, "reportcheater", "Report Cheater"); - } - - SetMenuPagination(hMenu, MENU_NO_PAGINATION); - SetMenuExitButton(hMenu, true); - return hMenu; -} - -stock Handle:BuildPlayerHudPanel(iClient, iTarget) -{ - - /** - Create all the string variables we will need - */ - new String:sTargetName[MAX_NAME_LENGTH + 1], - String:sTargetID[64], - String:sTargetIP[16]; - - new String:sDisplayName[MAX_NAME_LENGTH + 1], - String:sDisplayID[64], - String:sDisplayIP[64], - String:sDisplayFrags[16], - String:sDisplayDeaths[16]; - - new iTargetFrags, - iTargetDeaths; - - /** - Get the targets information - */ - GetClientName(iTarget, sTargetName, sizeof(sTargetName)); - GetClientIP(iTarget, sTargetIP, sizeof(sTargetIP)); - GetClientAuthString(iTarget, sTargetID, sizeof(sTargetID)); - iTargetFrags = GetClientFrags(iTarget); - iTargetDeaths = GetClientDeaths(iTarget); - - /** - Format the strings for the menu - */ - Format(sDisplayName, sizeof(sDisplayName), "Player: %s", sTargetName); - Format(sDisplayID, sizeof(sDisplayID), "Steam ID: %s", sTargetID); - Format(sDisplayIP, sizeof(sDisplayIP), "IP Address: %s", sTargetIP); - Format(sDisplayFrags, sizeof(sDisplayFrags), "Kills: %i", iTargetFrags); - Format(sDisplayDeaths, sizeof(sDisplayDeaths), "Deaths: %i", iTargetDeaths); - - /** - Create the menu and set the menu options. - */ - new Handle:hPanel = CreatePanel(); - SetPanelTitle(hPanel, "Simple Spectator"); - - DrawPanelText(hPanel, "Player Information:"); - DrawPanelText(hPanel, sDisplayName); - DrawPanelText(hPanel, sDisplayID); - if (SM_IsValidAdmin(iClient, g_sAdminFlags)) - { - DrawPanelText(hPanel, sDisplayIP); - } - - DrawPanelText(hPanel, sDisplayFrags); - DrawPanelText(hPanel, sDisplayDeaths); - - if (g_aPlayers[iClient][iTargetIndex]) - { - DrawPanelItem(hPanel, "Stop Following"); - } - else - { - DrawPanelItem(hPanel, "Follow Player"); - } - - if ((GetUserFlagBits(iClient) & ADMFLAG_GENERIC) || (GetUserFlagBits(iClient) & ADMFLAG_ROOT)) - { - if (g_aPlayers[iTarget][bIsFlaggedCheater] && (GetUserFlagBits(iClient) & ADMFLAG_ROOT)) - { - DrawPanelItem(hPanel, "Remove Cheater Flag"); - } - else - { - if (CanUserTarget(iClient, iTarget)) - { - DrawPanelItem(hPanel, "Punish Player"); - } - else - { - DrawPanelItem(hPanel, "Punish Player (Immune)", ITEMDRAW_DISABLED); - } - } - } - else - { - DrawPanelItem(hPanel, "Report Cheater"); - } - - DrawPanelItem(hPanel, "Close Hud Panel"); - return hPanel; -} - -/** -Adjust the settings if a convar was changed -*/ -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - for (new iCvar = 0 ; _:iCvar < sizeof(g_aPluginCvarSettings); iCvar++) - { - if (g_aPluginCvar[_:iCvar] == convar) - { - if (StringToInt(newValue) == 1) - { - g_aPluginCvarSettings[_:iCvar] = true; - } - else - { - g_aPluginCvarSettings[_:iCvar] = false; - } - } - } - - /* - ReBuild the global menu that depends on cvars - */ - g_aMenus[hBanTime] = BuildBanTimeMenu(); - - /** - Run a loop to reset the hud - */ - for(new i = 1; i <= MaxClients; i++) - { - StopDisplayingHud(i); - if (IsClientConnected(i) && IsClientInGame(i) && GetClientTeam(i) == g_aCurrentTeams[Spectator]) - { - StartDisplayingHud(i); - } - } -} diff --git a/Simple Plugins Core/addons/sourcemod/scripting/simple-teambalancer.sp b/Simple Plugins Core/addons/sourcemod/scripting/simple-teambalancer.sp deleted file mode 100644 index 3302255..0000000 --- a/Simple Plugins Core/addons/sourcemod/scripting/simple-teambalancer.sp +++ /dev/null @@ -1,1797 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Team Balancer -Description: - Balances teams based upon player count - Player will not be balanced more than once in 5 (default) mins - Buddy system tries to keep buddies together - Ability to prioritize players - Ability to force players to accept the new team - Admins are immune -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include -#include - -#define PLUGIN_VERSION "2.1.$Rev$" - -enum PlayerData -{ - Handle:hBalanceTimer, - Handle:hForcedTimer, - bool:bSwitched, - bool:bFlagCarrier -}; - -/** - Global convar handles - */ -new Handle:stb_enabled = INVALID_HANDLE; -new Handle:stb_buddyenabled = INVALID_HANDLE; -new Handle:stb_logactivity = INVALID_HANDLE; -new Handle:stb_logactivity2 = INVALID_HANDLE; -new Handle:stb_unbalancelimit = INVALID_HANDLE; -new Handle:stb_deadonly = INVALID_HANDLE; -new Handle:stb_priorityenabled = INVALID_HANDLE; -new Handle:stb_uberlevel = INVALID_HANDLE; -new Handle:stb_balancedelay = INVALID_HANDLE; -new Handle:stb_livingplayerswitchdelay = INVALID_HANDLE; -new Handle:stb_livingplayercheckdelay = INVALID_HANDLE; -new Handle:stb_roundstartdelay = INVALID_HANDLE; -new Handle:stb_switchbackforced = INVALID_HANDLE; -new Handle:stb_adminflag = INVALID_HANDLE; -new Handle:stb_buddyrestriction = INVALID_HANDLE; -new Handle:stb_convarcontrol = INVALID_HANDLE; - -/** - Built-in cvars handles - */ -new Handle:stb_mp_autoteambalance = INVALID_HANDLE; -new Handle:stb_mp_teams_unbalance_limit = INVALID_HANDLE; -new Handle:TFGameModeArena = INVALID_HANDLE; - -/** - Timer handles - */ -new Handle:g_hBalanceTimer = INVALID_HANDLE; -new Handle:g_hLivingPlayerCheckTimer = INVALID_HANDLE; - -/** - Player arrays - */ -new g_aPlayers[MAXPLAYERS + 1][PlayerData]; - -/** -Global bools -*/ -new bool:g_bIsEnabled = true; -new bool:g_bPriorityPlayers = true; -new bool:g_bBuddyRestriction = false; -new bool:g_bLogActivity = false; -new bool:g_bLogActivity2 = false; -new bool:g_bDeadOnly = false; -new bool:g_bConVarControl = true; -new bool:g_bBuddyEnabled = true; -new bool:g_bBalanceInProgress = false; -new bool:g_bRoundStart = false; -new bool:g_bRoundEnd = false; -new bool:g_bSuddenDeath = false; -new bool:g_bIsArenaMode = false; - -/** - Global strings/integers/floats - */ -new g_iUnbalanceLimit, g_iLivingPlayerSwitchDelay, g_iLivingPlayerCheckDelay; -new g_iRoundStartDelay, g_iSwitchBackForced, g_iBalanceDelay; -new Float:g_fUberLevel; -new g_iOwnerOffset; -new String:g_sAdminFlag[5]; - -public Plugin:myinfo = -{ - name = "Simple Team Balancer", - author = "Simple Plugins", - description = "Balances teams based upon player count.", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -} - -public OnPluginStart() -{ - - /** - Create console variables - */ - CreateConVar("stb_version", PLUGIN_VERSION, "Simple Team Balancer", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - stb_enabled = CreateConVar("stb_enabled", "1", "Enable or Disable Simple Team Balancer", _, true, 0.0, true, 1.0); - stb_priorityenabled = CreateConVar("stb_priorityenabled", "1", "Enable or Disable the prioritization of living players", _, true, 0.0, true, 1.0); - stb_buddyrestriction = CreateConVar("stb_buddyrestriction", "0", "Enable or Disable Admin Only buddy lists", _, true, 0.0, true, 1.0); - stb_logactivity = CreateConVar("stb_logactivity", "0", "Enable or Disable the disaplying of events in the log", _, true, 0.0, true, 1.0); - stb_logactivity2 = CreateConVar("stb_logactivity2", "0", "Enable or Disable the disaplying of detailed events in the log (WILL SPAM LOG)", _, true, 0.0, true, 1.0); - stb_deadonly = CreateConVar("stb_deadonly", "0", "Enable or Disable the switching of only dead players", _, true, 0.0, true, 1.0); - stb_convarcontrol = CreateConVar("stb_convarcontrol", "1", "Enable or Disable the control of builtin console variables", _, true, 0.0, true, 1.0); - stb_buddyenabled = CreateConVar("stb_buddyenabled", "1", "Enable or Disable the buddy system", _, true, 0.0, true, 1.0); - stb_unbalancelimit = CreateConVar("stb_unbalancelimit", "2", "Amount of players teams are ALLOWED to be unbalanced by", _, true, 1.0, true, 32.0); - stb_balancedelay = CreateConVar("stb_balancedelay", "10", "Delay in seconds to start an autobalance"); - stb_livingplayerswitchdelay = CreateConVar("stb_livingplayerswitchdelay", "20", "Delay in seconds to switch living players once selected"); - stb_livingplayercheckdelay = CreateConVar("stb_livingplayercheckdelay", "10", "Delay in seconds to start checking living players once teams become unbalanced"); - stb_roundstartdelay = CreateConVar("stb_roundstartdelay", "15", "Delay in seconds to start balancing teams after the start of a round"); - stb_switchbackforced = CreateConVar("stb_switchbackforced", "300", "Amount of time in seconds to not switch a player twice and force the team if enabled"); - stb_uberlevel = CreateConVar("stb_uberlevel", "1.0", "Min uber level medic must have to have priority over other living players. Setting to 0 will rarely switch a living medic", _, true, 0.0, true, 1.0); - stb_adminflag = CreateConVar("stb_adminflag", "a", "Admin flag to use for immunity. Must be a in char format."); - stb_mp_autoteambalance = FindConVar("mp_autoteambalance"); - stb_mp_teams_unbalance_limit = FindConVar("mp_teams_unbalance_limit"); - - /** - Removing the notify tags from the built in cvars. We dont want spam. - */ - if (stb_mp_autoteambalance != INVALID_HANDLE) - { - SetConVarFlags(stb_mp_autoteambalance, GetConVarFlags(stb_mp_autoteambalance)^FCVAR_NOTIFY); - } - if (stb_mp_teams_unbalance_limit != INVALID_HANDLE) - { - SetConVarFlags(stb_mp_teams_unbalance_limit, GetConVarFlags(stb_mp_teams_unbalance_limit)^FCVAR_NOTIFY); - } - - /** - Hook console variables - */ - HookConVarChange(stb_enabled, ConVarSettingsChanged); - HookConVarChange(stb_priorityenabled, ConVarSettingsChanged); - HookConVarChange(stb_buddyrestriction, ConVarSettingsChanged); - HookConVarChange(stb_logactivity, ConVarSettingsChanged); - HookConVarChange(stb_logactivity2, ConVarSettingsChanged); - HookConVarChange(stb_deadonly, ConVarSettingsChanged); - HookConVarChange(stb_convarcontrol, ConVarSettingsChanged); - HookConVarChange(stb_buddyenabled, ConVarSettingsChanged); - HookConVarChange(stb_unbalancelimit, ConVarSettingsChanged); - HookConVarChange(stb_balancedelay, ConVarSettingsChanged); - HookConVarChange(stb_livingplayerswitchdelay, ConVarSettingsChanged); - HookConVarChange(stb_livingplayercheckdelay, ConVarSettingsChanged); - HookConVarChange(stb_roundstartdelay, ConVarSettingsChanged); - HookConVarChange(stb_switchbackforced, ConVarSettingsChanged); - HookConVarChange(stb_uberlevel, ConVarSettingsChanged); - HookConVarChange(stb_mp_autoteambalance, ConVarSettingsChanged); - HookConVarChange(stb_mp_teams_unbalance_limit, ConVarSettingsChanged); - - /** - Create console commands - */ - RegConsoleCmd("sm_buddy", Command_AddBalanceBuddy, "Add a balance buddy"); - RegConsoleCmd("sm_lockbuddy", Command_LockBuddy, "Locks your balance buddy selection"); - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook the game events - */ - LogAction(0, -1, "[STB] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_death", HookPlayerDeath, EventHookMode_Post); - HookEvent("player_team", HookPlayerChangeTeam, EventHookMode_Post); - switch (g_CurrentMod) - { - case GameType_TF: - { - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - HookEvent("teamplay_suddendeath_begin", HookSuddenDeathBegin, EventHookMode_PostNoCopy); - HookEvent("teamplay_flag_event", HookFlagEvent, EventHookMode_Post); - TFGameModeArena = FindConVar("tf_gamemode_arena"); - g_iOwnerOffset = FindSendPropInfo("CBaseObject", "m_hBuilder"); - } - case GameType_DOD: - { - HookEvent("dod_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_Post); - } - default: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - } - } - - /** - Load translations and .cfg file - */ - LoadTranslations ("simpleteambalancer.phrases"); - AutoExecConfig(true, "plugin.simpleteambalancer"); - LogAction(0, -1, "[STB] Simple Team Balancer is loaded."); -} - -public OnAllPluginsLoaded() -{ - //something -} - -public OnLibraryRemoved(const String:name[]) -{ - //something -} - -public OnConfigsExecuted() -{ - - /** - Load up global variables - */ - g_bIsEnabled = GetConVarBool(stb_enabled); - g_bBuddyEnabled = GetConVarBool(stb_buddyenabled); - g_bLogActivity = GetConVarBool(stb_logactivity); - g_bLogActivity2 = GetConVarBool(stb_logactivity2); - g_bDeadOnly = GetConVarBool(stb_deadonly); - g_bPriorityPlayers = GetConVarBool(stb_priorityenabled); - g_bBuddyRestriction = GetConVarBool(stb_buddyrestriction); - g_bConVarControl = GetConVarBool(stb_convarcontrol); - g_fUberLevel = GetConVarFloat(stb_uberlevel); - g_iUnbalanceLimit = GetConVarInt(stb_unbalancelimit); - g_iBalanceDelay = GetConVarInt(stb_balancedelay); - g_iLivingPlayerSwitchDelay = GetConVarInt(stb_livingplayerswitchdelay); - g_iLivingPlayerCheckDelay = GetConVarInt(stb_livingplayercheckdelay); - g_iRoundStartDelay = GetConVarInt(stb_roundstartdelay); - g_iSwitchBackForced = GetConVarInt(stb_switchbackforced); - GetConVarString(stb_adminflag, g_sAdminFlag, sizeof(g_sAdminFlag)); - - /** - Report enabled - */ - if (g_bIsEnabled) - { - LogAction(0, -1, "[STB] Simple Team Balancer is ENABLED."); - } - else - { - LogAction(0, -1, "[STB] Simple Team Balancer is DISABLED."); - } - - - /** - Report log activity - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Log Activity ENABLED."); - } - else - { - LogAction(0, -1, "[STB] Log Activity DISABLED."); - } - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Detailed Log Activity ENABLED."); - } - else - { - LogAction(0, -1, "[STB] Detailed Log Activity DISABLED."); - } -} - -public OnMapStart() -{ - - /** - Check for arena mode - */ - if (g_CurrentMod == GameType_TF && GetConVarBool(TFGameModeArena)) - { - g_bIsArenaMode = true; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Simple Team Balancer detected arena mode and will be bypassed"); - } - } - else - { - g_bIsArenaMode = false; - } - - /** - Reset the globals - */ - g_bBalanceInProgress = false; - g_bRoundStart = false; - g_bRoundEnd = false; - g_bSuddenDeath = false; - - /** - Set the built-in convars - */ - SetGameCvars(); -} - -public OnClientPostAdminCheck(client) -{ - - /** - Make sure its a valid connected client and buddy system is enabled - */ - if (client == 0 || !g_bIsEnabled || !IsClientConnected(client) || !g_bBuddyEnabled) - { - return; - } - - /** - Make sure if its set for admins only they have the flags - */ - if (g_bBuddyRestriction && !SM_IsValidAdmin(client, g_sAdminFlag)) - { - return; - } - - /** - Start the advertisement timer - */ - CreateTimer (60.0, Timer_WelcomeAdvert, client); -} - -public OnClientDisconnect(client) -{ - - /** - Call stock function to cleaup - */ - CleanUp(client); -} - -public OnClientDisconnect_Post(client) -{ - - /** - Determine if we need a balance - */ - if (OkToBalance() && IsUnbalanced() && !g_bBalanceInProgress) - { - - /** - No balance in progress but balance is needed - */ - StartABalance(); - } -} - -public SM_OnPlayerMoved(Handle:plugin, client, team) -{ - - /** - Make sure we called the move function - */ - if (plugin != GetMyHandle()) - { - if (g_bLogActivity2) - { - LogAction(0, client, "[STB] Callback was not started with current plugin, bugging out."); - } - return; - } - - /** - Get the players name and report the event - */ - decl String:sPlayerName[64]; - GetClientName(client, sPlayerName, sizeof(sPlayerName)); - if (g_bLogActivity) - { - LogAction(0, client, "[STB] Changed %s to team %i.", sPlayerName, team); - } - - /** - If we are in TF2 fire the bult-in team balance event - */ - if(g_CurrentMod == GameType_TF) - { - new Handle:event = CreateEvent("teamplay_teambalanced_player"); - SetEventInt(event, "player", client); - SetEventInt(event, "team", team); - FireEvent(event); - } - - /** - Notify the players - */ - PrintToChatAll("[SM] %T", "BalanceMessage", LANG_SERVER, sPlayerName); - - /** - Set the players variables and start a timer - */ - g_aPlayers[client][bSwitched] = true; - g_aPlayers[client][hForcedTimer] = CreateTimer(float(g_iSwitchBackForced), Timer_ForcedExpired, client, TIMER_FLAG_NO_MAPCHANGE); - - /** - We are done, log the completion and end the balance - */ - if (g_bLogActivity) - { - LogAction(0, client, "[STB] Balance finished."); - } - g_bBalanceInProgress = false; -} - -/* HOOKED EVENTS */ - -public HookPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get our event variables - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - decl String:sWeapon[64]; - GetEventString(event, "weapon", sWeapon, sizeof(sWeapon)); - - /** - Return if death was not caused by a player - This is the case when the player switches teams - */ - if (StrEqual(sWeapon, "world", false)) - { - return; - } - - - /** - Check if balance is needed - */ - if (IsClientInGame(iClient) && OkToBalance() && IsUnbalanced()) - { - new iSmallerTeam = GetSmallerTeam(); - - /** - Check if balance is in progress - */ - if (g_bBalanceInProgress) - { - - /** - There is a balance in progress - Check the player who died to see if he is supposed to be switched - */ - if (g_aPlayers[iClient][hBalanceTimer] != INVALID_HANDLE) - { - - /** - The player has a timer on him to switch him to other team - Stop the timer - */ - CloseHandle(g_aPlayers[iClient][hBalanceTimer]); - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - if (g_bLogActivity) - { - LogAction(0, iClient, "[STB] With a balance in progress the queued living player died and was switched."); - } - - /** - Call the stock change team function - */ - BalancePlayer(iClient, SM_GetForcedTeam(iClient)); - return; - } - - /** - Before we continue, lets make sure the client is switchable - */ - if (IsSwitchablePlayer(iClient, GetBiggerTeam())) - { - - /** - Now we check the buddy system - */ - if (g_bBuddyEnabled) - { - - /** - Buddy system is enabled, check to see if client has buddy - */ - new iBuddyIndex = SM_GetClientBuddy(iClient); - if (iBuddyIndex != 0 || !IsClientConnected(iBuddyIndex) || !IsClientInGame(iBuddyIndex)) - { - - /** - The client has a buddy, so we check to see if they are on same team - */ - if (GetClientTeam(iClient) == GetClientTeam(iBuddyIndex)) - { - - /** - They are, but we don't bug out, we still need to start a balance - */ - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] With a balance in progress a buddy on the right team was found and skipped."); - } - } - else - { - - /** - They are not on the same team - The buddy could be in spec, and that would make it not matter where he is, or the buddy is on the smaller team - */ - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] With a balance in progress a buddy on the wrong team was switched."); - } - BalancePlayer(iClient, iSmallerTeam); - return; - } - } - else - { - - /** - Client doesn't have a buddy, balance this player - */ - BalancePlayer(iClient, iSmallerTeam); - return; - } - } - else - { - - /** - Buddy system is not enabled, balance this player - */ - BalancePlayer(iClient, iSmallerTeam); - return; - } - } - } - else - { - - /** - If we get to here then we must need to start a balance - */ - StartABalance(); - } - } -} - -public HookPlayerChangeTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get our event variables. - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - new iTeam = GetEventInt(event, "team"); - - /** - Make sure its ok to balance. - */ - if (OkToBalance()) - { - - /** - See if the client that changed teams was set to with a balance. - */ - if (g_aPlayers[iClient][hBalanceTimer] != INVALID_HANDLE - && SM_GetForcedTeam(iClient) == iTeam - && g_bBalanceInProgress) - { - - /** - The client was set to be balanced, so we close the timer. - */ - CloseHandle(g_aPlayers[iClient][hBalanceTimer]); - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - - /** - Stop the balance. - */ - g_bBalanceInProgress = false; - return; - } - - /** - It's not likely that this team change can cause us to need a balance. - If it does, start one with a small dealy to deal with forced switch backs. - */ - if (IsUnbalanced() && !g_bBalanceInProgress) - { - CreateTimer(2.0, Timer_ChangeTeamBalanceDelay, _, TIMER_FLAG_NO_MAPCHANGE); - } - } -} - -public HookRoundStart(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Set the variables we need to start a round - */ - g_bRoundStart = true; - g_bRoundEnd = false; - g_bSuddenDeath = false; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Round Started"); - } - - /** - Start a delayed balance check at the start of the round - */ - CreateTimer(float(g_iRoundStartDelay), Timer_RoundStart); -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Set the variables we need at round end - */ - g_bRoundEnd = true; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Round Ended"); - } -} - -public HookSuddenDeathBegin(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Set the variables we need for sudden death - */ - g_bSuddenDeath = true; -} - -public HookFlagEvent(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get our event variables - */ - new iClient = GetEventInt(event, "player"); - new iFlagStatus = GetEventInt(event, "eventtype"); - - /** - Make sure we have a valid client - */ - if (!IsClientInGame(iClient)) - { - return; - } - - /** - Determine what kind of event this is - */ - switch (iFlagStatus) - { - case 1: - { - - /** - The flag was picked up - */ - g_aPlayers[iClient][bFlagCarrier] = true; - } - case 2: - { - - /** - The flag was capped - */ - g_aPlayers[iClient][bFlagCarrier] = false; - } - case 3: - { - - /** - The flag was defended, we don't have to do anything - */ - } - case 4: - { - - /** - The flag was dropped - */ - g_aPlayers[iClient][bFlagCarrier] = false; - } - } -} - -/* COMMAND EVENTS */ - -public Action:Command_AddBalanceBuddy(client, args) -{ - if (client == 0) - { - ReplyToCommand(client, "[SM] %T", "PlayerLevelCmd", LANG_SERVER); - return Plugin_Handled; - } - if (!g_bIsEnabled || !g_bBuddyEnabled) - { - ReplyToCommand(client, "[SM] %T", "CmdDisabled", LANG_SERVER); - return Plugin_Handled; - } - if (g_bBuddyRestriction) - { - if (!SM_IsValidAdmin(client, g_sAdminFlag)) - { - ReplyToCommand(client, "[SM] %T", "RestrictedBuddy", LANG_SERVER); - return Plugin_Handled; - } - } - decl String:sPlayerUserId[24]; - GetCmdArg(1, sPlayerUserId, sizeof(sPlayerUserId)); - new iPlayer = GetClientOfUserId(StringToInt(sPlayerUserId)); - if (!iPlayer || !IsClientInGame(iPlayer) || client == iPlayer) - { - if (client == iPlayer) - { - PrintHintText(client, "%T", "SelectSelf", LANG_SERVER); - } - ReplyToCommand(client, "[SM] Usage: buddy "); - new Handle:playermenu = BuildPlayerMenu(); - DisplayMenu(playermenu, client, MENU_TIME_FOREVER); - } - else - { - decl String:cName[128]; - decl String:bName[128]; - GetClientName(client, cName, sizeof(cName)); - GetClientName(iPlayer, bName, sizeof(bName)); - if (SM_IsBuddyLocked(iPlayer)) - { - ReplyToCommand(client, "[SM] %T", "PlayerLockedBuddyMsg", LANG_SERVER, bName); - return Plugin_Handled; - } - SM_AssignBuddy(client, iPlayer); - PrintHintText(client, "%T", "BuddyMsg", LANG_SERVER, bName); - PrintHintText(iPlayer, "%T", "BuddyMsg", LANG_SERVER, cName); - } - return Plugin_Handled; -} - -public Action:Command_LockBuddy(client, args) -{ - if (client == 0) - { - ReplyToCommand(client, "[SM] %T", "PlayerLevelCmd", LANG_SERVER); - return Plugin_Handled; - } - if (!g_bIsEnabled) - { - ReplyToCommand(client, "[SM] %T", "CmdDisabled", LANG_SERVER); - return Plugin_Handled; - } - if (g_bBuddyRestriction) - { - if (!SM_IsValidAdmin(client, g_sAdminFlag)) - { - ReplyToCommand(client, "[SM] %T", "RestrictedBuddy", LANG_SERVER); - return Plugin_Handled; - } - } - if (SM_IsBuddyLocked(client)) - { - SM_LockBuddy(client, false); - PrintHintText(client, "%T", "BuddyLockMsgDisabled", LANG_SERVER); - } - else - { - SM_LockBuddy(client, true); - PrintHintText(client, "%T", "BuddyLockMsgEnabled", LANG_SERVER); - } - return Plugin_Handled; -} - -/** -Stock functions . - */ - -stock bool:IsUnbalanced() -{ - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Checking if teams are unbalanced"); - } - new Team1Count = GetTeamClientCount(g_aCurrentTeams[Team1]); - new Team2Count = GetTeamClientCount(g_aCurrentTeams[Team2]); - new ubCount = RoundFloat(FloatAbs(float(Team1Count - Team2Count))); - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Team1:%i Team2:%i Difference:%i", Team1Count, Team2Count, ubCount); - } - if (ubCount > g_iUnbalanceLimit) - { - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Teams are unbalanced"); - } - return true; - } - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Teams are not unbalanced"); - } - return false; -} - -stock bool:OkToBalance() -{ - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Checking if OK to balance."); - } - new bool:bResult = false; - if (g_bIsEnabled && !g_bRoundStart && !g_bRoundEnd && !g_bIsArenaMode && !g_bSuddenDeath) - { - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Passed IF statement"); - LogAction(0, -1, "[STB] Now checking admins"); - } - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientInGame(i) && !SM_IsValidAdmin(i, g_sAdminFlag)) - { - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Found at least 1 non-admin"); - LogAction(0, -1, "[STB] OK to balance"); - } - bResult = true; - break; - } - } - if (!bResult && g_bLogActivity2) - { - LogAction(0, -1, "[STB] All admins online"); - } - } - if (!bResult && g_bLogActivity2) - { - LogAction(0, -1, "[STB] Not OK to balance"); - } - return bResult; -} - -stock bool:IsSwitchablePlayer(iClient, iBiggerTeam) -{ - - /** - Run the client thru some standard checks - */ - if (!IsClientInGame(iClient) - || SM_IsValidAdmin(iClient, g_sAdminFlag) - || g_aPlayers[iClient][bFlagCarrier] - || GetClientTeam(iClient) != iBiggerTeam - || g_aPlayers[iClient][bSwitched]) - { - - /** - The supplied client can't be switched - */ - return false; - } - - /** - The supplied client can be switched - */ - return true; -} - -stock bool:HasUber(iClient) -{ - - /** - First things first, make sure the client is a medic - */ - if(TF2_GetPlayerClass(iClient) == TFClass_Medic) - { - - /** - We can only check the active weapon, so make sure the client is holding the uber gun - */ - decl String:sWeaponName[32]; - GetClientWeapon(iClient, sWeaponName, sizeof(sWeaponName)); - if(StrEqual(sWeaponName, "tf_weapon_medigun")) - { - - /** - They are, so lets check the uber level of the gun - */ - new iEntityIndex = GetEntDataEnt2(iClient, FindSendPropInfo("CTFPlayer", "m_hActiveWeapon")); - new Float:fChargeLevel = GetEntDataFloat(iEntityIndex, FindSendPropInfo("CWeaponMedigun", "m_flChargeLevel")); - if (fChargeLevel >= g_fUberLevel) - { - - /** - The client supplied has an uber above the supplied level, return true - */ - if (g_bLogActivity2) - { - LogAction(0, iClient, "[STB] Found a medic with a uber and skipped him."); - } - return true; - } - } - } - - /** - The client supplied does not have an uber above the supplied level, return false - */ - return false; -} - -stock bool:HasBuildingsBuilt(iClient) -{ - - /** - We have to start a loop to check the owner of all the valid entities - */ - new iMaxEntities = GetMaxEntities(); - for (new i = MaxClients + 1; i <= iMaxEntities; i++) - { - if (!IsValidEntity(i)) - { - - /** - Not valid, continue to next one - */ - continue; - } - - /** - Get the name of the current entity - */ - decl String:sNetClass[32]; - GetEntityNetClass(i, sNetClass, sizeof(sNetClass)); - - /** - See if its something that an engineer would build - */ - if (strcmp(sNetClass, "CObjectSentrygun") == 0 - || strcmp(sNetClass, "CObjectTeleporter") == 0 - || strcmp(sNetClass, "CObjectDispenser") == 0) - { - - /** - It is, so lets check the owner - */ - if (GetEntDataEnt2(i, g_iOwnerOffset) == iClient) - { - - /** - The client supplied is the owner, return true - */ - if (g_bLogActivity2) - { - LogAction(0, iClient, "[STB] Found an engineer with buildings and skipped him."); - } - return true; - } - } - } - - /** - The client supplied didn't have any buildings, return false - */ - return false; -} - -stock StartABalance() -{ - - /** - See if we are already started a balance - */ - if (g_hBalanceTimer != INVALID_HANDLE) - { - - /** - We have, check if we still need to - */ - if (!IsUnbalanced() || !OkToBalance()) - { - - /** - We don't, stop the balance - It's almost impossible to reach this code, but we do it just in case - */ - CloseHandle(g_hBalanceTimer); - g_hBalanceTimer = INVALID_HANDLE; - g_bBalanceInProgress = false; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Balance delay timer was not needed and was killed before the callback."); - } - return; - } - else - { - - /** - We still need to balance - Bug out and wait for the current one to finish - */ - return; - } - } - - /** - Report that teams are unbalanced - */ - PrintToChatAll("[SM] %T", "UnBalanced", LANG_SERVER); - - /** - Check to see if we are supposed to delay the balance - */ - if (g_iBalanceDelay == 0) - { - - /** - Start the balance now - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Balance is now in progress."); - } - g_bBalanceInProgress = true; - g_hBalanceTimer = INVALID_HANDLE; - - /** - Check if we are allowed to scan living players - */ - if (!g_bDeadOnly) - { - - /** - We are allowed to, so we start a timer - */ - StartALivingPlayerTimer(); - - /** - Also report that we are now scanning dead players as well - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Now scanning dead players."); - } - } - else - { - - /** - We are not allowed to, so report that we are only scanning dead players - */ - if (g_bLogActivity) - LogAction(0, -1, "[STB] Only scanning dead players."); - } - - /** - We started the balance, bug out - */ - return; - } - - /** - We are supposed to delay the balance, start a balance timer - */ - g_hBalanceTimer = CreateTimer(float(g_iBalanceDelay), Timer_BalanceTeams, _, TIMER_FLAG_NO_MAPCHANGE); - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Teams are unbalanced. Balance delay timer started."); - } -} - -stock StartALivingPlayerTimer() -{ - - /** - Start a timer to check living players - */ - if (g_hLivingPlayerCheckTimer != INVALID_HANDLE) - { - - /** - If we for some reason already have one started, stop it. - */ - CloseHandle(g_hLivingPlayerCheckTimer); - g_hLivingPlayerCheckTimer = INVALID_HANDLE; - } - - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Living player balance delay timer started."); - } - g_hLivingPlayerCheckTimer = CreateTimer(float(g_iLivingPlayerCheckDelay), Timer_LivingPlayerCheck, _, TIMER_FLAG_NO_MAPCHANGE); -} - -stock FindSwitchablePlayer() -{ - - /** - Start a loop to find a switchable player - */ - new iPlayer; - new iBiggerTeam = GetBiggerTeam(); - for (new i = 1; i <= MaxClients; i++) - { - - /** - Check the stock function to see if we are allows to even switch the player - */ - if (!IsSwitchablePlayer(i, iBiggerTeam)) - { - continue; - } - - /** - If the mod is TF2 and they have Priority Players set check if the client has buildings or an uber - */ - if (g_CurrentMod == GameType_TF && g_bPriorityPlayers) - { - if (HasUber(i) || HasBuildingsBuilt(i)) - { - continue; - } - } - - /** - So far we are able we switch this player - Now we check the buddy system - */ - if (g_bBuddyEnabled) - { - - /** - Buddy system is enabled, check to see if client has buddy - */ - if (SM_GetClientBuddy(i) != 0) - { - - /** - The client has a buddy, so we check to see if they are on same team - */ - if (GetClientTeam(i) == GetClientTeam(SM_GetClientBuddy(i))) - { - - /** - They are, so we continue to next client - */ - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] With a balance in progress a buddy on the right team was found and skipped."); - } - continue; - } - else - { - - /** - They are not on the same team, set this client - The buddy could be in spec, and that would make it not matter where he is, or the buddy is on the smaller team - */ - iPlayer = i; - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] With a balance in progress a buddy on the wrong team was found."); - } - break; - } - } - else - { - - /** - The client does not have a buddy, set this client - */ - iPlayer = i; - break; - } - } - else - { - - /** - Buddy system is not enabled, set this client - */ - iPlayer = i; - break; - } - } - - /** - Return the client we set, this could be 0, but very unlikely - */ - return iPlayer; -} - -stock BalancePlayer(iClient, iTeam) -{ - new Handle:hPack = CreateDataPack(); - WritePackCell(hPack, iClient); - WritePackCell(hPack, iTeam); - CreateTimer(0.1, Timer_BalancePlayer, hPack, TIMER_FLAG_NO_MAPCHANGE); -} - -stock CleanUp(iClient) -{ - g_aPlayers[iClient][bFlagCarrier] = false; - g_aPlayers[iClient][bSwitched] = false; - if (g_aPlayers[iClient][hForcedTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[iClient][hForcedTimer]); - g_aPlayers[iClient][hForcedTimer] = INVALID_HANDLE; - if (g_bLogActivity) - { - LogAction(0, iClient, "[STB] Forced player disconnected, killing timer."); - } - } - if (g_aPlayers[iClient][hBalanceTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[iClient][hBalanceTimer]); - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - if (g_bLogActivity) - { - LogAction(0, iClient, "[STB] Living player set to be balanced disconnected, killing timer."); - } - } -} - -stock GetSmallerTeam() -{ - - /** - Get the count of players on each team - */ - new iCountT1 = GetTeamClientCount(g_aCurrentTeams[Team1]); - new iCountT2 = GetTeamClientCount(g_aCurrentTeams[Team2]); - - /** - Return the smaller team - */ - if (iCountT1 < iCountT2) - { - return g_aCurrentTeams[Team1]; - } - else if (iCountT1 > iCountT2) - { - return g_aCurrentTeams[Team2]; - } - return 0; -} - -stock GetBiggerTeam() -{ - - /** - Get the count of players on each team - */ - new iCountT1 = GetTeamClientCount(g_aCurrentTeams[Team1]); - new iCountT2 = GetTeamClientCount(g_aCurrentTeams[Team2]); - - /** - Return the bigger team - */ - if (iCountT1 > iCountT2) - { - return g_aCurrentTeams[Team1]; - } - else if (iCountT1 < iCountT2) - { - return g_aCurrentTeams[Team2]; - } - return 0; -} - -stock SetGameCvars() -{ - if (g_bConVarControl && g_bIsEnabled) - { - if (stb_mp_autoteambalance != INVALID_HANDLE) - { - SetConVarInt(stb_mp_autoteambalance, 0); - } - if (stb_mp_teams_unbalance_limit != INVALID_HANDLE) - { - SetConVarInt(stb_mp_teams_unbalance_limit, g_iUnbalanceLimit); - } - } -} - -/* TIMER FUNCTIONS */ - -public Action:Timer_ChangeTeamBalanceDelay(Handle:timer, any:data) -{ - - /** - Finally start one if it's still unbalanced - */ - if (IsUnbalanced() && !g_bBalanceInProgress) - { - StartABalance(); - } -} - -public Action:Timer_BalanceTeams(Handle:timer, any:data) -{ - - /** - See if we still need to balance the teams - */ - if (!IsUnbalanced() || !OkToBalance()) - { - - /** - We don't, kill the balance - */ - g_bBalanceInProgress = false; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Balance delay timer was not needed and died."); - } - g_hBalanceTimer = INVALID_HANDLE; - return Plugin_Handled; - } - - /** - We still need to balance the teams - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Teams are still unbalanced. Balance is now in progress."); - } - g_bBalanceInProgress = true; - - - /** - Check if we are allowed to scan living players - */ - if (!g_bDeadOnly) - { - - /** - We are allowed to, so we start a timer - */ - StartALivingPlayerTimer(); - - /** - Also report that we are now scanning dead players as well - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Now scanning dead players."); - } - } - else - { - - /** - We are not allowed to, so report that we are only scanning dead players - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Only scanning dead players."); - } - } - - g_hBalanceTimer = INVALID_HANDLE; - return Plugin_Handled; -} - -public Action:Timer_LivingPlayerCheck(Handle:timer, any:data) -{ - - /** - Check to see if we still need to balance the teams - */ - if (!IsUnbalanced() || !OkToBalance()) - { - - /** - We don't, kill it and bug out - */ - g_bBalanceInProgress = false; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Living player balance delay timer was not needed and died."); - } - g_hLivingPlayerCheckTimer = INVALID_HANDLE; - return Plugin_Handled; - } - - /** - Call the stock function to find a player we can switch - */ - new iPlayer = FindSwitchablePlayer(); - - /** - Check to see if we found a player - */ - if (iPlayer == 0) - { - - /** - In the unlikely event that the stock function didn't return a player - Start a loop to find a random player - */ - new iBiggerTeam = GetBiggerTeam(); - do - { - iPlayer = GetRandomInt(1, MaxClients); - } while (!IsSwitchablePlayer(iPlayer, iBiggerTeam)); - - if (g_bLogActivity) - { - LogAction(0, iPlayer, "[STB] Found a random living player."); - } - } - else - { - if (g_bLogActivity) - { - LogAction(0, iPlayer, "[STB] Found a living player."); - } - } - - /** - Now that we have a player assigned them to the smaller team - */ - new iSmallerTeam = GetSmallerTeam(); - SM_SetForcedTeam(iPlayer, iSmallerTeam, true); - - /** - Let the player know we could be switching him soon - */ - PrintHintText(iPlayer, "%T", "PlayerMessage", LANG_SERVER, g_iLivingPlayerSwitchDelay); - if (g_bLogActivity) - { - LogAction(0, iPlayer, "[STB] Living player placed on a timer."); - } - - /** - Create a timer to switch the player - */ - g_aPlayers[iPlayer][hBalanceTimer] = CreateTimer(float(g_iLivingPlayerSwitchDelay), Timer_LivingPlayerBalance, iPlayer, TIMER_FLAG_NO_MAPCHANGE); - - /** - Reset the timer handle - */ - g_hLivingPlayerCheckTimer = INVALID_HANDLE; - - /** - We are done, bug out - */ - return Plugin_Handled; -} - -public Action:Timer_LivingPlayerBalance(Handle:timer, any:iClient) -{ - - /** - Check to make sure we still need to balance - */ - if (!IsUnbalanced() || !OkToBalance()) - { - - /** - We don't need to balance, bug out - */ - g_bBalanceInProgress = false; - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - SM_ClearForcedTeam(iClient); - return Plugin_Handled; - } - - /** - We still need to balance, lets make sure we can still balance this player - */ - if (!IsClientConnected(iClient) || g_aPlayers[iClient][bFlagCarrier]) - { - g_bBalanceInProgress = false; - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - SM_ClearForcedTeam(iClient); - if (g_bLogActivity) - { - if (g_aPlayers[iClient][bFlagCarrier]) - { - LogAction(0, iClient, "[STB] Living player became flag carrier, balance restarted."); - } - else - { - LogAction(0, iClient, "[STB] Living player timer was not needed and died."); - } - } - return Plugin_Handled; - } - - /** - Clear to balance this player, so do it - */ - BalancePlayer(iClient, SM_GetForcedTeam(iClient)); - if (g_bLogActivity) - { - LogAction(0, iClient, "[STB] Living player was switched."); - } - - /** - We are done, bug out - */ - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - return Plugin_Handled; -} - -public Action:Timer_BalancePlayer(Handle:timer, Handle:pack) -{ - - /** - Rest the datapack and load the variables - */ - ResetPack(pack); - new iClient = ReadPackCell(pack); - new iUnBalancedTeam = ReadPackCell(pack); - - /** - We are done with you now - */ - CloseHandle(pack); - - /** - Check the team and make sure its a valid team - */ - if(!SM_IsValidTeam(iUnBalancedTeam)) - { - if (g_bLogActivity) - { - LogAction(0, iClient, "[STB] Balance failed due to invalid team number %i", iUnBalancedTeam); - } - return Plugin_Handled; - } - - /** - Use our core function to change the clients team - */ - SM_MovePlayer(iClient, iUnBalancedTeam); - - return Plugin_Handled; -} - -public Action:Timer_RoundStart(Handle:timer, any:data) -{ - g_bRoundStart = false; - if (OkToBalance() && IsUnbalanced() && !g_bBalanceInProgress) - { - StartABalance(); - } - return Plugin_Handled; -} - -public Action:Timer_ForcedExpired(Handle:timer, any:iClient) -{ - SM_ClearForcedTeam(iClient); - g_aPlayers[iClient][bSwitched] = false; - g_aPlayers[iClient][hForcedTimer] = INVALID_HANDLE; - return Plugin_Handled; -} - -public Action:Timer_WelcomeAdvert(Handle:timer, any:iClient) -{ - if (IsClientConnected(iClient) && IsClientInGame(iClient)) - { - PrintToChat (iClient, "\x01\x04[STB]\x01 %T", "BuddyWelcomeMsg1", LANG_SERVER); - PrintToChat (iClient, "\x01\x04[STB]\x01 %T", "BuddyWelcomeMsg2", LANG_SERVER); - PrintToChat (iClient, "\x01\x04[STB]\x01 %T", "BuddyWelcomeMsg3", LANG_SERVER); - } - return Plugin_Handled; -} - -/* CONSOLE VARIABLE CHANGE EVENT */ - -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (convar == stb_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsEnabled = false; - PrintToChatAll("[SM] %T", "Disabled", LANG_SERVER); - LogAction(0, -1, "[SimpleTeamBalancer] Disabled"); - } - else - { - g_bIsEnabled = true; - SetGameCvars(); - PrintToChatAll("[SM] %T", "Enabled", LANG_SERVER); - LogAction(0, -1, "[SimpleTeamBalancer] Enabled"); - } - } - else if (convar == stb_logactivity) - { - if (StringToInt(newValue) == 0) - { - g_bLogActivity = false; - LogAction(0, -1, "[STB] Log Activity DISABLED."); - } - else - { - g_bLogActivity = true; - LogAction(0, -1, "[STB] Log Activity ENABLED."); - } - } - else if (convar == stb_logactivity2) - { - if (StringToInt(newValue) == 0) - { - g_bLogActivity2 = false; - LogAction(0, -1, "[STB] Detailed Log Activity DISABLED."); - } - else - { - g_bLogActivity2 = true; - LogAction(0, -1, "[STB] Detailed Log Activity ENABLED."); - } - } - else if (convar == stb_convarcontrol) - { - if (StringToInt(newValue) == 0) - { - g_bConVarControl = false; - } - else - { - g_bConVarControl = true; - SetGameCvars(); - } - } - else if (convar == stb_deadonly) - { - if (StringToInt(newValue) == 0) - { - g_bDeadOnly = false; - } - else - { - g_bDeadOnly = true; - } - } - else if (convar == stb_priorityenabled) - { - if (StringToInt(newValue) == 0) - { - g_bPriorityPlayers = false; - } - else - { - g_bPriorityPlayers = true; - } - } - else if (convar == stb_buddyenabled) - { - if (StringToInt(newValue) == 0) - { - g_bBuddyEnabled = false; - } - else - { - g_bBuddyEnabled = true; - } - } - else if (convar == stb_buddyrestriction) - { - if (StringToInt(newValue) == 0) - { - g_bBuddyRestriction = false; - } - else - { - g_bBuddyRestriction = true; - } - } - else if (convar == stb_unbalancelimit) - { - g_iUnbalanceLimit = StringToInt(newValue); - SetGameCvars(); - } - else if (convar == stb_balancedelay) - { - g_iBalanceDelay = StringToInt(newValue); - } - else if (convar == stb_roundstartdelay) - { - g_iRoundStartDelay = StringToInt(newValue); - } - else if (convar == stb_livingplayerswitchdelay) - { - g_iLivingPlayerSwitchDelay = StringToInt(newValue); - } - else if (convar == stb_livingplayercheckdelay) - { - g_iLivingPlayerCheckDelay = StringToInt(newValue); - } - else if (convar == stb_uberlevel) - { - g_fUberLevel = StringToFloat(newValue); - } - else if (convar == stb_switchbackforced) - { - g_iSwitchBackForced = StringToInt(newValue); - } - else if (convar == stb_adminflag) - { - SetConVarString(stb_adminflag, newValue); - } - else if (convar == stb_mp_autoteambalance) - { - SetGameCvars(); - } - else if (convar == stb_mp_teams_unbalance_limit) - { - SetGameCvars(); - } -} - -/* MENU CODE */ - -stock Handle:BuildPlayerMenu() -{ - new Handle:menu = CreateMenu(Menu_SelectPlayer); - AddTargetsToMenu(menu, 0, true, false); - SetMenuTitle(menu, "Select A Player:"); - SetMenuExitButton(menu, true); - return menu; -} - -public Menu_SelectPlayer(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[24]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - new buddy = GetClientOfUserId(StringToInt(sSelection)); - if (param1 == buddy) { - PrintHintText(param1, "%T", "SelectSelf", LANG_SERVER); - } else if (!IsClientInGame(buddy)) { - PrintHintText(param1, "%T", "BuddyGone", LANG_SERVER); - } else { - decl String:cName[128]; - decl String:bName[128]; - GetClientName(param1, cName, sizeof(cName)); - GetClientName(buddy, bName, sizeof(bName)); - if (!SM_IsBuddyLocked(buddy)) { - SM_AssignBuddy(param1, buddy); - PrintHintText(param1, "%T", "BuddyMsg", LANG_SERVER, bName); - PrintHintText(buddy, "%T", "BuddyMsg", LANG_SERVER, cName); - } else - PrintHintText(param1, "%T", "PlayerLockedBuddyMsg", LANG_SERVER, bName); - } - } else if (action == MenuAction_End) { - CloseHandle(menu); - } -} \ No newline at end of file diff --git a/Simple Plugins Core/addons/sourcemod/scripting/simple-teammanager.sp b/Simple Plugins Core/addons/sourcemod/scripting/simple-teammanager.sp deleted file mode 100644 index 008f443..0000000 --- a/Simple Plugins Core/addons/sourcemod/scripting/simple-teammanager.sp +++ /dev/null @@ -1,1351 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Team Manager -Description: - Manges players and their team - Admin menu integration - Allows admins/donators to swap their teams (clears force)* - Allows admins to move players to a team (forced\unforced)* - Allows admins to scramble the teams* - *Works with Simple Team Balancer (if installed) -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include - -#define PLUGIN_VERSION "2.1.$Rev$" -#define VOTE_YES "##YES##" -#define VOTE_NO "##NO##" - -enum PlayerData -{ - iNewTeam, - bool:bQueue -}; - -new Handle:stm_enabled = INVALID_HANDLE; -new Handle:stm_logactivity = INVALID_HANDLE; -new Handle:stm_adminflag_swapteam = INVALID_HANDLE; -new Handle:stm_adminflag_moveplayer = INVALID_HANDLE; -new Handle:stm_adminflag_scramble = INVALID_HANDLE; -new Handle:stm_scrambledelay = INVALID_HANDLE; -new Handle:stm_voteenabled = INVALID_HANDLE; -new Handle:stm_votewin = INVALID_HANDLE; -new Handle:stm_votedelay = INVALID_HANDLE; -new Handle:stm_mp_bonusroundtime = INVALID_HANDLE; -new Handle:g_hAdminMenu = INVALID_HANDLE; -new Handle:g_hTimerPrepScramble = INVALID_HANDLE; -new Handle:g_hTimerClearScrambleForce = INVALID_HANDLE; - -new g_aPlayers[MAXPLAYERS + 1][PlayerData]; - -new bool:g_bIsEnabled = true; -new bool:g_bVoteEnabled = true; -new bool:g_bLogActivity = true; -new bool:g_bScrambleRoundEnd = false; -new g_iVoteDelay, g_iLastVoteTime, g_iTimeLeft; -new Float:g_fScrambleDelay, Float:g_fVoteWin; - -public Plugin:myinfo = -{ - name = "Simple Team Manager", - author = "Simple Plugins", - description = "Manages players and thier team.", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -}; - -public OnPluginStart() -{ - - /** - Need to create all of our console variables. - */ - CreateConVar("stm_version", PLUGIN_VERSION, "Simple Team Manager Version",FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - stm_enabled = CreateConVar("stm_enabled", "1", "Enable or Disable Simple Team Manager", _, true, 0.0, true, 1.0); - stm_logactivity = CreateConVar("stm_logactivity", "0", "Enable or Disable the disaplying of events in the log", _, true, 0.0, true, 1.0); - stm_adminflag_swapteam = CreateConVar("stm_adminflag_swapteam", "a", "Admin flag to use for the swapteam command. Must be a in char format."); - stm_adminflag_moveplayer = CreateConVar("stm_adminflag_moveplayer", "c", "Admin flag to use for the moveplayer command. Must be a in char format."); - stm_adminflag_scramble = CreateConVar("stm_adminflag_scramble", "c", "Admin flag to use for the scrambleteam command. Must be a in char format."); - stm_scrambledelay = CreateConVar("stm_scrambledelay", "15", "Delay to scramble teams"); - stm_voteenabled = CreateConVar("stm_voteenabled", "1", "Enable or Disable voting to scramble the teams", _, true, 0.0, true, 1.0); - stm_votewin = CreateConVar("stm_votewin", "0.45", "Win percentage vote must win by", _, true, 0.0, true, 1.0); - stm_votedelay = CreateConVar("stm_votedelay", "600", "Delay before another vote can be cast"); - stm_mp_bonusroundtime = FindConVar("mp_bonusroundtime"); - - - /** - Need deal with changes to the console variables after the plugin is loaded. - We could not do this and just call the actual console variable each time we need it, but it's not efficent. - */ - HookConVarChange(stm_enabled, ConVarSettingsChanged); - HookConVarChange(stm_logactivity, ConVarSettingsChanged); - HookConVarChange(stm_scrambledelay, ConVarSettingsChanged); - HookConVarChange(stm_voteenabled, ConVarSettingsChanged); - HookConVarChange(stm_votewin, ConVarSettingsChanged); - HookConVarChange(stm_votedelay, ConVarSettingsChanged); - - /** - Need to register the commands we are going to create and use. - */ - RegConsoleCmd("sm_swapteam", Command_SwapTeam, "sm_swapteam <[0]instant/[1]queued>: Swaps your team to the other team"); - RegConsoleCmd("sm_moveplayer", Command_MovePlayer, "sm_moveplayer <[0]instant/[1]ondeath> <[0]unforced/[1]forced>: Moves a player to the specified team"); - RegConsoleCmd("sm_scrambleteams", Command_ScrambleTeams, "sm_scrambleteams: <[0]now/[1]roundend> <[0]dontrestart/[1]restartround> Scrambles the current teams"); - RegConsoleCmd("sm_votescramble", Command_VoteScramble, "sm_votescramble: Starts a vote to scramble the teams"); - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook the game events - */ - LogAction(0, -1, "[STM] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_death", HookPlayerDeath, EventHookMode_Post); - HookEvent("player_team", HookPlayerChangeTeam, EventHookMode_Post); - switch (g_CurrentMod) - { - case GameType_TF: - { - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - } - case GameType_DOD: - { - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_Post); - } - default: - { - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - } - } - - /** - Now we have to deal with the admin menu. If the admin library is loaded call the function to add our items. - */ - new Handle:gTopMenu; - if (LibraryExists("adminmenu") && ((gTopMenu = GetAdminTopMenu()) != INVALID_HANDLE)) - { - OnAdminMenuReady(gTopMenu); - } - - /** - Load translations and .cfg file - */ - LoadTranslations ("simpleteammanager.phrases"); - AutoExecConfig(true, "plugin.simpleteammanager"); - LogAction(0, -1, "[STM] Simple Team Manager is loaded."); -} - -public OnAllPluginsLoaded() -{ - //something -} - -public OnLibraryRemoved(const String:name[]) -{ - if (StrEqual(name, "adminmenu")) - { - - /** - Looks like the admin menu was removed. Set the global. - */ - g_hAdminMenu = INVALID_HANDLE; - } - else if (StrEqual(name, "simpleplugins")) - { - SetFailState("Required plugin Simple SourceMod Plugins Core was removed."); - } -} - -public OnConfigsExecuted() -{ - - /** - Once we loaded up all the console variables from the config file, lets now set all the global variables we will use. - */ - g_bIsEnabled = GetConVarBool(stm_enabled); - g_bLogActivity = GetConVarBool(stm_logactivity); - g_fScrambleDelay = GetConVarFloat(stm_scrambledelay); - g_iVoteDelay = GetConVarInt(stm_votedelay); - g_fVoteWin = GetConVarFloat(stm_votewin); - g_iLastVoteTime = RoundFloat(GetEngineTime()); - g_bScrambleRoundEnd = false; - g_hTimerClearScrambleForce = INVALID_HANDLE; - - /** - Report enabled - */ - if (g_bIsEnabled) - { - LogAction(0, -1, "[STM] Simple Team Manager is ENABLED."); - } - else - { - LogAction(0, -1, "[STM] Simple Team Manager is DISABLED."); - } - - if (g_bLogActivity) - { - LogAction(0, -1, "[STM] Log Activity ENABLED."); - } - else - { - LogAction(0, -1, "[STM] Log Activity DISABLED."); - } -} - -/* COMMANDS */ - -public Action:Command_SwapTeam(client, args) -{ - - /** - Make sure we are enabled, if not bug out. - */ - if (!g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - If this was ran from the console bug out. - */ - if (client == 0) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "PlayerLevelCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Make sure the client is authorized to run this command. - */ - decl String:sFlags[5]; - GetConVarString(stm_adminflag_swapteam, sFlags, sizeof(sFlags)); - if (!SM_IsValidAdmin(client, sFlags)) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Lets make sure the client is one a team we can swap. - If he is we set the global array to the opposite team. - */ - new iTeam = GetClientTeam(client); - if (iTeam == g_aCurrentTeams[Team1]) - { - g_aPlayers[client][iNewTeam] = g_aCurrentTeams[Team2]; - } - else if (iTeam == g_aCurrentTeams[Team2]) - { - g_aPlayers[client][iNewTeam] = g_aCurrentTeams[Team1]; - } - else - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "InValidTeam", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check to see if we have command arguments. - */ - if (GetCmdArgs()) - { - - /** - We do, so lets get it and see if the client wants to be switched instantly or queued for death. - */ - decl String:sArg[5]; - GetCmdArg(1, sArg, sizeof(sArg)); - new iWantsQue = StringToInt(sArg); - if (iWantsQue && !g_aPlayers[client][bQueue]) - { - - /** - He wants the que and isn't already in it, set the global array. - */ - g_aPlayers[client][bQueue] = true; - ReplyToCommand(client, "\x01\x04[STM]\x01 %T", "PlayerQueue", LANG_SERVER); - } - else if (!iWantsQue) - { - - /** - He wants to be switched right now, lets call the stock function. - */ - SM_MovePlayer(client, g_aPlayers[client][iNewTeam]); - } - } - else - { - - /** - There are no command arguments so we build and display the swap menu. - */ - DisplaySwapModeMenu(client, client); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_MovePlayer(client, args) -{ - - /** - Make sure we are enabled, if not bug out. - */ - if (!g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - Make sure the client is authorized to run this command. - */ - decl String:sFlags[5]; - GetConVarString(stm_adminflag_moveplayer, sFlags, sizeof(sFlags)); - if (!SM_IsValidAdmin(client, sFlags)) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check to see if we have command arguments. - */ - new iCmdArgs = GetCmdArgs(); - if (iCmdArgs == 0) - { - - /** - We don't. Build the player menu, display it, and bug out. - */ - DisplayPlayerMenu(client); - return Plugin_Handled; - } - - /** - Check the first argument - If should be a players name or userid. - */ - decl String:sPlayer[64]; - GetCmdArg(1, sPlayer, sizeof(sPlayer)); - new iPlayerIndex = FindTarget(client, sPlayer, true, true); - if (iPlayerIndex == -1 || !IsClientInGame(iPlayerIndex)) - { - - /** - We don't know who this is. Build the player menu, display it, and bug out. - */ - DisplayPlayerMenu(client); - return Plugin_Handled; - } - - /** - We have figured out the first argument, lets check the second. - If should be the team the client wants to put the player on. - */ - if (iCmdArgs >= 2) - { - - /** - We have a command argument at least, lets see if we can identify the team. - */ - decl String:sTeam[24]; - GetCmdArg(2, sTeam, sizeof(sTeam)); - - new iTeam = StringToInt(sTeam); - if (SM_IsValidTeam(iTeam)) - { - - /** - It's a vaild team so lets set the global array to the new team. - */ - g_aPlayers[iPlayerIndex][iNewTeam] = iTeam; - } - else - { - - /** - It's not a vaild team so set the menu to display to the team menu. - */ - DisplayTeamMenu(client, iPlayerIndex); - return Plugin_Handled; - } - } - else - { - /** - We were not given a team, display the team menu. - */ - DisplayTeamMenu(client, iPlayerIndex); - return Plugin_Handled; - } - - /** - Check to see if we were given any more command arguments and found a team. - */ - if (iCmdArgs < 3) - { - - /** - No more command arguments and found a team. - Now lets check to see if the player is a spectator. If he is there is no reason to ask if it's instant or on death... he can't die. - */ - if (!IsClientObserver(iPlayerIndex)) - { - - /** - Not a spectator so display the swapmode menu. - */ - DisplaySwapModeMenu(client, iPlayerIndex); - } - else - { - - /** - The player is a spectator. - We make sure the player is not set to switch on death, since a spec can't die. - */ - g_aPlayers[iPlayerIndex][bQueue] = false; - } - } - - /** - We have figured out the second argument, lets check the third. - If should be the how the client wants to move the player: instant/on death. - */ - if (iCmdArgs >= 3) - { - - /** - The client gave us a command argument, lets check it. - */ - decl String:sSwapMode[5]; - GetCmdArg(3, sSwapMode, sizeof(sSwapMode)); - new iWantsQue = StringToInt(sSwapMode); - if (iWantsQue) - { - - /** - The client wants to que the player, set the global array. - */ - g_aPlayers[iPlayerIndex][bQueue] = true; - } - else - { - - /** - The client doesn't want to que the player, set the global array. - */ - g_aPlayers[iPlayerIndex][bQueue] = false; - } - } - else - { - /** - No swapmode argument, display the menu - */ - DisplaySwapModeMenu(client, iPlayerIndex); - } - - if (iCmdArgs >= 4) - { - - /** - Since we are compiling for Simple Team Balancer, and given a 4th argument, lets check it. - If should be the if the client wants to force the player to that team. - */ - decl String:sPlayerForced[5]; - GetCmdArg(4, sPlayerForced, sizeof(sPlayerForced)); - new iForceHim = StringToInt(sPlayerForced); - if (iForceHim) - { - - /** - The client wants to force the player - */ - SM_SetForcedTeam(iPlayerIndex, g_aPlayers[iPlayerIndex][iNewTeam]); - } - else - { - - /** - The client doesn't want to force the player - */ - SM_ClearForcedTeam(iPlayerIndex); - } - } - else - { - - } - - /** - We found and processed all the arguments. - */ - if (!IsPlayerAlive(iPlayerIndex)) - { - - /** - The player is not alive or died during this process so we just move him. - */ - SM_MovePlayer(iPlayerIndex, g_aPlayers[iPlayerIndex][iNewTeam]); - } - else - { - if (!g_aPlayers[iPlayerIndex][bQueue]) - { - - /** - The player is alive and is not set to be queued so we just move him. - */ - SM_MovePlayer(iPlayerIndex, g_aPlayers[iPlayerIndex][iNewTeam]); - } - } - - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_ScrambleTeams(client, args) -{ - - /** - Make sure we are enabled, if not bug out. - */ - if (!g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - Make sure the client is authorized to run this command. - */ - decl String:sFlags[5]; - GetConVarString(stm_adminflag_scramble, sFlags, sizeof(sFlags)); - if (!SM_IsValidAdmin(client, sFlags)) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check if a scramble timer was already called, if so close it down. - */ - if (g_hTimerPrepScramble != INVALID_HANDLE) - { - CloseHandle(g_hTimerPrepScramble); - g_hTimerPrepScramble = INVALID_HANDLE; - } - - /** - Check if we have any command arguments. - If we don't we display the scramble menu and bug out. - */ - new iCmdArgs = GetCmdArgs(); - if (iCmdArgs == 0) - { - DisplayScrambleMenu(client); - return Plugin_Handled; - } - - /** - We have a command argument. - It should be whether or not to scramble at round end. - */ - decl String:sRoundEnd[5]; - GetCmdArg(1, sRoundEnd, sizeof(sRoundEnd)); - if (StringToInt(sRoundEnd)) - { - /** - The client wants to scramble at round end so we set the global bool. - */ - g_bScrambleRoundEnd = true; - } - else - { - g_bScrambleRoundEnd = false; - } - - /** - Check for another command argument. - It should be whether or not to restart the round. - */ - decl String:sRestartRound[5]; - new bool:bRestartRound = false; - GetCmdArg(1, sRestartRound, sizeof(sRestartRound)); - if (StringToInt(sRestartRound)) - { - bRestartRound = true; - } - - /** - Now we start the scramble timer. - */ - StartScrambleTimer(_, bRestartRound); - - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_VoteScramble(client, args) -{ - - /** - Make sure we are enabled, if not bug out. - */ - if (!g_bVoteEnabled || !g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - Make sure there is a vote in progress, if so bug out. - */ - if (IsVoteInProgress()) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "VoteInProgress", LANG_SERVER); - return Plugin_Handled; - } - - /** - Make sure enough time has passed since the last vote. - */ - new iVoteTime = RoundFloat(GetEngineTime()); - if (iVoteTime - g_iLastVoteTime <= g_iVoteDelay) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "ScrambleTime", LANG_SERVER); - return Plugin_Handled; - } - - /** - Enough time has passed so reset the global vote time to now. - */ - g_iLastVoteTime = iVoteTime; - - /** - Build the vote menu and send it to everyone. - */ - new Handle:hMenu = CreateMenu(Menu_VoteScramble); - SetMenuTitle(hMenu, "Scramble Teams?"); - AddMenuItem(hMenu, VOTE_YES, "Yes"); - AddMenuItem(hMenu, VOTE_NO, "No"); - SetMenuExitButton(hMenu, false); - VoteMenuToAll(hMenu, 20); - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -/* HOOKED EVENTS */ - -public HookPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Find out who died. - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - - /** - Find out how the client died. - */ - new String:sWeapon[64]; - GetEventString(event, "weapon", sWeapon, sizeof(sWeapon)); - if (StrEqual(sWeapon, "world", false)) - { - - /** - He died because he changed teams so cleanup and bug out. - */ - s_CleanUp(iClient); - return; - } - - /** - Find out if this player was queued to change teams. - */ - if (g_aPlayers[iClient][bQueue]) - { - /** - Looks like he was, so call the stock function to move him. - */ - SM_MovePlayer(iClient, g_aPlayers[iClient][iNewTeam]); - } -} - -public HookPlayerChangeTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Find out who changed teams. - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - - /** - If he was queued to switch teams we cleanup the variables. The client did it themself. - */ - if (g_aPlayers[iClient][bQueue]) - { - s_CleanUp(iClient); - } -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get the amount of time left in the map. - */ - new iTimeLeft; - GetMapTimeLeft(iTimeLeft); - - /** - Check to see if we are supposed to scramble at the end of the round and that there is enough time left in the map. - */ - if (g_bScrambleRoundEnd && iTimeLeft >= 60) - { - - /** - Check to see if there is a scramble timer in action and if so close it down. - */ - if (g_hTimerPrepScramble != INVALID_HANDLE) - { - CloseHandle(g_hTimerPrepScramble); - g_hTimerPrepScramble = INVALID_HANDLE; - } - - /** - Determine the round end chat time and run the scramble 1 second before it ends. - */ - new Float:fDelay = GetConVarFloat(stm_mp_bonusroundtime); - fDelay -= 1.0; - StartScrambleTimer(fDelay); - } -} - -public OnClientPostAdminCheck(client) -{ - - /** - Determine if the client has the flag to use the swapteam command. - */ - decl String:sFlags[5]; - GetConVarString(stm_adminflag_swapteam, sFlags, sizeof(sFlags)); - if (SM_IsValidAdmin(client, sFlags)) - { - /** - The client does so lets create a timer to run an advertise to tell him about it. - */ - CreateTimer (60.0, Timer_WelcomeAdvert, client); - } -} - -public OnClientDisconnect(client) -{ - - /** - Cleanup the clients variables. - */ - s_CleanUp(client); -} - -public SM_OnPlayerMoved(Handle:plugin, client, team) -{ - - /** - Make sure we called the move function - */ - if (plugin != GetMyHandle()) - { - if (g_bLogActivity) - { - LogAction(0, client, "[STM] Callback was not started with current plugin, bugging out."); - } - return; - } - - decl String:sPlayerName[64]; - GetClientName(client, sPlayerName, sizeof(sPlayerName)); - - PrintToChat(client, "\x01\x04[SM]\x01 %T", "PlayerSwitched", LANG_SERVER); - - s_CleanUp(client); -} - -/* TIMER FUNCTIONS */ - -public Action:Timer_PrepTeamScramble(Handle:timer, any:data) -{ - new bool:bRestartRound = data; - /** - Call the scramble the teams stock function. - */ - PrepTeamScramble(bRestartRound); - - /** - Reset the timer handle so we know the timer is done. - */ - g_hTimerPrepScramble = INVALID_HANDLE; - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Timer_ScrambleTheTeams(Handle:timer, any:data) -{ - new iPlayers[MAXPLAYERS + 1]; - new iCount, i, bool:bTeam, bool:bRestartRound = data; - - /** - Get all the client index numbers of valid players - */ - for(i = 1; i <= MaxClients; i++) - { - if(IsClientInGame(i)) // && !IsFakeClient(i)) - { - iPlayers[iCount++] = i; - } - } - - /** - Randomly sort the players - */ - SortIntegers(iPlayers, iCount, Sort_Random); - - /** - Loop through all the players and assign each one to a team, alternating each time - */ - for(i = 0; i < iCount; i++) - { - if (!bRestartRound) - { - /** - We didn't want to restart the round, so we move them to spec 1 at a time. - */ - SM_MovePlayer(iPlayers[i], g_aCurrentTeams[Spectator]); - } - SM_MovePlayer(iPlayers[i], bTeam ? g_aCurrentTeams[Team2] : g_aCurrentTeams[Team1]); - SM_SetForcedTeam(iPlayers[i], bTeam ? g_aCurrentTeams[Team2] : g_aCurrentTeams[Team1], true); - bTeam = !bTeam; - } - - /** - Reset this variable since we completed a scramble - */ - g_bScrambleRoundEnd = false; - - if (g_hTimerClearScrambleForce != INVALID_HANDLE) - { - CloseHandle(g_hTimerClearScrambleForce); - g_hTimerClearScrambleForce = INVALID_HANDLE; - } - - g_hTimerClearScrambleForce = CreateTimer(300.0, Timer_ClearScrambleForce, _, TIMER_FLAG_NO_MAPCHANGE); - - ServerCommand("mp_timelimit %i", g_iTimeLeft / 60); - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Timer_ClearScrambleForce(Handle:timer, any:data) -{ - - for(new i = 1; i <= MaxClients; i++) - { - if(IsClientInGame(i)) // && !IsFakeClient(i)) - { - SM_ClearForcedTeam(i); - PrintToChat(i, "\x01\x04[SM]\x01 Your forced team status has been cleared"); - } - } - - g_hTimerClearScrambleForce = INVALID_HANDLE; - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Timer_WelcomeAdvert(Handle:timer, any:client) -{ - - /** - Lets make sure the client is connected and actually in the game. - */ - if (IsClientConnected(client) && IsClientInGame(client)) - { - - /** - We are good to go so lets tell him about the swapteam command. - */ - PrintToChat (client, "\x01\x04[STM]\x01 %T", "SwapTeamMsg", LANG_SERVER); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -/* STOCK FUNCTIONS */ - -stock s_CleanUp(iClient) -{ - - /** - Reset all the client variables - */ - g_aPlayers[iClient][bQueue] = false; - g_aPlayers[iClient][iNewTeam] = 0; -} - -stock StartScrambleTimer(Float:fdelay = 0.0, bool:bRestartRound = false) -{ - if (fdelay == 0.0) - { - fdelay = g_fScrambleDelay; - } - if (g_hTimerPrepScramble != INVALID_HANDLE) - { - CloseHandle(g_hTimerPrepScramble); - g_hTimerPrepScramble = INVALID_HANDLE; - } - PrintCenterTextAll("%T", "Scramble", LANG_SERVER); - g_hTimerPrepScramble = CreateTimer(fdelay, Timer_PrepTeamScramble, bRestartRound, TIMER_FLAG_NO_MAPCHANGE); -} - -stock PrepTeamScramble(bool:bRestartRound = false) -{ - new iPlayers[MAXPLAYERS + 1]; - new iCount; - - GetMapTimeLeft(g_iTimeLeft); - - if (bRestartRound) - { - - for(new i = 1; i <= MaxClients; i++) - { - if(IsClientInGame(i)) - // && !IsFakeClient(i)) - { - iPlayers[iCount++] = i; - SM_ClearForcedTeam(i); - SM_ClearBuddy(i); - SM_MovePlayer(i, g_aCurrentTeams[Spectator]); - } - } - } - else - { - //Can't move them all to spec at the same time - for(new i = 1; i <= MaxClients; i++) - { - if(IsClientInGame(i)) - // && !IsFakeClient(i)) - { - iPlayers[iCount++] = i; - SM_ClearForcedTeam(i); - SM_ClearBuddy(i); - //SM_MovePlayer(i, g_aCurrentTeams[Spectator]); - } - } - } - CreateTimer(4.0, Timer_ScrambleTheTeams, bRestartRound, TIMER_FLAG_NO_MAPCHANGE); -} - -/* CONSOLE VARIABLE CHANGE EVENT */ - -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (convar == stm_enabled) { - if (StringToInt(newValue) == 0) { - g_bIsEnabled = false; - LogAction(0, -1, "[STM] Simple Team Manager is loaded and disabled."); - } else { - g_bIsEnabled = true; - LogAction(0, -1, "[STM] Simple Team Manager is loaded and enabled."); - } - } - else if (convar == stm_logactivity) { - if (StringToInt(newValue) == 0) { - g_bLogActivity = false; - LogAction(0, -1, "[STM] Log Activity DISABLED."); - } else { - g_bLogActivity = true; - LogAction(0, -1, "[STM] Log Activity ENABLED."); - } - } - else if (convar == stm_scrambledelay) - g_fScrambleDelay = StringToFloat(newValue); - else if (convar == stm_votewin) - g_fVoteWin = StringToFloat(newValue); - else if (convar == stm_votedelay) - g_iVoteDelay = StringToInt(newValue); - else if (convar == stm_voteenabled) { - if (StringToInt(newValue) == 0) - g_bVoteEnabled = false; - else - g_bVoteEnabled = true; - } -} - -/* MENU CODE */ - -public OnAdminMenuReady(Handle:topmenu) -{ - if (topmenu == g_hAdminMenu) - return; - g_hAdminMenu = topmenu; - new TopMenuObject:player_commands = FindTopMenuCategory(g_hAdminMenu, ADMINMENU_PLAYERCOMMANDS); - new TopMenuObject:server_commands = FindTopMenuCategory(g_hAdminMenu, ADMINMENU_SERVERCOMMANDS); - if (player_commands == INVALID_TOPMENUOBJECT) - return; - - AddToTopMenu(g_hAdminMenu, - "moveplayer", - TopMenuObject_Item, - AdminMenu_MovePlayer, - player_commands, - "moveplayer", - ADMFLAG_BAN); - - AddToTopMenu(g_hAdminMenu, - "scrambleteams", - TopMenuObject_Item, - AdminMenu_Scrambleteams, - server_commands, - "scrambleteams", - ADMFLAG_BAN); -} - -public AdminMenu_MovePlayer(Handle:topmenu, TopMenuAction:action, TopMenuObject:object_id, param, String:buffer[], maxlength) -{ - if (action == TopMenuAction_DisplayOption) - Format(buffer, maxlength, "Move Player"); - else if (action == TopMenuAction_SelectOption){ - DisplayPlayerMenu(param); - } -} - -public AdminMenu_Scrambleteams(Handle:topmenu, TopMenuAction:action, TopMenuObject:object_id, param, String:buffer[], maxlength) -{ - if (action == TopMenuAction_DisplayOption) - Format(buffer, maxlength, "Scramble Teams"); - else if (action == TopMenuAction_SelectOption) { - DisplayScrambleMenu(param); - } -} - -public Menu_SelectPlayer(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - DisplayTeamMenu(param1, GetClientOfUserId(StringToInt(sSelection))); - } else if (action == MenuAction_Cancel) { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -public Menu_SelectTeam(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new iTeam; - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - decl String:sIndex[64]; - if (SplitString(sSelection, "A", sIndex, sizeof(sIndex)) != -1) - iTeam = g_aCurrentTeams[Team1]; - else if (SplitString(sSelection, "B", sIndex, sizeof(sIndex)) != -1) - iTeam = g_aCurrentTeams[Team2]; - else { - SplitString(sSelection, "C", sIndex, sizeof(sIndex)); - iTeam = g_aCurrentTeams[Spectator]; - } - new iTarget = StringToInt(sIndex); - g_aPlayers[iTarget][iNewTeam] = iTeam; - DisplaySwapModeMenu(param1, iTarget); - } else if (action == MenuAction_Cancel) { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -public Menu_SwapMode(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - decl String:sIndex[64]; - - if (SplitString(sSelection, "A", sIndex, sizeof(sIndex)) == -1) - { - SplitString(sSelection, "B", sIndex, sizeof(sIndex)); - } - - new iTarget = StringToInt(sIndex); - - if (StrContains(sSelection, "A", true) != -1) - { - g_aPlayers[iTarget][bQueue] = false; - } - else if (StrContains(sSelection, "B", true) != -1) - { - g_aPlayers[iTarget][bQueue] = true; - } - - if (param1 == iTarget && !g_aPlayers[iTarget][bQueue]) - { - SM_MovePlayer(iTarget, g_aPlayers[iTarget][iNewTeam]); - } - else - { - DisplayForceModeMenu(param1, iTarget); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - { - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } - return; -} - -public Menu_ForceMode(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - decl String:sIndex[64]; - if (SplitString(sSelection, "A", sIndex, sizeof(sIndex)) == -1) - { - SplitString(sSelection, "B", sIndex, sizeof(sIndex)); - } - new iTarget = StringToInt(sIndex); - if (StrContains(sSelection, "A", true) != -1) - { - SM_ClearForcedTeam(iTarget); - } - else if (StrContains(sSelection, "B", true) != -1) - { - SM_SetForcedTeam(iTarget, g_aPlayers[iTarget][iNewTeam], true); - } - if (!g_aPlayers[iTarget][bQueue]) - { - SM_MovePlayer(iTarget, g_aPlayers[iTarget][iNewTeam]); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - { - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } - return; -} - -public Menu_VoteScramble(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_VoteEnd) { - new winning_votes, total_votes; - GetMenuVoteInfo(param2, winning_votes, total_votes); - if (param1 == 0) { - if (float(total_votes) / float(winning_votes) < g_fVoteWin) { - PrintToChatAll("\x01\x04[SM]\x01 %T", "VoteScramble2", LANG_SERVER, winning_votes, total_votes); - return; - } - PrintCenterTextAll("[SM] %T", "Scramble", LANG_SERVER); - PrintToChatAll("\x01\x04[SM]\x01 %T", "VoteScramble1", LANG_SERVER, winning_votes, total_votes); - StartScrambleTimer(); - } - if (param1 == 1) { - PrintToChatAll("\x01\x04[SM]\x01 %T", "VoteScramble2", LANG_SERVER, winning_votes, total_votes); - } - } - if (action == MenuAction_End) - CloseHandle(menu); -} - -public Menu_ScrambleTeams(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "NOW", false)) - g_bScrambleRoundEnd = false; - else - g_bScrambleRoundEnd = true; - DisplayScrambleMenu2(param1); - } else if (action == MenuAction_Cancel) { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -public Menu_ScrambleTeams2(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[64]; - new bool:bRestartRound; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "NO", false)) - { - bRestartRound = false; - } - else - { - bRestartRound = true; - } - StartScrambleTimer(_, bRestartRound); - } else if (action == MenuAction_Cancel) { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -stock DisplayScrambleMenu(iClient) -{ - new Handle:hMenu = CreateMenu(Menu_ScrambleTeams); - SetMenuTitle(hMenu, "Select When to Scramble:"); - AddMenuItem(hMenu, "NOW", "Instantly"); - AddMenuItem(hMenu, "END", "At Round End"); - SetMenuExitBackButton(hMenu, false); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} - -stock DisplayScrambleMenu2(iClient) -{ - new Handle:hMenu = CreateMenu(Menu_ScrambleTeams2); - SetMenuTitle(hMenu, "Select When to Scramble:"); - AddMenuItem(hMenu, "NO", "No Round Restart"); - AddMenuItem(hMenu, "YES", "Restart Round"); - SetMenuExitBackButton(hMenu, false); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} - -stock DisplaySwapModeMenu(iClient, iTarget) -{ - new Handle:hMenu = CreateMenu(Menu_SwapMode); - decl String:optionA[64]; - decl String:optionB[64]; - Format(optionA, sizeof(optionA), "%iA", iTarget); - Format(optionB, sizeof(optionB), "%iB", iTarget); - SetMenuTitle(hMenu, "Select When to Swap:"); - AddMenuItem(hMenu, optionA, "Instantly (Kills)"); - if (!IsClientObserver(iTarget)) - AddMenuItem(hMenu, optionB, "Queue on next death"); - SetMenuExitBackButton(hMenu, false); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} - -stock DisplayForceModeMenu(iClient, iTarget) -{ - new Handle:hMenu = CreateMenu(Menu_ForceMode); - decl String:optionA[64]; - decl String:optionB[64]; - Format(optionA, sizeof(optionA), "%iA", iTarget); - Format(optionB, sizeof(optionB), "%iB", iTarget); - SetMenuTitle(hMenu, "Select Force Mode:"); - AddMenuItem(hMenu, optionA, "UnForced"); - AddMenuItem(hMenu, optionB, "Forced"); - SetMenuExitBackButton(hMenu, false); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} - -stock DisplayTeamMenu(iClient, iTarget) -{ - new Handle:hMenu = CreateMenu(Menu_SelectTeam); - decl String:optionA[64]; - decl String:optionB[64]; - decl String:optionC[64]; - Format(optionA, sizeof(optionA), "%iA", iTarget); - Format(optionB, sizeof(optionB), "%iB", iTarget); - Format(optionC, sizeof(optionC), "%iC", iTarget); - SetMenuTitle(hMenu, "Select Team:"); - AddMenuItem(hMenu, optionA, "Team One"); - AddMenuItem(hMenu, optionB, "Team Two"); - AddMenuItem(hMenu, optionC, "Spectator"); - SetMenuExitBackButton(hMenu, false); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} - -stock DisplayPlayerMenu(iClient) -{ - new Handle:hMenu = CreateMenu(Menu_SelectPlayer); - AddTargetsToMenu(hMenu, 0, true, false); - SetMenuTitle(hMenu, "Select A Player:"); - SetMenuExitBackButton(hMenu, true); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} diff --git a/Simple Plugins Core/addons/sourcemod/translations/simpledonatorbenefits.phrases.txt b/Simple Plugins Core/addons/sourcemod/translations/simpledonatorbenefits.phrases.txt deleted file mode 100644 index 3826846..0000000 --- a/Simple Plugins Core/addons/sourcemod/translations/simpledonatorbenefits.phrases.txt +++ /dev/null @@ -1,62 +0,0 @@ -"Phrases" -{ - "PlayerLevelCmd" - { - "en" "Command must be run at the player level" - "fr" "Cette commande doit être tapée en jeu" - "hu" "Ezt a parancsot jatekosi szinten kell futtatni!" - } - "RestrictedCmd" - { - "en" "You must be a donator or admin to run this command" - "fr" "Vous devez être un donateur ou un admin pour lancer cette commande" - "hu" "A parancs futtatasahoz admin, vagy tamogatoi szint szukseges!" - } - "InValidTeam" - { - "en" "You must be on red or blue to swap teams" - "fr" "Vous devez être RED ou BLU pour changer d'équipe" - "hu" "Jatekban kell lenned, hogy megcsereld a csapatokat!" - } - "PlayerQueue" - { - "en" "You have been queued to swap teams on next death" - "fr" "Vous avez été mis en attente pour changer d'équipe lors de votre prochaine mort" - "hu" "A kovetkezo halalnal csapatcsere lesz" - } - "PlayerSwitched" - { - "en" "Your team has been switched as requested" - "fr" "Vous avez changé d'équipe comme demandé" - "hu" "A keresnek eleget teve a csapatod meg lett csererlve" - } - "SwapTeamMsg" - { - "en" "Type /swapteam or !swapteam to swap your team!" - } - "ReachedCount" - { - "en" "You have reached your health limit. You must die before you can use it again" - } - "AtMaxHealth" - { - "en" "You are already at your maximum health!" - } - "ToMaxHealth" - { - "en" "Instant health bonus applied! You are not at your maximun health!" - } - "HealthBonus" - { - "en" "Instant health bonus applied!" - } - "PublicJoinMessage" - { - "#format" "{1:s}" - "en" "{1} a [donator] as joined the server" - } - "PrivateJoinMessage" - { - "en" "Thanks for donating!" - } -} \ No newline at end of file diff --git a/Simple Plugins Core/addons/sourcemod/translations/simplespectate.phrases.txt b/Simple Plugins Core/addons/sourcemod/translations/simplespectate.phrases.txt deleted file mode 100644 index 2d1a096..0000000 --- a/Simple Plugins Core/addons/sourcemod/translations/simplespectate.phrases.txt +++ /dev/null @@ -1,42 +0,0 @@ -"Phrases" -{ - "Stopped spectating" - { - "#format" "{1:s}" - "en" "Stopped tracking player: {1}" - } - "Yourself" - { - "en" "You can't spectate yourself" - } - "Spectator" - { - "en" "You can't spectate another spectator" - } - "Spectating" - { - "#format" "{1:s}" - "en" "Now spectating {1}. Type !stopspec or /stopspec to stop spectating this player" - } - "Invalid Target" - { - "en" "Invalid target" - } - "Cant Target" - { - "en" "Can't target this player" - } - "Must Have Target" - { - "en" "You must be following/tracking a player to punish" - } - "Target Left" - { - "en" "The player you were following/tracking has left" - } - "Punished" - { - "#format" "{1:s}{2:s}{3:s}" - "en" "{1} was punished with a {2} for {3}" - } -} \ No newline at end of file diff --git a/Simple Plugins Core/addons/sourcemod/translations/simpleteambalancer.phrases.txt b/Simple Plugins Core/addons/sourcemod/translations/simpleteambalancer.phrases.txt deleted file mode 100644 index 03595fd..0000000 --- a/Simple Plugins Core/addons/sourcemod/translations/simpleteambalancer.phrases.txt +++ /dev/null @@ -1,130 +0,0 @@ -"Phrases" -{ - "UnBalanced" - { - "en" "Teams are unbalanced and will be balanced shortly" - "fr" "Les équipes ne sont pas équilibrées et le seront bientôt" - "de" "Die Teams sind ungleich und werden in Kürze ausgeglichen" - "hu" "A csapatok nem kiegyenlitettek! Egyensuly beallitas kovetkezik!" - } - "Enabled" - { - "en" "Simple Team Balancer is ENABLED" - "fr" "Simple Team Balancer est ACTIVE" - "de" "Simple Team Balancer ist AKTIV" - "hu" "Az Egyszeru Csapat Egyensulytarto AKTIV!" - } - "Disabled" - { - "en" "Simple Team Balancer is DISABLED" - "fr" "Simple Team Balancer est DESACTIVE" - "de" "Simple Team Balancer ist INAKTIV" - "hu" "Az Egyszeru Csapat Egyensulytarto INAKTIV!" - } - "PlayerMessage" - { - "#format" "{1:i}" - "en" "You are going to be auto balanced in {1} seconds unless a dead player can be found" - "fr" "Vous passerez dans l'autre équipe dans {1} secondes si aucun joueur mort ne peut être trouvé dans cet intervalle" - "de" "Du wirst in {1} Sekunden zum automatischen Ausgleich herangezogen wenn kein toter Spieler gefunden werden kann" - "hu" "{1} masodpercen belul at leszel helyezve a masik csapatba, hacsak nem lesz addig egy halott jatekos!" - } - "BalanceMessage" - { - "#format" "{1:s}" - "en" "{1} was moved to the other team for game balance" - "fr" "{1} est passé dans l'autre équipe pour équilibrer la partie" - "de" "{1} wurde zum anderen Team verschoben um das Spiel auszugleichen" - "hu" "{1} at lett helyezve az egyensuly megtartasa erdekeben." - } - "PlayerLevelCmd" - { - "en" "Command must be run at the player level" - "fr" "La commande doit être lancée au niveau du joueur" - "de" "Das Kommando muss auf Spieler Ebene ausgeführt werden" - "hu" "Jatekosi szinten kell futtatni ezt a parancsot!" - } - "CmdDisabled" - { - "en" "Command is currently disabled" - "fr" "La commande est actuellement désactivée" - "de" "Das Kommando ist momentan inaktiv" - "hu" "A parancs jelenleg inaktiv" - } - "RestrictedBuddy" - { - "en" "You must be a donator or admin to add a balance buddy" - "fr" "Vous devez être un donateur ou un admin pour choisir un partenaire" - "de" "Du musst ein Spender oder Admin sein um einen Partner wählen zu können" - "hu" "Tamogato vagy admin kell hogy legyel, hogy 'Tarsat' jelolhess meg" - } - "SelectSelf" - { - "en" "You cannot be your own buddy" - "fr" "Vous ne pouvez pas être votre propre partenaire" - "de" "Du kannst nicht dein eigener Partner sein" - "hu" "Nem valaszthatod ki onmagad!" - } - "BuddyGone" - { - "en" "Your selected buddy has disconnected" - "fr" "Le partenaire que vous avez sélectionné s'est déconnecté" - "de" "Dein gewählter Partner hat die Verbindung getrennt" - "hu" "A valasztott 'Tarsad' kilepett" - } - "BuddyMsg" - { - "#format" "{1:s}" - "en" "You and {1} are now buddies" - "fr" "Vous et {1} êtes maintenant partenaires" - "de" "Du und {1} seid jetzt Partner" - "hu" "{1} es Te 'Tarsak' vagytok." - } - "BuddyLockMsgDisabled" - { - "en" "You can now be anyone's buddy" - "fr" "Vous pouvez à présent être le partenaire de n'importe qui" - "de" "Du kannst jetzt jedermanns Partner sein" - "hu" "Barkinek lehetsz a 'Tarsa'." - } - "BuddyLockMsgEnabled" - { - "en" "Buddy selection locked. Only you can change your buddy" - "fr" "Sélection de partenaire bloquée. Vous êtes le seul à pouvoir choisir votre partenaire" - "de" "Wahl des Partners gesperrt. Nur du kannst deinen Partner wechseln" - "hu" "Tars-lista lezarva. Csak Te tudod modositani a Tars-listadat." - } - "PlayerLockedBuddyMsg" - { - "#format" "{1:s}" - "en" "{1} has locked his buddy selection. Try again" - "fr" "{1} a bloqué sa sélection de partenaire. Essayez de nouveau." - "de" "{1} hat seine Wahl des Partners gesperrt. Versuche es erneut" - "hu" "{1} lezarta a Tars-listajat. Probald kesobb!" - } - "BuddyWelcomeMsg1" - { - "en" "Select a balance buddy and stay together during an autobalance!" - "fr" "Choisissez un partenaire et restez ensemble durant l'équilibrage automatique!" - "de" "Wähle einen Partner und bleibt zusammen während eines Ausgleichs" - "hu" "Valasz ki egy 'Tarsat' akivel egyuttmaradhatsz a csapatkiegyenlites alatt!" - } - "BuddyWelcomeMsg2" - { - "en" "/buddy or !buddy to select a balance buddy" - "fr" "/buddy or !buddy pour choisir un partenaire" - "de" "/buddy oder !buddy um einen Partner zu wählen" - "hu" "Hasznald a /buddy vagy !buddy parancsokat a 'Tars' kijelolesehez" - } - "BuddyWelcomeMsg3" - { - "en" "/lockbuddy or !lockbuddy to lock your selection" - "fr" "/lockbuddy or !lockbuddy pour bloquer votre sélection" - "de" "/lockbuddy oder !lockbuddy um deine Auswahl zu sperren" - "hu" "Hasznald a /lockbuddy vagy a !lockbuddy parancsokat a Tars-listad lezarasahoz" - } -} - - - - diff --git a/Simple Plugins Core/addons/sourcemod/translations/simpleteammanager.phrases.txt b/Simple Plugins Core/addons/sourcemod/translations/simpleteammanager.phrases.txt deleted file mode 100644 index f2093a7..0000000 --- a/Simple Plugins Core/addons/sourcemod/translations/simpleteammanager.phrases.txt +++ /dev/null @@ -1,92 +0,0 @@ -"Phrases" -{ - "PlayerLevelCmd" - { - "en" "Command must be run at the player level" - "fr" "Cette commande doit être tapée en jeu" - "hu" "Ezt a parancsot jatekosi szinten kell futtatni!" - } - "RestrictedCmd" - { - "en" "You must be a donator or admin to run this command" - "fr" "Vous devez être un donateur ou un admin pour lancer cette commande" - "hu" "A parancs futtatasahoz admin, vagy tamogatoi szint szukseges!" - } - "InValidTeam" - { - "en" "You must be on red or blue to swap teams" - "fr" "Vous devez être RED ou BLU pour changer d'équipe" - "hu" "Jatekban kell lenned, hogy megcsereld a csapatokat!" - } - "PlayerInValidTeam" - { - "en" "Player must be on red or blue to swap teams" - "fr" "Le joueur doit être RED ou BLU pour changer d'équipe" - "hu" "Valamelyik csapatban kell lenni, hogy csere legyen" - } - "PlayerQueue" - { - "en" "You have been queued to swap teams on next death" - "fr" "Vous avez été mis en attente pour changer d'équipe lors de votre prochaine mort" - "hu" "A kovetkezo halalnal csapatcsere lesz" - } - "PlayerSwitched" - { - "en" "Your team has been switched" - } - "PlayerSwitched1" - { - "en" "Your team has been switched as requested" - "fr" "Vous avez changé d'équipe comme demandé" - "hu" "A keresnek eleget teve a csapatod meg lett csererlve" - } - "PlayerSwitched2" - { - "en" "Your team has been switched by an Admin" - "fr" "Vous avez été changé d'équipe par un admin" - "hu" "Az Admin megcserelte a csapatodat!" - } - "SwapTeamMsg" - { - "en" "Type /swapteam or !swapteam to swap your team!" - } - "PlayerSwitched3" - { - "#format" "{1:s}" - "en" "{1}'s team has been switched" - "fr" "{1} a changé d'équipe" - "hu" "{1} csapata meg lett cserelve" - } - "Scramble" - { - "en" "Teams are about to be scrambled!" - "fr" "Les équipes vont être rééquilibrés" - "hu" "A csapatok hamarosan meg lesznek keverve!" - } - "VoteScramble1" - { - "#format" "{1:i}{2:i}" - "en" "Vote Scramble successful with {1} votes out of {2}" - "fr" "Le vote d'équilibrage des équipes a réussi avec {1} votes pour sur {2}" - "hu" "A szavazas sikeres volt, {1} szavazat a keveresre a {2} -bol" - } - "VoteScramble2" - { - "#format" "{1:i}{2:i}" - "en" "Vote Scramble failed with {1} votes out of {2}" - "fr" "Le vote d'équilibrage a échoué avec {1} votes pour sur {2}" - "hu" "A szavazas sikertelen volt, {1} szavazat a keveresre a {2} -bol" - } - "VoteInProgress" - { - "en" "A vote is currently in progress" - "fr" "Un vote est actuellement en cours" - "hu" "Egy szavazas mar fut!" - } - "ScrambleTime" - { - "en" "A vote was recently made, please wait" - "fr" "Un vote a déjà été fait récemment, réessayez plus tard" - "hu" "Nemreg volt szavazas, kerlek varj egy kicsit!" - } -} \ No newline at end of file diff --git a/Simple Round Immunity/addons/sourcemod/configs/simple-alltalkmanager_events.cfg b/Simple Round Immunity/addons/sourcemod/configs/simple-alltalkmanager_events.cfg deleted file mode 100644 index b739cf0..0000000 --- a/Simple Round Immunity/addons/sourcemod/configs/simple-alltalkmanager_events.cfg +++ /dev/null @@ -1,43 +0,0 @@ -"game_events" -{ - "teamplay_round_start" - { - "reason" "Round Start" - "setting" "1" - } - "teamplay_setup_finished" - { - "reason" "Setup Period Ended" - "setting" "0" - } - "teamplay_overtime_begin" - { - "reason" "Overtime Began" - "setting" "1" - } - "teamplay_overtime_end" - { - "reason" "Overtime Ended" - "setting" "1" - } - "teamplay_round_win" - { - "reason" "Round Ended" - "setting" "1" - } - "teamplay_suddendeath_begin" - { - "reason" "Sudden Death Began" - "setting" "1" - } - "teamplay_suddendeath_end" - { - "reason" "Sudden Death Ended" - "setting" "1" - } - "teamplay_round_stalemate" - { - "reason" "Stalemate" - "setting" "1" - } -} \ No newline at end of file diff --git a/Simple Round Immunity/addons/sourcemod/configs/simple-chatcolors.cfg b/Simple Round Immunity/addons/sourcemod/configs/simple-chatcolors.cfg deleted file mode 100644 index 14b98c6..0000000 --- a/Simple Round Immunity/addons/sourcemod/configs/simple-chatcolors.cfg +++ /dev/null @@ -1,15 +0,0 @@ -"admin_colors" -{ - "groupname2" - { - "flag" "z" - "namecolor" "{green}" - "textcolor" "{olive}" - } - "groupname1" - { - "flag" "a" - "namecolor" "{teamcolor}" - "textcolor" "{green}" - } -} \ No newline at end of file diff --git a/Simple Round Immunity/addons/sourcemod/plugins/simple-alltalkmanager.smx b/Simple Round Immunity/addons/sourcemod/plugins/simple-alltalkmanager.smx deleted file mode 100644 index 6122756..0000000 Binary files a/Simple Round Immunity/addons/sourcemod/plugins/simple-alltalkmanager.smx and /dev/null differ diff --git a/Simple Round Immunity/addons/sourcemod/plugins/simple-donatorbenefits.smx b/Simple Round Immunity/addons/sourcemod/plugins/simple-donatorbenefits.smx deleted file mode 100644 index 821d61d..0000000 Binary files a/Simple Round Immunity/addons/sourcemod/plugins/simple-donatorbenefits.smx and /dev/null differ diff --git a/Simple Round Immunity/addons/sourcemod/plugins/simple-messagesuppression.smx b/Simple Round Immunity/addons/sourcemod/plugins/simple-messagesuppression.smx deleted file mode 100644 index cc20dad..0000000 Binary files a/Simple Round Immunity/addons/sourcemod/plugins/simple-messagesuppression.smx and /dev/null differ diff --git a/Simple Round Immunity/addons/sourcemod/plugins/simple-plugins.smx b/Simple Round Immunity/addons/sourcemod/plugins/simple-plugins.smx deleted file mode 100644 index ac307a3..0000000 Binary files a/Simple Round Immunity/addons/sourcemod/plugins/simple-plugins.smx and /dev/null differ diff --git a/Simple Round Immunity/addons/sourcemod/plugins/simple-spectate.smx b/Simple Round Immunity/addons/sourcemod/plugins/simple-spectate.smx deleted file mode 100644 index c6885b0..0000000 Binary files a/Simple Round Immunity/addons/sourcemod/plugins/simple-spectate.smx and /dev/null differ diff --git a/Simple Round Immunity/addons/sourcemod/plugins/simple-teambalancer.smx b/Simple Round Immunity/addons/sourcemod/plugins/simple-teambalancer.smx deleted file mode 100644 index 95beb01..0000000 Binary files a/Simple Round Immunity/addons/sourcemod/plugins/simple-teambalancer.smx and /dev/null differ diff --git a/Simple Round Immunity/addons/sourcemod/plugins/simple-teammanager.smx b/Simple Round Immunity/addons/sourcemod/plugins/simple-teammanager.smx deleted file mode 100644 index 81905ba..0000000 Binary files a/Simple Round Immunity/addons/sourcemod/plugins/simple-teammanager.smx and /dev/null differ diff --git a/Simple Round Immunity/addons/sourcemod/scripting/include/simple-plugins.inc b/Simple Round Immunity/addons/sourcemod/scripting/include/simple-plugins.inc deleted file mode 100644 index 8f21956..0000000 --- a/Simple Round Immunity/addons/sourcemod/scripting/include/simple-plugins.inc +++ /dev/null @@ -1,337 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Plugins -Description: - Included file for core plugin in the Simple Plugins project -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -*************************************************************************/ - -#if defined _simpleplugin_included - #endinput -#endif - -#define _simpleplugin_included - -#define CORE_INC_VERSION "1.1.$Rev$" - -#pragma semicolon 1 -#include -#undef REQUIRE_PLUGIN -#include -#define REQUIRE_PLUGIN -#undef REQUIRE_EXTENSIONS -#undef AUTOLOAD_EXTENSIONS -#tryinclude -#tryinclude -#tryinclude -#define AUTOLOAD_EXTENSIONS -#define REQUIRE_EXTENSIONS - -enum e_SupportedMods -{ - GameType_Unknown, - GameType_AOC, - GameType_CSS, - GameType_DOD, - GameType_FF, - GameType_HIDDEN, - GameType_HL2DM, - GameType_INS, - GameType_L4D, - GameType_NEO, - GameType_SGTLS, - GameType_TF, - GameType_ZPS -}; - -enum e_Teams -{ - Unknown, - Spectator, - Team1, - Team2 -}; - -new g_aCurrentTeams[e_Teams]; -new e_SupportedMods:g_CurrentMod; -new String:g_sGameName[e_SupportedMods][32] = { "Unknown", - "Age of Chivalry", - "Counter Strike", - "Day Of Defeat", - "Fortress Forever", - "Hidden: Source", - "Half Life 2: Deathmatch", - "Insurgency", - "Left 4 Dead", - "Neotokyo", - "Stargate TLS", - "Team Fortress 2", - "Zombie Panic: Source" - }; - -public SharedPlugin:_pl_simpleplugin = -{ - name = "simple-plugins", - file = "simple-plugins.smx", -#if defined REQUIRE_PLUGIN - required = 1 -#else - required = 0 -#endif -}; - -#if !defined REQUIRE_PLUGIN -public _pl_simpleplugin_SetNTVOptional() -{ - MarkNativeAsOptional("SM_MovePlayer"); - MarkNativeAsOptional("SM_SetForcedTeam"); - MarkNativeAsOptional("SM_GetForcedTeam"); - MarkNativeAsOptional("SM_ClearForcedTeam"); - MarkNativeAsOptional("SM_GetForcedPlayer"); - MarkNativeAsOptional("SM_AssignBuddy"); - MarkNativeAsOptional("SM_SearchBuddy"); - MarkNativeAsOptional("SM_LockBuddy"); - MarkNativeAsOptional("SM_IsBuddyLocked"); - MarkNativeAsOptional("SM_ClearBuddy"); - MarkNativeAsOptional("SM_IsValidAdmin"); - MarkNativeAsOptional("SM_IsValidTeam"); -} -#endif - -/********************************************************************** - * When a player has to moved - * - * @param plugin Plugin that initiated the move - * @param client The client index of the player that was moved - * @param team The team index the player was moved to - * @noreturn - **********************************************************************/ -forward SM_OnPlayerMoved(Handle:plugin, client, team); - -/********************************************************************** - * Move a player to the supplied team - * - * @param client The client index of the player to be moved - * @param team The team to move the player to - * @noreturn - * @error Invalid client or team index - **********************************************************************/ -native SM_MovePlayer(client, team); - -/********************************************************************** - * Move a player to the supplied team - * - * @param client The client index of the player to set - * @param team The team to move the to set - * @param override Whether or not to override another plugin - * @return True if successful, false if not - * @error Invalid client or team index - **********************************************************************/ -native SM_SetForcedTeam(client, team, bool:override = false); - -/********************************************************************** - * Gets the client's forced team index - * - * @param client The client index of the player to check - * @param plugin Optional: The plugin handle of the plugin - that set the team - * @return The team index of the forced team - Zero if no forced team - * @error Invalid client index - **********************************************************************/ -native SM_GetForcedTeam(client, &Handle:plugin = INVALID_HANDLE); - -/********************************************************************** - * Clears a client's forced team - * - * @param client The client index of the player to check - * @return True if successful, false if not - * @error Invalid client index - **********************************************************************/ -native SM_ClearForcedTeam(client); - -/********************************************************************** - * Gets a forced player on the wrong that is currently on the wrong team - * This will only return a player if the calling plugin assigned the team - * - * @param team The team index the player should be on - * @return The client index of the player - Zero if no player found - * @error Invalid client index - **********************************************************************/ -native SM_GetForcedPlayer(team); - -/********************************************************************** - * Assign a players buddy - * - * @param client The client index of the player to assign - * @param player The player index of the player to assign - * @param override Whether or not to override a player lock - * @return True if successful, false if not - * @error Invalid client or player index - **********************************************************************/ -native bool:SM_AssignBuddy(client, player, bool:override = false); - -/********************************************************************** - * Rturns the client's buddy - * - * @param client The client index of the player to assign - * @return The client index of the player's buddy - Zero if no buddy - * @error Invalid client index - **********************************************************************/ -native SM_GetClientBuddy(client); - -/********************************************************************** - * Set the buddy lock setting for a client - * - * @param client The client index of the player to assign - * @param setting Setting to set, True or False - * @return True if successful, false if not - * @error Invalid client index - **********************************************************************/ -native bool:SM_LockBuddy(client, bool:setting); - -/********************************************************************** - * Returns the buddy lock setting for a client - * - * @param client The client index of the player to assign - * @return True if locked, false if not - * @error Invalid client index - **********************************************************************/ -native bool:SM_IsBuddyLocked(client); - -/********************************************************************** - * Clear a players buddy - * - * @param client The client index of the player to clear - * @param override Whether or not to override a player lock - * @return True if successful, false if not - * @error Invalid client index - **********************************************************************/ -native bool:SM_ClearBuddy(client, bool:override = false); - -/********************************************************************** - * Determine if the player has the supplied flags - * ADMFLAG_ROOT will always return true - * - * @param client The client index of the player to assign - * @param flags The char flag(s) to check against - * @return True if valid, false if not - **********************************************************************/ -native bool:SM_IsValidAdmin(client, const String:flags[]); - - -/********************************************************************** - * Determine if the team is a valid team - * - * @param team The team index to determine if valid for - currently installed/supported mod - * @return True if valid, false if not - **********************************************************************/ -native bool:SM_IsValidTeam(team); - - -public e_SupportedMods:GetCurrentMod() -{ - new String:sGameType[64]; - GetGameFolderName(sGameType, sizeof(sGameType)); - - if (StrEqual(sGameType, "aoc", false)) - { - return GameType_AOC; - } - if (StrEqual(sGameType, "cstrike", false)) - { - return GameType_CSS; - } - if (StrEqual(sGameType, "dod", false)) - { - return GameType_DOD; - } - if (StrEqual(sGameType, "ff", false)) - { - return GameType_FF; - } - if (StrEqual(sGameType, "hidden", false)) - { - return GameType_HIDDEN; - } - if (StrEqual(sGameType, "hl2mp", false)) - { - return GameType_FF; - } - if (StrEqual(sGameType, "insurgency", false) || StrEqual(sGameType, "ins", false)) - { - return GameType_INS; - } - if (StrEqual(sGameType, "l4d", false)) - { - return GameType_L4D; - } - if (StrEqual(sGameType, "nts", false)) - { - return GameType_NEO; - } - if (StrEqual(sGameType, "sgtls", false)) - { - return GameType_SGTLS; - } - if (StrEqual(sGameType, "tf", false)) - { - return GameType_TF; - } - if (StrEqual(sGameType, "zps", false)) - { - return GameType_ZPS; - } - return GameType_Unknown; -} - -public LoadCurrentTeams() -{ - switch (g_CurrentMod) - { - case GameType_INS: - { - g_aCurrentTeams[Unknown] = 0; - g_aCurrentTeams[Spectator] = 3; - g_aCurrentTeams[Team1] = 1; - g_aCurrentTeams[Team2] = 2; - } - case default: - { - g_aCurrentTeams[Unknown] = 0; - g_aCurrentTeams[Spectator] = 1; - g_aCurrentTeams[Team1] = 2; - g_aCurrentTeams[Team2] = 3; - } - } -} diff --git a/Simple Round Immunity/addons/sourcemod/scripting/simple-alltalkmanager.sp b/Simple Round Immunity/addons/sourcemod/scripting/simple-alltalkmanager.sp deleted file mode 100644 index c848332..0000000 --- a/Simple Round Immunity/addons/sourcemod/scripting/simple-alltalkmanager.sp +++ /dev/null @@ -1,515 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple AllTalk Manager -Description: - Allows you to set alltalk at different times -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#pragma semicolon 1 -#include -#include - -#define PLUGIN_VERSION "1.4.$Rev$" - -new Handle:satm_enabled = INVALID_HANDLE; -new Handle:satm_threshold_enabled = INVALID_HANDLE; -new Handle:satm_player_threshold = INVALID_HANDLE; -new Handle:satm_threshold_setting = INVALID_HANDLE; -new Handle:satm_logactivity = INVALID_HANDLE; -new Handle:satm_alltalk = INVALID_HANDLE; - -new Handle:g_aEventNames = INVALID_HANDLE; -new Handle:g_aEventReasons = INVALID_HANDLE; -new Handle:g_aEventSettings = INVALID_HANDLE; - -new bool:g_bLastThreshold = false; -new bool:g_bEnabled = true; -new bool:g_bThresholdEnabled = true; -new bool:g_bIsSetupMap = false; -new bool:g_bIsGameTF2 = false; -new bool:g_bLogActivity = false; - -new g_iLastEventIndex; - -public Plugin:myinfo = -{ - name = "Simple AllTalk Manager", - author = "Simple Plugins", - description = "Allows you to set alltalk at different times", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -} - -/** -Sourcemod callbacks -*/ -public OnPluginStart() -{ - - /** - Need to create all of our console variables. - */ - CreateConVar("satm_version", PLUGIN_VERSION, "Simple AllTalk Manager", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - satm_enabled = CreateConVar("satm_enabled", "1", "Enables/Disables Simple AllTalk Manager", _, true, 0.0, true, 1.0); - satm_threshold_enabled = CreateConVar("satm_threshold_enabled", "1", "Enables/Disables player threshold", _, true, 0.0, true, 1.0); - satm_player_threshold = CreateConVar("satm_player_threshold", "8", "Amount of players for the threshold"); - satm_threshold_setting = CreateConVar("satm_threshold_setting", "1", "Enables/Disables all talk up to player threshold, with the opposite set after the threshold", _, true, 0.0, true, 1.0); - satm_logactivity = CreateConVar("satm_logactivity", "0", "Enables/Disables log activity", _, true, 0.0, true, 1.0); - satm_alltalk = FindConVar("sv_alltalk"); - - /** - Hook console variables - */ - HookConVarChange(satm_enabled, ConVarSettingsChanged); - HookConVarChange(satm_threshold_enabled, ConVarSettingsChanged); - HookConVarChange(satm_player_threshold, ConVarSettingsChanged); - HookConVarChange(satm_logactivity, ConVarSettingsChanged); - - /** - Remove the notify flag from all talk cvar since we do it - */ - SetConVarFlags(satm_alltalk, GetConVarFlags(satm_alltalk)~FCVAR_NOTIFY); - - /** - Get the game type. We only care if it's TF2 - */ - new String:sGameType[64]; - GetGameFolderName(sGameType, sizeof(sGameType)); - if (StrEqual(sGameType, "tf", false)) - { - g_bIsGameTF2 = true; - } - - /** - Create the arrays - */ - g_aEventNames = CreateArray(255, 1); - g_aEventReasons = CreateArray(255, 1); - g_aEventSettings = CreateArray(1, 1); - - /** - Need to register the commands we are going to create and use. - */ - RegAdminCmd("sm_reloadatconfig", Command_Reload, ADMFLAG_GENERIC, "Reloads settings from config file"); - - /** - Create the config file - */ - AutoExecConfig(true); - - /** - Load the events from the config - */ - LoadEventsFromConfig(); -} - -public OnConfigsExecuted() -{ - - /** - Load up the settings - */ - g_bEnabled = GetConVarBool(satm_enabled); - g_bLogActivity = GetConVarBool(satm_logactivity); - g_bThresholdEnabled = GetConVarBool(satm_threshold_enabled); -} - -public OnMapStart() -{ - - /** - Reset the globals - */ - g_iLastEventIndex = 0; - g_bLastThreshold = false; - - /** - Check the map type if we are in TF2 - */ - if (g_bIsGameTF2) - { - g_bIsSetupMap = IsSetupPeriodMap(); - } - - /** - Set AllTalk - */ - if (g_bEnabled) - { - SetConVarBool(satm_alltalk, true); - } -} - -public OnClientDisconnect_Post(client) -{ - if (g_bEnabled) - { - SetAllTalk(-1); - } -} - -public OnClientPostAdminCheck(client) -{ - if (g_bEnabled) - { - SetAllTalk(-1); - } - CreateTimer(2.0, Timer_ShowAllTalkStatus, client, TIMER_FLAG_NO_MAPCHANGE); -} - -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (convar == satm_enabled) - { - if (StringToInt(newValue)) - { - g_bEnabled = true; - } - else - { - g_bEnabled = false; - } - } - else if (convar == satm_threshold_enabled) - { - if (StringToInt(newValue)) - { - g_bThresholdEnabled = true; - } - else - { - g_bThresholdEnabled = false; - } - } - else if (convar == satm_logactivity) - { - if (StringToInt(newValue)) - { - g_bLogActivity = true; - } - else - { - g_bLogActivity = false; - } - } - if (g_bEnabled) - { - SetAllTalk(-1); - } -} - -/** -Commands -*/ -public Action:Command_Reload(client, args) -{ - - /** - Clear the array - */ - ClearArray(g_aEventNames); - ClearArray(g_aEventReasons); - ClearArray(g_aEventSettings); - - /** - Load the events from the config - */ - LoadEventsFromConfig(); - - return Plugin_Handled; -} - -/** -Game Event Hooks -*/ -public Hook_All_Events(Handle:event, const String:name[], bool:dontBroadcast) -{ - if (!g_bIsSetupMap) - { - if (StrEqual(name, "teamplay_round_start")) - { - if (FindStringInArray(g_aEventNames, "teamplay_setup_finished") != -1) - { - g_iLastEventIndex = FindStringInArray(g_aEventNames, "teamplay_setup_finished"); - if (g_bEnabled) - { - SetAllTalk(g_iLastEventIndex); - return; - } - } - } - } - g_iLastEventIndex = FindStringInArray(g_aEventNames, name); - if (g_bEnabled) - { - SetAllTalk(g_iLastEventIndex); - } -} - -/** -Timers -*/ -public Action:Timer_ShowAllTalkStatus(Handle:timer, any:client) -{ - if (IsClientConnected(client) && IsClientInGame(client)) - { - new bool:bSetting = GetConVarBool(satm_alltalk); - if (bSetting) - { - PrintToChat(client, "\x01\x04[SM] AllTalk is \x01[on]"); - } - else - { - PrintToChat(client, "\x01\x04[SM] AllTalk is \x01[off]"); - } - } -} - -/** -Stock Functions -*/ -stock LoadEventsFromConfig() -{ - - /** - Make sure the config file is here and load it up - */ - new String:sConfigFile[256]; - BuildPath(Path_SM, sConfigFile, sizeof(sConfigFile), "configs/simple-alltalkmanager_events.cfg"); - if (!FileExists(sConfigFile)) - { - - /** - Config file doesn't exists, stop the plugin - */ - LogError("[SATM] Simple AllTalk Manager is not running! Could not find file %s", sConfigFile); - SetFailState("Could not find file %s", sConfigFile); - } - - /** - Create the arrays and variables - */ - new String:sGameEventName[256]; - new String:sReason[256]; - new iSetting; - - /** - Load config file as a KeyValues file - */ - new Handle:kvGameEvents = CreateKeyValues("game_events"); - FileToKeyValues(kvGameEvents, sConfigFile); - - if (!KvGotoFirstSubKey(kvGameEvents)) - { - return; - } - - /** - Hook the game events and load the settings - */ - do - { - - /** - Get the section name; this should be the event name - */ - KvGetSectionName(kvGameEvents, sGameEventName, sizeof(sGameEventName)); - if (!HookEventEx(sGameEventName, Hook_All_Events, EventHookMode_PostNoCopy)) - { - - /** - Could not hook this event, stop the plugin - */ - SetFailState("Could not hook event %s", sGameEventName); - } - else - { - if (g_bLogActivity) - { - LogMessage("[SATM] Hooked event: %s", sGameEventName); - } - } - - /** - Get the reason string and setting - */ - KvGetString(kvGameEvents, "reason", sReason, sizeof(sReason)); - iSetting = KvGetNum(kvGameEvents, "setting"); - if (g_bLogActivity) - { - LogMessage("[SATM] Event reason string: %s", sReason); - LogMessage("[SATM] Event setting: %i", iSetting); - } - - /** - Push the values to the arrays - */ - PushArrayString(g_aEventNames, sGameEventName); - PushArrayString(g_aEventReasons, sReason); - PushArrayCell(g_aEventSettings, iSetting); - } while (KvGotoNextKey(kvGameEvents)); - - /** - Close our handle - */ - CloseHandle(kvGameEvents); -} - -stock SetAllTalk(index) -{ - new iPlayerThreshold = GetConVarInt(satm_player_threshold); - new bool:bThresholdMet = ((GetClientCount() >= iPlayerThreshold) ? true : false); - new bool:bSetting; - - if (g_bThresholdEnabled) - { - if (bThresholdMet) - { - if (index == -1) - { - if (bThresholdMet != g_bLastThreshold) - { - g_bLastThreshold = true; - bSetting = !GetConVarBool(satm_threshold_setting); - new bool:bLastSetting = GetArrayCell(g_aEventSettings, g_iLastEventIndex); - if (bLastSetting && !bSetting) - { - bSetting = GetArrayCell(g_aEventSettings, g_iLastEventIndex); - } - } - else - { - bSetting = GetArrayCell(g_aEventSettings, g_iLastEventIndex); - } - } - else - { - bSetting = GetArrayCell(g_aEventSettings, index); - } - } - else - { - g_bLastThreshold = false; - bSetting = GetConVarBool(satm_threshold_setting); - } - } - else - { - if (index != -1) - { - bSetting = GetArrayCell(g_aEventSettings, index); - } - } - - if (GetConVarBool(satm_alltalk) != bSetting) - { - - SetConVarBool(satm_alltalk, bSetting); - - new String:sReason[256]; - if (index == -1) - { - Format(sReason, sizeof(sReason), "Player Threshold"); - } - else - { - if (!g_bIsSetupMap) - { - new String:sCurrentEvent[256]; - GetArrayString(g_aEventNames, index, sCurrentEvent, sizeof(sCurrentEvent)); - if (StrEqual(sCurrentEvent, "teamplay_setup_finished")) - { - new iRoundStartIndex = FindStringInArray(g_aEventNames, "teamplay_round_start"); - if (iRoundStartIndex != -1) - { - GetArrayString(g_aEventReasons, iRoundStartIndex, sReason, sizeof(sReason)); - } - else - { - GetArrayString(g_aEventReasons, index, sReason, sizeof(sReason)); - } - } - else - { - GetArrayString(g_aEventReasons, index, sReason, sizeof(sReason)); - } - } - else - { - GetArrayString(g_aEventReasons, index, sReason, sizeof(sReason)); - } - } - - if (bSetting) - { - PrintToChatAll("\x01\x04[SM] AllTalk turned \x01[on] \x04due to:\x01 %s", sReason); - } - else - { - PrintToChatAll("\x01\x04[SM] AllTalk turned \x01[off] \x04due to:\x01 %s", sReason); - } - } -} - -stock bool:IsSetupPeriodMap() -{ - new iEnt = -1; - new String:sMapName[32]; - - GetCurrentMap(sMapName, sizeof(sMapName)); - - if (strncmp(sMapName, "cp_", 3, false) == 0) - { - new iTeam; - while ((iEnt = FindEntityByClassname(iEnt, "team_control_point")) != -1) - { - iTeam = GetEntProp(iEnt, Prop_Send, "m_iTeamNum"); - - /** - If there is a blu CP or a neutral CP, then it's not an attack/defend map - */ - if (iTeam != 2) - { - //this is a push map - return false; - } - } - //this is a attack/defend map - return true; - } - else if (strncmp(sMapName, "ctf_", 3, false) == 0) - { - //this is a ctf map - return false; - } - return false; -} diff --git a/Simple Round Immunity/addons/sourcemod/scripting/simple-autoscrambler.sp b/Simple Round Immunity/addons/sourcemod/scripting/simple-autoscrambler.sp deleted file mode 100644 index 6c6799e..0000000 --- a/Simple Round Immunity/addons/sourcemod/scripting/simple-autoscrambler.sp +++ /dev/null @@ -1,459 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple AutoScrambler -Description: - Automatically scrambles the teams based upon a number of events. -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include - -#define PLUGIN_VERSION "1.1.$Rev$" - -/** -Different scramble modes: - -1 = Full Scramble, dont restart round. -2 = Admins Immune, dont restart round. -3 = Full Scramble, restart round and reset scores. -4 = Admins Immune, restart round and reset scores. - -*/ - -/** -Different top player modes: - -1 = Divide Top 4 players on the two teams. -2 = Protect the Top 2 players on each team. - -*/ - -enum PlayerData -{ - Handle:hForcedTimer, - bool:bProtected; -}; - -/** -Cvars used for admins -*/ -new Handle: sas_admin_immunity_enabled = INVALID_HANDLE, - Handle: sas_admin_flag_scramblenow = INVALID_HANDLE, - Handle: sas_admin_flag_immunity = INVALID_HANDLE; - -/** -Cvars used for autoscramble -*/ -new Handle: sas_autoscramble_enabled = INVALID_HANDLE, - Handle: sas_autoscramble_minplayers = INVALID_HANDLE, - Handle: sas_autoscramble_mode = INVALID_HANDLE, - Handle: sas_autoscramble_winstreak = INVALID_HANDLE, - Handle: sas_autoscramble_steamroll = INVALID_HANDLE, - Handle: sas_autoscramble_frags = INVALID_HANDLE; - -/** -Cvars used for voting -*/ -new Handle: sas_vote_enabled = INVALID_HANDLE, - Handle: sas_vote_upcount = INVALID_HANDLE, - Handle: sas_vote_winpercent = INVALID_HANDLE, - Handle: sas_vote_mode = INVALID_HANDLE, - Handle: sas_vote_minplayers = INVALID_HANDLE; - -/** -Additional cvars -*/ -new Handle: sas_enabled = INVALID_HANDLE, - Handle: sas_timer_scrambledelay = INVALID_HANDLE, - Handle: TFGameModeArena = INVALID_HANDLE; - -/** -Timers -*/ -new Handle: g_hScrambleTimer = INVALID_HANDLE; - -/** - Player arrays - */ -new g_aPlayers[MAXPLAYERS + 1][PlayerData]; - -/** - Cvar variables - */ -new bool: g_bIsEnabled, - bool: g_bIsAutoScrambleEnabled, - bool: g_bIsVoteEnabled, - bool: g_bIsAdminImmunityEnabled; -new Float: g_fTimer_ScrambleDelay, - Float: g_fVote_UpCount, - Float: g_fVote_WinPercent; -new g_iAutoScramble_Minplayers, - g_iAutoScramble_Mode, - g_iAutoScramble_WinStreak, - g_iAutoScramble_SteamRoll, - g_iAutoScramble_Frags, - g_iVote_Mode, - g_iVote_MinPlayers; -new String: g_sScrambleNowFlag[5], - String: g_sAdminImmunityFlag[5]; - -/** -Other globals -*/ -new g_iMaxEntities, - g_iOwnerOffset; - -public Plugin:myinfo = -{ - name = "Simple AutoScrambler", - author = "Simple Plugins", - description = "Automatically scrambles the teams based upon a number of events.", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -}; - -public OnPluginStart() -{ - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook the game events - */ - LogAction(0, -1, "[SAS] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - switch (g_CurrentMod) - { - case GameType_TF: - { - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - } - case GameType_DOD: - { - HookEvent("dod_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_Post); - } - default: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_Post); - } - } - - /** - Create console variables - */ - CreateConVar("sas_version", PLUGIN_VERSION, "Simple AutoScrambler Version",FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - sas_enabled = CreateConVar("sas_enabled", "1", "Enable/Disable Simple AutoScrambler"); - sas_timer_scrambledelay = CreateConVar("sas_timer_scrambledelay", "5.0", "Delay used after a scramble has been started", _, true, 1.0, true, 30.0); - - /** - Cvars used for admins - */ - sas_admin_immunity_enabled = CreateConVar("sas_admin_immunity_enabled", "1", "Enable/Disable admin immunity for scrambles"); - sas_admin_flag_scramblenow = CreateConVar("sas_admin_flag_scramblenow", "z", "Admin flag to use for scramblenow function/command"); - sas_admin_flag_immunity = CreateConVar("sas_admin_flag_immunity", "z", "Admin flag to use for scramble immunity"); - - /** - Cvars used for autoscramble - */ - sas_autoscramble_enabled = CreateConVar("sas_autoscramble_enabled", "1", "Enable/Disable the autoscramble function"); - sas_autoscramble_minplayers = CreateConVar("sas_autoscramble_minplayers", "16", "Min players needed to start an autoscramble"); - sas_autoscramble_mode = CreateConVar("sas_autoscramble_mode", "1", "Scramble mode used when autoscrambling"); - sas_autoscramble_winstreak = CreateConVar("sas_autoscramble_winstreak", "5", "Max amount of wins in a row a team can achieve before an autoscramble starts"); - sas_autoscramble_steamroll = CreateConVar("sas_autoscramble_steamroll", "120", "Shortest amount of time a team can win by before an autoscramble starts (seconds)"); - sas_autoscramble_frags = CreateConVar("sas_autoscramble_frags", "1", "Min players needed to start a vote and scramble"); - - /** - Cvars used for voting - */ - sas_vote_enabled = CreateConVar("sas_vote_enabled", "1", "Enable/Disable voting for scramble"); - sas_vote_upcount = CreateConVar("sas_vote_upcount", "5", "Amount of people wanting a scramble before a vote starts. If less than 1 it will be considered a percentage. (ie 0.5 = 50% | 1 = 1 Player | 5 = 5 Players)"); - sas_vote_winpercent = CreateConVar("sas_vote_winpercent", "0.6", "Percentage of votes needed to scramble", _, true, 0.0, true, 1.0); - sas_vote_mode = CreateConVar("sas_vote_mode", "1", "Scramble mode used when a vote results in a scramble"); - sas_vote_minplayers = CreateConVar("sas_vote_minplayers", "16", "Min players needed to start a vote and scramble"); - - /** - Hook the console variables if they change - */ - HookConVarChange(sas_enabled, ConVarSettingsChanged); - HookConVarChange(sas_timer_scrambledelay, ConVarSettingsChanged); - HookConVarChange(sas_admin_immunity_enabled, ConVarSettingsChanged); - HookConVarChange(sas_admin_flag_scramblenow, ConVarSettingsChanged); - HookConVarChange(sas_admin_flag_immunity, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_enabled, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_minplayers, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_mode, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_winstreak, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_steamroll, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_frags, ConVarSettingsChanged); - HookConVarChange(sas_vote_enabled, ConVarSettingsChanged); - HookConVarChange(sas_vote_upcount, ConVarSettingsChanged); - HookConVarChange(sas_vote_winpercent, ConVarSettingsChanged); - HookConVarChange(sas_vote_mode, ConVarSettingsChanged); - HookConVarChange(sas_vote_minplayers, ConVarSettingsChanged); - - /** - Register the command - */ - RegConsoleCmd("sm_scramblenow", Command_ScrambleNow, "sm_scramblenow (mode): Scrambles the teams"); - - /** - Load translations and .cfg file - */ - LoadTranslations ("simpleautoscrambler.phrases"); - AutoExecConfig(true, "plugin.simpleautoscrambler"); - LogAction(0, -1, "[SAS] Simple AutoScrambler is loaded."); -} - -public OnAllPluginsLoaded() -{ - //something -} - -public OnLibraryRemoved(const String:name[]) -{ - //something -} - -public OnConfigsExecuted() -{ - - /** - Load up all the variable defaults - */ - LoadUpVariables(); - - /** - Log our activity - */ - if (g_bIsEnabled) - LogAction(0, -1, "Simple AutoScrambler is ENABLED"); - else - LogAction(0, -1, "Simple AutoScrambler is DISABLED"); -} - -public Action:Command_ScrambleNow(client, args) -{ - - /** - Make sure we are enabled - */ - if (!g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - Make sure the client is authorized to run this command. - */ - if (!SM_IsValidAdmin(client, g_sScrambleNowFlag)) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Make sure it's ok to scramble at this time - */ - if (!OkToScramble) - { - return Plugin_Handled; - } - - /** - Make sure it's ok to scramble at this time - */ - LogAction(0, -1, "[SAS] The scramblenow command was used"); - - /** - Scramble the teams - */ - StartAScramble(); - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public HookRoundStart(Handle:event, const String:name[], bool:dontBroadcast) -{ - -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - -} - -public Action:Timer_ScrambleTeams(Handle:timer, any:mode) -{ - - /** - Make sure it's still ok to scramble - */ - if (!OkToScramble) - { - return Plugin_Handled; - } - - - switch (mode) - { - case - - - - } - - - /** - Reset the handle because the timer is over and the callback is done - */ - g_hScrambleTimer = INVALID_HANDLE; - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - -} - -stock StartAScramble(mode) -{ - - /** - See if we are already started a scramble - */ - if (g_hScrambleTimer == INVALID_HANDLE) - { - - /** - There is a scramble in progress - */ - return; - - } - - /** - Report that a scramble is about to start - */ - PrintCenterTextAll("%T", "Scramble", LANG_SERVER); - - /** - Start a timer and log the action - */ - g_hScrambleTimer = CreateTimer(g_fTimer_ScrambleDelay, Timer_ScrambleTeams, mode, TIMER_FLAG_NO_MAPCHANGE); - LogAction(0, -1, "[SAS] A scamble timer was started"); -} - -stock bool:OkToScramble() -{ - -} - -stock LoadUpVariables() -{ - g_bIsEnabled = GetConVarBool(sas_enabled); - g_bIsAutoScrambleEnabled = GetConVarBool(sas_autoscramble_enabled); - g_bIsVoteEnabled = GetConVarBool(sas_vote_enabled); - g_bIsAdminImmunityEnabled = GetConVarBool(sas_admin_immunity_enabled); - g_iAutoScramble_Minplayers = GetConVarInt(sas_autoscramble_minplayers); - g_iAutoScramble_Mode = GetConVarInt(sas_autoscramble_mode); - g_iAutoScramble_WinStreak = GetConVarInt(sas_autoscramble_winstreak); - g_iAutoScramble_SteamRoll = GetConVarInt(sas_autoscramble_steamroll); - g_iAutoScramble_Frags = GetConVarInt(sas_autoscramble_frags); - g_iVote_Mode = GetConVarInt(sas_vote_mode); - g_iVote_MinPlayers = GetConVarInt(sas_vote_minplayers); - GetConVarString(sas_admin_flag_scramblenow, g_sScrambleNowFlag, sizeof(g_sScrambleNowFlag)); - GetConVarString(sas_admin_flag_immunity, g_sAdminImmunityFlag, sizeof(g_sAdminImmunityFlag)); - g_fTimer_ScrambleDelay = GetConVarFloat(sas_timer_scrambledelay); - g_fVote_UpCount = GetConVarFloat(sas_vote_upcount); - g_fVote_WinPercent = GetConVarFloat(sas_vote_winpercent); - g_iMaxEntities = GetMaxEntities(); - g_iOwnerOffset = FindSendPropInfo("CBaseObject", "m_hBuilder"); -} - -stock TF2_DestroyBuildings(client) -{ - - /** - We have to start a loop to check the owner of all the valid entities - */ - for (new i = MaxClients + 1; i <= g_iMaxEntities; i++) - { - if (!IsValidEntity(i)) - { - - /** - Not valid, continue to next one - */ - continue; - } - - /** - Get the name of the current entity - */ - decl String:sNetClass[32]; - GetEntityNetClass(i, sNetClass, sizeof(sNetClass)); - - /** - See if its something that an engineer would build - */ - if (strcmp(sNetClass, "CObjectSentrygun") == 0 - || strcmp(sNetClass, "CObjectTeleporter") == 0 - || strcmp(sNetClass, "CObjectDispenser") == 0) - { - - /** - It is, so lets check the owner - */ - if (GetEntDataEnt2(i, g_iOwnerOffset) == client) - { - - /** - It's the clients building, so we blow it up. - */ - SetVariantInt(9999); - AcceptEntityInput(i, "RemoveHealth"); - } - } - } -} \ No newline at end of file diff --git a/Simple Round Immunity/addons/sourcemod/scripting/simple-chatcolors.sp b/Simple Round Immunity/addons/sourcemod/scripting/simple-chatcolors.sp deleted file mode 100644 index 539d057..0000000 --- a/Simple Round Immunity/addons/sourcemod/scripting/simple-chatcolors.sp +++ /dev/null @@ -1,496 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Chat Colors -Description: - Changes the colors of players chat based on config file -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#pragma semicolon 1 -#include -#include - -#define PLUGIN_VERSION "0.9.0.$Rev$" - -#define CHAT_SYMBOL '@' -#define TRIGGER_SYMBOL1 '!' -#define TRIGGER_SYMBOL2 '/' -#define CHAT_MAX_MESSAGE_LENGTH 1024 - -new Handle:g_hDebugCvar = INVALID_HANDLE; -new Handle:g_aGroupNames = INVALID_HANDLE; -new Handle:g_aGroupFlag = INVALID_HANDLE; -new Handle:g_aGroupNameColor = INVALID_HANDLE; -new Handle:g_aGroupTextColor = INVALID_HANDLE; - -new bool:g_bDebug = false; - -new g_iArraySize; - -new g_aPlayerColorIndex[MAXPLAYERS + 1] = { -1, ... }; - -public Plugin:myinfo = -{ - name = "Simple Chat Colors", - author = "Simple Plugins", - description = "Changes the colors of players chat based on config file.", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -}; - -/** -Sourcemod callbacks -*/ -public OnPluginStart() -{ - - /** - Need to create all of our console variables. - */ - CreateConVar("sm_chatcolors_version", PLUGIN_VERSION, "Simple Chat Colors", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - g_hDebugCvar = CreateConVar("sm_chatcolors_debug", "1", "Enable/Disable debugging information"); - - /** - Hook console variables - */ - HookConVarChange(g_hDebugCvar, ConVarSettingsChanged); - - /** - Need to register the commands we are going to use - */ - RegConsoleCmd("say", Command_Say); - RegConsoleCmd("say_team", Command_SayTeam); - RegAdminCmd("sm_reloadcolorsconfig", Command_Reload, ADMFLAG_GENERIC, "Reloads settings from config file"); - - /** - Create the arrays - */ - g_aGroupNames = CreateArray(256, 1); - g_aGroupFlag = CreateArray(15, 1); - g_aGroupNameColor = CreateArray(15, 1); - g_aGroupTextColor = CreateArray(15, 1); - - /** - Load the admins and colors from the config - */ - LoadAdminsAndColorsFromConfig(); - g_iArraySize = GetArraySize(g_aGroupNames); -} - -public OnConfigsExecuted() -{ - g_bDebug = GetConVarBool(g_hDebugCvar); - ReloadConfigFile(); -} - -public OnClientPostAdminCheck(client) -{ - - /** - Check the client to see if they are a admin - */ - CheckAdmin(client); -} - -public OnClientDisconnect(client) -{ - g_aPlayerColorIndex[client] = -1; -} - -/** -Commands -*/ -public Action:Command_Say(client, args) -{ - - /** - Make sure we are enabled. - */ - if (client == 0 || IsChatTrigger()) - { - return Plugin_Continue; - } - - if (g_aPlayerColorIndex[client] != -1) - { - - /** - The client is, so get the chat message and strip it down. - */ - decl String:sArg[CHAT_MAX_MESSAGE_LENGTH], - String:sChatMsg[CHAT_MAX_MESSAGE_LENGTH]; - - new bool:bAlive = IsPlayerAlive(client); - - GetCmdArgString(sArg, sizeof(sArg)); - StripQuotes(sArg); - TrimString(sArg); - new startidx; - if (sArg[strlen(sArg)-1] == '"') - { - sArg[strlen(sArg)-1] = '\0'; - startidx = 1; - } - - /** - Bug out if they are using the admin chat symbol (admin chat). If we are in CSS it may not find all the triggers, so we double check. - */ - if (sArg[startidx] == CHAT_SYMBOL || sArg[startidx] == TRIGGER_SYMBOL1 || sArg[startidx] == TRIGGER_SYMBOL2) - { - return Plugin_Continue; - } - - /** - Log the message for hlstatsx and other things. - */ - new iUserID = GetClientUserId(client); - decl String:sAuthID[64]; - GetClientAuthString(client, sAuthID, sizeof(sAuthID)); - LogToGame("\"%N<%i><%s><>\" say \"%s\"", client, iUserID, sAuthID, sArg); - - /** - Format the message. - */ - FormatMessage(client, 0, bAlive, sChatMsg, sArg, g_aPlayerColorIndex[client]); - - /** - Send the message. - */ - //SayText2(0, client, sChatMsg); - CPrintToChatAll(sChatMsg); - - /** - We are done, bug out, and stop the original chat message. - */ - return Plugin_Stop; - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -public Action:Command_SayTeam(client, args) -{ - - /** - Make sure we are enabled. - */ - if (client == 0 || IsChatTrigger()) - { - return Plugin_Continue; - } - - /** - Check the client to see if they are a admin - */ - if (g_aPlayerColorIndex[client] != -1) - { - - /** - The client is, so get the chat message and strip it down. - */ - decl String:sArg[CHAT_MAX_MESSAGE_LENGTH], - String:sChatMsg[CHAT_MAX_MESSAGE_LENGTH]; - - new bool:bAlive = IsPlayerAlive(client); - new iCurrentTeam = GetClientTeam(client); - - GetCmdArgString(sArg, sizeof(sArg)); - StripQuotes(sArg); - TrimString(sArg); - new startidx; - if (sArg[strlen(sArg)-1] == '"') - { - sArg[strlen(sArg)-1] = '\0'; - startidx = 1; - } - - /** - Bug out if they are using the admin chat symbol (admin chat). - */ - if (sArg[startidx] == CHAT_SYMBOL || sArg[startidx] == TRIGGER_SYMBOL1 || sArg[startidx] == TRIGGER_SYMBOL2) - { - return Plugin_Continue; - } - - /** - Log the message for hlstatsx and other things. - */ - new iUserID = GetClientUserId(client); - decl String:sAuthID[64]; - GetClientAuthString(client, sAuthID, sizeof(sAuthID)); - LogToGame("\"%N<%i><%s><>\" say_team \"%s\"", client, iUserID, sAuthID, sArg); - - /** - Format the message. - */ - FormatMessage(client, iCurrentTeam, bAlive, sChatMsg, sArg, g_aPlayerColorIndex[client]); - - /** - Send the message to the same team - */ - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientConnected(i) && IsClientInGame(i) && GetClientTeam(i) == iCurrentTeam) - { - CPrintToChat(client, sChatMsg); - } - } - - /** - We are done, bug out, and stop the original chat message. - */ - return Plugin_Stop; - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -public Action:Command_Reload(client, args) -{ - ReloadConfigFile(); - return Plugin_Handled; -} - -/** -Stock Functions -*/ -stock LoadAdminsAndColorsFromConfig() -{ - - /** - Make sure the config file is here and load it up - */ - new String:sConfigFile[256]; - BuildPath(Path_SM, sConfigFile, sizeof(sConfigFile), "configs/simple-chatcolors.cfg"); - if (!FileExists(sConfigFile)) - { - - /** - Config file doesn't exists, stop the plugin - */ - LogError("[SCC] Simple Chat Colors is not running! Could not find file %s", sConfigFile); - SetFailState("Could not find file %s", sConfigFile); - } - - /** - Create the arrays and variables - */ - new String:sGroupName[256]; - new String:sGroupFlag[15]; - new String:sGroupNameColor[15]; - new String:sGroupTextColor[15]; - - - /** - Load config file as a KeyValues file - */ - new Handle:kvChatColors = CreateKeyValues("admin_colors"); - FileToKeyValues(kvChatColors, sConfigFile); - - if (!KvGotoFirstSubKey(kvChatColors)) - { - return; - } - - /** - Load up all the groups in the file - */ - do - { - - /** - Get the section name; should be the "group" name - */ - KvGetSectionName(kvChatColors, sGroupName, sizeof(sGroupName)); - - - /** - Get the flags and colors - */ - KvGetString(kvChatColors, "flag", sGroupFlag, sizeof(sGroupFlag)); - KvGetString(kvChatColors, "namecolor", sGroupNameColor, sizeof(sGroupNameColor)); - KvGetString(kvChatColors, "textcolor", sGroupTextColor, sizeof(sGroupTextColor)); - - if (g_bDebug) - { - LogMessage("Group Name/SteamID: %s", sGroupName); - LogMessage("Flag String: %s", sGroupFlag); - LogMessage("Color on name: %s", sGroupNameColor); - LogMessage("Color of text: %s", sGroupTextColor); - } - - /** - Push the values to the arrays - */ - PushArrayString(g_aGroupNames, sGroupName); - PushArrayString(g_aGroupFlag, sGroupFlag); - PushArrayString(g_aGroupNameColor, sGroupNameColor); - PushArrayString(g_aGroupTextColor, sGroupTextColor); - } while (KvGotoNextKey(kvChatColors)); - - /** - Close our handle - */ - CloseHandle(kvChatColors); -} - -stock ReloadConfigFile() -{ - - /** - Clear the array - */ - ClearArray(g_aGroupNames); - ClearArray(g_aGroupFlag); - ClearArray(g_aGroupNameColor); - ClearArray(g_aGroupTextColor); - - /** - Load the admins, groups, and colors from the config - */ - LoadAdminsAndColorsFromConfig(); - g_iArraySize = GetArraySize(g_aGroupNames); - - /** - Recheck all the online players for assigned colors - */ - for (new index = 1; index <= MaxClients; index++) - { - if (IsClientConnected(index) && IsClientInGame(index)) - { - CheckAdmin(index); - } - } -} - -stock CheckAdmin(client) -{ - new String:sFlags[15]; - new String:sClientSteamID[64]; - new iGroupFlags; - new iFlags; - new iIndex = -1; - - /** - Look for a steamid first - */ - GetClientAuthString(client, sClientSteamID, sizeof(sClientSteamID)); - iIndex = FindStringInArray(g_aGroupNames, sClientSteamID); - if (iIndex != -1) - { - g_aPlayerColorIndex[client] = iIndex; - } - - /** - Didn't find one, check flags - */ - else - { - /** - Search for flag in groups - */ - - iFlags = GetUserFlagBits(client); - for (iIndex = 0; iIndex < g_iArraySize; iIndex++) - { - GetArrayString(g_aGroupFlag, iIndex, sFlags, sizeof(sFlags)); - iGroupFlags = ReadFlagString(sFlags); - if (iFlags & iGroupFlags) - { - g_aPlayerColorIndex[client] = iIndex; - break; - } - } - } - - if (g_bDebug) - { - PrintToChatAll("SteamID: %s", sClientSteamID); - PrintToChatAll("Array Index: %i", iIndex); - PrintToChatAll("Flag String: %s", sFlags); - PrintToChatAll("Flag Bits of Client: %i", iFlags); - PrintToChatAll("Flag Bits of Group: %i", iGroupFlags); - } -} - -stock FormatMessage(iClient, iTeam, bool:bAlive, String:sChatMsg[], const Sting:sMessage[], iArrayIndex) -{ - decl String:sDead[10], - String:sTeam[10], - String:sClientName[64]; - - GetClientName(iClient, sClientName, sizeof(sClientName)); - - if (iTeam != 0) - { - Format(sTeam, sizeof(sTeam), "(TEAM) "); - } - else - { - Format(sTeam, sizeof(sTeam), ""); - } - if (bAlive) - { - Format(sDead, sizeof(sDead), ""); - } - else - { - Format(sDead, sizeof(sDead), "*DEAD* "); - } - - new String:sNameColor[15]; - new String:sTextColor[15]; - GetArrayString(g_aGroupNameColor, iArrayIndex, sNameColor, sizeof(sNameColor)); - GetArrayString(g_aGroupTextColor, iArrayIndex, sTextColor, sizeof(sTextColor)); - - Format(sChatMsg, CHAT_MAX_MESSAGE_LENGTH, "{default}%s%s%s%s {default}: %s%s", sDead, sTeam, sNameColor, sClientName, sTextColor, sMessage); -} - -/** -Adjust the settings if a convar was changed -*/ -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (StringToInt(newValue) == 1) - { - g_bDebug = true; - } - else - { - g_bDebug = false; - } -} \ No newline at end of file diff --git a/Simple Round Immunity/addons/sourcemod/scripting/simple-donatorbenefits.sp b/Simple Round Immunity/addons/sourcemod/scripting/simple-donatorbenefits.sp deleted file mode 100644 index e3f6845..0000000 --- a/Simple Round Immunity/addons/sourcemod/scripting/simple-donatorbenefits.sp +++ /dev/null @@ -1,1312 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Donator Benefits -Description: - Provides donator benefits to players -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include -#include - -#define PLUGIN_VERSION "1.1.$Rev$" - -#define CHAT_SYMBOL '@' -#define CHAT_MAX_MESSAGE_LENGTH 1024 - -enum PlayerData -{ - bool:bIsDonator, - bool:bQueue, - bool:bImmune, - iHealthCount, - iNewTeam -}; - -/** - Public convar handles - */ -new Handle:sdb_enabled = INVALID_HANDLE; -new Handle:sdb_donationflag = INVALID_HANDLE; -new Handle:sdb_soundfile = INVALID_HANDLE; -new Handle:sdb_joinsound_enabled = INVALID_HANDLE; -new Handle:sdb_joinpubmsg_enabled = INVALID_HANDLE; -new Handle:sdb_joinprivmsg_enabled = INVALID_HANDLE; -new Handle:sdb_chatcolors_enabled = INVALID_HANDLE; -new Handle:sdb_immunity_enabled = INVALID_HANDLE; -new Handle:sdb_ubercharge_enabled = INVALID_HANDLE; -new Handle:sdb_givehealth_enabled = INVALID_HANDLE; -new Handle:sdb_nofalldmg_enabled = INVALID_HANDLE; -new Handle:sdb_fastheavy_enabled = INVALID_HANDLE; -new Handle:sdb_swapteam_enabled = INVALID_HANDLE; -new Handle:sdb_chatcolor = INVALID_HANDLE; -new Handle:sdb_uberlevel = INVALID_HANDLE; -new Handle:sdb_healthcount = INVALID_HANDLE; -new Handle:sdb_healthbonus = INVALID_HANDLE; -new Handle:sdb_heavymultiplier = INVALID_HANDLE; - -/** -Create global enable/disable bools so we don't have to check the console variable on every call -*/ -new bool:g_bIsEnabled = true; -new bool:g_bIsJoinSoundEnabled = true; -new bool:g_bIsJoinPubMsgEnabled = true; -new bool:g_bIsJoinPrivMsgEnabled = true; -new bool:g_bIsChatColorsEnabled = true; -new bool:g_bIsImmuntyEnabled = true; -new bool:g_bIsUberChargeEnabled = true; -new bool:g_bIsGiveHealthEnabled = true; -new bool:g_bIsNoFallDmgEnabled = true; -new bool:g_bIsFastHeayEnabled = true; -new bool:g_bIsSwapTeamEnabled = true; - -/** - Player arrays - */ -new g_aPlayers[MAXPLAYERS + 1][PlayerData]; - - -/** -Rest of the globals -*/ -new bool:g_bRoundEnd = false; -new String:g_sCharDonatorFlag[5]; -new String:g_sSoundFile[PLATFORM_MAX_PATH]; -new String:g_sChatColor[11]; -new g_iHealthBonus; -new g_iHealthCount; -new g_iClassMaxHealth[TFClassType] = {0, 125, 125, 200, 175, 150, 300, 175, 125, 125}; -new g_fClassMaxSpeed[TFClassType] = {0, 400, 300, 240, 280, 320, 230, 300, 300, 300}; -new Float:g_fHeavyMultiplier = 0.0; -new Float:g_fUberLevel = 0.0; - -public Plugin:myinfo = -{ - name = "Simple Donation Benefits", - author = "Simple Plugins", - description = "Gives donators benefits to players", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -} - -public OnPluginStart() -{ - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook the game events - */ - LogAction(0, -1, "[SDB] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_connect", HookPlayerSpawn, EventHookMode_Pre); - HookEvent("player_spawn", HookPlayerSpawn, EventHookMode_Post); - HookEvent("player_death", HookPlayerDeath, EventHookMode_Post); - HookEvent("player_team", HookPlayerChangeTeam, EventHookMode_Post); - switch (g_CurrentMod) - { - case GameType_TF: - { - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - HookEvent("player_changeclass", HookPlayerClass, EventHookMode_Post); - } - case GameType_DOD: - { - HookEvent("dod_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_Post); - } - default: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - } - } - - /** - Create console variables - */ - CreateConVar("sdb_version", PLUGIN_VERSION, "Simple Donation Benefits", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - sdb_enabled = CreateConVar("sdb_enabled", "1", "Enable/Disable Simple Donation Benefits"); - sdb_donationflag = CreateConVar("sdb_donationflag", "a", "Flag ALREADY given to donators. Must be in char format"); - - /** - Create the enable/disable donator console variables - */ - sdb_joinsound_enabled = CreateConVar("sdb_joinsound_enabled", "1", "Enable/Disable donator join sound"); - sdb_joinpubmsg_enabled = CreateConVar("sdb_joinpubmsg_enabled", "1", "Enable/Disable public donator join message (replaces: as connected)"); - sdb_joinprivmsg_enabled = CreateConVar("sdb_joinprivmsg_enabled", "1", "Enable/Disable private donator join message (sent only to donator)"); - sdb_chatcolors_enabled = CreateConVar("sdb_chatcolors_enabled", "1", "Enable/Disable donator chat colors"); - sdb_immunity_enabled = CreateConVar("sdb_immunity_enabled", "1", "Enable/Disable donator round end immunity"); - sdb_ubercharge_enabled = CreateConVar("sdb_ubercharge_enabled", "1", "Enable/Disable donator medics starting with ubercharge"); - sdb_givehealth_enabled = CreateConVar("sdb_givehealth_enabled", "1", "Enable/Disable donator instant health bonus"); - sdb_nofalldmg_enabled = CreateConVar("sdb_nofalldmg_enabled", "1", "Enable/Disable no fall damage for donators"); - sdb_fastheavy_enabled = CreateConVar("sdb_fastheavy_enabled", "1", "Enable/Disable donator heavies moving faster while spinning"); - sdb_swapteam_enabled = CreateConVar("sdb_swampteam_enabled", "1", "Enable/Disable donator swap team ability"); - - /** - Create the donator setting console variables - */ - sdb_soundfile = CreateConVar("sdb_soundfile", "custom/donatorjoin.mp3", "The location of sound file"); - sdb_chatcolor = CreateConVar("sdb_chatcolor", "green", "Color to use for donator chat. Valid colors are green and lightgreen"); - sdb_uberlevel = CreateConVar("sdb_uberlevel", "0.5", "Uberlevel to give donator medic at spawn. 1.0 = full uber", _, true, 0.0, true, 1.0); - sdb_healthcount = CreateConVar("sdb_healthcount", "1", "Number of times a donator can use use instant health per life"); - sdb_healthbonus = CreateConVar("sdb_healthbonus", "100", "The amount of health to heal the donator"); - sdb_heavymultiplier = CreateConVar("sdb_heavyspeed", "0.5", "The speed multiplier for the fast heavy. Based on running speed. 1.0 = running speed. (Game Default is 0.20)", _, true, 0.0, true, 1.0); - - /** - Hook dukehacks calls - */ - dhAddClientHook(CHK_TakeDamage, Hacks_TakeDamageHook); - dhAddClientHook(CHK_PreThink, Hacks_PreThinkHook); - - /** - Hook the console variables if they change - */ - HookConVarChange(sdb_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_donationflag, ConVarSettingsChanged); - HookConVarChange(sdb_joinsound_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_joinpubmsg_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_joinprivmsg_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_chatcolors_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_immunity_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_ubercharge_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_givehealth_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_nofalldmg_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_swapteam_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_fastheavy_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_soundfile, ConVarSettingsChanged); - HookConVarChange(sdb_chatcolor, ConVarSettingsChanged); - HookConVarChange(sdb_uberlevel, ConVarSettingsChanged); - HookConVarChange(sdb_healthcount, ConVarSettingsChanged); - HookConVarChange(sdb_healthbonus, ConVarSettingsChanged); - HookConVarChange(sdb_heavymultiplier, ConVarSettingsChanged); - - /** - Register the commands - */ - RegConsoleCmd("sm_swapteams", Command_SwapTeam, "sm_swapteams <[0]instant/[1]queued>: Swaps your team to the other team"); - RegConsoleCmd("sm_ihealth", Command_InstantHealth, "sm_ihealth: Gives you a instant health pack"); - RegAdminCmd("sm_teaser", Command_Teaser, ADMFLAG_GENERIC,"sm_teaser <[0]add/[1]remove>: Gives temporary donator privilages to a player"); - RegConsoleCmd("say", Command_Say); - - RegConsoleCmd("sm_test", Command_TEST); - - /** - Load the translations - */ - LoadTranslations("common.phrases"); - LoadTranslations("simpledonatorbenefits.phrases"); - - /** - Load or create the config file - */ - AutoExecConfig(true, "plugin.simpledonatorbenefits"); - LogAction(0, -1, "[SDB] Simple Donator Benefits is loaded."); -} - -public OnAllPluginsLoaded() -{ - //something -} - -public OnLibraryRemoved(const String:name[]) -{ - //something -} - -public OnConfigsExecuted() -{ - /** - Load up all the variable defaults - */ - LoadUpVariables(); - - /** - If the join sound is enabled, prep the sound files - */ - if (g_bIsJoinSoundEnabled) - PrepSoundFile(); - - /** - Log our activity - */ - if (g_bIsEnabled) - LogAction(0, -1, "Simple Donation Benefits is ENABLED"); - else - LogAction(0, -1, "Simple Donation Benefits is DISABLED"); -} - -public OnClientPostAdminCheck(client) -{ - - /** - Check if the client is a donator - */ - if (SM_IsValidAdmin(client, g_sCharDonatorFlag)) - { - - /** - They are, so we set the player array to true and start a timer for the sound or add - */ - g_aPlayers[client][bIsDonator] = true; - if (g_bIsJoinSoundEnabled || g_bIsJoinPrivMsgEnabled) - { - CreateTimer(10.0, Timer_DonatorJoined, client, TIMER_FLAG_NO_MAPCHANGE); - } - } - else - { - /** - They aren't, so we set the player array to false - */ - g_aPlayers[client][bIsDonator] = false; - } -} - -public OnClientDisconnect_Post(client) -{ - - /** - Clean up the player variables - */ - CleanUpPlayer(client); -} - -public Action:Command_SwapTeam(client, args) -{ - - /** - Make sure we are enabled - */ - if (!g_bIsEnabled || !g_bIsSwapTeamEnabled) - { - return Plugin_Handled; - } - - /** - Make sure the command is not started by the server - */ - if (client == 0) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "PlayerLevelCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Make sure the player is a donator - */ - if (!g_aPlayers[client][bIsDonator]) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Lets make sure the client is one a team we can swap. - If he is we set the global array to the opposite team. - */ - new iTeam = GetClientTeam(client); - if (iTeam == g_aCurrentTeams[Team1]) - { - g_aPlayers[client][iNewTeam] = g_aCurrentTeams[Team2]; - } - else if (iTeam == g_aCurrentTeams[Team2]) - { - g_aPlayers[client][iNewTeam] = g_aCurrentTeams[Team1]; - } - else - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "InValidTeam", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check to see if we have command arguments. - */ - if (GetCmdArgs()) - { - - /** - We do, so lets get it and see if the client wants to be switched instantly or queued for death. - */ - decl String:sArg[5]; - GetCmdArg(1, sArg, sizeof(sArg)); - new iWantsQue = StringToInt(sArg); - if (iWantsQue && !g_aPlayers[client][bQueue]) - { - - /** - He wants the que and isn't already in it, set the global array. - */ - g_aPlayers[client][bQueue] = true; - ReplyToCommand(client, "\x01\x04[STM]\x01 %T", "PlayerQueue", LANG_SERVER); - } - else if (!iWantsQue) - { - - /** - He wants to be switched right now, lets call the stock function. - */ - SM_MovePlayer(client, g_aPlayers[client][iNewTeam]); - } - } - else - { - - /** - There are no command arguments so we build and display the swap menu. - */ - new Handle:hPlayerMenu = BuildSwapModeMenu(); - DisplayMenu(hPlayerMenu, client, MENU_TIME_FOREVER); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_InstantHealth(client, args) -{ - - /** - Make sure we are enabled - */ - if (!g_bIsEnabled || !g_bIsGiveHealthEnabled) - { - return Plugin_Handled; - } - - /** - Make sure the command is not started by the server - */ - if (client == 0) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "PlayerLevelCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Make sure the player is a donator - */ - if (!g_aPlayers[client][bIsDonator]) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check health count to see if the player has reached the max - */ - if (g_aPlayers[client][iHealthCount] >= g_iHealthCount) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "ReachedCount", LANG_SERVER); - return Plugin_Handled; - } - - /** - Get the class of the player and the max health for that class - */ - new iHealth = GetClientHealth(client); - new TFClassType:PlayerClass = TF2_GetPlayerClass(client); - new iMaxHealth = g_iClassMaxHealth[PlayerClass]; - - /** - Check to see if the player is at the max health of the class - */ - if (iHealth >= iMaxHealth) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "AtMaxHealth", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check the current health - */ - if (iHealth + g_iHealthBonus >= iMaxHealth) - { - - /** - Raise them to max health if the current health + bonus would go above it - */ - SetEntityHealth(client, iMaxHealth); - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "ToMaxHealth", LANG_SERVER); - } - else - { - - /** - Give them the instant health bonus - */ - SetEntityHealth(client, iHealth + g_iHealthBonus); - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "HealthBonus", LANG_SERVER); - } - - /** - Increase the count - */ - g_aPlayers[client][iHealthCount] += 1; - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_Teaser(client, args) -{ - - /** - Make sure we are enabled - */ - if (!g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - Check to see if we have command arguments. - */ - new iCmdArgs = GetCmdArgs(); - if (iCmdArgs == 0) - { - - /** - We don't so display the player menu. - */ - new Handle:hPlayerMenu = BuildPlayerMenu(); - DisplayMenu(hPlayerMenu, client, MENU_TIME_FOREVER); - return Plugin_Handled; - } - - /** - We have some arguments, see if we can find the player - */ - decl String:sPlayer[64]; - GetCmdArg(1, sPlayer, sizeof(sPlayer)); - new iTarget = FindTarget(client, sPlayer, true, true); - if (iTarget == -1 || !IsClientInGame(iTarget)) - { - - /** - We don't know who this is, so display the player menu. - */ - new Handle:hPlayerMenu = BuildPlayerMenu(); - DisplayMenu(hPlayerMenu, client, MENU_TIME_FOREVER); - } - else - { - /** - We found the player, see if we are supposed to turn it on or off. - */ - if (iCmdArgs >= 2) - { - decl String:sOn[3]; - GetCmdArg(2, sOn, sizeof(sOn)); - if (StringToInt(sOn)) - { - - /** - Turn temp benefits on. - */ - g_aPlayers[iTarget][bIsDonator] = true; - } - else - { - - /** - Turn temp benefits on. - */ - g_aPlayers[iTarget][bIsDonator] = false; - } - } - else - { - - /** - We don't know what to do, so just turn it on. - */ - g_aPlayers[iTarget][bIsDonator] = true; - } - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_Say(client, args) -{ - - /** - Make sure we are enabled. - */ - if (client == 0 || IsChatTrigger() || !g_bIsChatColorsEnabled || !g_bIsEnabled) - { - return Plugin_Continue; - } - - /** - Check the client to see if they are a donator. - */ - if (g_aPlayers[client][bIsDonator]) - { - - /** - The client is, so get the chat message and strip it down. - */ - decl String:sArg[CHAT_MAX_MESSAGE_LENGTH], - String:sChatMsg[CHAT_MAX_MESSAGE_LENGTH]; - new bool:bAlive = IsPlayerAlive(client); - GetCmdArgString(sArg, sizeof(sArg)); - StripQuotes(sArg); - TrimString(sArg); - new startidx; - if (sArg[strlen(sArg)-1] == '"') - { - sArg[strlen(sArg)-1] = '\0'; - startidx = 1; - } - - /** - Bug out if they are using the admin chat symbol (admin chat). - */ - if (sArg[startidx] == CHAT_SYMBOL) - { - return Plugin_Continue; - } - - /** - Format the message. - */ - FormatMessage(client, 0, bAlive, sChatMsg, sArg); - - /** - Send the message. - */ - SayText2(0, client, sChatMsg); - - /** - We are done, bug out, and stop the original chat message. - */ - return Plugin_Stop; - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -public Action:Hacks_TakeDamageHook(client, attacker, inflictor, Float:damage, &Float:multiplier, damagetype) -{ - - /** - Make sure we are enabled and the client is a donator. - */ - if (g_bIsEnabled && g_bIsNoFallDmgEnabled && g_aPlayers[client][bIsDonator]) - { - - /** - Check for fall damage. - */ - if (damagetype & DMG_FALL) - { - - /** - Cancel the fall damage and bug out. - */ - multiplier *= 0.0; - return Plugin_Changed; - } - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -public Action:Hacks_PreThinkHook(client) -{ - - /** - Make sure we are enabled and the client is a donator. - */ - if (!g_bIsEnabled || !g_bIsFastHeayEnabled || !g_aPlayers[client][bIsDonator]) - { - return Plugin_Continue; - } - - /** - Check the players class. We are looking for the heavy. - */ - new TFClassType:PlayerClass = TF2_GetPlayerClass(client); - if (PlayerClass == TFClass_Heavy) - { - - /** - We have a heavy, lets check the weapon. - */ - decl String:sWeaponCurrent[64]; - GetClientWeapon(client, sWeaponCurrent, sizeof(sWeaponCurrent)); - if (StrEqual(sWeaponCurrent, "tf_weapon_minigun", false)) - { - - /** - We have a minigun, check the heavies current weapon state to see if it's spinning. - */ - new iWeapon = GetPlayerWeaponSlot(client, 0); - new iWeaponState = GetEntProp(iWeapon, Prop_Send, "m_iWeaponState"); - if (iWeaponState > 0) - { - - /** - He is spinning, so lets change the heavies speed. - */ - new Float:fMaxSpeed = FloatMul(g_fHeavyMultiplier, float(g_fClassMaxSpeed[PlayerClass])); - SetEntPropFloat(client, Prop_Send, "m_flMaxspeed", fMaxSpeed); - } - } - } - - /** - We are done, bug out. - */ - // use Plugin_Continue (other options are ignored on PreThink hook) - return Plugin_Continue; -} - -public Action:HookPlayerConnect(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Make sure we are enabled. - */ - if (!g_bIsEnabled || !g_bIsJoinPubMsgEnabled || !dontBroadcast) - { - return Plugin_Continue; - } - - /** - Get our event variables and check the client. - */ - new iUserId = GetEventInt(event,"userid"); - new iClient = GetClientOfUserId(iUserId); - if (iClient != 0) - { - - /** - Get the info on the client and format the message. - */ - decl String:sClientName[255], - String:sAuthID[255], - String:sMsg[1024]; - - GetEventString(event, "name", sClientName, sizeof(sClientName)); - GetClientAuthString(iClient, sAuthID, sizeof(sAuthID)); - Format(sMsg, sizeof(sMsg), "%T", "PublicJoinMessage", LANG_SERVER, sClientName); - - /** - Print the message to the clients and do the normal functions. - */ - for (new i = 1; i <= MaxClients; i++) - { - if(IsClientConnected(i) && IsClientInGame(i)) - { - PrintToChat(i,"\x01\x05%s", sMsg); - PrintToConsole(i,"%s has connected.", sClientName); - } - } - LogToGame("\"%s<%d><%s><>\" entered the game", sClientName, iUserId, sAuthID); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public HookPlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled && g_bIsUberChargeEnabled) - { - - /** - Get the event variables and check the class for medic - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - if (TF2_GetPlayerClass(iClient) == TFClass_Medic) - { - - /** - Start a timer to get the medic the uber boost - */ - CreateTimer(0.25, Timer_PlayerUberDelay, iClient, TIMER_FLAG_NO_MAPCHANGE); - } - } -} - -public HookPlayerClass(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled && g_bIsUberChargeEnabled) - { - - /** - Get the event variables and check the class for medic - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - if (TF2_GetPlayerClass(iClient) == TFClass_Medic) - { - - /** - Start a timer to get the medic the uber boost - */ - CreateTimer(0.25, Timer_PlayerUberDelay, iClient, TIMER_FLAG_NO_MAPCHANGE); - } - } -} - -public HookPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled || g_bIsSwapTeamEnabled) - { - - /** - Get the event variables - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - new String:sWeapon[256]; - GetEventString(event, "weapon", sWeapon, sizeof(sWeapon)); - - /** - Bug out if world killed him. Means he changed team or something - */ - if (StrEqual(sWeapon, "world", false)) - { - g_aPlayers[iClient][bQueue] = false; - return; - } - - /** - If he is queued up, swap him - */ - if (g_aPlayers[iClient][bQueue]) - { - SM_MovePlayer(iClient, g_aPlayers[iClient][iNewTeam]); - } - } -} - -public HookPlayerChangeTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled || g_bIsSwapTeamEnabled) - { - - /** - Get the event variables - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - - /** - If he is queued up, clear the status - */ - if (g_aPlayers[iClient][bQueue]) - { - g_aPlayers[iClient][bQueue] = false; - } - } -} - -public HookRoundStart(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Set our variables. - */ - g_bRoundEnd = false; - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled && g_bIsImmuntyEnabled) - { - - /** - Get rid of their immunity. - */ - ProcessRoundEndImmunity(false); - } -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Set our variables. - */ - g_bRoundEnd = true; - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled && g_bIsImmuntyEnabled) - { - - /** - Give them their immunity. - */ - ProcessRoundEndImmunity(true); - } -} - -public Action:Timer_DonatorJoined(Handle:timer, any:client) -{ - - /** - Make sure sounds are enabled. - */ - if (g_bIsEnabled && g_bIsJoinSoundEnabled) - { - EmitSoundToClient(client, g_sSoundFile); - } - - /** - Make sure private messages are enabled. - */ - if (g_bIsJoinPrivMsgEnabled) - { - - /** - Send messages to the client. - */ - decl String:sMsg[1024]; - Format(sMsg, sizeof(sMsg), "%T", "PrivateJoinMessage", LANG_SERVER); - PrintToChat(client,"\x01\x05%s", sMsg); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Timer_PlayerUberDelay(Handle:timer, any:client) -{ - - /** - Make sure the client is still in game. - */ - if (IsClientInGame(client)) - { - - /** - Make sure the client is still a medic. - */ - if (TF2_GetPlayerClass(client) == TFClass_Medic) - { - - /** - Get the medgun weapon index - */ - new iIndex = GetPlayerWeaponSlot(client, 1); - if (iIndex > 0) - { - - /** - Set the uber level with the bonus. - */ - SetEntPropFloat(iIndex, Prop_Send, "m_flChargeLevel", g_fUberLevel); - } - } - } -} - -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (convar == sdb_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsEnabled = false; - } - else - { - g_bIsEnabled = true; - } - } - else if (convar == sdb_donationflag) - { - Format(g_sCharDonatorFlag, sizeof(g_sCharDonatorFlag), "%s", newValue); - } - else if (convar == sdb_soundfile) - { - Format(g_sSoundFile, sizeof(g_sSoundFile), "%s", newValue); - } - else if (convar == sdb_joinsound_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsJoinSoundEnabled = false; - } - else - { - g_bIsJoinSoundEnabled = true; - } - } - else if (convar == sdb_joinpubmsg_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsJoinPubMsgEnabled = false; - } - else - { - g_bIsJoinPubMsgEnabled = true; - } - } - else if (convar == sdb_joinprivmsg_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsJoinPrivMsgEnabled = false; - } - else - { - g_bIsJoinPrivMsgEnabled = true; - } - } - else if (convar == sdb_chatcolors_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsChatColorsEnabled = false; - } - else - { - g_bIsChatColorsEnabled = true; - } - } - else if (convar == sdb_immunity_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsImmuntyEnabled = false; - } - else - { - g_bIsImmuntyEnabled = true; - } - } - else if (convar == sdb_ubercharge_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsUberChargeEnabled = false; - } - else - { - g_bIsUberChargeEnabled = true; - } - } - else if (convar == sdb_givehealth_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsGiveHealthEnabled = false; - } - else - { - g_bIsGiveHealthEnabled = true; - } - } - else if (convar == sdb_nofalldmg_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsNoFallDmgEnabled = false; - } - else - { - g_bIsNoFallDmgEnabled = true; - } - } - else if (convar == sdb_fastheavy_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsFastHeayEnabled = false; - } - else - { - g_bIsFastHeayEnabled = true; - } - } - else if (convar == sdb_swapteam_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsSwapTeamEnabled = false; - } - else - { - g_bIsSwapTeamEnabled = true; - } - } - else if (convar == sdb_chatcolor) - { - Format(g_sChatColor, sizeof(g_sChatColor), "%s", newValue); - } - else if (convar == sdb_uberlevel) - { - g_fUberLevel = StringToFloat(newValue); - } - else if (convar == sdb_healthcount) - { - g_iHealthCount = StringToInt(newValue); - } - else if (convar == sdb_healthbonus) - { - g_iHealthBonus = StringToInt(newValue); - } - else if (convar == sdb_heavymultiplier) - { - g_fHeavyMultiplier = StringToFloat(newValue); - } -} - -stock LoadUpVariables() -{ - g_bIsEnabled = GetConVarBool(sdb_enabled); - g_bIsJoinSoundEnabled = GetConVarBool(sdb_enabled); - g_bIsJoinPubMsgEnabled = GetConVarBool(sdb_enabled); - g_bIsJoinPrivMsgEnabled = GetConVarBool(sdb_enabled); - g_bIsChatColorsEnabled = GetConVarBool(sdb_enabled); - g_bIsImmuntyEnabled = GetConVarBool(sdb_enabled); - g_bIsUberChargeEnabled = GetConVarBool(sdb_enabled); - g_bIsGiveHealthEnabled = GetConVarBool(sdb_enabled); - g_bIsNoFallDmgEnabled = GetConVarBool(sdb_enabled); - g_bIsFastHeayEnabled = GetConVarBool(sdb_enabled); - g_bIsSwapTeamEnabled = GetConVarBool(sdb_enabled); - GetConVarString(sdb_donationflag, g_sCharDonatorFlag, sizeof(g_sCharDonatorFlag)); - GetConVarString(sdb_soundfile, g_sSoundFile, sizeof(g_sSoundFile)); - GetConVarString(sdb_chatcolor, g_sChatColor, sizeof(g_sChatColor)); - g_bRoundEnd = false; - g_iHealthBonus = GetConVarInt(sdb_healthbonus); - g_iHealthCount = GetConVarInt(sdb_healthcount); - g_fHeavyMultiplier = GetConVarFloat(sdb_heavymultiplier); - g_fUberLevel = GetConVarFloat(sdb_uberlevel); -} - -stock PrepSoundFile() -{ - decl String:buffer[PLATFORM_MAX_PATH]; - PrecacheSound(g_sSoundFile, true); - Format(buffer, sizeof(buffer), "sound/%s", g_sSoundFile); - AddFileToDownloadsTable(buffer); -} - -stock CleanUpPlayer(client) -{ - g_aPlayers[client][bIsDonator] = false; - g_aPlayers[client][bQueue] = false; - g_aPlayers[client][bImmune] = false; - g_aPlayers[client][iNewTeam] = 0; - g_aPlayers[client][iHealthCount] = 0; -} - -stock ProcessRoundEndImmunity(bool:give) -{ - for (new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][bIsDonator]) - { - if (give) - { - SetEntProp(i, Prop_Data, "m_takedamage", 0, 1); - g_aPlayers[i][bImmune] = true; - } - else - { - SetEntProp(i, Prop_Data, "m_takedamage", 2, 1); - g_aPlayers[i][bImmune] = false; - } - } - } -} - -stock FormatMessage(iClient, iTeam, bool:bAlive, String:sChatMsg[], const Sting:sMessage[]) -{ - decl String:sDead[10], - String:sTeam[10], - String:sClientName[64]; - GetClientName(iClient, sClientName, sizeof(sClientName)); - if (iTeam != 0) - Format(sTeam, sizeof(sTeam), "(TEAM) "); - else - Format(sTeam, sizeof(sTeam), ""); - if (bAlive) - Format(sDead, sizeof(sDead), ""); - else - Format(sDead, sizeof(sDead), "*DEAD* "); - if (StrContains(g_sChatColor, "light", false) == -1) - Format(sChatMsg, CHAT_MAX_MESSAGE_LENGTH, "\x01%s%s\x03%s \x01: \x05%s", sDead, sTeam, sClientName, sMessage); - else - Format(sChatMsg, CHAT_MAX_MESSAGE_LENGTH, "\x01%s%s\x03%s \x01: \x04%s", sDead, sTeam, sClientName, sMessage); -} - -stock SayText2(target, author, const String:message[]) -{ - new Handle:hBf; - if (target == 0) - hBf = StartMessageAll("SayText2"); - else - hBf = StartMessageOne("SayText2", target); - if (hBf != INVALID_HANDLE) - { - BfWriteByte(hBf, author); - BfWriteByte(hBf, true); - BfWriteString(hBf, message); - EndMessage(); - } -} - -stock ProcessAdmins() -{ - for (new i = 1; i <= MaxClients; i++) - { - if (SM_IsValidAdmin(i, g_sCharDonatorFlag)) - { - g_aPlayers[i][bDonator] = true; - } - else - { - g_aPlayers[i][bDonator] = false; - } - } -} - -stock ProcessLate() -{ - if (g_bIsEnabled) - { - ProcessAdmins(); - PrepSoundFile(); - if (g_bRoundEnd && g_bIsImmuntyEnabled) - { - ProcessRoundEndImmunity(true); - } - if (!g_bIsImmuntyEnabled) - { - ProcessRoundEndImmunity(false); - } - } - else - { - ProcessRoundEndImmunity(false); - } -} - -public Menu_SwapMode(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, 64); - if (StringToInt(sSelection)) - g_aPlayers[param1][bQueue] = false; - else - g_aPlayers[param1][bQueue] = true; - if (!g_aPlayers[param1][bQueue]) - SM_MovePlayer(param1, g_aPlayers[param1][iNewTeam]); - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -public Menu_SelectPlayer(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[256]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - new iTarget = GetClientOfUserId(StringToInt(sSelection)); - if (g_aPlayers[iTarget][bIsDonator]) - g_aPlayers[iTarget][bIsDonator] = false; - else - g_aPlayers[iTarget][bIsDonator] = true; - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -stock Handle:BuildSwapModeMenu() -{ - new Handle:menu = CreateMenu(Menu_SwapMode); - SetMenuTitle(menu, "Select When to Swap:"); - AddMenuItem(menu, "0", "Instantly (Kills)"); - AddMenuItem(menu, "1", "Queue on next death"); - SetMenuExitBackButton(menu, false); - return menu; -} - -stock Handle:BuildPlayerMenu() -{ - new Handle:menu = CreateMenu(Menu_SelectPlayer); - AddTargetsToMenu(menu, 0, true, false); - SetMenuTitle(menu, "Select A Player:"); - SetMenuExitBackButton(menu, true); - return menu; -} - -public Action:Command_TEST(client, args) -{ - -} \ No newline at end of file diff --git a/Simple Round Immunity/addons/sourcemod/scripting/simple-messagesuppression.sp b/Simple Round Immunity/addons/sourcemod/scripting/simple-messagesuppression.sp deleted file mode 100644 index f7725a4..0000000 --- a/Simple Round Immunity/addons/sourcemod/scripting/simple-messagesuppression.sp +++ /dev/null @@ -1,227 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Message Suppression -Description: - Blocks Specific Message Outputs -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include -#include - -#define SUPPRESS_VERSION "1.1.$Rev$" - -public Plugin:myinfo = -{ - name = "Simple Message Suppression", - author = "FlyingMongoose, psychonic", - description = "Blocks Specific Message Outputs", - version = SUPPRESS_VERSION, - url = "http://www.simple-plugins.com/" -} - -new Handle:cvarBlockSpectateMessage; -new Handle:cvarBlockDisconnectMessage; -new Handle:cvarBlockConnectMessage; -new Handle:cvarAdminShowMessages; -new iSpecTeam = 1; - - -public OnPluginStart() -{ - CreateConVar("suppress_version", SUPPRESS_VERSION, _, FCVAR_PLUGIN|FCVAR_NOTIFY|FCVAR_REPLICATED|FCVAR_SPONLY|FCVAR_DONTRECORD); - cvarBlockSpectateMessage = CreateConVar("sm_blockspectatemessage", "1", "If enabled it blocks the join team message if an administrator joins spectator", FCVAR_PLUGIN, true, 0.0, true, 1.0); - cvarBlockDisconnectMessage = CreateConVar("sm_blockdisconnectmessage", "1", "Blocks the disconnect message", FCVAR_PLUGIN, true, 0.0, true, 1.0); - cvarBlockConnectMessage = CreateConVar("sm_blockconnectmessage", "1", "If enabled it blocks the player connection message.", FCVAR_PLUGIN, true, 0.0, true, 1.0); - cvarAdminShowMessages = CreateConVar("sm_adminshowmessages", "1", "Shows disconnect/connect/team join messages for admins only (if disconnect message is set to be blocked)", FCVAR_PLUGIN, true, 0.0, true, 1.0); - HookEvent("player_team", ev_PlayerTeam, EventHookMode_Pre); - HookEvent("player_disconnect", ev_PlayerDisconnect, EventHookMode_Pre); - HookEvent("player_connect", ev_PlayerConnect, EventHookMode_Pre); - - new String:game_folder[64]; - GetGameFolderName(game_folder, sizeof(game_folder)) - - if (StrContains(game_folder, "insurgency", false) != -1) - { - iSpecTeam = 3; - } - else - { - new String:game_description[64]; - GetGameDescription(game_description, sizeof(game_description), true); - if (StrContains(game_description, "Insurgency", false) != -1) - { - iSpecTeam = 3; - } - } - - AutoExecConfig(true, "suppressmessage", "sourcemod"); -} - -public Action:ev_PlayerTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - if (GetConVarBool(cvarBlockSpectateMessage)) - { - if (!dontBroadcast && !GetEventBool(event, "silent")) - { - new iUserId = GetEventInt(event, "userid"); - new iClient = GetClientOfUserId(iUserId); - new iTeam = GetEventInt(event, "team"); - - if (iTeam == iSpecTeam && GetAdminFlag(GetUserAdmin(iClient), Admin_Kick)) - { - new iOldTeam = GetEventInt(event, "oldteam"); - new bool:bDisconnect = GetEventBool(event, "disconnect"); - new bool:bAutoteam = GetEventBool(event, "autoteam"); - decl String:strName[50]; - GetEventString(event, "name", strName, sizeof(strName)); - - if (iClient != 0) - { - if (GetConVarInt(cvarAdminShowMessages) == 1) - { - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientConnected(i) && IsClientInGame(i) && GetUserAdmin(i) != INVALID_ADMIN_ID) - { - PrintToChat(i,"%N joined team Spectator.", iClient); - PrintToConsole(i,"%N joined team Spectator.", iClient); - } - } - } - } - - new Handle:hEvent = CreateEvent("player_team"); - SetEventInt(hEvent, "userid", iUserId); - SetEventInt(hEvent, "team", iTeam); - SetEventInt(hEvent, "oldteam", iOldTeam); - SetEventBool(hEvent, "disconnect", bDisconnect); - SetEventBool(hEvent, "autoteam", bAutoteam); - SetEventBool(hEvent, "silent", true); - SetEventString(hEvent, "name", strName); - - FireEvent(hEvent, true); - - return Plugin_Handled; - } - } - } - return Plugin_Continue; -} -public Action:ev_PlayerConnect(Handle:event, const String:name[], bool:dontBroadcast) -{ - if (GetConVarBool(cvarBlockConnectMessage)) - { - if (!dontBroadcast) - { - decl String:strName[50]; - GetEventString(event, "name", strName, sizeof(strName)); - new iIndex = GetEventInt(event, "index"); - new iUserId = GetEventInt(event, "userid"); - new iClient = GetClientOfUserId(iUserId); - decl String:strNetworkId[50]; - GetEventString(event, "networkid", strNetworkId, sizeof(strNetworkId)); - decl String:strAddress[50]; - GetEventString(event, "address", strAddress, sizeof(strAddress)); - - if (iClient != 0) - { - if (GetConVarInt(cvarAdminShowMessages) == 1) - { - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientConnected(i) && IsClientInGame(i) && GetUserAdmin(i) != INVALID_ADMIN_ID) - { - PrintToChat(i,"%N has connected.", iClient); - PrintToConsole(i,"%N has connected.", iClient); - } - } - } - } - - new Handle:hEvent = CreateEvent("player_connect"); - SetEventString(hEvent, "name", strName); - SetEventInt(hEvent, "index", iIndex); - SetEventInt(hEvent, "userid", iUserId); - SetEventString(hEvent, "networkid", strNetworkId); - SetEventString(hEvent, "address", strAddress); - - FireEvent(hEvent, true); - - return Plugin_Handled; - } - } - return Plugin_Continue; -} -public Action:ev_PlayerDisconnect(Handle:event, const String:name[], bool:dontBroadcast) -{ - if (GetConVarBool(cvarBlockDisconnectMessage)) - { - if (!dontBroadcast) - { - new iUserId = GetEventInt(event, "userid"); - new iClient = GetClientOfUserId(iUserId); - decl String:strReason[50]; - GetEventString(event, "reason", strReason, sizeof(strReason)); - decl String:strName[50]; - GetEventString(event, "name", strName, sizeof(strName)); - decl String:strNetworkId[50]; - GetEventString(event, "networkid", strNetworkId, sizeof(strNetworkId)); - - if (iClient != 0) - { - if (GetConVarInt(cvarAdminShowMessages) == 1) - { - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientConnected(i) && IsClientInGame(i) && GetUserAdmin(i) != INVALID_ADMIN_ID) - { - PrintToChat(i, "%N has left the server.", iClient); - PrintToConsole(i, "Dropped %N from server (Disconnect by user.)", iClient); - } - } - } - } - - new Handle:hEvent = CreateEvent("player_disconnect"); - SetEventInt(hEvent, "userid", iUserId); - SetEventString(hEvent, "reason", strReason); - SetEventString(hEvent, "name", strName); - SetEventString(hEvent, "networkid", strNetworkId); - - FireEvent(hEvent, true); - - return Plugin_Handled; - } - } - - return Plugin_Continue; -} \ No newline at end of file diff --git a/Simple Round Immunity/addons/sourcemod/scripting/simple-plugins.sp b/Simple Round Immunity/addons/sourcemod/scripting/simple-plugins.sp deleted file mode 100644 index 4462b41..0000000 --- a/Simple Round Immunity/addons/sourcemod/scripting/simple-plugins.sp +++ /dev/null @@ -1,785 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Plugins -Description: - Core plugin for Simple Plugins project -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#define CORE_PLUGIN_VERSION "1.1.$Rev$" - -#include - -enum e_PlayerInfo -{ - Handle:hForcedTeamPlugin = INVALID_HANDLE, - iForcedTeam = 0, - iBuddy = 0, - bool:bBuddyLocked = false -}; - -new Handle:g_fwdPlayerMoved; -new g_aPlayers[MAXPLAYERS + 1][e_PlayerInfo]; -new bool:g_bTeamsSwitched = false; - -/** -Setting our plugin information. -*/ -public Plugin:myinfo = -{ - name = "Simple Plugins Core Plugin", - author = "Simple Plugins", - description = "Core plugin for Simple Plugins", - version = CORE_PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -}; - -public bool:AskPluginLoad(Handle:myself, bool:late, String:error[], err_max) -{ - - /** - Register natives for other plugins - */ - CreateNative("SM_MovePlayer", Native_SM_MovePlayer); - CreateNative("SM_SetForcedTeam", Native_SM_SetForcedTeam); - CreateNative("SM_GetForcedTeam", Native_SM_GetForcedTeam); - CreateNative("SM_ClearForcedTeam", Native_SM_ClearForcedTeam); - CreateNative("SM_GetForcedPlayer", Native_SM_GetForcedPlayer); - CreateNative("SM_AssignBuddy", Native_SM_AssignBuddy); - CreateNative("SM_GetClientBuddy", Native_SM_GetClientBuddy); - CreateNative("SM_LockBuddy", Native_SM_LockBuddy); - CreateNative("SM_IsBuddyLocked", Native_SM_IsBuddyLocked); - CreateNative("SM_ClearBuddy", Native_SM_ClearBuddy); - CreateNative("SM_IsValidAdmin", Native_SM_IsValidAdmin); - CreateNative("SM_IsValidTeam", Native_SM_IsValidTeam); - RegPluginLibrary("simpleplugins"); - return true; -} - -public OnPluginStart() -{ - - CreateConVar("ssm_core_pl_ver", CORE_PLUGIN_VERSION, "Simple SourceMod Plugins Core Plugin Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - CreateConVar("ssm_core_inc_ver", CORE_INC_VERSION, "Simple SourceMod Plugins Core Include Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook some events to control forced players and check extensions - */ - decl String:sExtError[256]; - LogAction(0, -1, "[SSM] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_team", HookPlayerChangeTeam, EventHookMode_Pre); - switch (g_CurrentMod) - { - case GameType_CSS: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - new iExtStatus = GetExtensionFileStatus("game.cstrike.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SSM] Required extension was not found."); - LogAction(0, -1, "[SSM] Plugin FAILED TO LOAD."); - SetFailState("Required extension was not found."); - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SSM] Required extension is loaded with errors."); - LogAction(0, -1, "[SSM] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SSM] Plugin FAILED TO LOAD."); - SetFailState("Required extension is loaded with errors."); - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SSM] Required extension is loaded."); - } - } - case GameType_TF: - { - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_PostNoCopy); - HookUserMessage(GetUserMessageId("TextMsg"), UserMessageHook_Class, true); - new iExtStatus = GetExtensionFileStatus("game.tf2.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SSM] Required extension was not found."); - LogAction(0, -1, "[SSM] Plugin FAILED TO LOAD."); - SetFailState("Required extension was not found."); - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SSM] Required extension is loaded with errors."); - LogAction(0, -1, "[SSM] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SSM] Plugin FAILED TO LOAD."); - SetFailState("Required extension is loaded with errors."); - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SSM] Required extension is loaded."); - } - } - case GameType_DOD: - { - HookEvent("dod_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_PostNoCopy); - } - default: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - } - } - - /** - Load common translations - */ - LoadTranslations ("common.phrases"); - - /** - Create the global forward - */ - g_fwdPlayerMoved = CreateGlobalForward("SM_OnPlayerMoved", ET_Event, Param_Cell, Param_Cell, Param_Cell); -} - -public OnClientDisconnect(client) -{ - - /** - Cleanup clients/players buddy list - */ - if (!IsFakeClient(client)) - { - SM_ClearBuddy(client, true); - SM_LockBuddy(client, false); - } - SM_ClearForcedTeam(client); -} - -public HookRoundStart(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - See if the teams have been switched - */ - if (g_bTeamsSwitched) - { - - /** - Switch the teams the players are forced to - */ - for (new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][iForcedTeam] != 0) - { - if (g_aPlayers[i][iForcedTeam] == g_aCurrentTeams[Team1]) - { - g_aPlayers[i][iForcedTeam] = g_aCurrentTeams[Team2]; - } - else - { - g_aPlayers[i][iForcedTeam] = g_aCurrentTeams[Team1]; - } - } - } - } -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - g_bTeamsSwitched = false; -} - -public HookPlayerChangeTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get our event variables - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - new iTeam = GetEventInt(event, "team"); - - /** - See if the player is on the wrong team - */ - if (g_aPlayers[iClient][iForcedTeam] != 0 && g_aPlayers[iClient][iForcedTeam] != iTeam) - { - - /** - Move the player back to the forced team - */ - CreateTimer(1.0, Timer_ForcePlayerMove, iClient, TIMER_FLAG_NO_MAPCHANGE); - - /** - If the event was going to be broadcasted, we refire it so it is not broadcasted and stop this one - */ - if (!dontBroadcast) - { - new Handle:hEvent = CreateEvent("player_team"); - SetEventInt(hEvent, "userid", GetEventInt(event, "userid")); - SetEventInt(hEvent, "team", GetEventInt(event, "team")); - SetEventInt(hEvent, "oldteam", GetEventInt(event, "oldteam")); - SetEventBool(hEvent, "disconnect", GetEventBool(event, "disconnect")); - - if (g_CurrentMod == GameType_DOD || g_CurrentMod == GameType_L4D || g_CurrentMod == GameType_TF) - { - new String:sClientName[MAX_NAME_LENGTH + 1]; - GetClientName(client, sClientName, sizeof(sClientName)); - SetEventBool(hEvent, "autoteam", GetEventBool(event, "autoteam")); - SetEventBool(hEvent, "silent", true); - SetEventString(hEvent, "name", sClientName); - FireEvent(hEvent, true); - } - else - { - FireEvent(hEvent, true); - } - return Plugin_Handled; - } - } - return Plugin_Continue; -} - -public Action:UserMessageHook_Class(UserMsg:msg_id, Handle:bf, const players[], playersNum, bool:reliable, bool:init) -{ - new String:sMessage[120]; - BfReadString(bf, sMessage, sizeof(sMessage), true); - if (StrContains(sMessage, "#TF_TeamsSwitched", false) != -1) - { - g_bTeamsSwitched = true; - } - return Plugin_Continue; -} - -public Native_SM_MovePlayer(Handle:plugin, numParams) -{ - - /** - Get and check the client and team - */ - new iClient = GetNativeCell(1); - new iTeam = GetNativeCell(2); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (iTeam != g_aCurrentTeams[Spectator] && iTeam != g_aCurrentTeams[Team1] && iTeam != g_aCurrentTeams[Team2]) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid team %d", iTeam); - } - - MovePlayer(iClient, iTeam); - if (!IsClientObserver(iClient)) - { - RespawnPlayer(iClient); - } - - new fResult; - - Call_StartForward(g_fwdPlayerMoved); - Call_PushCell(plugin); - Call_PushCell(iClient); - Call_PushCell(iTeam); - Call_Finish(fResult); - - if (fResult != SP_ERROR_NONE) - { - return ThrowNativeError(fResult, "Forward failed"); - } - - return fResult; -} - -public Native_SM_SetForcedTeam(Handle:plugin, numParams) -{ - - /** - Get and check the client and team - */ - new iClient = GetNativeCell(1); - new iTeam = GetNativeCell(2); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (iTeam != g_aCurrentTeams[Spectator] && iTeam != g_aCurrentTeams[Team1] && iTeam != g_aCurrentTeams[Team2] && iTeam != g_aCurrentTeams[Unknown]) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid team %d", iTeam); - } - - new bool:bOverRide = GetNativeCell(3) ? true : false; - - if (!bOverRide && g_aPlayers[iClient][hForcedTeamPlugin] != INVALID_HANDLE && plugin != g_aPlayers[iClient][hForcedTeamPlugin]) - { - return false; - } - - g_aPlayers[iClient][hForcedTeamPlugin] = plugin; - g_aPlayers[iClient][iForcedTeam] = iTeam; - return true; -} - -public Native_SM_GetForcedTeam(Handle:plugin, numParams) -{ - - /** - Get and check the client - */ - new iClient = GetNativeCell(1); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - - /** - Get and set the plugin if they want it - */ - new Handle:hPlugin = GetNativeCell(2); - if (hPlugin != INVALID_HANDLE) - { - SetNativeCellRef(2, g_aPlayers[iClient][hForcedTeamPlugin]); - } - - /** - Return the forced team, this could be 0 - */ - return g_aPlayers[iClient][iForcedTeam]; -} - -public Native_SM_ClearForcedTeam(Handle:plugin, numParams) -{ - - /** - Get and check the client and team - */ - new iClient = GetNativeCell(1); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - - g_aPlayers[iClient][hForcedTeamPlugin] = INVALID_HANDLE; - g_aPlayers[iClient][iForcedTeam] = 0; - - return true; -} - -public Native_SM_GetForcedPlayer(Handle:plugin, numParams) -{ - - /** - Get and check the team - */ - new iTeam = GetNativeCell(1); - if (iTeam != g_aCurrentTeams[Spectator] && iTeam != g_aCurrentTeams[Team1] && iTeam != g_aCurrentTeams[Team2]) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid team %d", iTeam); - } - - /** - Start a loop to check for a player on the wrong team - Also make sure the plugin that set the forced team is the plugin that asked - */ - new iPlayer = 0; - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientInGame(i) - && GetClientTeam(i) != g_aPlayers[i][iForcedTeam] - && g_aPlayers[i][iForcedTeam] == iTeam - && g_aPlayers[i][hForcedTeamPlugin] == plugin) - { - iPlayer = i; - break; - } - } - - /** - Return the player we found, this could be 0 - */ - return iPlayer; -} - -public Native_SM_AssignBuddy(Handle:plugin, numParams) -{ - - /** - Get and check the client and player - */ - new iClient = GetNativeCell(1); - new iPlayer = GetNativeCell(2); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (iPlayer < 0 || iPlayer > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid player index (%d)", iPlayer); - } - if (!IsClientConnected(iPlayer)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Player %d is not connected", iPlayer); - } - if (!IsClientInGame(iPlayer)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Player %d is not in the game", iClient); - } - if (IsFakeClient(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Bots are not supported"); - } - - /** - See if we can override his setting - */ - new bool:bOverRide = GetNativeCell(3) ? true : false; - if (!bOverRide) - { - - /** - We can't override, so check if they are locked - */ - if (g_aPlayers[iClient][bBuddyLocked] || g_aPlayers[iPlayer][bBuddyLocked]) - { - - /** - We detected at least 1 lock, so we bug out - */ - return false; - } - } - - /** - Ready to set the buddies - */ - g_aPlayers[iClient][iBuddy] = iPlayer; - g_aPlayers[iPlayer][iBuddy] = iClient; - return true; -} - -public Native_SM_GetClientBuddy(Handle:plugin, numParams) -{ - - /** - Get and check the client - */ - new iClient = GetNativeCell(1); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (IsFakeClient(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Bots are not supported"); - } - - /** - Return the players buddy, this could be 0 - */ - return g_aPlayers[iClient][iBuddy]; -} - -public Native_SM_LockBuddy(Handle:plugin, numParams) -{ - - /** - Get and check the client - */ - new iClient = GetNativeCell(1); - new bool:bSetting = GetNativeCell(2) ? true : false; - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (IsFakeClient(iClient)) - { - return ThrowNativeError(SP_ERROR_NATIVE, "Bots are not supported"); - } - - g_aPlayers[iClient][bBuddyLocked] = bSetting; - return true; -} - -public Native_SM_IsBuddyLocked(Handle:plugin, numParams) -{ - - /** - Get and check the client - */ - new iClient = GetNativeCell(1); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (IsFakeClient(iClient)) - { - return ThrowNativeError(SP_ERROR_NATIVE, "Bots are not supported"); - } - - return g_aPlayers[iClient][bBuddyLocked]; -} - -public Native_SM_ClearBuddy(Handle:plugin, numParams) -{ - - /** - Get and check the client - */ - new iClient = GetNativeCell(1); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_NATIVE, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_NATIVE, "Client (%d) is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (IsFakeClient(iClient)) - { - return ThrowNativeError(SP_ERROR_NATIVE, "Bots are not supported"); - } - - /** - Get the clients buddy and see if we can override his setting - */ - new bool:bOverRide = GetNativeCell(2) ? true : false; - new iPlayer = g_aPlayers[iClient][iBuddy]; - - /** - There is no buddy, we don't care about anything else so bug out - */ - if (iPlayer == 0) - { - return true; - } - - /** - We determined he had a buddy, check the override setting - */ - if (!bOverRide) - { - - /** - We can't override, so check if they are locked - */ - if (g_aPlayers[iClient][bBuddyLocked] || g_aPlayers[iPlayer][bBuddyLocked]) - { - - /** - We detected at least 1 lock, so we bug out - */ - return false; - } - } - - /** - Ready to clear the buddies - */ - g_aPlayers[iClient][iBuddy] = 0; - g_aPlayers[iPlayer][iBuddy] = 0; - return true; -} - -public Native_SM_IsValidTeam(Handle:plugin, numParams) -{ - - /** - Get the team - */ - new iTeam = GetNativeCell(1); - - /** - Check the team - */ - if (iTeam == g_aCurrentTeams[Spectator] || iTeam == g_aCurrentTeams[Team1] || iTeam == g_aCurrentTeams[Team2]) - { - return true; - } - return false; -} - -public Native_SM_IsValidAdmin(Handle:plugin, numParams) -{ - /** - Get the client and flags - */ - new iClient = GetNativeCell(1); - decl String:sFlags[15]; - GetNativeString(2, sFlags, sizeof(sFlags)); - new ibFlags = ReadFlagString(sFlags); - - /** - Check the flags - */ - if ((GetUserFlagBits(iClient) & ibFlags) == ibFlags) - { - return true; - } - if (GetUserFlagBits(iClient) & ADMFLAG_ROOT) - { - return true; - } - return false; -} - -public Action:Timer_ForcePlayerMove(Handle:timer, any:iClient) -{ - - MovePlayer(iClient, g_aPlayers[iClient][iForcedTeam]); - - if (g_aPlayers[iClient][iForcedTeam] != g_aCurrentTeams[Spectator]) - { - RespawnPlayer(iClient); - } - - PrintToChat(iClient, "\x01\x04----------------------------------"); - PrintToChat(iClient, "\x01\x04You have been forced to this team."); - PrintToChat(iClient, "\x01\x04----------------------------------"); - - return Plugin_Handled; -} - -stock MovePlayer(iClient, iTeam) -{ - - /** - Change the client's team based on the mod - */ - switch (g_CurrentMod) - { - case GameType_CSS: - { - CS_SwitchTeam(iClient, iTeam); - } - default: - { - ChangeClientTeam(iClient, iTeam); - } - } -} - -stock RespawnPlayer(iClient) -{ - - /** - Respawn the client based on the mod - */ - switch (g_CurrentMod) - { - case GameType_CSS: - { - CS_RespawnPlayer(iClient); - } - case GameType_TF: - { - TF2_RespawnPlayer(iClient); - } - case GameType_INS: - { - FakeClientCommand(iClient, "kill"); - } - default: - { - // - } - } -} diff --git a/Simple Round Immunity/addons/sourcemod/scripting/simple-spectate.sp b/Simple Round Immunity/addons/sourcemod/scripting/simple-spectate.sp deleted file mode 100644 index 4108f8f..0000000 --- a/Simple Round Immunity/addons/sourcemod/scripting/simple-spectate.sp +++ /dev/null @@ -1,2022 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Spectate -Description: - Spectate a player and follow them through death. -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include -#undef REQUIRE_EXTENSIONS -#undef AUTOLOAD_EXTENSIONS -#tryinclude -#define AUTOLOAD_EXTENSIONS -#define REQUIRE_EXTENSIONS - -#define PLUGIN_VERSION "1.2.1.$Rev$" - -#define SPECMODE_NONE 0 -#define SPECMODE_FIRSTPERSON 4 -#define SPECMODE_3RDPERSON 5 -#define SPECMODE_FREELOOK 6 -#define SPECMODE_CSS_FIRSTPERSON 3 -#define SPECMODE_CSS_3RDPERSON 4 -#define SPECMODE_CSS_FREELOOK 5 - -enum e_CvarHandles -{ - Handle:hHudMode, - Handle:hMenuType, - Handle:hRestrictHud, - Handle:hBan, - Handle:hBanPerm, - Handle:hBeacon, - Handle:hBlind, - Handle:hCheater, - Handle:hDrug, - Handle:hFreeze, - Handle:hFreezeBomb, - Handle:hKick, - Handle:hSlap, - Handle:hSlay, - Handle:hTimeBomb -}; - -enum e_CvarSettings -{ - bool:bHudMode, - bool:bMenuType, - bool:bRestrictHud, - bool:bBan, - bool:bBanPerm, - bool:bBeacon, - bool:bBlind, - bool:bCheater, - bool:bDrug, - bool:bFreeze, - bool:bFreezebomb, - bool:bKick, - bool:bSlap, - bool:bSlay, - bool:bTimeBomb -}; - -enum e_PluginSettings -{ - bool:bUseSteamBans, - bool:bUseSourceBans, - bool:bUseMySQLBans, - bool:bCanHUD, - bool:bUseDukehacks -}; - -enum e_Menus -{ - Handle:hSelectPlayer, - Handle:hBanTime, - Handle:hReason -}; - -enum e_Punishments -{ - Punish_None, - Punish_Ban, - Punish_Beacon, - Punish_Blind, - Punish_Cheater, - Punish_Drug, - Punish_Freeze, - Punish_FreezeBomb, - Punish_Kick, - Punish_Slap, - Punish_Slay, - Punish_TimeBomb -}; - -enum e_PlayerData -{ - bool:bIsDisplayingHud, - bool:bIsFlaggedCheater, - Handle:hHudTimer, - Handle:hTargetTimer, - iTargetIndex, - e_Punishments:TargetPunishment, - iBanTime -}; - -new Handle:sm_spectate_adminflag = INVALID_HANDLE; -new Handle:g_hAdminMenu = INVALID_HANDLE; -new Handle:g_hHud = INVALID_HANDLE; -new Handle:g_aPluginCvar[e_CvarHandles]; -new g_aPluginCvarSettings[e_CvarSettings]; -new g_aPluginSettings[e_PluginSettings]; -new g_aMenus[e_Menus]; -new g_aPlayers[MAXPLAYERS + 1][e_PlayerData]; -new String:g_sAdminFlags[16]; -new String:g_sPunishments[e_Punishments][15] = { "None", "Ban", "Beacon", "Blind", "Cheater", "Drug", "Freeze", "FreezeBomb", "Kick", "Slap", "Slay", "TimeBomb" }; - -public Plugin:myinfo = -{ - name = "Simple Spectate", - author = "Simple Plugins", - description = "Spectate a player and follow them through death.", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -}; - -/** -Sourcemod callbacks -*/ -public OnPluginStart() -{ - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook the game events - */ - LogAction(0, -1, "[SSPEC] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_team", HookPlayerChangeTeam, EventHookMode_Pre); - - /** - Need to create all of our console variables. - */ - CreateConVar("sm_spectate_version", PLUGIN_VERSION, "Sourcemod Spectate", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - g_aPluginCvar[hHudMode] = CreateConVar("sm_spectate_hudmode", "1", "Hud Mode: 0 = Hud Text | 1 = Panel/Menu (NOTE: The panel/menu will override other menus until canceled)"); - g_aPluginCvar[hMenuType] = CreateConVar("sm_spectate_menutype", "0", "Menu Mode: 0 = Panel | 1 = Menu"); - g_aPluginCvar[hRestrictHud] = CreateConVar("sm_spectate_restricthud", "0", "Restrict the hud to the admin flag provided"); - g_aPluginCvar[hBan] = CreateConVar("sm_spectate_ban", "1", "Enable/Disable ban option"); - g_aPluginCvar[hBanPerm] = CreateConVar("sm_spectate_banperm", "1", "Enable/Disable permanent ban option"); - g_aPluginCvar[hBeacon] = CreateConVar("sm_spectate_beacon", "1", "Enable/Disable beacon option"); - g_aPluginCvar[hBlind] = CreateConVar("sm_spectate_blind", "1", "Enable/Disable blind option"); - g_aPluginCvar[hCheater] = CreateConVar("sm_spectate_cheater", "1", "Enable/Disable cheater option"); - g_aPluginCvar[hDrug] = CreateConVar("sm_spectate_drug", "1", "Enable/Disable drug option"); - g_aPluginCvar[hFreeze] = CreateConVar("sm_spectate_freeze", "1", "Enable/Disable freeze option"); - g_aPluginCvar[hFreezeBomb] = CreateConVar("sm_spectate_freezebomb", "1", "Enable/Disable freezebomb option"); - g_aPluginCvar[hKick] = CreateConVar("sm_spectate_kick", "1", "Enable/Disable kick option"); - g_aPluginCvar[hSlap] = CreateConVar("sm_spectate_slap", "1", "Enable/Disable slap option"); - g_aPluginCvar[hSlay] = CreateConVar("sm_spectate_slay", "1", "Enable/Disable slay option"); - g_aPluginCvar[hTimeBomb] = CreateConVar("sm_spectate_timebomb", "1", "Enable/Disable timebomb option"); - - sm_spectate_adminflag = CreateConVar("sm_spectate_adminflag", "d", "Admin Flag to use for admin hud"); - - /** - Hook console variables - */ - new e_CvarHandles:iCvar; - for ( ; _:iCvar < sizeof(g_aPluginCvar); iCvar++) - { - HookConVarChange(g_aPluginCvar[iCvar], ConVarSettingsChanged); - } - - /** - Need to register the commands we are going to create and use. - */ - RegConsoleCmd("sm_spectate", Command_Spectate, "Spectate a player"); - RegConsoleCmd("sm_spec", Command_Spectate, "Spectate a player"); - RegConsoleCmd("sm_observe", Command_Spectate, "Spectate a player"); - RegConsoleCmd("sm_stopspec", Command_StopSpectate, "Stop Spectating a player"); - RegConsoleCmd("sm_endobserve", Command_StopSpectate, "Stop Spectating a player"); - RegConsoleCmd("sm_specinfo", Command_ToggleHud, "Toggles the hud display if in spectator"); - - /** - Now we have to deal with the admin menu. If the admin library is loaded call the function to add our items. - */ - new Handle:gTopMenu; - if (LibraryExists("adminmenu") && ((gTopMenu = GetAdminTopMenu()) != INVALID_HANDLE)) - { - OnAdminMenuReady(gTopMenu); - } - - /** - Deal with the hud - Thanks to Spray Trace plugin (http://forums.alliedmods.net/showthread.php?p=665448) - */ - new String:sHudGames[32]; - GetGameFolderName(sHudGames, sizeof(sHudGames)); - g_aPluginSettings[bCanHUD] = StrEqual(sHudGames,"tf",false) - || StrEqual(sHudGames,"hl2mp",false) - || StrEqual(sHudGames,"sourceforts",false) - || StrEqual(sHudGames,"obsidian",false) - || StrEqual(sHudGames,"left4dead",false) - || StrEqual(sHudGames,"l4d",false); - - if (g_aPluginSettings[bCanHUD]) - { - g_hHud = CreateHudSynchronizer(); - } - - /** - Load translations - */ - LoadTranslations ("common.phrases"); - LoadTranslations ("simplespectate.phrases"); - - /** - Create the config file - */ - AutoExecConfig(true); -} - -public OnConfigsExecuted() -{ - new e_CvarHandles:iCvar; - for ( ; _:iCvar < sizeof(g_aPluginCvarSettings); iCvar++) - { - g_aPluginCvarSettings[iCvar] = GetConVarBool(g_aPluginCvar[iCvar]); - } - - /* - Build the global menus - */ - g_aMenus[hSelectPlayer] = BuildSelectPlayerMenu(); - g_aMenus[hBanTime] = BuildBanTimeMenu(); - g_aMenus[hReason] = BuildReasonMenu(); - - GetConVarString(sm_spectate_adminflag, g_sAdminFlags, sizeof(g_sAdminFlags)); -} - -public OnAllPluginsLoaded() -{ - - /* - Check for steambans - */ - if (FindConVar("sbsrc_version") != INVALID_HANDLE) - { - g_aPluginSettings[bUseSteamBans] = true; - } - else - { - g_aPluginSettings[bUseSteamBans] = false; - } - - /* - Check for sourcebans - */ - if (FindConVar("sb_version") != INVALID_HANDLE) - { - g_aPluginSettings[bUseSourceBans] = true; - } - else - { - g_aPluginSettings[bUseSourceBans] = false; - } - - /* - Check for mysql bans - */ - if (FindConVar("mysql_bans_version") != INVALID_HANDLE) - { - g_aPluginSettings[bUseMySQLBans] = true; - } - else - { - g_aPluginSettings[bUseMySQLBans] = false; - } - - /* - Check for dukehacks - */ - new String:sExtError[256]; - new iExtStatus = GetExtensionFileStatus("dukehacks.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SSPEC] Dukehacks extension was not found."); - LogAction(0, -1, "[SSPEC] Plugin continued to load, but that feature will not be used."); - g_aPluginSettings[bUseDukehacks] = false; - } - else if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SSPEC] Dukehacks extension is loaded with errors."); - LogAction(0, -1, "[SSPEC] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SSPEC] Plugin continued to load, but that feature will not be used."); - g_aPluginSettings[bUseDukehacks] = false; - } - else if (iExtStatus == 1) - { - LogAction(0, -1, "[SSPEC] Dukehacks extension is loaded and will be used."); - g_aPluginSettings[bUseDukehacks] = true; - dhAddClientHook(CHK_TakeDamage, Hacks_TakeDamageHook); - } - - /* - Deal with some known plugin conflicts - */ - new Handle:hObserveClient = FindConVar("observe_version"); - if (hObserveClient != INVALID_HANDLE) - { - new String:sNewFile[PLATFORM_MAX_PATH + 1], String:sOldFile[PLATFORM_MAX_PATH + 1]; - BuildPath(Path_SM, sNewFile, sizeof(sNewFile), "plugins/disabled/observe.smx"); - BuildPath(Path_SM, sOldFile, sizeof(sOldFile), "plugins/observe.smx"); - - /** - Check if plugins/observe.smx exists, and if not, ignore - */ - if(!FileExists(sOldFile)) - { - return; - } - - /** - Check if plugins/disabled/observe.smx already exists, and if so, delete it - */ - if(FileExists(sNewFile)) - { - DeleteFile(sNewFile); - } - - /** - Unload plugins/observe.smx and move it to plugins/disabled/observe.smx - */ - LogAction(0, -1, "Detected the plugin ObserveClient"); - LogAction(0, -1, "ObserveClient plugin conflicts with Simple Spectate"); - LogAction(0, -1, "Unloading plugin and disabling ObserveClient plugin"); - ServerCommand("sm plugins unload observe"); - RenameFile(sNewFile, sOldFile); - } -} - -public OnLibraryRemoved(const String:name[]) -{ - if (StrEqual(name, "adminmenu")) - { - - /** - Looks like the admin menu was removed. Set the global. - */ - g_hAdminMenu = INVALID_HANDLE; - } - else if (StrEqual(name, "simpleplugins")) - { - //something - } -} - -public OnClientDisconnect(client) -{ - - /** - Cleanup the clients variables. - */ - ResetClient(client); - - /** - Run a loop and see if we are supposed to spectate this person (is a target) - */ - for(new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][iTargetIndex] == client) - { - - /** - Cleanup the clients variables. - */ - StopFollowingPlayer(i); - g_aPlayers[i][TargetPunishment] = Punish_None; - g_aPlayers[i][iBanTime] = 0; - } - } -} - -/** -Thirdparty callbacks -*/ -public SM_OnPlayerMoved(Handle:plugin, client, team) -{ - - /** - Make sure we called the move function - */ - if (plugin != GetMyHandle()) - { - return; - } - - //Nothing -} - -public Action:Hacks_TakeDamageHook(client, attacker, inflictor, Float:damage, &Float:multiplier, damagetype) -{ - - /** - Check for a valid client - */ - if (client > 0 && client <= MaxClients) - { - - /** - Check if the client taking damage is flagged as a cheater - */ - if (g_aPlayers[client][bIsFlaggedCheater]) - { - - /** - Check for fall damage and increase it - */ - if (damagetype & DMG_FALL) - { - multiplier *= 1000.0; - return Plugin_Changed; - } - } - } - - /** - Check for a valid attacker - */ - if (attacker > 0 && attacker <= MaxClients) - { - - /** - Check if the attacker causing the damage is flagged as a cheater - */ - if (g_aPlayers[attacker][bIsFlaggedCheater]) - { - - /** - Make sure they are not hurting themselves - */ - if (client != attacker) - { - - /** - Stop the damage - */ - multiplier *= 0.0; - return Plugin_Changed; - } - } - } - return Plugin_Continue; -} - -/** -Events -*/ -public Action:HookPlayerChangeTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get the client and team - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - new iTeam = GetEventInt(event, "team"); - - /** - Make sure it's a valid client - */ - if (iClient == 0) - { - return Plugin_Continue; - } - - /** - If it's a move to spectator start displaying the hud - */ - else if ((iTeam == g_aCurrentTeams[Spectator]) && (GetUserFlagBits(iClient) & ADMFLAG_GENERIC)) - { - StartDisplayingHud(iClient); - - /** - If the event was going to be broadcasted, we refire it so it is not broadcasted and stop this one - */ - if (!dontBroadcast) - { - new Handle:hEvent = CreateEvent("player_team"); - SetEventInt(hEvent, "userid", GetEventInt(event, "userid")); - SetEventInt(hEvent, "team", GetEventInt(event, "team")); - SetEventInt(hEvent, "oldteam", GetEventInt(event, "oldteam")); - SetEventBool(hEvent, "disconnect", GetEventBool(event, "disconnect")); - - if (g_CurrentMod == GameType_DOD || g_CurrentMod == GameType_L4D || g_CurrentMod == GameType_TF) - { - new String:sClientName[MAX_NAME_LENGTH + 1]; - GetClientName(client, sClientName, sizeof(sClientName)); - SetEventBool(hEvent, "autoteam", GetEventBool(event, "autoteam")); - SetEventBool(hEvent, "silent", true); - SetEventString(hEvent, "name", sClientName); - FireEvent(hEvent, true); - } - else - { - FireEvent(hEvent, true); - } - return Plugin_Handled; - } - } - - /** - Otherwise cleanup the client - */ - else - { - StopDisplayingHud(iClient); - StopFollowingPlayer(iClient); - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -/** -Commands -*/ -public Action:Command_Spectate(client, args) -{ - - /** - See if we already have a target (for toggling of command) - */ - if (g_aPlayers[client][iTargetIndex]) - { - - /** - We do, toggle it off - */ - StopFollowingPlayer(client); - - /** - We are done, bug out. - */ - return Plugin_Handled; - } - - /** - We don't... must want to enable it - See if we have some command arguments. - */ - new iCmdArgs = GetCmdArgs(); - if (iCmdArgs == 0) - { - - /** - We don't have any. Display the player menu. - */ - if (g_aPlayers[client][bIsDisplayingHud]) - { - StopDisplayingHud(client); - } - - DisplayMenu(BuildPlayerListMenu(), client, MENU_TIME_FOREVER); - return Plugin_Handled; - } - - /** - We have an argument. - Try to find the target. - */ - new String:sPlayer[128]; - GetCmdArg(1, sPlayer, sizeof(sPlayer)); - new iTarget = FindTarget(client, sPlayer, true, true); - if (iTarget == -1 || !IsClientInGame(iTarget)) - { - - /** - We couldn't find the target. Display the player menu. - */ - if (g_aPlayers[client][bIsDisplayingHud]) - { - StopDisplayingHud(client); - } - - DisplayMenu(BuildPlayerListMenu(), client, MENU_TIME_FOREVER); - return Plugin_Handled; - } - - /** - We found the target. - Call the stock function to spectate the target. - */ - StartFollowingPlayer(client, iTarget); - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_StopSpectate(client, args) -{ - - /** - Cleanup the clients variables. - */ - StopFollowingPlayer(client); - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_ToggleHud(client, args) -{ - - /** - Toggle the hud - */ - if (g_aPlayers[client][bIsDisplayingHud]) - { - StopDisplayingHud(client); - } - else - { - StartDisplayingHud(client); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -/** -Timers -*/ -public Action:Timer_ResetTarget(Handle:timer, any:client) -{ - - new iTargetID = GetEntPropEnt(client, Prop_Send, "m_hObserverTarget"); - - if (iTargetID != g_aPlayers[client][iTargetIndex] && IsPlayerAlive(g_aPlayers[client][iTargetIndex])) - { - - /** - Run the command to spectate the target from the clients prospectative. - */ - FakeClientCommandEx(client, "spec_player \"%N\"", g_aPlayers[client][iTargetIndex]); - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -public Action:Timer_UpdateHud(Handle:timer, any:client) -{ - - /** - Make sure the client is still in game and a spectator - */ - if (!IsClientConnected(client) || !IsClientInGame(client) || GetClientTeam(client) != g_aCurrentTeams[Spectator] || !g_aPlayers[client][bIsDisplayingHud]) - { - - /** - We are done, bug out - */ - g_aPlayers[client][hHudTimer] = INVALID_HANDLE; - g_aPlayers[client][bIsDisplayingHud] = false; - return Plugin_Stop; - } - /** - Get the target - */ - new iTarget = GetEntPropEnt(client, Prop_Send, "m_hObserverTarget"); - - /** - Check to make sure the target is valid - */ - if (iTarget <= 0 || iTarget > MaxClients) - { - return Plugin_Continue; - } - - /** - Get the spectator mode - */ - new iSpecMode = GetEntProp(client, Prop_Send, "m_iObserverMode"); - - /** - This is a double check to make sure we are in spec - If we are on a regular team, specmod would = none or zero - */ - if (iSpecMode == SPECMODE_NONE) - { - - /** - We are done, bug out - */ - g_aPlayers[client][hHudTimer] = INVALID_HANDLE; - g_aPlayers[client][bIsDisplayingHud] = false; - return Plugin_Stop; - } - - /** - Check the spectator mode - CSS has different index's so we have to check game type first - */ - if (g_CurrentMod == GameType_CSS) - { - switch (iSpecMode) - { - case SPECMODE_CSS_FIRSTPERSON: - { - //Do Nothing - } - case SPECMODE_CSS_3RDPERSON: - { - //Do Nothing - } - case SPECMODE_CSS_FREELOOK: - { - return Plugin_Continue; - } - } - } - else - { - switch (iSpecMode) - { - case SPECMODE_FIRSTPERSON: - { - //Do Nothing - } - case SPECMODE_3RDPERSON: - { - //Do Nothing - } - case SPECMODE_FREELOOK: - { - return Plugin_Continue; - } - } - } - - - /** - Display with the hud - */ - if (g_aPluginSettings[bCanHUD] && !g_aPluginCvarSettings[bHudMode]) - { - new String:sSteamID[64]; - GetClientAuthString(iTarget, sSteamID, sizeof(sSteamID)); - SetHudTextParams(0.04, 0.6, 0.5, 255, 50, 50, 255); - ShowSyncHudText(client, g_hHud, "%N [%s]", iTarget, sSteamID); - } - else if (g_aPluginCvarSettings[bHudMode]) - { - if (g_aPluginCvarSettings[bMenuType]) - { - DisplayMenu(BuildPlayerHudMenu(client, iTarget), client, 1); - } - else - { - new Handle:hPanel = BuildPlayerHudPanel(client, iTarget); - SendPanelToClient(hPanel, client, Panel_PlayerHud, 1); - CloseHandle(hPanel); - } - } - - /** - We are done, keep going! - */ - return Plugin_Continue; -} - -/** -Admin Menu Callbacks -*/ -public OnAdminMenuReady(Handle:topmenu) -{ - if (topmenu == g_hAdminMenu) - { - return; - } - g_hAdminMenu = topmenu; - new TopMenuObject:player_commands = FindTopMenuCategory(g_hAdminMenu, ADMINMENU_PLAYERCOMMANDS); - if (player_commands == INVALID_TOPMENUOBJECT) - { - return; - } - AddToTopMenu(g_hAdminMenu, - "sm_spectate", - TopMenuObject_Item, - AdminMenu_SpecPlayer, - player_commands, - "sm_spectate", - ADMFLAG_GENERIC); -} - -public AdminMenu_SpecPlayer(Handle:topmenu, TopMenuAction:action, TopMenuObject:object_id, param, String:buffer[], maxlength) -{ - if (action == TopMenuAction_DisplayOption) - { - - if (g_aPlayers[param][bIsDisplayingHud]) - { - StopDisplayingHud(param); - } - /** - See if we already have a target - */ - if (g_aPlayers[param][iTargetIndex]) - { - Format(buffer, maxlength, "Spectate(Disable)"); - } - else - { - Format(buffer, maxlength, "Spectate(Select Player)"); - } - } - else if (action == TopMenuAction_SelectOption) - { - - /** - See if we already have a target - */ - if (g_aPlayers[param][iTargetIndex]) - { - - /** - We do, toggle it off - */ - StopFollowingPlayer(param); - - /** - We are done, bug out. - */ - return; - } - else - { - DisplayMenu(BuildPlayerListMenu(), param, MENU_TIME_FOREVER); - } - } -} - -/** -Select Player Menu Callbacks -*/ -public Menu_PlayerList(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - /** - Get the selected player - */ - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - new iTarget = GetClientOfUserId(StringToInt(sSelection)); - - /** - Start following the player - */ - StartFollowingPlayer(param1, iTarget); - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_GENERIC) - { - - /** - Display the last admin menu - */ - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } - else if (param2 == MenuCancel_Exit && GetClientTeam(param1) == g_aCurrentTeams[Spectator]) - { - /** - They canceled the current menu, start the hud back up - */ - StartDisplayingHud(param1); - } - } - else if (action == MenuAction_End) - { - - /** - Not a global menu, close it - */ - CloseHandle(menu); - } -} - -public Menu_SelectPlayer(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - - /** - Get the selected player - */ - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (strcmp(sSelection, "Current", false) == 0) - { - /** - Get the current target - */ - new iTarget = GetEntPropEnt(param1, Prop_Send, "m_hObserverTarget"); - - /** - Check to make sure the target is valid - */ - if (iTarget <= 0 || iTarget > MaxClients) - { - PrintToChat(param1, "\x03[SM-SPEC]\x01 %t", "Invalid Target"); - DisplayMenu(BuildPlayerListMenu(), param1, MENU_TIME_FOREVER); - } - - /** - Start following the player - */ - StartFollowingPlayer(param1, iTarget); - } - else - { - - /** - They want to select a player, show the player list - */ - DisplayMenu(BuildPlayerListMenu(), param1, MENU_TIME_FOREVER); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - - /** - They canceled the current menu, start the hud back up - */ - StartDisplayingHud(param1); - } - } - else if (action == MenuAction_End) - { - /** - Its a global menu, leave it alive - */ - } -} - -/** -Punishment Menu Callbacks -*/ -public Menu_Punishments(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - - /** - Get the menu selection - */ - new String:sSelection[15]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - - /** - Search for the correct index - */ - new e_Punishments:Index = Punish_None; - for ( ; _:Index <= sizeof(g_sPunishments); Index++) - { - if (StrEqual(sSelection, g_sPunishments[Index])) - { - break; - } - } - - /** - Display the next menu - */ - if (Index == Punish_Ban) - { - - /** - Set the punishment index and display ban time menu - */ - g_aPlayers[param1][TargetPunishment] = Index; - DisplayMenu(g_aMenus[hBanTime], param1, MENU_TIME_FOREVER); - } - else if (Index == Punish_Cheater) - { - - /** - Ask for confirmation before we set punishment index - */ - new Handle:hPanel = BuildAdminCheaterPanel(); - SendPanelToClient(hPanel, param1, Panel_AdminCheater, MENU_TIME_FOREVER); - CloseHandle(hPanel); - } - else - { - - /** - Set the punishment index and display reason menu - */ - g_aPlayers[param1][TargetPunishment] = Index; - DisplayMenu(g_aMenus[hReason], param1, MENU_TIME_FOREVER); - } - } - else if (action == MenuAction_Cancel) - { - - /** - They canceled the current menu, start the hud back up - */ - StartDisplayingHud(param1); - } - else if (action == MenuAction_End) - { - - /** - Not a global menu, close it - */ - CloseHandle(menu); - } -} - -public Menu_BanTime(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - - /** - Get the menu selection - */ - new String:sSelection[15]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - - /** - Set the ban time global - */ - g_aPlayers[param1][iBanTime] = StringToInt(sSelection); - - /** - Display the reason menu - */ - DisplayMenu(g_aMenus[hReason], param1, MENU_TIME_FOREVER); - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - - /** - They canceled the current menu, start the hud back up - */ - StartDisplayingHud(param1); - } - } - else if (action == MenuAction_End) - { - /** - Its a global menu, leave it alive - */ - } -} - -public Menu_Reason(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - - /** - Get the menu selection - */ - new String:sSelection[15]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - - /** - Perform the punishment - */ - PerformPunishment(param1, g_aPlayers[param1][iTargetIndex], g_aPlayers[param1][TargetPunishment], sSelection, g_aPlayers[param1][iBanTime]); - - /** - Reactivate the hud if still in spectator - */ - if (GetClientTeam(param1) == g_aCurrentTeams[Spectator]) - { - StartDisplayingHud(param1); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - - /** - They canceled the current menu, start the hud back up - */ - StartDisplayingHud(param1); - } - } - else if (action == MenuAction_End) - { - /** - Its a global menu, leave it alive - */ - } -} - -public Panel_AdminCheater(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - if (param2 == 1) - { - - /** - Set the punishment index and display reason menu - */ - g_aPlayers[param1][TargetPunishment] = Punish_Cheater; - DisplayMenu(g_aMenus[hReason], param1, MENU_TIME_FOREVER); - } - else - { - - /** - Reactivate the hud if still in spectator - */ - if (GetClientTeam(param1) == g_aCurrentTeams[Spectator]) - { - StartDisplayingHud(param1); - } - } - } -} - -public Panel_PublicCheater(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - if (param2 == 1) - { - //Waiting for SB 2.0 and sb_submission to be published - } - else - { - - /** - Reactivate the hud if still in spectator - */ - if (GetClientTeam(param1) == g_aCurrentTeams[Spectator]) - { - StartDisplayingHud(param1); - } - } - } -} - -/** -Hud Menu/Panel Callbacks -*/ -public Menu_PlayerHud(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "stop", false)) - { - StopFollowingPlayer(param1); - } - else if (StrEqual(sSelection, "start", false)) - { - StopDisplayingHud(param1); - DisplayMenu(g_aMenus[hSelectPlayer], param1, MENU_TIME_FOREVER); - } - else if (StrEqual(sSelection, "removecheater", false)) - { - g_aPlayers[g_aPlayers[param1][iTargetIndex]][bIsFlaggedCheater] = false; - } - else if (StrEqual(sSelection, "punish", false)) - { - if (g_aPlayers[param1][iTargetIndex]) - { - StopDisplayingHud(param1); - DisplayMenu(BuildPunishmentMenu(param1), param1, MENU_TIME_FOREVER); - } - else - { - StopDisplayingHud(param1); - PrintToChat(param1, "\x03[SM-SPEC]\x01 %t", "Must Have Target"); - DisplayMenu(g_aMenus[hSelectPlayer], param1, MENU_TIME_FOREVER); - } - } - else if (StrEqual(sSelection, "reportcheater", false)) - { - if (g_aPlayers[param1][iTargetIndex]) - { - StopDisplayingHud(param1); - new Handle:hPanel = BuildPublicCheaterPanel(); - SendPanelToClient(hPanel, param1, Panel_PublicCheater, MENU_TIME_FOREVER); - CloseHandle(hPanel); - } - else - { - StopDisplayingHud(param1); - PrintToChat(param1, "\x03[SM-SPEC]\x01 %t", "Must Have Target"); - DisplayMenu(g_aMenus[hSelectPlayer], param1, MENU_TIME_FOREVER); - } - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_Interrupted) - { - if (GetClientMenu(param1) == MenuSource_External) - { - StopDisplayingHud(param1); - } - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } -} - -public Panel_PlayerHud(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - switch (param2) - { - case 1: - { - if (g_aPlayers[param1][iTargetIndex]) - { - StopFollowingPlayer(param1); - } - else - { - StopDisplayingHud(param1); - DisplayMenu(BuildSelectPlayerMenu(), param1, MENU_TIME_FOREVER); - } - } - case 2: - { - if (!g_aPlayers[param1][iTargetIndex]) - { - StopDisplayingHud(param1); - PrintToChat(param1, "\x03[SM-SPEC]\x01 %t", "Must Have Target"); - DisplayMenu(g_aMenus[hSelectPlayer], param1, MENU_TIME_FOREVER); - return; - } - - if ((GetUserFlagBits(param1) & ADMFLAG_GENERIC) || (GetUserFlagBits(param1) & ADMFLAG_ROOT)) - { - if (g_aPlayers[g_aPlayers[param1][iTargetIndex]][bIsFlaggedCheater] && (GetUserFlagBits(param1) & ADMFLAG_ROOT)) - { - //Remove cheater flag - g_aPlayers[g_aPlayers[param1][iTargetIndex]][bIsFlaggedCheater] = false; - } - else - { - //Punish menu - StopDisplayingHud(param1); - DisplayMenu(BuildPunishmentMenu(param1), param1, MENU_TIME_FOREVER); - } - } - else - { - //Report Cheater - new Handle:hPanel = BuildPublicCheaterPanel(); - SendPanelToClient(hPanel, param1, Panel_PublicCheater, MENU_TIME_FOREVER); - CloseHandle(hPanel); - } - } - case 3: - { - StopDisplayingHud(param1); - } - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_Interrupted) - { - if (GetClientMenu(param1) == MenuSource_External) - { - StopDisplayingHud(param1); - } - } - } -} - - -/** -Stock functions -*/ -stock StartFollowingPlayer(client, target) -{ - - /** - If we have an open timer, close it. - */ - if (g_aPlayers[client][hTargetTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[client][hTargetTimer]); - g_aPlayers[client][hTargetTimer] = INVALID_HANDLE; - } - - /** - Make sure the target is on a non spectator team, and the client != target - */ - if (client == target) - { - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Yourself"); - return; - } - new iTargetTeam = GetClientTeam(target); - if (iTargetTeam == g_aCurrentTeams[Spectator] || iTargetTeam == g_aCurrentTeams[Unknown]) - { - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Spectator"); - return; - } - - /** - Check to see if client is already a spectator - */ - if (GetClientTeam(client) != g_aCurrentTeams[Spectator]) - { - - /** - Client is not a spectator, lets move them to spec. - */ - SM_MovePlayer(client, g_aCurrentTeams[Spectator]); - } - - /** - If we are using steambans call sb_status - */ - if (g_aPluginSettings[bUseSteamBans]) - { - FakeClientCommandEx(client, "sb_status"); - } - - - /** - Set the global and start to spectate the target. - Making sure it's long enough to deal with moving the client to spec if we had to. - */ - new String:sTargetName[MAX_NAME_LENGTH + 1]; - GetClientName(target, sTargetName, sizeof(sTargetName)); - g_aPlayers[client][iTargetIndex] = target; - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Spectating", sTargetName); - g_aPlayers[client][hTargetTimer] = CreateTimer(0.5, Timer_ResetTarget, client, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); - if (!g_aPlayers[client][bIsDisplayingHud] && GetClientTeam(client) == g_aCurrentTeams[Spectator]) - { - StartDisplayingHud(client); - } -} - -stock StopFollowingPlayer(client) -{ - - /** - If we have an open timer, close it. - */ - if (g_aPlayers[client][hTargetTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[client][hTargetTimer]); - } - - /** - Tell the client we can't spec his target anymore... if they are in game. - */ - if (IsClientInGame(client) && g_aPlayers[client][iTargetIndex] != 0) - { - new String:sTargetName[MAX_NAME_LENGTH + 1]; - GetClientName(g_aPlayers[client][iTargetIndex], sTargetName, sizeof(sTargetName)); - if (!IsClientConnected(g_aPlayers[client][iTargetIndex]) || !IsClientInGame(g_aPlayers[client][iTargetIndex])) - { - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Target Left"); - } - else - { - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Stopped spectating", sTargetName); - } - } - - /** - Null the globals. - */ - g_aPlayers[client][iTargetIndex] = 0; - g_aPlayers[client][hTargetTimer] = INVALID_HANDLE; -} - -stock StartDisplayingHud(client) -{ - if (g_aPluginCvarSettings[bRestrictHud] && !SM_IsValidAdmin(client, g_sAdminFlags)) - { - return; - } - else - { - /** - Double check the hud timer - We should not have one, but if we do, lets cancel it for the current callback - */ - StopDisplayingHud(client); - - /** - Now we can safely display the hud and make sure the current stored handle is the current timer - */ - g_aPlayers[client][bIsDisplayingHud] = true; - g_aPlayers[client][hHudTimer] = CreateTimer(0.5, Timer_UpdateHud, client, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); - } -} - -stock StopDisplayingHud(client) -{ - if (g_aPlayers[client][hHudTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[client][hHudTimer]); - } - g_aPlayers[client][hHudTimer] = INVALID_HANDLE; - g_aPlayers[client][bIsDisplayingHud] = false; -} - -stock ResetClient(client) -{ - StopFollowingPlayer(client); - StopDisplayingHud(client); - - g_aPlayers[client][bIsFlaggedCheater] = false; - g_aPlayers[client][TargetPunishment] = Punish_None; - g_aPlayers[client][iBanTime] = -1; -} - -stock PerformPunishment(client, target, e_Punishments:punishment, const String:reason[], time = 300) -{ - new String:sTargetName[MAX_NAME_LENGTH + 1], - String:sTargetID[64]; - - /** - The target could have left the game by the time we get here - Check for a valid target - */ - if (!IsClientConnected(target) || !IsClientInGame(target)) - { - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Target Left"); - return; - } - - GetClientName(target, sTargetName, sizeof(sTargetName)); - GetClientAuthString(target, sTargetID, sizeof(sTargetID)); - - switch (punishment) - { - case Punish_Kick: - { - KickClient(g_aPlayers[client][iTargetIndex], "%s", reason); - } - case Punish_Ban: - { - if (g_aPluginSettings[bUseSourceBans]) - { - ClientCommand(client, "sm_ban #%d %d \"%s\"", GetClientUserId(target), time, reason); - } - else if (g_aPluginSettings[bUseMySQLBans]) - { - ClientCommand(client, "mysql_ban #%d %d \"%s\"", GetClientUserId(target), time, reason); - } - else - { - BanClient(target, time, BANFLAG_AUTHID, reason, reason); - } - } - case Punish_Cheater: - { - g_aPlayers[target][bIsFlaggedCheater] = true; - } - case Punish_Beacon: - { - ClientCommand(client, "sm_beacon \"%s\"", sTargetName); - } - case Punish_Blind: - { - ClientCommand(client, "sm_blind \"%s\"", sTargetName); - } - case Punish_Drug: - { - ClientCommand(client, "sm_drug \"%s\"", sTargetName); - } - case Punish_Freeze: - { - ClientCommand(client, "sm_freeze \"%s\"", sTargetName); - } - case Punish_FreezeBomb: - { - ClientCommand(client, "sm_freezebomb \"%s\"", sTargetName); - } - case Punish_Slap: - { - ClientCommand(client, "sm_slap \"%s\" 10", sTargetName); - } - case Punish_Slay: - { - ClientCommand(client, "sm_slay \"%s\"", sTargetName); - } - case Punish_TimeBomb: - { - ClientCommand(client, "sm_timebomb \"%s\"", sTargetName); - } - } - - if (punishment == Punish_Cheater) - { - LogAction(client, target, "[SM SPEC] %N marked %N(%s) with a %s flag for %s", client, target, sTargetID, g_sPunishments[punishment], reason); - } - else - { - ShowActivity(client, "%t", "Punished", sTargetName, g_sPunishments[punishment], reason); - LogAction(client, target, "[SM SPEC] %N punished %N(%s) with a %s for %s", client, target, sTargetID, g_sPunishments[punishment], reason); - } - - /** - Null the globals. - */ - g_aPlayers[client][TargetPunishment] = Punish_None; - g_aPlayers[client][iBanTime] = -1; -} - -/** -Build the menu of player names -*/ -stock Handle:BuildPlayerListMenu() -{ - new Handle:hMenu = CreateMenu(Menu_PlayerList); - AddTargetsToMenu(hMenu, 0, true, false); - SetMenuTitle(hMenu, "Select A Player:"); - SetMenuExitBackButton(hMenu, true); - return hMenu; -} - -/** -Build the select player menu (current or list of players) -*/ -stock Handle:BuildSelectPlayerMenu() -{ - new Handle:hMenu = CreateMenu(Menu_SelectPlayer); - SetMenuTitle(hMenu, "Select A Player:"); - AddMenuItem(hMenu, "Current", "Current Target"); - AddMenuItem(hMenu, "List", "Player List"); - SetMenuExitBackButton(hMenu, true); - return hMenu; -} - -/** -Build the punishmenu menu -*/ -stock Handle:BuildPunishmentMenu(iClient) -{ - new Handle:hMenu = CreateMenu(Menu_Punishments); - SetMenuTitle(hMenu, "Select A Punishment:"); - SetMenuExitBackButton(hMenu, true); - SetMenuExitButton(hMenu, true); - - if (g_aPluginCvarSettings[bKick] && ((GetUserFlagBits(iClient) & ADMFLAG_GENERIC) || (GetUserFlagBits(iClient) & ADMFLAG_ROOT))) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Kick], "Kick"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Kick], "Kick", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bBan] && ((GetUserFlagBits(iClient) & ADMFLAG_GENERIC) || (GetUserFlagBits(iClient) & ADMFLAG_ROOT))) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Ban], "Ban"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Ban], "Ban", ITEMDRAW_DISABLED); - } - - if (g_aPluginSettings[bUseDukehacks] && g_aPluginCvarSettings[bCheater] && (GetUserFlagBits(iClient) & ADMFLAG_ROOT)) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Cheater], "Flag As Cheater"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Cheater], "Flag As Cheater", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bBeacon]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Beacon], "Beacon"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Beacon], "Beacon", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bBlind]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Blind], "Blind"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Blind], "Blind", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bDrug]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Drug], "Drug"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Drug], "Drug", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bFreeze]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Freeze], "Freeze"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Freeze], "Freeze", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bFreezebomb]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_FreezeBomb], "Freeze Bomb"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_FreezeBomb], "Freeze Bomb", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bSlap]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Slap], "Slap"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Slap], "Slap", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bSlay]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Slay], "Slay"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Slay], "Slay", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bTimeBomb]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_TimeBomb], "Time Bomb"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_TimeBomb], "Time Bomb", ITEMDRAW_DISABLED); - } - - return hMenu; -} - -/** -Build the punishmenu menu -*/ -stock Handle:BuildBanTimeMenu() -{ - new Handle:hMenu = CreateMenu(Menu_BanTime); - SetMenuTitle(hMenu, "Select Ban Type:"); - - if (g_aPluginCvarSettings[bBanPerm]) - { - AddMenuItem(hMenu, "permban", "Permanent"); - } - else - { - AddMenuItem(hMenu, "permban", "Permanent", ITEMDRAW_DISABLED); - } - - AddMenuItem(hMenu, "10", "10 Minutes"); - AddMenuItem(hMenu, "30", "30 Minutes"); - AddMenuItem(hMenu, "60", "1 Hour"); - AddMenuItem(hMenu, "240", "4 Hours"); - AddMenuItem(hMenu, "1440", "1 Day"); - AddMenuItem(hMenu, "10080", "1 Week"); - - SetMenuExitBackButton(hMenu, true); - return hMenu; -} - -/** -Build the punishmenu menu -*/ -stock Handle:BuildReasonMenu() -{ - new Handle:hMenu = CreateMenu(Menu_Reason); - SetMenuTitle(hMenu, "Select A Reason:"); - - AddMenuItem(hMenu, "Abusive", "Abusive"); - AddMenuItem(hMenu, "Racism", "Racism"); - AddMenuItem(hMenu, "General cheating/exploits", "General cheating/exploits"); - AddMenuItem(hMenu, "Wallhack", "Wallhack"); - AddMenuItem(hMenu, "Aimbot", "Aimbot"); - AddMenuItem(hMenu, "Speedhacking", "Speedhacking"); - AddMenuItem(hMenu, "Mic spamming", "Mic spamming"); - AddMenuItem(hMenu, "Admin disrepect", "Admin disrepect"); - AddMenuItem(hMenu, "Camping", "Camping"); - AddMenuItem(hMenu, "Team killing", "Team killing"); - AddMenuItem(hMenu, "Unacceptable Spray", "Unacceptable Spray"); - AddMenuItem(hMenu, "Breaking Server Rules", "Breaking Server Rules"); - AddMenuItem(hMenu, "Other", "Other"); - - SetMenuExitBackButton(hMenu, true); - return hMenu; -} - -/** -Build the cheater displays -*/ -stock Handle:BuildAdminCheaterPanel() -{ - - /** - Create the menu and set the menu options. - */ - new Handle:hPanel = CreatePanel(); - SetPanelTitle(hPanel, "Simple Spectator:"); - - DrawPanelText(hPanel, "Are you sure you want to"); - DrawPanelText(hPanel, "flag this player as a cheater?"); - DrawPanelText(hPanel, "They will not be able to damage"); - DrawPanelText(hPanel, "anyone and die on fall damage."); - DrawPanelItem(hPanel, "Yes"); - DrawPanelItem(hPanel, "No"); - - return hPanel; -} - -stock Handle:BuildPublicCheaterPanel() -{ - - /** - Create the menu and set the menu options. - */ - new Handle:hPanel = CreatePanel(); - SetPanelTitle(hPanel, "Simple Spectator:"); - - DrawPanelText(hPanel, "Are you sure you want to"); - DrawPanelText(hPanel, "submit this player as a cheater?"); - DrawPanelItem(hPanel, "Yes (Not Implemented Yet)", ITEMDRAW_DISABLED); - DrawPanelItem(hPanel, "No"); - return hPanel; -} - -/** -Build the hud displays -*/ -stock Handle:BuildPlayerHudMenu(iClient, iTarget) -{ - - /** - Create all the string variables we will need - */ - new String:sTargetName[MAX_NAME_LENGTH + 1], - String:sTargetID[64], - String:sTargetIP[16]; - - new String:sDisplayName[MAX_NAME_LENGTH + 1], - String:sDisplayID[64], - String:sDisplayIP[64], - String:sDisplayFrags[16], - String:sDisplayDeaths[16]; - - new iTargetFrags, - iTargetDeaths; - - /** - Get the targets information - */ - GetClientName(iTarget, sTargetName, sizeof(sTargetName)); - GetClientIP(iTarget, sTargetIP, sizeof(sTargetIP)); - GetClientAuthString(iTarget, sTargetID, sizeof(sTargetID)); - iTargetFrags = GetClientFrags(iTarget); - iTargetDeaths = GetClientDeaths(iTarget); - - /** - Format the strings for the menu - */ - Format(sDisplayName, sizeof(sDisplayName), "Player: %s", sTargetName); - Format(sDisplayID, sizeof(sDisplayID), "Steam ID: %s", sTargetID); - Format(sDisplayIP, sizeof(sDisplayIP), "IP Address: %s", sTargetIP); - Format(sDisplayFrags, sizeof(sDisplayFrags), "Kills: %i", iTargetFrags); - Format(sDisplayDeaths, sizeof(sDisplayDeaths), "Deaths: %i", iTargetDeaths); - - /** - Create the menu and set the menu options. - */ - new Handle:hMenu = CreateMenu(Menu_PlayerHud); - SetMenuExitBackButton(hMenu, false); - SetMenuTitle(hMenu, "Simple Spectator"); - - AddMenuItem(hMenu, "name", sDisplayName, ITEMDRAW_DISABLED); - AddMenuItem(hMenu, "steamid", sDisplayID, ITEMDRAW_DISABLED); - - if (SM_IsValidAdmin(iClient, g_sAdminFlags)) - { - AddMenuItem(hMenu, "ip", sDisplayIP, ITEMDRAW_DISABLED); - } - - AddMenuItem(hMenu, "kills", sDisplayFrags, ITEMDRAW_DISABLED); - AddMenuItem(hMenu, "deaths", sDisplayDeaths, ITEMDRAW_DISABLED); - - if (g_aPlayers[iClient][iTargetIndex]) - { - AddMenuItem(hMenu, "stop", "Stop Following"); - } - else - { - AddMenuItem(hMenu, "start", "Follow Player"); - } - - if ((GetUserFlagBits(iClient) & ADMFLAG_GENERIC) || (GetUserFlagBits(iClient) & ADMFLAG_ROOT)) - { - if (g_aPlayers[iTarget][bIsFlaggedCheater] && (GetUserFlagBits(iClient) & ADMFLAG_ROOT)) - { - AddMenuItem(hMenu, "removecheater", "Remove Cheater Flag"); - } - else - { - if (CanUserTarget(iClient, iTarget)) - { - AddMenuItem(hMenu, "punish", "Punish Player"); - } - else - { - AddMenuItem(hMenu, "punish", "Punish Player (Immune)", ITEMDRAW_DISABLED); - } - } - } - else - { - AddMenuItem(hMenu, "reportcheater", "Report Cheater"); - } - - SetMenuPagination(hMenu, MENU_NO_PAGINATION); - SetMenuExitButton(hMenu, true); - return hMenu; -} - -stock Handle:BuildPlayerHudPanel(iClient, iTarget) -{ - - /** - Create all the string variables we will need - */ - new String:sTargetName[MAX_NAME_LENGTH + 1], - String:sTargetID[64], - String:sTargetIP[16]; - - new String:sDisplayName[MAX_NAME_LENGTH + 1], - String:sDisplayID[64], - String:sDisplayIP[64], - String:sDisplayFrags[16], - String:sDisplayDeaths[16]; - - new iTargetFrags, - iTargetDeaths; - - /** - Get the targets information - */ - GetClientName(iTarget, sTargetName, sizeof(sTargetName)); - GetClientIP(iTarget, sTargetIP, sizeof(sTargetIP)); - GetClientAuthString(iTarget, sTargetID, sizeof(sTargetID)); - iTargetFrags = GetClientFrags(iTarget); - iTargetDeaths = GetClientDeaths(iTarget); - - /** - Format the strings for the menu - */ - Format(sDisplayName, sizeof(sDisplayName), "Player: %s", sTargetName); - Format(sDisplayID, sizeof(sDisplayID), "Steam ID: %s", sTargetID); - Format(sDisplayIP, sizeof(sDisplayIP), "IP Address: %s", sTargetIP); - Format(sDisplayFrags, sizeof(sDisplayFrags), "Kills: %i", iTargetFrags); - Format(sDisplayDeaths, sizeof(sDisplayDeaths), "Deaths: %i", iTargetDeaths); - - /** - Create the menu and set the menu options. - */ - new Handle:hPanel = CreatePanel(); - SetPanelTitle(hPanel, "Simple Spectator"); - - DrawPanelText(hPanel, "Player Information:"); - DrawPanelText(hPanel, sDisplayName); - DrawPanelText(hPanel, sDisplayID); - if (SM_IsValidAdmin(iClient, g_sAdminFlags)) - { - DrawPanelText(hPanel, sDisplayIP); - } - - DrawPanelText(hPanel, sDisplayFrags); - DrawPanelText(hPanel, sDisplayDeaths); - - if (g_aPlayers[iClient][iTargetIndex]) - { - DrawPanelItem(hPanel, "Stop Following"); - } - else - { - DrawPanelItem(hPanel, "Follow Player"); - } - - if ((GetUserFlagBits(iClient) & ADMFLAG_GENERIC) || (GetUserFlagBits(iClient) & ADMFLAG_ROOT)) - { - if (g_aPlayers[iTarget][bIsFlaggedCheater] && (GetUserFlagBits(iClient) & ADMFLAG_ROOT)) - { - DrawPanelItem(hPanel, "Remove Cheater Flag"); - } - else - { - if (CanUserTarget(iClient, iTarget)) - { - DrawPanelItem(hPanel, "Punish Player"); - } - else - { - DrawPanelItem(hPanel, "Punish Player (Immune)", ITEMDRAW_DISABLED); - } - } - } - else - { - DrawPanelItem(hPanel, "Report Cheater"); - } - - DrawPanelItem(hPanel, "Close Hud Panel"); - return hPanel; -} - -/** -Adjust the settings if a convar was changed -*/ -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - for (new iCvar = 0 ; _:iCvar < sizeof(g_aPluginCvarSettings); iCvar++) - { - if (g_aPluginCvar[_:iCvar] == convar) - { - if (StringToInt(newValue) == 1) - { - g_aPluginCvarSettings[_:iCvar] = true; - } - else - { - g_aPluginCvarSettings[_:iCvar] = false; - } - } - } - - /* - ReBuild the global menu that depends on cvars - */ - g_aMenus[hBanTime] = BuildBanTimeMenu(); - - /** - Run a loop to reset the hud - */ - for(new i = 1; i <= MaxClients; i++) - { - StopDisplayingHud(i); - if (IsClientConnected(i) && IsClientInGame(i) && GetClientTeam(i) == g_aCurrentTeams[Spectator]) - { - StartDisplayingHud(i); - } - } -} diff --git a/Simple Round Immunity/addons/sourcemod/scripting/simple-teambalancer.sp b/Simple Round Immunity/addons/sourcemod/scripting/simple-teambalancer.sp deleted file mode 100644 index 3302255..0000000 --- a/Simple Round Immunity/addons/sourcemod/scripting/simple-teambalancer.sp +++ /dev/null @@ -1,1797 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Team Balancer -Description: - Balances teams based upon player count - Player will not be balanced more than once in 5 (default) mins - Buddy system tries to keep buddies together - Ability to prioritize players - Ability to force players to accept the new team - Admins are immune -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include -#include - -#define PLUGIN_VERSION "2.1.$Rev$" - -enum PlayerData -{ - Handle:hBalanceTimer, - Handle:hForcedTimer, - bool:bSwitched, - bool:bFlagCarrier -}; - -/** - Global convar handles - */ -new Handle:stb_enabled = INVALID_HANDLE; -new Handle:stb_buddyenabled = INVALID_HANDLE; -new Handle:stb_logactivity = INVALID_HANDLE; -new Handle:stb_logactivity2 = INVALID_HANDLE; -new Handle:stb_unbalancelimit = INVALID_HANDLE; -new Handle:stb_deadonly = INVALID_HANDLE; -new Handle:stb_priorityenabled = INVALID_HANDLE; -new Handle:stb_uberlevel = INVALID_HANDLE; -new Handle:stb_balancedelay = INVALID_HANDLE; -new Handle:stb_livingplayerswitchdelay = INVALID_HANDLE; -new Handle:stb_livingplayercheckdelay = INVALID_HANDLE; -new Handle:stb_roundstartdelay = INVALID_HANDLE; -new Handle:stb_switchbackforced = INVALID_HANDLE; -new Handle:stb_adminflag = INVALID_HANDLE; -new Handle:stb_buddyrestriction = INVALID_HANDLE; -new Handle:stb_convarcontrol = INVALID_HANDLE; - -/** - Built-in cvars handles - */ -new Handle:stb_mp_autoteambalance = INVALID_HANDLE; -new Handle:stb_mp_teams_unbalance_limit = INVALID_HANDLE; -new Handle:TFGameModeArena = INVALID_HANDLE; - -/** - Timer handles - */ -new Handle:g_hBalanceTimer = INVALID_HANDLE; -new Handle:g_hLivingPlayerCheckTimer = INVALID_HANDLE; - -/** - Player arrays - */ -new g_aPlayers[MAXPLAYERS + 1][PlayerData]; - -/** -Global bools -*/ -new bool:g_bIsEnabled = true; -new bool:g_bPriorityPlayers = true; -new bool:g_bBuddyRestriction = false; -new bool:g_bLogActivity = false; -new bool:g_bLogActivity2 = false; -new bool:g_bDeadOnly = false; -new bool:g_bConVarControl = true; -new bool:g_bBuddyEnabled = true; -new bool:g_bBalanceInProgress = false; -new bool:g_bRoundStart = false; -new bool:g_bRoundEnd = false; -new bool:g_bSuddenDeath = false; -new bool:g_bIsArenaMode = false; - -/** - Global strings/integers/floats - */ -new g_iUnbalanceLimit, g_iLivingPlayerSwitchDelay, g_iLivingPlayerCheckDelay; -new g_iRoundStartDelay, g_iSwitchBackForced, g_iBalanceDelay; -new Float:g_fUberLevel; -new g_iOwnerOffset; -new String:g_sAdminFlag[5]; - -public Plugin:myinfo = -{ - name = "Simple Team Balancer", - author = "Simple Plugins", - description = "Balances teams based upon player count.", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -} - -public OnPluginStart() -{ - - /** - Create console variables - */ - CreateConVar("stb_version", PLUGIN_VERSION, "Simple Team Balancer", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - stb_enabled = CreateConVar("stb_enabled", "1", "Enable or Disable Simple Team Balancer", _, true, 0.0, true, 1.0); - stb_priorityenabled = CreateConVar("stb_priorityenabled", "1", "Enable or Disable the prioritization of living players", _, true, 0.0, true, 1.0); - stb_buddyrestriction = CreateConVar("stb_buddyrestriction", "0", "Enable or Disable Admin Only buddy lists", _, true, 0.0, true, 1.0); - stb_logactivity = CreateConVar("stb_logactivity", "0", "Enable or Disable the disaplying of events in the log", _, true, 0.0, true, 1.0); - stb_logactivity2 = CreateConVar("stb_logactivity2", "0", "Enable or Disable the disaplying of detailed events in the log (WILL SPAM LOG)", _, true, 0.0, true, 1.0); - stb_deadonly = CreateConVar("stb_deadonly", "0", "Enable or Disable the switching of only dead players", _, true, 0.0, true, 1.0); - stb_convarcontrol = CreateConVar("stb_convarcontrol", "1", "Enable or Disable the control of builtin console variables", _, true, 0.0, true, 1.0); - stb_buddyenabled = CreateConVar("stb_buddyenabled", "1", "Enable or Disable the buddy system", _, true, 0.0, true, 1.0); - stb_unbalancelimit = CreateConVar("stb_unbalancelimit", "2", "Amount of players teams are ALLOWED to be unbalanced by", _, true, 1.0, true, 32.0); - stb_balancedelay = CreateConVar("stb_balancedelay", "10", "Delay in seconds to start an autobalance"); - stb_livingplayerswitchdelay = CreateConVar("stb_livingplayerswitchdelay", "20", "Delay in seconds to switch living players once selected"); - stb_livingplayercheckdelay = CreateConVar("stb_livingplayercheckdelay", "10", "Delay in seconds to start checking living players once teams become unbalanced"); - stb_roundstartdelay = CreateConVar("stb_roundstartdelay", "15", "Delay in seconds to start balancing teams after the start of a round"); - stb_switchbackforced = CreateConVar("stb_switchbackforced", "300", "Amount of time in seconds to not switch a player twice and force the team if enabled"); - stb_uberlevel = CreateConVar("stb_uberlevel", "1.0", "Min uber level medic must have to have priority over other living players. Setting to 0 will rarely switch a living medic", _, true, 0.0, true, 1.0); - stb_adminflag = CreateConVar("stb_adminflag", "a", "Admin flag to use for immunity. Must be a in char format."); - stb_mp_autoteambalance = FindConVar("mp_autoteambalance"); - stb_mp_teams_unbalance_limit = FindConVar("mp_teams_unbalance_limit"); - - /** - Removing the notify tags from the built in cvars. We dont want spam. - */ - if (stb_mp_autoteambalance != INVALID_HANDLE) - { - SetConVarFlags(stb_mp_autoteambalance, GetConVarFlags(stb_mp_autoteambalance)^FCVAR_NOTIFY); - } - if (stb_mp_teams_unbalance_limit != INVALID_HANDLE) - { - SetConVarFlags(stb_mp_teams_unbalance_limit, GetConVarFlags(stb_mp_teams_unbalance_limit)^FCVAR_NOTIFY); - } - - /** - Hook console variables - */ - HookConVarChange(stb_enabled, ConVarSettingsChanged); - HookConVarChange(stb_priorityenabled, ConVarSettingsChanged); - HookConVarChange(stb_buddyrestriction, ConVarSettingsChanged); - HookConVarChange(stb_logactivity, ConVarSettingsChanged); - HookConVarChange(stb_logactivity2, ConVarSettingsChanged); - HookConVarChange(stb_deadonly, ConVarSettingsChanged); - HookConVarChange(stb_convarcontrol, ConVarSettingsChanged); - HookConVarChange(stb_buddyenabled, ConVarSettingsChanged); - HookConVarChange(stb_unbalancelimit, ConVarSettingsChanged); - HookConVarChange(stb_balancedelay, ConVarSettingsChanged); - HookConVarChange(stb_livingplayerswitchdelay, ConVarSettingsChanged); - HookConVarChange(stb_livingplayercheckdelay, ConVarSettingsChanged); - HookConVarChange(stb_roundstartdelay, ConVarSettingsChanged); - HookConVarChange(stb_switchbackforced, ConVarSettingsChanged); - HookConVarChange(stb_uberlevel, ConVarSettingsChanged); - HookConVarChange(stb_mp_autoteambalance, ConVarSettingsChanged); - HookConVarChange(stb_mp_teams_unbalance_limit, ConVarSettingsChanged); - - /** - Create console commands - */ - RegConsoleCmd("sm_buddy", Command_AddBalanceBuddy, "Add a balance buddy"); - RegConsoleCmd("sm_lockbuddy", Command_LockBuddy, "Locks your balance buddy selection"); - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook the game events - */ - LogAction(0, -1, "[STB] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_death", HookPlayerDeath, EventHookMode_Post); - HookEvent("player_team", HookPlayerChangeTeam, EventHookMode_Post); - switch (g_CurrentMod) - { - case GameType_TF: - { - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - HookEvent("teamplay_suddendeath_begin", HookSuddenDeathBegin, EventHookMode_PostNoCopy); - HookEvent("teamplay_flag_event", HookFlagEvent, EventHookMode_Post); - TFGameModeArena = FindConVar("tf_gamemode_arena"); - g_iOwnerOffset = FindSendPropInfo("CBaseObject", "m_hBuilder"); - } - case GameType_DOD: - { - HookEvent("dod_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_Post); - } - default: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - } - } - - /** - Load translations and .cfg file - */ - LoadTranslations ("simpleteambalancer.phrases"); - AutoExecConfig(true, "plugin.simpleteambalancer"); - LogAction(0, -1, "[STB] Simple Team Balancer is loaded."); -} - -public OnAllPluginsLoaded() -{ - //something -} - -public OnLibraryRemoved(const String:name[]) -{ - //something -} - -public OnConfigsExecuted() -{ - - /** - Load up global variables - */ - g_bIsEnabled = GetConVarBool(stb_enabled); - g_bBuddyEnabled = GetConVarBool(stb_buddyenabled); - g_bLogActivity = GetConVarBool(stb_logactivity); - g_bLogActivity2 = GetConVarBool(stb_logactivity2); - g_bDeadOnly = GetConVarBool(stb_deadonly); - g_bPriorityPlayers = GetConVarBool(stb_priorityenabled); - g_bBuddyRestriction = GetConVarBool(stb_buddyrestriction); - g_bConVarControl = GetConVarBool(stb_convarcontrol); - g_fUberLevel = GetConVarFloat(stb_uberlevel); - g_iUnbalanceLimit = GetConVarInt(stb_unbalancelimit); - g_iBalanceDelay = GetConVarInt(stb_balancedelay); - g_iLivingPlayerSwitchDelay = GetConVarInt(stb_livingplayerswitchdelay); - g_iLivingPlayerCheckDelay = GetConVarInt(stb_livingplayercheckdelay); - g_iRoundStartDelay = GetConVarInt(stb_roundstartdelay); - g_iSwitchBackForced = GetConVarInt(stb_switchbackforced); - GetConVarString(stb_adminflag, g_sAdminFlag, sizeof(g_sAdminFlag)); - - /** - Report enabled - */ - if (g_bIsEnabled) - { - LogAction(0, -1, "[STB] Simple Team Balancer is ENABLED."); - } - else - { - LogAction(0, -1, "[STB] Simple Team Balancer is DISABLED."); - } - - - /** - Report log activity - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Log Activity ENABLED."); - } - else - { - LogAction(0, -1, "[STB] Log Activity DISABLED."); - } - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Detailed Log Activity ENABLED."); - } - else - { - LogAction(0, -1, "[STB] Detailed Log Activity DISABLED."); - } -} - -public OnMapStart() -{ - - /** - Check for arena mode - */ - if (g_CurrentMod == GameType_TF && GetConVarBool(TFGameModeArena)) - { - g_bIsArenaMode = true; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Simple Team Balancer detected arena mode and will be bypassed"); - } - } - else - { - g_bIsArenaMode = false; - } - - /** - Reset the globals - */ - g_bBalanceInProgress = false; - g_bRoundStart = false; - g_bRoundEnd = false; - g_bSuddenDeath = false; - - /** - Set the built-in convars - */ - SetGameCvars(); -} - -public OnClientPostAdminCheck(client) -{ - - /** - Make sure its a valid connected client and buddy system is enabled - */ - if (client == 0 || !g_bIsEnabled || !IsClientConnected(client) || !g_bBuddyEnabled) - { - return; - } - - /** - Make sure if its set for admins only they have the flags - */ - if (g_bBuddyRestriction && !SM_IsValidAdmin(client, g_sAdminFlag)) - { - return; - } - - /** - Start the advertisement timer - */ - CreateTimer (60.0, Timer_WelcomeAdvert, client); -} - -public OnClientDisconnect(client) -{ - - /** - Call stock function to cleaup - */ - CleanUp(client); -} - -public OnClientDisconnect_Post(client) -{ - - /** - Determine if we need a balance - */ - if (OkToBalance() && IsUnbalanced() && !g_bBalanceInProgress) - { - - /** - No balance in progress but balance is needed - */ - StartABalance(); - } -} - -public SM_OnPlayerMoved(Handle:plugin, client, team) -{ - - /** - Make sure we called the move function - */ - if (plugin != GetMyHandle()) - { - if (g_bLogActivity2) - { - LogAction(0, client, "[STB] Callback was not started with current plugin, bugging out."); - } - return; - } - - /** - Get the players name and report the event - */ - decl String:sPlayerName[64]; - GetClientName(client, sPlayerName, sizeof(sPlayerName)); - if (g_bLogActivity) - { - LogAction(0, client, "[STB] Changed %s to team %i.", sPlayerName, team); - } - - /** - If we are in TF2 fire the bult-in team balance event - */ - if(g_CurrentMod == GameType_TF) - { - new Handle:event = CreateEvent("teamplay_teambalanced_player"); - SetEventInt(event, "player", client); - SetEventInt(event, "team", team); - FireEvent(event); - } - - /** - Notify the players - */ - PrintToChatAll("[SM] %T", "BalanceMessage", LANG_SERVER, sPlayerName); - - /** - Set the players variables and start a timer - */ - g_aPlayers[client][bSwitched] = true; - g_aPlayers[client][hForcedTimer] = CreateTimer(float(g_iSwitchBackForced), Timer_ForcedExpired, client, TIMER_FLAG_NO_MAPCHANGE); - - /** - We are done, log the completion and end the balance - */ - if (g_bLogActivity) - { - LogAction(0, client, "[STB] Balance finished."); - } - g_bBalanceInProgress = false; -} - -/* HOOKED EVENTS */ - -public HookPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get our event variables - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - decl String:sWeapon[64]; - GetEventString(event, "weapon", sWeapon, sizeof(sWeapon)); - - /** - Return if death was not caused by a player - This is the case when the player switches teams - */ - if (StrEqual(sWeapon, "world", false)) - { - return; - } - - - /** - Check if balance is needed - */ - if (IsClientInGame(iClient) && OkToBalance() && IsUnbalanced()) - { - new iSmallerTeam = GetSmallerTeam(); - - /** - Check if balance is in progress - */ - if (g_bBalanceInProgress) - { - - /** - There is a balance in progress - Check the player who died to see if he is supposed to be switched - */ - if (g_aPlayers[iClient][hBalanceTimer] != INVALID_HANDLE) - { - - /** - The player has a timer on him to switch him to other team - Stop the timer - */ - CloseHandle(g_aPlayers[iClient][hBalanceTimer]); - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - if (g_bLogActivity) - { - LogAction(0, iClient, "[STB] With a balance in progress the queued living player died and was switched."); - } - - /** - Call the stock change team function - */ - BalancePlayer(iClient, SM_GetForcedTeam(iClient)); - return; - } - - /** - Before we continue, lets make sure the client is switchable - */ - if (IsSwitchablePlayer(iClient, GetBiggerTeam())) - { - - /** - Now we check the buddy system - */ - if (g_bBuddyEnabled) - { - - /** - Buddy system is enabled, check to see if client has buddy - */ - new iBuddyIndex = SM_GetClientBuddy(iClient); - if (iBuddyIndex != 0 || !IsClientConnected(iBuddyIndex) || !IsClientInGame(iBuddyIndex)) - { - - /** - The client has a buddy, so we check to see if they are on same team - */ - if (GetClientTeam(iClient) == GetClientTeam(iBuddyIndex)) - { - - /** - They are, but we don't bug out, we still need to start a balance - */ - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] With a balance in progress a buddy on the right team was found and skipped."); - } - } - else - { - - /** - They are not on the same team - The buddy could be in spec, and that would make it not matter where he is, or the buddy is on the smaller team - */ - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] With a balance in progress a buddy on the wrong team was switched."); - } - BalancePlayer(iClient, iSmallerTeam); - return; - } - } - else - { - - /** - Client doesn't have a buddy, balance this player - */ - BalancePlayer(iClient, iSmallerTeam); - return; - } - } - else - { - - /** - Buddy system is not enabled, balance this player - */ - BalancePlayer(iClient, iSmallerTeam); - return; - } - } - } - else - { - - /** - If we get to here then we must need to start a balance - */ - StartABalance(); - } - } -} - -public HookPlayerChangeTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get our event variables. - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - new iTeam = GetEventInt(event, "team"); - - /** - Make sure its ok to balance. - */ - if (OkToBalance()) - { - - /** - See if the client that changed teams was set to with a balance. - */ - if (g_aPlayers[iClient][hBalanceTimer] != INVALID_HANDLE - && SM_GetForcedTeam(iClient) == iTeam - && g_bBalanceInProgress) - { - - /** - The client was set to be balanced, so we close the timer. - */ - CloseHandle(g_aPlayers[iClient][hBalanceTimer]); - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - - /** - Stop the balance. - */ - g_bBalanceInProgress = false; - return; - } - - /** - It's not likely that this team change can cause us to need a balance. - If it does, start one with a small dealy to deal with forced switch backs. - */ - if (IsUnbalanced() && !g_bBalanceInProgress) - { - CreateTimer(2.0, Timer_ChangeTeamBalanceDelay, _, TIMER_FLAG_NO_MAPCHANGE); - } - } -} - -public HookRoundStart(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Set the variables we need to start a round - */ - g_bRoundStart = true; - g_bRoundEnd = false; - g_bSuddenDeath = false; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Round Started"); - } - - /** - Start a delayed balance check at the start of the round - */ - CreateTimer(float(g_iRoundStartDelay), Timer_RoundStart); -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Set the variables we need at round end - */ - g_bRoundEnd = true; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Round Ended"); - } -} - -public HookSuddenDeathBegin(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Set the variables we need for sudden death - */ - g_bSuddenDeath = true; -} - -public HookFlagEvent(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get our event variables - */ - new iClient = GetEventInt(event, "player"); - new iFlagStatus = GetEventInt(event, "eventtype"); - - /** - Make sure we have a valid client - */ - if (!IsClientInGame(iClient)) - { - return; - } - - /** - Determine what kind of event this is - */ - switch (iFlagStatus) - { - case 1: - { - - /** - The flag was picked up - */ - g_aPlayers[iClient][bFlagCarrier] = true; - } - case 2: - { - - /** - The flag was capped - */ - g_aPlayers[iClient][bFlagCarrier] = false; - } - case 3: - { - - /** - The flag was defended, we don't have to do anything - */ - } - case 4: - { - - /** - The flag was dropped - */ - g_aPlayers[iClient][bFlagCarrier] = false; - } - } -} - -/* COMMAND EVENTS */ - -public Action:Command_AddBalanceBuddy(client, args) -{ - if (client == 0) - { - ReplyToCommand(client, "[SM] %T", "PlayerLevelCmd", LANG_SERVER); - return Plugin_Handled; - } - if (!g_bIsEnabled || !g_bBuddyEnabled) - { - ReplyToCommand(client, "[SM] %T", "CmdDisabled", LANG_SERVER); - return Plugin_Handled; - } - if (g_bBuddyRestriction) - { - if (!SM_IsValidAdmin(client, g_sAdminFlag)) - { - ReplyToCommand(client, "[SM] %T", "RestrictedBuddy", LANG_SERVER); - return Plugin_Handled; - } - } - decl String:sPlayerUserId[24]; - GetCmdArg(1, sPlayerUserId, sizeof(sPlayerUserId)); - new iPlayer = GetClientOfUserId(StringToInt(sPlayerUserId)); - if (!iPlayer || !IsClientInGame(iPlayer) || client == iPlayer) - { - if (client == iPlayer) - { - PrintHintText(client, "%T", "SelectSelf", LANG_SERVER); - } - ReplyToCommand(client, "[SM] Usage: buddy "); - new Handle:playermenu = BuildPlayerMenu(); - DisplayMenu(playermenu, client, MENU_TIME_FOREVER); - } - else - { - decl String:cName[128]; - decl String:bName[128]; - GetClientName(client, cName, sizeof(cName)); - GetClientName(iPlayer, bName, sizeof(bName)); - if (SM_IsBuddyLocked(iPlayer)) - { - ReplyToCommand(client, "[SM] %T", "PlayerLockedBuddyMsg", LANG_SERVER, bName); - return Plugin_Handled; - } - SM_AssignBuddy(client, iPlayer); - PrintHintText(client, "%T", "BuddyMsg", LANG_SERVER, bName); - PrintHintText(iPlayer, "%T", "BuddyMsg", LANG_SERVER, cName); - } - return Plugin_Handled; -} - -public Action:Command_LockBuddy(client, args) -{ - if (client == 0) - { - ReplyToCommand(client, "[SM] %T", "PlayerLevelCmd", LANG_SERVER); - return Plugin_Handled; - } - if (!g_bIsEnabled) - { - ReplyToCommand(client, "[SM] %T", "CmdDisabled", LANG_SERVER); - return Plugin_Handled; - } - if (g_bBuddyRestriction) - { - if (!SM_IsValidAdmin(client, g_sAdminFlag)) - { - ReplyToCommand(client, "[SM] %T", "RestrictedBuddy", LANG_SERVER); - return Plugin_Handled; - } - } - if (SM_IsBuddyLocked(client)) - { - SM_LockBuddy(client, false); - PrintHintText(client, "%T", "BuddyLockMsgDisabled", LANG_SERVER); - } - else - { - SM_LockBuddy(client, true); - PrintHintText(client, "%T", "BuddyLockMsgEnabled", LANG_SERVER); - } - return Plugin_Handled; -} - -/** -Stock functions . - */ - -stock bool:IsUnbalanced() -{ - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Checking if teams are unbalanced"); - } - new Team1Count = GetTeamClientCount(g_aCurrentTeams[Team1]); - new Team2Count = GetTeamClientCount(g_aCurrentTeams[Team2]); - new ubCount = RoundFloat(FloatAbs(float(Team1Count - Team2Count))); - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Team1:%i Team2:%i Difference:%i", Team1Count, Team2Count, ubCount); - } - if (ubCount > g_iUnbalanceLimit) - { - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Teams are unbalanced"); - } - return true; - } - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Teams are not unbalanced"); - } - return false; -} - -stock bool:OkToBalance() -{ - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Checking if OK to balance."); - } - new bool:bResult = false; - if (g_bIsEnabled && !g_bRoundStart && !g_bRoundEnd && !g_bIsArenaMode && !g_bSuddenDeath) - { - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Passed IF statement"); - LogAction(0, -1, "[STB] Now checking admins"); - } - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientInGame(i) && !SM_IsValidAdmin(i, g_sAdminFlag)) - { - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Found at least 1 non-admin"); - LogAction(0, -1, "[STB] OK to balance"); - } - bResult = true; - break; - } - } - if (!bResult && g_bLogActivity2) - { - LogAction(0, -1, "[STB] All admins online"); - } - } - if (!bResult && g_bLogActivity2) - { - LogAction(0, -1, "[STB] Not OK to balance"); - } - return bResult; -} - -stock bool:IsSwitchablePlayer(iClient, iBiggerTeam) -{ - - /** - Run the client thru some standard checks - */ - if (!IsClientInGame(iClient) - || SM_IsValidAdmin(iClient, g_sAdminFlag) - || g_aPlayers[iClient][bFlagCarrier] - || GetClientTeam(iClient) != iBiggerTeam - || g_aPlayers[iClient][bSwitched]) - { - - /** - The supplied client can't be switched - */ - return false; - } - - /** - The supplied client can be switched - */ - return true; -} - -stock bool:HasUber(iClient) -{ - - /** - First things first, make sure the client is a medic - */ - if(TF2_GetPlayerClass(iClient) == TFClass_Medic) - { - - /** - We can only check the active weapon, so make sure the client is holding the uber gun - */ - decl String:sWeaponName[32]; - GetClientWeapon(iClient, sWeaponName, sizeof(sWeaponName)); - if(StrEqual(sWeaponName, "tf_weapon_medigun")) - { - - /** - They are, so lets check the uber level of the gun - */ - new iEntityIndex = GetEntDataEnt2(iClient, FindSendPropInfo("CTFPlayer", "m_hActiveWeapon")); - new Float:fChargeLevel = GetEntDataFloat(iEntityIndex, FindSendPropInfo("CWeaponMedigun", "m_flChargeLevel")); - if (fChargeLevel >= g_fUberLevel) - { - - /** - The client supplied has an uber above the supplied level, return true - */ - if (g_bLogActivity2) - { - LogAction(0, iClient, "[STB] Found a medic with a uber and skipped him."); - } - return true; - } - } - } - - /** - The client supplied does not have an uber above the supplied level, return false - */ - return false; -} - -stock bool:HasBuildingsBuilt(iClient) -{ - - /** - We have to start a loop to check the owner of all the valid entities - */ - new iMaxEntities = GetMaxEntities(); - for (new i = MaxClients + 1; i <= iMaxEntities; i++) - { - if (!IsValidEntity(i)) - { - - /** - Not valid, continue to next one - */ - continue; - } - - /** - Get the name of the current entity - */ - decl String:sNetClass[32]; - GetEntityNetClass(i, sNetClass, sizeof(sNetClass)); - - /** - See if its something that an engineer would build - */ - if (strcmp(sNetClass, "CObjectSentrygun") == 0 - || strcmp(sNetClass, "CObjectTeleporter") == 0 - || strcmp(sNetClass, "CObjectDispenser") == 0) - { - - /** - It is, so lets check the owner - */ - if (GetEntDataEnt2(i, g_iOwnerOffset) == iClient) - { - - /** - The client supplied is the owner, return true - */ - if (g_bLogActivity2) - { - LogAction(0, iClient, "[STB] Found an engineer with buildings and skipped him."); - } - return true; - } - } - } - - /** - The client supplied didn't have any buildings, return false - */ - return false; -} - -stock StartABalance() -{ - - /** - See if we are already started a balance - */ - if (g_hBalanceTimer != INVALID_HANDLE) - { - - /** - We have, check if we still need to - */ - if (!IsUnbalanced() || !OkToBalance()) - { - - /** - We don't, stop the balance - It's almost impossible to reach this code, but we do it just in case - */ - CloseHandle(g_hBalanceTimer); - g_hBalanceTimer = INVALID_HANDLE; - g_bBalanceInProgress = false; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Balance delay timer was not needed and was killed before the callback."); - } - return; - } - else - { - - /** - We still need to balance - Bug out and wait for the current one to finish - */ - return; - } - } - - /** - Report that teams are unbalanced - */ - PrintToChatAll("[SM] %T", "UnBalanced", LANG_SERVER); - - /** - Check to see if we are supposed to delay the balance - */ - if (g_iBalanceDelay == 0) - { - - /** - Start the balance now - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Balance is now in progress."); - } - g_bBalanceInProgress = true; - g_hBalanceTimer = INVALID_HANDLE; - - /** - Check if we are allowed to scan living players - */ - if (!g_bDeadOnly) - { - - /** - We are allowed to, so we start a timer - */ - StartALivingPlayerTimer(); - - /** - Also report that we are now scanning dead players as well - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Now scanning dead players."); - } - } - else - { - - /** - We are not allowed to, so report that we are only scanning dead players - */ - if (g_bLogActivity) - LogAction(0, -1, "[STB] Only scanning dead players."); - } - - /** - We started the balance, bug out - */ - return; - } - - /** - We are supposed to delay the balance, start a balance timer - */ - g_hBalanceTimer = CreateTimer(float(g_iBalanceDelay), Timer_BalanceTeams, _, TIMER_FLAG_NO_MAPCHANGE); - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Teams are unbalanced. Balance delay timer started."); - } -} - -stock StartALivingPlayerTimer() -{ - - /** - Start a timer to check living players - */ - if (g_hLivingPlayerCheckTimer != INVALID_HANDLE) - { - - /** - If we for some reason already have one started, stop it. - */ - CloseHandle(g_hLivingPlayerCheckTimer); - g_hLivingPlayerCheckTimer = INVALID_HANDLE; - } - - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Living player balance delay timer started."); - } - g_hLivingPlayerCheckTimer = CreateTimer(float(g_iLivingPlayerCheckDelay), Timer_LivingPlayerCheck, _, TIMER_FLAG_NO_MAPCHANGE); -} - -stock FindSwitchablePlayer() -{ - - /** - Start a loop to find a switchable player - */ - new iPlayer; - new iBiggerTeam = GetBiggerTeam(); - for (new i = 1; i <= MaxClients; i++) - { - - /** - Check the stock function to see if we are allows to even switch the player - */ - if (!IsSwitchablePlayer(i, iBiggerTeam)) - { - continue; - } - - /** - If the mod is TF2 and they have Priority Players set check if the client has buildings or an uber - */ - if (g_CurrentMod == GameType_TF && g_bPriorityPlayers) - { - if (HasUber(i) || HasBuildingsBuilt(i)) - { - continue; - } - } - - /** - So far we are able we switch this player - Now we check the buddy system - */ - if (g_bBuddyEnabled) - { - - /** - Buddy system is enabled, check to see if client has buddy - */ - if (SM_GetClientBuddy(i) != 0) - { - - /** - The client has a buddy, so we check to see if they are on same team - */ - if (GetClientTeam(i) == GetClientTeam(SM_GetClientBuddy(i))) - { - - /** - They are, so we continue to next client - */ - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] With a balance in progress a buddy on the right team was found and skipped."); - } - continue; - } - else - { - - /** - They are not on the same team, set this client - The buddy could be in spec, and that would make it not matter where he is, or the buddy is on the smaller team - */ - iPlayer = i; - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] With a balance in progress a buddy on the wrong team was found."); - } - break; - } - } - else - { - - /** - The client does not have a buddy, set this client - */ - iPlayer = i; - break; - } - } - else - { - - /** - Buddy system is not enabled, set this client - */ - iPlayer = i; - break; - } - } - - /** - Return the client we set, this could be 0, but very unlikely - */ - return iPlayer; -} - -stock BalancePlayer(iClient, iTeam) -{ - new Handle:hPack = CreateDataPack(); - WritePackCell(hPack, iClient); - WritePackCell(hPack, iTeam); - CreateTimer(0.1, Timer_BalancePlayer, hPack, TIMER_FLAG_NO_MAPCHANGE); -} - -stock CleanUp(iClient) -{ - g_aPlayers[iClient][bFlagCarrier] = false; - g_aPlayers[iClient][bSwitched] = false; - if (g_aPlayers[iClient][hForcedTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[iClient][hForcedTimer]); - g_aPlayers[iClient][hForcedTimer] = INVALID_HANDLE; - if (g_bLogActivity) - { - LogAction(0, iClient, "[STB] Forced player disconnected, killing timer."); - } - } - if (g_aPlayers[iClient][hBalanceTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[iClient][hBalanceTimer]); - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - if (g_bLogActivity) - { - LogAction(0, iClient, "[STB] Living player set to be balanced disconnected, killing timer."); - } - } -} - -stock GetSmallerTeam() -{ - - /** - Get the count of players on each team - */ - new iCountT1 = GetTeamClientCount(g_aCurrentTeams[Team1]); - new iCountT2 = GetTeamClientCount(g_aCurrentTeams[Team2]); - - /** - Return the smaller team - */ - if (iCountT1 < iCountT2) - { - return g_aCurrentTeams[Team1]; - } - else if (iCountT1 > iCountT2) - { - return g_aCurrentTeams[Team2]; - } - return 0; -} - -stock GetBiggerTeam() -{ - - /** - Get the count of players on each team - */ - new iCountT1 = GetTeamClientCount(g_aCurrentTeams[Team1]); - new iCountT2 = GetTeamClientCount(g_aCurrentTeams[Team2]); - - /** - Return the bigger team - */ - if (iCountT1 > iCountT2) - { - return g_aCurrentTeams[Team1]; - } - else if (iCountT1 < iCountT2) - { - return g_aCurrentTeams[Team2]; - } - return 0; -} - -stock SetGameCvars() -{ - if (g_bConVarControl && g_bIsEnabled) - { - if (stb_mp_autoteambalance != INVALID_HANDLE) - { - SetConVarInt(stb_mp_autoteambalance, 0); - } - if (stb_mp_teams_unbalance_limit != INVALID_HANDLE) - { - SetConVarInt(stb_mp_teams_unbalance_limit, g_iUnbalanceLimit); - } - } -} - -/* TIMER FUNCTIONS */ - -public Action:Timer_ChangeTeamBalanceDelay(Handle:timer, any:data) -{ - - /** - Finally start one if it's still unbalanced - */ - if (IsUnbalanced() && !g_bBalanceInProgress) - { - StartABalance(); - } -} - -public Action:Timer_BalanceTeams(Handle:timer, any:data) -{ - - /** - See if we still need to balance the teams - */ - if (!IsUnbalanced() || !OkToBalance()) - { - - /** - We don't, kill the balance - */ - g_bBalanceInProgress = false; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Balance delay timer was not needed and died."); - } - g_hBalanceTimer = INVALID_HANDLE; - return Plugin_Handled; - } - - /** - We still need to balance the teams - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Teams are still unbalanced. Balance is now in progress."); - } - g_bBalanceInProgress = true; - - - /** - Check if we are allowed to scan living players - */ - if (!g_bDeadOnly) - { - - /** - We are allowed to, so we start a timer - */ - StartALivingPlayerTimer(); - - /** - Also report that we are now scanning dead players as well - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Now scanning dead players."); - } - } - else - { - - /** - We are not allowed to, so report that we are only scanning dead players - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Only scanning dead players."); - } - } - - g_hBalanceTimer = INVALID_HANDLE; - return Plugin_Handled; -} - -public Action:Timer_LivingPlayerCheck(Handle:timer, any:data) -{ - - /** - Check to see if we still need to balance the teams - */ - if (!IsUnbalanced() || !OkToBalance()) - { - - /** - We don't, kill it and bug out - */ - g_bBalanceInProgress = false; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Living player balance delay timer was not needed and died."); - } - g_hLivingPlayerCheckTimer = INVALID_HANDLE; - return Plugin_Handled; - } - - /** - Call the stock function to find a player we can switch - */ - new iPlayer = FindSwitchablePlayer(); - - /** - Check to see if we found a player - */ - if (iPlayer == 0) - { - - /** - In the unlikely event that the stock function didn't return a player - Start a loop to find a random player - */ - new iBiggerTeam = GetBiggerTeam(); - do - { - iPlayer = GetRandomInt(1, MaxClients); - } while (!IsSwitchablePlayer(iPlayer, iBiggerTeam)); - - if (g_bLogActivity) - { - LogAction(0, iPlayer, "[STB] Found a random living player."); - } - } - else - { - if (g_bLogActivity) - { - LogAction(0, iPlayer, "[STB] Found a living player."); - } - } - - /** - Now that we have a player assigned them to the smaller team - */ - new iSmallerTeam = GetSmallerTeam(); - SM_SetForcedTeam(iPlayer, iSmallerTeam, true); - - /** - Let the player know we could be switching him soon - */ - PrintHintText(iPlayer, "%T", "PlayerMessage", LANG_SERVER, g_iLivingPlayerSwitchDelay); - if (g_bLogActivity) - { - LogAction(0, iPlayer, "[STB] Living player placed on a timer."); - } - - /** - Create a timer to switch the player - */ - g_aPlayers[iPlayer][hBalanceTimer] = CreateTimer(float(g_iLivingPlayerSwitchDelay), Timer_LivingPlayerBalance, iPlayer, TIMER_FLAG_NO_MAPCHANGE); - - /** - Reset the timer handle - */ - g_hLivingPlayerCheckTimer = INVALID_HANDLE; - - /** - We are done, bug out - */ - return Plugin_Handled; -} - -public Action:Timer_LivingPlayerBalance(Handle:timer, any:iClient) -{ - - /** - Check to make sure we still need to balance - */ - if (!IsUnbalanced() || !OkToBalance()) - { - - /** - We don't need to balance, bug out - */ - g_bBalanceInProgress = false; - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - SM_ClearForcedTeam(iClient); - return Plugin_Handled; - } - - /** - We still need to balance, lets make sure we can still balance this player - */ - if (!IsClientConnected(iClient) || g_aPlayers[iClient][bFlagCarrier]) - { - g_bBalanceInProgress = false; - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - SM_ClearForcedTeam(iClient); - if (g_bLogActivity) - { - if (g_aPlayers[iClient][bFlagCarrier]) - { - LogAction(0, iClient, "[STB] Living player became flag carrier, balance restarted."); - } - else - { - LogAction(0, iClient, "[STB] Living player timer was not needed and died."); - } - } - return Plugin_Handled; - } - - /** - Clear to balance this player, so do it - */ - BalancePlayer(iClient, SM_GetForcedTeam(iClient)); - if (g_bLogActivity) - { - LogAction(0, iClient, "[STB] Living player was switched."); - } - - /** - We are done, bug out - */ - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - return Plugin_Handled; -} - -public Action:Timer_BalancePlayer(Handle:timer, Handle:pack) -{ - - /** - Rest the datapack and load the variables - */ - ResetPack(pack); - new iClient = ReadPackCell(pack); - new iUnBalancedTeam = ReadPackCell(pack); - - /** - We are done with you now - */ - CloseHandle(pack); - - /** - Check the team and make sure its a valid team - */ - if(!SM_IsValidTeam(iUnBalancedTeam)) - { - if (g_bLogActivity) - { - LogAction(0, iClient, "[STB] Balance failed due to invalid team number %i", iUnBalancedTeam); - } - return Plugin_Handled; - } - - /** - Use our core function to change the clients team - */ - SM_MovePlayer(iClient, iUnBalancedTeam); - - return Plugin_Handled; -} - -public Action:Timer_RoundStart(Handle:timer, any:data) -{ - g_bRoundStart = false; - if (OkToBalance() && IsUnbalanced() && !g_bBalanceInProgress) - { - StartABalance(); - } - return Plugin_Handled; -} - -public Action:Timer_ForcedExpired(Handle:timer, any:iClient) -{ - SM_ClearForcedTeam(iClient); - g_aPlayers[iClient][bSwitched] = false; - g_aPlayers[iClient][hForcedTimer] = INVALID_HANDLE; - return Plugin_Handled; -} - -public Action:Timer_WelcomeAdvert(Handle:timer, any:iClient) -{ - if (IsClientConnected(iClient) && IsClientInGame(iClient)) - { - PrintToChat (iClient, "\x01\x04[STB]\x01 %T", "BuddyWelcomeMsg1", LANG_SERVER); - PrintToChat (iClient, "\x01\x04[STB]\x01 %T", "BuddyWelcomeMsg2", LANG_SERVER); - PrintToChat (iClient, "\x01\x04[STB]\x01 %T", "BuddyWelcomeMsg3", LANG_SERVER); - } - return Plugin_Handled; -} - -/* CONSOLE VARIABLE CHANGE EVENT */ - -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (convar == stb_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsEnabled = false; - PrintToChatAll("[SM] %T", "Disabled", LANG_SERVER); - LogAction(0, -1, "[SimpleTeamBalancer] Disabled"); - } - else - { - g_bIsEnabled = true; - SetGameCvars(); - PrintToChatAll("[SM] %T", "Enabled", LANG_SERVER); - LogAction(0, -1, "[SimpleTeamBalancer] Enabled"); - } - } - else if (convar == stb_logactivity) - { - if (StringToInt(newValue) == 0) - { - g_bLogActivity = false; - LogAction(0, -1, "[STB] Log Activity DISABLED."); - } - else - { - g_bLogActivity = true; - LogAction(0, -1, "[STB] Log Activity ENABLED."); - } - } - else if (convar == stb_logactivity2) - { - if (StringToInt(newValue) == 0) - { - g_bLogActivity2 = false; - LogAction(0, -1, "[STB] Detailed Log Activity DISABLED."); - } - else - { - g_bLogActivity2 = true; - LogAction(0, -1, "[STB] Detailed Log Activity ENABLED."); - } - } - else if (convar == stb_convarcontrol) - { - if (StringToInt(newValue) == 0) - { - g_bConVarControl = false; - } - else - { - g_bConVarControl = true; - SetGameCvars(); - } - } - else if (convar == stb_deadonly) - { - if (StringToInt(newValue) == 0) - { - g_bDeadOnly = false; - } - else - { - g_bDeadOnly = true; - } - } - else if (convar == stb_priorityenabled) - { - if (StringToInt(newValue) == 0) - { - g_bPriorityPlayers = false; - } - else - { - g_bPriorityPlayers = true; - } - } - else if (convar == stb_buddyenabled) - { - if (StringToInt(newValue) == 0) - { - g_bBuddyEnabled = false; - } - else - { - g_bBuddyEnabled = true; - } - } - else if (convar == stb_buddyrestriction) - { - if (StringToInt(newValue) == 0) - { - g_bBuddyRestriction = false; - } - else - { - g_bBuddyRestriction = true; - } - } - else if (convar == stb_unbalancelimit) - { - g_iUnbalanceLimit = StringToInt(newValue); - SetGameCvars(); - } - else if (convar == stb_balancedelay) - { - g_iBalanceDelay = StringToInt(newValue); - } - else if (convar == stb_roundstartdelay) - { - g_iRoundStartDelay = StringToInt(newValue); - } - else if (convar == stb_livingplayerswitchdelay) - { - g_iLivingPlayerSwitchDelay = StringToInt(newValue); - } - else if (convar == stb_livingplayercheckdelay) - { - g_iLivingPlayerCheckDelay = StringToInt(newValue); - } - else if (convar == stb_uberlevel) - { - g_fUberLevel = StringToFloat(newValue); - } - else if (convar == stb_switchbackforced) - { - g_iSwitchBackForced = StringToInt(newValue); - } - else if (convar == stb_adminflag) - { - SetConVarString(stb_adminflag, newValue); - } - else if (convar == stb_mp_autoteambalance) - { - SetGameCvars(); - } - else if (convar == stb_mp_teams_unbalance_limit) - { - SetGameCvars(); - } -} - -/* MENU CODE */ - -stock Handle:BuildPlayerMenu() -{ - new Handle:menu = CreateMenu(Menu_SelectPlayer); - AddTargetsToMenu(menu, 0, true, false); - SetMenuTitle(menu, "Select A Player:"); - SetMenuExitButton(menu, true); - return menu; -} - -public Menu_SelectPlayer(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[24]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - new buddy = GetClientOfUserId(StringToInt(sSelection)); - if (param1 == buddy) { - PrintHintText(param1, "%T", "SelectSelf", LANG_SERVER); - } else if (!IsClientInGame(buddy)) { - PrintHintText(param1, "%T", "BuddyGone", LANG_SERVER); - } else { - decl String:cName[128]; - decl String:bName[128]; - GetClientName(param1, cName, sizeof(cName)); - GetClientName(buddy, bName, sizeof(bName)); - if (!SM_IsBuddyLocked(buddy)) { - SM_AssignBuddy(param1, buddy); - PrintHintText(param1, "%T", "BuddyMsg", LANG_SERVER, bName); - PrintHintText(buddy, "%T", "BuddyMsg", LANG_SERVER, cName); - } else - PrintHintText(param1, "%T", "PlayerLockedBuddyMsg", LANG_SERVER, bName); - } - } else if (action == MenuAction_End) { - CloseHandle(menu); - } -} \ No newline at end of file diff --git a/Simple Round Immunity/addons/sourcemod/scripting/simple-teammanager.sp b/Simple Round Immunity/addons/sourcemod/scripting/simple-teammanager.sp deleted file mode 100644 index 008f443..0000000 --- a/Simple Round Immunity/addons/sourcemod/scripting/simple-teammanager.sp +++ /dev/null @@ -1,1351 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Team Manager -Description: - Manges players and their team - Admin menu integration - Allows admins/donators to swap their teams (clears force)* - Allows admins to move players to a team (forced\unforced)* - Allows admins to scramble the teams* - *Works with Simple Team Balancer (if installed) -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include - -#define PLUGIN_VERSION "2.1.$Rev$" -#define VOTE_YES "##YES##" -#define VOTE_NO "##NO##" - -enum PlayerData -{ - iNewTeam, - bool:bQueue -}; - -new Handle:stm_enabled = INVALID_HANDLE; -new Handle:stm_logactivity = INVALID_HANDLE; -new Handle:stm_adminflag_swapteam = INVALID_HANDLE; -new Handle:stm_adminflag_moveplayer = INVALID_HANDLE; -new Handle:stm_adminflag_scramble = INVALID_HANDLE; -new Handle:stm_scrambledelay = INVALID_HANDLE; -new Handle:stm_voteenabled = INVALID_HANDLE; -new Handle:stm_votewin = INVALID_HANDLE; -new Handle:stm_votedelay = INVALID_HANDLE; -new Handle:stm_mp_bonusroundtime = INVALID_HANDLE; -new Handle:g_hAdminMenu = INVALID_HANDLE; -new Handle:g_hTimerPrepScramble = INVALID_HANDLE; -new Handle:g_hTimerClearScrambleForce = INVALID_HANDLE; - -new g_aPlayers[MAXPLAYERS + 1][PlayerData]; - -new bool:g_bIsEnabled = true; -new bool:g_bVoteEnabled = true; -new bool:g_bLogActivity = true; -new bool:g_bScrambleRoundEnd = false; -new g_iVoteDelay, g_iLastVoteTime, g_iTimeLeft; -new Float:g_fScrambleDelay, Float:g_fVoteWin; - -public Plugin:myinfo = -{ - name = "Simple Team Manager", - author = "Simple Plugins", - description = "Manages players and thier team.", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -}; - -public OnPluginStart() -{ - - /** - Need to create all of our console variables. - */ - CreateConVar("stm_version", PLUGIN_VERSION, "Simple Team Manager Version",FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - stm_enabled = CreateConVar("stm_enabled", "1", "Enable or Disable Simple Team Manager", _, true, 0.0, true, 1.0); - stm_logactivity = CreateConVar("stm_logactivity", "0", "Enable or Disable the disaplying of events in the log", _, true, 0.0, true, 1.0); - stm_adminflag_swapteam = CreateConVar("stm_adminflag_swapteam", "a", "Admin flag to use for the swapteam command. Must be a in char format."); - stm_adminflag_moveplayer = CreateConVar("stm_adminflag_moveplayer", "c", "Admin flag to use for the moveplayer command. Must be a in char format."); - stm_adminflag_scramble = CreateConVar("stm_adminflag_scramble", "c", "Admin flag to use for the scrambleteam command. Must be a in char format."); - stm_scrambledelay = CreateConVar("stm_scrambledelay", "15", "Delay to scramble teams"); - stm_voteenabled = CreateConVar("stm_voteenabled", "1", "Enable or Disable voting to scramble the teams", _, true, 0.0, true, 1.0); - stm_votewin = CreateConVar("stm_votewin", "0.45", "Win percentage vote must win by", _, true, 0.0, true, 1.0); - stm_votedelay = CreateConVar("stm_votedelay", "600", "Delay before another vote can be cast"); - stm_mp_bonusroundtime = FindConVar("mp_bonusroundtime"); - - - /** - Need deal with changes to the console variables after the plugin is loaded. - We could not do this and just call the actual console variable each time we need it, but it's not efficent. - */ - HookConVarChange(stm_enabled, ConVarSettingsChanged); - HookConVarChange(stm_logactivity, ConVarSettingsChanged); - HookConVarChange(stm_scrambledelay, ConVarSettingsChanged); - HookConVarChange(stm_voteenabled, ConVarSettingsChanged); - HookConVarChange(stm_votewin, ConVarSettingsChanged); - HookConVarChange(stm_votedelay, ConVarSettingsChanged); - - /** - Need to register the commands we are going to create and use. - */ - RegConsoleCmd("sm_swapteam", Command_SwapTeam, "sm_swapteam <[0]instant/[1]queued>: Swaps your team to the other team"); - RegConsoleCmd("sm_moveplayer", Command_MovePlayer, "sm_moveplayer <[0]instant/[1]ondeath> <[0]unforced/[1]forced>: Moves a player to the specified team"); - RegConsoleCmd("sm_scrambleteams", Command_ScrambleTeams, "sm_scrambleteams: <[0]now/[1]roundend> <[0]dontrestart/[1]restartround> Scrambles the current teams"); - RegConsoleCmd("sm_votescramble", Command_VoteScramble, "sm_votescramble: Starts a vote to scramble the teams"); - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook the game events - */ - LogAction(0, -1, "[STM] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_death", HookPlayerDeath, EventHookMode_Post); - HookEvent("player_team", HookPlayerChangeTeam, EventHookMode_Post); - switch (g_CurrentMod) - { - case GameType_TF: - { - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - } - case GameType_DOD: - { - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_Post); - } - default: - { - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - } - } - - /** - Now we have to deal with the admin menu. If the admin library is loaded call the function to add our items. - */ - new Handle:gTopMenu; - if (LibraryExists("adminmenu") && ((gTopMenu = GetAdminTopMenu()) != INVALID_HANDLE)) - { - OnAdminMenuReady(gTopMenu); - } - - /** - Load translations and .cfg file - */ - LoadTranslations ("simpleteammanager.phrases"); - AutoExecConfig(true, "plugin.simpleteammanager"); - LogAction(0, -1, "[STM] Simple Team Manager is loaded."); -} - -public OnAllPluginsLoaded() -{ - //something -} - -public OnLibraryRemoved(const String:name[]) -{ - if (StrEqual(name, "adminmenu")) - { - - /** - Looks like the admin menu was removed. Set the global. - */ - g_hAdminMenu = INVALID_HANDLE; - } - else if (StrEqual(name, "simpleplugins")) - { - SetFailState("Required plugin Simple SourceMod Plugins Core was removed."); - } -} - -public OnConfigsExecuted() -{ - - /** - Once we loaded up all the console variables from the config file, lets now set all the global variables we will use. - */ - g_bIsEnabled = GetConVarBool(stm_enabled); - g_bLogActivity = GetConVarBool(stm_logactivity); - g_fScrambleDelay = GetConVarFloat(stm_scrambledelay); - g_iVoteDelay = GetConVarInt(stm_votedelay); - g_fVoteWin = GetConVarFloat(stm_votewin); - g_iLastVoteTime = RoundFloat(GetEngineTime()); - g_bScrambleRoundEnd = false; - g_hTimerClearScrambleForce = INVALID_HANDLE; - - /** - Report enabled - */ - if (g_bIsEnabled) - { - LogAction(0, -1, "[STM] Simple Team Manager is ENABLED."); - } - else - { - LogAction(0, -1, "[STM] Simple Team Manager is DISABLED."); - } - - if (g_bLogActivity) - { - LogAction(0, -1, "[STM] Log Activity ENABLED."); - } - else - { - LogAction(0, -1, "[STM] Log Activity DISABLED."); - } -} - -/* COMMANDS */ - -public Action:Command_SwapTeam(client, args) -{ - - /** - Make sure we are enabled, if not bug out. - */ - if (!g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - If this was ran from the console bug out. - */ - if (client == 0) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "PlayerLevelCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Make sure the client is authorized to run this command. - */ - decl String:sFlags[5]; - GetConVarString(stm_adminflag_swapteam, sFlags, sizeof(sFlags)); - if (!SM_IsValidAdmin(client, sFlags)) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Lets make sure the client is one a team we can swap. - If he is we set the global array to the opposite team. - */ - new iTeam = GetClientTeam(client); - if (iTeam == g_aCurrentTeams[Team1]) - { - g_aPlayers[client][iNewTeam] = g_aCurrentTeams[Team2]; - } - else if (iTeam == g_aCurrentTeams[Team2]) - { - g_aPlayers[client][iNewTeam] = g_aCurrentTeams[Team1]; - } - else - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "InValidTeam", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check to see if we have command arguments. - */ - if (GetCmdArgs()) - { - - /** - We do, so lets get it and see if the client wants to be switched instantly or queued for death. - */ - decl String:sArg[5]; - GetCmdArg(1, sArg, sizeof(sArg)); - new iWantsQue = StringToInt(sArg); - if (iWantsQue && !g_aPlayers[client][bQueue]) - { - - /** - He wants the que and isn't already in it, set the global array. - */ - g_aPlayers[client][bQueue] = true; - ReplyToCommand(client, "\x01\x04[STM]\x01 %T", "PlayerQueue", LANG_SERVER); - } - else if (!iWantsQue) - { - - /** - He wants to be switched right now, lets call the stock function. - */ - SM_MovePlayer(client, g_aPlayers[client][iNewTeam]); - } - } - else - { - - /** - There are no command arguments so we build and display the swap menu. - */ - DisplaySwapModeMenu(client, client); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_MovePlayer(client, args) -{ - - /** - Make sure we are enabled, if not bug out. - */ - if (!g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - Make sure the client is authorized to run this command. - */ - decl String:sFlags[5]; - GetConVarString(stm_adminflag_moveplayer, sFlags, sizeof(sFlags)); - if (!SM_IsValidAdmin(client, sFlags)) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check to see if we have command arguments. - */ - new iCmdArgs = GetCmdArgs(); - if (iCmdArgs == 0) - { - - /** - We don't. Build the player menu, display it, and bug out. - */ - DisplayPlayerMenu(client); - return Plugin_Handled; - } - - /** - Check the first argument - If should be a players name or userid. - */ - decl String:sPlayer[64]; - GetCmdArg(1, sPlayer, sizeof(sPlayer)); - new iPlayerIndex = FindTarget(client, sPlayer, true, true); - if (iPlayerIndex == -1 || !IsClientInGame(iPlayerIndex)) - { - - /** - We don't know who this is. Build the player menu, display it, and bug out. - */ - DisplayPlayerMenu(client); - return Plugin_Handled; - } - - /** - We have figured out the first argument, lets check the second. - If should be the team the client wants to put the player on. - */ - if (iCmdArgs >= 2) - { - - /** - We have a command argument at least, lets see if we can identify the team. - */ - decl String:sTeam[24]; - GetCmdArg(2, sTeam, sizeof(sTeam)); - - new iTeam = StringToInt(sTeam); - if (SM_IsValidTeam(iTeam)) - { - - /** - It's a vaild team so lets set the global array to the new team. - */ - g_aPlayers[iPlayerIndex][iNewTeam] = iTeam; - } - else - { - - /** - It's not a vaild team so set the menu to display to the team menu. - */ - DisplayTeamMenu(client, iPlayerIndex); - return Plugin_Handled; - } - } - else - { - /** - We were not given a team, display the team menu. - */ - DisplayTeamMenu(client, iPlayerIndex); - return Plugin_Handled; - } - - /** - Check to see if we were given any more command arguments and found a team. - */ - if (iCmdArgs < 3) - { - - /** - No more command arguments and found a team. - Now lets check to see if the player is a spectator. If he is there is no reason to ask if it's instant or on death... he can't die. - */ - if (!IsClientObserver(iPlayerIndex)) - { - - /** - Not a spectator so display the swapmode menu. - */ - DisplaySwapModeMenu(client, iPlayerIndex); - } - else - { - - /** - The player is a spectator. - We make sure the player is not set to switch on death, since a spec can't die. - */ - g_aPlayers[iPlayerIndex][bQueue] = false; - } - } - - /** - We have figured out the second argument, lets check the third. - If should be the how the client wants to move the player: instant/on death. - */ - if (iCmdArgs >= 3) - { - - /** - The client gave us a command argument, lets check it. - */ - decl String:sSwapMode[5]; - GetCmdArg(3, sSwapMode, sizeof(sSwapMode)); - new iWantsQue = StringToInt(sSwapMode); - if (iWantsQue) - { - - /** - The client wants to que the player, set the global array. - */ - g_aPlayers[iPlayerIndex][bQueue] = true; - } - else - { - - /** - The client doesn't want to que the player, set the global array. - */ - g_aPlayers[iPlayerIndex][bQueue] = false; - } - } - else - { - /** - No swapmode argument, display the menu - */ - DisplaySwapModeMenu(client, iPlayerIndex); - } - - if (iCmdArgs >= 4) - { - - /** - Since we are compiling for Simple Team Balancer, and given a 4th argument, lets check it. - If should be the if the client wants to force the player to that team. - */ - decl String:sPlayerForced[5]; - GetCmdArg(4, sPlayerForced, sizeof(sPlayerForced)); - new iForceHim = StringToInt(sPlayerForced); - if (iForceHim) - { - - /** - The client wants to force the player - */ - SM_SetForcedTeam(iPlayerIndex, g_aPlayers[iPlayerIndex][iNewTeam]); - } - else - { - - /** - The client doesn't want to force the player - */ - SM_ClearForcedTeam(iPlayerIndex); - } - } - else - { - - } - - /** - We found and processed all the arguments. - */ - if (!IsPlayerAlive(iPlayerIndex)) - { - - /** - The player is not alive or died during this process so we just move him. - */ - SM_MovePlayer(iPlayerIndex, g_aPlayers[iPlayerIndex][iNewTeam]); - } - else - { - if (!g_aPlayers[iPlayerIndex][bQueue]) - { - - /** - The player is alive and is not set to be queued so we just move him. - */ - SM_MovePlayer(iPlayerIndex, g_aPlayers[iPlayerIndex][iNewTeam]); - } - } - - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_ScrambleTeams(client, args) -{ - - /** - Make sure we are enabled, if not bug out. - */ - if (!g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - Make sure the client is authorized to run this command. - */ - decl String:sFlags[5]; - GetConVarString(stm_adminflag_scramble, sFlags, sizeof(sFlags)); - if (!SM_IsValidAdmin(client, sFlags)) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check if a scramble timer was already called, if so close it down. - */ - if (g_hTimerPrepScramble != INVALID_HANDLE) - { - CloseHandle(g_hTimerPrepScramble); - g_hTimerPrepScramble = INVALID_HANDLE; - } - - /** - Check if we have any command arguments. - If we don't we display the scramble menu and bug out. - */ - new iCmdArgs = GetCmdArgs(); - if (iCmdArgs == 0) - { - DisplayScrambleMenu(client); - return Plugin_Handled; - } - - /** - We have a command argument. - It should be whether or not to scramble at round end. - */ - decl String:sRoundEnd[5]; - GetCmdArg(1, sRoundEnd, sizeof(sRoundEnd)); - if (StringToInt(sRoundEnd)) - { - /** - The client wants to scramble at round end so we set the global bool. - */ - g_bScrambleRoundEnd = true; - } - else - { - g_bScrambleRoundEnd = false; - } - - /** - Check for another command argument. - It should be whether or not to restart the round. - */ - decl String:sRestartRound[5]; - new bool:bRestartRound = false; - GetCmdArg(1, sRestartRound, sizeof(sRestartRound)); - if (StringToInt(sRestartRound)) - { - bRestartRound = true; - } - - /** - Now we start the scramble timer. - */ - StartScrambleTimer(_, bRestartRound); - - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_VoteScramble(client, args) -{ - - /** - Make sure we are enabled, if not bug out. - */ - if (!g_bVoteEnabled || !g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - Make sure there is a vote in progress, if so bug out. - */ - if (IsVoteInProgress()) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "VoteInProgress", LANG_SERVER); - return Plugin_Handled; - } - - /** - Make sure enough time has passed since the last vote. - */ - new iVoteTime = RoundFloat(GetEngineTime()); - if (iVoteTime - g_iLastVoteTime <= g_iVoteDelay) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "ScrambleTime", LANG_SERVER); - return Plugin_Handled; - } - - /** - Enough time has passed so reset the global vote time to now. - */ - g_iLastVoteTime = iVoteTime; - - /** - Build the vote menu and send it to everyone. - */ - new Handle:hMenu = CreateMenu(Menu_VoteScramble); - SetMenuTitle(hMenu, "Scramble Teams?"); - AddMenuItem(hMenu, VOTE_YES, "Yes"); - AddMenuItem(hMenu, VOTE_NO, "No"); - SetMenuExitButton(hMenu, false); - VoteMenuToAll(hMenu, 20); - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -/* HOOKED EVENTS */ - -public HookPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Find out who died. - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - - /** - Find out how the client died. - */ - new String:sWeapon[64]; - GetEventString(event, "weapon", sWeapon, sizeof(sWeapon)); - if (StrEqual(sWeapon, "world", false)) - { - - /** - He died because he changed teams so cleanup and bug out. - */ - s_CleanUp(iClient); - return; - } - - /** - Find out if this player was queued to change teams. - */ - if (g_aPlayers[iClient][bQueue]) - { - /** - Looks like he was, so call the stock function to move him. - */ - SM_MovePlayer(iClient, g_aPlayers[iClient][iNewTeam]); - } -} - -public HookPlayerChangeTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Find out who changed teams. - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - - /** - If he was queued to switch teams we cleanup the variables. The client did it themself. - */ - if (g_aPlayers[iClient][bQueue]) - { - s_CleanUp(iClient); - } -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get the amount of time left in the map. - */ - new iTimeLeft; - GetMapTimeLeft(iTimeLeft); - - /** - Check to see if we are supposed to scramble at the end of the round and that there is enough time left in the map. - */ - if (g_bScrambleRoundEnd && iTimeLeft >= 60) - { - - /** - Check to see if there is a scramble timer in action and if so close it down. - */ - if (g_hTimerPrepScramble != INVALID_HANDLE) - { - CloseHandle(g_hTimerPrepScramble); - g_hTimerPrepScramble = INVALID_HANDLE; - } - - /** - Determine the round end chat time and run the scramble 1 second before it ends. - */ - new Float:fDelay = GetConVarFloat(stm_mp_bonusroundtime); - fDelay -= 1.0; - StartScrambleTimer(fDelay); - } -} - -public OnClientPostAdminCheck(client) -{ - - /** - Determine if the client has the flag to use the swapteam command. - */ - decl String:sFlags[5]; - GetConVarString(stm_adminflag_swapteam, sFlags, sizeof(sFlags)); - if (SM_IsValidAdmin(client, sFlags)) - { - /** - The client does so lets create a timer to run an advertise to tell him about it. - */ - CreateTimer (60.0, Timer_WelcomeAdvert, client); - } -} - -public OnClientDisconnect(client) -{ - - /** - Cleanup the clients variables. - */ - s_CleanUp(client); -} - -public SM_OnPlayerMoved(Handle:plugin, client, team) -{ - - /** - Make sure we called the move function - */ - if (plugin != GetMyHandle()) - { - if (g_bLogActivity) - { - LogAction(0, client, "[STM] Callback was not started with current plugin, bugging out."); - } - return; - } - - decl String:sPlayerName[64]; - GetClientName(client, sPlayerName, sizeof(sPlayerName)); - - PrintToChat(client, "\x01\x04[SM]\x01 %T", "PlayerSwitched", LANG_SERVER); - - s_CleanUp(client); -} - -/* TIMER FUNCTIONS */ - -public Action:Timer_PrepTeamScramble(Handle:timer, any:data) -{ - new bool:bRestartRound = data; - /** - Call the scramble the teams stock function. - */ - PrepTeamScramble(bRestartRound); - - /** - Reset the timer handle so we know the timer is done. - */ - g_hTimerPrepScramble = INVALID_HANDLE; - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Timer_ScrambleTheTeams(Handle:timer, any:data) -{ - new iPlayers[MAXPLAYERS + 1]; - new iCount, i, bool:bTeam, bool:bRestartRound = data; - - /** - Get all the client index numbers of valid players - */ - for(i = 1; i <= MaxClients; i++) - { - if(IsClientInGame(i)) // && !IsFakeClient(i)) - { - iPlayers[iCount++] = i; - } - } - - /** - Randomly sort the players - */ - SortIntegers(iPlayers, iCount, Sort_Random); - - /** - Loop through all the players and assign each one to a team, alternating each time - */ - for(i = 0; i < iCount; i++) - { - if (!bRestartRound) - { - /** - We didn't want to restart the round, so we move them to spec 1 at a time. - */ - SM_MovePlayer(iPlayers[i], g_aCurrentTeams[Spectator]); - } - SM_MovePlayer(iPlayers[i], bTeam ? g_aCurrentTeams[Team2] : g_aCurrentTeams[Team1]); - SM_SetForcedTeam(iPlayers[i], bTeam ? g_aCurrentTeams[Team2] : g_aCurrentTeams[Team1], true); - bTeam = !bTeam; - } - - /** - Reset this variable since we completed a scramble - */ - g_bScrambleRoundEnd = false; - - if (g_hTimerClearScrambleForce != INVALID_HANDLE) - { - CloseHandle(g_hTimerClearScrambleForce); - g_hTimerClearScrambleForce = INVALID_HANDLE; - } - - g_hTimerClearScrambleForce = CreateTimer(300.0, Timer_ClearScrambleForce, _, TIMER_FLAG_NO_MAPCHANGE); - - ServerCommand("mp_timelimit %i", g_iTimeLeft / 60); - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Timer_ClearScrambleForce(Handle:timer, any:data) -{ - - for(new i = 1; i <= MaxClients; i++) - { - if(IsClientInGame(i)) // && !IsFakeClient(i)) - { - SM_ClearForcedTeam(i); - PrintToChat(i, "\x01\x04[SM]\x01 Your forced team status has been cleared"); - } - } - - g_hTimerClearScrambleForce = INVALID_HANDLE; - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Timer_WelcomeAdvert(Handle:timer, any:client) -{ - - /** - Lets make sure the client is connected and actually in the game. - */ - if (IsClientConnected(client) && IsClientInGame(client)) - { - - /** - We are good to go so lets tell him about the swapteam command. - */ - PrintToChat (client, "\x01\x04[STM]\x01 %T", "SwapTeamMsg", LANG_SERVER); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -/* STOCK FUNCTIONS */ - -stock s_CleanUp(iClient) -{ - - /** - Reset all the client variables - */ - g_aPlayers[iClient][bQueue] = false; - g_aPlayers[iClient][iNewTeam] = 0; -} - -stock StartScrambleTimer(Float:fdelay = 0.0, bool:bRestartRound = false) -{ - if (fdelay == 0.0) - { - fdelay = g_fScrambleDelay; - } - if (g_hTimerPrepScramble != INVALID_HANDLE) - { - CloseHandle(g_hTimerPrepScramble); - g_hTimerPrepScramble = INVALID_HANDLE; - } - PrintCenterTextAll("%T", "Scramble", LANG_SERVER); - g_hTimerPrepScramble = CreateTimer(fdelay, Timer_PrepTeamScramble, bRestartRound, TIMER_FLAG_NO_MAPCHANGE); -} - -stock PrepTeamScramble(bool:bRestartRound = false) -{ - new iPlayers[MAXPLAYERS + 1]; - new iCount; - - GetMapTimeLeft(g_iTimeLeft); - - if (bRestartRound) - { - - for(new i = 1; i <= MaxClients; i++) - { - if(IsClientInGame(i)) - // && !IsFakeClient(i)) - { - iPlayers[iCount++] = i; - SM_ClearForcedTeam(i); - SM_ClearBuddy(i); - SM_MovePlayer(i, g_aCurrentTeams[Spectator]); - } - } - } - else - { - //Can't move them all to spec at the same time - for(new i = 1; i <= MaxClients; i++) - { - if(IsClientInGame(i)) - // && !IsFakeClient(i)) - { - iPlayers[iCount++] = i; - SM_ClearForcedTeam(i); - SM_ClearBuddy(i); - //SM_MovePlayer(i, g_aCurrentTeams[Spectator]); - } - } - } - CreateTimer(4.0, Timer_ScrambleTheTeams, bRestartRound, TIMER_FLAG_NO_MAPCHANGE); -} - -/* CONSOLE VARIABLE CHANGE EVENT */ - -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (convar == stm_enabled) { - if (StringToInt(newValue) == 0) { - g_bIsEnabled = false; - LogAction(0, -1, "[STM] Simple Team Manager is loaded and disabled."); - } else { - g_bIsEnabled = true; - LogAction(0, -1, "[STM] Simple Team Manager is loaded and enabled."); - } - } - else if (convar == stm_logactivity) { - if (StringToInt(newValue) == 0) { - g_bLogActivity = false; - LogAction(0, -1, "[STM] Log Activity DISABLED."); - } else { - g_bLogActivity = true; - LogAction(0, -1, "[STM] Log Activity ENABLED."); - } - } - else if (convar == stm_scrambledelay) - g_fScrambleDelay = StringToFloat(newValue); - else if (convar == stm_votewin) - g_fVoteWin = StringToFloat(newValue); - else if (convar == stm_votedelay) - g_iVoteDelay = StringToInt(newValue); - else if (convar == stm_voteenabled) { - if (StringToInt(newValue) == 0) - g_bVoteEnabled = false; - else - g_bVoteEnabled = true; - } -} - -/* MENU CODE */ - -public OnAdminMenuReady(Handle:topmenu) -{ - if (topmenu == g_hAdminMenu) - return; - g_hAdminMenu = topmenu; - new TopMenuObject:player_commands = FindTopMenuCategory(g_hAdminMenu, ADMINMENU_PLAYERCOMMANDS); - new TopMenuObject:server_commands = FindTopMenuCategory(g_hAdminMenu, ADMINMENU_SERVERCOMMANDS); - if (player_commands == INVALID_TOPMENUOBJECT) - return; - - AddToTopMenu(g_hAdminMenu, - "moveplayer", - TopMenuObject_Item, - AdminMenu_MovePlayer, - player_commands, - "moveplayer", - ADMFLAG_BAN); - - AddToTopMenu(g_hAdminMenu, - "scrambleteams", - TopMenuObject_Item, - AdminMenu_Scrambleteams, - server_commands, - "scrambleteams", - ADMFLAG_BAN); -} - -public AdminMenu_MovePlayer(Handle:topmenu, TopMenuAction:action, TopMenuObject:object_id, param, String:buffer[], maxlength) -{ - if (action == TopMenuAction_DisplayOption) - Format(buffer, maxlength, "Move Player"); - else if (action == TopMenuAction_SelectOption){ - DisplayPlayerMenu(param); - } -} - -public AdminMenu_Scrambleteams(Handle:topmenu, TopMenuAction:action, TopMenuObject:object_id, param, String:buffer[], maxlength) -{ - if (action == TopMenuAction_DisplayOption) - Format(buffer, maxlength, "Scramble Teams"); - else if (action == TopMenuAction_SelectOption) { - DisplayScrambleMenu(param); - } -} - -public Menu_SelectPlayer(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - DisplayTeamMenu(param1, GetClientOfUserId(StringToInt(sSelection))); - } else if (action == MenuAction_Cancel) { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -public Menu_SelectTeam(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new iTeam; - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - decl String:sIndex[64]; - if (SplitString(sSelection, "A", sIndex, sizeof(sIndex)) != -1) - iTeam = g_aCurrentTeams[Team1]; - else if (SplitString(sSelection, "B", sIndex, sizeof(sIndex)) != -1) - iTeam = g_aCurrentTeams[Team2]; - else { - SplitString(sSelection, "C", sIndex, sizeof(sIndex)); - iTeam = g_aCurrentTeams[Spectator]; - } - new iTarget = StringToInt(sIndex); - g_aPlayers[iTarget][iNewTeam] = iTeam; - DisplaySwapModeMenu(param1, iTarget); - } else if (action == MenuAction_Cancel) { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -public Menu_SwapMode(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - decl String:sIndex[64]; - - if (SplitString(sSelection, "A", sIndex, sizeof(sIndex)) == -1) - { - SplitString(sSelection, "B", sIndex, sizeof(sIndex)); - } - - new iTarget = StringToInt(sIndex); - - if (StrContains(sSelection, "A", true) != -1) - { - g_aPlayers[iTarget][bQueue] = false; - } - else if (StrContains(sSelection, "B", true) != -1) - { - g_aPlayers[iTarget][bQueue] = true; - } - - if (param1 == iTarget && !g_aPlayers[iTarget][bQueue]) - { - SM_MovePlayer(iTarget, g_aPlayers[iTarget][iNewTeam]); - } - else - { - DisplayForceModeMenu(param1, iTarget); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - { - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } - return; -} - -public Menu_ForceMode(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - decl String:sIndex[64]; - if (SplitString(sSelection, "A", sIndex, sizeof(sIndex)) == -1) - { - SplitString(sSelection, "B", sIndex, sizeof(sIndex)); - } - new iTarget = StringToInt(sIndex); - if (StrContains(sSelection, "A", true) != -1) - { - SM_ClearForcedTeam(iTarget); - } - else if (StrContains(sSelection, "B", true) != -1) - { - SM_SetForcedTeam(iTarget, g_aPlayers[iTarget][iNewTeam], true); - } - if (!g_aPlayers[iTarget][bQueue]) - { - SM_MovePlayer(iTarget, g_aPlayers[iTarget][iNewTeam]); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - { - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } - return; -} - -public Menu_VoteScramble(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_VoteEnd) { - new winning_votes, total_votes; - GetMenuVoteInfo(param2, winning_votes, total_votes); - if (param1 == 0) { - if (float(total_votes) / float(winning_votes) < g_fVoteWin) { - PrintToChatAll("\x01\x04[SM]\x01 %T", "VoteScramble2", LANG_SERVER, winning_votes, total_votes); - return; - } - PrintCenterTextAll("[SM] %T", "Scramble", LANG_SERVER); - PrintToChatAll("\x01\x04[SM]\x01 %T", "VoteScramble1", LANG_SERVER, winning_votes, total_votes); - StartScrambleTimer(); - } - if (param1 == 1) { - PrintToChatAll("\x01\x04[SM]\x01 %T", "VoteScramble2", LANG_SERVER, winning_votes, total_votes); - } - } - if (action == MenuAction_End) - CloseHandle(menu); -} - -public Menu_ScrambleTeams(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "NOW", false)) - g_bScrambleRoundEnd = false; - else - g_bScrambleRoundEnd = true; - DisplayScrambleMenu2(param1); - } else if (action == MenuAction_Cancel) { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -public Menu_ScrambleTeams2(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[64]; - new bool:bRestartRound; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "NO", false)) - { - bRestartRound = false; - } - else - { - bRestartRound = true; - } - StartScrambleTimer(_, bRestartRound); - } else if (action == MenuAction_Cancel) { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -stock DisplayScrambleMenu(iClient) -{ - new Handle:hMenu = CreateMenu(Menu_ScrambleTeams); - SetMenuTitle(hMenu, "Select When to Scramble:"); - AddMenuItem(hMenu, "NOW", "Instantly"); - AddMenuItem(hMenu, "END", "At Round End"); - SetMenuExitBackButton(hMenu, false); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} - -stock DisplayScrambleMenu2(iClient) -{ - new Handle:hMenu = CreateMenu(Menu_ScrambleTeams2); - SetMenuTitle(hMenu, "Select When to Scramble:"); - AddMenuItem(hMenu, "NO", "No Round Restart"); - AddMenuItem(hMenu, "YES", "Restart Round"); - SetMenuExitBackButton(hMenu, false); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} - -stock DisplaySwapModeMenu(iClient, iTarget) -{ - new Handle:hMenu = CreateMenu(Menu_SwapMode); - decl String:optionA[64]; - decl String:optionB[64]; - Format(optionA, sizeof(optionA), "%iA", iTarget); - Format(optionB, sizeof(optionB), "%iB", iTarget); - SetMenuTitle(hMenu, "Select When to Swap:"); - AddMenuItem(hMenu, optionA, "Instantly (Kills)"); - if (!IsClientObserver(iTarget)) - AddMenuItem(hMenu, optionB, "Queue on next death"); - SetMenuExitBackButton(hMenu, false); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} - -stock DisplayForceModeMenu(iClient, iTarget) -{ - new Handle:hMenu = CreateMenu(Menu_ForceMode); - decl String:optionA[64]; - decl String:optionB[64]; - Format(optionA, sizeof(optionA), "%iA", iTarget); - Format(optionB, sizeof(optionB), "%iB", iTarget); - SetMenuTitle(hMenu, "Select Force Mode:"); - AddMenuItem(hMenu, optionA, "UnForced"); - AddMenuItem(hMenu, optionB, "Forced"); - SetMenuExitBackButton(hMenu, false); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} - -stock DisplayTeamMenu(iClient, iTarget) -{ - new Handle:hMenu = CreateMenu(Menu_SelectTeam); - decl String:optionA[64]; - decl String:optionB[64]; - decl String:optionC[64]; - Format(optionA, sizeof(optionA), "%iA", iTarget); - Format(optionB, sizeof(optionB), "%iB", iTarget); - Format(optionC, sizeof(optionC), "%iC", iTarget); - SetMenuTitle(hMenu, "Select Team:"); - AddMenuItem(hMenu, optionA, "Team One"); - AddMenuItem(hMenu, optionB, "Team Two"); - AddMenuItem(hMenu, optionC, "Spectator"); - SetMenuExitBackButton(hMenu, false); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} - -stock DisplayPlayerMenu(iClient) -{ - new Handle:hMenu = CreateMenu(Menu_SelectPlayer); - AddTargetsToMenu(hMenu, 0, true, false); - SetMenuTitle(hMenu, "Select A Player:"); - SetMenuExitBackButton(hMenu, true); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} diff --git a/Simple Round Immunity/addons/sourcemod/translations/simpledonatorbenefits.phrases.txt b/Simple Round Immunity/addons/sourcemod/translations/simpledonatorbenefits.phrases.txt deleted file mode 100644 index 3826846..0000000 --- a/Simple Round Immunity/addons/sourcemod/translations/simpledonatorbenefits.phrases.txt +++ /dev/null @@ -1,62 +0,0 @@ -"Phrases" -{ - "PlayerLevelCmd" - { - "en" "Command must be run at the player level" - "fr" "Cette commande doit être tapée en jeu" - "hu" "Ezt a parancsot jatekosi szinten kell futtatni!" - } - "RestrictedCmd" - { - "en" "You must be a donator or admin to run this command" - "fr" "Vous devez être un donateur ou un admin pour lancer cette commande" - "hu" "A parancs futtatasahoz admin, vagy tamogatoi szint szukseges!" - } - "InValidTeam" - { - "en" "You must be on red or blue to swap teams" - "fr" "Vous devez être RED ou BLU pour changer d'équipe" - "hu" "Jatekban kell lenned, hogy megcsereld a csapatokat!" - } - "PlayerQueue" - { - "en" "You have been queued to swap teams on next death" - "fr" "Vous avez été mis en attente pour changer d'équipe lors de votre prochaine mort" - "hu" "A kovetkezo halalnal csapatcsere lesz" - } - "PlayerSwitched" - { - "en" "Your team has been switched as requested" - "fr" "Vous avez changé d'équipe comme demandé" - "hu" "A keresnek eleget teve a csapatod meg lett csererlve" - } - "SwapTeamMsg" - { - "en" "Type /swapteam or !swapteam to swap your team!" - } - "ReachedCount" - { - "en" "You have reached your health limit. You must die before you can use it again" - } - "AtMaxHealth" - { - "en" "You are already at your maximum health!" - } - "ToMaxHealth" - { - "en" "Instant health bonus applied! You are not at your maximun health!" - } - "HealthBonus" - { - "en" "Instant health bonus applied!" - } - "PublicJoinMessage" - { - "#format" "{1:s}" - "en" "{1} a [donator] as joined the server" - } - "PrivateJoinMessage" - { - "en" "Thanks for donating!" - } -} \ No newline at end of file diff --git a/Simple Round Immunity/addons/sourcemod/translations/simplespectate.phrases.txt b/Simple Round Immunity/addons/sourcemod/translations/simplespectate.phrases.txt deleted file mode 100644 index 2d1a096..0000000 --- a/Simple Round Immunity/addons/sourcemod/translations/simplespectate.phrases.txt +++ /dev/null @@ -1,42 +0,0 @@ -"Phrases" -{ - "Stopped spectating" - { - "#format" "{1:s}" - "en" "Stopped tracking player: {1}" - } - "Yourself" - { - "en" "You can't spectate yourself" - } - "Spectator" - { - "en" "You can't spectate another spectator" - } - "Spectating" - { - "#format" "{1:s}" - "en" "Now spectating {1}. Type !stopspec or /stopspec to stop spectating this player" - } - "Invalid Target" - { - "en" "Invalid target" - } - "Cant Target" - { - "en" "Can't target this player" - } - "Must Have Target" - { - "en" "You must be following/tracking a player to punish" - } - "Target Left" - { - "en" "The player you were following/tracking has left" - } - "Punished" - { - "#format" "{1:s}{2:s}{3:s}" - "en" "{1} was punished with a {2} for {3}" - } -} \ No newline at end of file diff --git a/Simple Round Immunity/addons/sourcemod/translations/simpleteambalancer.phrases.txt b/Simple Round Immunity/addons/sourcemod/translations/simpleteambalancer.phrases.txt deleted file mode 100644 index 03595fd..0000000 --- a/Simple Round Immunity/addons/sourcemod/translations/simpleteambalancer.phrases.txt +++ /dev/null @@ -1,130 +0,0 @@ -"Phrases" -{ - "UnBalanced" - { - "en" "Teams are unbalanced and will be balanced shortly" - "fr" "Les équipes ne sont pas équilibrées et le seront bientôt" - "de" "Die Teams sind ungleich und werden in Kürze ausgeglichen" - "hu" "A csapatok nem kiegyenlitettek! Egyensuly beallitas kovetkezik!" - } - "Enabled" - { - "en" "Simple Team Balancer is ENABLED" - "fr" "Simple Team Balancer est ACTIVE" - "de" "Simple Team Balancer ist AKTIV" - "hu" "Az Egyszeru Csapat Egyensulytarto AKTIV!" - } - "Disabled" - { - "en" "Simple Team Balancer is DISABLED" - "fr" "Simple Team Balancer est DESACTIVE" - "de" "Simple Team Balancer ist INAKTIV" - "hu" "Az Egyszeru Csapat Egyensulytarto INAKTIV!" - } - "PlayerMessage" - { - "#format" "{1:i}" - "en" "You are going to be auto balanced in {1} seconds unless a dead player can be found" - "fr" "Vous passerez dans l'autre équipe dans {1} secondes si aucun joueur mort ne peut être trouvé dans cet intervalle" - "de" "Du wirst in {1} Sekunden zum automatischen Ausgleich herangezogen wenn kein toter Spieler gefunden werden kann" - "hu" "{1} masodpercen belul at leszel helyezve a masik csapatba, hacsak nem lesz addig egy halott jatekos!" - } - "BalanceMessage" - { - "#format" "{1:s}" - "en" "{1} was moved to the other team for game balance" - "fr" "{1} est passé dans l'autre équipe pour équilibrer la partie" - "de" "{1} wurde zum anderen Team verschoben um das Spiel auszugleichen" - "hu" "{1} at lett helyezve az egyensuly megtartasa erdekeben." - } - "PlayerLevelCmd" - { - "en" "Command must be run at the player level" - "fr" "La commande doit être lancée au niveau du joueur" - "de" "Das Kommando muss auf Spieler Ebene ausgeführt werden" - "hu" "Jatekosi szinten kell futtatni ezt a parancsot!" - } - "CmdDisabled" - { - "en" "Command is currently disabled" - "fr" "La commande est actuellement désactivée" - "de" "Das Kommando ist momentan inaktiv" - "hu" "A parancs jelenleg inaktiv" - } - "RestrictedBuddy" - { - "en" "You must be a donator or admin to add a balance buddy" - "fr" "Vous devez être un donateur ou un admin pour choisir un partenaire" - "de" "Du musst ein Spender oder Admin sein um einen Partner wählen zu können" - "hu" "Tamogato vagy admin kell hogy legyel, hogy 'Tarsat' jelolhess meg" - } - "SelectSelf" - { - "en" "You cannot be your own buddy" - "fr" "Vous ne pouvez pas être votre propre partenaire" - "de" "Du kannst nicht dein eigener Partner sein" - "hu" "Nem valaszthatod ki onmagad!" - } - "BuddyGone" - { - "en" "Your selected buddy has disconnected" - "fr" "Le partenaire que vous avez sélectionné s'est déconnecté" - "de" "Dein gewählter Partner hat die Verbindung getrennt" - "hu" "A valasztott 'Tarsad' kilepett" - } - "BuddyMsg" - { - "#format" "{1:s}" - "en" "You and {1} are now buddies" - "fr" "Vous et {1} êtes maintenant partenaires" - "de" "Du und {1} seid jetzt Partner" - "hu" "{1} es Te 'Tarsak' vagytok." - } - "BuddyLockMsgDisabled" - { - "en" "You can now be anyone's buddy" - "fr" "Vous pouvez à présent être le partenaire de n'importe qui" - "de" "Du kannst jetzt jedermanns Partner sein" - "hu" "Barkinek lehetsz a 'Tarsa'." - } - "BuddyLockMsgEnabled" - { - "en" "Buddy selection locked. Only you can change your buddy" - "fr" "Sélection de partenaire bloquée. Vous êtes le seul à pouvoir choisir votre partenaire" - "de" "Wahl des Partners gesperrt. Nur du kannst deinen Partner wechseln" - "hu" "Tars-lista lezarva. Csak Te tudod modositani a Tars-listadat." - } - "PlayerLockedBuddyMsg" - { - "#format" "{1:s}" - "en" "{1} has locked his buddy selection. Try again" - "fr" "{1} a bloqué sa sélection de partenaire. Essayez de nouveau." - "de" "{1} hat seine Wahl des Partners gesperrt. Versuche es erneut" - "hu" "{1} lezarta a Tars-listajat. Probald kesobb!" - } - "BuddyWelcomeMsg1" - { - "en" "Select a balance buddy and stay together during an autobalance!" - "fr" "Choisissez un partenaire et restez ensemble durant l'équilibrage automatique!" - "de" "Wähle einen Partner und bleibt zusammen während eines Ausgleichs" - "hu" "Valasz ki egy 'Tarsat' akivel egyuttmaradhatsz a csapatkiegyenlites alatt!" - } - "BuddyWelcomeMsg2" - { - "en" "/buddy or !buddy to select a balance buddy" - "fr" "/buddy or !buddy pour choisir un partenaire" - "de" "/buddy oder !buddy um einen Partner zu wählen" - "hu" "Hasznald a /buddy vagy !buddy parancsokat a 'Tars' kijelolesehez" - } - "BuddyWelcomeMsg3" - { - "en" "/lockbuddy or !lockbuddy to lock your selection" - "fr" "/lockbuddy or !lockbuddy pour bloquer votre sélection" - "de" "/lockbuddy oder !lockbuddy um deine Auswahl zu sperren" - "hu" "Hasznald a /lockbuddy vagy a !lockbuddy parancsokat a Tars-listad lezarasahoz" - } -} - - - - diff --git a/Simple Round Immunity/addons/sourcemod/translations/simpleteammanager.phrases.txt b/Simple Round Immunity/addons/sourcemod/translations/simpleteammanager.phrases.txt deleted file mode 100644 index f2093a7..0000000 --- a/Simple Round Immunity/addons/sourcemod/translations/simpleteammanager.phrases.txt +++ /dev/null @@ -1,92 +0,0 @@ -"Phrases" -{ - "PlayerLevelCmd" - { - "en" "Command must be run at the player level" - "fr" "Cette commande doit être tapée en jeu" - "hu" "Ezt a parancsot jatekosi szinten kell futtatni!" - } - "RestrictedCmd" - { - "en" "You must be a donator or admin to run this command" - "fr" "Vous devez être un donateur ou un admin pour lancer cette commande" - "hu" "A parancs futtatasahoz admin, vagy tamogatoi szint szukseges!" - } - "InValidTeam" - { - "en" "You must be on red or blue to swap teams" - "fr" "Vous devez être RED ou BLU pour changer d'équipe" - "hu" "Jatekban kell lenned, hogy megcsereld a csapatokat!" - } - "PlayerInValidTeam" - { - "en" "Player must be on red or blue to swap teams" - "fr" "Le joueur doit être RED ou BLU pour changer d'équipe" - "hu" "Valamelyik csapatban kell lenni, hogy csere legyen" - } - "PlayerQueue" - { - "en" "You have been queued to swap teams on next death" - "fr" "Vous avez été mis en attente pour changer d'équipe lors de votre prochaine mort" - "hu" "A kovetkezo halalnal csapatcsere lesz" - } - "PlayerSwitched" - { - "en" "Your team has been switched" - } - "PlayerSwitched1" - { - "en" "Your team has been switched as requested" - "fr" "Vous avez changé d'équipe comme demandé" - "hu" "A keresnek eleget teve a csapatod meg lett csererlve" - } - "PlayerSwitched2" - { - "en" "Your team has been switched by an Admin" - "fr" "Vous avez été changé d'équipe par un admin" - "hu" "Az Admin megcserelte a csapatodat!" - } - "SwapTeamMsg" - { - "en" "Type /swapteam or !swapteam to swap your team!" - } - "PlayerSwitched3" - { - "#format" "{1:s}" - "en" "{1}'s team has been switched" - "fr" "{1} a changé d'équipe" - "hu" "{1} csapata meg lett cserelve" - } - "Scramble" - { - "en" "Teams are about to be scrambled!" - "fr" "Les équipes vont être rééquilibrés" - "hu" "A csapatok hamarosan meg lesznek keverve!" - } - "VoteScramble1" - { - "#format" "{1:i}{2:i}" - "en" "Vote Scramble successful with {1} votes out of {2}" - "fr" "Le vote d'équilibrage des équipes a réussi avec {1} votes pour sur {2}" - "hu" "A szavazas sikeres volt, {1} szavazat a keveresre a {2} -bol" - } - "VoteScramble2" - { - "#format" "{1:i}{2:i}" - "en" "Vote Scramble failed with {1} votes out of {2}" - "fr" "Le vote d'équilibrage a échoué avec {1} votes pour sur {2}" - "hu" "A szavazas sikertelen volt, {1} szavazat a keveresre a {2} -bol" - } - "VoteInProgress" - { - "en" "A vote is currently in progress" - "fr" "Un vote est actuellement en cours" - "hu" "Egy szavazas mar fut!" - } - "ScrambleTime" - { - "en" "A vote was recently made, please wait" - "fr" "Un vote a déjà été fait récemment, réessayez plus tard" - "hu" "Nemreg volt szavazas, kerlek varj egy kicsit!" - } -} \ No newline at end of file diff --git a/Simple Spectate/addons/sourcemod/configs/simple-alltalkmanager_events.cfg b/Simple Spectate/addons/sourcemod/configs/simple-alltalkmanager_events.cfg deleted file mode 100644 index b739cf0..0000000 --- a/Simple Spectate/addons/sourcemod/configs/simple-alltalkmanager_events.cfg +++ /dev/null @@ -1,43 +0,0 @@ -"game_events" -{ - "teamplay_round_start" - { - "reason" "Round Start" - "setting" "1" - } - "teamplay_setup_finished" - { - "reason" "Setup Period Ended" - "setting" "0" - } - "teamplay_overtime_begin" - { - "reason" "Overtime Began" - "setting" "1" - } - "teamplay_overtime_end" - { - "reason" "Overtime Ended" - "setting" "1" - } - "teamplay_round_win" - { - "reason" "Round Ended" - "setting" "1" - } - "teamplay_suddendeath_begin" - { - "reason" "Sudden Death Began" - "setting" "1" - } - "teamplay_suddendeath_end" - { - "reason" "Sudden Death Ended" - "setting" "1" - } - "teamplay_round_stalemate" - { - "reason" "Stalemate" - "setting" "1" - } -} \ No newline at end of file diff --git a/Simple Spectate/addons/sourcemod/configs/simple-chatcolors.cfg b/Simple Spectate/addons/sourcemod/configs/simple-chatcolors.cfg deleted file mode 100644 index 14b98c6..0000000 --- a/Simple Spectate/addons/sourcemod/configs/simple-chatcolors.cfg +++ /dev/null @@ -1,15 +0,0 @@ -"admin_colors" -{ - "groupname2" - { - "flag" "z" - "namecolor" "{green}" - "textcolor" "{olive}" - } - "groupname1" - { - "flag" "a" - "namecolor" "{teamcolor}" - "textcolor" "{green}" - } -} \ No newline at end of file diff --git a/Simple Spectate/addons/sourcemod/plugins/simple-alltalkmanager.smx b/Simple Spectate/addons/sourcemod/plugins/simple-alltalkmanager.smx deleted file mode 100644 index 6122756..0000000 Binary files a/Simple Spectate/addons/sourcemod/plugins/simple-alltalkmanager.smx and /dev/null differ diff --git a/Simple Spectate/addons/sourcemod/plugins/simple-donatorbenefits.smx b/Simple Spectate/addons/sourcemod/plugins/simple-donatorbenefits.smx deleted file mode 100644 index 821d61d..0000000 Binary files a/Simple Spectate/addons/sourcemod/plugins/simple-donatorbenefits.smx and /dev/null differ diff --git a/Simple Spectate/addons/sourcemod/plugins/simple-messagesuppression.smx b/Simple Spectate/addons/sourcemod/plugins/simple-messagesuppression.smx deleted file mode 100644 index cc20dad..0000000 Binary files a/Simple Spectate/addons/sourcemod/plugins/simple-messagesuppression.smx and /dev/null differ diff --git a/Simple Spectate/addons/sourcemod/plugins/simple-plugins.smx b/Simple Spectate/addons/sourcemod/plugins/simple-plugins.smx deleted file mode 100644 index ac307a3..0000000 Binary files a/Simple Spectate/addons/sourcemod/plugins/simple-plugins.smx and /dev/null differ diff --git a/Simple Spectate/addons/sourcemod/plugins/simple-spectate.smx b/Simple Spectate/addons/sourcemod/plugins/simple-spectate.smx index c6885b0..1270110 100644 Binary files a/Simple Spectate/addons/sourcemod/plugins/simple-spectate.smx and b/Simple Spectate/addons/sourcemod/plugins/simple-spectate.smx differ diff --git a/Simple Spectate/addons/sourcemod/plugins/simple-teambalancer.smx b/Simple Spectate/addons/sourcemod/plugins/simple-teambalancer.smx deleted file mode 100644 index 95beb01..0000000 Binary files a/Simple Spectate/addons/sourcemod/plugins/simple-teambalancer.smx and /dev/null differ diff --git a/Simple Spectate/addons/sourcemod/plugins/simple-teammanager.smx b/Simple Spectate/addons/sourcemod/plugins/simple-teammanager.smx deleted file mode 100644 index 81905ba..0000000 Binary files a/Simple Spectate/addons/sourcemod/plugins/simple-teammanager.smx and /dev/null differ diff --git a/Simple Spectate/addons/sourcemod/scripting/include/simple-plugins.inc b/Simple Spectate/addons/sourcemod/scripting/include/simple-plugins.inc deleted file mode 100644 index 8f21956..0000000 --- a/Simple Spectate/addons/sourcemod/scripting/include/simple-plugins.inc +++ /dev/null @@ -1,337 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Plugins -Description: - Included file for core plugin in the Simple Plugins project -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -*************************************************************************/ - -#if defined _simpleplugin_included - #endinput -#endif - -#define _simpleplugin_included - -#define CORE_INC_VERSION "1.1.$Rev$" - -#pragma semicolon 1 -#include -#undef REQUIRE_PLUGIN -#include -#define REQUIRE_PLUGIN -#undef REQUIRE_EXTENSIONS -#undef AUTOLOAD_EXTENSIONS -#tryinclude -#tryinclude -#tryinclude -#define AUTOLOAD_EXTENSIONS -#define REQUIRE_EXTENSIONS - -enum e_SupportedMods -{ - GameType_Unknown, - GameType_AOC, - GameType_CSS, - GameType_DOD, - GameType_FF, - GameType_HIDDEN, - GameType_HL2DM, - GameType_INS, - GameType_L4D, - GameType_NEO, - GameType_SGTLS, - GameType_TF, - GameType_ZPS -}; - -enum e_Teams -{ - Unknown, - Spectator, - Team1, - Team2 -}; - -new g_aCurrentTeams[e_Teams]; -new e_SupportedMods:g_CurrentMod; -new String:g_sGameName[e_SupportedMods][32] = { "Unknown", - "Age of Chivalry", - "Counter Strike", - "Day Of Defeat", - "Fortress Forever", - "Hidden: Source", - "Half Life 2: Deathmatch", - "Insurgency", - "Left 4 Dead", - "Neotokyo", - "Stargate TLS", - "Team Fortress 2", - "Zombie Panic: Source" - }; - -public SharedPlugin:_pl_simpleplugin = -{ - name = "simple-plugins", - file = "simple-plugins.smx", -#if defined REQUIRE_PLUGIN - required = 1 -#else - required = 0 -#endif -}; - -#if !defined REQUIRE_PLUGIN -public _pl_simpleplugin_SetNTVOptional() -{ - MarkNativeAsOptional("SM_MovePlayer"); - MarkNativeAsOptional("SM_SetForcedTeam"); - MarkNativeAsOptional("SM_GetForcedTeam"); - MarkNativeAsOptional("SM_ClearForcedTeam"); - MarkNativeAsOptional("SM_GetForcedPlayer"); - MarkNativeAsOptional("SM_AssignBuddy"); - MarkNativeAsOptional("SM_SearchBuddy"); - MarkNativeAsOptional("SM_LockBuddy"); - MarkNativeAsOptional("SM_IsBuddyLocked"); - MarkNativeAsOptional("SM_ClearBuddy"); - MarkNativeAsOptional("SM_IsValidAdmin"); - MarkNativeAsOptional("SM_IsValidTeam"); -} -#endif - -/********************************************************************** - * When a player has to moved - * - * @param plugin Plugin that initiated the move - * @param client The client index of the player that was moved - * @param team The team index the player was moved to - * @noreturn - **********************************************************************/ -forward SM_OnPlayerMoved(Handle:plugin, client, team); - -/********************************************************************** - * Move a player to the supplied team - * - * @param client The client index of the player to be moved - * @param team The team to move the player to - * @noreturn - * @error Invalid client or team index - **********************************************************************/ -native SM_MovePlayer(client, team); - -/********************************************************************** - * Move a player to the supplied team - * - * @param client The client index of the player to set - * @param team The team to move the to set - * @param override Whether or not to override another plugin - * @return True if successful, false if not - * @error Invalid client or team index - **********************************************************************/ -native SM_SetForcedTeam(client, team, bool:override = false); - -/********************************************************************** - * Gets the client's forced team index - * - * @param client The client index of the player to check - * @param plugin Optional: The plugin handle of the plugin - that set the team - * @return The team index of the forced team - Zero if no forced team - * @error Invalid client index - **********************************************************************/ -native SM_GetForcedTeam(client, &Handle:plugin = INVALID_HANDLE); - -/********************************************************************** - * Clears a client's forced team - * - * @param client The client index of the player to check - * @return True if successful, false if not - * @error Invalid client index - **********************************************************************/ -native SM_ClearForcedTeam(client); - -/********************************************************************** - * Gets a forced player on the wrong that is currently on the wrong team - * This will only return a player if the calling plugin assigned the team - * - * @param team The team index the player should be on - * @return The client index of the player - Zero if no player found - * @error Invalid client index - **********************************************************************/ -native SM_GetForcedPlayer(team); - -/********************************************************************** - * Assign a players buddy - * - * @param client The client index of the player to assign - * @param player The player index of the player to assign - * @param override Whether or not to override a player lock - * @return True if successful, false if not - * @error Invalid client or player index - **********************************************************************/ -native bool:SM_AssignBuddy(client, player, bool:override = false); - -/********************************************************************** - * Rturns the client's buddy - * - * @param client The client index of the player to assign - * @return The client index of the player's buddy - Zero if no buddy - * @error Invalid client index - **********************************************************************/ -native SM_GetClientBuddy(client); - -/********************************************************************** - * Set the buddy lock setting for a client - * - * @param client The client index of the player to assign - * @param setting Setting to set, True or False - * @return True if successful, false if not - * @error Invalid client index - **********************************************************************/ -native bool:SM_LockBuddy(client, bool:setting); - -/********************************************************************** - * Returns the buddy lock setting for a client - * - * @param client The client index of the player to assign - * @return True if locked, false if not - * @error Invalid client index - **********************************************************************/ -native bool:SM_IsBuddyLocked(client); - -/********************************************************************** - * Clear a players buddy - * - * @param client The client index of the player to clear - * @param override Whether or not to override a player lock - * @return True if successful, false if not - * @error Invalid client index - **********************************************************************/ -native bool:SM_ClearBuddy(client, bool:override = false); - -/********************************************************************** - * Determine if the player has the supplied flags - * ADMFLAG_ROOT will always return true - * - * @param client The client index of the player to assign - * @param flags The char flag(s) to check against - * @return True if valid, false if not - **********************************************************************/ -native bool:SM_IsValidAdmin(client, const String:flags[]); - - -/********************************************************************** - * Determine if the team is a valid team - * - * @param team The team index to determine if valid for - currently installed/supported mod - * @return True if valid, false if not - **********************************************************************/ -native bool:SM_IsValidTeam(team); - - -public e_SupportedMods:GetCurrentMod() -{ - new String:sGameType[64]; - GetGameFolderName(sGameType, sizeof(sGameType)); - - if (StrEqual(sGameType, "aoc", false)) - { - return GameType_AOC; - } - if (StrEqual(sGameType, "cstrike", false)) - { - return GameType_CSS; - } - if (StrEqual(sGameType, "dod", false)) - { - return GameType_DOD; - } - if (StrEqual(sGameType, "ff", false)) - { - return GameType_FF; - } - if (StrEqual(sGameType, "hidden", false)) - { - return GameType_HIDDEN; - } - if (StrEqual(sGameType, "hl2mp", false)) - { - return GameType_FF; - } - if (StrEqual(sGameType, "insurgency", false) || StrEqual(sGameType, "ins", false)) - { - return GameType_INS; - } - if (StrEqual(sGameType, "l4d", false)) - { - return GameType_L4D; - } - if (StrEqual(sGameType, "nts", false)) - { - return GameType_NEO; - } - if (StrEqual(sGameType, "sgtls", false)) - { - return GameType_SGTLS; - } - if (StrEqual(sGameType, "tf", false)) - { - return GameType_TF; - } - if (StrEqual(sGameType, "zps", false)) - { - return GameType_ZPS; - } - return GameType_Unknown; -} - -public LoadCurrentTeams() -{ - switch (g_CurrentMod) - { - case GameType_INS: - { - g_aCurrentTeams[Unknown] = 0; - g_aCurrentTeams[Spectator] = 3; - g_aCurrentTeams[Team1] = 1; - g_aCurrentTeams[Team2] = 2; - } - case default: - { - g_aCurrentTeams[Unknown] = 0; - g_aCurrentTeams[Spectator] = 1; - g_aCurrentTeams[Team1] = 2; - g_aCurrentTeams[Team2] = 3; - } - } -} diff --git a/Simple Spectate/addons/sourcemod/scripting/simple-alltalkmanager.sp b/Simple Spectate/addons/sourcemod/scripting/simple-alltalkmanager.sp deleted file mode 100644 index c848332..0000000 --- a/Simple Spectate/addons/sourcemod/scripting/simple-alltalkmanager.sp +++ /dev/null @@ -1,515 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple AllTalk Manager -Description: - Allows you to set alltalk at different times -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#pragma semicolon 1 -#include -#include - -#define PLUGIN_VERSION "1.4.$Rev$" - -new Handle:satm_enabled = INVALID_HANDLE; -new Handle:satm_threshold_enabled = INVALID_HANDLE; -new Handle:satm_player_threshold = INVALID_HANDLE; -new Handle:satm_threshold_setting = INVALID_HANDLE; -new Handle:satm_logactivity = INVALID_HANDLE; -new Handle:satm_alltalk = INVALID_HANDLE; - -new Handle:g_aEventNames = INVALID_HANDLE; -new Handle:g_aEventReasons = INVALID_HANDLE; -new Handle:g_aEventSettings = INVALID_HANDLE; - -new bool:g_bLastThreshold = false; -new bool:g_bEnabled = true; -new bool:g_bThresholdEnabled = true; -new bool:g_bIsSetupMap = false; -new bool:g_bIsGameTF2 = false; -new bool:g_bLogActivity = false; - -new g_iLastEventIndex; - -public Plugin:myinfo = -{ - name = "Simple AllTalk Manager", - author = "Simple Plugins", - description = "Allows you to set alltalk at different times", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -} - -/** -Sourcemod callbacks -*/ -public OnPluginStart() -{ - - /** - Need to create all of our console variables. - */ - CreateConVar("satm_version", PLUGIN_VERSION, "Simple AllTalk Manager", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - satm_enabled = CreateConVar("satm_enabled", "1", "Enables/Disables Simple AllTalk Manager", _, true, 0.0, true, 1.0); - satm_threshold_enabled = CreateConVar("satm_threshold_enabled", "1", "Enables/Disables player threshold", _, true, 0.0, true, 1.0); - satm_player_threshold = CreateConVar("satm_player_threshold", "8", "Amount of players for the threshold"); - satm_threshold_setting = CreateConVar("satm_threshold_setting", "1", "Enables/Disables all talk up to player threshold, with the opposite set after the threshold", _, true, 0.0, true, 1.0); - satm_logactivity = CreateConVar("satm_logactivity", "0", "Enables/Disables log activity", _, true, 0.0, true, 1.0); - satm_alltalk = FindConVar("sv_alltalk"); - - /** - Hook console variables - */ - HookConVarChange(satm_enabled, ConVarSettingsChanged); - HookConVarChange(satm_threshold_enabled, ConVarSettingsChanged); - HookConVarChange(satm_player_threshold, ConVarSettingsChanged); - HookConVarChange(satm_logactivity, ConVarSettingsChanged); - - /** - Remove the notify flag from all talk cvar since we do it - */ - SetConVarFlags(satm_alltalk, GetConVarFlags(satm_alltalk)~FCVAR_NOTIFY); - - /** - Get the game type. We only care if it's TF2 - */ - new String:sGameType[64]; - GetGameFolderName(sGameType, sizeof(sGameType)); - if (StrEqual(sGameType, "tf", false)) - { - g_bIsGameTF2 = true; - } - - /** - Create the arrays - */ - g_aEventNames = CreateArray(255, 1); - g_aEventReasons = CreateArray(255, 1); - g_aEventSettings = CreateArray(1, 1); - - /** - Need to register the commands we are going to create and use. - */ - RegAdminCmd("sm_reloadatconfig", Command_Reload, ADMFLAG_GENERIC, "Reloads settings from config file"); - - /** - Create the config file - */ - AutoExecConfig(true); - - /** - Load the events from the config - */ - LoadEventsFromConfig(); -} - -public OnConfigsExecuted() -{ - - /** - Load up the settings - */ - g_bEnabled = GetConVarBool(satm_enabled); - g_bLogActivity = GetConVarBool(satm_logactivity); - g_bThresholdEnabled = GetConVarBool(satm_threshold_enabled); -} - -public OnMapStart() -{ - - /** - Reset the globals - */ - g_iLastEventIndex = 0; - g_bLastThreshold = false; - - /** - Check the map type if we are in TF2 - */ - if (g_bIsGameTF2) - { - g_bIsSetupMap = IsSetupPeriodMap(); - } - - /** - Set AllTalk - */ - if (g_bEnabled) - { - SetConVarBool(satm_alltalk, true); - } -} - -public OnClientDisconnect_Post(client) -{ - if (g_bEnabled) - { - SetAllTalk(-1); - } -} - -public OnClientPostAdminCheck(client) -{ - if (g_bEnabled) - { - SetAllTalk(-1); - } - CreateTimer(2.0, Timer_ShowAllTalkStatus, client, TIMER_FLAG_NO_MAPCHANGE); -} - -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (convar == satm_enabled) - { - if (StringToInt(newValue)) - { - g_bEnabled = true; - } - else - { - g_bEnabled = false; - } - } - else if (convar == satm_threshold_enabled) - { - if (StringToInt(newValue)) - { - g_bThresholdEnabled = true; - } - else - { - g_bThresholdEnabled = false; - } - } - else if (convar == satm_logactivity) - { - if (StringToInt(newValue)) - { - g_bLogActivity = true; - } - else - { - g_bLogActivity = false; - } - } - if (g_bEnabled) - { - SetAllTalk(-1); - } -} - -/** -Commands -*/ -public Action:Command_Reload(client, args) -{ - - /** - Clear the array - */ - ClearArray(g_aEventNames); - ClearArray(g_aEventReasons); - ClearArray(g_aEventSettings); - - /** - Load the events from the config - */ - LoadEventsFromConfig(); - - return Plugin_Handled; -} - -/** -Game Event Hooks -*/ -public Hook_All_Events(Handle:event, const String:name[], bool:dontBroadcast) -{ - if (!g_bIsSetupMap) - { - if (StrEqual(name, "teamplay_round_start")) - { - if (FindStringInArray(g_aEventNames, "teamplay_setup_finished") != -1) - { - g_iLastEventIndex = FindStringInArray(g_aEventNames, "teamplay_setup_finished"); - if (g_bEnabled) - { - SetAllTalk(g_iLastEventIndex); - return; - } - } - } - } - g_iLastEventIndex = FindStringInArray(g_aEventNames, name); - if (g_bEnabled) - { - SetAllTalk(g_iLastEventIndex); - } -} - -/** -Timers -*/ -public Action:Timer_ShowAllTalkStatus(Handle:timer, any:client) -{ - if (IsClientConnected(client) && IsClientInGame(client)) - { - new bool:bSetting = GetConVarBool(satm_alltalk); - if (bSetting) - { - PrintToChat(client, "\x01\x04[SM] AllTalk is \x01[on]"); - } - else - { - PrintToChat(client, "\x01\x04[SM] AllTalk is \x01[off]"); - } - } -} - -/** -Stock Functions -*/ -stock LoadEventsFromConfig() -{ - - /** - Make sure the config file is here and load it up - */ - new String:sConfigFile[256]; - BuildPath(Path_SM, sConfigFile, sizeof(sConfigFile), "configs/simple-alltalkmanager_events.cfg"); - if (!FileExists(sConfigFile)) - { - - /** - Config file doesn't exists, stop the plugin - */ - LogError("[SATM] Simple AllTalk Manager is not running! Could not find file %s", sConfigFile); - SetFailState("Could not find file %s", sConfigFile); - } - - /** - Create the arrays and variables - */ - new String:sGameEventName[256]; - new String:sReason[256]; - new iSetting; - - /** - Load config file as a KeyValues file - */ - new Handle:kvGameEvents = CreateKeyValues("game_events"); - FileToKeyValues(kvGameEvents, sConfigFile); - - if (!KvGotoFirstSubKey(kvGameEvents)) - { - return; - } - - /** - Hook the game events and load the settings - */ - do - { - - /** - Get the section name; this should be the event name - */ - KvGetSectionName(kvGameEvents, sGameEventName, sizeof(sGameEventName)); - if (!HookEventEx(sGameEventName, Hook_All_Events, EventHookMode_PostNoCopy)) - { - - /** - Could not hook this event, stop the plugin - */ - SetFailState("Could not hook event %s", sGameEventName); - } - else - { - if (g_bLogActivity) - { - LogMessage("[SATM] Hooked event: %s", sGameEventName); - } - } - - /** - Get the reason string and setting - */ - KvGetString(kvGameEvents, "reason", sReason, sizeof(sReason)); - iSetting = KvGetNum(kvGameEvents, "setting"); - if (g_bLogActivity) - { - LogMessage("[SATM] Event reason string: %s", sReason); - LogMessage("[SATM] Event setting: %i", iSetting); - } - - /** - Push the values to the arrays - */ - PushArrayString(g_aEventNames, sGameEventName); - PushArrayString(g_aEventReasons, sReason); - PushArrayCell(g_aEventSettings, iSetting); - } while (KvGotoNextKey(kvGameEvents)); - - /** - Close our handle - */ - CloseHandle(kvGameEvents); -} - -stock SetAllTalk(index) -{ - new iPlayerThreshold = GetConVarInt(satm_player_threshold); - new bool:bThresholdMet = ((GetClientCount() >= iPlayerThreshold) ? true : false); - new bool:bSetting; - - if (g_bThresholdEnabled) - { - if (bThresholdMet) - { - if (index == -1) - { - if (bThresholdMet != g_bLastThreshold) - { - g_bLastThreshold = true; - bSetting = !GetConVarBool(satm_threshold_setting); - new bool:bLastSetting = GetArrayCell(g_aEventSettings, g_iLastEventIndex); - if (bLastSetting && !bSetting) - { - bSetting = GetArrayCell(g_aEventSettings, g_iLastEventIndex); - } - } - else - { - bSetting = GetArrayCell(g_aEventSettings, g_iLastEventIndex); - } - } - else - { - bSetting = GetArrayCell(g_aEventSettings, index); - } - } - else - { - g_bLastThreshold = false; - bSetting = GetConVarBool(satm_threshold_setting); - } - } - else - { - if (index != -1) - { - bSetting = GetArrayCell(g_aEventSettings, index); - } - } - - if (GetConVarBool(satm_alltalk) != bSetting) - { - - SetConVarBool(satm_alltalk, bSetting); - - new String:sReason[256]; - if (index == -1) - { - Format(sReason, sizeof(sReason), "Player Threshold"); - } - else - { - if (!g_bIsSetupMap) - { - new String:sCurrentEvent[256]; - GetArrayString(g_aEventNames, index, sCurrentEvent, sizeof(sCurrentEvent)); - if (StrEqual(sCurrentEvent, "teamplay_setup_finished")) - { - new iRoundStartIndex = FindStringInArray(g_aEventNames, "teamplay_round_start"); - if (iRoundStartIndex != -1) - { - GetArrayString(g_aEventReasons, iRoundStartIndex, sReason, sizeof(sReason)); - } - else - { - GetArrayString(g_aEventReasons, index, sReason, sizeof(sReason)); - } - } - else - { - GetArrayString(g_aEventReasons, index, sReason, sizeof(sReason)); - } - } - else - { - GetArrayString(g_aEventReasons, index, sReason, sizeof(sReason)); - } - } - - if (bSetting) - { - PrintToChatAll("\x01\x04[SM] AllTalk turned \x01[on] \x04due to:\x01 %s", sReason); - } - else - { - PrintToChatAll("\x01\x04[SM] AllTalk turned \x01[off] \x04due to:\x01 %s", sReason); - } - } -} - -stock bool:IsSetupPeriodMap() -{ - new iEnt = -1; - new String:sMapName[32]; - - GetCurrentMap(sMapName, sizeof(sMapName)); - - if (strncmp(sMapName, "cp_", 3, false) == 0) - { - new iTeam; - while ((iEnt = FindEntityByClassname(iEnt, "team_control_point")) != -1) - { - iTeam = GetEntProp(iEnt, Prop_Send, "m_iTeamNum"); - - /** - If there is a blu CP or a neutral CP, then it's not an attack/defend map - */ - if (iTeam != 2) - { - //this is a push map - return false; - } - } - //this is a attack/defend map - return true; - } - else if (strncmp(sMapName, "ctf_", 3, false) == 0) - { - //this is a ctf map - return false; - } - return false; -} diff --git a/Simple Spectate/addons/sourcemod/scripting/simple-autoscrambler.sp b/Simple Spectate/addons/sourcemod/scripting/simple-autoscrambler.sp deleted file mode 100644 index 6c6799e..0000000 --- a/Simple Spectate/addons/sourcemod/scripting/simple-autoscrambler.sp +++ /dev/null @@ -1,459 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple AutoScrambler -Description: - Automatically scrambles the teams based upon a number of events. -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include - -#define PLUGIN_VERSION "1.1.$Rev$" - -/** -Different scramble modes: - -1 = Full Scramble, dont restart round. -2 = Admins Immune, dont restart round. -3 = Full Scramble, restart round and reset scores. -4 = Admins Immune, restart round and reset scores. - -*/ - -/** -Different top player modes: - -1 = Divide Top 4 players on the two teams. -2 = Protect the Top 2 players on each team. - -*/ - -enum PlayerData -{ - Handle:hForcedTimer, - bool:bProtected; -}; - -/** -Cvars used for admins -*/ -new Handle: sas_admin_immunity_enabled = INVALID_HANDLE, - Handle: sas_admin_flag_scramblenow = INVALID_HANDLE, - Handle: sas_admin_flag_immunity = INVALID_HANDLE; - -/** -Cvars used for autoscramble -*/ -new Handle: sas_autoscramble_enabled = INVALID_HANDLE, - Handle: sas_autoscramble_minplayers = INVALID_HANDLE, - Handle: sas_autoscramble_mode = INVALID_HANDLE, - Handle: sas_autoscramble_winstreak = INVALID_HANDLE, - Handle: sas_autoscramble_steamroll = INVALID_HANDLE, - Handle: sas_autoscramble_frags = INVALID_HANDLE; - -/** -Cvars used for voting -*/ -new Handle: sas_vote_enabled = INVALID_HANDLE, - Handle: sas_vote_upcount = INVALID_HANDLE, - Handle: sas_vote_winpercent = INVALID_HANDLE, - Handle: sas_vote_mode = INVALID_HANDLE, - Handle: sas_vote_minplayers = INVALID_HANDLE; - -/** -Additional cvars -*/ -new Handle: sas_enabled = INVALID_HANDLE, - Handle: sas_timer_scrambledelay = INVALID_HANDLE, - Handle: TFGameModeArena = INVALID_HANDLE; - -/** -Timers -*/ -new Handle: g_hScrambleTimer = INVALID_HANDLE; - -/** - Player arrays - */ -new g_aPlayers[MAXPLAYERS + 1][PlayerData]; - -/** - Cvar variables - */ -new bool: g_bIsEnabled, - bool: g_bIsAutoScrambleEnabled, - bool: g_bIsVoteEnabled, - bool: g_bIsAdminImmunityEnabled; -new Float: g_fTimer_ScrambleDelay, - Float: g_fVote_UpCount, - Float: g_fVote_WinPercent; -new g_iAutoScramble_Minplayers, - g_iAutoScramble_Mode, - g_iAutoScramble_WinStreak, - g_iAutoScramble_SteamRoll, - g_iAutoScramble_Frags, - g_iVote_Mode, - g_iVote_MinPlayers; -new String: g_sScrambleNowFlag[5], - String: g_sAdminImmunityFlag[5]; - -/** -Other globals -*/ -new g_iMaxEntities, - g_iOwnerOffset; - -public Plugin:myinfo = -{ - name = "Simple AutoScrambler", - author = "Simple Plugins", - description = "Automatically scrambles the teams based upon a number of events.", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -}; - -public OnPluginStart() -{ - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook the game events - */ - LogAction(0, -1, "[SAS] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - switch (g_CurrentMod) - { - case GameType_TF: - { - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - } - case GameType_DOD: - { - HookEvent("dod_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_Post); - } - default: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_Post); - } - } - - /** - Create console variables - */ - CreateConVar("sas_version", PLUGIN_VERSION, "Simple AutoScrambler Version",FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - sas_enabled = CreateConVar("sas_enabled", "1", "Enable/Disable Simple AutoScrambler"); - sas_timer_scrambledelay = CreateConVar("sas_timer_scrambledelay", "5.0", "Delay used after a scramble has been started", _, true, 1.0, true, 30.0); - - /** - Cvars used for admins - */ - sas_admin_immunity_enabled = CreateConVar("sas_admin_immunity_enabled", "1", "Enable/Disable admin immunity for scrambles"); - sas_admin_flag_scramblenow = CreateConVar("sas_admin_flag_scramblenow", "z", "Admin flag to use for scramblenow function/command"); - sas_admin_flag_immunity = CreateConVar("sas_admin_flag_immunity", "z", "Admin flag to use for scramble immunity"); - - /** - Cvars used for autoscramble - */ - sas_autoscramble_enabled = CreateConVar("sas_autoscramble_enabled", "1", "Enable/Disable the autoscramble function"); - sas_autoscramble_minplayers = CreateConVar("sas_autoscramble_minplayers", "16", "Min players needed to start an autoscramble"); - sas_autoscramble_mode = CreateConVar("sas_autoscramble_mode", "1", "Scramble mode used when autoscrambling"); - sas_autoscramble_winstreak = CreateConVar("sas_autoscramble_winstreak", "5", "Max amount of wins in a row a team can achieve before an autoscramble starts"); - sas_autoscramble_steamroll = CreateConVar("sas_autoscramble_steamroll", "120", "Shortest amount of time a team can win by before an autoscramble starts (seconds)"); - sas_autoscramble_frags = CreateConVar("sas_autoscramble_frags", "1", "Min players needed to start a vote and scramble"); - - /** - Cvars used for voting - */ - sas_vote_enabled = CreateConVar("sas_vote_enabled", "1", "Enable/Disable voting for scramble"); - sas_vote_upcount = CreateConVar("sas_vote_upcount", "5", "Amount of people wanting a scramble before a vote starts. If less than 1 it will be considered a percentage. (ie 0.5 = 50% | 1 = 1 Player | 5 = 5 Players)"); - sas_vote_winpercent = CreateConVar("sas_vote_winpercent", "0.6", "Percentage of votes needed to scramble", _, true, 0.0, true, 1.0); - sas_vote_mode = CreateConVar("sas_vote_mode", "1", "Scramble mode used when a vote results in a scramble"); - sas_vote_minplayers = CreateConVar("sas_vote_minplayers", "16", "Min players needed to start a vote and scramble"); - - /** - Hook the console variables if they change - */ - HookConVarChange(sas_enabled, ConVarSettingsChanged); - HookConVarChange(sas_timer_scrambledelay, ConVarSettingsChanged); - HookConVarChange(sas_admin_immunity_enabled, ConVarSettingsChanged); - HookConVarChange(sas_admin_flag_scramblenow, ConVarSettingsChanged); - HookConVarChange(sas_admin_flag_immunity, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_enabled, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_minplayers, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_mode, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_winstreak, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_steamroll, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_frags, ConVarSettingsChanged); - HookConVarChange(sas_vote_enabled, ConVarSettingsChanged); - HookConVarChange(sas_vote_upcount, ConVarSettingsChanged); - HookConVarChange(sas_vote_winpercent, ConVarSettingsChanged); - HookConVarChange(sas_vote_mode, ConVarSettingsChanged); - HookConVarChange(sas_vote_minplayers, ConVarSettingsChanged); - - /** - Register the command - */ - RegConsoleCmd("sm_scramblenow", Command_ScrambleNow, "sm_scramblenow (mode): Scrambles the teams"); - - /** - Load translations and .cfg file - */ - LoadTranslations ("simpleautoscrambler.phrases"); - AutoExecConfig(true, "plugin.simpleautoscrambler"); - LogAction(0, -1, "[SAS] Simple AutoScrambler is loaded."); -} - -public OnAllPluginsLoaded() -{ - //something -} - -public OnLibraryRemoved(const String:name[]) -{ - //something -} - -public OnConfigsExecuted() -{ - - /** - Load up all the variable defaults - */ - LoadUpVariables(); - - /** - Log our activity - */ - if (g_bIsEnabled) - LogAction(0, -1, "Simple AutoScrambler is ENABLED"); - else - LogAction(0, -1, "Simple AutoScrambler is DISABLED"); -} - -public Action:Command_ScrambleNow(client, args) -{ - - /** - Make sure we are enabled - */ - if (!g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - Make sure the client is authorized to run this command. - */ - if (!SM_IsValidAdmin(client, g_sScrambleNowFlag)) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Make sure it's ok to scramble at this time - */ - if (!OkToScramble) - { - return Plugin_Handled; - } - - /** - Make sure it's ok to scramble at this time - */ - LogAction(0, -1, "[SAS] The scramblenow command was used"); - - /** - Scramble the teams - */ - StartAScramble(); - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public HookRoundStart(Handle:event, const String:name[], bool:dontBroadcast) -{ - -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - -} - -public Action:Timer_ScrambleTeams(Handle:timer, any:mode) -{ - - /** - Make sure it's still ok to scramble - */ - if (!OkToScramble) - { - return Plugin_Handled; - } - - - switch (mode) - { - case - - - - } - - - /** - Reset the handle because the timer is over and the callback is done - */ - g_hScrambleTimer = INVALID_HANDLE; - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - -} - -stock StartAScramble(mode) -{ - - /** - See if we are already started a scramble - */ - if (g_hScrambleTimer == INVALID_HANDLE) - { - - /** - There is a scramble in progress - */ - return; - - } - - /** - Report that a scramble is about to start - */ - PrintCenterTextAll("%T", "Scramble", LANG_SERVER); - - /** - Start a timer and log the action - */ - g_hScrambleTimer = CreateTimer(g_fTimer_ScrambleDelay, Timer_ScrambleTeams, mode, TIMER_FLAG_NO_MAPCHANGE); - LogAction(0, -1, "[SAS] A scamble timer was started"); -} - -stock bool:OkToScramble() -{ - -} - -stock LoadUpVariables() -{ - g_bIsEnabled = GetConVarBool(sas_enabled); - g_bIsAutoScrambleEnabled = GetConVarBool(sas_autoscramble_enabled); - g_bIsVoteEnabled = GetConVarBool(sas_vote_enabled); - g_bIsAdminImmunityEnabled = GetConVarBool(sas_admin_immunity_enabled); - g_iAutoScramble_Minplayers = GetConVarInt(sas_autoscramble_minplayers); - g_iAutoScramble_Mode = GetConVarInt(sas_autoscramble_mode); - g_iAutoScramble_WinStreak = GetConVarInt(sas_autoscramble_winstreak); - g_iAutoScramble_SteamRoll = GetConVarInt(sas_autoscramble_steamroll); - g_iAutoScramble_Frags = GetConVarInt(sas_autoscramble_frags); - g_iVote_Mode = GetConVarInt(sas_vote_mode); - g_iVote_MinPlayers = GetConVarInt(sas_vote_minplayers); - GetConVarString(sas_admin_flag_scramblenow, g_sScrambleNowFlag, sizeof(g_sScrambleNowFlag)); - GetConVarString(sas_admin_flag_immunity, g_sAdminImmunityFlag, sizeof(g_sAdminImmunityFlag)); - g_fTimer_ScrambleDelay = GetConVarFloat(sas_timer_scrambledelay); - g_fVote_UpCount = GetConVarFloat(sas_vote_upcount); - g_fVote_WinPercent = GetConVarFloat(sas_vote_winpercent); - g_iMaxEntities = GetMaxEntities(); - g_iOwnerOffset = FindSendPropInfo("CBaseObject", "m_hBuilder"); -} - -stock TF2_DestroyBuildings(client) -{ - - /** - We have to start a loop to check the owner of all the valid entities - */ - for (new i = MaxClients + 1; i <= g_iMaxEntities; i++) - { - if (!IsValidEntity(i)) - { - - /** - Not valid, continue to next one - */ - continue; - } - - /** - Get the name of the current entity - */ - decl String:sNetClass[32]; - GetEntityNetClass(i, sNetClass, sizeof(sNetClass)); - - /** - See if its something that an engineer would build - */ - if (strcmp(sNetClass, "CObjectSentrygun") == 0 - || strcmp(sNetClass, "CObjectTeleporter") == 0 - || strcmp(sNetClass, "CObjectDispenser") == 0) - { - - /** - It is, so lets check the owner - */ - if (GetEntDataEnt2(i, g_iOwnerOffset) == client) - { - - /** - It's the clients building, so we blow it up. - */ - SetVariantInt(9999); - AcceptEntityInput(i, "RemoveHealth"); - } - } - } -} \ No newline at end of file diff --git a/Simple Spectate/addons/sourcemod/scripting/simple-chatcolors.sp b/Simple Spectate/addons/sourcemod/scripting/simple-chatcolors.sp deleted file mode 100644 index 539d057..0000000 --- a/Simple Spectate/addons/sourcemod/scripting/simple-chatcolors.sp +++ /dev/null @@ -1,496 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Chat Colors -Description: - Changes the colors of players chat based on config file -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#pragma semicolon 1 -#include -#include - -#define PLUGIN_VERSION "0.9.0.$Rev$" - -#define CHAT_SYMBOL '@' -#define TRIGGER_SYMBOL1 '!' -#define TRIGGER_SYMBOL2 '/' -#define CHAT_MAX_MESSAGE_LENGTH 1024 - -new Handle:g_hDebugCvar = INVALID_HANDLE; -new Handle:g_aGroupNames = INVALID_HANDLE; -new Handle:g_aGroupFlag = INVALID_HANDLE; -new Handle:g_aGroupNameColor = INVALID_HANDLE; -new Handle:g_aGroupTextColor = INVALID_HANDLE; - -new bool:g_bDebug = false; - -new g_iArraySize; - -new g_aPlayerColorIndex[MAXPLAYERS + 1] = { -1, ... }; - -public Plugin:myinfo = -{ - name = "Simple Chat Colors", - author = "Simple Plugins", - description = "Changes the colors of players chat based on config file.", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -}; - -/** -Sourcemod callbacks -*/ -public OnPluginStart() -{ - - /** - Need to create all of our console variables. - */ - CreateConVar("sm_chatcolors_version", PLUGIN_VERSION, "Simple Chat Colors", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - g_hDebugCvar = CreateConVar("sm_chatcolors_debug", "1", "Enable/Disable debugging information"); - - /** - Hook console variables - */ - HookConVarChange(g_hDebugCvar, ConVarSettingsChanged); - - /** - Need to register the commands we are going to use - */ - RegConsoleCmd("say", Command_Say); - RegConsoleCmd("say_team", Command_SayTeam); - RegAdminCmd("sm_reloadcolorsconfig", Command_Reload, ADMFLAG_GENERIC, "Reloads settings from config file"); - - /** - Create the arrays - */ - g_aGroupNames = CreateArray(256, 1); - g_aGroupFlag = CreateArray(15, 1); - g_aGroupNameColor = CreateArray(15, 1); - g_aGroupTextColor = CreateArray(15, 1); - - /** - Load the admins and colors from the config - */ - LoadAdminsAndColorsFromConfig(); - g_iArraySize = GetArraySize(g_aGroupNames); -} - -public OnConfigsExecuted() -{ - g_bDebug = GetConVarBool(g_hDebugCvar); - ReloadConfigFile(); -} - -public OnClientPostAdminCheck(client) -{ - - /** - Check the client to see if they are a admin - */ - CheckAdmin(client); -} - -public OnClientDisconnect(client) -{ - g_aPlayerColorIndex[client] = -1; -} - -/** -Commands -*/ -public Action:Command_Say(client, args) -{ - - /** - Make sure we are enabled. - */ - if (client == 0 || IsChatTrigger()) - { - return Plugin_Continue; - } - - if (g_aPlayerColorIndex[client] != -1) - { - - /** - The client is, so get the chat message and strip it down. - */ - decl String:sArg[CHAT_MAX_MESSAGE_LENGTH], - String:sChatMsg[CHAT_MAX_MESSAGE_LENGTH]; - - new bool:bAlive = IsPlayerAlive(client); - - GetCmdArgString(sArg, sizeof(sArg)); - StripQuotes(sArg); - TrimString(sArg); - new startidx; - if (sArg[strlen(sArg)-1] == '"') - { - sArg[strlen(sArg)-1] = '\0'; - startidx = 1; - } - - /** - Bug out if they are using the admin chat symbol (admin chat). If we are in CSS it may not find all the triggers, so we double check. - */ - if (sArg[startidx] == CHAT_SYMBOL || sArg[startidx] == TRIGGER_SYMBOL1 || sArg[startidx] == TRIGGER_SYMBOL2) - { - return Plugin_Continue; - } - - /** - Log the message for hlstatsx and other things. - */ - new iUserID = GetClientUserId(client); - decl String:sAuthID[64]; - GetClientAuthString(client, sAuthID, sizeof(sAuthID)); - LogToGame("\"%N<%i><%s><>\" say \"%s\"", client, iUserID, sAuthID, sArg); - - /** - Format the message. - */ - FormatMessage(client, 0, bAlive, sChatMsg, sArg, g_aPlayerColorIndex[client]); - - /** - Send the message. - */ - //SayText2(0, client, sChatMsg); - CPrintToChatAll(sChatMsg); - - /** - We are done, bug out, and stop the original chat message. - */ - return Plugin_Stop; - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -public Action:Command_SayTeam(client, args) -{ - - /** - Make sure we are enabled. - */ - if (client == 0 || IsChatTrigger()) - { - return Plugin_Continue; - } - - /** - Check the client to see if they are a admin - */ - if (g_aPlayerColorIndex[client] != -1) - { - - /** - The client is, so get the chat message and strip it down. - */ - decl String:sArg[CHAT_MAX_MESSAGE_LENGTH], - String:sChatMsg[CHAT_MAX_MESSAGE_LENGTH]; - - new bool:bAlive = IsPlayerAlive(client); - new iCurrentTeam = GetClientTeam(client); - - GetCmdArgString(sArg, sizeof(sArg)); - StripQuotes(sArg); - TrimString(sArg); - new startidx; - if (sArg[strlen(sArg)-1] == '"') - { - sArg[strlen(sArg)-1] = '\0'; - startidx = 1; - } - - /** - Bug out if they are using the admin chat symbol (admin chat). - */ - if (sArg[startidx] == CHAT_SYMBOL || sArg[startidx] == TRIGGER_SYMBOL1 || sArg[startidx] == TRIGGER_SYMBOL2) - { - return Plugin_Continue; - } - - /** - Log the message for hlstatsx and other things. - */ - new iUserID = GetClientUserId(client); - decl String:sAuthID[64]; - GetClientAuthString(client, sAuthID, sizeof(sAuthID)); - LogToGame("\"%N<%i><%s><>\" say_team \"%s\"", client, iUserID, sAuthID, sArg); - - /** - Format the message. - */ - FormatMessage(client, iCurrentTeam, bAlive, sChatMsg, sArg, g_aPlayerColorIndex[client]); - - /** - Send the message to the same team - */ - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientConnected(i) && IsClientInGame(i) && GetClientTeam(i) == iCurrentTeam) - { - CPrintToChat(client, sChatMsg); - } - } - - /** - We are done, bug out, and stop the original chat message. - */ - return Plugin_Stop; - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -public Action:Command_Reload(client, args) -{ - ReloadConfigFile(); - return Plugin_Handled; -} - -/** -Stock Functions -*/ -stock LoadAdminsAndColorsFromConfig() -{ - - /** - Make sure the config file is here and load it up - */ - new String:sConfigFile[256]; - BuildPath(Path_SM, sConfigFile, sizeof(sConfigFile), "configs/simple-chatcolors.cfg"); - if (!FileExists(sConfigFile)) - { - - /** - Config file doesn't exists, stop the plugin - */ - LogError("[SCC] Simple Chat Colors is not running! Could not find file %s", sConfigFile); - SetFailState("Could not find file %s", sConfigFile); - } - - /** - Create the arrays and variables - */ - new String:sGroupName[256]; - new String:sGroupFlag[15]; - new String:sGroupNameColor[15]; - new String:sGroupTextColor[15]; - - - /** - Load config file as a KeyValues file - */ - new Handle:kvChatColors = CreateKeyValues("admin_colors"); - FileToKeyValues(kvChatColors, sConfigFile); - - if (!KvGotoFirstSubKey(kvChatColors)) - { - return; - } - - /** - Load up all the groups in the file - */ - do - { - - /** - Get the section name; should be the "group" name - */ - KvGetSectionName(kvChatColors, sGroupName, sizeof(sGroupName)); - - - /** - Get the flags and colors - */ - KvGetString(kvChatColors, "flag", sGroupFlag, sizeof(sGroupFlag)); - KvGetString(kvChatColors, "namecolor", sGroupNameColor, sizeof(sGroupNameColor)); - KvGetString(kvChatColors, "textcolor", sGroupTextColor, sizeof(sGroupTextColor)); - - if (g_bDebug) - { - LogMessage("Group Name/SteamID: %s", sGroupName); - LogMessage("Flag String: %s", sGroupFlag); - LogMessage("Color on name: %s", sGroupNameColor); - LogMessage("Color of text: %s", sGroupTextColor); - } - - /** - Push the values to the arrays - */ - PushArrayString(g_aGroupNames, sGroupName); - PushArrayString(g_aGroupFlag, sGroupFlag); - PushArrayString(g_aGroupNameColor, sGroupNameColor); - PushArrayString(g_aGroupTextColor, sGroupTextColor); - } while (KvGotoNextKey(kvChatColors)); - - /** - Close our handle - */ - CloseHandle(kvChatColors); -} - -stock ReloadConfigFile() -{ - - /** - Clear the array - */ - ClearArray(g_aGroupNames); - ClearArray(g_aGroupFlag); - ClearArray(g_aGroupNameColor); - ClearArray(g_aGroupTextColor); - - /** - Load the admins, groups, and colors from the config - */ - LoadAdminsAndColorsFromConfig(); - g_iArraySize = GetArraySize(g_aGroupNames); - - /** - Recheck all the online players for assigned colors - */ - for (new index = 1; index <= MaxClients; index++) - { - if (IsClientConnected(index) && IsClientInGame(index)) - { - CheckAdmin(index); - } - } -} - -stock CheckAdmin(client) -{ - new String:sFlags[15]; - new String:sClientSteamID[64]; - new iGroupFlags; - new iFlags; - new iIndex = -1; - - /** - Look for a steamid first - */ - GetClientAuthString(client, sClientSteamID, sizeof(sClientSteamID)); - iIndex = FindStringInArray(g_aGroupNames, sClientSteamID); - if (iIndex != -1) - { - g_aPlayerColorIndex[client] = iIndex; - } - - /** - Didn't find one, check flags - */ - else - { - /** - Search for flag in groups - */ - - iFlags = GetUserFlagBits(client); - for (iIndex = 0; iIndex < g_iArraySize; iIndex++) - { - GetArrayString(g_aGroupFlag, iIndex, sFlags, sizeof(sFlags)); - iGroupFlags = ReadFlagString(sFlags); - if (iFlags & iGroupFlags) - { - g_aPlayerColorIndex[client] = iIndex; - break; - } - } - } - - if (g_bDebug) - { - PrintToChatAll("SteamID: %s", sClientSteamID); - PrintToChatAll("Array Index: %i", iIndex); - PrintToChatAll("Flag String: %s", sFlags); - PrintToChatAll("Flag Bits of Client: %i", iFlags); - PrintToChatAll("Flag Bits of Group: %i", iGroupFlags); - } -} - -stock FormatMessage(iClient, iTeam, bool:bAlive, String:sChatMsg[], const Sting:sMessage[], iArrayIndex) -{ - decl String:sDead[10], - String:sTeam[10], - String:sClientName[64]; - - GetClientName(iClient, sClientName, sizeof(sClientName)); - - if (iTeam != 0) - { - Format(sTeam, sizeof(sTeam), "(TEAM) "); - } - else - { - Format(sTeam, sizeof(sTeam), ""); - } - if (bAlive) - { - Format(sDead, sizeof(sDead), ""); - } - else - { - Format(sDead, sizeof(sDead), "*DEAD* "); - } - - new String:sNameColor[15]; - new String:sTextColor[15]; - GetArrayString(g_aGroupNameColor, iArrayIndex, sNameColor, sizeof(sNameColor)); - GetArrayString(g_aGroupTextColor, iArrayIndex, sTextColor, sizeof(sTextColor)); - - Format(sChatMsg, CHAT_MAX_MESSAGE_LENGTH, "{default}%s%s%s%s {default}: %s%s", sDead, sTeam, sNameColor, sClientName, sTextColor, sMessage); -} - -/** -Adjust the settings if a convar was changed -*/ -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (StringToInt(newValue) == 1) - { - g_bDebug = true; - } - else - { - g_bDebug = false; - } -} \ No newline at end of file diff --git a/Simple Spectate/addons/sourcemod/scripting/simple-donatorbenefits.sp b/Simple Spectate/addons/sourcemod/scripting/simple-donatorbenefits.sp deleted file mode 100644 index e3f6845..0000000 --- a/Simple Spectate/addons/sourcemod/scripting/simple-donatorbenefits.sp +++ /dev/null @@ -1,1312 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Donator Benefits -Description: - Provides donator benefits to players -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include -#include - -#define PLUGIN_VERSION "1.1.$Rev$" - -#define CHAT_SYMBOL '@' -#define CHAT_MAX_MESSAGE_LENGTH 1024 - -enum PlayerData -{ - bool:bIsDonator, - bool:bQueue, - bool:bImmune, - iHealthCount, - iNewTeam -}; - -/** - Public convar handles - */ -new Handle:sdb_enabled = INVALID_HANDLE; -new Handle:sdb_donationflag = INVALID_HANDLE; -new Handle:sdb_soundfile = INVALID_HANDLE; -new Handle:sdb_joinsound_enabled = INVALID_HANDLE; -new Handle:sdb_joinpubmsg_enabled = INVALID_HANDLE; -new Handle:sdb_joinprivmsg_enabled = INVALID_HANDLE; -new Handle:sdb_chatcolors_enabled = INVALID_HANDLE; -new Handle:sdb_immunity_enabled = INVALID_HANDLE; -new Handle:sdb_ubercharge_enabled = INVALID_HANDLE; -new Handle:sdb_givehealth_enabled = INVALID_HANDLE; -new Handle:sdb_nofalldmg_enabled = INVALID_HANDLE; -new Handle:sdb_fastheavy_enabled = INVALID_HANDLE; -new Handle:sdb_swapteam_enabled = INVALID_HANDLE; -new Handle:sdb_chatcolor = INVALID_HANDLE; -new Handle:sdb_uberlevel = INVALID_HANDLE; -new Handle:sdb_healthcount = INVALID_HANDLE; -new Handle:sdb_healthbonus = INVALID_HANDLE; -new Handle:sdb_heavymultiplier = INVALID_HANDLE; - -/** -Create global enable/disable bools so we don't have to check the console variable on every call -*/ -new bool:g_bIsEnabled = true; -new bool:g_bIsJoinSoundEnabled = true; -new bool:g_bIsJoinPubMsgEnabled = true; -new bool:g_bIsJoinPrivMsgEnabled = true; -new bool:g_bIsChatColorsEnabled = true; -new bool:g_bIsImmuntyEnabled = true; -new bool:g_bIsUberChargeEnabled = true; -new bool:g_bIsGiveHealthEnabled = true; -new bool:g_bIsNoFallDmgEnabled = true; -new bool:g_bIsFastHeayEnabled = true; -new bool:g_bIsSwapTeamEnabled = true; - -/** - Player arrays - */ -new g_aPlayers[MAXPLAYERS + 1][PlayerData]; - - -/** -Rest of the globals -*/ -new bool:g_bRoundEnd = false; -new String:g_sCharDonatorFlag[5]; -new String:g_sSoundFile[PLATFORM_MAX_PATH]; -new String:g_sChatColor[11]; -new g_iHealthBonus; -new g_iHealthCount; -new g_iClassMaxHealth[TFClassType] = {0, 125, 125, 200, 175, 150, 300, 175, 125, 125}; -new g_fClassMaxSpeed[TFClassType] = {0, 400, 300, 240, 280, 320, 230, 300, 300, 300}; -new Float:g_fHeavyMultiplier = 0.0; -new Float:g_fUberLevel = 0.0; - -public Plugin:myinfo = -{ - name = "Simple Donation Benefits", - author = "Simple Plugins", - description = "Gives donators benefits to players", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -} - -public OnPluginStart() -{ - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook the game events - */ - LogAction(0, -1, "[SDB] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_connect", HookPlayerSpawn, EventHookMode_Pre); - HookEvent("player_spawn", HookPlayerSpawn, EventHookMode_Post); - HookEvent("player_death", HookPlayerDeath, EventHookMode_Post); - HookEvent("player_team", HookPlayerChangeTeam, EventHookMode_Post); - switch (g_CurrentMod) - { - case GameType_TF: - { - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - HookEvent("player_changeclass", HookPlayerClass, EventHookMode_Post); - } - case GameType_DOD: - { - HookEvent("dod_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_Post); - } - default: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - } - } - - /** - Create console variables - */ - CreateConVar("sdb_version", PLUGIN_VERSION, "Simple Donation Benefits", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - sdb_enabled = CreateConVar("sdb_enabled", "1", "Enable/Disable Simple Donation Benefits"); - sdb_donationflag = CreateConVar("sdb_donationflag", "a", "Flag ALREADY given to donators. Must be in char format"); - - /** - Create the enable/disable donator console variables - */ - sdb_joinsound_enabled = CreateConVar("sdb_joinsound_enabled", "1", "Enable/Disable donator join sound"); - sdb_joinpubmsg_enabled = CreateConVar("sdb_joinpubmsg_enabled", "1", "Enable/Disable public donator join message (replaces: as connected)"); - sdb_joinprivmsg_enabled = CreateConVar("sdb_joinprivmsg_enabled", "1", "Enable/Disable private donator join message (sent only to donator)"); - sdb_chatcolors_enabled = CreateConVar("sdb_chatcolors_enabled", "1", "Enable/Disable donator chat colors"); - sdb_immunity_enabled = CreateConVar("sdb_immunity_enabled", "1", "Enable/Disable donator round end immunity"); - sdb_ubercharge_enabled = CreateConVar("sdb_ubercharge_enabled", "1", "Enable/Disable donator medics starting with ubercharge"); - sdb_givehealth_enabled = CreateConVar("sdb_givehealth_enabled", "1", "Enable/Disable donator instant health bonus"); - sdb_nofalldmg_enabled = CreateConVar("sdb_nofalldmg_enabled", "1", "Enable/Disable no fall damage for donators"); - sdb_fastheavy_enabled = CreateConVar("sdb_fastheavy_enabled", "1", "Enable/Disable donator heavies moving faster while spinning"); - sdb_swapteam_enabled = CreateConVar("sdb_swampteam_enabled", "1", "Enable/Disable donator swap team ability"); - - /** - Create the donator setting console variables - */ - sdb_soundfile = CreateConVar("sdb_soundfile", "custom/donatorjoin.mp3", "The location of sound file"); - sdb_chatcolor = CreateConVar("sdb_chatcolor", "green", "Color to use for donator chat. Valid colors are green and lightgreen"); - sdb_uberlevel = CreateConVar("sdb_uberlevel", "0.5", "Uberlevel to give donator medic at spawn. 1.0 = full uber", _, true, 0.0, true, 1.0); - sdb_healthcount = CreateConVar("sdb_healthcount", "1", "Number of times a donator can use use instant health per life"); - sdb_healthbonus = CreateConVar("sdb_healthbonus", "100", "The amount of health to heal the donator"); - sdb_heavymultiplier = CreateConVar("sdb_heavyspeed", "0.5", "The speed multiplier for the fast heavy. Based on running speed. 1.0 = running speed. (Game Default is 0.20)", _, true, 0.0, true, 1.0); - - /** - Hook dukehacks calls - */ - dhAddClientHook(CHK_TakeDamage, Hacks_TakeDamageHook); - dhAddClientHook(CHK_PreThink, Hacks_PreThinkHook); - - /** - Hook the console variables if they change - */ - HookConVarChange(sdb_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_donationflag, ConVarSettingsChanged); - HookConVarChange(sdb_joinsound_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_joinpubmsg_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_joinprivmsg_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_chatcolors_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_immunity_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_ubercharge_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_givehealth_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_nofalldmg_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_swapteam_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_fastheavy_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_soundfile, ConVarSettingsChanged); - HookConVarChange(sdb_chatcolor, ConVarSettingsChanged); - HookConVarChange(sdb_uberlevel, ConVarSettingsChanged); - HookConVarChange(sdb_healthcount, ConVarSettingsChanged); - HookConVarChange(sdb_healthbonus, ConVarSettingsChanged); - HookConVarChange(sdb_heavymultiplier, ConVarSettingsChanged); - - /** - Register the commands - */ - RegConsoleCmd("sm_swapteams", Command_SwapTeam, "sm_swapteams <[0]instant/[1]queued>: Swaps your team to the other team"); - RegConsoleCmd("sm_ihealth", Command_InstantHealth, "sm_ihealth: Gives you a instant health pack"); - RegAdminCmd("sm_teaser", Command_Teaser, ADMFLAG_GENERIC,"sm_teaser <[0]add/[1]remove>: Gives temporary donator privilages to a player"); - RegConsoleCmd("say", Command_Say); - - RegConsoleCmd("sm_test", Command_TEST); - - /** - Load the translations - */ - LoadTranslations("common.phrases"); - LoadTranslations("simpledonatorbenefits.phrases"); - - /** - Load or create the config file - */ - AutoExecConfig(true, "plugin.simpledonatorbenefits"); - LogAction(0, -1, "[SDB] Simple Donator Benefits is loaded."); -} - -public OnAllPluginsLoaded() -{ - //something -} - -public OnLibraryRemoved(const String:name[]) -{ - //something -} - -public OnConfigsExecuted() -{ - /** - Load up all the variable defaults - */ - LoadUpVariables(); - - /** - If the join sound is enabled, prep the sound files - */ - if (g_bIsJoinSoundEnabled) - PrepSoundFile(); - - /** - Log our activity - */ - if (g_bIsEnabled) - LogAction(0, -1, "Simple Donation Benefits is ENABLED"); - else - LogAction(0, -1, "Simple Donation Benefits is DISABLED"); -} - -public OnClientPostAdminCheck(client) -{ - - /** - Check if the client is a donator - */ - if (SM_IsValidAdmin(client, g_sCharDonatorFlag)) - { - - /** - They are, so we set the player array to true and start a timer for the sound or add - */ - g_aPlayers[client][bIsDonator] = true; - if (g_bIsJoinSoundEnabled || g_bIsJoinPrivMsgEnabled) - { - CreateTimer(10.0, Timer_DonatorJoined, client, TIMER_FLAG_NO_MAPCHANGE); - } - } - else - { - /** - They aren't, so we set the player array to false - */ - g_aPlayers[client][bIsDonator] = false; - } -} - -public OnClientDisconnect_Post(client) -{ - - /** - Clean up the player variables - */ - CleanUpPlayer(client); -} - -public Action:Command_SwapTeam(client, args) -{ - - /** - Make sure we are enabled - */ - if (!g_bIsEnabled || !g_bIsSwapTeamEnabled) - { - return Plugin_Handled; - } - - /** - Make sure the command is not started by the server - */ - if (client == 0) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "PlayerLevelCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Make sure the player is a donator - */ - if (!g_aPlayers[client][bIsDonator]) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Lets make sure the client is one a team we can swap. - If he is we set the global array to the opposite team. - */ - new iTeam = GetClientTeam(client); - if (iTeam == g_aCurrentTeams[Team1]) - { - g_aPlayers[client][iNewTeam] = g_aCurrentTeams[Team2]; - } - else if (iTeam == g_aCurrentTeams[Team2]) - { - g_aPlayers[client][iNewTeam] = g_aCurrentTeams[Team1]; - } - else - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "InValidTeam", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check to see if we have command arguments. - */ - if (GetCmdArgs()) - { - - /** - We do, so lets get it and see if the client wants to be switched instantly or queued for death. - */ - decl String:sArg[5]; - GetCmdArg(1, sArg, sizeof(sArg)); - new iWantsQue = StringToInt(sArg); - if (iWantsQue && !g_aPlayers[client][bQueue]) - { - - /** - He wants the que and isn't already in it, set the global array. - */ - g_aPlayers[client][bQueue] = true; - ReplyToCommand(client, "\x01\x04[STM]\x01 %T", "PlayerQueue", LANG_SERVER); - } - else if (!iWantsQue) - { - - /** - He wants to be switched right now, lets call the stock function. - */ - SM_MovePlayer(client, g_aPlayers[client][iNewTeam]); - } - } - else - { - - /** - There are no command arguments so we build and display the swap menu. - */ - new Handle:hPlayerMenu = BuildSwapModeMenu(); - DisplayMenu(hPlayerMenu, client, MENU_TIME_FOREVER); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_InstantHealth(client, args) -{ - - /** - Make sure we are enabled - */ - if (!g_bIsEnabled || !g_bIsGiveHealthEnabled) - { - return Plugin_Handled; - } - - /** - Make sure the command is not started by the server - */ - if (client == 0) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "PlayerLevelCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Make sure the player is a donator - */ - if (!g_aPlayers[client][bIsDonator]) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check health count to see if the player has reached the max - */ - if (g_aPlayers[client][iHealthCount] >= g_iHealthCount) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "ReachedCount", LANG_SERVER); - return Plugin_Handled; - } - - /** - Get the class of the player and the max health for that class - */ - new iHealth = GetClientHealth(client); - new TFClassType:PlayerClass = TF2_GetPlayerClass(client); - new iMaxHealth = g_iClassMaxHealth[PlayerClass]; - - /** - Check to see if the player is at the max health of the class - */ - if (iHealth >= iMaxHealth) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "AtMaxHealth", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check the current health - */ - if (iHealth + g_iHealthBonus >= iMaxHealth) - { - - /** - Raise them to max health if the current health + bonus would go above it - */ - SetEntityHealth(client, iMaxHealth); - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "ToMaxHealth", LANG_SERVER); - } - else - { - - /** - Give them the instant health bonus - */ - SetEntityHealth(client, iHealth + g_iHealthBonus); - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "HealthBonus", LANG_SERVER); - } - - /** - Increase the count - */ - g_aPlayers[client][iHealthCount] += 1; - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_Teaser(client, args) -{ - - /** - Make sure we are enabled - */ - if (!g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - Check to see if we have command arguments. - */ - new iCmdArgs = GetCmdArgs(); - if (iCmdArgs == 0) - { - - /** - We don't so display the player menu. - */ - new Handle:hPlayerMenu = BuildPlayerMenu(); - DisplayMenu(hPlayerMenu, client, MENU_TIME_FOREVER); - return Plugin_Handled; - } - - /** - We have some arguments, see if we can find the player - */ - decl String:sPlayer[64]; - GetCmdArg(1, sPlayer, sizeof(sPlayer)); - new iTarget = FindTarget(client, sPlayer, true, true); - if (iTarget == -1 || !IsClientInGame(iTarget)) - { - - /** - We don't know who this is, so display the player menu. - */ - new Handle:hPlayerMenu = BuildPlayerMenu(); - DisplayMenu(hPlayerMenu, client, MENU_TIME_FOREVER); - } - else - { - /** - We found the player, see if we are supposed to turn it on or off. - */ - if (iCmdArgs >= 2) - { - decl String:sOn[3]; - GetCmdArg(2, sOn, sizeof(sOn)); - if (StringToInt(sOn)) - { - - /** - Turn temp benefits on. - */ - g_aPlayers[iTarget][bIsDonator] = true; - } - else - { - - /** - Turn temp benefits on. - */ - g_aPlayers[iTarget][bIsDonator] = false; - } - } - else - { - - /** - We don't know what to do, so just turn it on. - */ - g_aPlayers[iTarget][bIsDonator] = true; - } - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_Say(client, args) -{ - - /** - Make sure we are enabled. - */ - if (client == 0 || IsChatTrigger() || !g_bIsChatColorsEnabled || !g_bIsEnabled) - { - return Plugin_Continue; - } - - /** - Check the client to see if they are a donator. - */ - if (g_aPlayers[client][bIsDonator]) - { - - /** - The client is, so get the chat message and strip it down. - */ - decl String:sArg[CHAT_MAX_MESSAGE_LENGTH], - String:sChatMsg[CHAT_MAX_MESSAGE_LENGTH]; - new bool:bAlive = IsPlayerAlive(client); - GetCmdArgString(sArg, sizeof(sArg)); - StripQuotes(sArg); - TrimString(sArg); - new startidx; - if (sArg[strlen(sArg)-1] == '"') - { - sArg[strlen(sArg)-1] = '\0'; - startidx = 1; - } - - /** - Bug out if they are using the admin chat symbol (admin chat). - */ - if (sArg[startidx] == CHAT_SYMBOL) - { - return Plugin_Continue; - } - - /** - Format the message. - */ - FormatMessage(client, 0, bAlive, sChatMsg, sArg); - - /** - Send the message. - */ - SayText2(0, client, sChatMsg); - - /** - We are done, bug out, and stop the original chat message. - */ - return Plugin_Stop; - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -public Action:Hacks_TakeDamageHook(client, attacker, inflictor, Float:damage, &Float:multiplier, damagetype) -{ - - /** - Make sure we are enabled and the client is a donator. - */ - if (g_bIsEnabled && g_bIsNoFallDmgEnabled && g_aPlayers[client][bIsDonator]) - { - - /** - Check for fall damage. - */ - if (damagetype & DMG_FALL) - { - - /** - Cancel the fall damage and bug out. - */ - multiplier *= 0.0; - return Plugin_Changed; - } - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -public Action:Hacks_PreThinkHook(client) -{ - - /** - Make sure we are enabled and the client is a donator. - */ - if (!g_bIsEnabled || !g_bIsFastHeayEnabled || !g_aPlayers[client][bIsDonator]) - { - return Plugin_Continue; - } - - /** - Check the players class. We are looking for the heavy. - */ - new TFClassType:PlayerClass = TF2_GetPlayerClass(client); - if (PlayerClass == TFClass_Heavy) - { - - /** - We have a heavy, lets check the weapon. - */ - decl String:sWeaponCurrent[64]; - GetClientWeapon(client, sWeaponCurrent, sizeof(sWeaponCurrent)); - if (StrEqual(sWeaponCurrent, "tf_weapon_minigun", false)) - { - - /** - We have a minigun, check the heavies current weapon state to see if it's spinning. - */ - new iWeapon = GetPlayerWeaponSlot(client, 0); - new iWeaponState = GetEntProp(iWeapon, Prop_Send, "m_iWeaponState"); - if (iWeaponState > 0) - { - - /** - He is spinning, so lets change the heavies speed. - */ - new Float:fMaxSpeed = FloatMul(g_fHeavyMultiplier, float(g_fClassMaxSpeed[PlayerClass])); - SetEntPropFloat(client, Prop_Send, "m_flMaxspeed", fMaxSpeed); - } - } - } - - /** - We are done, bug out. - */ - // use Plugin_Continue (other options are ignored on PreThink hook) - return Plugin_Continue; -} - -public Action:HookPlayerConnect(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Make sure we are enabled. - */ - if (!g_bIsEnabled || !g_bIsJoinPubMsgEnabled || !dontBroadcast) - { - return Plugin_Continue; - } - - /** - Get our event variables and check the client. - */ - new iUserId = GetEventInt(event,"userid"); - new iClient = GetClientOfUserId(iUserId); - if (iClient != 0) - { - - /** - Get the info on the client and format the message. - */ - decl String:sClientName[255], - String:sAuthID[255], - String:sMsg[1024]; - - GetEventString(event, "name", sClientName, sizeof(sClientName)); - GetClientAuthString(iClient, sAuthID, sizeof(sAuthID)); - Format(sMsg, sizeof(sMsg), "%T", "PublicJoinMessage", LANG_SERVER, sClientName); - - /** - Print the message to the clients and do the normal functions. - */ - for (new i = 1; i <= MaxClients; i++) - { - if(IsClientConnected(i) && IsClientInGame(i)) - { - PrintToChat(i,"\x01\x05%s", sMsg); - PrintToConsole(i,"%s has connected.", sClientName); - } - } - LogToGame("\"%s<%d><%s><>\" entered the game", sClientName, iUserId, sAuthID); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public HookPlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled && g_bIsUberChargeEnabled) - { - - /** - Get the event variables and check the class for medic - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - if (TF2_GetPlayerClass(iClient) == TFClass_Medic) - { - - /** - Start a timer to get the medic the uber boost - */ - CreateTimer(0.25, Timer_PlayerUberDelay, iClient, TIMER_FLAG_NO_MAPCHANGE); - } - } -} - -public HookPlayerClass(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled && g_bIsUberChargeEnabled) - { - - /** - Get the event variables and check the class for medic - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - if (TF2_GetPlayerClass(iClient) == TFClass_Medic) - { - - /** - Start a timer to get the medic the uber boost - */ - CreateTimer(0.25, Timer_PlayerUberDelay, iClient, TIMER_FLAG_NO_MAPCHANGE); - } - } -} - -public HookPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled || g_bIsSwapTeamEnabled) - { - - /** - Get the event variables - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - new String:sWeapon[256]; - GetEventString(event, "weapon", sWeapon, sizeof(sWeapon)); - - /** - Bug out if world killed him. Means he changed team or something - */ - if (StrEqual(sWeapon, "world", false)) - { - g_aPlayers[iClient][bQueue] = false; - return; - } - - /** - If he is queued up, swap him - */ - if (g_aPlayers[iClient][bQueue]) - { - SM_MovePlayer(iClient, g_aPlayers[iClient][iNewTeam]); - } - } -} - -public HookPlayerChangeTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled || g_bIsSwapTeamEnabled) - { - - /** - Get the event variables - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - - /** - If he is queued up, clear the status - */ - if (g_aPlayers[iClient][bQueue]) - { - g_aPlayers[iClient][bQueue] = false; - } - } -} - -public HookRoundStart(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Set our variables. - */ - g_bRoundEnd = false; - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled && g_bIsImmuntyEnabled) - { - - /** - Get rid of their immunity. - */ - ProcessRoundEndImmunity(false); - } -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Set our variables. - */ - g_bRoundEnd = true; - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled && g_bIsImmuntyEnabled) - { - - /** - Give them their immunity. - */ - ProcessRoundEndImmunity(true); - } -} - -public Action:Timer_DonatorJoined(Handle:timer, any:client) -{ - - /** - Make sure sounds are enabled. - */ - if (g_bIsEnabled && g_bIsJoinSoundEnabled) - { - EmitSoundToClient(client, g_sSoundFile); - } - - /** - Make sure private messages are enabled. - */ - if (g_bIsJoinPrivMsgEnabled) - { - - /** - Send messages to the client. - */ - decl String:sMsg[1024]; - Format(sMsg, sizeof(sMsg), "%T", "PrivateJoinMessage", LANG_SERVER); - PrintToChat(client,"\x01\x05%s", sMsg); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Timer_PlayerUberDelay(Handle:timer, any:client) -{ - - /** - Make sure the client is still in game. - */ - if (IsClientInGame(client)) - { - - /** - Make sure the client is still a medic. - */ - if (TF2_GetPlayerClass(client) == TFClass_Medic) - { - - /** - Get the medgun weapon index - */ - new iIndex = GetPlayerWeaponSlot(client, 1); - if (iIndex > 0) - { - - /** - Set the uber level with the bonus. - */ - SetEntPropFloat(iIndex, Prop_Send, "m_flChargeLevel", g_fUberLevel); - } - } - } -} - -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (convar == sdb_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsEnabled = false; - } - else - { - g_bIsEnabled = true; - } - } - else if (convar == sdb_donationflag) - { - Format(g_sCharDonatorFlag, sizeof(g_sCharDonatorFlag), "%s", newValue); - } - else if (convar == sdb_soundfile) - { - Format(g_sSoundFile, sizeof(g_sSoundFile), "%s", newValue); - } - else if (convar == sdb_joinsound_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsJoinSoundEnabled = false; - } - else - { - g_bIsJoinSoundEnabled = true; - } - } - else if (convar == sdb_joinpubmsg_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsJoinPubMsgEnabled = false; - } - else - { - g_bIsJoinPubMsgEnabled = true; - } - } - else if (convar == sdb_joinprivmsg_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsJoinPrivMsgEnabled = false; - } - else - { - g_bIsJoinPrivMsgEnabled = true; - } - } - else if (convar == sdb_chatcolors_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsChatColorsEnabled = false; - } - else - { - g_bIsChatColorsEnabled = true; - } - } - else if (convar == sdb_immunity_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsImmuntyEnabled = false; - } - else - { - g_bIsImmuntyEnabled = true; - } - } - else if (convar == sdb_ubercharge_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsUberChargeEnabled = false; - } - else - { - g_bIsUberChargeEnabled = true; - } - } - else if (convar == sdb_givehealth_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsGiveHealthEnabled = false; - } - else - { - g_bIsGiveHealthEnabled = true; - } - } - else if (convar == sdb_nofalldmg_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsNoFallDmgEnabled = false; - } - else - { - g_bIsNoFallDmgEnabled = true; - } - } - else if (convar == sdb_fastheavy_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsFastHeayEnabled = false; - } - else - { - g_bIsFastHeayEnabled = true; - } - } - else if (convar == sdb_swapteam_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsSwapTeamEnabled = false; - } - else - { - g_bIsSwapTeamEnabled = true; - } - } - else if (convar == sdb_chatcolor) - { - Format(g_sChatColor, sizeof(g_sChatColor), "%s", newValue); - } - else if (convar == sdb_uberlevel) - { - g_fUberLevel = StringToFloat(newValue); - } - else if (convar == sdb_healthcount) - { - g_iHealthCount = StringToInt(newValue); - } - else if (convar == sdb_healthbonus) - { - g_iHealthBonus = StringToInt(newValue); - } - else if (convar == sdb_heavymultiplier) - { - g_fHeavyMultiplier = StringToFloat(newValue); - } -} - -stock LoadUpVariables() -{ - g_bIsEnabled = GetConVarBool(sdb_enabled); - g_bIsJoinSoundEnabled = GetConVarBool(sdb_enabled); - g_bIsJoinPubMsgEnabled = GetConVarBool(sdb_enabled); - g_bIsJoinPrivMsgEnabled = GetConVarBool(sdb_enabled); - g_bIsChatColorsEnabled = GetConVarBool(sdb_enabled); - g_bIsImmuntyEnabled = GetConVarBool(sdb_enabled); - g_bIsUberChargeEnabled = GetConVarBool(sdb_enabled); - g_bIsGiveHealthEnabled = GetConVarBool(sdb_enabled); - g_bIsNoFallDmgEnabled = GetConVarBool(sdb_enabled); - g_bIsFastHeayEnabled = GetConVarBool(sdb_enabled); - g_bIsSwapTeamEnabled = GetConVarBool(sdb_enabled); - GetConVarString(sdb_donationflag, g_sCharDonatorFlag, sizeof(g_sCharDonatorFlag)); - GetConVarString(sdb_soundfile, g_sSoundFile, sizeof(g_sSoundFile)); - GetConVarString(sdb_chatcolor, g_sChatColor, sizeof(g_sChatColor)); - g_bRoundEnd = false; - g_iHealthBonus = GetConVarInt(sdb_healthbonus); - g_iHealthCount = GetConVarInt(sdb_healthcount); - g_fHeavyMultiplier = GetConVarFloat(sdb_heavymultiplier); - g_fUberLevel = GetConVarFloat(sdb_uberlevel); -} - -stock PrepSoundFile() -{ - decl String:buffer[PLATFORM_MAX_PATH]; - PrecacheSound(g_sSoundFile, true); - Format(buffer, sizeof(buffer), "sound/%s", g_sSoundFile); - AddFileToDownloadsTable(buffer); -} - -stock CleanUpPlayer(client) -{ - g_aPlayers[client][bIsDonator] = false; - g_aPlayers[client][bQueue] = false; - g_aPlayers[client][bImmune] = false; - g_aPlayers[client][iNewTeam] = 0; - g_aPlayers[client][iHealthCount] = 0; -} - -stock ProcessRoundEndImmunity(bool:give) -{ - for (new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][bIsDonator]) - { - if (give) - { - SetEntProp(i, Prop_Data, "m_takedamage", 0, 1); - g_aPlayers[i][bImmune] = true; - } - else - { - SetEntProp(i, Prop_Data, "m_takedamage", 2, 1); - g_aPlayers[i][bImmune] = false; - } - } - } -} - -stock FormatMessage(iClient, iTeam, bool:bAlive, String:sChatMsg[], const Sting:sMessage[]) -{ - decl String:sDead[10], - String:sTeam[10], - String:sClientName[64]; - GetClientName(iClient, sClientName, sizeof(sClientName)); - if (iTeam != 0) - Format(sTeam, sizeof(sTeam), "(TEAM) "); - else - Format(sTeam, sizeof(sTeam), ""); - if (bAlive) - Format(sDead, sizeof(sDead), ""); - else - Format(sDead, sizeof(sDead), "*DEAD* "); - if (StrContains(g_sChatColor, "light", false) == -1) - Format(sChatMsg, CHAT_MAX_MESSAGE_LENGTH, "\x01%s%s\x03%s \x01: \x05%s", sDead, sTeam, sClientName, sMessage); - else - Format(sChatMsg, CHAT_MAX_MESSAGE_LENGTH, "\x01%s%s\x03%s \x01: \x04%s", sDead, sTeam, sClientName, sMessage); -} - -stock SayText2(target, author, const String:message[]) -{ - new Handle:hBf; - if (target == 0) - hBf = StartMessageAll("SayText2"); - else - hBf = StartMessageOne("SayText2", target); - if (hBf != INVALID_HANDLE) - { - BfWriteByte(hBf, author); - BfWriteByte(hBf, true); - BfWriteString(hBf, message); - EndMessage(); - } -} - -stock ProcessAdmins() -{ - for (new i = 1; i <= MaxClients; i++) - { - if (SM_IsValidAdmin(i, g_sCharDonatorFlag)) - { - g_aPlayers[i][bDonator] = true; - } - else - { - g_aPlayers[i][bDonator] = false; - } - } -} - -stock ProcessLate() -{ - if (g_bIsEnabled) - { - ProcessAdmins(); - PrepSoundFile(); - if (g_bRoundEnd && g_bIsImmuntyEnabled) - { - ProcessRoundEndImmunity(true); - } - if (!g_bIsImmuntyEnabled) - { - ProcessRoundEndImmunity(false); - } - } - else - { - ProcessRoundEndImmunity(false); - } -} - -public Menu_SwapMode(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, 64); - if (StringToInt(sSelection)) - g_aPlayers[param1][bQueue] = false; - else - g_aPlayers[param1][bQueue] = true; - if (!g_aPlayers[param1][bQueue]) - SM_MovePlayer(param1, g_aPlayers[param1][iNewTeam]); - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -public Menu_SelectPlayer(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[256]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - new iTarget = GetClientOfUserId(StringToInt(sSelection)); - if (g_aPlayers[iTarget][bIsDonator]) - g_aPlayers[iTarget][bIsDonator] = false; - else - g_aPlayers[iTarget][bIsDonator] = true; - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -stock Handle:BuildSwapModeMenu() -{ - new Handle:menu = CreateMenu(Menu_SwapMode); - SetMenuTitle(menu, "Select When to Swap:"); - AddMenuItem(menu, "0", "Instantly (Kills)"); - AddMenuItem(menu, "1", "Queue on next death"); - SetMenuExitBackButton(menu, false); - return menu; -} - -stock Handle:BuildPlayerMenu() -{ - new Handle:menu = CreateMenu(Menu_SelectPlayer); - AddTargetsToMenu(menu, 0, true, false); - SetMenuTitle(menu, "Select A Player:"); - SetMenuExitBackButton(menu, true); - return menu; -} - -public Action:Command_TEST(client, args) -{ - -} \ No newline at end of file diff --git a/Simple Spectate/addons/sourcemod/scripting/simple-messagesuppression.sp b/Simple Spectate/addons/sourcemod/scripting/simple-messagesuppression.sp deleted file mode 100644 index f7725a4..0000000 --- a/Simple Spectate/addons/sourcemod/scripting/simple-messagesuppression.sp +++ /dev/null @@ -1,227 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Message Suppression -Description: - Blocks Specific Message Outputs -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include -#include - -#define SUPPRESS_VERSION "1.1.$Rev$" - -public Plugin:myinfo = -{ - name = "Simple Message Suppression", - author = "FlyingMongoose, psychonic", - description = "Blocks Specific Message Outputs", - version = SUPPRESS_VERSION, - url = "http://www.simple-plugins.com/" -} - -new Handle:cvarBlockSpectateMessage; -new Handle:cvarBlockDisconnectMessage; -new Handle:cvarBlockConnectMessage; -new Handle:cvarAdminShowMessages; -new iSpecTeam = 1; - - -public OnPluginStart() -{ - CreateConVar("suppress_version", SUPPRESS_VERSION, _, FCVAR_PLUGIN|FCVAR_NOTIFY|FCVAR_REPLICATED|FCVAR_SPONLY|FCVAR_DONTRECORD); - cvarBlockSpectateMessage = CreateConVar("sm_blockspectatemessage", "1", "If enabled it blocks the join team message if an administrator joins spectator", FCVAR_PLUGIN, true, 0.0, true, 1.0); - cvarBlockDisconnectMessage = CreateConVar("sm_blockdisconnectmessage", "1", "Blocks the disconnect message", FCVAR_PLUGIN, true, 0.0, true, 1.0); - cvarBlockConnectMessage = CreateConVar("sm_blockconnectmessage", "1", "If enabled it blocks the player connection message.", FCVAR_PLUGIN, true, 0.0, true, 1.0); - cvarAdminShowMessages = CreateConVar("sm_adminshowmessages", "1", "Shows disconnect/connect/team join messages for admins only (if disconnect message is set to be blocked)", FCVAR_PLUGIN, true, 0.0, true, 1.0); - HookEvent("player_team", ev_PlayerTeam, EventHookMode_Pre); - HookEvent("player_disconnect", ev_PlayerDisconnect, EventHookMode_Pre); - HookEvent("player_connect", ev_PlayerConnect, EventHookMode_Pre); - - new String:game_folder[64]; - GetGameFolderName(game_folder, sizeof(game_folder)) - - if (StrContains(game_folder, "insurgency", false) != -1) - { - iSpecTeam = 3; - } - else - { - new String:game_description[64]; - GetGameDescription(game_description, sizeof(game_description), true); - if (StrContains(game_description, "Insurgency", false) != -1) - { - iSpecTeam = 3; - } - } - - AutoExecConfig(true, "suppressmessage", "sourcemod"); -} - -public Action:ev_PlayerTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - if (GetConVarBool(cvarBlockSpectateMessage)) - { - if (!dontBroadcast && !GetEventBool(event, "silent")) - { - new iUserId = GetEventInt(event, "userid"); - new iClient = GetClientOfUserId(iUserId); - new iTeam = GetEventInt(event, "team"); - - if (iTeam == iSpecTeam && GetAdminFlag(GetUserAdmin(iClient), Admin_Kick)) - { - new iOldTeam = GetEventInt(event, "oldteam"); - new bool:bDisconnect = GetEventBool(event, "disconnect"); - new bool:bAutoteam = GetEventBool(event, "autoteam"); - decl String:strName[50]; - GetEventString(event, "name", strName, sizeof(strName)); - - if (iClient != 0) - { - if (GetConVarInt(cvarAdminShowMessages) == 1) - { - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientConnected(i) && IsClientInGame(i) && GetUserAdmin(i) != INVALID_ADMIN_ID) - { - PrintToChat(i,"%N joined team Spectator.", iClient); - PrintToConsole(i,"%N joined team Spectator.", iClient); - } - } - } - } - - new Handle:hEvent = CreateEvent("player_team"); - SetEventInt(hEvent, "userid", iUserId); - SetEventInt(hEvent, "team", iTeam); - SetEventInt(hEvent, "oldteam", iOldTeam); - SetEventBool(hEvent, "disconnect", bDisconnect); - SetEventBool(hEvent, "autoteam", bAutoteam); - SetEventBool(hEvent, "silent", true); - SetEventString(hEvent, "name", strName); - - FireEvent(hEvent, true); - - return Plugin_Handled; - } - } - } - return Plugin_Continue; -} -public Action:ev_PlayerConnect(Handle:event, const String:name[], bool:dontBroadcast) -{ - if (GetConVarBool(cvarBlockConnectMessage)) - { - if (!dontBroadcast) - { - decl String:strName[50]; - GetEventString(event, "name", strName, sizeof(strName)); - new iIndex = GetEventInt(event, "index"); - new iUserId = GetEventInt(event, "userid"); - new iClient = GetClientOfUserId(iUserId); - decl String:strNetworkId[50]; - GetEventString(event, "networkid", strNetworkId, sizeof(strNetworkId)); - decl String:strAddress[50]; - GetEventString(event, "address", strAddress, sizeof(strAddress)); - - if (iClient != 0) - { - if (GetConVarInt(cvarAdminShowMessages) == 1) - { - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientConnected(i) && IsClientInGame(i) && GetUserAdmin(i) != INVALID_ADMIN_ID) - { - PrintToChat(i,"%N has connected.", iClient); - PrintToConsole(i,"%N has connected.", iClient); - } - } - } - } - - new Handle:hEvent = CreateEvent("player_connect"); - SetEventString(hEvent, "name", strName); - SetEventInt(hEvent, "index", iIndex); - SetEventInt(hEvent, "userid", iUserId); - SetEventString(hEvent, "networkid", strNetworkId); - SetEventString(hEvent, "address", strAddress); - - FireEvent(hEvent, true); - - return Plugin_Handled; - } - } - return Plugin_Continue; -} -public Action:ev_PlayerDisconnect(Handle:event, const String:name[], bool:dontBroadcast) -{ - if (GetConVarBool(cvarBlockDisconnectMessage)) - { - if (!dontBroadcast) - { - new iUserId = GetEventInt(event, "userid"); - new iClient = GetClientOfUserId(iUserId); - decl String:strReason[50]; - GetEventString(event, "reason", strReason, sizeof(strReason)); - decl String:strName[50]; - GetEventString(event, "name", strName, sizeof(strName)); - decl String:strNetworkId[50]; - GetEventString(event, "networkid", strNetworkId, sizeof(strNetworkId)); - - if (iClient != 0) - { - if (GetConVarInt(cvarAdminShowMessages) == 1) - { - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientConnected(i) && IsClientInGame(i) && GetUserAdmin(i) != INVALID_ADMIN_ID) - { - PrintToChat(i, "%N has left the server.", iClient); - PrintToConsole(i, "Dropped %N from server (Disconnect by user.)", iClient); - } - } - } - } - - new Handle:hEvent = CreateEvent("player_disconnect"); - SetEventInt(hEvent, "userid", iUserId); - SetEventString(hEvent, "reason", strReason); - SetEventString(hEvent, "name", strName); - SetEventString(hEvent, "networkid", strNetworkId); - - FireEvent(hEvent, true); - - return Plugin_Handled; - } - } - - return Plugin_Continue; -} \ No newline at end of file diff --git a/Simple Spectate/addons/sourcemod/scripting/simple-plugins.sp b/Simple Spectate/addons/sourcemod/scripting/simple-plugins.sp deleted file mode 100644 index 4462b41..0000000 --- a/Simple Spectate/addons/sourcemod/scripting/simple-plugins.sp +++ /dev/null @@ -1,785 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Plugins -Description: - Core plugin for Simple Plugins project -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#define CORE_PLUGIN_VERSION "1.1.$Rev$" - -#include - -enum e_PlayerInfo -{ - Handle:hForcedTeamPlugin = INVALID_HANDLE, - iForcedTeam = 0, - iBuddy = 0, - bool:bBuddyLocked = false -}; - -new Handle:g_fwdPlayerMoved; -new g_aPlayers[MAXPLAYERS + 1][e_PlayerInfo]; -new bool:g_bTeamsSwitched = false; - -/** -Setting our plugin information. -*/ -public Plugin:myinfo = -{ - name = "Simple Plugins Core Plugin", - author = "Simple Plugins", - description = "Core plugin for Simple Plugins", - version = CORE_PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -}; - -public bool:AskPluginLoad(Handle:myself, bool:late, String:error[], err_max) -{ - - /** - Register natives for other plugins - */ - CreateNative("SM_MovePlayer", Native_SM_MovePlayer); - CreateNative("SM_SetForcedTeam", Native_SM_SetForcedTeam); - CreateNative("SM_GetForcedTeam", Native_SM_GetForcedTeam); - CreateNative("SM_ClearForcedTeam", Native_SM_ClearForcedTeam); - CreateNative("SM_GetForcedPlayer", Native_SM_GetForcedPlayer); - CreateNative("SM_AssignBuddy", Native_SM_AssignBuddy); - CreateNative("SM_GetClientBuddy", Native_SM_GetClientBuddy); - CreateNative("SM_LockBuddy", Native_SM_LockBuddy); - CreateNative("SM_IsBuddyLocked", Native_SM_IsBuddyLocked); - CreateNative("SM_ClearBuddy", Native_SM_ClearBuddy); - CreateNative("SM_IsValidAdmin", Native_SM_IsValidAdmin); - CreateNative("SM_IsValidTeam", Native_SM_IsValidTeam); - RegPluginLibrary("simpleplugins"); - return true; -} - -public OnPluginStart() -{ - - CreateConVar("ssm_core_pl_ver", CORE_PLUGIN_VERSION, "Simple SourceMod Plugins Core Plugin Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - CreateConVar("ssm_core_inc_ver", CORE_INC_VERSION, "Simple SourceMod Plugins Core Include Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook some events to control forced players and check extensions - */ - decl String:sExtError[256]; - LogAction(0, -1, "[SSM] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_team", HookPlayerChangeTeam, EventHookMode_Pre); - switch (g_CurrentMod) - { - case GameType_CSS: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - new iExtStatus = GetExtensionFileStatus("game.cstrike.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SSM] Required extension was not found."); - LogAction(0, -1, "[SSM] Plugin FAILED TO LOAD."); - SetFailState("Required extension was not found."); - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SSM] Required extension is loaded with errors."); - LogAction(0, -1, "[SSM] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SSM] Plugin FAILED TO LOAD."); - SetFailState("Required extension is loaded with errors."); - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SSM] Required extension is loaded."); - } - } - case GameType_TF: - { - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_PostNoCopy); - HookUserMessage(GetUserMessageId("TextMsg"), UserMessageHook_Class, true); - new iExtStatus = GetExtensionFileStatus("game.tf2.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SSM] Required extension was not found."); - LogAction(0, -1, "[SSM] Plugin FAILED TO LOAD."); - SetFailState("Required extension was not found."); - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SSM] Required extension is loaded with errors."); - LogAction(0, -1, "[SSM] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SSM] Plugin FAILED TO LOAD."); - SetFailState("Required extension is loaded with errors."); - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SSM] Required extension is loaded."); - } - } - case GameType_DOD: - { - HookEvent("dod_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_PostNoCopy); - } - default: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - } - } - - /** - Load common translations - */ - LoadTranslations ("common.phrases"); - - /** - Create the global forward - */ - g_fwdPlayerMoved = CreateGlobalForward("SM_OnPlayerMoved", ET_Event, Param_Cell, Param_Cell, Param_Cell); -} - -public OnClientDisconnect(client) -{ - - /** - Cleanup clients/players buddy list - */ - if (!IsFakeClient(client)) - { - SM_ClearBuddy(client, true); - SM_LockBuddy(client, false); - } - SM_ClearForcedTeam(client); -} - -public HookRoundStart(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - See if the teams have been switched - */ - if (g_bTeamsSwitched) - { - - /** - Switch the teams the players are forced to - */ - for (new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][iForcedTeam] != 0) - { - if (g_aPlayers[i][iForcedTeam] == g_aCurrentTeams[Team1]) - { - g_aPlayers[i][iForcedTeam] = g_aCurrentTeams[Team2]; - } - else - { - g_aPlayers[i][iForcedTeam] = g_aCurrentTeams[Team1]; - } - } - } - } -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - g_bTeamsSwitched = false; -} - -public HookPlayerChangeTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get our event variables - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - new iTeam = GetEventInt(event, "team"); - - /** - See if the player is on the wrong team - */ - if (g_aPlayers[iClient][iForcedTeam] != 0 && g_aPlayers[iClient][iForcedTeam] != iTeam) - { - - /** - Move the player back to the forced team - */ - CreateTimer(1.0, Timer_ForcePlayerMove, iClient, TIMER_FLAG_NO_MAPCHANGE); - - /** - If the event was going to be broadcasted, we refire it so it is not broadcasted and stop this one - */ - if (!dontBroadcast) - { - new Handle:hEvent = CreateEvent("player_team"); - SetEventInt(hEvent, "userid", GetEventInt(event, "userid")); - SetEventInt(hEvent, "team", GetEventInt(event, "team")); - SetEventInt(hEvent, "oldteam", GetEventInt(event, "oldteam")); - SetEventBool(hEvent, "disconnect", GetEventBool(event, "disconnect")); - - if (g_CurrentMod == GameType_DOD || g_CurrentMod == GameType_L4D || g_CurrentMod == GameType_TF) - { - new String:sClientName[MAX_NAME_LENGTH + 1]; - GetClientName(client, sClientName, sizeof(sClientName)); - SetEventBool(hEvent, "autoteam", GetEventBool(event, "autoteam")); - SetEventBool(hEvent, "silent", true); - SetEventString(hEvent, "name", sClientName); - FireEvent(hEvent, true); - } - else - { - FireEvent(hEvent, true); - } - return Plugin_Handled; - } - } - return Plugin_Continue; -} - -public Action:UserMessageHook_Class(UserMsg:msg_id, Handle:bf, const players[], playersNum, bool:reliable, bool:init) -{ - new String:sMessage[120]; - BfReadString(bf, sMessage, sizeof(sMessage), true); - if (StrContains(sMessage, "#TF_TeamsSwitched", false) != -1) - { - g_bTeamsSwitched = true; - } - return Plugin_Continue; -} - -public Native_SM_MovePlayer(Handle:plugin, numParams) -{ - - /** - Get and check the client and team - */ - new iClient = GetNativeCell(1); - new iTeam = GetNativeCell(2); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (iTeam != g_aCurrentTeams[Spectator] && iTeam != g_aCurrentTeams[Team1] && iTeam != g_aCurrentTeams[Team2]) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid team %d", iTeam); - } - - MovePlayer(iClient, iTeam); - if (!IsClientObserver(iClient)) - { - RespawnPlayer(iClient); - } - - new fResult; - - Call_StartForward(g_fwdPlayerMoved); - Call_PushCell(plugin); - Call_PushCell(iClient); - Call_PushCell(iTeam); - Call_Finish(fResult); - - if (fResult != SP_ERROR_NONE) - { - return ThrowNativeError(fResult, "Forward failed"); - } - - return fResult; -} - -public Native_SM_SetForcedTeam(Handle:plugin, numParams) -{ - - /** - Get and check the client and team - */ - new iClient = GetNativeCell(1); - new iTeam = GetNativeCell(2); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (iTeam != g_aCurrentTeams[Spectator] && iTeam != g_aCurrentTeams[Team1] && iTeam != g_aCurrentTeams[Team2] && iTeam != g_aCurrentTeams[Unknown]) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid team %d", iTeam); - } - - new bool:bOverRide = GetNativeCell(3) ? true : false; - - if (!bOverRide && g_aPlayers[iClient][hForcedTeamPlugin] != INVALID_HANDLE && plugin != g_aPlayers[iClient][hForcedTeamPlugin]) - { - return false; - } - - g_aPlayers[iClient][hForcedTeamPlugin] = plugin; - g_aPlayers[iClient][iForcedTeam] = iTeam; - return true; -} - -public Native_SM_GetForcedTeam(Handle:plugin, numParams) -{ - - /** - Get and check the client - */ - new iClient = GetNativeCell(1); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - - /** - Get and set the plugin if they want it - */ - new Handle:hPlugin = GetNativeCell(2); - if (hPlugin != INVALID_HANDLE) - { - SetNativeCellRef(2, g_aPlayers[iClient][hForcedTeamPlugin]); - } - - /** - Return the forced team, this could be 0 - */ - return g_aPlayers[iClient][iForcedTeam]; -} - -public Native_SM_ClearForcedTeam(Handle:plugin, numParams) -{ - - /** - Get and check the client and team - */ - new iClient = GetNativeCell(1); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - - g_aPlayers[iClient][hForcedTeamPlugin] = INVALID_HANDLE; - g_aPlayers[iClient][iForcedTeam] = 0; - - return true; -} - -public Native_SM_GetForcedPlayer(Handle:plugin, numParams) -{ - - /** - Get and check the team - */ - new iTeam = GetNativeCell(1); - if (iTeam != g_aCurrentTeams[Spectator] && iTeam != g_aCurrentTeams[Team1] && iTeam != g_aCurrentTeams[Team2]) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid team %d", iTeam); - } - - /** - Start a loop to check for a player on the wrong team - Also make sure the plugin that set the forced team is the plugin that asked - */ - new iPlayer = 0; - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientInGame(i) - && GetClientTeam(i) != g_aPlayers[i][iForcedTeam] - && g_aPlayers[i][iForcedTeam] == iTeam - && g_aPlayers[i][hForcedTeamPlugin] == plugin) - { - iPlayer = i; - break; - } - } - - /** - Return the player we found, this could be 0 - */ - return iPlayer; -} - -public Native_SM_AssignBuddy(Handle:plugin, numParams) -{ - - /** - Get and check the client and player - */ - new iClient = GetNativeCell(1); - new iPlayer = GetNativeCell(2); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (iPlayer < 0 || iPlayer > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid player index (%d)", iPlayer); - } - if (!IsClientConnected(iPlayer)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Player %d is not connected", iPlayer); - } - if (!IsClientInGame(iPlayer)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Player %d is not in the game", iClient); - } - if (IsFakeClient(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Bots are not supported"); - } - - /** - See if we can override his setting - */ - new bool:bOverRide = GetNativeCell(3) ? true : false; - if (!bOverRide) - { - - /** - We can't override, so check if they are locked - */ - if (g_aPlayers[iClient][bBuddyLocked] || g_aPlayers[iPlayer][bBuddyLocked]) - { - - /** - We detected at least 1 lock, so we bug out - */ - return false; - } - } - - /** - Ready to set the buddies - */ - g_aPlayers[iClient][iBuddy] = iPlayer; - g_aPlayers[iPlayer][iBuddy] = iClient; - return true; -} - -public Native_SM_GetClientBuddy(Handle:plugin, numParams) -{ - - /** - Get and check the client - */ - new iClient = GetNativeCell(1); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (IsFakeClient(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Bots are not supported"); - } - - /** - Return the players buddy, this could be 0 - */ - return g_aPlayers[iClient][iBuddy]; -} - -public Native_SM_LockBuddy(Handle:plugin, numParams) -{ - - /** - Get and check the client - */ - new iClient = GetNativeCell(1); - new bool:bSetting = GetNativeCell(2) ? true : false; - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (IsFakeClient(iClient)) - { - return ThrowNativeError(SP_ERROR_NATIVE, "Bots are not supported"); - } - - g_aPlayers[iClient][bBuddyLocked] = bSetting; - return true; -} - -public Native_SM_IsBuddyLocked(Handle:plugin, numParams) -{ - - /** - Get and check the client - */ - new iClient = GetNativeCell(1); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (IsFakeClient(iClient)) - { - return ThrowNativeError(SP_ERROR_NATIVE, "Bots are not supported"); - } - - return g_aPlayers[iClient][bBuddyLocked]; -} - -public Native_SM_ClearBuddy(Handle:plugin, numParams) -{ - - /** - Get and check the client - */ - new iClient = GetNativeCell(1); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_NATIVE, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_NATIVE, "Client (%d) is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (IsFakeClient(iClient)) - { - return ThrowNativeError(SP_ERROR_NATIVE, "Bots are not supported"); - } - - /** - Get the clients buddy and see if we can override his setting - */ - new bool:bOverRide = GetNativeCell(2) ? true : false; - new iPlayer = g_aPlayers[iClient][iBuddy]; - - /** - There is no buddy, we don't care about anything else so bug out - */ - if (iPlayer == 0) - { - return true; - } - - /** - We determined he had a buddy, check the override setting - */ - if (!bOverRide) - { - - /** - We can't override, so check if they are locked - */ - if (g_aPlayers[iClient][bBuddyLocked] || g_aPlayers[iPlayer][bBuddyLocked]) - { - - /** - We detected at least 1 lock, so we bug out - */ - return false; - } - } - - /** - Ready to clear the buddies - */ - g_aPlayers[iClient][iBuddy] = 0; - g_aPlayers[iPlayer][iBuddy] = 0; - return true; -} - -public Native_SM_IsValidTeam(Handle:plugin, numParams) -{ - - /** - Get the team - */ - new iTeam = GetNativeCell(1); - - /** - Check the team - */ - if (iTeam == g_aCurrentTeams[Spectator] || iTeam == g_aCurrentTeams[Team1] || iTeam == g_aCurrentTeams[Team2]) - { - return true; - } - return false; -} - -public Native_SM_IsValidAdmin(Handle:plugin, numParams) -{ - /** - Get the client and flags - */ - new iClient = GetNativeCell(1); - decl String:sFlags[15]; - GetNativeString(2, sFlags, sizeof(sFlags)); - new ibFlags = ReadFlagString(sFlags); - - /** - Check the flags - */ - if ((GetUserFlagBits(iClient) & ibFlags) == ibFlags) - { - return true; - } - if (GetUserFlagBits(iClient) & ADMFLAG_ROOT) - { - return true; - } - return false; -} - -public Action:Timer_ForcePlayerMove(Handle:timer, any:iClient) -{ - - MovePlayer(iClient, g_aPlayers[iClient][iForcedTeam]); - - if (g_aPlayers[iClient][iForcedTeam] != g_aCurrentTeams[Spectator]) - { - RespawnPlayer(iClient); - } - - PrintToChat(iClient, "\x01\x04----------------------------------"); - PrintToChat(iClient, "\x01\x04You have been forced to this team."); - PrintToChat(iClient, "\x01\x04----------------------------------"); - - return Plugin_Handled; -} - -stock MovePlayer(iClient, iTeam) -{ - - /** - Change the client's team based on the mod - */ - switch (g_CurrentMod) - { - case GameType_CSS: - { - CS_SwitchTeam(iClient, iTeam); - } - default: - { - ChangeClientTeam(iClient, iTeam); - } - } -} - -stock RespawnPlayer(iClient) -{ - - /** - Respawn the client based on the mod - */ - switch (g_CurrentMod) - { - case GameType_CSS: - { - CS_RespawnPlayer(iClient); - } - case GameType_TF: - { - TF2_RespawnPlayer(iClient); - } - case GameType_INS: - { - FakeClientCommand(iClient, "kill"); - } - default: - { - // - } - } -} diff --git a/Simple Spectate/addons/sourcemod/scripting/simple-roundimmunity.sp b/Simple Spectate/addons/sourcemod/scripting/simple-roundimmunity.sp deleted file mode 100644 index 5f0bca3..0000000 --- a/Simple Spectate/addons/sourcemod/scripting/simple-roundimmunity.sp +++ /dev/null @@ -1,947 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Round Immunity -Description: - Gives admins immunity during certain rounds -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or any later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#pragma semicolon 1 -#include -#include -#undef REQUIRE_EXTENSIONS -#undef AUTOLOAD_EXTENSIONS -#include -#include -#define REQUIRE_EXTENSIONS -#define AUTOLOAD_EXTENSIONS - -#define PLUGIN_VERSION "1.1.$Rev$" -#define SPECTATOR 1 -#define TEAM_RED 2 -#define TEAM_BLUE 3 - -#define COLOR_GREEN 0 -#define COLOR_BLACK 1 -#define COLOR_RED 2 -#define COLOR_BLUE 3 -#define COLOR_TEAM 4 -#define COLOR_RAINBOW 5 -#define COLOR_NONE 6 - -#define PLAYERCOND_SLOWED (1<<0) //1 -#define PLAYERCOND_ZOOMED (1<<1) //2 -#define PLAYERCOND_DISGUISING (1<<2) //4 -#define PLAYERCOND_DISGUISED (1<<3) //8 -#define PLAYERCOND_SPYCLOAK (1<<4) //16 -#define PLAYERCOND_UBERED (1<<5) //32 -#define PLAYERCOND_TELEPORTTRAIL (1<<6) //64 -#define PLAYERCOND_TAUNT (1<<7) //128 -// (1<<8) //256 -// (1<<9) //512 -#define PLAYERCOND_TELEPORTFLASH (1<<10) //1024 -#define PLAYERCOND_KRUBER (1<<11) //2048 -// (1<<12) //4096 -// (1<<13) //8192 -#define PLAYERCOND_BONKED (1<<14) //16384 (blame Neph if it doesn't work) -#define PLAYERCOND_BONKEDORDRINKSLOWDOWN (1<<15) //32768 -#define PLAYERCOND_HEALING (1<<16) //65536 -#define PLAYERCOND_BURNING (1<<17) //131072 -#define PLAYERCOND_FULLYCHARGEDBYMEDIC (1<<18) //262144 - -enum e_Cookies -{ - bEnabled, - iColor, - iMode -}; - -enum e_ColorNames -{ - Green, - Black, - Red, - Blue -}; - -enum e_ColorValues -{ - iRed, - iGreen, - iBlue -}; - -enum e_PlayerData -{ - Handle:hGodModeTimer, - Handle:hColorTimer, - bool:bIsAdmin, - bool:bIsImmune, - iCycleColor -}; - -/** - Global convar handles - */ -new Handle:sri_charadminflag = INVALID_HANDLE; -new Handle:sri_enabled = INVALID_HANDLE; -new Handle:sri_cookie_enabled = INVALID_HANDLE; -new Handle:sri_cookie_color = INVALID_HANDLE; -new Handle:sri_cookie_mode = INVALID_HANDLE; - -/** - Player arrays - */ -new g_aPlayers[MAXPLAYERS + 1][e_PlayerData]; -new g_aClientCookies[MAXPLAYERS + 1][e_Cookies]; - -/** - Global bools - */ -new bool:g_bLoadedLate = false; -new bool:g_bIsEnabled = true; -new bool:g_bRoundEnd = false; -new bool:g_bUseDukehacks = false; -new bool:g_bUseClientprefs = false; - -/** - Global strings/integers/floats - */ -new String:g_sCharAdminFlag[32]; -new g_iColors[e_ColorNames][e_ColorValues]; -new g_iClassMaxHealth[TFClassType] = {0, 125, 125, 200, 175, 150, 300, 175, 125, 125}; - -public Plugin:myinfo = -{ - name = "Simple Round Immunity", - author = "Simple Plugins", - description = "Gives admins immunity during certain rounds", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -} - -bool:AskPluginLoad(Handle:myself, bool:late, String:error[], err_max) -{ - g_bLoadedLate = late; - return true; -} - -public OnPluginStart() -{ - - /** - Create console variables - */ - CreateConVar("sri_version", PLUGIN_VERSION, "Simple Round Immunity", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - sri_enabled = CreateConVar("sri_enabled", "1", "Enable/Disable Admin immunity during certain round."); - sri_charadminflag = CreateConVar("sri_charadminflag", "a", "Admin flag to use for immunity (only one). Must be a in char format."); - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook some events and check extensions - */ - decl String:sExtError[256]; - LogAction(0, -1, "[SRI] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_spawn", HookPlayerSpawn, EventHookMode_Post); - HookEvent("player_hurt", HookPlayerHurt, EventHookMode_Pre); - switch (g_CurrentMod) - { - case GameType_CSS: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - new iExtStatus = GetExtensionFileStatus("game.cstrike.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SRI] Required extension was not found."); - LogAction(0, -1, "[SRI] Plugin FAILED TO LOAD."); - SetFailState("Required extension was not found."); - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SRI] Required extension is loaded with errors."); - LogAction(0, -1, "[SRI] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SRI] Plugin FAILED TO LOAD."); - SetFailState("Required extension is loaded with errors."); - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SRI] Required css extension is loaded."); - } - } - case GameType_TF: - { - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_PostNoCopy); - HookUserMessage(GetUserMessageId("TextMsg"), UserMessageHook_Class, true); - new iExtStatus = GetExtensionFileStatus("game.tf2.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SRI] Required extension was not found."); - LogAction(0, -1, "[SRI] Plugin FAILED TO LOAD."); - SetFailState("Required extension was not found."); - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SRI] Required extension is loaded with errors."); - LogAction(0, -1, "[SRI] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SRI] Plugin FAILED TO LOAD."); - SetFailState("Required extension is loaded with errors."); - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SRI] Required tf2 extension is loaded."); - } - iExtStatus = GetExtensionFileStatus("dukehacks.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SRI] Dukehacks extension was not found."); - LogAction(0, -1, "[SRI] Plugin continued to load, but that feature will not be used."); - g_bUseDukehacks = false; - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SRI] Dukehacks extension is loaded with errors."); - LogAction(0, -1, "[SRI] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SRI] Plugin continued to load, but that feature will not be used."); - g_bUseDukehacks = false; - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SRI] Dukehacks extension is loaded and will be used."); - g_bUseDukehacks = true; - dhAddClientHook(CHK_TakeDamage, Hacks_TakeDamageHook); - } - } - case GameType_DOD: - { - HookEvent("dod_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_PostNoCopy); - } - default: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - } - } - /** - Now lets check for client prefs extension - */ - new iExtStatus = GetExtensionFileStatus("clientprefs.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SRI] Client Preferences extension was not found."); - LogAction(0, -1, "[SRI] Plugin continued to load, but that feature will not be used."); - g_bUseClientprefs = false; - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SRI] Client Preferences extension is loaded with errors."); - LogAction(0, -1, "[SRI] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SRI] Plugin continued to load, but that feature will not be used."); - g_bUseClientprefs = false; - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SRI] Client Preferences extension is loaded, checking database."); - if (!SQL_CheckConfig(clientprefs)) - { - LogAction(0, -1, "[SRI] No 'clientprefs' database found. Check your database.cfg file."); - LogAction(0, -1, "[SRI] Plugin continued to load, but Client Preferences will not be used."); - g_bUseClientprefs = false; - } - g_bUseClientprefs = true; - - /** - Deal with client cookies - */ - sri_cookie_enabled = RegClientCookie("bri_client_enabled", "Enable/Disable your immunity during the bonus round.", CookieAccess_Public); - sri_cookie_color = RegClientCookie("bri_client_color", "Color to render when immune.", CookieAccess_Public); - sri_cookie_mode = RegClientCookie("bri_client_mode", "God mode to select", CookieAccess_Public); - SetCookieMenuItem(CookieMenu_TopMenu, sri_cookie_enabled, "Bonus Round Immunity"); - } - - HookConVarChange(sri_enabled, EnabledChanged); - - RegAdminCmd("sm_immunity", Command_Immunity, ADMFLAG_ROOT, "sm_immunity: Gives you immunity"); - - LoadColors(); - - AutoExecConfig(true, "plugin.simpleroundimmunity"); -} - -public OnAllPluginsLoaded() -{ - //something - // need to deal with the unloading of dukehacks, clientprefs, and simpleplugins - // should move hooking the client prefs cookies to a function to make sure they are done post plugin start if ext is loaded late -} - -public OnLibraryRemoved(const String:name[]) -{ - //something - // need to deal with the loading of dukehacks, clientprefs, and simpleplugins -} - -public OnConfigsExecuted() -{ - GetConVarString(sri_charadminflag, g_sCharAdminFlag, sizeof(g_sCharAdminFlag)); - g_bIsEnabled = GetConVarBool(sri_enabled); - g_bRoundEnd = false; -} - -/** - Client events - */ - -public OnClientPostAdminCheck(client) -{ - if (SM_IsValidAdmin(client, g_sCharAdminFlag)) - g_aPlayers[client][bIsAdmin] = true; - else - g_aPlayers[client][bIsAdmin] = false; -} - -public OnClientCookiesCached(client) -{ - decl String:sEnabled[2], String:sColor[4], String:sMode[2]; - GetClientCookie(client, sri_cookie_enabled, sEnabled, sizeof(sEnabled)); - GetClientCookie(client, sri_cookie_color, sColor, sizeof(sColor)); - GetClientCookie(client, sri_cookie_mode, sMode, sizeof(sMode)); - g_aClientCookies[client][bEnabled] = StringToInt(sEnabled); - g_aClientCookies[client][iColor] = StringToInt(sColor); - g_aClientCookies[client][iMode] = StringToInt(sMode); -} - -public OnClientDisconnect(client) -{ - CleanUp(client); -} - -/** - Commands - */ - -public Action:Command_Immunity(client, args) -{ - if (g_aPlayers[client][IsImmune]) - { - DisableImmunity(client); - } - else - { - EnableImmunity(client); - } - return Plugin_Handled; -} - -/** - Event hooks - */ - -public Action:Hacks_TakeDamageHook(client, attacker, inflictor, Float:damage, &Float:multiplier, damagetype) -{ - if (attacker == 0 || attacker >= MaxClients) - { - return Plugin_Continue; - } - if (g_aPlayers[client][IsImmune]) - { - new TFClassType:PlayerClass = TF2_GetPlayerClass(attacker); - if (PlayerClass == TFClass_Spy) - { - multiplier *= 0.0; - return Plugin_Changed; - } - } - return Plugin_Continue; -} - -public HookRoundStart(Handle:event, const String:name[], bool:dontBroadcast) -{ - g_bRoundEnd = false; - if (g_bIsEnabled) - { - for (new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][IsImmune]) - { - DisableImmunity(i); - } - } - } -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - g_bRoundEnd = true; - if (g_bIsEnabled) - { - for (new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][bIsAdmin]) - { - EnableImmunity(i); - } - } - } -} - -public HookPlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast) -{ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - if (g_bIsEnabled && g_aPlayers[iClient][bIsAdmin] && g_bRoundEnd) - { - EnableImmunity(iClient); - } -} - -public Action:HookPlayerHurt(Handle:event, const String:name[], bool:dontBroadcast) -{ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - if (g_aPlayers[iClient][IsImmune]) - { - SetEntityHealth(iClient, 2000); - return Plugin_Continue; - } - return Plugin_Continue; -} - -/** - Cookie menus - */ - -public CookieMenu_TopMenu(client, CookieMenuAction:action, any:info, String:buffer[], maxlen) -{ - if (action == CookieMenuAction_DisplayOption) - { - //don't think we need to do anything - } - else - { - new Handle:hMenu = CreateMenu(Menu_CookieSettings); - SetMenuTitle(hMenu, "Options (Current Setting)"); - if (g_aClientCookies[client][bEnabled]) - { - AddMenuItem(hMenu, "enable", "Enabled/Disable (Enabled)"); - } - else - { - AddMenuItem(hMenu, "enable", "Enabled/Disable (Disabled)"); - } - if (g_aClientCookies[client][iMode]) - { - AddMenuItem(hMenu, "mode", "Immunity Mode Setting (God Mode)"); - } - else - { - AddMenuItem(hMenu, "mode", "Immunity Mode Setting (Health)"); - } - switch (g_aClientCookies[client][iColor]) - { - case COLOR_GREEN: - { - AddMenuItem(hMenu, "color", "Color (Green)"); - } - case COLOR_BLACK: - { - AddMenuItem(hMenu, "color", "Color (Black)"); - } - case COLOR_RED: - { - AddMenuItem(hMenu, "color", "Color (Red)"); - } - case COLOR_BLUE: - { - AddMenuItem(hMenu, "color", "Color (Blue)"); - } - case COLOR_TEAM: - { - AddMenuItem(hMenu, "color", "Color (Team)"); - } - case COLOR_RAINBOW: - { - AddMenuItem(hMenu, "color", "Color (Rainbow)"); - } - case COLOR_NONE: - { - AddMenuItem(hMenu, "color", "Color (None)"); - } - } - SetMenuExitBackButton(hMenu, true); - DisplayMenu(hMenu, client, MENU_TIME_FOREVER); - } -} - -public Menu_CookieSettings(Handle:menu, MenuAction:action, param1, param2) -{ - new client = param1; - if (action == MenuAction_Select) - { - new String:sSelection[24]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "enable", false)) - { - new Handle:hMenu = CreateMenu(Menu_CookieSettingsEnable); - SetMenuTitle(hMenu, "Enable/Disable Round End Immunity"); - - if (g_aClientCookies[client][bEnabled]) - { - AddMenuItem(hMenu, "enable", "Enable (Set)"); - AddMenuItem(hMenu, "disable", "Disable"); - } - else - { - AddMenuItem(hMenu, "enable", "Enabled"); - AddMenuItem(hMenu, "disable", "Disable (Set)"); - } - - SetMenuExitBackButton(hMenu, true); - DisplayMenu(hMenu, client, MENU_TIME_FOREVER); - } - else if (StrEqual(sSelection, "mode", false)) - { - new Handle:hMenu = CreateMenu(Menu_CookieSettingsMode); - SetMenuTitle(hMenu, "Set Immunity Mode"); - - if (g_aClientCookies[client][iMode]) - { - AddMenuItem(hMenu, "god", "God Mode (Set)"); - AddMenuItem(hMenu, "health", "Health"); - } - else - { - AddMenuItem(hMenu, "god", "God Mode"); - AddMenuItem(hMenu, "health", "Health (Set)"); - } - - SetMenuExitBackButton(hMenu, true); - DisplayMenu(hMenu, client, MENU_TIME_FOREVER); - } - else - { - new Handle:hMenu = CreateMenu(Menu_CookieSettingsColors); - SetMenuTitle(hMenu, "Select Immunity Color"); - switch (g_aClientCookies[client][iColor]) - { - case COLOR_GREEN: - { - AddMenuItem(hMenu, "Green", "Green (Set)"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_BLACK: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black (Set)"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_RED: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red (Set)"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_BLUE: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue (Set)"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_TEAM: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color (Set)"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_RAINBOW: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow (Set)"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_NONE: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None (Set)"); - } - } - SetMenuExitBackButton(hMenu, true); - DisplayMenu(hMenu, client, MENU_TIME_FOREVER); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - ShowCookieMenu(client); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } -} - -public Menu_CookieSettingsEnable(Handle:menu, MenuAction:action, param1, param2) -{ - new client = param1; - if (action == MenuAction_Select) - { - new String:sSelection[24]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "enable", false)) - { - SetClientCookie(client, sri_cookie_enabled, "1"); - g_aClientCookies[client][bEnabled] = 1; - PrintToChat(client, "[SM] Bonus Round Immunity is ENABLED"); - } - else - { - SetClientCookie(client, sri_cookie_enabled, "0"); - g_aClientCookies[client][bEnabled] = 0; - PrintToChat(client, "[SM] Bonus Round Immunity is DISABLED"); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - ShowCookieMenu(client); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } -} - -public Menu_CookieSettingsColors(Handle:menu, MenuAction:action, param1, param2) -{ - new client = param1; - if (action == MenuAction_Select) - { - new String:sSelection[24]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "Green", false)) - { - SetClientCookie(client, sri_cookie_color, "0"); - g_aClientCookies[client][iColor] = COLOR_GREEN; - PrintToChat(client, "[SM] Bonus Round Immunity color set to GREEN"); - } - else if (StrEqual(sSelection, "Black", false)) - { - SetClientCookie(client, sri_cookie_color, "1"); - g_aClientCookies[client][iColor] = COLOR_BLACK; - PrintToChat(client, "[SM] Bonus Round Immunity color set to BLACK"); - } - else if (StrEqual(sSelection, "Red", false)) - { - SetClientCookie(client, sri_cookie_color, "2"); - g_aClientCookies[client][iColor] = COLOR_RED; - PrintToChat(client, "[SM] Bonus Round Immunity color set to RED"); - } - else if (StrEqual(sSelection, "Blue", false)) - { - SetClientCookie(client, sri_cookie_color, "3"); - g_aClientCookies[client][iColor] = COLOR_BLUE; - PrintToChat(client, "[SM] Bonus Round Immunity color set to BLUE"); - } - else if (StrEqual(sSelection, "Team", false)) - { - SetClientCookie(client, sri_cookie_color, "4"); - g_aClientCookies[client][iColor] = COLOR_TEAM; - PrintToChat(client, "[SM] Bonus Round Immunity color set to TEAM COLOR"); - } - else if (StrEqual(sSelection, "Rain", false)) - { - SetClientCookie(client, sri_cookie_color, "5"); - g_aClientCookies[client][iColor] = COLOR_RAINBOW; - PrintToChat(client, "[SM] Bonus Round Immunity color set to RAINBOW"); - } - else if (StrEqual(sSelection, "None", false)) - { - SetClientCookie(client, sri_cookie_color, "6"); - g_aClientCookies[client][iColor] = COLOR_NONE; - PrintToChat(client, "[SM] Bonus Round Immunity color set to NONE"); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - ShowCookieMenu(client); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } -} - -public Menu_CookieSettingsMode(Handle:menu, MenuAction:action, param1, param2) -{ - new client = param1; - if (action == MenuAction_Select) - { - new String:sSelection[24]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "god", false)) - { - SetClientCookie(client, sri_cookie_mode, "1"); - g_aClientCookies[client][iMode] = 1; - PrintToChat(client, "[SM] Bonus Round Immunity set to GOD MODE"); - } - else - { - SetClientCookie(client, sri_cookie_mode, "0"); - g_aClientCookies[client][iMode] = 0; - PrintToChat(client, "[SM] Bonus Round Immunity set to HEALTH BONUS"); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - ShowCookieMenu(client); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } -} - -/** -Timer functions - */ - -public Action:Timer_ChangeColor(Handle:timer, any:client) -{ - if (g_aPlayers[client][CycleColor]++ == 3) - { - g_aPlayers[client][CycleColor] = 0; - } - SetEntityRenderMode(client, RENDER_TRANSCOLOR); - SetEntityRenderColor(client, g_iColors[g_aPlayers[client][CycleColor]][iRed], g_iColors[g_aPlayers[client][CycleColor]][iGreen], g_iColors[g_aPlayers[client][CycleColor]][iBlue], 255); - return Plugin_Continue; -} - -public Action:Timer_UndoGodMode(Handle:timer, any:client) -{ - if (IsClientInGame(client)) - { - SetEntProp(client, Prop_Data, "m_takedamage", 2, 1); - } - g_aPlayers[iClient][hGodModeTimer] = INVALID_HANDLE; - return Plugin_Handled; -} - -/** -Stock functions . - */ - -stock CleanUp(iClient) -{ - g_aPlayers[iClient][bIsAdmin] = false; - DisableImmunity(iClient); -} - -stock EnableImmunity(iClient) -{ - SetEntityRenderMode(iClient, RENDER_TRANSCOLOR); - switch (g_aClientCookies[iClient][iColor]) - { - case COLOR_TEAM: - { - new iTeam = GetClientTeam(iClient); - SetEntityRenderColor(iClient, g_iColors[e_ColorNames:iTeam][iRed], g_iColors[e_ColorNames:iTeam][iGreen], g_iColors[e_ColorNames:iTeam][iBlue], 255); - } - case COLOR_RAINBOW: - { - if (g_aPlayers[iClient][hColorTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[iClient][hColorTimer]); - g_aPlayers[iClient][hColorTimer] = INVALID_HANDLE; - } - g_aPlayers[iClient][hColorTimer] = CreateTimer(0.2, Timer_ChangeColor, iClient, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); - } - case COLOR_NONE: - { - //We dont have to set a color - } - default: - { - SetEntityRenderColor(iClient, g_iColors[e_ColorNames:g_aClientCookies[iClient][iColor]][iRed], g_iColors[e_ColorNames:g_aClientCookies[iClient][iColor]][iGreen], g_iColors[e_ColorNames:g_aClientCookies[iClient][iColor]][iBlue], 255); - } - } - SetEntityHealth(iClient, 2000); - SetEntProp(iClient, Prop_Data, "m_takedamage", 0, 1); - g_aPlayers[iClient][hGodModeTimer] = CreateTimer(2.0, Timer_UndoGodMode, iClient); - g_aPlayers[iClient][IsImmune] = true; -} - -stock DisableImmunity(iClient) -{ - if (g_aPlayers[iClient][hGodModeTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[iClient][hGodModeTimer]); - g_aPlayers[iClient][hGodModeTimer] = INVALID_HANDLE; - } - if (g_aPlayers[iClient][hColorTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[iClient][hColorTimer]); - g_aPlayers[iClient][hColorTimer] = INVALID_HANDLE; - } - if (IsClientInGame(iClient)) - { - SetEntityRenderMode(iClient, RENDER_TRANSCOLOR); - SetEntityRenderColor(iClient, 255, 255, 255, 255); - new TFClassType:PlayerClass = TF2_GetPlayerClass(iClient); - new iMaxHealth = g_iClassMaxHealth[PlayerClass]; - SetEntityHealth(iClient, iMaxHealth); - } - g_aPlayers[iClient][CycleColor] = 0; - g_aPlayers[iClient][IsImmune] = false; -} - -stock LoadColors() -{ - g_iColors[Green][iRed] = 0; - g_iColors[Green][iGreen] = 255; - g_iColors[Green][iBlue] = 0; - - g_iColors[Black][iRed] = 10; - g_iColors[Black][iGreen] = 10; - g_iColors[Black][iBlue] = 0; - - g_iColors[Red][iRed] = 255; - g_iColors[Red][iGreen] = 0; - g_iColors[Red][iBlue] = 0; - - g_iColors[Blue][iRed] = 0; - g_iColors[Blue][iGreen] = 0; - g_iColors[Blue][iBlue] = 255; -} - -stock TF2_AddCond(client, cond) -{ - new Handle:cvar = FindConVar("sv_cheats"), bool:enabled = GetConVarBool(cvar), flags = GetConVarFlags(cvar); - if(!enabled) - { - SetConVarFlags(cvar, flags^FCVAR_NOTIFY); - SetConVarBool(cvar, true); - } - FakeClientCommand(client, "addcond %i", cond); - if(!enabled) - { - SetConVarBool(cvar, false); - SetConVarFlags(cvar, flags); - } -} - -stock TF2_RemoveCond(client, cond) -{ - new Handle:cvar = FindConVar("sv_cheats"), bool:enabled = GetConVarBool(cvar), flags = GetConVarFlags(cvar); - if(!enabled) - { - SetConVarFlags(cvar, flags^FCVAR_NOTIFY); - SetConVarBool(cvar, true); - } - FakeClientCommand(client, "removecond %i", cond); - if(!enabled) - { - SetConVarBool(cvar, false); - SetConVarFlags(cvar, flags); - } -} - -/** -Enabled hook - */ - -public EnabledChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (StringToInt(newValue) == 0) - { - UnhookEvent("player_spawn", HookPlayerSpawn, EventHookMode_Post); - UnhookEvent("teamplay_round_start", HookRoundStart, EventHookMode_Post); - UnhookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - for (new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][bIsAdmin] && g_aPlayers[i][IsImmune]) - { - DisableImmunity(i); - } - } - g_bIsEnabled = false; - } - else - { - HookEvent("player_spawn", HookPlayerSpawn, EventHookMode_Post); - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_Post); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - g_bIsEnabled = true; - } -} diff --git a/Simple Spectate/addons/sourcemod/scripting/simple-spectate.sp b/Simple Spectate/addons/sourcemod/scripting/simple-spectate.sp index 4108f8f..4513b6a 100644 --- a/Simple Spectate/addons/sourcemod/scripting/simple-spectate.sp +++ b/Simple Spectate/addons/sourcemod/scripting/simple-spectate.sp @@ -524,7 +524,7 @@ public Action:HookPlayerChangeTeam(Handle:event, const String:name[], bool:dontB if (g_CurrentMod == GameType_DOD || g_CurrentMod == GameType_L4D || g_CurrentMod == GameType_TF) { new String:sClientName[MAX_NAME_LENGTH + 1]; - GetClientName(client, sClientName, sizeof(sClientName)); + GetClientName(iClient, sClientName, sizeof(sClientName)); SetEventBool(hEvent, "autoteam", GetEventBool(event, "autoteam")); SetEventBool(hEvent, "silent", true); SetEventString(hEvent, "name", sClientName); diff --git a/Simple Spectate/addons/sourcemod/scripting/simple-teambalancer.sp b/Simple Spectate/addons/sourcemod/scripting/simple-teambalancer.sp deleted file mode 100644 index 3302255..0000000 --- a/Simple Spectate/addons/sourcemod/scripting/simple-teambalancer.sp +++ /dev/null @@ -1,1797 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Team Balancer -Description: - Balances teams based upon player count - Player will not be balanced more than once in 5 (default) mins - Buddy system tries to keep buddies together - Ability to prioritize players - Ability to force players to accept the new team - Admins are immune -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include -#include - -#define PLUGIN_VERSION "2.1.$Rev$" - -enum PlayerData -{ - Handle:hBalanceTimer, - Handle:hForcedTimer, - bool:bSwitched, - bool:bFlagCarrier -}; - -/** - Global convar handles - */ -new Handle:stb_enabled = INVALID_HANDLE; -new Handle:stb_buddyenabled = INVALID_HANDLE; -new Handle:stb_logactivity = INVALID_HANDLE; -new Handle:stb_logactivity2 = INVALID_HANDLE; -new Handle:stb_unbalancelimit = INVALID_HANDLE; -new Handle:stb_deadonly = INVALID_HANDLE; -new Handle:stb_priorityenabled = INVALID_HANDLE; -new Handle:stb_uberlevel = INVALID_HANDLE; -new Handle:stb_balancedelay = INVALID_HANDLE; -new Handle:stb_livingplayerswitchdelay = INVALID_HANDLE; -new Handle:stb_livingplayercheckdelay = INVALID_HANDLE; -new Handle:stb_roundstartdelay = INVALID_HANDLE; -new Handle:stb_switchbackforced = INVALID_HANDLE; -new Handle:stb_adminflag = INVALID_HANDLE; -new Handle:stb_buddyrestriction = INVALID_HANDLE; -new Handle:stb_convarcontrol = INVALID_HANDLE; - -/** - Built-in cvars handles - */ -new Handle:stb_mp_autoteambalance = INVALID_HANDLE; -new Handle:stb_mp_teams_unbalance_limit = INVALID_HANDLE; -new Handle:TFGameModeArena = INVALID_HANDLE; - -/** - Timer handles - */ -new Handle:g_hBalanceTimer = INVALID_HANDLE; -new Handle:g_hLivingPlayerCheckTimer = INVALID_HANDLE; - -/** - Player arrays - */ -new g_aPlayers[MAXPLAYERS + 1][PlayerData]; - -/** -Global bools -*/ -new bool:g_bIsEnabled = true; -new bool:g_bPriorityPlayers = true; -new bool:g_bBuddyRestriction = false; -new bool:g_bLogActivity = false; -new bool:g_bLogActivity2 = false; -new bool:g_bDeadOnly = false; -new bool:g_bConVarControl = true; -new bool:g_bBuddyEnabled = true; -new bool:g_bBalanceInProgress = false; -new bool:g_bRoundStart = false; -new bool:g_bRoundEnd = false; -new bool:g_bSuddenDeath = false; -new bool:g_bIsArenaMode = false; - -/** - Global strings/integers/floats - */ -new g_iUnbalanceLimit, g_iLivingPlayerSwitchDelay, g_iLivingPlayerCheckDelay; -new g_iRoundStartDelay, g_iSwitchBackForced, g_iBalanceDelay; -new Float:g_fUberLevel; -new g_iOwnerOffset; -new String:g_sAdminFlag[5]; - -public Plugin:myinfo = -{ - name = "Simple Team Balancer", - author = "Simple Plugins", - description = "Balances teams based upon player count.", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -} - -public OnPluginStart() -{ - - /** - Create console variables - */ - CreateConVar("stb_version", PLUGIN_VERSION, "Simple Team Balancer", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - stb_enabled = CreateConVar("stb_enabled", "1", "Enable or Disable Simple Team Balancer", _, true, 0.0, true, 1.0); - stb_priorityenabled = CreateConVar("stb_priorityenabled", "1", "Enable or Disable the prioritization of living players", _, true, 0.0, true, 1.0); - stb_buddyrestriction = CreateConVar("stb_buddyrestriction", "0", "Enable or Disable Admin Only buddy lists", _, true, 0.0, true, 1.0); - stb_logactivity = CreateConVar("stb_logactivity", "0", "Enable or Disable the disaplying of events in the log", _, true, 0.0, true, 1.0); - stb_logactivity2 = CreateConVar("stb_logactivity2", "0", "Enable or Disable the disaplying of detailed events in the log (WILL SPAM LOG)", _, true, 0.0, true, 1.0); - stb_deadonly = CreateConVar("stb_deadonly", "0", "Enable or Disable the switching of only dead players", _, true, 0.0, true, 1.0); - stb_convarcontrol = CreateConVar("stb_convarcontrol", "1", "Enable or Disable the control of builtin console variables", _, true, 0.0, true, 1.0); - stb_buddyenabled = CreateConVar("stb_buddyenabled", "1", "Enable or Disable the buddy system", _, true, 0.0, true, 1.0); - stb_unbalancelimit = CreateConVar("stb_unbalancelimit", "2", "Amount of players teams are ALLOWED to be unbalanced by", _, true, 1.0, true, 32.0); - stb_balancedelay = CreateConVar("stb_balancedelay", "10", "Delay in seconds to start an autobalance"); - stb_livingplayerswitchdelay = CreateConVar("stb_livingplayerswitchdelay", "20", "Delay in seconds to switch living players once selected"); - stb_livingplayercheckdelay = CreateConVar("stb_livingplayercheckdelay", "10", "Delay in seconds to start checking living players once teams become unbalanced"); - stb_roundstartdelay = CreateConVar("stb_roundstartdelay", "15", "Delay in seconds to start balancing teams after the start of a round"); - stb_switchbackforced = CreateConVar("stb_switchbackforced", "300", "Amount of time in seconds to not switch a player twice and force the team if enabled"); - stb_uberlevel = CreateConVar("stb_uberlevel", "1.0", "Min uber level medic must have to have priority over other living players. Setting to 0 will rarely switch a living medic", _, true, 0.0, true, 1.0); - stb_adminflag = CreateConVar("stb_adminflag", "a", "Admin flag to use for immunity. Must be a in char format."); - stb_mp_autoteambalance = FindConVar("mp_autoteambalance"); - stb_mp_teams_unbalance_limit = FindConVar("mp_teams_unbalance_limit"); - - /** - Removing the notify tags from the built in cvars. We dont want spam. - */ - if (stb_mp_autoteambalance != INVALID_HANDLE) - { - SetConVarFlags(stb_mp_autoteambalance, GetConVarFlags(stb_mp_autoteambalance)^FCVAR_NOTIFY); - } - if (stb_mp_teams_unbalance_limit != INVALID_HANDLE) - { - SetConVarFlags(stb_mp_teams_unbalance_limit, GetConVarFlags(stb_mp_teams_unbalance_limit)^FCVAR_NOTIFY); - } - - /** - Hook console variables - */ - HookConVarChange(stb_enabled, ConVarSettingsChanged); - HookConVarChange(stb_priorityenabled, ConVarSettingsChanged); - HookConVarChange(stb_buddyrestriction, ConVarSettingsChanged); - HookConVarChange(stb_logactivity, ConVarSettingsChanged); - HookConVarChange(stb_logactivity2, ConVarSettingsChanged); - HookConVarChange(stb_deadonly, ConVarSettingsChanged); - HookConVarChange(stb_convarcontrol, ConVarSettingsChanged); - HookConVarChange(stb_buddyenabled, ConVarSettingsChanged); - HookConVarChange(stb_unbalancelimit, ConVarSettingsChanged); - HookConVarChange(stb_balancedelay, ConVarSettingsChanged); - HookConVarChange(stb_livingplayerswitchdelay, ConVarSettingsChanged); - HookConVarChange(stb_livingplayercheckdelay, ConVarSettingsChanged); - HookConVarChange(stb_roundstartdelay, ConVarSettingsChanged); - HookConVarChange(stb_switchbackforced, ConVarSettingsChanged); - HookConVarChange(stb_uberlevel, ConVarSettingsChanged); - HookConVarChange(stb_mp_autoteambalance, ConVarSettingsChanged); - HookConVarChange(stb_mp_teams_unbalance_limit, ConVarSettingsChanged); - - /** - Create console commands - */ - RegConsoleCmd("sm_buddy", Command_AddBalanceBuddy, "Add a balance buddy"); - RegConsoleCmd("sm_lockbuddy", Command_LockBuddy, "Locks your balance buddy selection"); - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook the game events - */ - LogAction(0, -1, "[STB] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_death", HookPlayerDeath, EventHookMode_Post); - HookEvent("player_team", HookPlayerChangeTeam, EventHookMode_Post); - switch (g_CurrentMod) - { - case GameType_TF: - { - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - HookEvent("teamplay_suddendeath_begin", HookSuddenDeathBegin, EventHookMode_PostNoCopy); - HookEvent("teamplay_flag_event", HookFlagEvent, EventHookMode_Post); - TFGameModeArena = FindConVar("tf_gamemode_arena"); - g_iOwnerOffset = FindSendPropInfo("CBaseObject", "m_hBuilder"); - } - case GameType_DOD: - { - HookEvent("dod_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_Post); - } - default: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - } - } - - /** - Load translations and .cfg file - */ - LoadTranslations ("simpleteambalancer.phrases"); - AutoExecConfig(true, "plugin.simpleteambalancer"); - LogAction(0, -1, "[STB] Simple Team Balancer is loaded."); -} - -public OnAllPluginsLoaded() -{ - //something -} - -public OnLibraryRemoved(const String:name[]) -{ - //something -} - -public OnConfigsExecuted() -{ - - /** - Load up global variables - */ - g_bIsEnabled = GetConVarBool(stb_enabled); - g_bBuddyEnabled = GetConVarBool(stb_buddyenabled); - g_bLogActivity = GetConVarBool(stb_logactivity); - g_bLogActivity2 = GetConVarBool(stb_logactivity2); - g_bDeadOnly = GetConVarBool(stb_deadonly); - g_bPriorityPlayers = GetConVarBool(stb_priorityenabled); - g_bBuddyRestriction = GetConVarBool(stb_buddyrestriction); - g_bConVarControl = GetConVarBool(stb_convarcontrol); - g_fUberLevel = GetConVarFloat(stb_uberlevel); - g_iUnbalanceLimit = GetConVarInt(stb_unbalancelimit); - g_iBalanceDelay = GetConVarInt(stb_balancedelay); - g_iLivingPlayerSwitchDelay = GetConVarInt(stb_livingplayerswitchdelay); - g_iLivingPlayerCheckDelay = GetConVarInt(stb_livingplayercheckdelay); - g_iRoundStartDelay = GetConVarInt(stb_roundstartdelay); - g_iSwitchBackForced = GetConVarInt(stb_switchbackforced); - GetConVarString(stb_adminflag, g_sAdminFlag, sizeof(g_sAdminFlag)); - - /** - Report enabled - */ - if (g_bIsEnabled) - { - LogAction(0, -1, "[STB] Simple Team Balancer is ENABLED."); - } - else - { - LogAction(0, -1, "[STB] Simple Team Balancer is DISABLED."); - } - - - /** - Report log activity - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Log Activity ENABLED."); - } - else - { - LogAction(0, -1, "[STB] Log Activity DISABLED."); - } - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Detailed Log Activity ENABLED."); - } - else - { - LogAction(0, -1, "[STB] Detailed Log Activity DISABLED."); - } -} - -public OnMapStart() -{ - - /** - Check for arena mode - */ - if (g_CurrentMod == GameType_TF && GetConVarBool(TFGameModeArena)) - { - g_bIsArenaMode = true; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Simple Team Balancer detected arena mode and will be bypassed"); - } - } - else - { - g_bIsArenaMode = false; - } - - /** - Reset the globals - */ - g_bBalanceInProgress = false; - g_bRoundStart = false; - g_bRoundEnd = false; - g_bSuddenDeath = false; - - /** - Set the built-in convars - */ - SetGameCvars(); -} - -public OnClientPostAdminCheck(client) -{ - - /** - Make sure its a valid connected client and buddy system is enabled - */ - if (client == 0 || !g_bIsEnabled || !IsClientConnected(client) || !g_bBuddyEnabled) - { - return; - } - - /** - Make sure if its set for admins only they have the flags - */ - if (g_bBuddyRestriction && !SM_IsValidAdmin(client, g_sAdminFlag)) - { - return; - } - - /** - Start the advertisement timer - */ - CreateTimer (60.0, Timer_WelcomeAdvert, client); -} - -public OnClientDisconnect(client) -{ - - /** - Call stock function to cleaup - */ - CleanUp(client); -} - -public OnClientDisconnect_Post(client) -{ - - /** - Determine if we need a balance - */ - if (OkToBalance() && IsUnbalanced() && !g_bBalanceInProgress) - { - - /** - No balance in progress but balance is needed - */ - StartABalance(); - } -} - -public SM_OnPlayerMoved(Handle:plugin, client, team) -{ - - /** - Make sure we called the move function - */ - if (plugin != GetMyHandle()) - { - if (g_bLogActivity2) - { - LogAction(0, client, "[STB] Callback was not started with current plugin, bugging out."); - } - return; - } - - /** - Get the players name and report the event - */ - decl String:sPlayerName[64]; - GetClientName(client, sPlayerName, sizeof(sPlayerName)); - if (g_bLogActivity) - { - LogAction(0, client, "[STB] Changed %s to team %i.", sPlayerName, team); - } - - /** - If we are in TF2 fire the bult-in team balance event - */ - if(g_CurrentMod == GameType_TF) - { - new Handle:event = CreateEvent("teamplay_teambalanced_player"); - SetEventInt(event, "player", client); - SetEventInt(event, "team", team); - FireEvent(event); - } - - /** - Notify the players - */ - PrintToChatAll("[SM] %T", "BalanceMessage", LANG_SERVER, sPlayerName); - - /** - Set the players variables and start a timer - */ - g_aPlayers[client][bSwitched] = true; - g_aPlayers[client][hForcedTimer] = CreateTimer(float(g_iSwitchBackForced), Timer_ForcedExpired, client, TIMER_FLAG_NO_MAPCHANGE); - - /** - We are done, log the completion and end the balance - */ - if (g_bLogActivity) - { - LogAction(0, client, "[STB] Balance finished."); - } - g_bBalanceInProgress = false; -} - -/* HOOKED EVENTS */ - -public HookPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get our event variables - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - decl String:sWeapon[64]; - GetEventString(event, "weapon", sWeapon, sizeof(sWeapon)); - - /** - Return if death was not caused by a player - This is the case when the player switches teams - */ - if (StrEqual(sWeapon, "world", false)) - { - return; - } - - - /** - Check if balance is needed - */ - if (IsClientInGame(iClient) && OkToBalance() && IsUnbalanced()) - { - new iSmallerTeam = GetSmallerTeam(); - - /** - Check if balance is in progress - */ - if (g_bBalanceInProgress) - { - - /** - There is a balance in progress - Check the player who died to see if he is supposed to be switched - */ - if (g_aPlayers[iClient][hBalanceTimer] != INVALID_HANDLE) - { - - /** - The player has a timer on him to switch him to other team - Stop the timer - */ - CloseHandle(g_aPlayers[iClient][hBalanceTimer]); - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - if (g_bLogActivity) - { - LogAction(0, iClient, "[STB] With a balance in progress the queued living player died and was switched."); - } - - /** - Call the stock change team function - */ - BalancePlayer(iClient, SM_GetForcedTeam(iClient)); - return; - } - - /** - Before we continue, lets make sure the client is switchable - */ - if (IsSwitchablePlayer(iClient, GetBiggerTeam())) - { - - /** - Now we check the buddy system - */ - if (g_bBuddyEnabled) - { - - /** - Buddy system is enabled, check to see if client has buddy - */ - new iBuddyIndex = SM_GetClientBuddy(iClient); - if (iBuddyIndex != 0 || !IsClientConnected(iBuddyIndex) || !IsClientInGame(iBuddyIndex)) - { - - /** - The client has a buddy, so we check to see if they are on same team - */ - if (GetClientTeam(iClient) == GetClientTeam(iBuddyIndex)) - { - - /** - They are, but we don't bug out, we still need to start a balance - */ - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] With a balance in progress a buddy on the right team was found and skipped."); - } - } - else - { - - /** - They are not on the same team - The buddy could be in spec, and that would make it not matter where he is, or the buddy is on the smaller team - */ - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] With a balance in progress a buddy on the wrong team was switched."); - } - BalancePlayer(iClient, iSmallerTeam); - return; - } - } - else - { - - /** - Client doesn't have a buddy, balance this player - */ - BalancePlayer(iClient, iSmallerTeam); - return; - } - } - else - { - - /** - Buddy system is not enabled, balance this player - */ - BalancePlayer(iClient, iSmallerTeam); - return; - } - } - } - else - { - - /** - If we get to here then we must need to start a balance - */ - StartABalance(); - } - } -} - -public HookPlayerChangeTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get our event variables. - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - new iTeam = GetEventInt(event, "team"); - - /** - Make sure its ok to balance. - */ - if (OkToBalance()) - { - - /** - See if the client that changed teams was set to with a balance. - */ - if (g_aPlayers[iClient][hBalanceTimer] != INVALID_HANDLE - && SM_GetForcedTeam(iClient) == iTeam - && g_bBalanceInProgress) - { - - /** - The client was set to be balanced, so we close the timer. - */ - CloseHandle(g_aPlayers[iClient][hBalanceTimer]); - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - - /** - Stop the balance. - */ - g_bBalanceInProgress = false; - return; - } - - /** - It's not likely that this team change can cause us to need a balance. - If it does, start one with a small dealy to deal with forced switch backs. - */ - if (IsUnbalanced() && !g_bBalanceInProgress) - { - CreateTimer(2.0, Timer_ChangeTeamBalanceDelay, _, TIMER_FLAG_NO_MAPCHANGE); - } - } -} - -public HookRoundStart(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Set the variables we need to start a round - */ - g_bRoundStart = true; - g_bRoundEnd = false; - g_bSuddenDeath = false; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Round Started"); - } - - /** - Start a delayed balance check at the start of the round - */ - CreateTimer(float(g_iRoundStartDelay), Timer_RoundStart); -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Set the variables we need at round end - */ - g_bRoundEnd = true; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Round Ended"); - } -} - -public HookSuddenDeathBegin(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Set the variables we need for sudden death - */ - g_bSuddenDeath = true; -} - -public HookFlagEvent(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get our event variables - */ - new iClient = GetEventInt(event, "player"); - new iFlagStatus = GetEventInt(event, "eventtype"); - - /** - Make sure we have a valid client - */ - if (!IsClientInGame(iClient)) - { - return; - } - - /** - Determine what kind of event this is - */ - switch (iFlagStatus) - { - case 1: - { - - /** - The flag was picked up - */ - g_aPlayers[iClient][bFlagCarrier] = true; - } - case 2: - { - - /** - The flag was capped - */ - g_aPlayers[iClient][bFlagCarrier] = false; - } - case 3: - { - - /** - The flag was defended, we don't have to do anything - */ - } - case 4: - { - - /** - The flag was dropped - */ - g_aPlayers[iClient][bFlagCarrier] = false; - } - } -} - -/* COMMAND EVENTS */ - -public Action:Command_AddBalanceBuddy(client, args) -{ - if (client == 0) - { - ReplyToCommand(client, "[SM] %T", "PlayerLevelCmd", LANG_SERVER); - return Plugin_Handled; - } - if (!g_bIsEnabled || !g_bBuddyEnabled) - { - ReplyToCommand(client, "[SM] %T", "CmdDisabled", LANG_SERVER); - return Plugin_Handled; - } - if (g_bBuddyRestriction) - { - if (!SM_IsValidAdmin(client, g_sAdminFlag)) - { - ReplyToCommand(client, "[SM] %T", "RestrictedBuddy", LANG_SERVER); - return Plugin_Handled; - } - } - decl String:sPlayerUserId[24]; - GetCmdArg(1, sPlayerUserId, sizeof(sPlayerUserId)); - new iPlayer = GetClientOfUserId(StringToInt(sPlayerUserId)); - if (!iPlayer || !IsClientInGame(iPlayer) || client == iPlayer) - { - if (client == iPlayer) - { - PrintHintText(client, "%T", "SelectSelf", LANG_SERVER); - } - ReplyToCommand(client, "[SM] Usage: buddy "); - new Handle:playermenu = BuildPlayerMenu(); - DisplayMenu(playermenu, client, MENU_TIME_FOREVER); - } - else - { - decl String:cName[128]; - decl String:bName[128]; - GetClientName(client, cName, sizeof(cName)); - GetClientName(iPlayer, bName, sizeof(bName)); - if (SM_IsBuddyLocked(iPlayer)) - { - ReplyToCommand(client, "[SM] %T", "PlayerLockedBuddyMsg", LANG_SERVER, bName); - return Plugin_Handled; - } - SM_AssignBuddy(client, iPlayer); - PrintHintText(client, "%T", "BuddyMsg", LANG_SERVER, bName); - PrintHintText(iPlayer, "%T", "BuddyMsg", LANG_SERVER, cName); - } - return Plugin_Handled; -} - -public Action:Command_LockBuddy(client, args) -{ - if (client == 0) - { - ReplyToCommand(client, "[SM] %T", "PlayerLevelCmd", LANG_SERVER); - return Plugin_Handled; - } - if (!g_bIsEnabled) - { - ReplyToCommand(client, "[SM] %T", "CmdDisabled", LANG_SERVER); - return Plugin_Handled; - } - if (g_bBuddyRestriction) - { - if (!SM_IsValidAdmin(client, g_sAdminFlag)) - { - ReplyToCommand(client, "[SM] %T", "RestrictedBuddy", LANG_SERVER); - return Plugin_Handled; - } - } - if (SM_IsBuddyLocked(client)) - { - SM_LockBuddy(client, false); - PrintHintText(client, "%T", "BuddyLockMsgDisabled", LANG_SERVER); - } - else - { - SM_LockBuddy(client, true); - PrintHintText(client, "%T", "BuddyLockMsgEnabled", LANG_SERVER); - } - return Plugin_Handled; -} - -/** -Stock functions . - */ - -stock bool:IsUnbalanced() -{ - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Checking if teams are unbalanced"); - } - new Team1Count = GetTeamClientCount(g_aCurrentTeams[Team1]); - new Team2Count = GetTeamClientCount(g_aCurrentTeams[Team2]); - new ubCount = RoundFloat(FloatAbs(float(Team1Count - Team2Count))); - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Team1:%i Team2:%i Difference:%i", Team1Count, Team2Count, ubCount); - } - if (ubCount > g_iUnbalanceLimit) - { - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Teams are unbalanced"); - } - return true; - } - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Teams are not unbalanced"); - } - return false; -} - -stock bool:OkToBalance() -{ - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Checking if OK to balance."); - } - new bool:bResult = false; - if (g_bIsEnabled && !g_bRoundStart && !g_bRoundEnd && !g_bIsArenaMode && !g_bSuddenDeath) - { - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Passed IF statement"); - LogAction(0, -1, "[STB] Now checking admins"); - } - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientInGame(i) && !SM_IsValidAdmin(i, g_sAdminFlag)) - { - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Found at least 1 non-admin"); - LogAction(0, -1, "[STB] OK to balance"); - } - bResult = true; - break; - } - } - if (!bResult && g_bLogActivity2) - { - LogAction(0, -1, "[STB] All admins online"); - } - } - if (!bResult && g_bLogActivity2) - { - LogAction(0, -1, "[STB] Not OK to balance"); - } - return bResult; -} - -stock bool:IsSwitchablePlayer(iClient, iBiggerTeam) -{ - - /** - Run the client thru some standard checks - */ - if (!IsClientInGame(iClient) - || SM_IsValidAdmin(iClient, g_sAdminFlag) - || g_aPlayers[iClient][bFlagCarrier] - || GetClientTeam(iClient) != iBiggerTeam - || g_aPlayers[iClient][bSwitched]) - { - - /** - The supplied client can't be switched - */ - return false; - } - - /** - The supplied client can be switched - */ - return true; -} - -stock bool:HasUber(iClient) -{ - - /** - First things first, make sure the client is a medic - */ - if(TF2_GetPlayerClass(iClient) == TFClass_Medic) - { - - /** - We can only check the active weapon, so make sure the client is holding the uber gun - */ - decl String:sWeaponName[32]; - GetClientWeapon(iClient, sWeaponName, sizeof(sWeaponName)); - if(StrEqual(sWeaponName, "tf_weapon_medigun")) - { - - /** - They are, so lets check the uber level of the gun - */ - new iEntityIndex = GetEntDataEnt2(iClient, FindSendPropInfo("CTFPlayer", "m_hActiveWeapon")); - new Float:fChargeLevel = GetEntDataFloat(iEntityIndex, FindSendPropInfo("CWeaponMedigun", "m_flChargeLevel")); - if (fChargeLevel >= g_fUberLevel) - { - - /** - The client supplied has an uber above the supplied level, return true - */ - if (g_bLogActivity2) - { - LogAction(0, iClient, "[STB] Found a medic with a uber and skipped him."); - } - return true; - } - } - } - - /** - The client supplied does not have an uber above the supplied level, return false - */ - return false; -} - -stock bool:HasBuildingsBuilt(iClient) -{ - - /** - We have to start a loop to check the owner of all the valid entities - */ - new iMaxEntities = GetMaxEntities(); - for (new i = MaxClients + 1; i <= iMaxEntities; i++) - { - if (!IsValidEntity(i)) - { - - /** - Not valid, continue to next one - */ - continue; - } - - /** - Get the name of the current entity - */ - decl String:sNetClass[32]; - GetEntityNetClass(i, sNetClass, sizeof(sNetClass)); - - /** - See if its something that an engineer would build - */ - if (strcmp(sNetClass, "CObjectSentrygun") == 0 - || strcmp(sNetClass, "CObjectTeleporter") == 0 - || strcmp(sNetClass, "CObjectDispenser") == 0) - { - - /** - It is, so lets check the owner - */ - if (GetEntDataEnt2(i, g_iOwnerOffset) == iClient) - { - - /** - The client supplied is the owner, return true - */ - if (g_bLogActivity2) - { - LogAction(0, iClient, "[STB] Found an engineer with buildings and skipped him."); - } - return true; - } - } - } - - /** - The client supplied didn't have any buildings, return false - */ - return false; -} - -stock StartABalance() -{ - - /** - See if we are already started a balance - */ - if (g_hBalanceTimer != INVALID_HANDLE) - { - - /** - We have, check if we still need to - */ - if (!IsUnbalanced() || !OkToBalance()) - { - - /** - We don't, stop the balance - It's almost impossible to reach this code, but we do it just in case - */ - CloseHandle(g_hBalanceTimer); - g_hBalanceTimer = INVALID_HANDLE; - g_bBalanceInProgress = false; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Balance delay timer was not needed and was killed before the callback."); - } - return; - } - else - { - - /** - We still need to balance - Bug out and wait for the current one to finish - */ - return; - } - } - - /** - Report that teams are unbalanced - */ - PrintToChatAll("[SM] %T", "UnBalanced", LANG_SERVER); - - /** - Check to see if we are supposed to delay the balance - */ - if (g_iBalanceDelay == 0) - { - - /** - Start the balance now - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Balance is now in progress."); - } - g_bBalanceInProgress = true; - g_hBalanceTimer = INVALID_HANDLE; - - /** - Check if we are allowed to scan living players - */ - if (!g_bDeadOnly) - { - - /** - We are allowed to, so we start a timer - */ - StartALivingPlayerTimer(); - - /** - Also report that we are now scanning dead players as well - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Now scanning dead players."); - } - } - else - { - - /** - We are not allowed to, so report that we are only scanning dead players - */ - if (g_bLogActivity) - LogAction(0, -1, "[STB] Only scanning dead players."); - } - - /** - We started the balance, bug out - */ - return; - } - - /** - We are supposed to delay the balance, start a balance timer - */ - g_hBalanceTimer = CreateTimer(float(g_iBalanceDelay), Timer_BalanceTeams, _, TIMER_FLAG_NO_MAPCHANGE); - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Teams are unbalanced. Balance delay timer started."); - } -} - -stock StartALivingPlayerTimer() -{ - - /** - Start a timer to check living players - */ - if (g_hLivingPlayerCheckTimer != INVALID_HANDLE) - { - - /** - If we for some reason already have one started, stop it. - */ - CloseHandle(g_hLivingPlayerCheckTimer); - g_hLivingPlayerCheckTimer = INVALID_HANDLE; - } - - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Living player balance delay timer started."); - } - g_hLivingPlayerCheckTimer = CreateTimer(float(g_iLivingPlayerCheckDelay), Timer_LivingPlayerCheck, _, TIMER_FLAG_NO_MAPCHANGE); -} - -stock FindSwitchablePlayer() -{ - - /** - Start a loop to find a switchable player - */ - new iPlayer; - new iBiggerTeam = GetBiggerTeam(); - for (new i = 1; i <= MaxClients; i++) - { - - /** - Check the stock function to see if we are allows to even switch the player - */ - if (!IsSwitchablePlayer(i, iBiggerTeam)) - { - continue; - } - - /** - If the mod is TF2 and they have Priority Players set check if the client has buildings or an uber - */ - if (g_CurrentMod == GameType_TF && g_bPriorityPlayers) - { - if (HasUber(i) || HasBuildingsBuilt(i)) - { - continue; - } - } - - /** - So far we are able we switch this player - Now we check the buddy system - */ - if (g_bBuddyEnabled) - { - - /** - Buddy system is enabled, check to see if client has buddy - */ - if (SM_GetClientBuddy(i) != 0) - { - - /** - The client has a buddy, so we check to see if they are on same team - */ - if (GetClientTeam(i) == GetClientTeam(SM_GetClientBuddy(i))) - { - - /** - They are, so we continue to next client - */ - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] With a balance in progress a buddy on the right team was found and skipped."); - } - continue; - } - else - { - - /** - They are not on the same team, set this client - The buddy could be in spec, and that would make it not matter where he is, or the buddy is on the smaller team - */ - iPlayer = i; - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] With a balance in progress a buddy on the wrong team was found."); - } - break; - } - } - else - { - - /** - The client does not have a buddy, set this client - */ - iPlayer = i; - break; - } - } - else - { - - /** - Buddy system is not enabled, set this client - */ - iPlayer = i; - break; - } - } - - /** - Return the client we set, this could be 0, but very unlikely - */ - return iPlayer; -} - -stock BalancePlayer(iClient, iTeam) -{ - new Handle:hPack = CreateDataPack(); - WritePackCell(hPack, iClient); - WritePackCell(hPack, iTeam); - CreateTimer(0.1, Timer_BalancePlayer, hPack, TIMER_FLAG_NO_MAPCHANGE); -} - -stock CleanUp(iClient) -{ - g_aPlayers[iClient][bFlagCarrier] = false; - g_aPlayers[iClient][bSwitched] = false; - if (g_aPlayers[iClient][hForcedTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[iClient][hForcedTimer]); - g_aPlayers[iClient][hForcedTimer] = INVALID_HANDLE; - if (g_bLogActivity) - { - LogAction(0, iClient, "[STB] Forced player disconnected, killing timer."); - } - } - if (g_aPlayers[iClient][hBalanceTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[iClient][hBalanceTimer]); - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - if (g_bLogActivity) - { - LogAction(0, iClient, "[STB] Living player set to be balanced disconnected, killing timer."); - } - } -} - -stock GetSmallerTeam() -{ - - /** - Get the count of players on each team - */ - new iCountT1 = GetTeamClientCount(g_aCurrentTeams[Team1]); - new iCountT2 = GetTeamClientCount(g_aCurrentTeams[Team2]); - - /** - Return the smaller team - */ - if (iCountT1 < iCountT2) - { - return g_aCurrentTeams[Team1]; - } - else if (iCountT1 > iCountT2) - { - return g_aCurrentTeams[Team2]; - } - return 0; -} - -stock GetBiggerTeam() -{ - - /** - Get the count of players on each team - */ - new iCountT1 = GetTeamClientCount(g_aCurrentTeams[Team1]); - new iCountT2 = GetTeamClientCount(g_aCurrentTeams[Team2]); - - /** - Return the bigger team - */ - if (iCountT1 > iCountT2) - { - return g_aCurrentTeams[Team1]; - } - else if (iCountT1 < iCountT2) - { - return g_aCurrentTeams[Team2]; - } - return 0; -} - -stock SetGameCvars() -{ - if (g_bConVarControl && g_bIsEnabled) - { - if (stb_mp_autoteambalance != INVALID_HANDLE) - { - SetConVarInt(stb_mp_autoteambalance, 0); - } - if (stb_mp_teams_unbalance_limit != INVALID_HANDLE) - { - SetConVarInt(stb_mp_teams_unbalance_limit, g_iUnbalanceLimit); - } - } -} - -/* TIMER FUNCTIONS */ - -public Action:Timer_ChangeTeamBalanceDelay(Handle:timer, any:data) -{ - - /** - Finally start one if it's still unbalanced - */ - if (IsUnbalanced() && !g_bBalanceInProgress) - { - StartABalance(); - } -} - -public Action:Timer_BalanceTeams(Handle:timer, any:data) -{ - - /** - See if we still need to balance the teams - */ - if (!IsUnbalanced() || !OkToBalance()) - { - - /** - We don't, kill the balance - */ - g_bBalanceInProgress = false; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Balance delay timer was not needed and died."); - } - g_hBalanceTimer = INVALID_HANDLE; - return Plugin_Handled; - } - - /** - We still need to balance the teams - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Teams are still unbalanced. Balance is now in progress."); - } - g_bBalanceInProgress = true; - - - /** - Check if we are allowed to scan living players - */ - if (!g_bDeadOnly) - { - - /** - We are allowed to, so we start a timer - */ - StartALivingPlayerTimer(); - - /** - Also report that we are now scanning dead players as well - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Now scanning dead players."); - } - } - else - { - - /** - We are not allowed to, so report that we are only scanning dead players - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Only scanning dead players."); - } - } - - g_hBalanceTimer = INVALID_HANDLE; - return Plugin_Handled; -} - -public Action:Timer_LivingPlayerCheck(Handle:timer, any:data) -{ - - /** - Check to see if we still need to balance the teams - */ - if (!IsUnbalanced() || !OkToBalance()) - { - - /** - We don't, kill it and bug out - */ - g_bBalanceInProgress = false; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Living player balance delay timer was not needed and died."); - } - g_hLivingPlayerCheckTimer = INVALID_HANDLE; - return Plugin_Handled; - } - - /** - Call the stock function to find a player we can switch - */ - new iPlayer = FindSwitchablePlayer(); - - /** - Check to see if we found a player - */ - if (iPlayer == 0) - { - - /** - In the unlikely event that the stock function didn't return a player - Start a loop to find a random player - */ - new iBiggerTeam = GetBiggerTeam(); - do - { - iPlayer = GetRandomInt(1, MaxClients); - } while (!IsSwitchablePlayer(iPlayer, iBiggerTeam)); - - if (g_bLogActivity) - { - LogAction(0, iPlayer, "[STB] Found a random living player."); - } - } - else - { - if (g_bLogActivity) - { - LogAction(0, iPlayer, "[STB] Found a living player."); - } - } - - /** - Now that we have a player assigned them to the smaller team - */ - new iSmallerTeam = GetSmallerTeam(); - SM_SetForcedTeam(iPlayer, iSmallerTeam, true); - - /** - Let the player know we could be switching him soon - */ - PrintHintText(iPlayer, "%T", "PlayerMessage", LANG_SERVER, g_iLivingPlayerSwitchDelay); - if (g_bLogActivity) - { - LogAction(0, iPlayer, "[STB] Living player placed on a timer."); - } - - /** - Create a timer to switch the player - */ - g_aPlayers[iPlayer][hBalanceTimer] = CreateTimer(float(g_iLivingPlayerSwitchDelay), Timer_LivingPlayerBalance, iPlayer, TIMER_FLAG_NO_MAPCHANGE); - - /** - Reset the timer handle - */ - g_hLivingPlayerCheckTimer = INVALID_HANDLE; - - /** - We are done, bug out - */ - return Plugin_Handled; -} - -public Action:Timer_LivingPlayerBalance(Handle:timer, any:iClient) -{ - - /** - Check to make sure we still need to balance - */ - if (!IsUnbalanced() || !OkToBalance()) - { - - /** - We don't need to balance, bug out - */ - g_bBalanceInProgress = false; - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - SM_ClearForcedTeam(iClient); - return Plugin_Handled; - } - - /** - We still need to balance, lets make sure we can still balance this player - */ - if (!IsClientConnected(iClient) || g_aPlayers[iClient][bFlagCarrier]) - { - g_bBalanceInProgress = false; - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - SM_ClearForcedTeam(iClient); - if (g_bLogActivity) - { - if (g_aPlayers[iClient][bFlagCarrier]) - { - LogAction(0, iClient, "[STB] Living player became flag carrier, balance restarted."); - } - else - { - LogAction(0, iClient, "[STB] Living player timer was not needed and died."); - } - } - return Plugin_Handled; - } - - /** - Clear to balance this player, so do it - */ - BalancePlayer(iClient, SM_GetForcedTeam(iClient)); - if (g_bLogActivity) - { - LogAction(0, iClient, "[STB] Living player was switched."); - } - - /** - We are done, bug out - */ - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - return Plugin_Handled; -} - -public Action:Timer_BalancePlayer(Handle:timer, Handle:pack) -{ - - /** - Rest the datapack and load the variables - */ - ResetPack(pack); - new iClient = ReadPackCell(pack); - new iUnBalancedTeam = ReadPackCell(pack); - - /** - We are done with you now - */ - CloseHandle(pack); - - /** - Check the team and make sure its a valid team - */ - if(!SM_IsValidTeam(iUnBalancedTeam)) - { - if (g_bLogActivity) - { - LogAction(0, iClient, "[STB] Balance failed due to invalid team number %i", iUnBalancedTeam); - } - return Plugin_Handled; - } - - /** - Use our core function to change the clients team - */ - SM_MovePlayer(iClient, iUnBalancedTeam); - - return Plugin_Handled; -} - -public Action:Timer_RoundStart(Handle:timer, any:data) -{ - g_bRoundStart = false; - if (OkToBalance() && IsUnbalanced() && !g_bBalanceInProgress) - { - StartABalance(); - } - return Plugin_Handled; -} - -public Action:Timer_ForcedExpired(Handle:timer, any:iClient) -{ - SM_ClearForcedTeam(iClient); - g_aPlayers[iClient][bSwitched] = false; - g_aPlayers[iClient][hForcedTimer] = INVALID_HANDLE; - return Plugin_Handled; -} - -public Action:Timer_WelcomeAdvert(Handle:timer, any:iClient) -{ - if (IsClientConnected(iClient) && IsClientInGame(iClient)) - { - PrintToChat (iClient, "\x01\x04[STB]\x01 %T", "BuddyWelcomeMsg1", LANG_SERVER); - PrintToChat (iClient, "\x01\x04[STB]\x01 %T", "BuddyWelcomeMsg2", LANG_SERVER); - PrintToChat (iClient, "\x01\x04[STB]\x01 %T", "BuddyWelcomeMsg3", LANG_SERVER); - } - return Plugin_Handled; -} - -/* CONSOLE VARIABLE CHANGE EVENT */ - -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (convar == stb_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsEnabled = false; - PrintToChatAll("[SM] %T", "Disabled", LANG_SERVER); - LogAction(0, -1, "[SimpleTeamBalancer] Disabled"); - } - else - { - g_bIsEnabled = true; - SetGameCvars(); - PrintToChatAll("[SM] %T", "Enabled", LANG_SERVER); - LogAction(0, -1, "[SimpleTeamBalancer] Enabled"); - } - } - else if (convar == stb_logactivity) - { - if (StringToInt(newValue) == 0) - { - g_bLogActivity = false; - LogAction(0, -1, "[STB] Log Activity DISABLED."); - } - else - { - g_bLogActivity = true; - LogAction(0, -1, "[STB] Log Activity ENABLED."); - } - } - else if (convar == stb_logactivity2) - { - if (StringToInt(newValue) == 0) - { - g_bLogActivity2 = false; - LogAction(0, -1, "[STB] Detailed Log Activity DISABLED."); - } - else - { - g_bLogActivity2 = true; - LogAction(0, -1, "[STB] Detailed Log Activity ENABLED."); - } - } - else if (convar == stb_convarcontrol) - { - if (StringToInt(newValue) == 0) - { - g_bConVarControl = false; - } - else - { - g_bConVarControl = true; - SetGameCvars(); - } - } - else if (convar == stb_deadonly) - { - if (StringToInt(newValue) == 0) - { - g_bDeadOnly = false; - } - else - { - g_bDeadOnly = true; - } - } - else if (convar == stb_priorityenabled) - { - if (StringToInt(newValue) == 0) - { - g_bPriorityPlayers = false; - } - else - { - g_bPriorityPlayers = true; - } - } - else if (convar == stb_buddyenabled) - { - if (StringToInt(newValue) == 0) - { - g_bBuddyEnabled = false; - } - else - { - g_bBuddyEnabled = true; - } - } - else if (convar == stb_buddyrestriction) - { - if (StringToInt(newValue) == 0) - { - g_bBuddyRestriction = false; - } - else - { - g_bBuddyRestriction = true; - } - } - else if (convar == stb_unbalancelimit) - { - g_iUnbalanceLimit = StringToInt(newValue); - SetGameCvars(); - } - else if (convar == stb_balancedelay) - { - g_iBalanceDelay = StringToInt(newValue); - } - else if (convar == stb_roundstartdelay) - { - g_iRoundStartDelay = StringToInt(newValue); - } - else if (convar == stb_livingplayerswitchdelay) - { - g_iLivingPlayerSwitchDelay = StringToInt(newValue); - } - else if (convar == stb_livingplayercheckdelay) - { - g_iLivingPlayerCheckDelay = StringToInt(newValue); - } - else if (convar == stb_uberlevel) - { - g_fUberLevel = StringToFloat(newValue); - } - else if (convar == stb_switchbackforced) - { - g_iSwitchBackForced = StringToInt(newValue); - } - else if (convar == stb_adminflag) - { - SetConVarString(stb_adminflag, newValue); - } - else if (convar == stb_mp_autoteambalance) - { - SetGameCvars(); - } - else if (convar == stb_mp_teams_unbalance_limit) - { - SetGameCvars(); - } -} - -/* MENU CODE */ - -stock Handle:BuildPlayerMenu() -{ - new Handle:menu = CreateMenu(Menu_SelectPlayer); - AddTargetsToMenu(menu, 0, true, false); - SetMenuTitle(menu, "Select A Player:"); - SetMenuExitButton(menu, true); - return menu; -} - -public Menu_SelectPlayer(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[24]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - new buddy = GetClientOfUserId(StringToInt(sSelection)); - if (param1 == buddy) { - PrintHintText(param1, "%T", "SelectSelf", LANG_SERVER); - } else if (!IsClientInGame(buddy)) { - PrintHintText(param1, "%T", "BuddyGone", LANG_SERVER); - } else { - decl String:cName[128]; - decl String:bName[128]; - GetClientName(param1, cName, sizeof(cName)); - GetClientName(buddy, bName, sizeof(bName)); - if (!SM_IsBuddyLocked(buddy)) { - SM_AssignBuddy(param1, buddy); - PrintHintText(param1, "%T", "BuddyMsg", LANG_SERVER, bName); - PrintHintText(buddy, "%T", "BuddyMsg", LANG_SERVER, cName); - } else - PrintHintText(param1, "%T", "PlayerLockedBuddyMsg", LANG_SERVER, bName); - } - } else if (action == MenuAction_End) { - CloseHandle(menu); - } -} \ No newline at end of file diff --git a/Simple Spectate/addons/sourcemod/scripting/simple-teammanager.sp b/Simple Spectate/addons/sourcemod/scripting/simple-teammanager.sp deleted file mode 100644 index 008f443..0000000 --- a/Simple Spectate/addons/sourcemod/scripting/simple-teammanager.sp +++ /dev/null @@ -1,1351 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Team Manager -Description: - Manges players and their team - Admin menu integration - Allows admins/donators to swap their teams (clears force)* - Allows admins to move players to a team (forced\unforced)* - Allows admins to scramble the teams* - *Works with Simple Team Balancer (if installed) -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include - -#define PLUGIN_VERSION "2.1.$Rev$" -#define VOTE_YES "##YES##" -#define VOTE_NO "##NO##" - -enum PlayerData -{ - iNewTeam, - bool:bQueue -}; - -new Handle:stm_enabled = INVALID_HANDLE; -new Handle:stm_logactivity = INVALID_HANDLE; -new Handle:stm_adminflag_swapteam = INVALID_HANDLE; -new Handle:stm_adminflag_moveplayer = INVALID_HANDLE; -new Handle:stm_adminflag_scramble = INVALID_HANDLE; -new Handle:stm_scrambledelay = INVALID_HANDLE; -new Handle:stm_voteenabled = INVALID_HANDLE; -new Handle:stm_votewin = INVALID_HANDLE; -new Handle:stm_votedelay = INVALID_HANDLE; -new Handle:stm_mp_bonusroundtime = INVALID_HANDLE; -new Handle:g_hAdminMenu = INVALID_HANDLE; -new Handle:g_hTimerPrepScramble = INVALID_HANDLE; -new Handle:g_hTimerClearScrambleForce = INVALID_HANDLE; - -new g_aPlayers[MAXPLAYERS + 1][PlayerData]; - -new bool:g_bIsEnabled = true; -new bool:g_bVoteEnabled = true; -new bool:g_bLogActivity = true; -new bool:g_bScrambleRoundEnd = false; -new g_iVoteDelay, g_iLastVoteTime, g_iTimeLeft; -new Float:g_fScrambleDelay, Float:g_fVoteWin; - -public Plugin:myinfo = -{ - name = "Simple Team Manager", - author = "Simple Plugins", - description = "Manages players and thier team.", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -}; - -public OnPluginStart() -{ - - /** - Need to create all of our console variables. - */ - CreateConVar("stm_version", PLUGIN_VERSION, "Simple Team Manager Version",FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - stm_enabled = CreateConVar("stm_enabled", "1", "Enable or Disable Simple Team Manager", _, true, 0.0, true, 1.0); - stm_logactivity = CreateConVar("stm_logactivity", "0", "Enable or Disable the disaplying of events in the log", _, true, 0.0, true, 1.0); - stm_adminflag_swapteam = CreateConVar("stm_adminflag_swapteam", "a", "Admin flag to use for the swapteam command. Must be a in char format."); - stm_adminflag_moveplayer = CreateConVar("stm_adminflag_moveplayer", "c", "Admin flag to use for the moveplayer command. Must be a in char format."); - stm_adminflag_scramble = CreateConVar("stm_adminflag_scramble", "c", "Admin flag to use for the scrambleteam command. Must be a in char format."); - stm_scrambledelay = CreateConVar("stm_scrambledelay", "15", "Delay to scramble teams"); - stm_voteenabled = CreateConVar("stm_voteenabled", "1", "Enable or Disable voting to scramble the teams", _, true, 0.0, true, 1.0); - stm_votewin = CreateConVar("stm_votewin", "0.45", "Win percentage vote must win by", _, true, 0.0, true, 1.0); - stm_votedelay = CreateConVar("stm_votedelay", "600", "Delay before another vote can be cast"); - stm_mp_bonusroundtime = FindConVar("mp_bonusroundtime"); - - - /** - Need deal with changes to the console variables after the plugin is loaded. - We could not do this and just call the actual console variable each time we need it, but it's not efficent. - */ - HookConVarChange(stm_enabled, ConVarSettingsChanged); - HookConVarChange(stm_logactivity, ConVarSettingsChanged); - HookConVarChange(stm_scrambledelay, ConVarSettingsChanged); - HookConVarChange(stm_voteenabled, ConVarSettingsChanged); - HookConVarChange(stm_votewin, ConVarSettingsChanged); - HookConVarChange(stm_votedelay, ConVarSettingsChanged); - - /** - Need to register the commands we are going to create and use. - */ - RegConsoleCmd("sm_swapteam", Command_SwapTeam, "sm_swapteam <[0]instant/[1]queued>: Swaps your team to the other team"); - RegConsoleCmd("sm_moveplayer", Command_MovePlayer, "sm_moveplayer <[0]instant/[1]ondeath> <[0]unforced/[1]forced>: Moves a player to the specified team"); - RegConsoleCmd("sm_scrambleteams", Command_ScrambleTeams, "sm_scrambleteams: <[0]now/[1]roundend> <[0]dontrestart/[1]restartround> Scrambles the current teams"); - RegConsoleCmd("sm_votescramble", Command_VoteScramble, "sm_votescramble: Starts a vote to scramble the teams"); - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook the game events - */ - LogAction(0, -1, "[STM] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_death", HookPlayerDeath, EventHookMode_Post); - HookEvent("player_team", HookPlayerChangeTeam, EventHookMode_Post); - switch (g_CurrentMod) - { - case GameType_TF: - { - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - } - case GameType_DOD: - { - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_Post); - } - default: - { - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - } - } - - /** - Now we have to deal with the admin menu. If the admin library is loaded call the function to add our items. - */ - new Handle:gTopMenu; - if (LibraryExists("adminmenu") && ((gTopMenu = GetAdminTopMenu()) != INVALID_HANDLE)) - { - OnAdminMenuReady(gTopMenu); - } - - /** - Load translations and .cfg file - */ - LoadTranslations ("simpleteammanager.phrases"); - AutoExecConfig(true, "plugin.simpleteammanager"); - LogAction(0, -1, "[STM] Simple Team Manager is loaded."); -} - -public OnAllPluginsLoaded() -{ - //something -} - -public OnLibraryRemoved(const String:name[]) -{ - if (StrEqual(name, "adminmenu")) - { - - /** - Looks like the admin menu was removed. Set the global. - */ - g_hAdminMenu = INVALID_HANDLE; - } - else if (StrEqual(name, "simpleplugins")) - { - SetFailState("Required plugin Simple SourceMod Plugins Core was removed."); - } -} - -public OnConfigsExecuted() -{ - - /** - Once we loaded up all the console variables from the config file, lets now set all the global variables we will use. - */ - g_bIsEnabled = GetConVarBool(stm_enabled); - g_bLogActivity = GetConVarBool(stm_logactivity); - g_fScrambleDelay = GetConVarFloat(stm_scrambledelay); - g_iVoteDelay = GetConVarInt(stm_votedelay); - g_fVoteWin = GetConVarFloat(stm_votewin); - g_iLastVoteTime = RoundFloat(GetEngineTime()); - g_bScrambleRoundEnd = false; - g_hTimerClearScrambleForce = INVALID_HANDLE; - - /** - Report enabled - */ - if (g_bIsEnabled) - { - LogAction(0, -1, "[STM] Simple Team Manager is ENABLED."); - } - else - { - LogAction(0, -1, "[STM] Simple Team Manager is DISABLED."); - } - - if (g_bLogActivity) - { - LogAction(0, -1, "[STM] Log Activity ENABLED."); - } - else - { - LogAction(0, -1, "[STM] Log Activity DISABLED."); - } -} - -/* COMMANDS */ - -public Action:Command_SwapTeam(client, args) -{ - - /** - Make sure we are enabled, if not bug out. - */ - if (!g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - If this was ran from the console bug out. - */ - if (client == 0) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "PlayerLevelCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Make sure the client is authorized to run this command. - */ - decl String:sFlags[5]; - GetConVarString(stm_adminflag_swapteam, sFlags, sizeof(sFlags)); - if (!SM_IsValidAdmin(client, sFlags)) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Lets make sure the client is one a team we can swap. - If he is we set the global array to the opposite team. - */ - new iTeam = GetClientTeam(client); - if (iTeam == g_aCurrentTeams[Team1]) - { - g_aPlayers[client][iNewTeam] = g_aCurrentTeams[Team2]; - } - else if (iTeam == g_aCurrentTeams[Team2]) - { - g_aPlayers[client][iNewTeam] = g_aCurrentTeams[Team1]; - } - else - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "InValidTeam", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check to see if we have command arguments. - */ - if (GetCmdArgs()) - { - - /** - We do, so lets get it and see if the client wants to be switched instantly or queued for death. - */ - decl String:sArg[5]; - GetCmdArg(1, sArg, sizeof(sArg)); - new iWantsQue = StringToInt(sArg); - if (iWantsQue && !g_aPlayers[client][bQueue]) - { - - /** - He wants the que and isn't already in it, set the global array. - */ - g_aPlayers[client][bQueue] = true; - ReplyToCommand(client, "\x01\x04[STM]\x01 %T", "PlayerQueue", LANG_SERVER); - } - else if (!iWantsQue) - { - - /** - He wants to be switched right now, lets call the stock function. - */ - SM_MovePlayer(client, g_aPlayers[client][iNewTeam]); - } - } - else - { - - /** - There are no command arguments so we build and display the swap menu. - */ - DisplaySwapModeMenu(client, client); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_MovePlayer(client, args) -{ - - /** - Make sure we are enabled, if not bug out. - */ - if (!g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - Make sure the client is authorized to run this command. - */ - decl String:sFlags[5]; - GetConVarString(stm_adminflag_moveplayer, sFlags, sizeof(sFlags)); - if (!SM_IsValidAdmin(client, sFlags)) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check to see if we have command arguments. - */ - new iCmdArgs = GetCmdArgs(); - if (iCmdArgs == 0) - { - - /** - We don't. Build the player menu, display it, and bug out. - */ - DisplayPlayerMenu(client); - return Plugin_Handled; - } - - /** - Check the first argument - If should be a players name or userid. - */ - decl String:sPlayer[64]; - GetCmdArg(1, sPlayer, sizeof(sPlayer)); - new iPlayerIndex = FindTarget(client, sPlayer, true, true); - if (iPlayerIndex == -1 || !IsClientInGame(iPlayerIndex)) - { - - /** - We don't know who this is. Build the player menu, display it, and bug out. - */ - DisplayPlayerMenu(client); - return Plugin_Handled; - } - - /** - We have figured out the first argument, lets check the second. - If should be the team the client wants to put the player on. - */ - if (iCmdArgs >= 2) - { - - /** - We have a command argument at least, lets see if we can identify the team. - */ - decl String:sTeam[24]; - GetCmdArg(2, sTeam, sizeof(sTeam)); - - new iTeam = StringToInt(sTeam); - if (SM_IsValidTeam(iTeam)) - { - - /** - It's a vaild team so lets set the global array to the new team. - */ - g_aPlayers[iPlayerIndex][iNewTeam] = iTeam; - } - else - { - - /** - It's not a vaild team so set the menu to display to the team menu. - */ - DisplayTeamMenu(client, iPlayerIndex); - return Plugin_Handled; - } - } - else - { - /** - We were not given a team, display the team menu. - */ - DisplayTeamMenu(client, iPlayerIndex); - return Plugin_Handled; - } - - /** - Check to see if we were given any more command arguments and found a team. - */ - if (iCmdArgs < 3) - { - - /** - No more command arguments and found a team. - Now lets check to see if the player is a spectator. If he is there is no reason to ask if it's instant or on death... he can't die. - */ - if (!IsClientObserver(iPlayerIndex)) - { - - /** - Not a spectator so display the swapmode menu. - */ - DisplaySwapModeMenu(client, iPlayerIndex); - } - else - { - - /** - The player is a spectator. - We make sure the player is not set to switch on death, since a spec can't die. - */ - g_aPlayers[iPlayerIndex][bQueue] = false; - } - } - - /** - We have figured out the second argument, lets check the third. - If should be the how the client wants to move the player: instant/on death. - */ - if (iCmdArgs >= 3) - { - - /** - The client gave us a command argument, lets check it. - */ - decl String:sSwapMode[5]; - GetCmdArg(3, sSwapMode, sizeof(sSwapMode)); - new iWantsQue = StringToInt(sSwapMode); - if (iWantsQue) - { - - /** - The client wants to que the player, set the global array. - */ - g_aPlayers[iPlayerIndex][bQueue] = true; - } - else - { - - /** - The client doesn't want to que the player, set the global array. - */ - g_aPlayers[iPlayerIndex][bQueue] = false; - } - } - else - { - /** - No swapmode argument, display the menu - */ - DisplaySwapModeMenu(client, iPlayerIndex); - } - - if (iCmdArgs >= 4) - { - - /** - Since we are compiling for Simple Team Balancer, and given a 4th argument, lets check it. - If should be the if the client wants to force the player to that team. - */ - decl String:sPlayerForced[5]; - GetCmdArg(4, sPlayerForced, sizeof(sPlayerForced)); - new iForceHim = StringToInt(sPlayerForced); - if (iForceHim) - { - - /** - The client wants to force the player - */ - SM_SetForcedTeam(iPlayerIndex, g_aPlayers[iPlayerIndex][iNewTeam]); - } - else - { - - /** - The client doesn't want to force the player - */ - SM_ClearForcedTeam(iPlayerIndex); - } - } - else - { - - } - - /** - We found and processed all the arguments. - */ - if (!IsPlayerAlive(iPlayerIndex)) - { - - /** - The player is not alive or died during this process so we just move him. - */ - SM_MovePlayer(iPlayerIndex, g_aPlayers[iPlayerIndex][iNewTeam]); - } - else - { - if (!g_aPlayers[iPlayerIndex][bQueue]) - { - - /** - The player is alive and is not set to be queued so we just move him. - */ - SM_MovePlayer(iPlayerIndex, g_aPlayers[iPlayerIndex][iNewTeam]); - } - } - - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_ScrambleTeams(client, args) -{ - - /** - Make sure we are enabled, if not bug out. - */ - if (!g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - Make sure the client is authorized to run this command. - */ - decl String:sFlags[5]; - GetConVarString(stm_adminflag_scramble, sFlags, sizeof(sFlags)); - if (!SM_IsValidAdmin(client, sFlags)) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check if a scramble timer was already called, if so close it down. - */ - if (g_hTimerPrepScramble != INVALID_HANDLE) - { - CloseHandle(g_hTimerPrepScramble); - g_hTimerPrepScramble = INVALID_HANDLE; - } - - /** - Check if we have any command arguments. - If we don't we display the scramble menu and bug out. - */ - new iCmdArgs = GetCmdArgs(); - if (iCmdArgs == 0) - { - DisplayScrambleMenu(client); - return Plugin_Handled; - } - - /** - We have a command argument. - It should be whether or not to scramble at round end. - */ - decl String:sRoundEnd[5]; - GetCmdArg(1, sRoundEnd, sizeof(sRoundEnd)); - if (StringToInt(sRoundEnd)) - { - /** - The client wants to scramble at round end so we set the global bool. - */ - g_bScrambleRoundEnd = true; - } - else - { - g_bScrambleRoundEnd = false; - } - - /** - Check for another command argument. - It should be whether or not to restart the round. - */ - decl String:sRestartRound[5]; - new bool:bRestartRound = false; - GetCmdArg(1, sRestartRound, sizeof(sRestartRound)); - if (StringToInt(sRestartRound)) - { - bRestartRound = true; - } - - /** - Now we start the scramble timer. - */ - StartScrambleTimer(_, bRestartRound); - - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_VoteScramble(client, args) -{ - - /** - Make sure we are enabled, if not bug out. - */ - if (!g_bVoteEnabled || !g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - Make sure there is a vote in progress, if so bug out. - */ - if (IsVoteInProgress()) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "VoteInProgress", LANG_SERVER); - return Plugin_Handled; - } - - /** - Make sure enough time has passed since the last vote. - */ - new iVoteTime = RoundFloat(GetEngineTime()); - if (iVoteTime - g_iLastVoteTime <= g_iVoteDelay) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "ScrambleTime", LANG_SERVER); - return Plugin_Handled; - } - - /** - Enough time has passed so reset the global vote time to now. - */ - g_iLastVoteTime = iVoteTime; - - /** - Build the vote menu and send it to everyone. - */ - new Handle:hMenu = CreateMenu(Menu_VoteScramble); - SetMenuTitle(hMenu, "Scramble Teams?"); - AddMenuItem(hMenu, VOTE_YES, "Yes"); - AddMenuItem(hMenu, VOTE_NO, "No"); - SetMenuExitButton(hMenu, false); - VoteMenuToAll(hMenu, 20); - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -/* HOOKED EVENTS */ - -public HookPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Find out who died. - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - - /** - Find out how the client died. - */ - new String:sWeapon[64]; - GetEventString(event, "weapon", sWeapon, sizeof(sWeapon)); - if (StrEqual(sWeapon, "world", false)) - { - - /** - He died because he changed teams so cleanup and bug out. - */ - s_CleanUp(iClient); - return; - } - - /** - Find out if this player was queued to change teams. - */ - if (g_aPlayers[iClient][bQueue]) - { - /** - Looks like he was, so call the stock function to move him. - */ - SM_MovePlayer(iClient, g_aPlayers[iClient][iNewTeam]); - } -} - -public HookPlayerChangeTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Find out who changed teams. - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - - /** - If he was queued to switch teams we cleanup the variables. The client did it themself. - */ - if (g_aPlayers[iClient][bQueue]) - { - s_CleanUp(iClient); - } -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get the amount of time left in the map. - */ - new iTimeLeft; - GetMapTimeLeft(iTimeLeft); - - /** - Check to see if we are supposed to scramble at the end of the round and that there is enough time left in the map. - */ - if (g_bScrambleRoundEnd && iTimeLeft >= 60) - { - - /** - Check to see if there is a scramble timer in action and if so close it down. - */ - if (g_hTimerPrepScramble != INVALID_HANDLE) - { - CloseHandle(g_hTimerPrepScramble); - g_hTimerPrepScramble = INVALID_HANDLE; - } - - /** - Determine the round end chat time and run the scramble 1 second before it ends. - */ - new Float:fDelay = GetConVarFloat(stm_mp_bonusroundtime); - fDelay -= 1.0; - StartScrambleTimer(fDelay); - } -} - -public OnClientPostAdminCheck(client) -{ - - /** - Determine if the client has the flag to use the swapteam command. - */ - decl String:sFlags[5]; - GetConVarString(stm_adminflag_swapteam, sFlags, sizeof(sFlags)); - if (SM_IsValidAdmin(client, sFlags)) - { - /** - The client does so lets create a timer to run an advertise to tell him about it. - */ - CreateTimer (60.0, Timer_WelcomeAdvert, client); - } -} - -public OnClientDisconnect(client) -{ - - /** - Cleanup the clients variables. - */ - s_CleanUp(client); -} - -public SM_OnPlayerMoved(Handle:plugin, client, team) -{ - - /** - Make sure we called the move function - */ - if (plugin != GetMyHandle()) - { - if (g_bLogActivity) - { - LogAction(0, client, "[STM] Callback was not started with current plugin, bugging out."); - } - return; - } - - decl String:sPlayerName[64]; - GetClientName(client, sPlayerName, sizeof(sPlayerName)); - - PrintToChat(client, "\x01\x04[SM]\x01 %T", "PlayerSwitched", LANG_SERVER); - - s_CleanUp(client); -} - -/* TIMER FUNCTIONS */ - -public Action:Timer_PrepTeamScramble(Handle:timer, any:data) -{ - new bool:bRestartRound = data; - /** - Call the scramble the teams stock function. - */ - PrepTeamScramble(bRestartRound); - - /** - Reset the timer handle so we know the timer is done. - */ - g_hTimerPrepScramble = INVALID_HANDLE; - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Timer_ScrambleTheTeams(Handle:timer, any:data) -{ - new iPlayers[MAXPLAYERS + 1]; - new iCount, i, bool:bTeam, bool:bRestartRound = data; - - /** - Get all the client index numbers of valid players - */ - for(i = 1; i <= MaxClients; i++) - { - if(IsClientInGame(i)) // && !IsFakeClient(i)) - { - iPlayers[iCount++] = i; - } - } - - /** - Randomly sort the players - */ - SortIntegers(iPlayers, iCount, Sort_Random); - - /** - Loop through all the players and assign each one to a team, alternating each time - */ - for(i = 0; i < iCount; i++) - { - if (!bRestartRound) - { - /** - We didn't want to restart the round, so we move them to spec 1 at a time. - */ - SM_MovePlayer(iPlayers[i], g_aCurrentTeams[Spectator]); - } - SM_MovePlayer(iPlayers[i], bTeam ? g_aCurrentTeams[Team2] : g_aCurrentTeams[Team1]); - SM_SetForcedTeam(iPlayers[i], bTeam ? g_aCurrentTeams[Team2] : g_aCurrentTeams[Team1], true); - bTeam = !bTeam; - } - - /** - Reset this variable since we completed a scramble - */ - g_bScrambleRoundEnd = false; - - if (g_hTimerClearScrambleForce != INVALID_HANDLE) - { - CloseHandle(g_hTimerClearScrambleForce); - g_hTimerClearScrambleForce = INVALID_HANDLE; - } - - g_hTimerClearScrambleForce = CreateTimer(300.0, Timer_ClearScrambleForce, _, TIMER_FLAG_NO_MAPCHANGE); - - ServerCommand("mp_timelimit %i", g_iTimeLeft / 60); - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Timer_ClearScrambleForce(Handle:timer, any:data) -{ - - for(new i = 1; i <= MaxClients; i++) - { - if(IsClientInGame(i)) // && !IsFakeClient(i)) - { - SM_ClearForcedTeam(i); - PrintToChat(i, "\x01\x04[SM]\x01 Your forced team status has been cleared"); - } - } - - g_hTimerClearScrambleForce = INVALID_HANDLE; - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Timer_WelcomeAdvert(Handle:timer, any:client) -{ - - /** - Lets make sure the client is connected and actually in the game. - */ - if (IsClientConnected(client) && IsClientInGame(client)) - { - - /** - We are good to go so lets tell him about the swapteam command. - */ - PrintToChat (client, "\x01\x04[STM]\x01 %T", "SwapTeamMsg", LANG_SERVER); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -/* STOCK FUNCTIONS */ - -stock s_CleanUp(iClient) -{ - - /** - Reset all the client variables - */ - g_aPlayers[iClient][bQueue] = false; - g_aPlayers[iClient][iNewTeam] = 0; -} - -stock StartScrambleTimer(Float:fdelay = 0.0, bool:bRestartRound = false) -{ - if (fdelay == 0.0) - { - fdelay = g_fScrambleDelay; - } - if (g_hTimerPrepScramble != INVALID_HANDLE) - { - CloseHandle(g_hTimerPrepScramble); - g_hTimerPrepScramble = INVALID_HANDLE; - } - PrintCenterTextAll("%T", "Scramble", LANG_SERVER); - g_hTimerPrepScramble = CreateTimer(fdelay, Timer_PrepTeamScramble, bRestartRound, TIMER_FLAG_NO_MAPCHANGE); -} - -stock PrepTeamScramble(bool:bRestartRound = false) -{ - new iPlayers[MAXPLAYERS + 1]; - new iCount; - - GetMapTimeLeft(g_iTimeLeft); - - if (bRestartRound) - { - - for(new i = 1; i <= MaxClients; i++) - { - if(IsClientInGame(i)) - // && !IsFakeClient(i)) - { - iPlayers[iCount++] = i; - SM_ClearForcedTeam(i); - SM_ClearBuddy(i); - SM_MovePlayer(i, g_aCurrentTeams[Spectator]); - } - } - } - else - { - //Can't move them all to spec at the same time - for(new i = 1; i <= MaxClients; i++) - { - if(IsClientInGame(i)) - // && !IsFakeClient(i)) - { - iPlayers[iCount++] = i; - SM_ClearForcedTeam(i); - SM_ClearBuddy(i); - //SM_MovePlayer(i, g_aCurrentTeams[Spectator]); - } - } - } - CreateTimer(4.0, Timer_ScrambleTheTeams, bRestartRound, TIMER_FLAG_NO_MAPCHANGE); -} - -/* CONSOLE VARIABLE CHANGE EVENT */ - -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (convar == stm_enabled) { - if (StringToInt(newValue) == 0) { - g_bIsEnabled = false; - LogAction(0, -1, "[STM] Simple Team Manager is loaded and disabled."); - } else { - g_bIsEnabled = true; - LogAction(0, -1, "[STM] Simple Team Manager is loaded and enabled."); - } - } - else if (convar == stm_logactivity) { - if (StringToInt(newValue) == 0) { - g_bLogActivity = false; - LogAction(0, -1, "[STM] Log Activity DISABLED."); - } else { - g_bLogActivity = true; - LogAction(0, -1, "[STM] Log Activity ENABLED."); - } - } - else if (convar == stm_scrambledelay) - g_fScrambleDelay = StringToFloat(newValue); - else if (convar == stm_votewin) - g_fVoteWin = StringToFloat(newValue); - else if (convar == stm_votedelay) - g_iVoteDelay = StringToInt(newValue); - else if (convar == stm_voteenabled) { - if (StringToInt(newValue) == 0) - g_bVoteEnabled = false; - else - g_bVoteEnabled = true; - } -} - -/* MENU CODE */ - -public OnAdminMenuReady(Handle:topmenu) -{ - if (topmenu == g_hAdminMenu) - return; - g_hAdminMenu = topmenu; - new TopMenuObject:player_commands = FindTopMenuCategory(g_hAdminMenu, ADMINMENU_PLAYERCOMMANDS); - new TopMenuObject:server_commands = FindTopMenuCategory(g_hAdminMenu, ADMINMENU_SERVERCOMMANDS); - if (player_commands == INVALID_TOPMENUOBJECT) - return; - - AddToTopMenu(g_hAdminMenu, - "moveplayer", - TopMenuObject_Item, - AdminMenu_MovePlayer, - player_commands, - "moveplayer", - ADMFLAG_BAN); - - AddToTopMenu(g_hAdminMenu, - "scrambleteams", - TopMenuObject_Item, - AdminMenu_Scrambleteams, - server_commands, - "scrambleteams", - ADMFLAG_BAN); -} - -public AdminMenu_MovePlayer(Handle:topmenu, TopMenuAction:action, TopMenuObject:object_id, param, String:buffer[], maxlength) -{ - if (action == TopMenuAction_DisplayOption) - Format(buffer, maxlength, "Move Player"); - else if (action == TopMenuAction_SelectOption){ - DisplayPlayerMenu(param); - } -} - -public AdminMenu_Scrambleteams(Handle:topmenu, TopMenuAction:action, TopMenuObject:object_id, param, String:buffer[], maxlength) -{ - if (action == TopMenuAction_DisplayOption) - Format(buffer, maxlength, "Scramble Teams"); - else if (action == TopMenuAction_SelectOption) { - DisplayScrambleMenu(param); - } -} - -public Menu_SelectPlayer(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - DisplayTeamMenu(param1, GetClientOfUserId(StringToInt(sSelection))); - } else if (action == MenuAction_Cancel) { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -public Menu_SelectTeam(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new iTeam; - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - decl String:sIndex[64]; - if (SplitString(sSelection, "A", sIndex, sizeof(sIndex)) != -1) - iTeam = g_aCurrentTeams[Team1]; - else if (SplitString(sSelection, "B", sIndex, sizeof(sIndex)) != -1) - iTeam = g_aCurrentTeams[Team2]; - else { - SplitString(sSelection, "C", sIndex, sizeof(sIndex)); - iTeam = g_aCurrentTeams[Spectator]; - } - new iTarget = StringToInt(sIndex); - g_aPlayers[iTarget][iNewTeam] = iTeam; - DisplaySwapModeMenu(param1, iTarget); - } else if (action == MenuAction_Cancel) { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -public Menu_SwapMode(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - decl String:sIndex[64]; - - if (SplitString(sSelection, "A", sIndex, sizeof(sIndex)) == -1) - { - SplitString(sSelection, "B", sIndex, sizeof(sIndex)); - } - - new iTarget = StringToInt(sIndex); - - if (StrContains(sSelection, "A", true) != -1) - { - g_aPlayers[iTarget][bQueue] = false; - } - else if (StrContains(sSelection, "B", true) != -1) - { - g_aPlayers[iTarget][bQueue] = true; - } - - if (param1 == iTarget && !g_aPlayers[iTarget][bQueue]) - { - SM_MovePlayer(iTarget, g_aPlayers[iTarget][iNewTeam]); - } - else - { - DisplayForceModeMenu(param1, iTarget); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - { - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } - return; -} - -public Menu_ForceMode(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - decl String:sIndex[64]; - if (SplitString(sSelection, "A", sIndex, sizeof(sIndex)) == -1) - { - SplitString(sSelection, "B", sIndex, sizeof(sIndex)); - } - new iTarget = StringToInt(sIndex); - if (StrContains(sSelection, "A", true) != -1) - { - SM_ClearForcedTeam(iTarget); - } - else if (StrContains(sSelection, "B", true) != -1) - { - SM_SetForcedTeam(iTarget, g_aPlayers[iTarget][iNewTeam], true); - } - if (!g_aPlayers[iTarget][bQueue]) - { - SM_MovePlayer(iTarget, g_aPlayers[iTarget][iNewTeam]); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - { - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } - return; -} - -public Menu_VoteScramble(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_VoteEnd) { - new winning_votes, total_votes; - GetMenuVoteInfo(param2, winning_votes, total_votes); - if (param1 == 0) { - if (float(total_votes) / float(winning_votes) < g_fVoteWin) { - PrintToChatAll("\x01\x04[SM]\x01 %T", "VoteScramble2", LANG_SERVER, winning_votes, total_votes); - return; - } - PrintCenterTextAll("[SM] %T", "Scramble", LANG_SERVER); - PrintToChatAll("\x01\x04[SM]\x01 %T", "VoteScramble1", LANG_SERVER, winning_votes, total_votes); - StartScrambleTimer(); - } - if (param1 == 1) { - PrintToChatAll("\x01\x04[SM]\x01 %T", "VoteScramble2", LANG_SERVER, winning_votes, total_votes); - } - } - if (action == MenuAction_End) - CloseHandle(menu); -} - -public Menu_ScrambleTeams(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "NOW", false)) - g_bScrambleRoundEnd = false; - else - g_bScrambleRoundEnd = true; - DisplayScrambleMenu2(param1); - } else if (action == MenuAction_Cancel) { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -public Menu_ScrambleTeams2(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[64]; - new bool:bRestartRound; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "NO", false)) - { - bRestartRound = false; - } - else - { - bRestartRound = true; - } - StartScrambleTimer(_, bRestartRound); - } else if (action == MenuAction_Cancel) { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -stock DisplayScrambleMenu(iClient) -{ - new Handle:hMenu = CreateMenu(Menu_ScrambleTeams); - SetMenuTitle(hMenu, "Select When to Scramble:"); - AddMenuItem(hMenu, "NOW", "Instantly"); - AddMenuItem(hMenu, "END", "At Round End"); - SetMenuExitBackButton(hMenu, false); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} - -stock DisplayScrambleMenu2(iClient) -{ - new Handle:hMenu = CreateMenu(Menu_ScrambleTeams2); - SetMenuTitle(hMenu, "Select When to Scramble:"); - AddMenuItem(hMenu, "NO", "No Round Restart"); - AddMenuItem(hMenu, "YES", "Restart Round"); - SetMenuExitBackButton(hMenu, false); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} - -stock DisplaySwapModeMenu(iClient, iTarget) -{ - new Handle:hMenu = CreateMenu(Menu_SwapMode); - decl String:optionA[64]; - decl String:optionB[64]; - Format(optionA, sizeof(optionA), "%iA", iTarget); - Format(optionB, sizeof(optionB), "%iB", iTarget); - SetMenuTitle(hMenu, "Select When to Swap:"); - AddMenuItem(hMenu, optionA, "Instantly (Kills)"); - if (!IsClientObserver(iTarget)) - AddMenuItem(hMenu, optionB, "Queue on next death"); - SetMenuExitBackButton(hMenu, false); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} - -stock DisplayForceModeMenu(iClient, iTarget) -{ - new Handle:hMenu = CreateMenu(Menu_ForceMode); - decl String:optionA[64]; - decl String:optionB[64]; - Format(optionA, sizeof(optionA), "%iA", iTarget); - Format(optionB, sizeof(optionB), "%iB", iTarget); - SetMenuTitle(hMenu, "Select Force Mode:"); - AddMenuItem(hMenu, optionA, "UnForced"); - AddMenuItem(hMenu, optionB, "Forced"); - SetMenuExitBackButton(hMenu, false); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} - -stock DisplayTeamMenu(iClient, iTarget) -{ - new Handle:hMenu = CreateMenu(Menu_SelectTeam); - decl String:optionA[64]; - decl String:optionB[64]; - decl String:optionC[64]; - Format(optionA, sizeof(optionA), "%iA", iTarget); - Format(optionB, sizeof(optionB), "%iB", iTarget); - Format(optionC, sizeof(optionC), "%iC", iTarget); - SetMenuTitle(hMenu, "Select Team:"); - AddMenuItem(hMenu, optionA, "Team One"); - AddMenuItem(hMenu, optionB, "Team Two"); - AddMenuItem(hMenu, optionC, "Spectator"); - SetMenuExitBackButton(hMenu, false); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} - -stock DisplayPlayerMenu(iClient) -{ - new Handle:hMenu = CreateMenu(Menu_SelectPlayer); - AddTargetsToMenu(hMenu, 0, true, false); - SetMenuTitle(hMenu, "Select A Player:"); - SetMenuExitBackButton(hMenu, true); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} diff --git a/Simple Spectate/addons/sourcemod/translations/simpledonatorbenefits.phrases.txt b/Simple Spectate/addons/sourcemod/translations/simpledonatorbenefits.phrases.txt deleted file mode 100644 index 3826846..0000000 --- a/Simple Spectate/addons/sourcemod/translations/simpledonatorbenefits.phrases.txt +++ /dev/null @@ -1,62 +0,0 @@ -"Phrases" -{ - "PlayerLevelCmd" - { - "en" "Command must be run at the player level" - "fr" "Cette commande doit être tapée en jeu" - "hu" "Ezt a parancsot jatekosi szinten kell futtatni!" - } - "RestrictedCmd" - { - "en" "You must be a donator or admin to run this command" - "fr" "Vous devez être un donateur ou un admin pour lancer cette commande" - "hu" "A parancs futtatasahoz admin, vagy tamogatoi szint szukseges!" - } - "InValidTeam" - { - "en" "You must be on red or blue to swap teams" - "fr" "Vous devez être RED ou BLU pour changer d'équipe" - "hu" "Jatekban kell lenned, hogy megcsereld a csapatokat!" - } - "PlayerQueue" - { - "en" "You have been queued to swap teams on next death" - "fr" "Vous avez été mis en attente pour changer d'équipe lors de votre prochaine mort" - "hu" "A kovetkezo halalnal csapatcsere lesz" - } - "PlayerSwitched" - { - "en" "Your team has been switched as requested" - "fr" "Vous avez changé d'équipe comme demandé" - "hu" "A keresnek eleget teve a csapatod meg lett csererlve" - } - "SwapTeamMsg" - { - "en" "Type /swapteam or !swapteam to swap your team!" - } - "ReachedCount" - { - "en" "You have reached your health limit. You must die before you can use it again" - } - "AtMaxHealth" - { - "en" "You are already at your maximum health!" - } - "ToMaxHealth" - { - "en" "Instant health bonus applied! You are not at your maximun health!" - } - "HealthBonus" - { - "en" "Instant health bonus applied!" - } - "PublicJoinMessage" - { - "#format" "{1:s}" - "en" "{1} a [donator] as joined the server" - } - "PrivateJoinMessage" - { - "en" "Thanks for donating!" - } -} \ No newline at end of file diff --git a/Simple Spectate/addons/sourcemod/translations/simpleteambalancer.phrases.txt b/Simple Spectate/addons/sourcemod/translations/simpleteambalancer.phrases.txt deleted file mode 100644 index 03595fd..0000000 --- a/Simple Spectate/addons/sourcemod/translations/simpleteambalancer.phrases.txt +++ /dev/null @@ -1,130 +0,0 @@ -"Phrases" -{ - "UnBalanced" - { - "en" "Teams are unbalanced and will be balanced shortly" - "fr" "Les équipes ne sont pas équilibrées et le seront bientôt" - "de" "Die Teams sind ungleich und werden in Kürze ausgeglichen" - "hu" "A csapatok nem kiegyenlitettek! Egyensuly beallitas kovetkezik!" - } - "Enabled" - { - "en" "Simple Team Balancer is ENABLED" - "fr" "Simple Team Balancer est ACTIVE" - "de" "Simple Team Balancer ist AKTIV" - "hu" "Az Egyszeru Csapat Egyensulytarto AKTIV!" - } - "Disabled" - { - "en" "Simple Team Balancer is DISABLED" - "fr" "Simple Team Balancer est DESACTIVE" - "de" "Simple Team Balancer ist INAKTIV" - "hu" "Az Egyszeru Csapat Egyensulytarto INAKTIV!" - } - "PlayerMessage" - { - "#format" "{1:i}" - "en" "You are going to be auto balanced in {1} seconds unless a dead player can be found" - "fr" "Vous passerez dans l'autre équipe dans {1} secondes si aucun joueur mort ne peut être trouvé dans cet intervalle" - "de" "Du wirst in {1} Sekunden zum automatischen Ausgleich herangezogen wenn kein toter Spieler gefunden werden kann" - "hu" "{1} masodpercen belul at leszel helyezve a masik csapatba, hacsak nem lesz addig egy halott jatekos!" - } - "BalanceMessage" - { - "#format" "{1:s}" - "en" "{1} was moved to the other team for game balance" - "fr" "{1} est passé dans l'autre équipe pour équilibrer la partie" - "de" "{1} wurde zum anderen Team verschoben um das Spiel auszugleichen" - "hu" "{1} at lett helyezve az egyensuly megtartasa erdekeben." - } - "PlayerLevelCmd" - { - "en" "Command must be run at the player level" - "fr" "La commande doit être lancée au niveau du joueur" - "de" "Das Kommando muss auf Spieler Ebene ausgeführt werden" - "hu" "Jatekosi szinten kell futtatni ezt a parancsot!" - } - "CmdDisabled" - { - "en" "Command is currently disabled" - "fr" "La commande est actuellement désactivée" - "de" "Das Kommando ist momentan inaktiv" - "hu" "A parancs jelenleg inaktiv" - } - "RestrictedBuddy" - { - "en" "You must be a donator or admin to add a balance buddy" - "fr" "Vous devez être un donateur ou un admin pour choisir un partenaire" - "de" "Du musst ein Spender oder Admin sein um einen Partner wählen zu können" - "hu" "Tamogato vagy admin kell hogy legyel, hogy 'Tarsat' jelolhess meg" - } - "SelectSelf" - { - "en" "You cannot be your own buddy" - "fr" "Vous ne pouvez pas être votre propre partenaire" - "de" "Du kannst nicht dein eigener Partner sein" - "hu" "Nem valaszthatod ki onmagad!" - } - "BuddyGone" - { - "en" "Your selected buddy has disconnected" - "fr" "Le partenaire que vous avez sélectionné s'est déconnecté" - "de" "Dein gewählter Partner hat die Verbindung getrennt" - "hu" "A valasztott 'Tarsad' kilepett" - } - "BuddyMsg" - { - "#format" "{1:s}" - "en" "You and {1} are now buddies" - "fr" "Vous et {1} êtes maintenant partenaires" - "de" "Du und {1} seid jetzt Partner" - "hu" "{1} es Te 'Tarsak' vagytok." - } - "BuddyLockMsgDisabled" - { - "en" "You can now be anyone's buddy" - "fr" "Vous pouvez à présent être le partenaire de n'importe qui" - "de" "Du kannst jetzt jedermanns Partner sein" - "hu" "Barkinek lehetsz a 'Tarsa'." - } - "BuddyLockMsgEnabled" - { - "en" "Buddy selection locked. Only you can change your buddy" - "fr" "Sélection de partenaire bloquée. Vous êtes le seul à pouvoir choisir votre partenaire" - "de" "Wahl des Partners gesperrt. Nur du kannst deinen Partner wechseln" - "hu" "Tars-lista lezarva. Csak Te tudod modositani a Tars-listadat." - } - "PlayerLockedBuddyMsg" - { - "#format" "{1:s}" - "en" "{1} has locked his buddy selection. Try again" - "fr" "{1} a bloqué sa sélection de partenaire. Essayez de nouveau." - "de" "{1} hat seine Wahl des Partners gesperrt. Versuche es erneut" - "hu" "{1} lezarta a Tars-listajat. Probald kesobb!" - } - "BuddyWelcomeMsg1" - { - "en" "Select a balance buddy and stay together during an autobalance!" - "fr" "Choisissez un partenaire et restez ensemble durant l'équilibrage automatique!" - "de" "Wähle einen Partner und bleibt zusammen während eines Ausgleichs" - "hu" "Valasz ki egy 'Tarsat' akivel egyuttmaradhatsz a csapatkiegyenlites alatt!" - } - "BuddyWelcomeMsg2" - { - "en" "/buddy or !buddy to select a balance buddy" - "fr" "/buddy or !buddy pour choisir un partenaire" - "de" "/buddy oder !buddy um einen Partner zu wählen" - "hu" "Hasznald a /buddy vagy !buddy parancsokat a 'Tars' kijelolesehez" - } - "BuddyWelcomeMsg3" - { - "en" "/lockbuddy or !lockbuddy to lock your selection" - "fr" "/lockbuddy or !lockbuddy pour bloquer votre sélection" - "de" "/lockbuddy oder !lockbuddy um deine Auswahl zu sperren" - "hu" "Hasznald a /lockbuddy vagy a !lockbuddy parancsokat a Tars-listad lezarasahoz" - } -} - - - - diff --git a/Simple Spectate/addons/sourcemod/translations/simpleteammanager.phrases.txt b/Simple Spectate/addons/sourcemod/translations/simpleteammanager.phrases.txt deleted file mode 100644 index f2093a7..0000000 --- a/Simple Spectate/addons/sourcemod/translations/simpleteammanager.phrases.txt +++ /dev/null @@ -1,92 +0,0 @@ -"Phrases" -{ - "PlayerLevelCmd" - { - "en" "Command must be run at the player level" - "fr" "Cette commande doit être tapée en jeu" - "hu" "Ezt a parancsot jatekosi szinten kell futtatni!" - } - "RestrictedCmd" - { - "en" "You must be a donator or admin to run this command" - "fr" "Vous devez être un donateur ou un admin pour lancer cette commande" - "hu" "A parancs futtatasahoz admin, vagy tamogatoi szint szukseges!" - } - "InValidTeam" - { - "en" "You must be on red or blue to swap teams" - "fr" "Vous devez être RED ou BLU pour changer d'équipe" - "hu" "Jatekban kell lenned, hogy megcsereld a csapatokat!" - } - "PlayerInValidTeam" - { - "en" "Player must be on red or blue to swap teams" - "fr" "Le joueur doit être RED ou BLU pour changer d'équipe" - "hu" "Valamelyik csapatban kell lenni, hogy csere legyen" - } - "PlayerQueue" - { - "en" "You have been queued to swap teams on next death" - "fr" "Vous avez été mis en attente pour changer d'équipe lors de votre prochaine mort" - "hu" "A kovetkezo halalnal csapatcsere lesz" - } - "PlayerSwitched" - { - "en" "Your team has been switched" - } - "PlayerSwitched1" - { - "en" "Your team has been switched as requested" - "fr" "Vous avez changé d'équipe comme demandé" - "hu" "A keresnek eleget teve a csapatod meg lett csererlve" - } - "PlayerSwitched2" - { - "en" "Your team has been switched by an Admin" - "fr" "Vous avez été changé d'équipe par un admin" - "hu" "Az Admin megcserelte a csapatodat!" - } - "SwapTeamMsg" - { - "en" "Type /swapteam or !swapteam to swap your team!" - } - "PlayerSwitched3" - { - "#format" "{1:s}" - "en" "{1}'s team has been switched" - "fr" "{1} a changé d'équipe" - "hu" "{1} csapata meg lett cserelve" - } - "Scramble" - { - "en" "Teams are about to be scrambled!" - "fr" "Les équipes vont être rééquilibrés" - "hu" "A csapatok hamarosan meg lesznek keverve!" - } - "VoteScramble1" - { - "#format" "{1:i}{2:i}" - "en" "Vote Scramble successful with {1} votes out of {2}" - "fr" "Le vote d'équilibrage des équipes a réussi avec {1} votes pour sur {2}" - "hu" "A szavazas sikeres volt, {1} szavazat a keveresre a {2} -bol" - } - "VoteScramble2" - { - "#format" "{1:i}{2:i}" - "en" "Vote Scramble failed with {1} votes out of {2}" - "fr" "Le vote d'équilibrage a échoué avec {1} votes pour sur {2}" - "hu" "A szavazas sikertelen volt, {1} szavazat a keveresre a {2} -bol" - } - "VoteInProgress" - { - "en" "A vote is currently in progress" - "fr" "Un vote est actuellement en cours" - "hu" "Egy szavazas mar fut!" - } - "ScrambleTime" - { - "en" "A vote was recently made, please wait" - "fr" "Un vote a déjà été fait récemment, réessayez plus tard" - "hu" "Nemreg volt szavazas, kerlek varj egy kicsit!" - } -} \ No newline at end of file diff --git a/Simple Team Balancer/addons/sourcemod/configs/simple-alltalkmanager_events.cfg b/Simple Team Balancer/addons/sourcemod/configs/simple-alltalkmanager_events.cfg deleted file mode 100644 index b739cf0..0000000 --- a/Simple Team Balancer/addons/sourcemod/configs/simple-alltalkmanager_events.cfg +++ /dev/null @@ -1,43 +0,0 @@ -"game_events" -{ - "teamplay_round_start" - { - "reason" "Round Start" - "setting" "1" - } - "teamplay_setup_finished" - { - "reason" "Setup Period Ended" - "setting" "0" - } - "teamplay_overtime_begin" - { - "reason" "Overtime Began" - "setting" "1" - } - "teamplay_overtime_end" - { - "reason" "Overtime Ended" - "setting" "1" - } - "teamplay_round_win" - { - "reason" "Round Ended" - "setting" "1" - } - "teamplay_suddendeath_begin" - { - "reason" "Sudden Death Began" - "setting" "1" - } - "teamplay_suddendeath_end" - { - "reason" "Sudden Death Ended" - "setting" "1" - } - "teamplay_round_stalemate" - { - "reason" "Stalemate" - "setting" "1" - } -} \ No newline at end of file diff --git a/Simple Team Balancer/addons/sourcemod/configs/simple-chatcolors.cfg b/Simple Team Balancer/addons/sourcemod/configs/simple-chatcolors.cfg deleted file mode 100644 index 14b98c6..0000000 --- a/Simple Team Balancer/addons/sourcemod/configs/simple-chatcolors.cfg +++ /dev/null @@ -1,15 +0,0 @@ -"admin_colors" -{ - "groupname2" - { - "flag" "z" - "namecolor" "{green}" - "textcolor" "{olive}" - } - "groupname1" - { - "flag" "a" - "namecolor" "{teamcolor}" - "textcolor" "{green}" - } -} \ No newline at end of file diff --git a/Simple Team Balancer/addons/sourcemod/plugins/simple-alltalkmanager.smx b/Simple Team Balancer/addons/sourcemod/plugins/simple-alltalkmanager.smx deleted file mode 100644 index 6122756..0000000 Binary files a/Simple Team Balancer/addons/sourcemod/plugins/simple-alltalkmanager.smx and /dev/null differ diff --git a/Simple Team Balancer/addons/sourcemod/plugins/simple-donatorbenefits.smx b/Simple Team Balancer/addons/sourcemod/plugins/simple-donatorbenefits.smx deleted file mode 100644 index 821d61d..0000000 Binary files a/Simple Team Balancer/addons/sourcemod/plugins/simple-donatorbenefits.smx and /dev/null differ diff --git a/Simple Team Balancer/addons/sourcemod/plugins/simple-messagesuppression.smx b/Simple Team Balancer/addons/sourcemod/plugins/simple-messagesuppression.smx deleted file mode 100644 index cc20dad..0000000 Binary files a/Simple Team Balancer/addons/sourcemod/plugins/simple-messagesuppression.smx and /dev/null differ diff --git a/Simple Team Balancer/addons/sourcemod/plugins/simple-plugins.smx b/Simple Team Balancer/addons/sourcemod/plugins/simple-plugins.smx deleted file mode 100644 index ac307a3..0000000 Binary files a/Simple Team Balancer/addons/sourcemod/plugins/simple-plugins.smx and /dev/null differ diff --git a/Simple Team Balancer/addons/sourcemod/plugins/simple-spectate.smx b/Simple Team Balancer/addons/sourcemod/plugins/simple-spectate.smx deleted file mode 100644 index c6885b0..0000000 Binary files a/Simple Team Balancer/addons/sourcemod/plugins/simple-spectate.smx and /dev/null differ diff --git a/Simple Team Balancer/addons/sourcemod/plugins/simple-teambalancer.smx b/Simple Team Balancer/addons/sourcemod/plugins/simple-teambalancer.smx index 95beb01..7b10a4f 100644 Binary files a/Simple Team Balancer/addons/sourcemod/plugins/simple-teambalancer.smx and b/Simple Team Balancer/addons/sourcemod/plugins/simple-teambalancer.smx differ diff --git a/Simple Team Balancer/addons/sourcemod/plugins/simple-teammanager.smx b/Simple Team Balancer/addons/sourcemod/plugins/simple-teammanager.smx deleted file mode 100644 index 81905ba..0000000 Binary files a/Simple Team Balancer/addons/sourcemod/plugins/simple-teammanager.smx and /dev/null differ diff --git a/Simple Team Balancer/addons/sourcemod/scripting/include/simple-plugins.inc b/Simple Team Balancer/addons/sourcemod/scripting/include/simple-plugins.inc deleted file mode 100644 index 8f21956..0000000 --- a/Simple Team Balancer/addons/sourcemod/scripting/include/simple-plugins.inc +++ /dev/null @@ -1,337 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Plugins -Description: - Included file for core plugin in the Simple Plugins project -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -*************************************************************************/ - -#if defined _simpleplugin_included - #endinput -#endif - -#define _simpleplugin_included - -#define CORE_INC_VERSION "1.1.$Rev$" - -#pragma semicolon 1 -#include -#undef REQUIRE_PLUGIN -#include -#define REQUIRE_PLUGIN -#undef REQUIRE_EXTENSIONS -#undef AUTOLOAD_EXTENSIONS -#tryinclude -#tryinclude -#tryinclude -#define AUTOLOAD_EXTENSIONS -#define REQUIRE_EXTENSIONS - -enum e_SupportedMods -{ - GameType_Unknown, - GameType_AOC, - GameType_CSS, - GameType_DOD, - GameType_FF, - GameType_HIDDEN, - GameType_HL2DM, - GameType_INS, - GameType_L4D, - GameType_NEO, - GameType_SGTLS, - GameType_TF, - GameType_ZPS -}; - -enum e_Teams -{ - Unknown, - Spectator, - Team1, - Team2 -}; - -new g_aCurrentTeams[e_Teams]; -new e_SupportedMods:g_CurrentMod; -new String:g_sGameName[e_SupportedMods][32] = { "Unknown", - "Age of Chivalry", - "Counter Strike", - "Day Of Defeat", - "Fortress Forever", - "Hidden: Source", - "Half Life 2: Deathmatch", - "Insurgency", - "Left 4 Dead", - "Neotokyo", - "Stargate TLS", - "Team Fortress 2", - "Zombie Panic: Source" - }; - -public SharedPlugin:_pl_simpleplugin = -{ - name = "simple-plugins", - file = "simple-plugins.smx", -#if defined REQUIRE_PLUGIN - required = 1 -#else - required = 0 -#endif -}; - -#if !defined REQUIRE_PLUGIN -public _pl_simpleplugin_SetNTVOptional() -{ - MarkNativeAsOptional("SM_MovePlayer"); - MarkNativeAsOptional("SM_SetForcedTeam"); - MarkNativeAsOptional("SM_GetForcedTeam"); - MarkNativeAsOptional("SM_ClearForcedTeam"); - MarkNativeAsOptional("SM_GetForcedPlayer"); - MarkNativeAsOptional("SM_AssignBuddy"); - MarkNativeAsOptional("SM_SearchBuddy"); - MarkNativeAsOptional("SM_LockBuddy"); - MarkNativeAsOptional("SM_IsBuddyLocked"); - MarkNativeAsOptional("SM_ClearBuddy"); - MarkNativeAsOptional("SM_IsValidAdmin"); - MarkNativeAsOptional("SM_IsValidTeam"); -} -#endif - -/********************************************************************** - * When a player has to moved - * - * @param plugin Plugin that initiated the move - * @param client The client index of the player that was moved - * @param team The team index the player was moved to - * @noreturn - **********************************************************************/ -forward SM_OnPlayerMoved(Handle:plugin, client, team); - -/********************************************************************** - * Move a player to the supplied team - * - * @param client The client index of the player to be moved - * @param team The team to move the player to - * @noreturn - * @error Invalid client or team index - **********************************************************************/ -native SM_MovePlayer(client, team); - -/********************************************************************** - * Move a player to the supplied team - * - * @param client The client index of the player to set - * @param team The team to move the to set - * @param override Whether or not to override another plugin - * @return True if successful, false if not - * @error Invalid client or team index - **********************************************************************/ -native SM_SetForcedTeam(client, team, bool:override = false); - -/********************************************************************** - * Gets the client's forced team index - * - * @param client The client index of the player to check - * @param plugin Optional: The plugin handle of the plugin - that set the team - * @return The team index of the forced team - Zero if no forced team - * @error Invalid client index - **********************************************************************/ -native SM_GetForcedTeam(client, &Handle:plugin = INVALID_HANDLE); - -/********************************************************************** - * Clears a client's forced team - * - * @param client The client index of the player to check - * @return True if successful, false if not - * @error Invalid client index - **********************************************************************/ -native SM_ClearForcedTeam(client); - -/********************************************************************** - * Gets a forced player on the wrong that is currently on the wrong team - * This will only return a player if the calling plugin assigned the team - * - * @param team The team index the player should be on - * @return The client index of the player - Zero if no player found - * @error Invalid client index - **********************************************************************/ -native SM_GetForcedPlayer(team); - -/********************************************************************** - * Assign a players buddy - * - * @param client The client index of the player to assign - * @param player The player index of the player to assign - * @param override Whether or not to override a player lock - * @return True if successful, false if not - * @error Invalid client or player index - **********************************************************************/ -native bool:SM_AssignBuddy(client, player, bool:override = false); - -/********************************************************************** - * Rturns the client's buddy - * - * @param client The client index of the player to assign - * @return The client index of the player's buddy - Zero if no buddy - * @error Invalid client index - **********************************************************************/ -native SM_GetClientBuddy(client); - -/********************************************************************** - * Set the buddy lock setting for a client - * - * @param client The client index of the player to assign - * @param setting Setting to set, True or False - * @return True if successful, false if not - * @error Invalid client index - **********************************************************************/ -native bool:SM_LockBuddy(client, bool:setting); - -/********************************************************************** - * Returns the buddy lock setting for a client - * - * @param client The client index of the player to assign - * @return True if locked, false if not - * @error Invalid client index - **********************************************************************/ -native bool:SM_IsBuddyLocked(client); - -/********************************************************************** - * Clear a players buddy - * - * @param client The client index of the player to clear - * @param override Whether or not to override a player lock - * @return True if successful, false if not - * @error Invalid client index - **********************************************************************/ -native bool:SM_ClearBuddy(client, bool:override = false); - -/********************************************************************** - * Determine if the player has the supplied flags - * ADMFLAG_ROOT will always return true - * - * @param client The client index of the player to assign - * @param flags The char flag(s) to check against - * @return True if valid, false if not - **********************************************************************/ -native bool:SM_IsValidAdmin(client, const String:flags[]); - - -/********************************************************************** - * Determine if the team is a valid team - * - * @param team The team index to determine if valid for - currently installed/supported mod - * @return True if valid, false if not - **********************************************************************/ -native bool:SM_IsValidTeam(team); - - -public e_SupportedMods:GetCurrentMod() -{ - new String:sGameType[64]; - GetGameFolderName(sGameType, sizeof(sGameType)); - - if (StrEqual(sGameType, "aoc", false)) - { - return GameType_AOC; - } - if (StrEqual(sGameType, "cstrike", false)) - { - return GameType_CSS; - } - if (StrEqual(sGameType, "dod", false)) - { - return GameType_DOD; - } - if (StrEqual(sGameType, "ff", false)) - { - return GameType_FF; - } - if (StrEqual(sGameType, "hidden", false)) - { - return GameType_HIDDEN; - } - if (StrEqual(sGameType, "hl2mp", false)) - { - return GameType_FF; - } - if (StrEqual(sGameType, "insurgency", false) || StrEqual(sGameType, "ins", false)) - { - return GameType_INS; - } - if (StrEqual(sGameType, "l4d", false)) - { - return GameType_L4D; - } - if (StrEqual(sGameType, "nts", false)) - { - return GameType_NEO; - } - if (StrEqual(sGameType, "sgtls", false)) - { - return GameType_SGTLS; - } - if (StrEqual(sGameType, "tf", false)) - { - return GameType_TF; - } - if (StrEqual(sGameType, "zps", false)) - { - return GameType_ZPS; - } - return GameType_Unknown; -} - -public LoadCurrentTeams() -{ - switch (g_CurrentMod) - { - case GameType_INS: - { - g_aCurrentTeams[Unknown] = 0; - g_aCurrentTeams[Spectator] = 3; - g_aCurrentTeams[Team1] = 1; - g_aCurrentTeams[Team2] = 2; - } - case default: - { - g_aCurrentTeams[Unknown] = 0; - g_aCurrentTeams[Spectator] = 1; - g_aCurrentTeams[Team1] = 2; - g_aCurrentTeams[Team2] = 3; - } - } -} diff --git a/Simple Team Balancer/addons/sourcemod/scripting/simple-alltalkmanager.sp b/Simple Team Balancer/addons/sourcemod/scripting/simple-alltalkmanager.sp deleted file mode 100644 index c848332..0000000 --- a/Simple Team Balancer/addons/sourcemod/scripting/simple-alltalkmanager.sp +++ /dev/null @@ -1,515 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple AllTalk Manager -Description: - Allows you to set alltalk at different times -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#pragma semicolon 1 -#include -#include - -#define PLUGIN_VERSION "1.4.$Rev$" - -new Handle:satm_enabled = INVALID_HANDLE; -new Handle:satm_threshold_enabled = INVALID_HANDLE; -new Handle:satm_player_threshold = INVALID_HANDLE; -new Handle:satm_threshold_setting = INVALID_HANDLE; -new Handle:satm_logactivity = INVALID_HANDLE; -new Handle:satm_alltalk = INVALID_HANDLE; - -new Handle:g_aEventNames = INVALID_HANDLE; -new Handle:g_aEventReasons = INVALID_HANDLE; -new Handle:g_aEventSettings = INVALID_HANDLE; - -new bool:g_bLastThreshold = false; -new bool:g_bEnabled = true; -new bool:g_bThresholdEnabled = true; -new bool:g_bIsSetupMap = false; -new bool:g_bIsGameTF2 = false; -new bool:g_bLogActivity = false; - -new g_iLastEventIndex; - -public Plugin:myinfo = -{ - name = "Simple AllTalk Manager", - author = "Simple Plugins", - description = "Allows you to set alltalk at different times", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -} - -/** -Sourcemod callbacks -*/ -public OnPluginStart() -{ - - /** - Need to create all of our console variables. - */ - CreateConVar("satm_version", PLUGIN_VERSION, "Simple AllTalk Manager", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - satm_enabled = CreateConVar("satm_enabled", "1", "Enables/Disables Simple AllTalk Manager", _, true, 0.0, true, 1.0); - satm_threshold_enabled = CreateConVar("satm_threshold_enabled", "1", "Enables/Disables player threshold", _, true, 0.0, true, 1.0); - satm_player_threshold = CreateConVar("satm_player_threshold", "8", "Amount of players for the threshold"); - satm_threshold_setting = CreateConVar("satm_threshold_setting", "1", "Enables/Disables all talk up to player threshold, with the opposite set after the threshold", _, true, 0.0, true, 1.0); - satm_logactivity = CreateConVar("satm_logactivity", "0", "Enables/Disables log activity", _, true, 0.0, true, 1.0); - satm_alltalk = FindConVar("sv_alltalk"); - - /** - Hook console variables - */ - HookConVarChange(satm_enabled, ConVarSettingsChanged); - HookConVarChange(satm_threshold_enabled, ConVarSettingsChanged); - HookConVarChange(satm_player_threshold, ConVarSettingsChanged); - HookConVarChange(satm_logactivity, ConVarSettingsChanged); - - /** - Remove the notify flag from all talk cvar since we do it - */ - SetConVarFlags(satm_alltalk, GetConVarFlags(satm_alltalk)~FCVAR_NOTIFY); - - /** - Get the game type. We only care if it's TF2 - */ - new String:sGameType[64]; - GetGameFolderName(sGameType, sizeof(sGameType)); - if (StrEqual(sGameType, "tf", false)) - { - g_bIsGameTF2 = true; - } - - /** - Create the arrays - */ - g_aEventNames = CreateArray(255, 1); - g_aEventReasons = CreateArray(255, 1); - g_aEventSettings = CreateArray(1, 1); - - /** - Need to register the commands we are going to create and use. - */ - RegAdminCmd("sm_reloadatconfig", Command_Reload, ADMFLAG_GENERIC, "Reloads settings from config file"); - - /** - Create the config file - */ - AutoExecConfig(true); - - /** - Load the events from the config - */ - LoadEventsFromConfig(); -} - -public OnConfigsExecuted() -{ - - /** - Load up the settings - */ - g_bEnabled = GetConVarBool(satm_enabled); - g_bLogActivity = GetConVarBool(satm_logactivity); - g_bThresholdEnabled = GetConVarBool(satm_threshold_enabled); -} - -public OnMapStart() -{ - - /** - Reset the globals - */ - g_iLastEventIndex = 0; - g_bLastThreshold = false; - - /** - Check the map type if we are in TF2 - */ - if (g_bIsGameTF2) - { - g_bIsSetupMap = IsSetupPeriodMap(); - } - - /** - Set AllTalk - */ - if (g_bEnabled) - { - SetConVarBool(satm_alltalk, true); - } -} - -public OnClientDisconnect_Post(client) -{ - if (g_bEnabled) - { - SetAllTalk(-1); - } -} - -public OnClientPostAdminCheck(client) -{ - if (g_bEnabled) - { - SetAllTalk(-1); - } - CreateTimer(2.0, Timer_ShowAllTalkStatus, client, TIMER_FLAG_NO_MAPCHANGE); -} - -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (convar == satm_enabled) - { - if (StringToInt(newValue)) - { - g_bEnabled = true; - } - else - { - g_bEnabled = false; - } - } - else if (convar == satm_threshold_enabled) - { - if (StringToInt(newValue)) - { - g_bThresholdEnabled = true; - } - else - { - g_bThresholdEnabled = false; - } - } - else if (convar == satm_logactivity) - { - if (StringToInt(newValue)) - { - g_bLogActivity = true; - } - else - { - g_bLogActivity = false; - } - } - if (g_bEnabled) - { - SetAllTalk(-1); - } -} - -/** -Commands -*/ -public Action:Command_Reload(client, args) -{ - - /** - Clear the array - */ - ClearArray(g_aEventNames); - ClearArray(g_aEventReasons); - ClearArray(g_aEventSettings); - - /** - Load the events from the config - */ - LoadEventsFromConfig(); - - return Plugin_Handled; -} - -/** -Game Event Hooks -*/ -public Hook_All_Events(Handle:event, const String:name[], bool:dontBroadcast) -{ - if (!g_bIsSetupMap) - { - if (StrEqual(name, "teamplay_round_start")) - { - if (FindStringInArray(g_aEventNames, "teamplay_setup_finished") != -1) - { - g_iLastEventIndex = FindStringInArray(g_aEventNames, "teamplay_setup_finished"); - if (g_bEnabled) - { - SetAllTalk(g_iLastEventIndex); - return; - } - } - } - } - g_iLastEventIndex = FindStringInArray(g_aEventNames, name); - if (g_bEnabled) - { - SetAllTalk(g_iLastEventIndex); - } -} - -/** -Timers -*/ -public Action:Timer_ShowAllTalkStatus(Handle:timer, any:client) -{ - if (IsClientConnected(client) && IsClientInGame(client)) - { - new bool:bSetting = GetConVarBool(satm_alltalk); - if (bSetting) - { - PrintToChat(client, "\x01\x04[SM] AllTalk is \x01[on]"); - } - else - { - PrintToChat(client, "\x01\x04[SM] AllTalk is \x01[off]"); - } - } -} - -/** -Stock Functions -*/ -stock LoadEventsFromConfig() -{ - - /** - Make sure the config file is here and load it up - */ - new String:sConfigFile[256]; - BuildPath(Path_SM, sConfigFile, sizeof(sConfigFile), "configs/simple-alltalkmanager_events.cfg"); - if (!FileExists(sConfigFile)) - { - - /** - Config file doesn't exists, stop the plugin - */ - LogError("[SATM] Simple AllTalk Manager is not running! Could not find file %s", sConfigFile); - SetFailState("Could not find file %s", sConfigFile); - } - - /** - Create the arrays and variables - */ - new String:sGameEventName[256]; - new String:sReason[256]; - new iSetting; - - /** - Load config file as a KeyValues file - */ - new Handle:kvGameEvents = CreateKeyValues("game_events"); - FileToKeyValues(kvGameEvents, sConfigFile); - - if (!KvGotoFirstSubKey(kvGameEvents)) - { - return; - } - - /** - Hook the game events and load the settings - */ - do - { - - /** - Get the section name; this should be the event name - */ - KvGetSectionName(kvGameEvents, sGameEventName, sizeof(sGameEventName)); - if (!HookEventEx(sGameEventName, Hook_All_Events, EventHookMode_PostNoCopy)) - { - - /** - Could not hook this event, stop the plugin - */ - SetFailState("Could not hook event %s", sGameEventName); - } - else - { - if (g_bLogActivity) - { - LogMessage("[SATM] Hooked event: %s", sGameEventName); - } - } - - /** - Get the reason string and setting - */ - KvGetString(kvGameEvents, "reason", sReason, sizeof(sReason)); - iSetting = KvGetNum(kvGameEvents, "setting"); - if (g_bLogActivity) - { - LogMessage("[SATM] Event reason string: %s", sReason); - LogMessage("[SATM] Event setting: %i", iSetting); - } - - /** - Push the values to the arrays - */ - PushArrayString(g_aEventNames, sGameEventName); - PushArrayString(g_aEventReasons, sReason); - PushArrayCell(g_aEventSettings, iSetting); - } while (KvGotoNextKey(kvGameEvents)); - - /** - Close our handle - */ - CloseHandle(kvGameEvents); -} - -stock SetAllTalk(index) -{ - new iPlayerThreshold = GetConVarInt(satm_player_threshold); - new bool:bThresholdMet = ((GetClientCount() >= iPlayerThreshold) ? true : false); - new bool:bSetting; - - if (g_bThresholdEnabled) - { - if (bThresholdMet) - { - if (index == -1) - { - if (bThresholdMet != g_bLastThreshold) - { - g_bLastThreshold = true; - bSetting = !GetConVarBool(satm_threshold_setting); - new bool:bLastSetting = GetArrayCell(g_aEventSettings, g_iLastEventIndex); - if (bLastSetting && !bSetting) - { - bSetting = GetArrayCell(g_aEventSettings, g_iLastEventIndex); - } - } - else - { - bSetting = GetArrayCell(g_aEventSettings, g_iLastEventIndex); - } - } - else - { - bSetting = GetArrayCell(g_aEventSettings, index); - } - } - else - { - g_bLastThreshold = false; - bSetting = GetConVarBool(satm_threshold_setting); - } - } - else - { - if (index != -1) - { - bSetting = GetArrayCell(g_aEventSettings, index); - } - } - - if (GetConVarBool(satm_alltalk) != bSetting) - { - - SetConVarBool(satm_alltalk, bSetting); - - new String:sReason[256]; - if (index == -1) - { - Format(sReason, sizeof(sReason), "Player Threshold"); - } - else - { - if (!g_bIsSetupMap) - { - new String:sCurrentEvent[256]; - GetArrayString(g_aEventNames, index, sCurrentEvent, sizeof(sCurrentEvent)); - if (StrEqual(sCurrentEvent, "teamplay_setup_finished")) - { - new iRoundStartIndex = FindStringInArray(g_aEventNames, "teamplay_round_start"); - if (iRoundStartIndex != -1) - { - GetArrayString(g_aEventReasons, iRoundStartIndex, sReason, sizeof(sReason)); - } - else - { - GetArrayString(g_aEventReasons, index, sReason, sizeof(sReason)); - } - } - else - { - GetArrayString(g_aEventReasons, index, sReason, sizeof(sReason)); - } - } - else - { - GetArrayString(g_aEventReasons, index, sReason, sizeof(sReason)); - } - } - - if (bSetting) - { - PrintToChatAll("\x01\x04[SM] AllTalk turned \x01[on] \x04due to:\x01 %s", sReason); - } - else - { - PrintToChatAll("\x01\x04[SM] AllTalk turned \x01[off] \x04due to:\x01 %s", sReason); - } - } -} - -stock bool:IsSetupPeriodMap() -{ - new iEnt = -1; - new String:sMapName[32]; - - GetCurrentMap(sMapName, sizeof(sMapName)); - - if (strncmp(sMapName, "cp_", 3, false) == 0) - { - new iTeam; - while ((iEnt = FindEntityByClassname(iEnt, "team_control_point")) != -1) - { - iTeam = GetEntProp(iEnt, Prop_Send, "m_iTeamNum"); - - /** - If there is a blu CP or a neutral CP, then it's not an attack/defend map - */ - if (iTeam != 2) - { - //this is a push map - return false; - } - } - //this is a attack/defend map - return true; - } - else if (strncmp(sMapName, "ctf_", 3, false) == 0) - { - //this is a ctf map - return false; - } - return false; -} diff --git a/Simple Team Balancer/addons/sourcemod/scripting/simple-autoscrambler.sp b/Simple Team Balancer/addons/sourcemod/scripting/simple-autoscrambler.sp deleted file mode 100644 index 6c6799e..0000000 --- a/Simple Team Balancer/addons/sourcemod/scripting/simple-autoscrambler.sp +++ /dev/null @@ -1,459 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple AutoScrambler -Description: - Automatically scrambles the teams based upon a number of events. -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include - -#define PLUGIN_VERSION "1.1.$Rev$" - -/** -Different scramble modes: - -1 = Full Scramble, dont restart round. -2 = Admins Immune, dont restart round. -3 = Full Scramble, restart round and reset scores. -4 = Admins Immune, restart round and reset scores. - -*/ - -/** -Different top player modes: - -1 = Divide Top 4 players on the two teams. -2 = Protect the Top 2 players on each team. - -*/ - -enum PlayerData -{ - Handle:hForcedTimer, - bool:bProtected; -}; - -/** -Cvars used for admins -*/ -new Handle: sas_admin_immunity_enabled = INVALID_HANDLE, - Handle: sas_admin_flag_scramblenow = INVALID_HANDLE, - Handle: sas_admin_flag_immunity = INVALID_HANDLE; - -/** -Cvars used for autoscramble -*/ -new Handle: sas_autoscramble_enabled = INVALID_HANDLE, - Handle: sas_autoscramble_minplayers = INVALID_HANDLE, - Handle: sas_autoscramble_mode = INVALID_HANDLE, - Handle: sas_autoscramble_winstreak = INVALID_HANDLE, - Handle: sas_autoscramble_steamroll = INVALID_HANDLE, - Handle: sas_autoscramble_frags = INVALID_HANDLE; - -/** -Cvars used for voting -*/ -new Handle: sas_vote_enabled = INVALID_HANDLE, - Handle: sas_vote_upcount = INVALID_HANDLE, - Handle: sas_vote_winpercent = INVALID_HANDLE, - Handle: sas_vote_mode = INVALID_HANDLE, - Handle: sas_vote_minplayers = INVALID_HANDLE; - -/** -Additional cvars -*/ -new Handle: sas_enabled = INVALID_HANDLE, - Handle: sas_timer_scrambledelay = INVALID_HANDLE, - Handle: TFGameModeArena = INVALID_HANDLE; - -/** -Timers -*/ -new Handle: g_hScrambleTimer = INVALID_HANDLE; - -/** - Player arrays - */ -new g_aPlayers[MAXPLAYERS + 1][PlayerData]; - -/** - Cvar variables - */ -new bool: g_bIsEnabled, - bool: g_bIsAutoScrambleEnabled, - bool: g_bIsVoteEnabled, - bool: g_bIsAdminImmunityEnabled; -new Float: g_fTimer_ScrambleDelay, - Float: g_fVote_UpCount, - Float: g_fVote_WinPercent; -new g_iAutoScramble_Minplayers, - g_iAutoScramble_Mode, - g_iAutoScramble_WinStreak, - g_iAutoScramble_SteamRoll, - g_iAutoScramble_Frags, - g_iVote_Mode, - g_iVote_MinPlayers; -new String: g_sScrambleNowFlag[5], - String: g_sAdminImmunityFlag[5]; - -/** -Other globals -*/ -new g_iMaxEntities, - g_iOwnerOffset; - -public Plugin:myinfo = -{ - name = "Simple AutoScrambler", - author = "Simple Plugins", - description = "Automatically scrambles the teams based upon a number of events.", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -}; - -public OnPluginStart() -{ - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook the game events - */ - LogAction(0, -1, "[SAS] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - switch (g_CurrentMod) - { - case GameType_TF: - { - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - } - case GameType_DOD: - { - HookEvent("dod_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_Post); - } - default: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_Post); - } - } - - /** - Create console variables - */ - CreateConVar("sas_version", PLUGIN_VERSION, "Simple AutoScrambler Version",FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - sas_enabled = CreateConVar("sas_enabled", "1", "Enable/Disable Simple AutoScrambler"); - sas_timer_scrambledelay = CreateConVar("sas_timer_scrambledelay", "5.0", "Delay used after a scramble has been started", _, true, 1.0, true, 30.0); - - /** - Cvars used for admins - */ - sas_admin_immunity_enabled = CreateConVar("sas_admin_immunity_enabled", "1", "Enable/Disable admin immunity for scrambles"); - sas_admin_flag_scramblenow = CreateConVar("sas_admin_flag_scramblenow", "z", "Admin flag to use for scramblenow function/command"); - sas_admin_flag_immunity = CreateConVar("sas_admin_flag_immunity", "z", "Admin flag to use for scramble immunity"); - - /** - Cvars used for autoscramble - */ - sas_autoscramble_enabled = CreateConVar("sas_autoscramble_enabled", "1", "Enable/Disable the autoscramble function"); - sas_autoscramble_minplayers = CreateConVar("sas_autoscramble_minplayers", "16", "Min players needed to start an autoscramble"); - sas_autoscramble_mode = CreateConVar("sas_autoscramble_mode", "1", "Scramble mode used when autoscrambling"); - sas_autoscramble_winstreak = CreateConVar("sas_autoscramble_winstreak", "5", "Max amount of wins in a row a team can achieve before an autoscramble starts"); - sas_autoscramble_steamroll = CreateConVar("sas_autoscramble_steamroll", "120", "Shortest amount of time a team can win by before an autoscramble starts (seconds)"); - sas_autoscramble_frags = CreateConVar("sas_autoscramble_frags", "1", "Min players needed to start a vote and scramble"); - - /** - Cvars used for voting - */ - sas_vote_enabled = CreateConVar("sas_vote_enabled", "1", "Enable/Disable voting for scramble"); - sas_vote_upcount = CreateConVar("sas_vote_upcount", "5", "Amount of people wanting a scramble before a vote starts. If less than 1 it will be considered a percentage. (ie 0.5 = 50% | 1 = 1 Player | 5 = 5 Players)"); - sas_vote_winpercent = CreateConVar("sas_vote_winpercent", "0.6", "Percentage of votes needed to scramble", _, true, 0.0, true, 1.0); - sas_vote_mode = CreateConVar("sas_vote_mode", "1", "Scramble mode used when a vote results in a scramble"); - sas_vote_minplayers = CreateConVar("sas_vote_minplayers", "16", "Min players needed to start a vote and scramble"); - - /** - Hook the console variables if they change - */ - HookConVarChange(sas_enabled, ConVarSettingsChanged); - HookConVarChange(sas_timer_scrambledelay, ConVarSettingsChanged); - HookConVarChange(sas_admin_immunity_enabled, ConVarSettingsChanged); - HookConVarChange(sas_admin_flag_scramblenow, ConVarSettingsChanged); - HookConVarChange(sas_admin_flag_immunity, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_enabled, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_minplayers, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_mode, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_winstreak, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_steamroll, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_frags, ConVarSettingsChanged); - HookConVarChange(sas_vote_enabled, ConVarSettingsChanged); - HookConVarChange(sas_vote_upcount, ConVarSettingsChanged); - HookConVarChange(sas_vote_winpercent, ConVarSettingsChanged); - HookConVarChange(sas_vote_mode, ConVarSettingsChanged); - HookConVarChange(sas_vote_minplayers, ConVarSettingsChanged); - - /** - Register the command - */ - RegConsoleCmd("sm_scramblenow", Command_ScrambleNow, "sm_scramblenow (mode): Scrambles the teams"); - - /** - Load translations and .cfg file - */ - LoadTranslations ("simpleautoscrambler.phrases"); - AutoExecConfig(true, "plugin.simpleautoscrambler"); - LogAction(0, -1, "[SAS] Simple AutoScrambler is loaded."); -} - -public OnAllPluginsLoaded() -{ - //something -} - -public OnLibraryRemoved(const String:name[]) -{ - //something -} - -public OnConfigsExecuted() -{ - - /** - Load up all the variable defaults - */ - LoadUpVariables(); - - /** - Log our activity - */ - if (g_bIsEnabled) - LogAction(0, -1, "Simple AutoScrambler is ENABLED"); - else - LogAction(0, -1, "Simple AutoScrambler is DISABLED"); -} - -public Action:Command_ScrambleNow(client, args) -{ - - /** - Make sure we are enabled - */ - if (!g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - Make sure the client is authorized to run this command. - */ - if (!SM_IsValidAdmin(client, g_sScrambleNowFlag)) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Make sure it's ok to scramble at this time - */ - if (!OkToScramble) - { - return Plugin_Handled; - } - - /** - Make sure it's ok to scramble at this time - */ - LogAction(0, -1, "[SAS] The scramblenow command was used"); - - /** - Scramble the teams - */ - StartAScramble(); - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public HookRoundStart(Handle:event, const String:name[], bool:dontBroadcast) -{ - -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - -} - -public Action:Timer_ScrambleTeams(Handle:timer, any:mode) -{ - - /** - Make sure it's still ok to scramble - */ - if (!OkToScramble) - { - return Plugin_Handled; - } - - - switch (mode) - { - case - - - - } - - - /** - Reset the handle because the timer is over and the callback is done - */ - g_hScrambleTimer = INVALID_HANDLE; - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - -} - -stock StartAScramble(mode) -{ - - /** - See if we are already started a scramble - */ - if (g_hScrambleTimer == INVALID_HANDLE) - { - - /** - There is a scramble in progress - */ - return; - - } - - /** - Report that a scramble is about to start - */ - PrintCenterTextAll("%T", "Scramble", LANG_SERVER); - - /** - Start a timer and log the action - */ - g_hScrambleTimer = CreateTimer(g_fTimer_ScrambleDelay, Timer_ScrambleTeams, mode, TIMER_FLAG_NO_MAPCHANGE); - LogAction(0, -1, "[SAS] A scamble timer was started"); -} - -stock bool:OkToScramble() -{ - -} - -stock LoadUpVariables() -{ - g_bIsEnabled = GetConVarBool(sas_enabled); - g_bIsAutoScrambleEnabled = GetConVarBool(sas_autoscramble_enabled); - g_bIsVoteEnabled = GetConVarBool(sas_vote_enabled); - g_bIsAdminImmunityEnabled = GetConVarBool(sas_admin_immunity_enabled); - g_iAutoScramble_Minplayers = GetConVarInt(sas_autoscramble_minplayers); - g_iAutoScramble_Mode = GetConVarInt(sas_autoscramble_mode); - g_iAutoScramble_WinStreak = GetConVarInt(sas_autoscramble_winstreak); - g_iAutoScramble_SteamRoll = GetConVarInt(sas_autoscramble_steamroll); - g_iAutoScramble_Frags = GetConVarInt(sas_autoscramble_frags); - g_iVote_Mode = GetConVarInt(sas_vote_mode); - g_iVote_MinPlayers = GetConVarInt(sas_vote_minplayers); - GetConVarString(sas_admin_flag_scramblenow, g_sScrambleNowFlag, sizeof(g_sScrambleNowFlag)); - GetConVarString(sas_admin_flag_immunity, g_sAdminImmunityFlag, sizeof(g_sAdminImmunityFlag)); - g_fTimer_ScrambleDelay = GetConVarFloat(sas_timer_scrambledelay); - g_fVote_UpCount = GetConVarFloat(sas_vote_upcount); - g_fVote_WinPercent = GetConVarFloat(sas_vote_winpercent); - g_iMaxEntities = GetMaxEntities(); - g_iOwnerOffset = FindSendPropInfo("CBaseObject", "m_hBuilder"); -} - -stock TF2_DestroyBuildings(client) -{ - - /** - We have to start a loop to check the owner of all the valid entities - */ - for (new i = MaxClients + 1; i <= g_iMaxEntities; i++) - { - if (!IsValidEntity(i)) - { - - /** - Not valid, continue to next one - */ - continue; - } - - /** - Get the name of the current entity - */ - decl String:sNetClass[32]; - GetEntityNetClass(i, sNetClass, sizeof(sNetClass)); - - /** - See if its something that an engineer would build - */ - if (strcmp(sNetClass, "CObjectSentrygun") == 0 - || strcmp(sNetClass, "CObjectTeleporter") == 0 - || strcmp(sNetClass, "CObjectDispenser") == 0) - { - - /** - It is, so lets check the owner - */ - if (GetEntDataEnt2(i, g_iOwnerOffset) == client) - { - - /** - It's the clients building, so we blow it up. - */ - SetVariantInt(9999); - AcceptEntityInput(i, "RemoveHealth"); - } - } - } -} \ No newline at end of file diff --git a/Simple Team Balancer/addons/sourcemod/scripting/simple-chatcolors.sp b/Simple Team Balancer/addons/sourcemod/scripting/simple-chatcolors.sp deleted file mode 100644 index 539d057..0000000 --- a/Simple Team Balancer/addons/sourcemod/scripting/simple-chatcolors.sp +++ /dev/null @@ -1,496 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Chat Colors -Description: - Changes the colors of players chat based on config file -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#pragma semicolon 1 -#include -#include - -#define PLUGIN_VERSION "0.9.0.$Rev$" - -#define CHAT_SYMBOL '@' -#define TRIGGER_SYMBOL1 '!' -#define TRIGGER_SYMBOL2 '/' -#define CHAT_MAX_MESSAGE_LENGTH 1024 - -new Handle:g_hDebugCvar = INVALID_HANDLE; -new Handle:g_aGroupNames = INVALID_HANDLE; -new Handle:g_aGroupFlag = INVALID_HANDLE; -new Handle:g_aGroupNameColor = INVALID_HANDLE; -new Handle:g_aGroupTextColor = INVALID_HANDLE; - -new bool:g_bDebug = false; - -new g_iArraySize; - -new g_aPlayerColorIndex[MAXPLAYERS + 1] = { -1, ... }; - -public Plugin:myinfo = -{ - name = "Simple Chat Colors", - author = "Simple Plugins", - description = "Changes the colors of players chat based on config file.", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -}; - -/** -Sourcemod callbacks -*/ -public OnPluginStart() -{ - - /** - Need to create all of our console variables. - */ - CreateConVar("sm_chatcolors_version", PLUGIN_VERSION, "Simple Chat Colors", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - g_hDebugCvar = CreateConVar("sm_chatcolors_debug", "1", "Enable/Disable debugging information"); - - /** - Hook console variables - */ - HookConVarChange(g_hDebugCvar, ConVarSettingsChanged); - - /** - Need to register the commands we are going to use - */ - RegConsoleCmd("say", Command_Say); - RegConsoleCmd("say_team", Command_SayTeam); - RegAdminCmd("sm_reloadcolorsconfig", Command_Reload, ADMFLAG_GENERIC, "Reloads settings from config file"); - - /** - Create the arrays - */ - g_aGroupNames = CreateArray(256, 1); - g_aGroupFlag = CreateArray(15, 1); - g_aGroupNameColor = CreateArray(15, 1); - g_aGroupTextColor = CreateArray(15, 1); - - /** - Load the admins and colors from the config - */ - LoadAdminsAndColorsFromConfig(); - g_iArraySize = GetArraySize(g_aGroupNames); -} - -public OnConfigsExecuted() -{ - g_bDebug = GetConVarBool(g_hDebugCvar); - ReloadConfigFile(); -} - -public OnClientPostAdminCheck(client) -{ - - /** - Check the client to see if they are a admin - */ - CheckAdmin(client); -} - -public OnClientDisconnect(client) -{ - g_aPlayerColorIndex[client] = -1; -} - -/** -Commands -*/ -public Action:Command_Say(client, args) -{ - - /** - Make sure we are enabled. - */ - if (client == 0 || IsChatTrigger()) - { - return Plugin_Continue; - } - - if (g_aPlayerColorIndex[client] != -1) - { - - /** - The client is, so get the chat message and strip it down. - */ - decl String:sArg[CHAT_MAX_MESSAGE_LENGTH], - String:sChatMsg[CHAT_MAX_MESSAGE_LENGTH]; - - new bool:bAlive = IsPlayerAlive(client); - - GetCmdArgString(sArg, sizeof(sArg)); - StripQuotes(sArg); - TrimString(sArg); - new startidx; - if (sArg[strlen(sArg)-1] == '"') - { - sArg[strlen(sArg)-1] = '\0'; - startidx = 1; - } - - /** - Bug out if they are using the admin chat symbol (admin chat). If we are in CSS it may not find all the triggers, so we double check. - */ - if (sArg[startidx] == CHAT_SYMBOL || sArg[startidx] == TRIGGER_SYMBOL1 || sArg[startidx] == TRIGGER_SYMBOL2) - { - return Plugin_Continue; - } - - /** - Log the message for hlstatsx and other things. - */ - new iUserID = GetClientUserId(client); - decl String:sAuthID[64]; - GetClientAuthString(client, sAuthID, sizeof(sAuthID)); - LogToGame("\"%N<%i><%s><>\" say \"%s\"", client, iUserID, sAuthID, sArg); - - /** - Format the message. - */ - FormatMessage(client, 0, bAlive, sChatMsg, sArg, g_aPlayerColorIndex[client]); - - /** - Send the message. - */ - //SayText2(0, client, sChatMsg); - CPrintToChatAll(sChatMsg); - - /** - We are done, bug out, and stop the original chat message. - */ - return Plugin_Stop; - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -public Action:Command_SayTeam(client, args) -{ - - /** - Make sure we are enabled. - */ - if (client == 0 || IsChatTrigger()) - { - return Plugin_Continue; - } - - /** - Check the client to see if they are a admin - */ - if (g_aPlayerColorIndex[client] != -1) - { - - /** - The client is, so get the chat message and strip it down. - */ - decl String:sArg[CHAT_MAX_MESSAGE_LENGTH], - String:sChatMsg[CHAT_MAX_MESSAGE_LENGTH]; - - new bool:bAlive = IsPlayerAlive(client); - new iCurrentTeam = GetClientTeam(client); - - GetCmdArgString(sArg, sizeof(sArg)); - StripQuotes(sArg); - TrimString(sArg); - new startidx; - if (sArg[strlen(sArg)-1] == '"') - { - sArg[strlen(sArg)-1] = '\0'; - startidx = 1; - } - - /** - Bug out if they are using the admin chat symbol (admin chat). - */ - if (sArg[startidx] == CHAT_SYMBOL || sArg[startidx] == TRIGGER_SYMBOL1 || sArg[startidx] == TRIGGER_SYMBOL2) - { - return Plugin_Continue; - } - - /** - Log the message for hlstatsx and other things. - */ - new iUserID = GetClientUserId(client); - decl String:sAuthID[64]; - GetClientAuthString(client, sAuthID, sizeof(sAuthID)); - LogToGame("\"%N<%i><%s><>\" say_team \"%s\"", client, iUserID, sAuthID, sArg); - - /** - Format the message. - */ - FormatMessage(client, iCurrentTeam, bAlive, sChatMsg, sArg, g_aPlayerColorIndex[client]); - - /** - Send the message to the same team - */ - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientConnected(i) && IsClientInGame(i) && GetClientTeam(i) == iCurrentTeam) - { - CPrintToChat(client, sChatMsg); - } - } - - /** - We are done, bug out, and stop the original chat message. - */ - return Plugin_Stop; - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -public Action:Command_Reload(client, args) -{ - ReloadConfigFile(); - return Plugin_Handled; -} - -/** -Stock Functions -*/ -stock LoadAdminsAndColorsFromConfig() -{ - - /** - Make sure the config file is here and load it up - */ - new String:sConfigFile[256]; - BuildPath(Path_SM, sConfigFile, sizeof(sConfigFile), "configs/simple-chatcolors.cfg"); - if (!FileExists(sConfigFile)) - { - - /** - Config file doesn't exists, stop the plugin - */ - LogError("[SCC] Simple Chat Colors is not running! Could not find file %s", sConfigFile); - SetFailState("Could not find file %s", sConfigFile); - } - - /** - Create the arrays and variables - */ - new String:sGroupName[256]; - new String:sGroupFlag[15]; - new String:sGroupNameColor[15]; - new String:sGroupTextColor[15]; - - - /** - Load config file as a KeyValues file - */ - new Handle:kvChatColors = CreateKeyValues("admin_colors"); - FileToKeyValues(kvChatColors, sConfigFile); - - if (!KvGotoFirstSubKey(kvChatColors)) - { - return; - } - - /** - Load up all the groups in the file - */ - do - { - - /** - Get the section name; should be the "group" name - */ - KvGetSectionName(kvChatColors, sGroupName, sizeof(sGroupName)); - - - /** - Get the flags and colors - */ - KvGetString(kvChatColors, "flag", sGroupFlag, sizeof(sGroupFlag)); - KvGetString(kvChatColors, "namecolor", sGroupNameColor, sizeof(sGroupNameColor)); - KvGetString(kvChatColors, "textcolor", sGroupTextColor, sizeof(sGroupTextColor)); - - if (g_bDebug) - { - LogMessage("Group Name/SteamID: %s", sGroupName); - LogMessage("Flag String: %s", sGroupFlag); - LogMessage("Color on name: %s", sGroupNameColor); - LogMessage("Color of text: %s", sGroupTextColor); - } - - /** - Push the values to the arrays - */ - PushArrayString(g_aGroupNames, sGroupName); - PushArrayString(g_aGroupFlag, sGroupFlag); - PushArrayString(g_aGroupNameColor, sGroupNameColor); - PushArrayString(g_aGroupTextColor, sGroupTextColor); - } while (KvGotoNextKey(kvChatColors)); - - /** - Close our handle - */ - CloseHandle(kvChatColors); -} - -stock ReloadConfigFile() -{ - - /** - Clear the array - */ - ClearArray(g_aGroupNames); - ClearArray(g_aGroupFlag); - ClearArray(g_aGroupNameColor); - ClearArray(g_aGroupTextColor); - - /** - Load the admins, groups, and colors from the config - */ - LoadAdminsAndColorsFromConfig(); - g_iArraySize = GetArraySize(g_aGroupNames); - - /** - Recheck all the online players for assigned colors - */ - for (new index = 1; index <= MaxClients; index++) - { - if (IsClientConnected(index) && IsClientInGame(index)) - { - CheckAdmin(index); - } - } -} - -stock CheckAdmin(client) -{ - new String:sFlags[15]; - new String:sClientSteamID[64]; - new iGroupFlags; - new iFlags; - new iIndex = -1; - - /** - Look for a steamid first - */ - GetClientAuthString(client, sClientSteamID, sizeof(sClientSteamID)); - iIndex = FindStringInArray(g_aGroupNames, sClientSteamID); - if (iIndex != -1) - { - g_aPlayerColorIndex[client] = iIndex; - } - - /** - Didn't find one, check flags - */ - else - { - /** - Search for flag in groups - */ - - iFlags = GetUserFlagBits(client); - for (iIndex = 0; iIndex < g_iArraySize; iIndex++) - { - GetArrayString(g_aGroupFlag, iIndex, sFlags, sizeof(sFlags)); - iGroupFlags = ReadFlagString(sFlags); - if (iFlags & iGroupFlags) - { - g_aPlayerColorIndex[client] = iIndex; - break; - } - } - } - - if (g_bDebug) - { - PrintToChatAll("SteamID: %s", sClientSteamID); - PrintToChatAll("Array Index: %i", iIndex); - PrintToChatAll("Flag String: %s", sFlags); - PrintToChatAll("Flag Bits of Client: %i", iFlags); - PrintToChatAll("Flag Bits of Group: %i", iGroupFlags); - } -} - -stock FormatMessage(iClient, iTeam, bool:bAlive, String:sChatMsg[], const Sting:sMessage[], iArrayIndex) -{ - decl String:sDead[10], - String:sTeam[10], - String:sClientName[64]; - - GetClientName(iClient, sClientName, sizeof(sClientName)); - - if (iTeam != 0) - { - Format(sTeam, sizeof(sTeam), "(TEAM) "); - } - else - { - Format(sTeam, sizeof(sTeam), ""); - } - if (bAlive) - { - Format(sDead, sizeof(sDead), ""); - } - else - { - Format(sDead, sizeof(sDead), "*DEAD* "); - } - - new String:sNameColor[15]; - new String:sTextColor[15]; - GetArrayString(g_aGroupNameColor, iArrayIndex, sNameColor, sizeof(sNameColor)); - GetArrayString(g_aGroupTextColor, iArrayIndex, sTextColor, sizeof(sTextColor)); - - Format(sChatMsg, CHAT_MAX_MESSAGE_LENGTH, "{default}%s%s%s%s {default}: %s%s", sDead, sTeam, sNameColor, sClientName, sTextColor, sMessage); -} - -/** -Adjust the settings if a convar was changed -*/ -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (StringToInt(newValue) == 1) - { - g_bDebug = true; - } - else - { - g_bDebug = false; - } -} \ No newline at end of file diff --git a/Simple Team Balancer/addons/sourcemod/scripting/simple-donatorbenefits.sp b/Simple Team Balancer/addons/sourcemod/scripting/simple-donatorbenefits.sp deleted file mode 100644 index e3f6845..0000000 --- a/Simple Team Balancer/addons/sourcemod/scripting/simple-donatorbenefits.sp +++ /dev/null @@ -1,1312 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Donator Benefits -Description: - Provides donator benefits to players -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include -#include - -#define PLUGIN_VERSION "1.1.$Rev$" - -#define CHAT_SYMBOL '@' -#define CHAT_MAX_MESSAGE_LENGTH 1024 - -enum PlayerData -{ - bool:bIsDonator, - bool:bQueue, - bool:bImmune, - iHealthCount, - iNewTeam -}; - -/** - Public convar handles - */ -new Handle:sdb_enabled = INVALID_HANDLE; -new Handle:sdb_donationflag = INVALID_HANDLE; -new Handle:sdb_soundfile = INVALID_HANDLE; -new Handle:sdb_joinsound_enabled = INVALID_HANDLE; -new Handle:sdb_joinpubmsg_enabled = INVALID_HANDLE; -new Handle:sdb_joinprivmsg_enabled = INVALID_HANDLE; -new Handle:sdb_chatcolors_enabled = INVALID_HANDLE; -new Handle:sdb_immunity_enabled = INVALID_HANDLE; -new Handle:sdb_ubercharge_enabled = INVALID_HANDLE; -new Handle:sdb_givehealth_enabled = INVALID_HANDLE; -new Handle:sdb_nofalldmg_enabled = INVALID_HANDLE; -new Handle:sdb_fastheavy_enabled = INVALID_HANDLE; -new Handle:sdb_swapteam_enabled = INVALID_HANDLE; -new Handle:sdb_chatcolor = INVALID_HANDLE; -new Handle:sdb_uberlevel = INVALID_HANDLE; -new Handle:sdb_healthcount = INVALID_HANDLE; -new Handle:sdb_healthbonus = INVALID_HANDLE; -new Handle:sdb_heavymultiplier = INVALID_HANDLE; - -/** -Create global enable/disable bools so we don't have to check the console variable on every call -*/ -new bool:g_bIsEnabled = true; -new bool:g_bIsJoinSoundEnabled = true; -new bool:g_bIsJoinPubMsgEnabled = true; -new bool:g_bIsJoinPrivMsgEnabled = true; -new bool:g_bIsChatColorsEnabled = true; -new bool:g_bIsImmuntyEnabled = true; -new bool:g_bIsUberChargeEnabled = true; -new bool:g_bIsGiveHealthEnabled = true; -new bool:g_bIsNoFallDmgEnabled = true; -new bool:g_bIsFastHeayEnabled = true; -new bool:g_bIsSwapTeamEnabled = true; - -/** - Player arrays - */ -new g_aPlayers[MAXPLAYERS + 1][PlayerData]; - - -/** -Rest of the globals -*/ -new bool:g_bRoundEnd = false; -new String:g_sCharDonatorFlag[5]; -new String:g_sSoundFile[PLATFORM_MAX_PATH]; -new String:g_sChatColor[11]; -new g_iHealthBonus; -new g_iHealthCount; -new g_iClassMaxHealth[TFClassType] = {0, 125, 125, 200, 175, 150, 300, 175, 125, 125}; -new g_fClassMaxSpeed[TFClassType] = {0, 400, 300, 240, 280, 320, 230, 300, 300, 300}; -new Float:g_fHeavyMultiplier = 0.0; -new Float:g_fUberLevel = 0.0; - -public Plugin:myinfo = -{ - name = "Simple Donation Benefits", - author = "Simple Plugins", - description = "Gives donators benefits to players", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -} - -public OnPluginStart() -{ - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook the game events - */ - LogAction(0, -1, "[SDB] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_connect", HookPlayerSpawn, EventHookMode_Pre); - HookEvent("player_spawn", HookPlayerSpawn, EventHookMode_Post); - HookEvent("player_death", HookPlayerDeath, EventHookMode_Post); - HookEvent("player_team", HookPlayerChangeTeam, EventHookMode_Post); - switch (g_CurrentMod) - { - case GameType_TF: - { - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - HookEvent("player_changeclass", HookPlayerClass, EventHookMode_Post); - } - case GameType_DOD: - { - HookEvent("dod_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_Post); - } - default: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - } - } - - /** - Create console variables - */ - CreateConVar("sdb_version", PLUGIN_VERSION, "Simple Donation Benefits", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - sdb_enabled = CreateConVar("sdb_enabled", "1", "Enable/Disable Simple Donation Benefits"); - sdb_donationflag = CreateConVar("sdb_donationflag", "a", "Flag ALREADY given to donators. Must be in char format"); - - /** - Create the enable/disable donator console variables - */ - sdb_joinsound_enabled = CreateConVar("sdb_joinsound_enabled", "1", "Enable/Disable donator join sound"); - sdb_joinpubmsg_enabled = CreateConVar("sdb_joinpubmsg_enabled", "1", "Enable/Disable public donator join message (replaces: as connected)"); - sdb_joinprivmsg_enabled = CreateConVar("sdb_joinprivmsg_enabled", "1", "Enable/Disable private donator join message (sent only to donator)"); - sdb_chatcolors_enabled = CreateConVar("sdb_chatcolors_enabled", "1", "Enable/Disable donator chat colors"); - sdb_immunity_enabled = CreateConVar("sdb_immunity_enabled", "1", "Enable/Disable donator round end immunity"); - sdb_ubercharge_enabled = CreateConVar("sdb_ubercharge_enabled", "1", "Enable/Disable donator medics starting with ubercharge"); - sdb_givehealth_enabled = CreateConVar("sdb_givehealth_enabled", "1", "Enable/Disable donator instant health bonus"); - sdb_nofalldmg_enabled = CreateConVar("sdb_nofalldmg_enabled", "1", "Enable/Disable no fall damage for donators"); - sdb_fastheavy_enabled = CreateConVar("sdb_fastheavy_enabled", "1", "Enable/Disable donator heavies moving faster while spinning"); - sdb_swapteam_enabled = CreateConVar("sdb_swampteam_enabled", "1", "Enable/Disable donator swap team ability"); - - /** - Create the donator setting console variables - */ - sdb_soundfile = CreateConVar("sdb_soundfile", "custom/donatorjoin.mp3", "The location of sound file"); - sdb_chatcolor = CreateConVar("sdb_chatcolor", "green", "Color to use for donator chat. Valid colors are green and lightgreen"); - sdb_uberlevel = CreateConVar("sdb_uberlevel", "0.5", "Uberlevel to give donator medic at spawn. 1.0 = full uber", _, true, 0.0, true, 1.0); - sdb_healthcount = CreateConVar("sdb_healthcount", "1", "Number of times a donator can use use instant health per life"); - sdb_healthbonus = CreateConVar("sdb_healthbonus", "100", "The amount of health to heal the donator"); - sdb_heavymultiplier = CreateConVar("sdb_heavyspeed", "0.5", "The speed multiplier for the fast heavy. Based on running speed. 1.0 = running speed. (Game Default is 0.20)", _, true, 0.0, true, 1.0); - - /** - Hook dukehacks calls - */ - dhAddClientHook(CHK_TakeDamage, Hacks_TakeDamageHook); - dhAddClientHook(CHK_PreThink, Hacks_PreThinkHook); - - /** - Hook the console variables if they change - */ - HookConVarChange(sdb_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_donationflag, ConVarSettingsChanged); - HookConVarChange(sdb_joinsound_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_joinpubmsg_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_joinprivmsg_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_chatcolors_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_immunity_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_ubercharge_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_givehealth_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_nofalldmg_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_swapteam_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_fastheavy_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_soundfile, ConVarSettingsChanged); - HookConVarChange(sdb_chatcolor, ConVarSettingsChanged); - HookConVarChange(sdb_uberlevel, ConVarSettingsChanged); - HookConVarChange(sdb_healthcount, ConVarSettingsChanged); - HookConVarChange(sdb_healthbonus, ConVarSettingsChanged); - HookConVarChange(sdb_heavymultiplier, ConVarSettingsChanged); - - /** - Register the commands - */ - RegConsoleCmd("sm_swapteams", Command_SwapTeam, "sm_swapteams <[0]instant/[1]queued>: Swaps your team to the other team"); - RegConsoleCmd("sm_ihealth", Command_InstantHealth, "sm_ihealth: Gives you a instant health pack"); - RegAdminCmd("sm_teaser", Command_Teaser, ADMFLAG_GENERIC,"sm_teaser <[0]add/[1]remove>: Gives temporary donator privilages to a player"); - RegConsoleCmd("say", Command_Say); - - RegConsoleCmd("sm_test", Command_TEST); - - /** - Load the translations - */ - LoadTranslations("common.phrases"); - LoadTranslations("simpledonatorbenefits.phrases"); - - /** - Load or create the config file - */ - AutoExecConfig(true, "plugin.simpledonatorbenefits"); - LogAction(0, -1, "[SDB] Simple Donator Benefits is loaded."); -} - -public OnAllPluginsLoaded() -{ - //something -} - -public OnLibraryRemoved(const String:name[]) -{ - //something -} - -public OnConfigsExecuted() -{ - /** - Load up all the variable defaults - */ - LoadUpVariables(); - - /** - If the join sound is enabled, prep the sound files - */ - if (g_bIsJoinSoundEnabled) - PrepSoundFile(); - - /** - Log our activity - */ - if (g_bIsEnabled) - LogAction(0, -1, "Simple Donation Benefits is ENABLED"); - else - LogAction(0, -1, "Simple Donation Benefits is DISABLED"); -} - -public OnClientPostAdminCheck(client) -{ - - /** - Check if the client is a donator - */ - if (SM_IsValidAdmin(client, g_sCharDonatorFlag)) - { - - /** - They are, so we set the player array to true and start a timer for the sound or add - */ - g_aPlayers[client][bIsDonator] = true; - if (g_bIsJoinSoundEnabled || g_bIsJoinPrivMsgEnabled) - { - CreateTimer(10.0, Timer_DonatorJoined, client, TIMER_FLAG_NO_MAPCHANGE); - } - } - else - { - /** - They aren't, so we set the player array to false - */ - g_aPlayers[client][bIsDonator] = false; - } -} - -public OnClientDisconnect_Post(client) -{ - - /** - Clean up the player variables - */ - CleanUpPlayer(client); -} - -public Action:Command_SwapTeam(client, args) -{ - - /** - Make sure we are enabled - */ - if (!g_bIsEnabled || !g_bIsSwapTeamEnabled) - { - return Plugin_Handled; - } - - /** - Make sure the command is not started by the server - */ - if (client == 0) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "PlayerLevelCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Make sure the player is a donator - */ - if (!g_aPlayers[client][bIsDonator]) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Lets make sure the client is one a team we can swap. - If he is we set the global array to the opposite team. - */ - new iTeam = GetClientTeam(client); - if (iTeam == g_aCurrentTeams[Team1]) - { - g_aPlayers[client][iNewTeam] = g_aCurrentTeams[Team2]; - } - else if (iTeam == g_aCurrentTeams[Team2]) - { - g_aPlayers[client][iNewTeam] = g_aCurrentTeams[Team1]; - } - else - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "InValidTeam", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check to see if we have command arguments. - */ - if (GetCmdArgs()) - { - - /** - We do, so lets get it and see if the client wants to be switched instantly or queued for death. - */ - decl String:sArg[5]; - GetCmdArg(1, sArg, sizeof(sArg)); - new iWantsQue = StringToInt(sArg); - if (iWantsQue && !g_aPlayers[client][bQueue]) - { - - /** - He wants the que and isn't already in it, set the global array. - */ - g_aPlayers[client][bQueue] = true; - ReplyToCommand(client, "\x01\x04[STM]\x01 %T", "PlayerQueue", LANG_SERVER); - } - else if (!iWantsQue) - { - - /** - He wants to be switched right now, lets call the stock function. - */ - SM_MovePlayer(client, g_aPlayers[client][iNewTeam]); - } - } - else - { - - /** - There are no command arguments so we build and display the swap menu. - */ - new Handle:hPlayerMenu = BuildSwapModeMenu(); - DisplayMenu(hPlayerMenu, client, MENU_TIME_FOREVER); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_InstantHealth(client, args) -{ - - /** - Make sure we are enabled - */ - if (!g_bIsEnabled || !g_bIsGiveHealthEnabled) - { - return Plugin_Handled; - } - - /** - Make sure the command is not started by the server - */ - if (client == 0) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "PlayerLevelCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Make sure the player is a donator - */ - if (!g_aPlayers[client][bIsDonator]) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check health count to see if the player has reached the max - */ - if (g_aPlayers[client][iHealthCount] >= g_iHealthCount) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "ReachedCount", LANG_SERVER); - return Plugin_Handled; - } - - /** - Get the class of the player and the max health for that class - */ - new iHealth = GetClientHealth(client); - new TFClassType:PlayerClass = TF2_GetPlayerClass(client); - new iMaxHealth = g_iClassMaxHealth[PlayerClass]; - - /** - Check to see if the player is at the max health of the class - */ - if (iHealth >= iMaxHealth) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "AtMaxHealth", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check the current health - */ - if (iHealth + g_iHealthBonus >= iMaxHealth) - { - - /** - Raise them to max health if the current health + bonus would go above it - */ - SetEntityHealth(client, iMaxHealth); - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "ToMaxHealth", LANG_SERVER); - } - else - { - - /** - Give them the instant health bonus - */ - SetEntityHealth(client, iHealth + g_iHealthBonus); - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "HealthBonus", LANG_SERVER); - } - - /** - Increase the count - */ - g_aPlayers[client][iHealthCount] += 1; - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_Teaser(client, args) -{ - - /** - Make sure we are enabled - */ - if (!g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - Check to see if we have command arguments. - */ - new iCmdArgs = GetCmdArgs(); - if (iCmdArgs == 0) - { - - /** - We don't so display the player menu. - */ - new Handle:hPlayerMenu = BuildPlayerMenu(); - DisplayMenu(hPlayerMenu, client, MENU_TIME_FOREVER); - return Plugin_Handled; - } - - /** - We have some arguments, see if we can find the player - */ - decl String:sPlayer[64]; - GetCmdArg(1, sPlayer, sizeof(sPlayer)); - new iTarget = FindTarget(client, sPlayer, true, true); - if (iTarget == -1 || !IsClientInGame(iTarget)) - { - - /** - We don't know who this is, so display the player menu. - */ - new Handle:hPlayerMenu = BuildPlayerMenu(); - DisplayMenu(hPlayerMenu, client, MENU_TIME_FOREVER); - } - else - { - /** - We found the player, see if we are supposed to turn it on or off. - */ - if (iCmdArgs >= 2) - { - decl String:sOn[3]; - GetCmdArg(2, sOn, sizeof(sOn)); - if (StringToInt(sOn)) - { - - /** - Turn temp benefits on. - */ - g_aPlayers[iTarget][bIsDonator] = true; - } - else - { - - /** - Turn temp benefits on. - */ - g_aPlayers[iTarget][bIsDonator] = false; - } - } - else - { - - /** - We don't know what to do, so just turn it on. - */ - g_aPlayers[iTarget][bIsDonator] = true; - } - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_Say(client, args) -{ - - /** - Make sure we are enabled. - */ - if (client == 0 || IsChatTrigger() || !g_bIsChatColorsEnabled || !g_bIsEnabled) - { - return Plugin_Continue; - } - - /** - Check the client to see if they are a donator. - */ - if (g_aPlayers[client][bIsDonator]) - { - - /** - The client is, so get the chat message and strip it down. - */ - decl String:sArg[CHAT_MAX_MESSAGE_LENGTH], - String:sChatMsg[CHAT_MAX_MESSAGE_LENGTH]; - new bool:bAlive = IsPlayerAlive(client); - GetCmdArgString(sArg, sizeof(sArg)); - StripQuotes(sArg); - TrimString(sArg); - new startidx; - if (sArg[strlen(sArg)-1] == '"') - { - sArg[strlen(sArg)-1] = '\0'; - startidx = 1; - } - - /** - Bug out if they are using the admin chat symbol (admin chat). - */ - if (sArg[startidx] == CHAT_SYMBOL) - { - return Plugin_Continue; - } - - /** - Format the message. - */ - FormatMessage(client, 0, bAlive, sChatMsg, sArg); - - /** - Send the message. - */ - SayText2(0, client, sChatMsg); - - /** - We are done, bug out, and stop the original chat message. - */ - return Plugin_Stop; - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -public Action:Hacks_TakeDamageHook(client, attacker, inflictor, Float:damage, &Float:multiplier, damagetype) -{ - - /** - Make sure we are enabled and the client is a donator. - */ - if (g_bIsEnabled && g_bIsNoFallDmgEnabled && g_aPlayers[client][bIsDonator]) - { - - /** - Check for fall damage. - */ - if (damagetype & DMG_FALL) - { - - /** - Cancel the fall damage and bug out. - */ - multiplier *= 0.0; - return Plugin_Changed; - } - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -public Action:Hacks_PreThinkHook(client) -{ - - /** - Make sure we are enabled and the client is a donator. - */ - if (!g_bIsEnabled || !g_bIsFastHeayEnabled || !g_aPlayers[client][bIsDonator]) - { - return Plugin_Continue; - } - - /** - Check the players class. We are looking for the heavy. - */ - new TFClassType:PlayerClass = TF2_GetPlayerClass(client); - if (PlayerClass == TFClass_Heavy) - { - - /** - We have a heavy, lets check the weapon. - */ - decl String:sWeaponCurrent[64]; - GetClientWeapon(client, sWeaponCurrent, sizeof(sWeaponCurrent)); - if (StrEqual(sWeaponCurrent, "tf_weapon_minigun", false)) - { - - /** - We have a minigun, check the heavies current weapon state to see if it's spinning. - */ - new iWeapon = GetPlayerWeaponSlot(client, 0); - new iWeaponState = GetEntProp(iWeapon, Prop_Send, "m_iWeaponState"); - if (iWeaponState > 0) - { - - /** - He is spinning, so lets change the heavies speed. - */ - new Float:fMaxSpeed = FloatMul(g_fHeavyMultiplier, float(g_fClassMaxSpeed[PlayerClass])); - SetEntPropFloat(client, Prop_Send, "m_flMaxspeed", fMaxSpeed); - } - } - } - - /** - We are done, bug out. - */ - // use Plugin_Continue (other options are ignored on PreThink hook) - return Plugin_Continue; -} - -public Action:HookPlayerConnect(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Make sure we are enabled. - */ - if (!g_bIsEnabled || !g_bIsJoinPubMsgEnabled || !dontBroadcast) - { - return Plugin_Continue; - } - - /** - Get our event variables and check the client. - */ - new iUserId = GetEventInt(event,"userid"); - new iClient = GetClientOfUserId(iUserId); - if (iClient != 0) - { - - /** - Get the info on the client and format the message. - */ - decl String:sClientName[255], - String:sAuthID[255], - String:sMsg[1024]; - - GetEventString(event, "name", sClientName, sizeof(sClientName)); - GetClientAuthString(iClient, sAuthID, sizeof(sAuthID)); - Format(sMsg, sizeof(sMsg), "%T", "PublicJoinMessage", LANG_SERVER, sClientName); - - /** - Print the message to the clients and do the normal functions. - */ - for (new i = 1; i <= MaxClients; i++) - { - if(IsClientConnected(i) && IsClientInGame(i)) - { - PrintToChat(i,"\x01\x05%s", sMsg); - PrintToConsole(i,"%s has connected.", sClientName); - } - } - LogToGame("\"%s<%d><%s><>\" entered the game", sClientName, iUserId, sAuthID); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public HookPlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled && g_bIsUberChargeEnabled) - { - - /** - Get the event variables and check the class for medic - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - if (TF2_GetPlayerClass(iClient) == TFClass_Medic) - { - - /** - Start a timer to get the medic the uber boost - */ - CreateTimer(0.25, Timer_PlayerUberDelay, iClient, TIMER_FLAG_NO_MAPCHANGE); - } - } -} - -public HookPlayerClass(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled && g_bIsUberChargeEnabled) - { - - /** - Get the event variables and check the class for medic - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - if (TF2_GetPlayerClass(iClient) == TFClass_Medic) - { - - /** - Start a timer to get the medic the uber boost - */ - CreateTimer(0.25, Timer_PlayerUberDelay, iClient, TIMER_FLAG_NO_MAPCHANGE); - } - } -} - -public HookPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled || g_bIsSwapTeamEnabled) - { - - /** - Get the event variables - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - new String:sWeapon[256]; - GetEventString(event, "weapon", sWeapon, sizeof(sWeapon)); - - /** - Bug out if world killed him. Means he changed team or something - */ - if (StrEqual(sWeapon, "world", false)) - { - g_aPlayers[iClient][bQueue] = false; - return; - } - - /** - If he is queued up, swap him - */ - if (g_aPlayers[iClient][bQueue]) - { - SM_MovePlayer(iClient, g_aPlayers[iClient][iNewTeam]); - } - } -} - -public HookPlayerChangeTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled || g_bIsSwapTeamEnabled) - { - - /** - Get the event variables - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - - /** - If he is queued up, clear the status - */ - if (g_aPlayers[iClient][bQueue]) - { - g_aPlayers[iClient][bQueue] = false; - } - } -} - -public HookRoundStart(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Set our variables. - */ - g_bRoundEnd = false; - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled && g_bIsImmuntyEnabled) - { - - /** - Get rid of their immunity. - */ - ProcessRoundEndImmunity(false); - } -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Set our variables. - */ - g_bRoundEnd = true; - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled && g_bIsImmuntyEnabled) - { - - /** - Give them their immunity. - */ - ProcessRoundEndImmunity(true); - } -} - -public Action:Timer_DonatorJoined(Handle:timer, any:client) -{ - - /** - Make sure sounds are enabled. - */ - if (g_bIsEnabled && g_bIsJoinSoundEnabled) - { - EmitSoundToClient(client, g_sSoundFile); - } - - /** - Make sure private messages are enabled. - */ - if (g_bIsJoinPrivMsgEnabled) - { - - /** - Send messages to the client. - */ - decl String:sMsg[1024]; - Format(sMsg, sizeof(sMsg), "%T", "PrivateJoinMessage", LANG_SERVER); - PrintToChat(client,"\x01\x05%s", sMsg); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Timer_PlayerUberDelay(Handle:timer, any:client) -{ - - /** - Make sure the client is still in game. - */ - if (IsClientInGame(client)) - { - - /** - Make sure the client is still a medic. - */ - if (TF2_GetPlayerClass(client) == TFClass_Medic) - { - - /** - Get the medgun weapon index - */ - new iIndex = GetPlayerWeaponSlot(client, 1); - if (iIndex > 0) - { - - /** - Set the uber level with the bonus. - */ - SetEntPropFloat(iIndex, Prop_Send, "m_flChargeLevel", g_fUberLevel); - } - } - } -} - -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (convar == sdb_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsEnabled = false; - } - else - { - g_bIsEnabled = true; - } - } - else if (convar == sdb_donationflag) - { - Format(g_sCharDonatorFlag, sizeof(g_sCharDonatorFlag), "%s", newValue); - } - else if (convar == sdb_soundfile) - { - Format(g_sSoundFile, sizeof(g_sSoundFile), "%s", newValue); - } - else if (convar == sdb_joinsound_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsJoinSoundEnabled = false; - } - else - { - g_bIsJoinSoundEnabled = true; - } - } - else if (convar == sdb_joinpubmsg_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsJoinPubMsgEnabled = false; - } - else - { - g_bIsJoinPubMsgEnabled = true; - } - } - else if (convar == sdb_joinprivmsg_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsJoinPrivMsgEnabled = false; - } - else - { - g_bIsJoinPrivMsgEnabled = true; - } - } - else if (convar == sdb_chatcolors_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsChatColorsEnabled = false; - } - else - { - g_bIsChatColorsEnabled = true; - } - } - else if (convar == sdb_immunity_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsImmuntyEnabled = false; - } - else - { - g_bIsImmuntyEnabled = true; - } - } - else if (convar == sdb_ubercharge_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsUberChargeEnabled = false; - } - else - { - g_bIsUberChargeEnabled = true; - } - } - else if (convar == sdb_givehealth_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsGiveHealthEnabled = false; - } - else - { - g_bIsGiveHealthEnabled = true; - } - } - else if (convar == sdb_nofalldmg_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsNoFallDmgEnabled = false; - } - else - { - g_bIsNoFallDmgEnabled = true; - } - } - else if (convar == sdb_fastheavy_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsFastHeayEnabled = false; - } - else - { - g_bIsFastHeayEnabled = true; - } - } - else if (convar == sdb_swapteam_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsSwapTeamEnabled = false; - } - else - { - g_bIsSwapTeamEnabled = true; - } - } - else if (convar == sdb_chatcolor) - { - Format(g_sChatColor, sizeof(g_sChatColor), "%s", newValue); - } - else if (convar == sdb_uberlevel) - { - g_fUberLevel = StringToFloat(newValue); - } - else if (convar == sdb_healthcount) - { - g_iHealthCount = StringToInt(newValue); - } - else if (convar == sdb_healthbonus) - { - g_iHealthBonus = StringToInt(newValue); - } - else if (convar == sdb_heavymultiplier) - { - g_fHeavyMultiplier = StringToFloat(newValue); - } -} - -stock LoadUpVariables() -{ - g_bIsEnabled = GetConVarBool(sdb_enabled); - g_bIsJoinSoundEnabled = GetConVarBool(sdb_enabled); - g_bIsJoinPubMsgEnabled = GetConVarBool(sdb_enabled); - g_bIsJoinPrivMsgEnabled = GetConVarBool(sdb_enabled); - g_bIsChatColorsEnabled = GetConVarBool(sdb_enabled); - g_bIsImmuntyEnabled = GetConVarBool(sdb_enabled); - g_bIsUberChargeEnabled = GetConVarBool(sdb_enabled); - g_bIsGiveHealthEnabled = GetConVarBool(sdb_enabled); - g_bIsNoFallDmgEnabled = GetConVarBool(sdb_enabled); - g_bIsFastHeayEnabled = GetConVarBool(sdb_enabled); - g_bIsSwapTeamEnabled = GetConVarBool(sdb_enabled); - GetConVarString(sdb_donationflag, g_sCharDonatorFlag, sizeof(g_sCharDonatorFlag)); - GetConVarString(sdb_soundfile, g_sSoundFile, sizeof(g_sSoundFile)); - GetConVarString(sdb_chatcolor, g_sChatColor, sizeof(g_sChatColor)); - g_bRoundEnd = false; - g_iHealthBonus = GetConVarInt(sdb_healthbonus); - g_iHealthCount = GetConVarInt(sdb_healthcount); - g_fHeavyMultiplier = GetConVarFloat(sdb_heavymultiplier); - g_fUberLevel = GetConVarFloat(sdb_uberlevel); -} - -stock PrepSoundFile() -{ - decl String:buffer[PLATFORM_MAX_PATH]; - PrecacheSound(g_sSoundFile, true); - Format(buffer, sizeof(buffer), "sound/%s", g_sSoundFile); - AddFileToDownloadsTable(buffer); -} - -stock CleanUpPlayer(client) -{ - g_aPlayers[client][bIsDonator] = false; - g_aPlayers[client][bQueue] = false; - g_aPlayers[client][bImmune] = false; - g_aPlayers[client][iNewTeam] = 0; - g_aPlayers[client][iHealthCount] = 0; -} - -stock ProcessRoundEndImmunity(bool:give) -{ - for (new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][bIsDonator]) - { - if (give) - { - SetEntProp(i, Prop_Data, "m_takedamage", 0, 1); - g_aPlayers[i][bImmune] = true; - } - else - { - SetEntProp(i, Prop_Data, "m_takedamage", 2, 1); - g_aPlayers[i][bImmune] = false; - } - } - } -} - -stock FormatMessage(iClient, iTeam, bool:bAlive, String:sChatMsg[], const Sting:sMessage[]) -{ - decl String:sDead[10], - String:sTeam[10], - String:sClientName[64]; - GetClientName(iClient, sClientName, sizeof(sClientName)); - if (iTeam != 0) - Format(sTeam, sizeof(sTeam), "(TEAM) "); - else - Format(sTeam, sizeof(sTeam), ""); - if (bAlive) - Format(sDead, sizeof(sDead), ""); - else - Format(sDead, sizeof(sDead), "*DEAD* "); - if (StrContains(g_sChatColor, "light", false) == -1) - Format(sChatMsg, CHAT_MAX_MESSAGE_LENGTH, "\x01%s%s\x03%s \x01: \x05%s", sDead, sTeam, sClientName, sMessage); - else - Format(sChatMsg, CHAT_MAX_MESSAGE_LENGTH, "\x01%s%s\x03%s \x01: \x04%s", sDead, sTeam, sClientName, sMessage); -} - -stock SayText2(target, author, const String:message[]) -{ - new Handle:hBf; - if (target == 0) - hBf = StartMessageAll("SayText2"); - else - hBf = StartMessageOne("SayText2", target); - if (hBf != INVALID_HANDLE) - { - BfWriteByte(hBf, author); - BfWriteByte(hBf, true); - BfWriteString(hBf, message); - EndMessage(); - } -} - -stock ProcessAdmins() -{ - for (new i = 1; i <= MaxClients; i++) - { - if (SM_IsValidAdmin(i, g_sCharDonatorFlag)) - { - g_aPlayers[i][bDonator] = true; - } - else - { - g_aPlayers[i][bDonator] = false; - } - } -} - -stock ProcessLate() -{ - if (g_bIsEnabled) - { - ProcessAdmins(); - PrepSoundFile(); - if (g_bRoundEnd && g_bIsImmuntyEnabled) - { - ProcessRoundEndImmunity(true); - } - if (!g_bIsImmuntyEnabled) - { - ProcessRoundEndImmunity(false); - } - } - else - { - ProcessRoundEndImmunity(false); - } -} - -public Menu_SwapMode(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, 64); - if (StringToInt(sSelection)) - g_aPlayers[param1][bQueue] = false; - else - g_aPlayers[param1][bQueue] = true; - if (!g_aPlayers[param1][bQueue]) - SM_MovePlayer(param1, g_aPlayers[param1][iNewTeam]); - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -public Menu_SelectPlayer(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[256]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - new iTarget = GetClientOfUserId(StringToInt(sSelection)); - if (g_aPlayers[iTarget][bIsDonator]) - g_aPlayers[iTarget][bIsDonator] = false; - else - g_aPlayers[iTarget][bIsDonator] = true; - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -stock Handle:BuildSwapModeMenu() -{ - new Handle:menu = CreateMenu(Menu_SwapMode); - SetMenuTitle(menu, "Select When to Swap:"); - AddMenuItem(menu, "0", "Instantly (Kills)"); - AddMenuItem(menu, "1", "Queue on next death"); - SetMenuExitBackButton(menu, false); - return menu; -} - -stock Handle:BuildPlayerMenu() -{ - new Handle:menu = CreateMenu(Menu_SelectPlayer); - AddTargetsToMenu(menu, 0, true, false); - SetMenuTitle(menu, "Select A Player:"); - SetMenuExitBackButton(menu, true); - return menu; -} - -public Action:Command_TEST(client, args) -{ - -} \ No newline at end of file diff --git a/Simple Team Balancer/addons/sourcemod/scripting/simple-messagesuppression.sp b/Simple Team Balancer/addons/sourcemod/scripting/simple-messagesuppression.sp deleted file mode 100644 index f7725a4..0000000 --- a/Simple Team Balancer/addons/sourcemod/scripting/simple-messagesuppression.sp +++ /dev/null @@ -1,227 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Message Suppression -Description: - Blocks Specific Message Outputs -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include -#include - -#define SUPPRESS_VERSION "1.1.$Rev$" - -public Plugin:myinfo = -{ - name = "Simple Message Suppression", - author = "FlyingMongoose, psychonic", - description = "Blocks Specific Message Outputs", - version = SUPPRESS_VERSION, - url = "http://www.simple-plugins.com/" -} - -new Handle:cvarBlockSpectateMessage; -new Handle:cvarBlockDisconnectMessage; -new Handle:cvarBlockConnectMessage; -new Handle:cvarAdminShowMessages; -new iSpecTeam = 1; - - -public OnPluginStart() -{ - CreateConVar("suppress_version", SUPPRESS_VERSION, _, FCVAR_PLUGIN|FCVAR_NOTIFY|FCVAR_REPLICATED|FCVAR_SPONLY|FCVAR_DONTRECORD); - cvarBlockSpectateMessage = CreateConVar("sm_blockspectatemessage", "1", "If enabled it blocks the join team message if an administrator joins spectator", FCVAR_PLUGIN, true, 0.0, true, 1.0); - cvarBlockDisconnectMessage = CreateConVar("sm_blockdisconnectmessage", "1", "Blocks the disconnect message", FCVAR_PLUGIN, true, 0.0, true, 1.0); - cvarBlockConnectMessage = CreateConVar("sm_blockconnectmessage", "1", "If enabled it blocks the player connection message.", FCVAR_PLUGIN, true, 0.0, true, 1.0); - cvarAdminShowMessages = CreateConVar("sm_adminshowmessages", "1", "Shows disconnect/connect/team join messages for admins only (if disconnect message is set to be blocked)", FCVAR_PLUGIN, true, 0.0, true, 1.0); - HookEvent("player_team", ev_PlayerTeam, EventHookMode_Pre); - HookEvent("player_disconnect", ev_PlayerDisconnect, EventHookMode_Pre); - HookEvent("player_connect", ev_PlayerConnect, EventHookMode_Pre); - - new String:game_folder[64]; - GetGameFolderName(game_folder, sizeof(game_folder)) - - if (StrContains(game_folder, "insurgency", false) != -1) - { - iSpecTeam = 3; - } - else - { - new String:game_description[64]; - GetGameDescription(game_description, sizeof(game_description), true); - if (StrContains(game_description, "Insurgency", false) != -1) - { - iSpecTeam = 3; - } - } - - AutoExecConfig(true, "suppressmessage", "sourcemod"); -} - -public Action:ev_PlayerTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - if (GetConVarBool(cvarBlockSpectateMessage)) - { - if (!dontBroadcast && !GetEventBool(event, "silent")) - { - new iUserId = GetEventInt(event, "userid"); - new iClient = GetClientOfUserId(iUserId); - new iTeam = GetEventInt(event, "team"); - - if (iTeam == iSpecTeam && GetAdminFlag(GetUserAdmin(iClient), Admin_Kick)) - { - new iOldTeam = GetEventInt(event, "oldteam"); - new bool:bDisconnect = GetEventBool(event, "disconnect"); - new bool:bAutoteam = GetEventBool(event, "autoteam"); - decl String:strName[50]; - GetEventString(event, "name", strName, sizeof(strName)); - - if (iClient != 0) - { - if (GetConVarInt(cvarAdminShowMessages) == 1) - { - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientConnected(i) && IsClientInGame(i) && GetUserAdmin(i) != INVALID_ADMIN_ID) - { - PrintToChat(i,"%N joined team Spectator.", iClient); - PrintToConsole(i,"%N joined team Spectator.", iClient); - } - } - } - } - - new Handle:hEvent = CreateEvent("player_team"); - SetEventInt(hEvent, "userid", iUserId); - SetEventInt(hEvent, "team", iTeam); - SetEventInt(hEvent, "oldteam", iOldTeam); - SetEventBool(hEvent, "disconnect", bDisconnect); - SetEventBool(hEvent, "autoteam", bAutoteam); - SetEventBool(hEvent, "silent", true); - SetEventString(hEvent, "name", strName); - - FireEvent(hEvent, true); - - return Plugin_Handled; - } - } - } - return Plugin_Continue; -} -public Action:ev_PlayerConnect(Handle:event, const String:name[], bool:dontBroadcast) -{ - if (GetConVarBool(cvarBlockConnectMessage)) - { - if (!dontBroadcast) - { - decl String:strName[50]; - GetEventString(event, "name", strName, sizeof(strName)); - new iIndex = GetEventInt(event, "index"); - new iUserId = GetEventInt(event, "userid"); - new iClient = GetClientOfUserId(iUserId); - decl String:strNetworkId[50]; - GetEventString(event, "networkid", strNetworkId, sizeof(strNetworkId)); - decl String:strAddress[50]; - GetEventString(event, "address", strAddress, sizeof(strAddress)); - - if (iClient != 0) - { - if (GetConVarInt(cvarAdminShowMessages) == 1) - { - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientConnected(i) && IsClientInGame(i) && GetUserAdmin(i) != INVALID_ADMIN_ID) - { - PrintToChat(i,"%N has connected.", iClient); - PrintToConsole(i,"%N has connected.", iClient); - } - } - } - } - - new Handle:hEvent = CreateEvent("player_connect"); - SetEventString(hEvent, "name", strName); - SetEventInt(hEvent, "index", iIndex); - SetEventInt(hEvent, "userid", iUserId); - SetEventString(hEvent, "networkid", strNetworkId); - SetEventString(hEvent, "address", strAddress); - - FireEvent(hEvent, true); - - return Plugin_Handled; - } - } - return Plugin_Continue; -} -public Action:ev_PlayerDisconnect(Handle:event, const String:name[], bool:dontBroadcast) -{ - if (GetConVarBool(cvarBlockDisconnectMessage)) - { - if (!dontBroadcast) - { - new iUserId = GetEventInt(event, "userid"); - new iClient = GetClientOfUserId(iUserId); - decl String:strReason[50]; - GetEventString(event, "reason", strReason, sizeof(strReason)); - decl String:strName[50]; - GetEventString(event, "name", strName, sizeof(strName)); - decl String:strNetworkId[50]; - GetEventString(event, "networkid", strNetworkId, sizeof(strNetworkId)); - - if (iClient != 0) - { - if (GetConVarInt(cvarAdminShowMessages) == 1) - { - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientConnected(i) && IsClientInGame(i) && GetUserAdmin(i) != INVALID_ADMIN_ID) - { - PrintToChat(i, "%N has left the server.", iClient); - PrintToConsole(i, "Dropped %N from server (Disconnect by user.)", iClient); - } - } - } - } - - new Handle:hEvent = CreateEvent("player_disconnect"); - SetEventInt(hEvent, "userid", iUserId); - SetEventString(hEvent, "reason", strReason); - SetEventString(hEvent, "name", strName); - SetEventString(hEvent, "networkid", strNetworkId); - - FireEvent(hEvent, true); - - return Plugin_Handled; - } - } - - return Plugin_Continue; -} \ No newline at end of file diff --git a/Simple Team Balancer/addons/sourcemod/scripting/simple-plugins.sp b/Simple Team Balancer/addons/sourcemod/scripting/simple-plugins.sp deleted file mode 100644 index 4462b41..0000000 --- a/Simple Team Balancer/addons/sourcemod/scripting/simple-plugins.sp +++ /dev/null @@ -1,785 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Plugins -Description: - Core plugin for Simple Plugins project -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#define CORE_PLUGIN_VERSION "1.1.$Rev$" - -#include - -enum e_PlayerInfo -{ - Handle:hForcedTeamPlugin = INVALID_HANDLE, - iForcedTeam = 0, - iBuddy = 0, - bool:bBuddyLocked = false -}; - -new Handle:g_fwdPlayerMoved; -new g_aPlayers[MAXPLAYERS + 1][e_PlayerInfo]; -new bool:g_bTeamsSwitched = false; - -/** -Setting our plugin information. -*/ -public Plugin:myinfo = -{ - name = "Simple Plugins Core Plugin", - author = "Simple Plugins", - description = "Core plugin for Simple Plugins", - version = CORE_PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -}; - -public bool:AskPluginLoad(Handle:myself, bool:late, String:error[], err_max) -{ - - /** - Register natives for other plugins - */ - CreateNative("SM_MovePlayer", Native_SM_MovePlayer); - CreateNative("SM_SetForcedTeam", Native_SM_SetForcedTeam); - CreateNative("SM_GetForcedTeam", Native_SM_GetForcedTeam); - CreateNative("SM_ClearForcedTeam", Native_SM_ClearForcedTeam); - CreateNative("SM_GetForcedPlayer", Native_SM_GetForcedPlayer); - CreateNative("SM_AssignBuddy", Native_SM_AssignBuddy); - CreateNative("SM_GetClientBuddy", Native_SM_GetClientBuddy); - CreateNative("SM_LockBuddy", Native_SM_LockBuddy); - CreateNative("SM_IsBuddyLocked", Native_SM_IsBuddyLocked); - CreateNative("SM_ClearBuddy", Native_SM_ClearBuddy); - CreateNative("SM_IsValidAdmin", Native_SM_IsValidAdmin); - CreateNative("SM_IsValidTeam", Native_SM_IsValidTeam); - RegPluginLibrary("simpleplugins"); - return true; -} - -public OnPluginStart() -{ - - CreateConVar("ssm_core_pl_ver", CORE_PLUGIN_VERSION, "Simple SourceMod Plugins Core Plugin Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - CreateConVar("ssm_core_inc_ver", CORE_INC_VERSION, "Simple SourceMod Plugins Core Include Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook some events to control forced players and check extensions - */ - decl String:sExtError[256]; - LogAction(0, -1, "[SSM] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_team", HookPlayerChangeTeam, EventHookMode_Pre); - switch (g_CurrentMod) - { - case GameType_CSS: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - new iExtStatus = GetExtensionFileStatus("game.cstrike.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SSM] Required extension was not found."); - LogAction(0, -1, "[SSM] Plugin FAILED TO LOAD."); - SetFailState("Required extension was not found."); - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SSM] Required extension is loaded with errors."); - LogAction(0, -1, "[SSM] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SSM] Plugin FAILED TO LOAD."); - SetFailState("Required extension is loaded with errors."); - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SSM] Required extension is loaded."); - } - } - case GameType_TF: - { - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_PostNoCopy); - HookUserMessage(GetUserMessageId("TextMsg"), UserMessageHook_Class, true); - new iExtStatus = GetExtensionFileStatus("game.tf2.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SSM] Required extension was not found."); - LogAction(0, -1, "[SSM] Plugin FAILED TO LOAD."); - SetFailState("Required extension was not found."); - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SSM] Required extension is loaded with errors."); - LogAction(0, -1, "[SSM] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SSM] Plugin FAILED TO LOAD."); - SetFailState("Required extension is loaded with errors."); - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SSM] Required extension is loaded."); - } - } - case GameType_DOD: - { - HookEvent("dod_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_PostNoCopy); - } - default: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - } - } - - /** - Load common translations - */ - LoadTranslations ("common.phrases"); - - /** - Create the global forward - */ - g_fwdPlayerMoved = CreateGlobalForward("SM_OnPlayerMoved", ET_Event, Param_Cell, Param_Cell, Param_Cell); -} - -public OnClientDisconnect(client) -{ - - /** - Cleanup clients/players buddy list - */ - if (!IsFakeClient(client)) - { - SM_ClearBuddy(client, true); - SM_LockBuddy(client, false); - } - SM_ClearForcedTeam(client); -} - -public HookRoundStart(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - See if the teams have been switched - */ - if (g_bTeamsSwitched) - { - - /** - Switch the teams the players are forced to - */ - for (new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][iForcedTeam] != 0) - { - if (g_aPlayers[i][iForcedTeam] == g_aCurrentTeams[Team1]) - { - g_aPlayers[i][iForcedTeam] = g_aCurrentTeams[Team2]; - } - else - { - g_aPlayers[i][iForcedTeam] = g_aCurrentTeams[Team1]; - } - } - } - } -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - g_bTeamsSwitched = false; -} - -public HookPlayerChangeTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get our event variables - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - new iTeam = GetEventInt(event, "team"); - - /** - See if the player is on the wrong team - */ - if (g_aPlayers[iClient][iForcedTeam] != 0 && g_aPlayers[iClient][iForcedTeam] != iTeam) - { - - /** - Move the player back to the forced team - */ - CreateTimer(1.0, Timer_ForcePlayerMove, iClient, TIMER_FLAG_NO_MAPCHANGE); - - /** - If the event was going to be broadcasted, we refire it so it is not broadcasted and stop this one - */ - if (!dontBroadcast) - { - new Handle:hEvent = CreateEvent("player_team"); - SetEventInt(hEvent, "userid", GetEventInt(event, "userid")); - SetEventInt(hEvent, "team", GetEventInt(event, "team")); - SetEventInt(hEvent, "oldteam", GetEventInt(event, "oldteam")); - SetEventBool(hEvent, "disconnect", GetEventBool(event, "disconnect")); - - if (g_CurrentMod == GameType_DOD || g_CurrentMod == GameType_L4D || g_CurrentMod == GameType_TF) - { - new String:sClientName[MAX_NAME_LENGTH + 1]; - GetClientName(client, sClientName, sizeof(sClientName)); - SetEventBool(hEvent, "autoteam", GetEventBool(event, "autoteam")); - SetEventBool(hEvent, "silent", true); - SetEventString(hEvent, "name", sClientName); - FireEvent(hEvent, true); - } - else - { - FireEvent(hEvent, true); - } - return Plugin_Handled; - } - } - return Plugin_Continue; -} - -public Action:UserMessageHook_Class(UserMsg:msg_id, Handle:bf, const players[], playersNum, bool:reliable, bool:init) -{ - new String:sMessage[120]; - BfReadString(bf, sMessage, sizeof(sMessage), true); - if (StrContains(sMessage, "#TF_TeamsSwitched", false) != -1) - { - g_bTeamsSwitched = true; - } - return Plugin_Continue; -} - -public Native_SM_MovePlayer(Handle:plugin, numParams) -{ - - /** - Get and check the client and team - */ - new iClient = GetNativeCell(1); - new iTeam = GetNativeCell(2); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (iTeam != g_aCurrentTeams[Spectator] && iTeam != g_aCurrentTeams[Team1] && iTeam != g_aCurrentTeams[Team2]) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid team %d", iTeam); - } - - MovePlayer(iClient, iTeam); - if (!IsClientObserver(iClient)) - { - RespawnPlayer(iClient); - } - - new fResult; - - Call_StartForward(g_fwdPlayerMoved); - Call_PushCell(plugin); - Call_PushCell(iClient); - Call_PushCell(iTeam); - Call_Finish(fResult); - - if (fResult != SP_ERROR_NONE) - { - return ThrowNativeError(fResult, "Forward failed"); - } - - return fResult; -} - -public Native_SM_SetForcedTeam(Handle:plugin, numParams) -{ - - /** - Get and check the client and team - */ - new iClient = GetNativeCell(1); - new iTeam = GetNativeCell(2); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (iTeam != g_aCurrentTeams[Spectator] && iTeam != g_aCurrentTeams[Team1] && iTeam != g_aCurrentTeams[Team2] && iTeam != g_aCurrentTeams[Unknown]) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid team %d", iTeam); - } - - new bool:bOverRide = GetNativeCell(3) ? true : false; - - if (!bOverRide && g_aPlayers[iClient][hForcedTeamPlugin] != INVALID_HANDLE && plugin != g_aPlayers[iClient][hForcedTeamPlugin]) - { - return false; - } - - g_aPlayers[iClient][hForcedTeamPlugin] = plugin; - g_aPlayers[iClient][iForcedTeam] = iTeam; - return true; -} - -public Native_SM_GetForcedTeam(Handle:plugin, numParams) -{ - - /** - Get and check the client - */ - new iClient = GetNativeCell(1); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - - /** - Get and set the plugin if they want it - */ - new Handle:hPlugin = GetNativeCell(2); - if (hPlugin != INVALID_HANDLE) - { - SetNativeCellRef(2, g_aPlayers[iClient][hForcedTeamPlugin]); - } - - /** - Return the forced team, this could be 0 - */ - return g_aPlayers[iClient][iForcedTeam]; -} - -public Native_SM_ClearForcedTeam(Handle:plugin, numParams) -{ - - /** - Get and check the client and team - */ - new iClient = GetNativeCell(1); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - - g_aPlayers[iClient][hForcedTeamPlugin] = INVALID_HANDLE; - g_aPlayers[iClient][iForcedTeam] = 0; - - return true; -} - -public Native_SM_GetForcedPlayer(Handle:plugin, numParams) -{ - - /** - Get and check the team - */ - new iTeam = GetNativeCell(1); - if (iTeam != g_aCurrentTeams[Spectator] && iTeam != g_aCurrentTeams[Team1] && iTeam != g_aCurrentTeams[Team2]) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid team %d", iTeam); - } - - /** - Start a loop to check for a player on the wrong team - Also make sure the plugin that set the forced team is the plugin that asked - */ - new iPlayer = 0; - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientInGame(i) - && GetClientTeam(i) != g_aPlayers[i][iForcedTeam] - && g_aPlayers[i][iForcedTeam] == iTeam - && g_aPlayers[i][hForcedTeamPlugin] == plugin) - { - iPlayer = i; - break; - } - } - - /** - Return the player we found, this could be 0 - */ - return iPlayer; -} - -public Native_SM_AssignBuddy(Handle:plugin, numParams) -{ - - /** - Get and check the client and player - */ - new iClient = GetNativeCell(1); - new iPlayer = GetNativeCell(2); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (iPlayer < 0 || iPlayer > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid player index (%d)", iPlayer); - } - if (!IsClientConnected(iPlayer)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Player %d is not connected", iPlayer); - } - if (!IsClientInGame(iPlayer)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Player %d is not in the game", iClient); - } - if (IsFakeClient(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Bots are not supported"); - } - - /** - See if we can override his setting - */ - new bool:bOverRide = GetNativeCell(3) ? true : false; - if (!bOverRide) - { - - /** - We can't override, so check if they are locked - */ - if (g_aPlayers[iClient][bBuddyLocked] || g_aPlayers[iPlayer][bBuddyLocked]) - { - - /** - We detected at least 1 lock, so we bug out - */ - return false; - } - } - - /** - Ready to set the buddies - */ - g_aPlayers[iClient][iBuddy] = iPlayer; - g_aPlayers[iPlayer][iBuddy] = iClient; - return true; -} - -public Native_SM_GetClientBuddy(Handle:plugin, numParams) -{ - - /** - Get and check the client - */ - new iClient = GetNativeCell(1); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (IsFakeClient(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Bots are not supported"); - } - - /** - Return the players buddy, this could be 0 - */ - return g_aPlayers[iClient][iBuddy]; -} - -public Native_SM_LockBuddy(Handle:plugin, numParams) -{ - - /** - Get and check the client - */ - new iClient = GetNativeCell(1); - new bool:bSetting = GetNativeCell(2) ? true : false; - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (IsFakeClient(iClient)) - { - return ThrowNativeError(SP_ERROR_NATIVE, "Bots are not supported"); - } - - g_aPlayers[iClient][bBuddyLocked] = bSetting; - return true; -} - -public Native_SM_IsBuddyLocked(Handle:plugin, numParams) -{ - - /** - Get and check the client - */ - new iClient = GetNativeCell(1); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (IsFakeClient(iClient)) - { - return ThrowNativeError(SP_ERROR_NATIVE, "Bots are not supported"); - } - - return g_aPlayers[iClient][bBuddyLocked]; -} - -public Native_SM_ClearBuddy(Handle:plugin, numParams) -{ - - /** - Get and check the client - */ - new iClient = GetNativeCell(1); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_NATIVE, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_NATIVE, "Client (%d) is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (IsFakeClient(iClient)) - { - return ThrowNativeError(SP_ERROR_NATIVE, "Bots are not supported"); - } - - /** - Get the clients buddy and see if we can override his setting - */ - new bool:bOverRide = GetNativeCell(2) ? true : false; - new iPlayer = g_aPlayers[iClient][iBuddy]; - - /** - There is no buddy, we don't care about anything else so bug out - */ - if (iPlayer == 0) - { - return true; - } - - /** - We determined he had a buddy, check the override setting - */ - if (!bOverRide) - { - - /** - We can't override, so check if they are locked - */ - if (g_aPlayers[iClient][bBuddyLocked] || g_aPlayers[iPlayer][bBuddyLocked]) - { - - /** - We detected at least 1 lock, so we bug out - */ - return false; - } - } - - /** - Ready to clear the buddies - */ - g_aPlayers[iClient][iBuddy] = 0; - g_aPlayers[iPlayer][iBuddy] = 0; - return true; -} - -public Native_SM_IsValidTeam(Handle:plugin, numParams) -{ - - /** - Get the team - */ - new iTeam = GetNativeCell(1); - - /** - Check the team - */ - if (iTeam == g_aCurrentTeams[Spectator] || iTeam == g_aCurrentTeams[Team1] || iTeam == g_aCurrentTeams[Team2]) - { - return true; - } - return false; -} - -public Native_SM_IsValidAdmin(Handle:plugin, numParams) -{ - /** - Get the client and flags - */ - new iClient = GetNativeCell(1); - decl String:sFlags[15]; - GetNativeString(2, sFlags, sizeof(sFlags)); - new ibFlags = ReadFlagString(sFlags); - - /** - Check the flags - */ - if ((GetUserFlagBits(iClient) & ibFlags) == ibFlags) - { - return true; - } - if (GetUserFlagBits(iClient) & ADMFLAG_ROOT) - { - return true; - } - return false; -} - -public Action:Timer_ForcePlayerMove(Handle:timer, any:iClient) -{ - - MovePlayer(iClient, g_aPlayers[iClient][iForcedTeam]); - - if (g_aPlayers[iClient][iForcedTeam] != g_aCurrentTeams[Spectator]) - { - RespawnPlayer(iClient); - } - - PrintToChat(iClient, "\x01\x04----------------------------------"); - PrintToChat(iClient, "\x01\x04You have been forced to this team."); - PrintToChat(iClient, "\x01\x04----------------------------------"); - - return Plugin_Handled; -} - -stock MovePlayer(iClient, iTeam) -{ - - /** - Change the client's team based on the mod - */ - switch (g_CurrentMod) - { - case GameType_CSS: - { - CS_SwitchTeam(iClient, iTeam); - } - default: - { - ChangeClientTeam(iClient, iTeam); - } - } -} - -stock RespawnPlayer(iClient) -{ - - /** - Respawn the client based on the mod - */ - switch (g_CurrentMod) - { - case GameType_CSS: - { - CS_RespawnPlayer(iClient); - } - case GameType_TF: - { - TF2_RespawnPlayer(iClient); - } - case GameType_INS: - { - FakeClientCommand(iClient, "kill"); - } - default: - { - // - } - } -} diff --git a/Simple Team Balancer/addons/sourcemod/scripting/simple-roundimmunity.sp b/Simple Team Balancer/addons/sourcemod/scripting/simple-roundimmunity.sp deleted file mode 100644 index 5f0bca3..0000000 --- a/Simple Team Balancer/addons/sourcemod/scripting/simple-roundimmunity.sp +++ /dev/null @@ -1,947 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Round Immunity -Description: - Gives admins immunity during certain rounds -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or any later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#pragma semicolon 1 -#include -#include -#undef REQUIRE_EXTENSIONS -#undef AUTOLOAD_EXTENSIONS -#include -#include -#define REQUIRE_EXTENSIONS -#define AUTOLOAD_EXTENSIONS - -#define PLUGIN_VERSION "1.1.$Rev$" -#define SPECTATOR 1 -#define TEAM_RED 2 -#define TEAM_BLUE 3 - -#define COLOR_GREEN 0 -#define COLOR_BLACK 1 -#define COLOR_RED 2 -#define COLOR_BLUE 3 -#define COLOR_TEAM 4 -#define COLOR_RAINBOW 5 -#define COLOR_NONE 6 - -#define PLAYERCOND_SLOWED (1<<0) //1 -#define PLAYERCOND_ZOOMED (1<<1) //2 -#define PLAYERCOND_DISGUISING (1<<2) //4 -#define PLAYERCOND_DISGUISED (1<<3) //8 -#define PLAYERCOND_SPYCLOAK (1<<4) //16 -#define PLAYERCOND_UBERED (1<<5) //32 -#define PLAYERCOND_TELEPORTTRAIL (1<<6) //64 -#define PLAYERCOND_TAUNT (1<<7) //128 -// (1<<8) //256 -// (1<<9) //512 -#define PLAYERCOND_TELEPORTFLASH (1<<10) //1024 -#define PLAYERCOND_KRUBER (1<<11) //2048 -// (1<<12) //4096 -// (1<<13) //8192 -#define PLAYERCOND_BONKED (1<<14) //16384 (blame Neph if it doesn't work) -#define PLAYERCOND_BONKEDORDRINKSLOWDOWN (1<<15) //32768 -#define PLAYERCOND_HEALING (1<<16) //65536 -#define PLAYERCOND_BURNING (1<<17) //131072 -#define PLAYERCOND_FULLYCHARGEDBYMEDIC (1<<18) //262144 - -enum e_Cookies -{ - bEnabled, - iColor, - iMode -}; - -enum e_ColorNames -{ - Green, - Black, - Red, - Blue -}; - -enum e_ColorValues -{ - iRed, - iGreen, - iBlue -}; - -enum e_PlayerData -{ - Handle:hGodModeTimer, - Handle:hColorTimer, - bool:bIsAdmin, - bool:bIsImmune, - iCycleColor -}; - -/** - Global convar handles - */ -new Handle:sri_charadminflag = INVALID_HANDLE; -new Handle:sri_enabled = INVALID_HANDLE; -new Handle:sri_cookie_enabled = INVALID_HANDLE; -new Handle:sri_cookie_color = INVALID_HANDLE; -new Handle:sri_cookie_mode = INVALID_HANDLE; - -/** - Player arrays - */ -new g_aPlayers[MAXPLAYERS + 1][e_PlayerData]; -new g_aClientCookies[MAXPLAYERS + 1][e_Cookies]; - -/** - Global bools - */ -new bool:g_bLoadedLate = false; -new bool:g_bIsEnabled = true; -new bool:g_bRoundEnd = false; -new bool:g_bUseDukehacks = false; -new bool:g_bUseClientprefs = false; - -/** - Global strings/integers/floats - */ -new String:g_sCharAdminFlag[32]; -new g_iColors[e_ColorNames][e_ColorValues]; -new g_iClassMaxHealth[TFClassType] = {0, 125, 125, 200, 175, 150, 300, 175, 125, 125}; - -public Plugin:myinfo = -{ - name = "Simple Round Immunity", - author = "Simple Plugins", - description = "Gives admins immunity during certain rounds", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -} - -bool:AskPluginLoad(Handle:myself, bool:late, String:error[], err_max) -{ - g_bLoadedLate = late; - return true; -} - -public OnPluginStart() -{ - - /** - Create console variables - */ - CreateConVar("sri_version", PLUGIN_VERSION, "Simple Round Immunity", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - sri_enabled = CreateConVar("sri_enabled", "1", "Enable/Disable Admin immunity during certain round."); - sri_charadminflag = CreateConVar("sri_charadminflag", "a", "Admin flag to use for immunity (only one). Must be a in char format."); - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook some events and check extensions - */ - decl String:sExtError[256]; - LogAction(0, -1, "[SRI] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_spawn", HookPlayerSpawn, EventHookMode_Post); - HookEvent("player_hurt", HookPlayerHurt, EventHookMode_Pre); - switch (g_CurrentMod) - { - case GameType_CSS: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - new iExtStatus = GetExtensionFileStatus("game.cstrike.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SRI] Required extension was not found."); - LogAction(0, -1, "[SRI] Plugin FAILED TO LOAD."); - SetFailState("Required extension was not found."); - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SRI] Required extension is loaded with errors."); - LogAction(0, -1, "[SRI] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SRI] Plugin FAILED TO LOAD."); - SetFailState("Required extension is loaded with errors."); - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SRI] Required css extension is loaded."); - } - } - case GameType_TF: - { - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_PostNoCopy); - HookUserMessage(GetUserMessageId("TextMsg"), UserMessageHook_Class, true); - new iExtStatus = GetExtensionFileStatus("game.tf2.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SRI] Required extension was not found."); - LogAction(0, -1, "[SRI] Plugin FAILED TO LOAD."); - SetFailState("Required extension was not found."); - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SRI] Required extension is loaded with errors."); - LogAction(0, -1, "[SRI] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SRI] Plugin FAILED TO LOAD."); - SetFailState("Required extension is loaded with errors."); - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SRI] Required tf2 extension is loaded."); - } - iExtStatus = GetExtensionFileStatus("dukehacks.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SRI] Dukehacks extension was not found."); - LogAction(0, -1, "[SRI] Plugin continued to load, but that feature will not be used."); - g_bUseDukehacks = false; - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SRI] Dukehacks extension is loaded with errors."); - LogAction(0, -1, "[SRI] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SRI] Plugin continued to load, but that feature will not be used."); - g_bUseDukehacks = false; - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SRI] Dukehacks extension is loaded and will be used."); - g_bUseDukehacks = true; - dhAddClientHook(CHK_TakeDamage, Hacks_TakeDamageHook); - } - } - case GameType_DOD: - { - HookEvent("dod_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_PostNoCopy); - } - default: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - } - } - /** - Now lets check for client prefs extension - */ - new iExtStatus = GetExtensionFileStatus("clientprefs.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SRI] Client Preferences extension was not found."); - LogAction(0, -1, "[SRI] Plugin continued to load, but that feature will not be used."); - g_bUseClientprefs = false; - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SRI] Client Preferences extension is loaded with errors."); - LogAction(0, -1, "[SRI] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SRI] Plugin continued to load, but that feature will not be used."); - g_bUseClientprefs = false; - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SRI] Client Preferences extension is loaded, checking database."); - if (!SQL_CheckConfig(clientprefs)) - { - LogAction(0, -1, "[SRI] No 'clientprefs' database found. Check your database.cfg file."); - LogAction(0, -1, "[SRI] Plugin continued to load, but Client Preferences will not be used."); - g_bUseClientprefs = false; - } - g_bUseClientprefs = true; - - /** - Deal with client cookies - */ - sri_cookie_enabled = RegClientCookie("bri_client_enabled", "Enable/Disable your immunity during the bonus round.", CookieAccess_Public); - sri_cookie_color = RegClientCookie("bri_client_color", "Color to render when immune.", CookieAccess_Public); - sri_cookie_mode = RegClientCookie("bri_client_mode", "God mode to select", CookieAccess_Public); - SetCookieMenuItem(CookieMenu_TopMenu, sri_cookie_enabled, "Bonus Round Immunity"); - } - - HookConVarChange(sri_enabled, EnabledChanged); - - RegAdminCmd("sm_immunity", Command_Immunity, ADMFLAG_ROOT, "sm_immunity: Gives you immunity"); - - LoadColors(); - - AutoExecConfig(true, "plugin.simpleroundimmunity"); -} - -public OnAllPluginsLoaded() -{ - //something - // need to deal with the unloading of dukehacks, clientprefs, and simpleplugins - // should move hooking the client prefs cookies to a function to make sure they are done post plugin start if ext is loaded late -} - -public OnLibraryRemoved(const String:name[]) -{ - //something - // need to deal with the loading of dukehacks, clientprefs, and simpleplugins -} - -public OnConfigsExecuted() -{ - GetConVarString(sri_charadminflag, g_sCharAdminFlag, sizeof(g_sCharAdminFlag)); - g_bIsEnabled = GetConVarBool(sri_enabled); - g_bRoundEnd = false; -} - -/** - Client events - */ - -public OnClientPostAdminCheck(client) -{ - if (SM_IsValidAdmin(client, g_sCharAdminFlag)) - g_aPlayers[client][bIsAdmin] = true; - else - g_aPlayers[client][bIsAdmin] = false; -} - -public OnClientCookiesCached(client) -{ - decl String:sEnabled[2], String:sColor[4], String:sMode[2]; - GetClientCookie(client, sri_cookie_enabled, sEnabled, sizeof(sEnabled)); - GetClientCookie(client, sri_cookie_color, sColor, sizeof(sColor)); - GetClientCookie(client, sri_cookie_mode, sMode, sizeof(sMode)); - g_aClientCookies[client][bEnabled] = StringToInt(sEnabled); - g_aClientCookies[client][iColor] = StringToInt(sColor); - g_aClientCookies[client][iMode] = StringToInt(sMode); -} - -public OnClientDisconnect(client) -{ - CleanUp(client); -} - -/** - Commands - */ - -public Action:Command_Immunity(client, args) -{ - if (g_aPlayers[client][IsImmune]) - { - DisableImmunity(client); - } - else - { - EnableImmunity(client); - } - return Plugin_Handled; -} - -/** - Event hooks - */ - -public Action:Hacks_TakeDamageHook(client, attacker, inflictor, Float:damage, &Float:multiplier, damagetype) -{ - if (attacker == 0 || attacker >= MaxClients) - { - return Plugin_Continue; - } - if (g_aPlayers[client][IsImmune]) - { - new TFClassType:PlayerClass = TF2_GetPlayerClass(attacker); - if (PlayerClass == TFClass_Spy) - { - multiplier *= 0.0; - return Plugin_Changed; - } - } - return Plugin_Continue; -} - -public HookRoundStart(Handle:event, const String:name[], bool:dontBroadcast) -{ - g_bRoundEnd = false; - if (g_bIsEnabled) - { - for (new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][IsImmune]) - { - DisableImmunity(i); - } - } - } -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - g_bRoundEnd = true; - if (g_bIsEnabled) - { - for (new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][bIsAdmin]) - { - EnableImmunity(i); - } - } - } -} - -public HookPlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast) -{ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - if (g_bIsEnabled && g_aPlayers[iClient][bIsAdmin] && g_bRoundEnd) - { - EnableImmunity(iClient); - } -} - -public Action:HookPlayerHurt(Handle:event, const String:name[], bool:dontBroadcast) -{ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - if (g_aPlayers[iClient][IsImmune]) - { - SetEntityHealth(iClient, 2000); - return Plugin_Continue; - } - return Plugin_Continue; -} - -/** - Cookie menus - */ - -public CookieMenu_TopMenu(client, CookieMenuAction:action, any:info, String:buffer[], maxlen) -{ - if (action == CookieMenuAction_DisplayOption) - { - //don't think we need to do anything - } - else - { - new Handle:hMenu = CreateMenu(Menu_CookieSettings); - SetMenuTitle(hMenu, "Options (Current Setting)"); - if (g_aClientCookies[client][bEnabled]) - { - AddMenuItem(hMenu, "enable", "Enabled/Disable (Enabled)"); - } - else - { - AddMenuItem(hMenu, "enable", "Enabled/Disable (Disabled)"); - } - if (g_aClientCookies[client][iMode]) - { - AddMenuItem(hMenu, "mode", "Immunity Mode Setting (God Mode)"); - } - else - { - AddMenuItem(hMenu, "mode", "Immunity Mode Setting (Health)"); - } - switch (g_aClientCookies[client][iColor]) - { - case COLOR_GREEN: - { - AddMenuItem(hMenu, "color", "Color (Green)"); - } - case COLOR_BLACK: - { - AddMenuItem(hMenu, "color", "Color (Black)"); - } - case COLOR_RED: - { - AddMenuItem(hMenu, "color", "Color (Red)"); - } - case COLOR_BLUE: - { - AddMenuItem(hMenu, "color", "Color (Blue)"); - } - case COLOR_TEAM: - { - AddMenuItem(hMenu, "color", "Color (Team)"); - } - case COLOR_RAINBOW: - { - AddMenuItem(hMenu, "color", "Color (Rainbow)"); - } - case COLOR_NONE: - { - AddMenuItem(hMenu, "color", "Color (None)"); - } - } - SetMenuExitBackButton(hMenu, true); - DisplayMenu(hMenu, client, MENU_TIME_FOREVER); - } -} - -public Menu_CookieSettings(Handle:menu, MenuAction:action, param1, param2) -{ - new client = param1; - if (action == MenuAction_Select) - { - new String:sSelection[24]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "enable", false)) - { - new Handle:hMenu = CreateMenu(Menu_CookieSettingsEnable); - SetMenuTitle(hMenu, "Enable/Disable Round End Immunity"); - - if (g_aClientCookies[client][bEnabled]) - { - AddMenuItem(hMenu, "enable", "Enable (Set)"); - AddMenuItem(hMenu, "disable", "Disable"); - } - else - { - AddMenuItem(hMenu, "enable", "Enabled"); - AddMenuItem(hMenu, "disable", "Disable (Set)"); - } - - SetMenuExitBackButton(hMenu, true); - DisplayMenu(hMenu, client, MENU_TIME_FOREVER); - } - else if (StrEqual(sSelection, "mode", false)) - { - new Handle:hMenu = CreateMenu(Menu_CookieSettingsMode); - SetMenuTitle(hMenu, "Set Immunity Mode"); - - if (g_aClientCookies[client][iMode]) - { - AddMenuItem(hMenu, "god", "God Mode (Set)"); - AddMenuItem(hMenu, "health", "Health"); - } - else - { - AddMenuItem(hMenu, "god", "God Mode"); - AddMenuItem(hMenu, "health", "Health (Set)"); - } - - SetMenuExitBackButton(hMenu, true); - DisplayMenu(hMenu, client, MENU_TIME_FOREVER); - } - else - { - new Handle:hMenu = CreateMenu(Menu_CookieSettingsColors); - SetMenuTitle(hMenu, "Select Immunity Color"); - switch (g_aClientCookies[client][iColor]) - { - case COLOR_GREEN: - { - AddMenuItem(hMenu, "Green", "Green (Set)"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_BLACK: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black (Set)"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_RED: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red (Set)"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_BLUE: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue (Set)"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_TEAM: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color (Set)"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_RAINBOW: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow (Set)"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_NONE: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None (Set)"); - } - } - SetMenuExitBackButton(hMenu, true); - DisplayMenu(hMenu, client, MENU_TIME_FOREVER); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - ShowCookieMenu(client); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } -} - -public Menu_CookieSettingsEnable(Handle:menu, MenuAction:action, param1, param2) -{ - new client = param1; - if (action == MenuAction_Select) - { - new String:sSelection[24]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "enable", false)) - { - SetClientCookie(client, sri_cookie_enabled, "1"); - g_aClientCookies[client][bEnabled] = 1; - PrintToChat(client, "[SM] Bonus Round Immunity is ENABLED"); - } - else - { - SetClientCookie(client, sri_cookie_enabled, "0"); - g_aClientCookies[client][bEnabled] = 0; - PrintToChat(client, "[SM] Bonus Round Immunity is DISABLED"); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - ShowCookieMenu(client); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } -} - -public Menu_CookieSettingsColors(Handle:menu, MenuAction:action, param1, param2) -{ - new client = param1; - if (action == MenuAction_Select) - { - new String:sSelection[24]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "Green", false)) - { - SetClientCookie(client, sri_cookie_color, "0"); - g_aClientCookies[client][iColor] = COLOR_GREEN; - PrintToChat(client, "[SM] Bonus Round Immunity color set to GREEN"); - } - else if (StrEqual(sSelection, "Black", false)) - { - SetClientCookie(client, sri_cookie_color, "1"); - g_aClientCookies[client][iColor] = COLOR_BLACK; - PrintToChat(client, "[SM] Bonus Round Immunity color set to BLACK"); - } - else if (StrEqual(sSelection, "Red", false)) - { - SetClientCookie(client, sri_cookie_color, "2"); - g_aClientCookies[client][iColor] = COLOR_RED; - PrintToChat(client, "[SM] Bonus Round Immunity color set to RED"); - } - else if (StrEqual(sSelection, "Blue", false)) - { - SetClientCookie(client, sri_cookie_color, "3"); - g_aClientCookies[client][iColor] = COLOR_BLUE; - PrintToChat(client, "[SM] Bonus Round Immunity color set to BLUE"); - } - else if (StrEqual(sSelection, "Team", false)) - { - SetClientCookie(client, sri_cookie_color, "4"); - g_aClientCookies[client][iColor] = COLOR_TEAM; - PrintToChat(client, "[SM] Bonus Round Immunity color set to TEAM COLOR"); - } - else if (StrEqual(sSelection, "Rain", false)) - { - SetClientCookie(client, sri_cookie_color, "5"); - g_aClientCookies[client][iColor] = COLOR_RAINBOW; - PrintToChat(client, "[SM] Bonus Round Immunity color set to RAINBOW"); - } - else if (StrEqual(sSelection, "None", false)) - { - SetClientCookie(client, sri_cookie_color, "6"); - g_aClientCookies[client][iColor] = COLOR_NONE; - PrintToChat(client, "[SM] Bonus Round Immunity color set to NONE"); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - ShowCookieMenu(client); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } -} - -public Menu_CookieSettingsMode(Handle:menu, MenuAction:action, param1, param2) -{ - new client = param1; - if (action == MenuAction_Select) - { - new String:sSelection[24]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "god", false)) - { - SetClientCookie(client, sri_cookie_mode, "1"); - g_aClientCookies[client][iMode] = 1; - PrintToChat(client, "[SM] Bonus Round Immunity set to GOD MODE"); - } - else - { - SetClientCookie(client, sri_cookie_mode, "0"); - g_aClientCookies[client][iMode] = 0; - PrintToChat(client, "[SM] Bonus Round Immunity set to HEALTH BONUS"); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - ShowCookieMenu(client); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } -} - -/** -Timer functions - */ - -public Action:Timer_ChangeColor(Handle:timer, any:client) -{ - if (g_aPlayers[client][CycleColor]++ == 3) - { - g_aPlayers[client][CycleColor] = 0; - } - SetEntityRenderMode(client, RENDER_TRANSCOLOR); - SetEntityRenderColor(client, g_iColors[g_aPlayers[client][CycleColor]][iRed], g_iColors[g_aPlayers[client][CycleColor]][iGreen], g_iColors[g_aPlayers[client][CycleColor]][iBlue], 255); - return Plugin_Continue; -} - -public Action:Timer_UndoGodMode(Handle:timer, any:client) -{ - if (IsClientInGame(client)) - { - SetEntProp(client, Prop_Data, "m_takedamage", 2, 1); - } - g_aPlayers[iClient][hGodModeTimer] = INVALID_HANDLE; - return Plugin_Handled; -} - -/** -Stock functions . - */ - -stock CleanUp(iClient) -{ - g_aPlayers[iClient][bIsAdmin] = false; - DisableImmunity(iClient); -} - -stock EnableImmunity(iClient) -{ - SetEntityRenderMode(iClient, RENDER_TRANSCOLOR); - switch (g_aClientCookies[iClient][iColor]) - { - case COLOR_TEAM: - { - new iTeam = GetClientTeam(iClient); - SetEntityRenderColor(iClient, g_iColors[e_ColorNames:iTeam][iRed], g_iColors[e_ColorNames:iTeam][iGreen], g_iColors[e_ColorNames:iTeam][iBlue], 255); - } - case COLOR_RAINBOW: - { - if (g_aPlayers[iClient][hColorTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[iClient][hColorTimer]); - g_aPlayers[iClient][hColorTimer] = INVALID_HANDLE; - } - g_aPlayers[iClient][hColorTimer] = CreateTimer(0.2, Timer_ChangeColor, iClient, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); - } - case COLOR_NONE: - { - //We dont have to set a color - } - default: - { - SetEntityRenderColor(iClient, g_iColors[e_ColorNames:g_aClientCookies[iClient][iColor]][iRed], g_iColors[e_ColorNames:g_aClientCookies[iClient][iColor]][iGreen], g_iColors[e_ColorNames:g_aClientCookies[iClient][iColor]][iBlue], 255); - } - } - SetEntityHealth(iClient, 2000); - SetEntProp(iClient, Prop_Data, "m_takedamage", 0, 1); - g_aPlayers[iClient][hGodModeTimer] = CreateTimer(2.0, Timer_UndoGodMode, iClient); - g_aPlayers[iClient][IsImmune] = true; -} - -stock DisableImmunity(iClient) -{ - if (g_aPlayers[iClient][hGodModeTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[iClient][hGodModeTimer]); - g_aPlayers[iClient][hGodModeTimer] = INVALID_HANDLE; - } - if (g_aPlayers[iClient][hColorTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[iClient][hColorTimer]); - g_aPlayers[iClient][hColorTimer] = INVALID_HANDLE; - } - if (IsClientInGame(iClient)) - { - SetEntityRenderMode(iClient, RENDER_TRANSCOLOR); - SetEntityRenderColor(iClient, 255, 255, 255, 255); - new TFClassType:PlayerClass = TF2_GetPlayerClass(iClient); - new iMaxHealth = g_iClassMaxHealth[PlayerClass]; - SetEntityHealth(iClient, iMaxHealth); - } - g_aPlayers[iClient][CycleColor] = 0; - g_aPlayers[iClient][IsImmune] = false; -} - -stock LoadColors() -{ - g_iColors[Green][iRed] = 0; - g_iColors[Green][iGreen] = 255; - g_iColors[Green][iBlue] = 0; - - g_iColors[Black][iRed] = 10; - g_iColors[Black][iGreen] = 10; - g_iColors[Black][iBlue] = 0; - - g_iColors[Red][iRed] = 255; - g_iColors[Red][iGreen] = 0; - g_iColors[Red][iBlue] = 0; - - g_iColors[Blue][iRed] = 0; - g_iColors[Blue][iGreen] = 0; - g_iColors[Blue][iBlue] = 255; -} - -stock TF2_AddCond(client, cond) -{ - new Handle:cvar = FindConVar("sv_cheats"), bool:enabled = GetConVarBool(cvar), flags = GetConVarFlags(cvar); - if(!enabled) - { - SetConVarFlags(cvar, flags^FCVAR_NOTIFY); - SetConVarBool(cvar, true); - } - FakeClientCommand(client, "addcond %i", cond); - if(!enabled) - { - SetConVarBool(cvar, false); - SetConVarFlags(cvar, flags); - } -} - -stock TF2_RemoveCond(client, cond) -{ - new Handle:cvar = FindConVar("sv_cheats"), bool:enabled = GetConVarBool(cvar), flags = GetConVarFlags(cvar); - if(!enabled) - { - SetConVarFlags(cvar, flags^FCVAR_NOTIFY); - SetConVarBool(cvar, true); - } - FakeClientCommand(client, "removecond %i", cond); - if(!enabled) - { - SetConVarBool(cvar, false); - SetConVarFlags(cvar, flags); - } -} - -/** -Enabled hook - */ - -public EnabledChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (StringToInt(newValue) == 0) - { - UnhookEvent("player_spawn", HookPlayerSpawn, EventHookMode_Post); - UnhookEvent("teamplay_round_start", HookRoundStart, EventHookMode_Post); - UnhookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - for (new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][bIsAdmin] && g_aPlayers[i][IsImmune]) - { - DisableImmunity(i); - } - } - g_bIsEnabled = false; - } - else - { - HookEvent("player_spawn", HookPlayerSpawn, EventHookMode_Post); - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_Post); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - g_bIsEnabled = true; - } -} diff --git a/Simple Team Balancer/addons/sourcemod/scripting/simple-spectate.sp b/Simple Team Balancer/addons/sourcemod/scripting/simple-spectate.sp deleted file mode 100644 index 4108f8f..0000000 --- a/Simple Team Balancer/addons/sourcemod/scripting/simple-spectate.sp +++ /dev/null @@ -1,2022 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Spectate -Description: - Spectate a player and follow them through death. -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include -#undef REQUIRE_EXTENSIONS -#undef AUTOLOAD_EXTENSIONS -#tryinclude -#define AUTOLOAD_EXTENSIONS -#define REQUIRE_EXTENSIONS - -#define PLUGIN_VERSION "1.2.1.$Rev$" - -#define SPECMODE_NONE 0 -#define SPECMODE_FIRSTPERSON 4 -#define SPECMODE_3RDPERSON 5 -#define SPECMODE_FREELOOK 6 -#define SPECMODE_CSS_FIRSTPERSON 3 -#define SPECMODE_CSS_3RDPERSON 4 -#define SPECMODE_CSS_FREELOOK 5 - -enum e_CvarHandles -{ - Handle:hHudMode, - Handle:hMenuType, - Handle:hRestrictHud, - Handle:hBan, - Handle:hBanPerm, - Handle:hBeacon, - Handle:hBlind, - Handle:hCheater, - Handle:hDrug, - Handle:hFreeze, - Handle:hFreezeBomb, - Handle:hKick, - Handle:hSlap, - Handle:hSlay, - Handle:hTimeBomb -}; - -enum e_CvarSettings -{ - bool:bHudMode, - bool:bMenuType, - bool:bRestrictHud, - bool:bBan, - bool:bBanPerm, - bool:bBeacon, - bool:bBlind, - bool:bCheater, - bool:bDrug, - bool:bFreeze, - bool:bFreezebomb, - bool:bKick, - bool:bSlap, - bool:bSlay, - bool:bTimeBomb -}; - -enum e_PluginSettings -{ - bool:bUseSteamBans, - bool:bUseSourceBans, - bool:bUseMySQLBans, - bool:bCanHUD, - bool:bUseDukehacks -}; - -enum e_Menus -{ - Handle:hSelectPlayer, - Handle:hBanTime, - Handle:hReason -}; - -enum e_Punishments -{ - Punish_None, - Punish_Ban, - Punish_Beacon, - Punish_Blind, - Punish_Cheater, - Punish_Drug, - Punish_Freeze, - Punish_FreezeBomb, - Punish_Kick, - Punish_Slap, - Punish_Slay, - Punish_TimeBomb -}; - -enum e_PlayerData -{ - bool:bIsDisplayingHud, - bool:bIsFlaggedCheater, - Handle:hHudTimer, - Handle:hTargetTimer, - iTargetIndex, - e_Punishments:TargetPunishment, - iBanTime -}; - -new Handle:sm_spectate_adminflag = INVALID_HANDLE; -new Handle:g_hAdminMenu = INVALID_HANDLE; -new Handle:g_hHud = INVALID_HANDLE; -new Handle:g_aPluginCvar[e_CvarHandles]; -new g_aPluginCvarSettings[e_CvarSettings]; -new g_aPluginSettings[e_PluginSettings]; -new g_aMenus[e_Menus]; -new g_aPlayers[MAXPLAYERS + 1][e_PlayerData]; -new String:g_sAdminFlags[16]; -new String:g_sPunishments[e_Punishments][15] = { "None", "Ban", "Beacon", "Blind", "Cheater", "Drug", "Freeze", "FreezeBomb", "Kick", "Slap", "Slay", "TimeBomb" }; - -public Plugin:myinfo = -{ - name = "Simple Spectate", - author = "Simple Plugins", - description = "Spectate a player and follow them through death.", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -}; - -/** -Sourcemod callbacks -*/ -public OnPluginStart() -{ - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook the game events - */ - LogAction(0, -1, "[SSPEC] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_team", HookPlayerChangeTeam, EventHookMode_Pre); - - /** - Need to create all of our console variables. - */ - CreateConVar("sm_spectate_version", PLUGIN_VERSION, "Sourcemod Spectate", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - g_aPluginCvar[hHudMode] = CreateConVar("sm_spectate_hudmode", "1", "Hud Mode: 0 = Hud Text | 1 = Panel/Menu (NOTE: The panel/menu will override other menus until canceled)"); - g_aPluginCvar[hMenuType] = CreateConVar("sm_spectate_menutype", "0", "Menu Mode: 0 = Panel | 1 = Menu"); - g_aPluginCvar[hRestrictHud] = CreateConVar("sm_spectate_restricthud", "0", "Restrict the hud to the admin flag provided"); - g_aPluginCvar[hBan] = CreateConVar("sm_spectate_ban", "1", "Enable/Disable ban option"); - g_aPluginCvar[hBanPerm] = CreateConVar("sm_spectate_banperm", "1", "Enable/Disable permanent ban option"); - g_aPluginCvar[hBeacon] = CreateConVar("sm_spectate_beacon", "1", "Enable/Disable beacon option"); - g_aPluginCvar[hBlind] = CreateConVar("sm_spectate_blind", "1", "Enable/Disable blind option"); - g_aPluginCvar[hCheater] = CreateConVar("sm_spectate_cheater", "1", "Enable/Disable cheater option"); - g_aPluginCvar[hDrug] = CreateConVar("sm_spectate_drug", "1", "Enable/Disable drug option"); - g_aPluginCvar[hFreeze] = CreateConVar("sm_spectate_freeze", "1", "Enable/Disable freeze option"); - g_aPluginCvar[hFreezeBomb] = CreateConVar("sm_spectate_freezebomb", "1", "Enable/Disable freezebomb option"); - g_aPluginCvar[hKick] = CreateConVar("sm_spectate_kick", "1", "Enable/Disable kick option"); - g_aPluginCvar[hSlap] = CreateConVar("sm_spectate_slap", "1", "Enable/Disable slap option"); - g_aPluginCvar[hSlay] = CreateConVar("sm_spectate_slay", "1", "Enable/Disable slay option"); - g_aPluginCvar[hTimeBomb] = CreateConVar("sm_spectate_timebomb", "1", "Enable/Disable timebomb option"); - - sm_spectate_adminflag = CreateConVar("sm_spectate_adminflag", "d", "Admin Flag to use for admin hud"); - - /** - Hook console variables - */ - new e_CvarHandles:iCvar; - for ( ; _:iCvar < sizeof(g_aPluginCvar); iCvar++) - { - HookConVarChange(g_aPluginCvar[iCvar], ConVarSettingsChanged); - } - - /** - Need to register the commands we are going to create and use. - */ - RegConsoleCmd("sm_spectate", Command_Spectate, "Spectate a player"); - RegConsoleCmd("sm_spec", Command_Spectate, "Spectate a player"); - RegConsoleCmd("sm_observe", Command_Spectate, "Spectate a player"); - RegConsoleCmd("sm_stopspec", Command_StopSpectate, "Stop Spectating a player"); - RegConsoleCmd("sm_endobserve", Command_StopSpectate, "Stop Spectating a player"); - RegConsoleCmd("sm_specinfo", Command_ToggleHud, "Toggles the hud display if in spectator"); - - /** - Now we have to deal with the admin menu. If the admin library is loaded call the function to add our items. - */ - new Handle:gTopMenu; - if (LibraryExists("adminmenu") && ((gTopMenu = GetAdminTopMenu()) != INVALID_HANDLE)) - { - OnAdminMenuReady(gTopMenu); - } - - /** - Deal with the hud - Thanks to Spray Trace plugin (http://forums.alliedmods.net/showthread.php?p=665448) - */ - new String:sHudGames[32]; - GetGameFolderName(sHudGames, sizeof(sHudGames)); - g_aPluginSettings[bCanHUD] = StrEqual(sHudGames,"tf",false) - || StrEqual(sHudGames,"hl2mp",false) - || StrEqual(sHudGames,"sourceforts",false) - || StrEqual(sHudGames,"obsidian",false) - || StrEqual(sHudGames,"left4dead",false) - || StrEqual(sHudGames,"l4d",false); - - if (g_aPluginSettings[bCanHUD]) - { - g_hHud = CreateHudSynchronizer(); - } - - /** - Load translations - */ - LoadTranslations ("common.phrases"); - LoadTranslations ("simplespectate.phrases"); - - /** - Create the config file - */ - AutoExecConfig(true); -} - -public OnConfigsExecuted() -{ - new e_CvarHandles:iCvar; - for ( ; _:iCvar < sizeof(g_aPluginCvarSettings); iCvar++) - { - g_aPluginCvarSettings[iCvar] = GetConVarBool(g_aPluginCvar[iCvar]); - } - - /* - Build the global menus - */ - g_aMenus[hSelectPlayer] = BuildSelectPlayerMenu(); - g_aMenus[hBanTime] = BuildBanTimeMenu(); - g_aMenus[hReason] = BuildReasonMenu(); - - GetConVarString(sm_spectate_adminflag, g_sAdminFlags, sizeof(g_sAdminFlags)); -} - -public OnAllPluginsLoaded() -{ - - /* - Check for steambans - */ - if (FindConVar("sbsrc_version") != INVALID_HANDLE) - { - g_aPluginSettings[bUseSteamBans] = true; - } - else - { - g_aPluginSettings[bUseSteamBans] = false; - } - - /* - Check for sourcebans - */ - if (FindConVar("sb_version") != INVALID_HANDLE) - { - g_aPluginSettings[bUseSourceBans] = true; - } - else - { - g_aPluginSettings[bUseSourceBans] = false; - } - - /* - Check for mysql bans - */ - if (FindConVar("mysql_bans_version") != INVALID_HANDLE) - { - g_aPluginSettings[bUseMySQLBans] = true; - } - else - { - g_aPluginSettings[bUseMySQLBans] = false; - } - - /* - Check for dukehacks - */ - new String:sExtError[256]; - new iExtStatus = GetExtensionFileStatus("dukehacks.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SSPEC] Dukehacks extension was not found."); - LogAction(0, -1, "[SSPEC] Plugin continued to load, but that feature will not be used."); - g_aPluginSettings[bUseDukehacks] = false; - } - else if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SSPEC] Dukehacks extension is loaded with errors."); - LogAction(0, -1, "[SSPEC] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SSPEC] Plugin continued to load, but that feature will not be used."); - g_aPluginSettings[bUseDukehacks] = false; - } - else if (iExtStatus == 1) - { - LogAction(0, -1, "[SSPEC] Dukehacks extension is loaded and will be used."); - g_aPluginSettings[bUseDukehacks] = true; - dhAddClientHook(CHK_TakeDamage, Hacks_TakeDamageHook); - } - - /* - Deal with some known plugin conflicts - */ - new Handle:hObserveClient = FindConVar("observe_version"); - if (hObserveClient != INVALID_HANDLE) - { - new String:sNewFile[PLATFORM_MAX_PATH + 1], String:sOldFile[PLATFORM_MAX_PATH + 1]; - BuildPath(Path_SM, sNewFile, sizeof(sNewFile), "plugins/disabled/observe.smx"); - BuildPath(Path_SM, sOldFile, sizeof(sOldFile), "plugins/observe.smx"); - - /** - Check if plugins/observe.smx exists, and if not, ignore - */ - if(!FileExists(sOldFile)) - { - return; - } - - /** - Check if plugins/disabled/observe.smx already exists, and if so, delete it - */ - if(FileExists(sNewFile)) - { - DeleteFile(sNewFile); - } - - /** - Unload plugins/observe.smx and move it to plugins/disabled/observe.smx - */ - LogAction(0, -1, "Detected the plugin ObserveClient"); - LogAction(0, -1, "ObserveClient plugin conflicts with Simple Spectate"); - LogAction(0, -1, "Unloading plugin and disabling ObserveClient plugin"); - ServerCommand("sm plugins unload observe"); - RenameFile(sNewFile, sOldFile); - } -} - -public OnLibraryRemoved(const String:name[]) -{ - if (StrEqual(name, "adminmenu")) - { - - /** - Looks like the admin menu was removed. Set the global. - */ - g_hAdminMenu = INVALID_HANDLE; - } - else if (StrEqual(name, "simpleplugins")) - { - //something - } -} - -public OnClientDisconnect(client) -{ - - /** - Cleanup the clients variables. - */ - ResetClient(client); - - /** - Run a loop and see if we are supposed to spectate this person (is a target) - */ - for(new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][iTargetIndex] == client) - { - - /** - Cleanup the clients variables. - */ - StopFollowingPlayer(i); - g_aPlayers[i][TargetPunishment] = Punish_None; - g_aPlayers[i][iBanTime] = 0; - } - } -} - -/** -Thirdparty callbacks -*/ -public SM_OnPlayerMoved(Handle:plugin, client, team) -{ - - /** - Make sure we called the move function - */ - if (plugin != GetMyHandle()) - { - return; - } - - //Nothing -} - -public Action:Hacks_TakeDamageHook(client, attacker, inflictor, Float:damage, &Float:multiplier, damagetype) -{ - - /** - Check for a valid client - */ - if (client > 0 && client <= MaxClients) - { - - /** - Check if the client taking damage is flagged as a cheater - */ - if (g_aPlayers[client][bIsFlaggedCheater]) - { - - /** - Check for fall damage and increase it - */ - if (damagetype & DMG_FALL) - { - multiplier *= 1000.0; - return Plugin_Changed; - } - } - } - - /** - Check for a valid attacker - */ - if (attacker > 0 && attacker <= MaxClients) - { - - /** - Check if the attacker causing the damage is flagged as a cheater - */ - if (g_aPlayers[attacker][bIsFlaggedCheater]) - { - - /** - Make sure they are not hurting themselves - */ - if (client != attacker) - { - - /** - Stop the damage - */ - multiplier *= 0.0; - return Plugin_Changed; - } - } - } - return Plugin_Continue; -} - -/** -Events -*/ -public Action:HookPlayerChangeTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get the client and team - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - new iTeam = GetEventInt(event, "team"); - - /** - Make sure it's a valid client - */ - if (iClient == 0) - { - return Plugin_Continue; - } - - /** - If it's a move to spectator start displaying the hud - */ - else if ((iTeam == g_aCurrentTeams[Spectator]) && (GetUserFlagBits(iClient) & ADMFLAG_GENERIC)) - { - StartDisplayingHud(iClient); - - /** - If the event was going to be broadcasted, we refire it so it is not broadcasted and stop this one - */ - if (!dontBroadcast) - { - new Handle:hEvent = CreateEvent("player_team"); - SetEventInt(hEvent, "userid", GetEventInt(event, "userid")); - SetEventInt(hEvent, "team", GetEventInt(event, "team")); - SetEventInt(hEvent, "oldteam", GetEventInt(event, "oldteam")); - SetEventBool(hEvent, "disconnect", GetEventBool(event, "disconnect")); - - if (g_CurrentMod == GameType_DOD || g_CurrentMod == GameType_L4D || g_CurrentMod == GameType_TF) - { - new String:sClientName[MAX_NAME_LENGTH + 1]; - GetClientName(client, sClientName, sizeof(sClientName)); - SetEventBool(hEvent, "autoteam", GetEventBool(event, "autoteam")); - SetEventBool(hEvent, "silent", true); - SetEventString(hEvent, "name", sClientName); - FireEvent(hEvent, true); - } - else - { - FireEvent(hEvent, true); - } - return Plugin_Handled; - } - } - - /** - Otherwise cleanup the client - */ - else - { - StopDisplayingHud(iClient); - StopFollowingPlayer(iClient); - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -/** -Commands -*/ -public Action:Command_Spectate(client, args) -{ - - /** - See if we already have a target (for toggling of command) - */ - if (g_aPlayers[client][iTargetIndex]) - { - - /** - We do, toggle it off - */ - StopFollowingPlayer(client); - - /** - We are done, bug out. - */ - return Plugin_Handled; - } - - /** - We don't... must want to enable it - See if we have some command arguments. - */ - new iCmdArgs = GetCmdArgs(); - if (iCmdArgs == 0) - { - - /** - We don't have any. Display the player menu. - */ - if (g_aPlayers[client][bIsDisplayingHud]) - { - StopDisplayingHud(client); - } - - DisplayMenu(BuildPlayerListMenu(), client, MENU_TIME_FOREVER); - return Plugin_Handled; - } - - /** - We have an argument. - Try to find the target. - */ - new String:sPlayer[128]; - GetCmdArg(1, sPlayer, sizeof(sPlayer)); - new iTarget = FindTarget(client, sPlayer, true, true); - if (iTarget == -1 || !IsClientInGame(iTarget)) - { - - /** - We couldn't find the target. Display the player menu. - */ - if (g_aPlayers[client][bIsDisplayingHud]) - { - StopDisplayingHud(client); - } - - DisplayMenu(BuildPlayerListMenu(), client, MENU_TIME_FOREVER); - return Plugin_Handled; - } - - /** - We found the target. - Call the stock function to spectate the target. - */ - StartFollowingPlayer(client, iTarget); - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_StopSpectate(client, args) -{ - - /** - Cleanup the clients variables. - */ - StopFollowingPlayer(client); - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_ToggleHud(client, args) -{ - - /** - Toggle the hud - */ - if (g_aPlayers[client][bIsDisplayingHud]) - { - StopDisplayingHud(client); - } - else - { - StartDisplayingHud(client); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -/** -Timers -*/ -public Action:Timer_ResetTarget(Handle:timer, any:client) -{ - - new iTargetID = GetEntPropEnt(client, Prop_Send, "m_hObserverTarget"); - - if (iTargetID != g_aPlayers[client][iTargetIndex] && IsPlayerAlive(g_aPlayers[client][iTargetIndex])) - { - - /** - Run the command to spectate the target from the clients prospectative. - */ - FakeClientCommandEx(client, "spec_player \"%N\"", g_aPlayers[client][iTargetIndex]); - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -public Action:Timer_UpdateHud(Handle:timer, any:client) -{ - - /** - Make sure the client is still in game and a spectator - */ - if (!IsClientConnected(client) || !IsClientInGame(client) || GetClientTeam(client) != g_aCurrentTeams[Spectator] || !g_aPlayers[client][bIsDisplayingHud]) - { - - /** - We are done, bug out - */ - g_aPlayers[client][hHudTimer] = INVALID_HANDLE; - g_aPlayers[client][bIsDisplayingHud] = false; - return Plugin_Stop; - } - /** - Get the target - */ - new iTarget = GetEntPropEnt(client, Prop_Send, "m_hObserverTarget"); - - /** - Check to make sure the target is valid - */ - if (iTarget <= 0 || iTarget > MaxClients) - { - return Plugin_Continue; - } - - /** - Get the spectator mode - */ - new iSpecMode = GetEntProp(client, Prop_Send, "m_iObserverMode"); - - /** - This is a double check to make sure we are in spec - If we are on a regular team, specmod would = none or zero - */ - if (iSpecMode == SPECMODE_NONE) - { - - /** - We are done, bug out - */ - g_aPlayers[client][hHudTimer] = INVALID_HANDLE; - g_aPlayers[client][bIsDisplayingHud] = false; - return Plugin_Stop; - } - - /** - Check the spectator mode - CSS has different index's so we have to check game type first - */ - if (g_CurrentMod == GameType_CSS) - { - switch (iSpecMode) - { - case SPECMODE_CSS_FIRSTPERSON: - { - //Do Nothing - } - case SPECMODE_CSS_3RDPERSON: - { - //Do Nothing - } - case SPECMODE_CSS_FREELOOK: - { - return Plugin_Continue; - } - } - } - else - { - switch (iSpecMode) - { - case SPECMODE_FIRSTPERSON: - { - //Do Nothing - } - case SPECMODE_3RDPERSON: - { - //Do Nothing - } - case SPECMODE_FREELOOK: - { - return Plugin_Continue; - } - } - } - - - /** - Display with the hud - */ - if (g_aPluginSettings[bCanHUD] && !g_aPluginCvarSettings[bHudMode]) - { - new String:sSteamID[64]; - GetClientAuthString(iTarget, sSteamID, sizeof(sSteamID)); - SetHudTextParams(0.04, 0.6, 0.5, 255, 50, 50, 255); - ShowSyncHudText(client, g_hHud, "%N [%s]", iTarget, sSteamID); - } - else if (g_aPluginCvarSettings[bHudMode]) - { - if (g_aPluginCvarSettings[bMenuType]) - { - DisplayMenu(BuildPlayerHudMenu(client, iTarget), client, 1); - } - else - { - new Handle:hPanel = BuildPlayerHudPanel(client, iTarget); - SendPanelToClient(hPanel, client, Panel_PlayerHud, 1); - CloseHandle(hPanel); - } - } - - /** - We are done, keep going! - */ - return Plugin_Continue; -} - -/** -Admin Menu Callbacks -*/ -public OnAdminMenuReady(Handle:topmenu) -{ - if (topmenu == g_hAdminMenu) - { - return; - } - g_hAdminMenu = topmenu; - new TopMenuObject:player_commands = FindTopMenuCategory(g_hAdminMenu, ADMINMENU_PLAYERCOMMANDS); - if (player_commands == INVALID_TOPMENUOBJECT) - { - return; - } - AddToTopMenu(g_hAdminMenu, - "sm_spectate", - TopMenuObject_Item, - AdminMenu_SpecPlayer, - player_commands, - "sm_spectate", - ADMFLAG_GENERIC); -} - -public AdminMenu_SpecPlayer(Handle:topmenu, TopMenuAction:action, TopMenuObject:object_id, param, String:buffer[], maxlength) -{ - if (action == TopMenuAction_DisplayOption) - { - - if (g_aPlayers[param][bIsDisplayingHud]) - { - StopDisplayingHud(param); - } - /** - See if we already have a target - */ - if (g_aPlayers[param][iTargetIndex]) - { - Format(buffer, maxlength, "Spectate(Disable)"); - } - else - { - Format(buffer, maxlength, "Spectate(Select Player)"); - } - } - else if (action == TopMenuAction_SelectOption) - { - - /** - See if we already have a target - */ - if (g_aPlayers[param][iTargetIndex]) - { - - /** - We do, toggle it off - */ - StopFollowingPlayer(param); - - /** - We are done, bug out. - */ - return; - } - else - { - DisplayMenu(BuildPlayerListMenu(), param, MENU_TIME_FOREVER); - } - } -} - -/** -Select Player Menu Callbacks -*/ -public Menu_PlayerList(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - /** - Get the selected player - */ - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - new iTarget = GetClientOfUserId(StringToInt(sSelection)); - - /** - Start following the player - */ - StartFollowingPlayer(param1, iTarget); - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_GENERIC) - { - - /** - Display the last admin menu - */ - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } - else if (param2 == MenuCancel_Exit && GetClientTeam(param1) == g_aCurrentTeams[Spectator]) - { - /** - They canceled the current menu, start the hud back up - */ - StartDisplayingHud(param1); - } - } - else if (action == MenuAction_End) - { - - /** - Not a global menu, close it - */ - CloseHandle(menu); - } -} - -public Menu_SelectPlayer(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - - /** - Get the selected player - */ - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (strcmp(sSelection, "Current", false) == 0) - { - /** - Get the current target - */ - new iTarget = GetEntPropEnt(param1, Prop_Send, "m_hObserverTarget"); - - /** - Check to make sure the target is valid - */ - if (iTarget <= 0 || iTarget > MaxClients) - { - PrintToChat(param1, "\x03[SM-SPEC]\x01 %t", "Invalid Target"); - DisplayMenu(BuildPlayerListMenu(), param1, MENU_TIME_FOREVER); - } - - /** - Start following the player - */ - StartFollowingPlayer(param1, iTarget); - } - else - { - - /** - They want to select a player, show the player list - */ - DisplayMenu(BuildPlayerListMenu(), param1, MENU_TIME_FOREVER); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - - /** - They canceled the current menu, start the hud back up - */ - StartDisplayingHud(param1); - } - } - else if (action == MenuAction_End) - { - /** - Its a global menu, leave it alive - */ - } -} - -/** -Punishment Menu Callbacks -*/ -public Menu_Punishments(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - - /** - Get the menu selection - */ - new String:sSelection[15]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - - /** - Search for the correct index - */ - new e_Punishments:Index = Punish_None; - for ( ; _:Index <= sizeof(g_sPunishments); Index++) - { - if (StrEqual(sSelection, g_sPunishments[Index])) - { - break; - } - } - - /** - Display the next menu - */ - if (Index == Punish_Ban) - { - - /** - Set the punishment index and display ban time menu - */ - g_aPlayers[param1][TargetPunishment] = Index; - DisplayMenu(g_aMenus[hBanTime], param1, MENU_TIME_FOREVER); - } - else if (Index == Punish_Cheater) - { - - /** - Ask for confirmation before we set punishment index - */ - new Handle:hPanel = BuildAdminCheaterPanel(); - SendPanelToClient(hPanel, param1, Panel_AdminCheater, MENU_TIME_FOREVER); - CloseHandle(hPanel); - } - else - { - - /** - Set the punishment index and display reason menu - */ - g_aPlayers[param1][TargetPunishment] = Index; - DisplayMenu(g_aMenus[hReason], param1, MENU_TIME_FOREVER); - } - } - else if (action == MenuAction_Cancel) - { - - /** - They canceled the current menu, start the hud back up - */ - StartDisplayingHud(param1); - } - else if (action == MenuAction_End) - { - - /** - Not a global menu, close it - */ - CloseHandle(menu); - } -} - -public Menu_BanTime(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - - /** - Get the menu selection - */ - new String:sSelection[15]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - - /** - Set the ban time global - */ - g_aPlayers[param1][iBanTime] = StringToInt(sSelection); - - /** - Display the reason menu - */ - DisplayMenu(g_aMenus[hReason], param1, MENU_TIME_FOREVER); - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - - /** - They canceled the current menu, start the hud back up - */ - StartDisplayingHud(param1); - } - } - else if (action == MenuAction_End) - { - /** - Its a global menu, leave it alive - */ - } -} - -public Menu_Reason(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - - /** - Get the menu selection - */ - new String:sSelection[15]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - - /** - Perform the punishment - */ - PerformPunishment(param1, g_aPlayers[param1][iTargetIndex], g_aPlayers[param1][TargetPunishment], sSelection, g_aPlayers[param1][iBanTime]); - - /** - Reactivate the hud if still in spectator - */ - if (GetClientTeam(param1) == g_aCurrentTeams[Spectator]) - { - StartDisplayingHud(param1); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - - /** - They canceled the current menu, start the hud back up - */ - StartDisplayingHud(param1); - } - } - else if (action == MenuAction_End) - { - /** - Its a global menu, leave it alive - */ - } -} - -public Panel_AdminCheater(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - if (param2 == 1) - { - - /** - Set the punishment index and display reason menu - */ - g_aPlayers[param1][TargetPunishment] = Punish_Cheater; - DisplayMenu(g_aMenus[hReason], param1, MENU_TIME_FOREVER); - } - else - { - - /** - Reactivate the hud if still in spectator - */ - if (GetClientTeam(param1) == g_aCurrentTeams[Spectator]) - { - StartDisplayingHud(param1); - } - } - } -} - -public Panel_PublicCheater(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - if (param2 == 1) - { - //Waiting for SB 2.0 and sb_submission to be published - } - else - { - - /** - Reactivate the hud if still in spectator - */ - if (GetClientTeam(param1) == g_aCurrentTeams[Spectator]) - { - StartDisplayingHud(param1); - } - } - } -} - -/** -Hud Menu/Panel Callbacks -*/ -public Menu_PlayerHud(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "stop", false)) - { - StopFollowingPlayer(param1); - } - else if (StrEqual(sSelection, "start", false)) - { - StopDisplayingHud(param1); - DisplayMenu(g_aMenus[hSelectPlayer], param1, MENU_TIME_FOREVER); - } - else if (StrEqual(sSelection, "removecheater", false)) - { - g_aPlayers[g_aPlayers[param1][iTargetIndex]][bIsFlaggedCheater] = false; - } - else if (StrEqual(sSelection, "punish", false)) - { - if (g_aPlayers[param1][iTargetIndex]) - { - StopDisplayingHud(param1); - DisplayMenu(BuildPunishmentMenu(param1), param1, MENU_TIME_FOREVER); - } - else - { - StopDisplayingHud(param1); - PrintToChat(param1, "\x03[SM-SPEC]\x01 %t", "Must Have Target"); - DisplayMenu(g_aMenus[hSelectPlayer], param1, MENU_TIME_FOREVER); - } - } - else if (StrEqual(sSelection, "reportcheater", false)) - { - if (g_aPlayers[param1][iTargetIndex]) - { - StopDisplayingHud(param1); - new Handle:hPanel = BuildPublicCheaterPanel(); - SendPanelToClient(hPanel, param1, Panel_PublicCheater, MENU_TIME_FOREVER); - CloseHandle(hPanel); - } - else - { - StopDisplayingHud(param1); - PrintToChat(param1, "\x03[SM-SPEC]\x01 %t", "Must Have Target"); - DisplayMenu(g_aMenus[hSelectPlayer], param1, MENU_TIME_FOREVER); - } - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_Interrupted) - { - if (GetClientMenu(param1) == MenuSource_External) - { - StopDisplayingHud(param1); - } - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } -} - -public Panel_PlayerHud(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - switch (param2) - { - case 1: - { - if (g_aPlayers[param1][iTargetIndex]) - { - StopFollowingPlayer(param1); - } - else - { - StopDisplayingHud(param1); - DisplayMenu(BuildSelectPlayerMenu(), param1, MENU_TIME_FOREVER); - } - } - case 2: - { - if (!g_aPlayers[param1][iTargetIndex]) - { - StopDisplayingHud(param1); - PrintToChat(param1, "\x03[SM-SPEC]\x01 %t", "Must Have Target"); - DisplayMenu(g_aMenus[hSelectPlayer], param1, MENU_TIME_FOREVER); - return; - } - - if ((GetUserFlagBits(param1) & ADMFLAG_GENERIC) || (GetUserFlagBits(param1) & ADMFLAG_ROOT)) - { - if (g_aPlayers[g_aPlayers[param1][iTargetIndex]][bIsFlaggedCheater] && (GetUserFlagBits(param1) & ADMFLAG_ROOT)) - { - //Remove cheater flag - g_aPlayers[g_aPlayers[param1][iTargetIndex]][bIsFlaggedCheater] = false; - } - else - { - //Punish menu - StopDisplayingHud(param1); - DisplayMenu(BuildPunishmentMenu(param1), param1, MENU_TIME_FOREVER); - } - } - else - { - //Report Cheater - new Handle:hPanel = BuildPublicCheaterPanel(); - SendPanelToClient(hPanel, param1, Panel_PublicCheater, MENU_TIME_FOREVER); - CloseHandle(hPanel); - } - } - case 3: - { - StopDisplayingHud(param1); - } - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_Interrupted) - { - if (GetClientMenu(param1) == MenuSource_External) - { - StopDisplayingHud(param1); - } - } - } -} - - -/** -Stock functions -*/ -stock StartFollowingPlayer(client, target) -{ - - /** - If we have an open timer, close it. - */ - if (g_aPlayers[client][hTargetTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[client][hTargetTimer]); - g_aPlayers[client][hTargetTimer] = INVALID_HANDLE; - } - - /** - Make sure the target is on a non spectator team, and the client != target - */ - if (client == target) - { - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Yourself"); - return; - } - new iTargetTeam = GetClientTeam(target); - if (iTargetTeam == g_aCurrentTeams[Spectator] || iTargetTeam == g_aCurrentTeams[Unknown]) - { - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Spectator"); - return; - } - - /** - Check to see if client is already a spectator - */ - if (GetClientTeam(client) != g_aCurrentTeams[Spectator]) - { - - /** - Client is not a spectator, lets move them to spec. - */ - SM_MovePlayer(client, g_aCurrentTeams[Spectator]); - } - - /** - If we are using steambans call sb_status - */ - if (g_aPluginSettings[bUseSteamBans]) - { - FakeClientCommandEx(client, "sb_status"); - } - - - /** - Set the global and start to spectate the target. - Making sure it's long enough to deal with moving the client to spec if we had to. - */ - new String:sTargetName[MAX_NAME_LENGTH + 1]; - GetClientName(target, sTargetName, sizeof(sTargetName)); - g_aPlayers[client][iTargetIndex] = target; - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Spectating", sTargetName); - g_aPlayers[client][hTargetTimer] = CreateTimer(0.5, Timer_ResetTarget, client, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); - if (!g_aPlayers[client][bIsDisplayingHud] && GetClientTeam(client) == g_aCurrentTeams[Spectator]) - { - StartDisplayingHud(client); - } -} - -stock StopFollowingPlayer(client) -{ - - /** - If we have an open timer, close it. - */ - if (g_aPlayers[client][hTargetTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[client][hTargetTimer]); - } - - /** - Tell the client we can't spec his target anymore... if they are in game. - */ - if (IsClientInGame(client) && g_aPlayers[client][iTargetIndex] != 0) - { - new String:sTargetName[MAX_NAME_LENGTH + 1]; - GetClientName(g_aPlayers[client][iTargetIndex], sTargetName, sizeof(sTargetName)); - if (!IsClientConnected(g_aPlayers[client][iTargetIndex]) || !IsClientInGame(g_aPlayers[client][iTargetIndex])) - { - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Target Left"); - } - else - { - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Stopped spectating", sTargetName); - } - } - - /** - Null the globals. - */ - g_aPlayers[client][iTargetIndex] = 0; - g_aPlayers[client][hTargetTimer] = INVALID_HANDLE; -} - -stock StartDisplayingHud(client) -{ - if (g_aPluginCvarSettings[bRestrictHud] && !SM_IsValidAdmin(client, g_sAdminFlags)) - { - return; - } - else - { - /** - Double check the hud timer - We should not have one, but if we do, lets cancel it for the current callback - */ - StopDisplayingHud(client); - - /** - Now we can safely display the hud and make sure the current stored handle is the current timer - */ - g_aPlayers[client][bIsDisplayingHud] = true; - g_aPlayers[client][hHudTimer] = CreateTimer(0.5, Timer_UpdateHud, client, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); - } -} - -stock StopDisplayingHud(client) -{ - if (g_aPlayers[client][hHudTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[client][hHudTimer]); - } - g_aPlayers[client][hHudTimer] = INVALID_HANDLE; - g_aPlayers[client][bIsDisplayingHud] = false; -} - -stock ResetClient(client) -{ - StopFollowingPlayer(client); - StopDisplayingHud(client); - - g_aPlayers[client][bIsFlaggedCheater] = false; - g_aPlayers[client][TargetPunishment] = Punish_None; - g_aPlayers[client][iBanTime] = -1; -} - -stock PerformPunishment(client, target, e_Punishments:punishment, const String:reason[], time = 300) -{ - new String:sTargetName[MAX_NAME_LENGTH + 1], - String:sTargetID[64]; - - /** - The target could have left the game by the time we get here - Check for a valid target - */ - if (!IsClientConnected(target) || !IsClientInGame(target)) - { - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Target Left"); - return; - } - - GetClientName(target, sTargetName, sizeof(sTargetName)); - GetClientAuthString(target, sTargetID, sizeof(sTargetID)); - - switch (punishment) - { - case Punish_Kick: - { - KickClient(g_aPlayers[client][iTargetIndex], "%s", reason); - } - case Punish_Ban: - { - if (g_aPluginSettings[bUseSourceBans]) - { - ClientCommand(client, "sm_ban #%d %d \"%s\"", GetClientUserId(target), time, reason); - } - else if (g_aPluginSettings[bUseMySQLBans]) - { - ClientCommand(client, "mysql_ban #%d %d \"%s\"", GetClientUserId(target), time, reason); - } - else - { - BanClient(target, time, BANFLAG_AUTHID, reason, reason); - } - } - case Punish_Cheater: - { - g_aPlayers[target][bIsFlaggedCheater] = true; - } - case Punish_Beacon: - { - ClientCommand(client, "sm_beacon \"%s\"", sTargetName); - } - case Punish_Blind: - { - ClientCommand(client, "sm_blind \"%s\"", sTargetName); - } - case Punish_Drug: - { - ClientCommand(client, "sm_drug \"%s\"", sTargetName); - } - case Punish_Freeze: - { - ClientCommand(client, "sm_freeze \"%s\"", sTargetName); - } - case Punish_FreezeBomb: - { - ClientCommand(client, "sm_freezebomb \"%s\"", sTargetName); - } - case Punish_Slap: - { - ClientCommand(client, "sm_slap \"%s\" 10", sTargetName); - } - case Punish_Slay: - { - ClientCommand(client, "sm_slay \"%s\"", sTargetName); - } - case Punish_TimeBomb: - { - ClientCommand(client, "sm_timebomb \"%s\"", sTargetName); - } - } - - if (punishment == Punish_Cheater) - { - LogAction(client, target, "[SM SPEC] %N marked %N(%s) with a %s flag for %s", client, target, sTargetID, g_sPunishments[punishment], reason); - } - else - { - ShowActivity(client, "%t", "Punished", sTargetName, g_sPunishments[punishment], reason); - LogAction(client, target, "[SM SPEC] %N punished %N(%s) with a %s for %s", client, target, sTargetID, g_sPunishments[punishment], reason); - } - - /** - Null the globals. - */ - g_aPlayers[client][TargetPunishment] = Punish_None; - g_aPlayers[client][iBanTime] = -1; -} - -/** -Build the menu of player names -*/ -stock Handle:BuildPlayerListMenu() -{ - new Handle:hMenu = CreateMenu(Menu_PlayerList); - AddTargetsToMenu(hMenu, 0, true, false); - SetMenuTitle(hMenu, "Select A Player:"); - SetMenuExitBackButton(hMenu, true); - return hMenu; -} - -/** -Build the select player menu (current or list of players) -*/ -stock Handle:BuildSelectPlayerMenu() -{ - new Handle:hMenu = CreateMenu(Menu_SelectPlayer); - SetMenuTitle(hMenu, "Select A Player:"); - AddMenuItem(hMenu, "Current", "Current Target"); - AddMenuItem(hMenu, "List", "Player List"); - SetMenuExitBackButton(hMenu, true); - return hMenu; -} - -/** -Build the punishmenu menu -*/ -stock Handle:BuildPunishmentMenu(iClient) -{ - new Handle:hMenu = CreateMenu(Menu_Punishments); - SetMenuTitle(hMenu, "Select A Punishment:"); - SetMenuExitBackButton(hMenu, true); - SetMenuExitButton(hMenu, true); - - if (g_aPluginCvarSettings[bKick] && ((GetUserFlagBits(iClient) & ADMFLAG_GENERIC) || (GetUserFlagBits(iClient) & ADMFLAG_ROOT))) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Kick], "Kick"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Kick], "Kick", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bBan] && ((GetUserFlagBits(iClient) & ADMFLAG_GENERIC) || (GetUserFlagBits(iClient) & ADMFLAG_ROOT))) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Ban], "Ban"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Ban], "Ban", ITEMDRAW_DISABLED); - } - - if (g_aPluginSettings[bUseDukehacks] && g_aPluginCvarSettings[bCheater] && (GetUserFlagBits(iClient) & ADMFLAG_ROOT)) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Cheater], "Flag As Cheater"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Cheater], "Flag As Cheater", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bBeacon]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Beacon], "Beacon"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Beacon], "Beacon", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bBlind]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Blind], "Blind"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Blind], "Blind", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bDrug]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Drug], "Drug"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Drug], "Drug", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bFreeze]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Freeze], "Freeze"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Freeze], "Freeze", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bFreezebomb]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_FreezeBomb], "Freeze Bomb"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_FreezeBomb], "Freeze Bomb", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bSlap]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Slap], "Slap"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Slap], "Slap", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bSlay]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Slay], "Slay"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Slay], "Slay", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bTimeBomb]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_TimeBomb], "Time Bomb"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_TimeBomb], "Time Bomb", ITEMDRAW_DISABLED); - } - - return hMenu; -} - -/** -Build the punishmenu menu -*/ -stock Handle:BuildBanTimeMenu() -{ - new Handle:hMenu = CreateMenu(Menu_BanTime); - SetMenuTitle(hMenu, "Select Ban Type:"); - - if (g_aPluginCvarSettings[bBanPerm]) - { - AddMenuItem(hMenu, "permban", "Permanent"); - } - else - { - AddMenuItem(hMenu, "permban", "Permanent", ITEMDRAW_DISABLED); - } - - AddMenuItem(hMenu, "10", "10 Minutes"); - AddMenuItem(hMenu, "30", "30 Minutes"); - AddMenuItem(hMenu, "60", "1 Hour"); - AddMenuItem(hMenu, "240", "4 Hours"); - AddMenuItem(hMenu, "1440", "1 Day"); - AddMenuItem(hMenu, "10080", "1 Week"); - - SetMenuExitBackButton(hMenu, true); - return hMenu; -} - -/** -Build the punishmenu menu -*/ -stock Handle:BuildReasonMenu() -{ - new Handle:hMenu = CreateMenu(Menu_Reason); - SetMenuTitle(hMenu, "Select A Reason:"); - - AddMenuItem(hMenu, "Abusive", "Abusive"); - AddMenuItem(hMenu, "Racism", "Racism"); - AddMenuItem(hMenu, "General cheating/exploits", "General cheating/exploits"); - AddMenuItem(hMenu, "Wallhack", "Wallhack"); - AddMenuItem(hMenu, "Aimbot", "Aimbot"); - AddMenuItem(hMenu, "Speedhacking", "Speedhacking"); - AddMenuItem(hMenu, "Mic spamming", "Mic spamming"); - AddMenuItem(hMenu, "Admin disrepect", "Admin disrepect"); - AddMenuItem(hMenu, "Camping", "Camping"); - AddMenuItem(hMenu, "Team killing", "Team killing"); - AddMenuItem(hMenu, "Unacceptable Spray", "Unacceptable Spray"); - AddMenuItem(hMenu, "Breaking Server Rules", "Breaking Server Rules"); - AddMenuItem(hMenu, "Other", "Other"); - - SetMenuExitBackButton(hMenu, true); - return hMenu; -} - -/** -Build the cheater displays -*/ -stock Handle:BuildAdminCheaterPanel() -{ - - /** - Create the menu and set the menu options. - */ - new Handle:hPanel = CreatePanel(); - SetPanelTitle(hPanel, "Simple Spectator:"); - - DrawPanelText(hPanel, "Are you sure you want to"); - DrawPanelText(hPanel, "flag this player as a cheater?"); - DrawPanelText(hPanel, "They will not be able to damage"); - DrawPanelText(hPanel, "anyone and die on fall damage."); - DrawPanelItem(hPanel, "Yes"); - DrawPanelItem(hPanel, "No"); - - return hPanel; -} - -stock Handle:BuildPublicCheaterPanel() -{ - - /** - Create the menu and set the menu options. - */ - new Handle:hPanel = CreatePanel(); - SetPanelTitle(hPanel, "Simple Spectator:"); - - DrawPanelText(hPanel, "Are you sure you want to"); - DrawPanelText(hPanel, "submit this player as a cheater?"); - DrawPanelItem(hPanel, "Yes (Not Implemented Yet)", ITEMDRAW_DISABLED); - DrawPanelItem(hPanel, "No"); - return hPanel; -} - -/** -Build the hud displays -*/ -stock Handle:BuildPlayerHudMenu(iClient, iTarget) -{ - - /** - Create all the string variables we will need - */ - new String:sTargetName[MAX_NAME_LENGTH + 1], - String:sTargetID[64], - String:sTargetIP[16]; - - new String:sDisplayName[MAX_NAME_LENGTH + 1], - String:sDisplayID[64], - String:sDisplayIP[64], - String:sDisplayFrags[16], - String:sDisplayDeaths[16]; - - new iTargetFrags, - iTargetDeaths; - - /** - Get the targets information - */ - GetClientName(iTarget, sTargetName, sizeof(sTargetName)); - GetClientIP(iTarget, sTargetIP, sizeof(sTargetIP)); - GetClientAuthString(iTarget, sTargetID, sizeof(sTargetID)); - iTargetFrags = GetClientFrags(iTarget); - iTargetDeaths = GetClientDeaths(iTarget); - - /** - Format the strings for the menu - */ - Format(sDisplayName, sizeof(sDisplayName), "Player: %s", sTargetName); - Format(sDisplayID, sizeof(sDisplayID), "Steam ID: %s", sTargetID); - Format(sDisplayIP, sizeof(sDisplayIP), "IP Address: %s", sTargetIP); - Format(sDisplayFrags, sizeof(sDisplayFrags), "Kills: %i", iTargetFrags); - Format(sDisplayDeaths, sizeof(sDisplayDeaths), "Deaths: %i", iTargetDeaths); - - /** - Create the menu and set the menu options. - */ - new Handle:hMenu = CreateMenu(Menu_PlayerHud); - SetMenuExitBackButton(hMenu, false); - SetMenuTitle(hMenu, "Simple Spectator"); - - AddMenuItem(hMenu, "name", sDisplayName, ITEMDRAW_DISABLED); - AddMenuItem(hMenu, "steamid", sDisplayID, ITEMDRAW_DISABLED); - - if (SM_IsValidAdmin(iClient, g_sAdminFlags)) - { - AddMenuItem(hMenu, "ip", sDisplayIP, ITEMDRAW_DISABLED); - } - - AddMenuItem(hMenu, "kills", sDisplayFrags, ITEMDRAW_DISABLED); - AddMenuItem(hMenu, "deaths", sDisplayDeaths, ITEMDRAW_DISABLED); - - if (g_aPlayers[iClient][iTargetIndex]) - { - AddMenuItem(hMenu, "stop", "Stop Following"); - } - else - { - AddMenuItem(hMenu, "start", "Follow Player"); - } - - if ((GetUserFlagBits(iClient) & ADMFLAG_GENERIC) || (GetUserFlagBits(iClient) & ADMFLAG_ROOT)) - { - if (g_aPlayers[iTarget][bIsFlaggedCheater] && (GetUserFlagBits(iClient) & ADMFLAG_ROOT)) - { - AddMenuItem(hMenu, "removecheater", "Remove Cheater Flag"); - } - else - { - if (CanUserTarget(iClient, iTarget)) - { - AddMenuItem(hMenu, "punish", "Punish Player"); - } - else - { - AddMenuItem(hMenu, "punish", "Punish Player (Immune)", ITEMDRAW_DISABLED); - } - } - } - else - { - AddMenuItem(hMenu, "reportcheater", "Report Cheater"); - } - - SetMenuPagination(hMenu, MENU_NO_PAGINATION); - SetMenuExitButton(hMenu, true); - return hMenu; -} - -stock Handle:BuildPlayerHudPanel(iClient, iTarget) -{ - - /** - Create all the string variables we will need - */ - new String:sTargetName[MAX_NAME_LENGTH + 1], - String:sTargetID[64], - String:sTargetIP[16]; - - new String:sDisplayName[MAX_NAME_LENGTH + 1], - String:sDisplayID[64], - String:sDisplayIP[64], - String:sDisplayFrags[16], - String:sDisplayDeaths[16]; - - new iTargetFrags, - iTargetDeaths; - - /** - Get the targets information - */ - GetClientName(iTarget, sTargetName, sizeof(sTargetName)); - GetClientIP(iTarget, sTargetIP, sizeof(sTargetIP)); - GetClientAuthString(iTarget, sTargetID, sizeof(sTargetID)); - iTargetFrags = GetClientFrags(iTarget); - iTargetDeaths = GetClientDeaths(iTarget); - - /** - Format the strings for the menu - */ - Format(sDisplayName, sizeof(sDisplayName), "Player: %s", sTargetName); - Format(sDisplayID, sizeof(sDisplayID), "Steam ID: %s", sTargetID); - Format(sDisplayIP, sizeof(sDisplayIP), "IP Address: %s", sTargetIP); - Format(sDisplayFrags, sizeof(sDisplayFrags), "Kills: %i", iTargetFrags); - Format(sDisplayDeaths, sizeof(sDisplayDeaths), "Deaths: %i", iTargetDeaths); - - /** - Create the menu and set the menu options. - */ - new Handle:hPanel = CreatePanel(); - SetPanelTitle(hPanel, "Simple Spectator"); - - DrawPanelText(hPanel, "Player Information:"); - DrawPanelText(hPanel, sDisplayName); - DrawPanelText(hPanel, sDisplayID); - if (SM_IsValidAdmin(iClient, g_sAdminFlags)) - { - DrawPanelText(hPanel, sDisplayIP); - } - - DrawPanelText(hPanel, sDisplayFrags); - DrawPanelText(hPanel, sDisplayDeaths); - - if (g_aPlayers[iClient][iTargetIndex]) - { - DrawPanelItem(hPanel, "Stop Following"); - } - else - { - DrawPanelItem(hPanel, "Follow Player"); - } - - if ((GetUserFlagBits(iClient) & ADMFLAG_GENERIC) || (GetUserFlagBits(iClient) & ADMFLAG_ROOT)) - { - if (g_aPlayers[iTarget][bIsFlaggedCheater] && (GetUserFlagBits(iClient) & ADMFLAG_ROOT)) - { - DrawPanelItem(hPanel, "Remove Cheater Flag"); - } - else - { - if (CanUserTarget(iClient, iTarget)) - { - DrawPanelItem(hPanel, "Punish Player"); - } - else - { - DrawPanelItem(hPanel, "Punish Player (Immune)", ITEMDRAW_DISABLED); - } - } - } - else - { - DrawPanelItem(hPanel, "Report Cheater"); - } - - DrawPanelItem(hPanel, "Close Hud Panel"); - return hPanel; -} - -/** -Adjust the settings if a convar was changed -*/ -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - for (new iCvar = 0 ; _:iCvar < sizeof(g_aPluginCvarSettings); iCvar++) - { - if (g_aPluginCvar[_:iCvar] == convar) - { - if (StringToInt(newValue) == 1) - { - g_aPluginCvarSettings[_:iCvar] = true; - } - else - { - g_aPluginCvarSettings[_:iCvar] = false; - } - } - } - - /* - ReBuild the global menu that depends on cvars - */ - g_aMenus[hBanTime] = BuildBanTimeMenu(); - - /** - Run a loop to reset the hud - */ - for(new i = 1; i <= MaxClients; i++) - { - StopDisplayingHud(i); - if (IsClientConnected(i) && IsClientInGame(i) && GetClientTeam(i) == g_aCurrentTeams[Spectator]) - { - StartDisplayingHud(i); - } - } -} diff --git a/Simple Team Balancer/addons/sourcemod/scripting/simple-teammanager.sp b/Simple Team Balancer/addons/sourcemod/scripting/simple-teammanager.sp deleted file mode 100644 index 008f443..0000000 --- a/Simple Team Balancer/addons/sourcemod/scripting/simple-teammanager.sp +++ /dev/null @@ -1,1351 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Team Manager -Description: - Manges players and their team - Admin menu integration - Allows admins/donators to swap their teams (clears force)* - Allows admins to move players to a team (forced\unforced)* - Allows admins to scramble the teams* - *Works with Simple Team Balancer (if installed) -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include - -#define PLUGIN_VERSION "2.1.$Rev$" -#define VOTE_YES "##YES##" -#define VOTE_NO "##NO##" - -enum PlayerData -{ - iNewTeam, - bool:bQueue -}; - -new Handle:stm_enabled = INVALID_HANDLE; -new Handle:stm_logactivity = INVALID_HANDLE; -new Handle:stm_adminflag_swapteam = INVALID_HANDLE; -new Handle:stm_adminflag_moveplayer = INVALID_HANDLE; -new Handle:stm_adminflag_scramble = INVALID_HANDLE; -new Handle:stm_scrambledelay = INVALID_HANDLE; -new Handle:stm_voteenabled = INVALID_HANDLE; -new Handle:stm_votewin = INVALID_HANDLE; -new Handle:stm_votedelay = INVALID_HANDLE; -new Handle:stm_mp_bonusroundtime = INVALID_HANDLE; -new Handle:g_hAdminMenu = INVALID_HANDLE; -new Handle:g_hTimerPrepScramble = INVALID_HANDLE; -new Handle:g_hTimerClearScrambleForce = INVALID_HANDLE; - -new g_aPlayers[MAXPLAYERS + 1][PlayerData]; - -new bool:g_bIsEnabled = true; -new bool:g_bVoteEnabled = true; -new bool:g_bLogActivity = true; -new bool:g_bScrambleRoundEnd = false; -new g_iVoteDelay, g_iLastVoteTime, g_iTimeLeft; -new Float:g_fScrambleDelay, Float:g_fVoteWin; - -public Plugin:myinfo = -{ - name = "Simple Team Manager", - author = "Simple Plugins", - description = "Manages players and thier team.", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -}; - -public OnPluginStart() -{ - - /** - Need to create all of our console variables. - */ - CreateConVar("stm_version", PLUGIN_VERSION, "Simple Team Manager Version",FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - stm_enabled = CreateConVar("stm_enabled", "1", "Enable or Disable Simple Team Manager", _, true, 0.0, true, 1.0); - stm_logactivity = CreateConVar("stm_logactivity", "0", "Enable or Disable the disaplying of events in the log", _, true, 0.0, true, 1.0); - stm_adminflag_swapteam = CreateConVar("stm_adminflag_swapteam", "a", "Admin flag to use for the swapteam command. Must be a in char format."); - stm_adminflag_moveplayer = CreateConVar("stm_adminflag_moveplayer", "c", "Admin flag to use for the moveplayer command. Must be a in char format."); - stm_adminflag_scramble = CreateConVar("stm_adminflag_scramble", "c", "Admin flag to use for the scrambleteam command. Must be a in char format."); - stm_scrambledelay = CreateConVar("stm_scrambledelay", "15", "Delay to scramble teams"); - stm_voteenabled = CreateConVar("stm_voteenabled", "1", "Enable or Disable voting to scramble the teams", _, true, 0.0, true, 1.0); - stm_votewin = CreateConVar("stm_votewin", "0.45", "Win percentage vote must win by", _, true, 0.0, true, 1.0); - stm_votedelay = CreateConVar("stm_votedelay", "600", "Delay before another vote can be cast"); - stm_mp_bonusroundtime = FindConVar("mp_bonusroundtime"); - - - /** - Need deal with changes to the console variables after the plugin is loaded. - We could not do this and just call the actual console variable each time we need it, but it's not efficent. - */ - HookConVarChange(stm_enabled, ConVarSettingsChanged); - HookConVarChange(stm_logactivity, ConVarSettingsChanged); - HookConVarChange(stm_scrambledelay, ConVarSettingsChanged); - HookConVarChange(stm_voteenabled, ConVarSettingsChanged); - HookConVarChange(stm_votewin, ConVarSettingsChanged); - HookConVarChange(stm_votedelay, ConVarSettingsChanged); - - /** - Need to register the commands we are going to create and use. - */ - RegConsoleCmd("sm_swapteam", Command_SwapTeam, "sm_swapteam <[0]instant/[1]queued>: Swaps your team to the other team"); - RegConsoleCmd("sm_moveplayer", Command_MovePlayer, "sm_moveplayer <[0]instant/[1]ondeath> <[0]unforced/[1]forced>: Moves a player to the specified team"); - RegConsoleCmd("sm_scrambleteams", Command_ScrambleTeams, "sm_scrambleteams: <[0]now/[1]roundend> <[0]dontrestart/[1]restartround> Scrambles the current teams"); - RegConsoleCmd("sm_votescramble", Command_VoteScramble, "sm_votescramble: Starts a vote to scramble the teams"); - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook the game events - */ - LogAction(0, -1, "[STM] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_death", HookPlayerDeath, EventHookMode_Post); - HookEvent("player_team", HookPlayerChangeTeam, EventHookMode_Post); - switch (g_CurrentMod) - { - case GameType_TF: - { - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - } - case GameType_DOD: - { - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_Post); - } - default: - { - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - } - } - - /** - Now we have to deal with the admin menu. If the admin library is loaded call the function to add our items. - */ - new Handle:gTopMenu; - if (LibraryExists("adminmenu") && ((gTopMenu = GetAdminTopMenu()) != INVALID_HANDLE)) - { - OnAdminMenuReady(gTopMenu); - } - - /** - Load translations and .cfg file - */ - LoadTranslations ("simpleteammanager.phrases"); - AutoExecConfig(true, "plugin.simpleteammanager"); - LogAction(0, -1, "[STM] Simple Team Manager is loaded."); -} - -public OnAllPluginsLoaded() -{ - //something -} - -public OnLibraryRemoved(const String:name[]) -{ - if (StrEqual(name, "adminmenu")) - { - - /** - Looks like the admin menu was removed. Set the global. - */ - g_hAdminMenu = INVALID_HANDLE; - } - else if (StrEqual(name, "simpleplugins")) - { - SetFailState("Required plugin Simple SourceMod Plugins Core was removed."); - } -} - -public OnConfigsExecuted() -{ - - /** - Once we loaded up all the console variables from the config file, lets now set all the global variables we will use. - */ - g_bIsEnabled = GetConVarBool(stm_enabled); - g_bLogActivity = GetConVarBool(stm_logactivity); - g_fScrambleDelay = GetConVarFloat(stm_scrambledelay); - g_iVoteDelay = GetConVarInt(stm_votedelay); - g_fVoteWin = GetConVarFloat(stm_votewin); - g_iLastVoteTime = RoundFloat(GetEngineTime()); - g_bScrambleRoundEnd = false; - g_hTimerClearScrambleForce = INVALID_HANDLE; - - /** - Report enabled - */ - if (g_bIsEnabled) - { - LogAction(0, -1, "[STM] Simple Team Manager is ENABLED."); - } - else - { - LogAction(0, -1, "[STM] Simple Team Manager is DISABLED."); - } - - if (g_bLogActivity) - { - LogAction(0, -1, "[STM] Log Activity ENABLED."); - } - else - { - LogAction(0, -1, "[STM] Log Activity DISABLED."); - } -} - -/* COMMANDS */ - -public Action:Command_SwapTeam(client, args) -{ - - /** - Make sure we are enabled, if not bug out. - */ - if (!g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - If this was ran from the console bug out. - */ - if (client == 0) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "PlayerLevelCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Make sure the client is authorized to run this command. - */ - decl String:sFlags[5]; - GetConVarString(stm_adminflag_swapteam, sFlags, sizeof(sFlags)); - if (!SM_IsValidAdmin(client, sFlags)) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Lets make sure the client is one a team we can swap. - If he is we set the global array to the opposite team. - */ - new iTeam = GetClientTeam(client); - if (iTeam == g_aCurrentTeams[Team1]) - { - g_aPlayers[client][iNewTeam] = g_aCurrentTeams[Team2]; - } - else if (iTeam == g_aCurrentTeams[Team2]) - { - g_aPlayers[client][iNewTeam] = g_aCurrentTeams[Team1]; - } - else - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "InValidTeam", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check to see if we have command arguments. - */ - if (GetCmdArgs()) - { - - /** - We do, so lets get it and see if the client wants to be switched instantly or queued for death. - */ - decl String:sArg[5]; - GetCmdArg(1, sArg, sizeof(sArg)); - new iWantsQue = StringToInt(sArg); - if (iWantsQue && !g_aPlayers[client][bQueue]) - { - - /** - He wants the que and isn't already in it, set the global array. - */ - g_aPlayers[client][bQueue] = true; - ReplyToCommand(client, "\x01\x04[STM]\x01 %T", "PlayerQueue", LANG_SERVER); - } - else if (!iWantsQue) - { - - /** - He wants to be switched right now, lets call the stock function. - */ - SM_MovePlayer(client, g_aPlayers[client][iNewTeam]); - } - } - else - { - - /** - There are no command arguments so we build and display the swap menu. - */ - DisplaySwapModeMenu(client, client); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_MovePlayer(client, args) -{ - - /** - Make sure we are enabled, if not bug out. - */ - if (!g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - Make sure the client is authorized to run this command. - */ - decl String:sFlags[5]; - GetConVarString(stm_adminflag_moveplayer, sFlags, sizeof(sFlags)); - if (!SM_IsValidAdmin(client, sFlags)) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check to see if we have command arguments. - */ - new iCmdArgs = GetCmdArgs(); - if (iCmdArgs == 0) - { - - /** - We don't. Build the player menu, display it, and bug out. - */ - DisplayPlayerMenu(client); - return Plugin_Handled; - } - - /** - Check the first argument - If should be a players name or userid. - */ - decl String:sPlayer[64]; - GetCmdArg(1, sPlayer, sizeof(sPlayer)); - new iPlayerIndex = FindTarget(client, sPlayer, true, true); - if (iPlayerIndex == -1 || !IsClientInGame(iPlayerIndex)) - { - - /** - We don't know who this is. Build the player menu, display it, and bug out. - */ - DisplayPlayerMenu(client); - return Plugin_Handled; - } - - /** - We have figured out the first argument, lets check the second. - If should be the team the client wants to put the player on. - */ - if (iCmdArgs >= 2) - { - - /** - We have a command argument at least, lets see if we can identify the team. - */ - decl String:sTeam[24]; - GetCmdArg(2, sTeam, sizeof(sTeam)); - - new iTeam = StringToInt(sTeam); - if (SM_IsValidTeam(iTeam)) - { - - /** - It's a vaild team so lets set the global array to the new team. - */ - g_aPlayers[iPlayerIndex][iNewTeam] = iTeam; - } - else - { - - /** - It's not a vaild team so set the menu to display to the team menu. - */ - DisplayTeamMenu(client, iPlayerIndex); - return Plugin_Handled; - } - } - else - { - /** - We were not given a team, display the team menu. - */ - DisplayTeamMenu(client, iPlayerIndex); - return Plugin_Handled; - } - - /** - Check to see if we were given any more command arguments and found a team. - */ - if (iCmdArgs < 3) - { - - /** - No more command arguments and found a team. - Now lets check to see if the player is a spectator. If he is there is no reason to ask if it's instant or on death... he can't die. - */ - if (!IsClientObserver(iPlayerIndex)) - { - - /** - Not a spectator so display the swapmode menu. - */ - DisplaySwapModeMenu(client, iPlayerIndex); - } - else - { - - /** - The player is a spectator. - We make sure the player is not set to switch on death, since a spec can't die. - */ - g_aPlayers[iPlayerIndex][bQueue] = false; - } - } - - /** - We have figured out the second argument, lets check the third. - If should be the how the client wants to move the player: instant/on death. - */ - if (iCmdArgs >= 3) - { - - /** - The client gave us a command argument, lets check it. - */ - decl String:sSwapMode[5]; - GetCmdArg(3, sSwapMode, sizeof(sSwapMode)); - new iWantsQue = StringToInt(sSwapMode); - if (iWantsQue) - { - - /** - The client wants to que the player, set the global array. - */ - g_aPlayers[iPlayerIndex][bQueue] = true; - } - else - { - - /** - The client doesn't want to que the player, set the global array. - */ - g_aPlayers[iPlayerIndex][bQueue] = false; - } - } - else - { - /** - No swapmode argument, display the menu - */ - DisplaySwapModeMenu(client, iPlayerIndex); - } - - if (iCmdArgs >= 4) - { - - /** - Since we are compiling for Simple Team Balancer, and given a 4th argument, lets check it. - If should be the if the client wants to force the player to that team. - */ - decl String:sPlayerForced[5]; - GetCmdArg(4, sPlayerForced, sizeof(sPlayerForced)); - new iForceHim = StringToInt(sPlayerForced); - if (iForceHim) - { - - /** - The client wants to force the player - */ - SM_SetForcedTeam(iPlayerIndex, g_aPlayers[iPlayerIndex][iNewTeam]); - } - else - { - - /** - The client doesn't want to force the player - */ - SM_ClearForcedTeam(iPlayerIndex); - } - } - else - { - - } - - /** - We found and processed all the arguments. - */ - if (!IsPlayerAlive(iPlayerIndex)) - { - - /** - The player is not alive or died during this process so we just move him. - */ - SM_MovePlayer(iPlayerIndex, g_aPlayers[iPlayerIndex][iNewTeam]); - } - else - { - if (!g_aPlayers[iPlayerIndex][bQueue]) - { - - /** - The player is alive and is not set to be queued so we just move him. - */ - SM_MovePlayer(iPlayerIndex, g_aPlayers[iPlayerIndex][iNewTeam]); - } - } - - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_ScrambleTeams(client, args) -{ - - /** - Make sure we are enabled, if not bug out. - */ - if (!g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - Make sure the client is authorized to run this command. - */ - decl String:sFlags[5]; - GetConVarString(stm_adminflag_scramble, sFlags, sizeof(sFlags)); - if (!SM_IsValidAdmin(client, sFlags)) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check if a scramble timer was already called, if so close it down. - */ - if (g_hTimerPrepScramble != INVALID_HANDLE) - { - CloseHandle(g_hTimerPrepScramble); - g_hTimerPrepScramble = INVALID_HANDLE; - } - - /** - Check if we have any command arguments. - If we don't we display the scramble menu and bug out. - */ - new iCmdArgs = GetCmdArgs(); - if (iCmdArgs == 0) - { - DisplayScrambleMenu(client); - return Plugin_Handled; - } - - /** - We have a command argument. - It should be whether or not to scramble at round end. - */ - decl String:sRoundEnd[5]; - GetCmdArg(1, sRoundEnd, sizeof(sRoundEnd)); - if (StringToInt(sRoundEnd)) - { - /** - The client wants to scramble at round end so we set the global bool. - */ - g_bScrambleRoundEnd = true; - } - else - { - g_bScrambleRoundEnd = false; - } - - /** - Check for another command argument. - It should be whether or not to restart the round. - */ - decl String:sRestartRound[5]; - new bool:bRestartRound = false; - GetCmdArg(1, sRestartRound, sizeof(sRestartRound)); - if (StringToInt(sRestartRound)) - { - bRestartRound = true; - } - - /** - Now we start the scramble timer. - */ - StartScrambleTimer(_, bRestartRound); - - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_VoteScramble(client, args) -{ - - /** - Make sure we are enabled, if not bug out. - */ - if (!g_bVoteEnabled || !g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - Make sure there is a vote in progress, if so bug out. - */ - if (IsVoteInProgress()) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "VoteInProgress", LANG_SERVER); - return Plugin_Handled; - } - - /** - Make sure enough time has passed since the last vote. - */ - new iVoteTime = RoundFloat(GetEngineTime()); - if (iVoteTime - g_iLastVoteTime <= g_iVoteDelay) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "ScrambleTime", LANG_SERVER); - return Plugin_Handled; - } - - /** - Enough time has passed so reset the global vote time to now. - */ - g_iLastVoteTime = iVoteTime; - - /** - Build the vote menu and send it to everyone. - */ - new Handle:hMenu = CreateMenu(Menu_VoteScramble); - SetMenuTitle(hMenu, "Scramble Teams?"); - AddMenuItem(hMenu, VOTE_YES, "Yes"); - AddMenuItem(hMenu, VOTE_NO, "No"); - SetMenuExitButton(hMenu, false); - VoteMenuToAll(hMenu, 20); - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -/* HOOKED EVENTS */ - -public HookPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Find out who died. - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - - /** - Find out how the client died. - */ - new String:sWeapon[64]; - GetEventString(event, "weapon", sWeapon, sizeof(sWeapon)); - if (StrEqual(sWeapon, "world", false)) - { - - /** - He died because he changed teams so cleanup and bug out. - */ - s_CleanUp(iClient); - return; - } - - /** - Find out if this player was queued to change teams. - */ - if (g_aPlayers[iClient][bQueue]) - { - /** - Looks like he was, so call the stock function to move him. - */ - SM_MovePlayer(iClient, g_aPlayers[iClient][iNewTeam]); - } -} - -public HookPlayerChangeTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Find out who changed teams. - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - - /** - If he was queued to switch teams we cleanup the variables. The client did it themself. - */ - if (g_aPlayers[iClient][bQueue]) - { - s_CleanUp(iClient); - } -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get the amount of time left in the map. - */ - new iTimeLeft; - GetMapTimeLeft(iTimeLeft); - - /** - Check to see if we are supposed to scramble at the end of the round and that there is enough time left in the map. - */ - if (g_bScrambleRoundEnd && iTimeLeft >= 60) - { - - /** - Check to see if there is a scramble timer in action and if so close it down. - */ - if (g_hTimerPrepScramble != INVALID_HANDLE) - { - CloseHandle(g_hTimerPrepScramble); - g_hTimerPrepScramble = INVALID_HANDLE; - } - - /** - Determine the round end chat time and run the scramble 1 second before it ends. - */ - new Float:fDelay = GetConVarFloat(stm_mp_bonusroundtime); - fDelay -= 1.0; - StartScrambleTimer(fDelay); - } -} - -public OnClientPostAdminCheck(client) -{ - - /** - Determine if the client has the flag to use the swapteam command. - */ - decl String:sFlags[5]; - GetConVarString(stm_adminflag_swapteam, sFlags, sizeof(sFlags)); - if (SM_IsValidAdmin(client, sFlags)) - { - /** - The client does so lets create a timer to run an advertise to tell him about it. - */ - CreateTimer (60.0, Timer_WelcomeAdvert, client); - } -} - -public OnClientDisconnect(client) -{ - - /** - Cleanup the clients variables. - */ - s_CleanUp(client); -} - -public SM_OnPlayerMoved(Handle:plugin, client, team) -{ - - /** - Make sure we called the move function - */ - if (plugin != GetMyHandle()) - { - if (g_bLogActivity) - { - LogAction(0, client, "[STM] Callback was not started with current plugin, bugging out."); - } - return; - } - - decl String:sPlayerName[64]; - GetClientName(client, sPlayerName, sizeof(sPlayerName)); - - PrintToChat(client, "\x01\x04[SM]\x01 %T", "PlayerSwitched", LANG_SERVER); - - s_CleanUp(client); -} - -/* TIMER FUNCTIONS */ - -public Action:Timer_PrepTeamScramble(Handle:timer, any:data) -{ - new bool:bRestartRound = data; - /** - Call the scramble the teams stock function. - */ - PrepTeamScramble(bRestartRound); - - /** - Reset the timer handle so we know the timer is done. - */ - g_hTimerPrepScramble = INVALID_HANDLE; - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Timer_ScrambleTheTeams(Handle:timer, any:data) -{ - new iPlayers[MAXPLAYERS + 1]; - new iCount, i, bool:bTeam, bool:bRestartRound = data; - - /** - Get all the client index numbers of valid players - */ - for(i = 1; i <= MaxClients; i++) - { - if(IsClientInGame(i)) // && !IsFakeClient(i)) - { - iPlayers[iCount++] = i; - } - } - - /** - Randomly sort the players - */ - SortIntegers(iPlayers, iCount, Sort_Random); - - /** - Loop through all the players and assign each one to a team, alternating each time - */ - for(i = 0; i < iCount; i++) - { - if (!bRestartRound) - { - /** - We didn't want to restart the round, so we move them to spec 1 at a time. - */ - SM_MovePlayer(iPlayers[i], g_aCurrentTeams[Spectator]); - } - SM_MovePlayer(iPlayers[i], bTeam ? g_aCurrentTeams[Team2] : g_aCurrentTeams[Team1]); - SM_SetForcedTeam(iPlayers[i], bTeam ? g_aCurrentTeams[Team2] : g_aCurrentTeams[Team1], true); - bTeam = !bTeam; - } - - /** - Reset this variable since we completed a scramble - */ - g_bScrambleRoundEnd = false; - - if (g_hTimerClearScrambleForce != INVALID_HANDLE) - { - CloseHandle(g_hTimerClearScrambleForce); - g_hTimerClearScrambleForce = INVALID_HANDLE; - } - - g_hTimerClearScrambleForce = CreateTimer(300.0, Timer_ClearScrambleForce, _, TIMER_FLAG_NO_MAPCHANGE); - - ServerCommand("mp_timelimit %i", g_iTimeLeft / 60); - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Timer_ClearScrambleForce(Handle:timer, any:data) -{ - - for(new i = 1; i <= MaxClients; i++) - { - if(IsClientInGame(i)) // && !IsFakeClient(i)) - { - SM_ClearForcedTeam(i); - PrintToChat(i, "\x01\x04[SM]\x01 Your forced team status has been cleared"); - } - } - - g_hTimerClearScrambleForce = INVALID_HANDLE; - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Timer_WelcomeAdvert(Handle:timer, any:client) -{ - - /** - Lets make sure the client is connected and actually in the game. - */ - if (IsClientConnected(client) && IsClientInGame(client)) - { - - /** - We are good to go so lets tell him about the swapteam command. - */ - PrintToChat (client, "\x01\x04[STM]\x01 %T", "SwapTeamMsg", LANG_SERVER); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -/* STOCK FUNCTIONS */ - -stock s_CleanUp(iClient) -{ - - /** - Reset all the client variables - */ - g_aPlayers[iClient][bQueue] = false; - g_aPlayers[iClient][iNewTeam] = 0; -} - -stock StartScrambleTimer(Float:fdelay = 0.0, bool:bRestartRound = false) -{ - if (fdelay == 0.0) - { - fdelay = g_fScrambleDelay; - } - if (g_hTimerPrepScramble != INVALID_HANDLE) - { - CloseHandle(g_hTimerPrepScramble); - g_hTimerPrepScramble = INVALID_HANDLE; - } - PrintCenterTextAll("%T", "Scramble", LANG_SERVER); - g_hTimerPrepScramble = CreateTimer(fdelay, Timer_PrepTeamScramble, bRestartRound, TIMER_FLAG_NO_MAPCHANGE); -} - -stock PrepTeamScramble(bool:bRestartRound = false) -{ - new iPlayers[MAXPLAYERS + 1]; - new iCount; - - GetMapTimeLeft(g_iTimeLeft); - - if (bRestartRound) - { - - for(new i = 1; i <= MaxClients; i++) - { - if(IsClientInGame(i)) - // && !IsFakeClient(i)) - { - iPlayers[iCount++] = i; - SM_ClearForcedTeam(i); - SM_ClearBuddy(i); - SM_MovePlayer(i, g_aCurrentTeams[Spectator]); - } - } - } - else - { - //Can't move them all to spec at the same time - for(new i = 1; i <= MaxClients; i++) - { - if(IsClientInGame(i)) - // && !IsFakeClient(i)) - { - iPlayers[iCount++] = i; - SM_ClearForcedTeam(i); - SM_ClearBuddy(i); - //SM_MovePlayer(i, g_aCurrentTeams[Spectator]); - } - } - } - CreateTimer(4.0, Timer_ScrambleTheTeams, bRestartRound, TIMER_FLAG_NO_MAPCHANGE); -} - -/* CONSOLE VARIABLE CHANGE EVENT */ - -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (convar == stm_enabled) { - if (StringToInt(newValue) == 0) { - g_bIsEnabled = false; - LogAction(0, -1, "[STM] Simple Team Manager is loaded and disabled."); - } else { - g_bIsEnabled = true; - LogAction(0, -1, "[STM] Simple Team Manager is loaded and enabled."); - } - } - else if (convar == stm_logactivity) { - if (StringToInt(newValue) == 0) { - g_bLogActivity = false; - LogAction(0, -1, "[STM] Log Activity DISABLED."); - } else { - g_bLogActivity = true; - LogAction(0, -1, "[STM] Log Activity ENABLED."); - } - } - else if (convar == stm_scrambledelay) - g_fScrambleDelay = StringToFloat(newValue); - else if (convar == stm_votewin) - g_fVoteWin = StringToFloat(newValue); - else if (convar == stm_votedelay) - g_iVoteDelay = StringToInt(newValue); - else if (convar == stm_voteenabled) { - if (StringToInt(newValue) == 0) - g_bVoteEnabled = false; - else - g_bVoteEnabled = true; - } -} - -/* MENU CODE */ - -public OnAdminMenuReady(Handle:topmenu) -{ - if (topmenu == g_hAdminMenu) - return; - g_hAdminMenu = topmenu; - new TopMenuObject:player_commands = FindTopMenuCategory(g_hAdminMenu, ADMINMENU_PLAYERCOMMANDS); - new TopMenuObject:server_commands = FindTopMenuCategory(g_hAdminMenu, ADMINMENU_SERVERCOMMANDS); - if (player_commands == INVALID_TOPMENUOBJECT) - return; - - AddToTopMenu(g_hAdminMenu, - "moveplayer", - TopMenuObject_Item, - AdminMenu_MovePlayer, - player_commands, - "moveplayer", - ADMFLAG_BAN); - - AddToTopMenu(g_hAdminMenu, - "scrambleteams", - TopMenuObject_Item, - AdminMenu_Scrambleteams, - server_commands, - "scrambleteams", - ADMFLAG_BAN); -} - -public AdminMenu_MovePlayer(Handle:topmenu, TopMenuAction:action, TopMenuObject:object_id, param, String:buffer[], maxlength) -{ - if (action == TopMenuAction_DisplayOption) - Format(buffer, maxlength, "Move Player"); - else if (action == TopMenuAction_SelectOption){ - DisplayPlayerMenu(param); - } -} - -public AdminMenu_Scrambleteams(Handle:topmenu, TopMenuAction:action, TopMenuObject:object_id, param, String:buffer[], maxlength) -{ - if (action == TopMenuAction_DisplayOption) - Format(buffer, maxlength, "Scramble Teams"); - else if (action == TopMenuAction_SelectOption) { - DisplayScrambleMenu(param); - } -} - -public Menu_SelectPlayer(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - DisplayTeamMenu(param1, GetClientOfUserId(StringToInt(sSelection))); - } else if (action == MenuAction_Cancel) { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -public Menu_SelectTeam(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new iTeam; - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - decl String:sIndex[64]; - if (SplitString(sSelection, "A", sIndex, sizeof(sIndex)) != -1) - iTeam = g_aCurrentTeams[Team1]; - else if (SplitString(sSelection, "B", sIndex, sizeof(sIndex)) != -1) - iTeam = g_aCurrentTeams[Team2]; - else { - SplitString(sSelection, "C", sIndex, sizeof(sIndex)); - iTeam = g_aCurrentTeams[Spectator]; - } - new iTarget = StringToInt(sIndex); - g_aPlayers[iTarget][iNewTeam] = iTeam; - DisplaySwapModeMenu(param1, iTarget); - } else if (action == MenuAction_Cancel) { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -public Menu_SwapMode(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - decl String:sIndex[64]; - - if (SplitString(sSelection, "A", sIndex, sizeof(sIndex)) == -1) - { - SplitString(sSelection, "B", sIndex, sizeof(sIndex)); - } - - new iTarget = StringToInt(sIndex); - - if (StrContains(sSelection, "A", true) != -1) - { - g_aPlayers[iTarget][bQueue] = false; - } - else if (StrContains(sSelection, "B", true) != -1) - { - g_aPlayers[iTarget][bQueue] = true; - } - - if (param1 == iTarget && !g_aPlayers[iTarget][bQueue]) - { - SM_MovePlayer(iTarget, g_aPlayers[iTarget][iNewTeam]); - } - else - { - DisplayForceModeMenu(param1, iTarget); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - { - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } - return; -} - -public Menu_ForceMode(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - decl String:sIndex[64]; - if (SplitString(sSelection, "A", sIndex, sizeof(sIndex)) == -1) - { - SplitString(sSelection, "B", sIndex, sizeof(sIndex)); - } - new iTarget = StringToInt(sIndex); - if (StrContains(sSelection, "A", true) != -1) - { - SM_ClearForcedTeam(iTarget); - } - else if (StrContains(sSelection, "B", true) != -1) - { - SM_SetForcedTeam(iTarget, g_aPlayers[iTarget][iNewTeam], true); - } - if (!g_aPlayers[iTarget][bQueue]) - { - SM_MovePlayer(iTarget, g_aPlayers[iTarget][iNewTeam]); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - { - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } - return; -} - -public Menu_VoteScramble(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_VoteEnd) { - new winning_votes, total_votes; - GetMenuVoteInfo(param2, winning_votes, total_votes); - if (param1 == 0) { - if (float(total_votes) / float(winning_votes) < g_fVoteWin) { - PrintToChatAll("\x01\x04[SM]\x01 %T", "VoteScramble2", LANG_SERVER, winning_votes, total_votes); - return; - } - PrintCenterTextAll("[SM] %T", "Scramble", LANG_SERVER); - PrintToChatAll("\x01\x04[SM]\x01 %T", "VoteScramble1", LANG_SERVER, winning_votes, total_votes); - StartScrambleTimer(); - } - if (param1 == 1) { - PrintToChatAll("\x01\x04[SM]\x01 %T", "VoteScramble2", LANG_SERVER, winning_votes, total_votes); - } - } - if (action == MenuAction_End) - CloseHandle(menu); -} - -public Menu_ScrambleTeams(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "NOW", false)) - g_bScrambleRoundEnd = false; - else - g_bScrambleRoundEnd = true; - DisplayScrambleMenu2(param1); - } else if (action == MenuAction_Cancel) { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -public Menu_ScrambleTeams2(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[64]; - new bool:bRestartRound; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "NO", false)) - { - bRestartRound = false; - } - else - { - bRestartRound = true; - } - StartScrambleTimer(_, bRestartRound); - } else if (action == MenuAction_Cancel) { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -stock DisplayScrambleMenu(iClient) -{ - new Handle:hMenu = CreateMenu(Menu_ScrambleTeams); - SetMenuTitle(hMenu, "Select When to Scramble:"); - AddMenuItem(hMenu, "NOW", "Instantly"); - AddMenuItem(hMenu, "END", "At Round End"); - SetMenuExitBackButton(hMenu, false); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} - -stock DisplayScrambleMenu2(iClient) -{ - new Handle:hMenu = CreateMenu(Menu_ScrambleTeams2); - SetMenuTitle(hMenu, "Select When to Scramble:"); - AddMenuItem(hMenu, "NO", "No Round Restart"); - AddMenuItem(hMenu, "YES", "Restart Round"); - SetMenuExitBackButton(hMenu, false); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} - -stock DisplaySwapModeMenu(iClient, iTarget) -{ - new Handle:hMenu = CreateMenu(Menu_SwapMode); - decl String:optionA[64]; - decl String:optionB[64]; - Format(optionA, sizeof(optionA), "%iA", iTarget); - Format(optionB, sizeof(optionB), "%iB", iTarget); - SetMenuTitle(hMenu, "Select When to Swap:"); - AddMenuItem(hMenu, optionA, "Instantly (Kills)"); - if (!IsClientObserver(iTarget)) - AddMenuItem(hMenu, optionB, "Queue on next death"); - SetMenuExitBackButton(hMenu, false); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} - -stock DisplayForceModeMenu(iClient, iTarget) -{ - new Handle:hMenu = CreateMenu(Menu_ForceMode); - decl String:optionA[64]; - decl String:optionB[64]; - Format(optionA, sizeof(optionA), "%iA", iTarget); - Format(optionB, sizeof(optionB), "%iB", iTarget); - SetMenuTitle(hMenu, "Select Force Mode:"); - AddMenuItem(hMenu, optionA, "UnForced"); - AddMenuItem(hMenu, optionB, "Forced"); - SetMenuExitBackButton(hMenu, false); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} - -stock DisplayTeamMenu(iClient, iTarget) -{ - new Handle:hMenu = CreateMenu(Menu_SelectTeam); - decl String:optionA[64]; - decl String:optionB[64]; - decl String:optionC[64]; - Format(optionA, sizeof(optionA), "%iA", iTarget); - Format(optionB, sizeof(optionB), "%iB", iTarget); - Format(optionC, sizeof(optionC), "%iC", iTarget); - SetMenuTitle(hMenu, "Select Team:"); - AddMenuItem(hMenu, optionA, "Team One"); - AddMenuItem(hMenu, optionB, "Team Two"); - AddMenuItem(hMenu, optionC, "Spectator"); - SetMenuExitBackButton(hMenu, false); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} - -stock DisplayPlayerMenu(iClient) -{ - new Handle:hMenu = CreateMenu(Menu_SelectPlayer); - AddTargetsToMenu(hMenu, 0, true, false); - SetMenuTitle(hMenu, "Select A Player:"); - SetMenuExitBackButton(hMenu, true); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} diff --git a/Simple Team Balancer/addons/sourcemod/translations/simpledonatorbenefits.phrases.txt b/Simple Team Balancer/addons/sourcemod/translations/simpledonatorbenefits.phrases.txt deleted file mode 100644 index 3826846..0000000 --- a/Simple Team Balancer/addons/sourcemod/translations/simpledonatorbenefits.phrases.txt +++ /dev/null @@ -1,62 +0,0 @@ -"Phrases" -{ - "PlayerLevelCmd" - { - "en" "Command must be run at the player level" - "fr" "Cette commande doit être tapée en jeu" - "hu" "Ezt a parancsot jatekosi szinten kell futtatni!" - } - "RestrictedCmd" - { - "en" "You must be a donator or admin to run this command" - "fr" "Vous devez être un donateur ou un admin pour lancer cette commande" - "hu" "A parancs futtatasahoz admin, vagy tamogatoi szint szukseges!" - } - "InValidTeam" - { - "en" "You must be on red or blue to swap teams" - "fr" "Vous devez être RED ou BLU pour changer d'équipe" - "hu" "Jatekban kell lenned, hogy megcsereld a csapatokat!" - } - "PlayerQueue" - { - "en" "You have been queued to swap teams on next death" - "fr" "Vous avez été mis en attente pour changer d'équipe lors de votre prochaine mort" - "hu" "A kovetkezo halalnal csapatcsere lesz" - } - "PlayerSwitched" - { - "en" "Your team has been switched as requested" - "fr" "Vous avez changé d'équipe comme demandé" - "hu" "A keresnek eleget teve a csapatod meg lett csererlve" - } - "SwapTeamMsg" - { - "en" "Type /swapteam or !swapteam to swap your team!" - } - "ReachedCount" - { - "en" "You have reached your health limit. You must die before you can use it again" - } - "AtMaxHealth" - { - "en" "You are already at your maximum health!" - } - "ToMaxHealth" - { - "en" "Instant health bonus applied! You are not at your maximun health!" - } - "HealthBonus" - { - "en" "Instant health bonus applied!" - } - "PublicJoinMessage" - { - "#format" "{1:s}" - "en" "{1} a [donator] as joined the server" - } - "PrivateJoinMessage" - { - "en" "Thanks for donating!" - } -} \ No newline at end of file diff --git a/Simple Team Balancer/addons/sourcemod/translations/simplespectate.phrases.txt b/Simple Team Balancer/addons/sourcemod/translations/simplespectate.phrases.txt deleted file mode 100644 index 2d1a096..0000000 --- a/Simple Team Balancer/addons/sourcemod/translations/simplespectate.phrases.txt +++ /dev/null @@ -1,42 +0,0 @@ -"Phrases" -{ - "Stopped spectating" - { - "#format" "{1:s}" - "en" "Stopped tracking player: {1}" - } - "Yourself" - { - "en" "You can't spectate yourself" - } - "Spectator" - { - "en" "You can't spectate another spectator" - } - "Spectating" - { - "#format" "{1:s}" - "en" "Now spectating {1}. Type !stopspec or /stopspec to stop spectating this player" - } - "Invalid Target" - { - "en" "Invalid target" - } - "Cant Target" - { - "en" "Can't target this player" - } - "Must Have Target" - { - "en" "You must be following/tracking a player to punish" - } - "Target Left" - { - "en" "The player you were following/tracking has left" - } - "Punished" - { - "#format" "{1:s}{2:s}{3:s}" - "en" "{1} was punished with a {2} for {3}" - } -} \ No newline at end of file diff --git a/Simple Team Balancer/addons/sourcemod/translations/simpleteammanager.phrases.txt b/Simple Team Balancer/addons/sourcemod/translations/simpleteammanager.phrases.txt deleted file mode 100644 index f2093a7..0000000 --- a/Simple Team Balancer/addons/sourcemod/translations/simpleteammanager.phrases.txt +++ /dev/null @@ -1,92 +0,0 @@ -"Phrases" -{ - "PlayerLevelCmd" - { - "en" "Command must be run at the player level" - "fr" "Cette commande doit être tapée en jeu" - "hu" "Ezt a parancsot jatekosi szinten kell futtatni!" - } - "RestrictedCmd" - { - "en" "You must be a donator or admin to run this command" - "fr" "Vous devez être un donateur ou un admin pour lancer cette commande" - "hu" "A parancs futtatasahoz admin, vagy tamogatoi szint szukseges!" - } - "InValidTeam" - { - "en" "You must be on red or blue to swap teams" - "fr" "Vous devez être RED ou BLU pour changer d'équipe" - "hu" "Jatekban kell lenned, hogy megcsereld a csapatokat!" - } - "PlayerInValidTeam" - { - "en" "Player must be on red or blue to swap teams" - "fr" "Le joueur doit être RED ou BLU pour changer d'équipe" - "hu" "Valamelyik csapatban kell lenni, hogy csere legyen" - } - "PlayerQueue" - { - "en" "You have been queued to swap teams on next death" - "fr" "Vous avez été mis en attente pour changer d'équipe lors de votre prochaine mort" - "hu" "A kovetkezo halalnal csapatcsere lesz" - } - "PlayerSwitched" - { - "en" "Your team has been switched" - } - "PlayerSwitched1" - { - "en" "Your team has been switched as requested" - "fr" "Vous avez changé d'équipe comme demandé" - "hu" "A keresnek eleget teve a csapatod meg lett csererlve" - } - "PlayerSwitched2" - { - "en" "Your team has been switched by an Admin" - "fr" "Vous avez été changé d'équipe par un admin" - "hu" "Az Admin megcserelte a csapatodat!" - } - "SwapTeamMsg" - { - "en" "Type /swapteam or !swapteam to swap your team!" - } - "PlayerSwitched3" - { - "#format" "{1:s}" - "en" "{1}'s team has been switched" - "fr" "{1} a changé d'équipe" - "hu" "{1} csapata meg lett cserelve" - } - "Scramble" - { - "en" "Teams are about to be scrambled!" - "fr" "Les équipes vont être rééquilibrés" - "hu" "A csapatok hamarosan meg lesznek keverve!" - } - "VoteScramble1" - { - "#format" "{1:i}{2:i}" - "en" "Vote Scramble successful with {1} votes out of {2}" - "fr" "Le vote d'équilibrage des équipes a réussi avec {1} votes pour sur {2}" - "hu" "A szavazas sikeres volt, {1} szavazat a keveresre a {2} -bol" - } - "VoteScramble2" - { - "#format" "{1:i}{2:i}" - "en" "Vote Scramble failed with {1} votes out of {2}" - "fr" "Le vote d'équilibrage a échoué avec {1} votes pour sur {2}" - "hu" "A szavazas sikertelen volt, {1} szavazat a keveresre a {2} -bol" - } - "VoteInProgress" - { - "en" "A vote is currently in progress" - "fr" "Un vote est actuellement en cours" - "hu" "Egy szavazas mar fut!" - } - "ScrambleTime" - { - "en" "A vote was recently made, please wait" - "fr" "Un vote a déjà été fait récemment, réessayez plus tard" - "hu" "Nemreg volt szavazas, kerlek varj egy kicsit!" - } -} \ No newline at end of file diff --git a/Simple Team Manager/addons/sourcemod/configs/simple-alltalkmanager_events.cfg b/Simple Team Manager/addons/sourcemod/configs/simple-alltalkmanager_events.cfg deleted file mode 100644 index b739cf0..0000000 --- a/Simple Team Manager/addons/sourcemod/configs/simple-alltalkmanager_events.cfg +++ /dev/null @@ -1,43 +0,0 @@ -"game_events" -{ - "teamplay_round_start" - { - "reason" "Round Start" - "setting" "1" - } - "teamplay_setup_finished" - { - "reason" "Setup Period Ended" - "setting" "0" - } - "teamplay_overtime_begin" - { - "reason" "Overtime Began" - "setting" "1" - } - "teamplay_overtime_end" - { - "reason" "Overtime Ended" - "setting" "1" - } - "teamplay_round_win" - { - "reason" "Round Ended" - "setting" "1" - } - "teamplay_suddendeath_begin" - { - "reason" "Sudden Death Began" - "setting" "1" - } - "teamplay_suddendeath_end" - { - "reason" "Sudden Death Ended" - "setting" "1" - } - "teamplay_round_stalemate" - { - "reason" "Stalemate" - "setting" "1" - } -} \ No newline at end of file diff --git a/Simple Team Manager/addons/sourcemod/configs/simple-chatcolors.cfg b/Simple Team Manager/addons/sourcemod/configs/simple-chatcolors.cfg deleted file mode 100644 index 14b98c6..0000000 --- a/Simple Team Manager/addons/sourcemod/configs/simple-chatcolors.cfg +++ /dev/null @@ -1,15 +0,0 @@ -"admin_colors" -{ - "groupname2" - { - "flag" "z" - "namecolor" "{green}" - "textcolor" "{olive}" - } - "groupname1" - { - "flag" "a" - "namecolor" "{teamcolor}" - "textcolor" "{green}" - } -} \ No newline at end of file diff --git a/Simple Team Manager/addons/sourcemod/plugins/simple-alltalkmanager.smx b/Simple Team Manager/addons/sourcemod/plugins/simple-alltalkmanager.smx deleted file mode 100644 index 6122756..0000000 Binary files a/Simple Team Manager/addons/sourcemod/plugins/simple-alltalkmanager.smx and /dev/null differ diff --git a/Simple Team Manager/addons/sourcemod/plugins/simple-donatorbenefits.smx b/Simple Team Manager/addons/sourcemod/plugins/simple-donatorbenefits.smx deleted file mode 100644 index 821d61d..0000000 Binary files a/Simple Team Manager/addons/sourcemod/plugins/simple-donatorbenefits.smx and /dev/null differ diff --git a/Simple Team Manager/addons/sourcemod/plugins/simple-messagesuppression.smx b/Simple Team Manager/addons/sourcemod/plugins/simple-messagesuppression.smx deleted file mode 100644 index cc20dad..0000000 Binary files a/Simple Team Manager/addons/sourcemod/plugins/simple-messagesuppression.smx and /dev/null differ diff --git a/Simple Team Manager/addons/sourcemod/plugins/simple-plugins.smx b/Simple Team Manager/addons/sourcemod/plugins/simple-plugins.smx deleted file mode 100644 index ac307a3..0000000 Binary files a/Simple Team Manager/addons/sourcemod/plugins/simple-plugins.smx and /dev/null differ diff --git a/Simple Team Manager/addons/sourcemod/plugins/simple-spectate.smx b/Simple Team Manager/addons/sourcemod/plugins/simple-spectate.smx deleted file mode 100644 index c6885b0..0000000 Binary files a/Simple Team Manager/addons/sourcemod/plugins/simple-spectate.smx and /dev/null differ diff --git a/Simple Team Manager/addons/sourcemod/plugins/simple-teambalancer.smx b/Simple Team Manager/addons/sourcemod/plugins/simple-teambalancer.smx deleted file mode 100644 index 95beb01..0000000 Binary files a/Simple Team Manager/addons/sourcemod/plugins/simple-teambalancer.smx and /dev/null differ diff --git a/Simple Team Manager/addons/sourcemod/plugins/simple-teammanager.smx b/Simple Team Manager/addons/sourcemod/plugins/simple-teammanager.smx index 81905ba..e67ce77 100644 Binary files a/Simple Team Manager/addons/sourcemod/plugins/simple-teammanager.smx and b/Simple Team Manager/addons/sourcemod/plugins/simple-teammanager.smx differ diff --git a/Simple Team Manager/addons/sourcemod/scripting/include/simple-plugins.inc b/Simple Team Manager/addons/sourcemod/scripting/include/simple-plugins.inc deleted file mode 100644 index 8f21956..0000000 --- a/Simple Team Manager/addons/sourcemod/scripting/include/simple-plugins.inc +++ /dev/null @@ -1,337 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Plugins -Description: - Included file for core plugin in the Simple Plugins project -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -*************************************************************************/ - -#if defined _simpleplugin_included - #endinput -#endif - -#define _simpleplugin_included - -#define CORE_INC_VERSION "1.1.$Rev$" - -#pragma semicolon 1 -#include -#undef REQUIRE_PLUGIN -#include -#define REQUIRE_PLUGIN -#undef REQUIRE_EXTENSIONS -#undef AUTOLOAD_EXTENSIONS -#tryinclude -#tryinclude -#tryinclude -#define AUTOLOAD_EXTENSIONS -#define REQUIRE_EXTENSIONS - -enum e_SupportedMods -{ - GameType_Unknown, - GameType_AOC, - GameType_CSS, - GameType_DOD, - GameType_FF, - GameType_HIDDEN, - GameType_HL2DM, - GameType_INS, - GameType_L4D, - GameType_NEO, - GameType_SGTLS, - GameType_TF, - GameType_ZPS -}; - -enum e_Teams -{ - Unknown, - Spectator, - Team1, - Team2 -}; - -new g_aCurrentTeams[e_Teams]; -new e_SupportedMods:g_CurrentMod; -new String:g_sGameName[e_SupportedMods][32] = { "Unknown", - "Age of Chivalry", - "Counter Strike", - "Day Of Defeat", - "Fortress Forever", - "Hidden: Source", - "Half Life 2: Deathmatch", - "Insurgency", - "Left 4 Dead", - "Neotokyo", - "Stargate TLS", - "Team Fortress 2", - "Zombie Panic: Source" - }; - -public SharedPlugin:_pl_simpleplugin = -{ - name = "simple-plugins", - file = "simple-plugins.smx", -#if defined REQUIRE_PLUGIN - required = 1 -#else - required = 0 -#endif -}; - -#if !defined REQUIRE_PLUGIN -public _pl_simpleplugin_SetNTVOptional() -{ - MarkNativeAsOptional("SM_MovePlayer"); - MarkNativeAsOptional("SM_SetForcedTeam"); - MarkNativeAsOptional("SM_GetForcedTeam"); - MarkNativeAsOptional("SM_ClearForcedTeam"); - MarkNativeAsOptional("SM_GetForcedPlayer"); - MarkNativeAsOptional("SM_AssignBuddy"); - MarkNativeAsOptional("SM_SearchBuddy"); - MarkNativeAsOptional("SM_LockBuddy"); - MarkNativeAsOptional("SM_IsBuddyLocked"); - MarkNativeAsOptional("SM_ClearBuddy"); - MarkNativeAsOptional("SM_IsValidAdmin"); - MarkNativeAsOptional("SM_IsValidTeam"); -} -#endif - -/********************************************************************** - * When a player has to moved - * - * @param plugin Plugin that initiated the move - * @param client The client index of the player that was moved - * @param team The team index the player was moved to - * @noreturn - **********************************************************************/ -forward SM_OnPlayerMoved(Handle:plugin, client, team); - -/********************************************************************** - * Move a player to the supplied team - * - * @param client The client index of the player to be moved - * @param team The team to move the player to - * @noreturn - * @error Invalid client or team index - **********************************************************************/ -native SM_MovePlayer(client, team); - -/********************************************************************** - * Move a player to the supplied team - * - * @param client The client index of the player to set - * @param team The team to move the to set - * @param override Whether or not to override another plugin - * @return True if successful, false if not - * @error Invalid client or team index - **********************************************************************/ -native SM_SetForcedTeam(client, team, bool:override = false); - -/********************************************************************** - * Gets the client's forced team index - * - * @param client The client index of the player to check - * @param plugin Optional: The plugin handle of the plugin - that set the team - * @return The team index of the forced team - Zero if no forced team - * @error Invalid client index - **********************************************************************/ -native SM_GetForcedTeam(client, &Handle:plugin = INVALID_HANDLE); - -/********************************************************************** - * Clears a client's forced team - * - * @param client The client index of the player to check - * @return True if successful, false if not - * @error Invalid client index - **********************************************************************/ -native SM_ClearForcedTeam(client); - -/********************************************************************** - * Gets a forced player on the wrong that is currently on the wrong team - * This will only return a player if the calling plugin assigned the team - * - * @param team The team index the player should be on - * @return The client index of the player - Zero if no player found - * @error Invalid client index - **********************************************************************/ -native SM_GetForcedPlayer(team); - -/********************************************************************** - * Assign a players buddy - * - * @param client The client index of the player to assign - * @param player The player index of the player to assign - * @param override Whether or not to override a player lock - * @return True if successful, false if not - * @error Invalid client or player index - **********************************************************************/ -native bool:SM_AssignBuddy(client, player, bool:override = false); - -/********************************************************************** - * Rturns the client's buddy - * - * @param client The client index of the player to assign - * @return The client index of the player's buddy - Zero if no buddy - * @error Invalid client index - **********************************************************************/ -native SM_GetClientBuddy(client); - -/********************************************************************** - * Set the buddy lock setting for a client - * - * @param client The client index of the player to assign - * @param setting Setting to set, True or False - * @return True if successful, false if not - * @error Invalid client index - **********************************************************************/ -native bool:SM_LockBuddy(client, bool:setting); - -/********************************************************************** - * Returns the buddy lock setting for a client - * - * @param client The client index of the player to assign - * @return True if locked, false if not - * @error Invalid client index - **********************************************************************/ -native bool:SM_IsBuddyLocked(client); - -/********************************************************************** - * Clear a players buddy - * - * @param client The client index of the player to clear - * @param override Whether or not to override a player lock - * @return True if successful, false if not - * @error Invalid client index - **********************************************************************/ -native bool:SM_ClearBuddy(client, bool:override = false); - -/********************************************************************** - * Determine if the player has the supplied flags - * ADMFLAG_ROOT will always return true - * - * @param client The client index of the player to assign - * @param flags The char flag(s) to check against - * @return True if valid, false if not - **********************************************************************/ -native bool:SM_IsValidAdmin(client, const String:flags[]); - - -/********************************************************************** - * Determine if the team is a valid team - * - * @param team The team index to determine if valid for - currently installed/supported mod - * @return True if valid, false if not - **********************************************************************/ -native bool:SM_IsValidTeam(team); - - -public e_SupportedMods:GetCurrentMod() -{ - new String:sGameType[64]; - GetGameFolderName(sGameType, sizeof(sGameType)); - - if (StrEqual(sGameType, "aoc", false)) - { - return GameType_AOC; - } - if (StrEqual(sGameType, "cstrike", false)) - { - return GameType_CSS; - } - if (StrEqual(sGameType, "dod", false)) - { - return GameType_DOD; - } - if (StrEqual(sGameType, "ff", false)) - { - return GameType_FF; - } - if (StrEqual(sGameType, "hidden", false)) - { - return GameType_HIDDEN; - } - if (StrEqual(sGameType, "hl2mp", false)) - { - return GameType_FF; - } - if (StrEqual(sGameType, "insurgency", false) || StrEqual(sGameType, "ins", false)) - { - return GameType_INS; - } - if (StrEqual(sGameType, "l4d", false)) - { - return GameType_L4D; - } - if (StrEqual(sGameType, "nts", false)) - { - return GameType_NEO; - } - if (StrEqual(sGameType, "sgtls", false)) - { - return GameType_SGTLS; - } - if (StrEqual(sGameType, "tf", false)) - { - return GameType_TF; - } - if (StrEqual(sGameType, "zps", false)) - { - return GameType_ZPS; - } - return GameType_Unknown; -} - -public LoadCurrentTeams() -{ - switch (g_CurrentMod) - { - case GameType_INS: - { - g_aCurrentTeams[Unknown] = 0; - g_aCurrentTeams[Spectator] = 3; - g_aCurrentTeams[Team1] = 1; - g_aCurrentTeams[Team2] = 2; - } - case default: - { - g_aCurrentTeams[Unknown] = 0; - g_aCurrentTeams[Spectator] = 1; - g_aCurrentTeams[Team1] = 2; - g_aCurrentTeams[Team2] = 3; - } - } -} diff --git a/Simple Team Manager/addons/sourcemod/scripting/simple-alltalkmanager.sp b/Simple Team Manager/addons/sourcemod/scripting/simple-alltalkmanager.sp deleted file mode 100644 index c848332..0000000 --- a/Simple Team Manager/addons/sourcemod/scripting/simple-alltalkmanager.sp +++ /dev/null @@ -1,515 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple AllTalk Manager -Description: - Allows you to set alltalk at different times -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#pragma semicolon 1 -#include -#include - -#define PLUGIN_VERSION "1.4.$Rev$" - -new Handle:satm_enabled = INVALID_HANDLE; -new Handle:satm_threshold_enabled = INVALID_HANDLE; -new Handle:satm_player_threshold = INVALID_HANDLE; -new Handle:satm_threshold_setting = INVALID_HANDLE; -new Handle:satm_logactivity = INVALID_HANDLE; -new Handle:satm_alltalk = INVALID_HANDLE; - -new Handle:g_aEventNames = INVALID_HANDLE; -new Handle:g_aEventReasons = INVALID_HANDLE; -new Handle:g_aEventSettings = INVALID_HANDLE; - -new bool:g_bLastThreshold = false; -new bool:g_bEnabled = true; -new bool:g_bThresholdEnabled = true; -new bool:g_bIsSetupMap = false; -new bool:g_bIsGameTF2 = false; -new bool:g_bLogActivity = false; - -new g_iLastEventIndex; - -public Plugin:myinfo = -{ - name = "Simple AllTalk Manager", - author = "Simple Plugins", - description = "Allows you to set alltalk at different times", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -} - -/** -Sourcemod callbacks -*/ -public OnPluginStart() -{ - - /** - Need to create all of our console variables. - */ - CreateConVar("satm_version", PLUGIN_VERSION, "Simple AllTalk Manager", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - satm_enabled = CreateConVar("satm_enabled", "1", "Enables/Disables Simple AllTalk Manager", _, true, 0.0, true, 1.0); - satm_threshold_enabled = CreateConVar("satm_threshold_enabled", "1", "Enables/Disables player threshold", _, true, 0.0, true, 1.0); - satm_player_threshold = CreateConVar("satm_player_threshold", "8", "Amount of players for the threshold"); - satm_threshold_setting = CreateConVar("satm_threshold_setting", "1", "Enables/Disables all talk up to player threshold, with the opposite set after the threshold", _, true, 0.0, true, 1.0); - satm_logactivity = CreateConVar("satm_logactivity", "0", "Enables/Disables log activity", _, true, 0.0, true, 1.0); - satm_alltalk = FindConVar("sv_alltalk"); - - /** - Hook console variables - */ - HookConVarChange(satm_enabled, ConVarSettingsChanged); - HookConVarChange(satm_threshold_enabled, ConVarSettingsChanged); - HookConVarChange(satm_player_threshold, ConVarSettingsChanged); - HookConVarChange(satm_logactivity, ConVarSettingsChanged); - - /** - Remove the notify flag from all talk cvar since we do it - */ - SetConVarFlags(satm_alltalk, GetConVarFlags(satm_alltalk)~FCVAR_NOTIFY); - - /** - Get the game type. We only care if it's TF2 - */ - new String:sGameType[64]; - GetGameFolderName(sGameType, sizeof(sGameType)); - if (StrEqual(sGameType, "tf", false)) - { - g_bIsGameTF2 = true; - } - - /** - Create the arrays - */ - g_aEventNames = CreateArray(255, 1); - g_aEventReasons = CreateArray(255, 1); - g_aEventSettings = CreateArray(1, 1); - - /** - Need to register the commands we are going to create and use. - */ - RegAdminCmd("sm_reloadatconfig", Command_Reload, ADMFLAG_GENERIC, "Reloads settings from config file"); - - /** - Create the config file - */ - AutoExecConfig(true); - - /** - Load the events from the config - */ - LoadEventsFromConfig(); -} - -public OnConfigsExecuted() -{ - - /** - Load up the settings - */ - g_bEnabled = GetConVarBool(satm_enabled); - g_bLogActivity = GetConVarBool(satm_logactivity); - g_bThresholdEnabled = GetConVarBool(satm_threshold_enabled); -} - -public OnMapStart() -{ - - /** - Reset the globals - */ - g_iLastEventIndex = 0; - g_bLastThreshold = false; - - /** - Check the map type if we are in TF2 - */ - if (g_bIsGameTF2) - { - g_bIsSetupMap = IsSetupPeriodMap(); - } - - /** - Set AllTalk - */ - if (g_bEnabled) - { - SetConVarBool(satm_alltalk, true); - } -} - -public OnClientDisconnect_Post(client) -{ - if (g_bEnabled) - { - SetAllTalk(-1); - } -} - -public OnClientPostAdminCheck(client) -{ - if (g_bEnabled) - { - SetAllTalk(-1); - } - CreateTimer(2.0, Timer_ShowAllTalkStatus, client, TIMER_FLAG_NO_MAPCHANGE); -} - -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (convar == satm_enabled) - { - if (StringToInt(newValue)) - { - g_bEnabled = true; - } - else - { - g_bEnabled = false; - } - } - else if (convar == satm_threshold_enabled) - { - if (StringToInt(newValue)) - { - g_bThresholdEnabled = true; - } - else - { - g_bThresholdEnabled = false; - } - } - else if (convar == satm_logactivity) - { - if (StringToInt(newValue)) - { - g_bLogActivity = true; - } - else - { - g_bLogActivity = false; - } - } - if (g_bEnabled) - { - SetAllTalk(-1); - } -} - -/** -Commands -*/ -public Action:Command_Reload(client, args) -{ - - /** - Clear the array - */ - ClearArray(g_aEventNames); - ClearArray(g_aEventReasons); - ClearArray(g_aEventSettings); - - /** - Load the events from the config - */ - LoadEventsFromConfig(); - - return Plugin_Handled; -} - -/** -Game Event Hooks -*/ -public Hook_All_Events(Handle:event, const String:name[], bool:dontBroadcast) -{ - if (!g_bIsSetupMap) - { - if (StrEqual(name, "teamplay_round_start")) - { - if (FindStringInArray(g_aEventNames, "teamplay_setup_finished") != -1) - { - g_iLastEventIndex = FindStringInArray(g_aEventNames, "teamplay_setup_finished"); - if (g_bEnabled) - { - SetAllTalk(g_iLastEventIndex); - return; - } - } - } - } - g_iLastEventIndex = FindStringInArray(g_aEventNames, name); - if (g_bEnabled) - { - SetAllTalk(g_iLastEventIndex); - } -} - -/** -Timers -*/ -public Action:Timer_ShowAllTalkStatus(Handle:timer, any:client) -{ - if (IsClientConnected(client) && IsClientInGame(client)) - { - new bool:bSetting = GetConVarBool(satm_alltalk); - if (bSetting) - { - PrintToChat(client, "\x01\x04[SM] AllTalk is \x01[on]"); - } - else - { - PrintToChat(client, "\x01\x04[SM] AllTalk is \x01[off]"); - } - } -} - -/** -Stock Functions -*/ -stock LoadEventsFromConfig() -{ - - /** - Make sure the config file is here and load it up - */ - new String:sConfigFile[256]; - BuildPath(Path_SM, sConfigFile, sizeof(sConfigFile), "configs/simple-alltalkmanager_events.cfg"); - if (!FileExists(sConfigFile)) - { - - /** - Config file doesn't exists, stop the plugin - */ - LogError("[SATM] Simple AllTalk Manager is not running! Could not find file %s", sConfigFile); - SetFailState("Could not find file %s", sConfigFile); - } - - /** - Create the arrays and variables - */ - new String:sGameEventName[256]; - new String:sReason[256]; - new iSetting; - - /** - Load config file as a KeyValues file - */ - new Handle:kvGameEvents = CreateKeyValues("game_events"); - FileToKeyValues(kvGameEvents, sConfigFile); - - if (!KvGotoFirstSubKey(kvGameEvents)) - { - return; - } - - /** - Hook the game events and load the settings - */ - do - { - - /** - Get the section name; this should be the event name - */ - KvGetSectionName(kvGameEvents, sGameEventName, sizeof(sGameEventName)); - if (!HookEventEx(sGameEventName, Hook_All_Events, EventHookMode_PostNoCopy)) - { - - /** - Could not hook this event, stop the plugin - */ - SetFailState("Could not hook event %s", sGameEventName); - } - else - { - if (g_bLogActivity) - { - LogMessage("[SATM] Hooked event: %s", sGameEventName); - } - } - - /** - Get the reason string and setting - */ - KvGetString(kvGameEvents, "reason", sReason, sizeof(sReason)); - iSetting = KvGetNum(kvGameEvents, "setting"); - if (g_bLogActivity) - { - LogMessage("[SATM] Event reason string: %s", sReason); - LogMessage("[SATM] Event setting: %i", iSetting); - } - - /** - Push the values to the arrays - */ - PushArrayString(g_aEventNames, sGameEventName); - PushArrayString(g_aEventReasons, sReason); - PushArrayCell(g_aEventSettings, iSetting); - } while (KvGotoNextKey(kvGameEvents)); - - /** - Close our handle - */ - CloseHandle(kvGameEvents); -} - -stock SetAllTalk(index) -{ - new iPlayerThreshold = GetConVarInt(satm_player_threshold); - new bool:bThresholdMet = ((GetClientCount() >= iPlayerThreshold) ? true : false); - new bool:bSetting; - - if (g_bThresholdEnabled) - { - if (bThresholdMet) - { - if (index == -1) - { - if (bThresholdMet != g_bLastThreshold) - { - g_bLastThreshold = true; - bSetting = !GetConVarBool(satm_threshold_setting); - new bool:bLastSetting = GetArrayCell(g_aEventSettings, g_iLastEventIndex); - if (bLastSetting && !bSetting) - { - bSetting = GetArrayCell(g_aEventSettings, g_iLastEventIndex); - } - } - else - { - bSetting = GetArrayCell(g_aEventSettings, g_iLastEventIndex); - } - } - else - { - bSetting = GetArrayCell(g_aEventSettings, index); - } - } - else - { - g_bLastThreshold = false; - bSetting = GetConVarBool(satm_threshold_setting); - } - } - else - { - if (index != -1) - { - bSetting = GetArrayCell(g_aEventSettings, index); - } - } - - if (GetConVarBool(satm_alltalk) != bSetting) - { - - SetConVarBool(satm_alltalk, bSetting); - - new String:sReason[256]; - if (index == -1) - { - Format(sReason, sizeof(sReason), "Player Threshold"); - } - else - { - if (!g_bIsSetupMap) - { - new String:sCurrentEvent[256]; - GetArrayString(g_aEventNames, index, sCurrentEvent, sizeof(sCurrentEvent)); - if (StrEqual(sCurrentEvent, "teamplay_setup_finished")) - { - new iRoundStartIndex = FindStringInArray(g_aEventNames, "teamplay_round_start"); - if (iRoundStartIndex != -1) - { - GetArrayString(g_aEventReasons, iRoundStartIndex, sReason, sizeof(sReason)); - } - else - { - GetArrayString(g_aEventReasons, index, sReason, sizeof(sReason)); - } - } - else - { - GetArrayString(g_aEventReasons, index, sReason, sizeof(sReason)); - } - } - else - { - GetArrayString(g_aEventReasons, index, sReason, sizeof(sReason)); - } - } - - if (bSetting) - { - PrintToChatAll("\x01\x04[SM] AllTalk turned \x01[on] \x04due to:\x01 %s", sReason); - } - else - { - PrintToChatAll("\x01\x04[SM] AllTalk turned \x01[off] \x04due to:\x01 %s", sReason); - } - } -} - -stock bool:IsSetupPeriodMap() -{ - new iEnt = -1; - new String:sMapName[32]; - - GetCurrentMap(sMapName, sizeof(sMapName)); - - if (strncmp(sMapName, "cp_", 3, false) == 0) - { - new iTeam; - while ((iEnt = FindEntityByClassname(iEnt, "team_control_point")) != -1) - { - iTeam = GetEntProp(iEnt, Prop_Send, "m_iTeamNum"); - - /** - If there is a blu CP or a neutral CP, then it's not an attack/defend map - */ - if (iTeam != 2) - { - //this is a push map - return false; - } - } - //this is a attack/defend map - return true; - } - else if (strncmp(sMapName, "ctf_", 3, false) == 0) - { - //this is a ctf map - return false; - } - return false; -} diff --git a/Simple Team Manager/addons/sourcemod/scripting/simple-autoscrambler.sp b/Simple Team Manager/addons/sourcemod/scripting/simple-autoscrambler.sp deleted file mode 100644 index 6c6799e..0000000 --- a/Simple Team Manager/addons/sourcemod/scripting/simple-autoscrambler.sp +++ /dev/null @@ -1,459 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple AutoScrambler -Description: - Automatically scrambles the teams based upon a number of events. -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include - -#define PLUGIN_VERSION "1.1.$Rev$" - -/** -Different scramble modes: - -1 = Full Scramble, dont restart round. -2 = Admins Immune, dont restart round. -3 = Full Scramble, restart round and reset scores. -4 = Admins Immune, restart round and reset scores. - -*/ - -/** -Different top player modes: - -1 = Divide Top 4 players on the two teams. -2 = Protect the Top 2 players on each team. - -*/ - -enum PlayerData -{ - Handle:hForcedTimer, - bool:bProtected; -}; - -/** -Cvars used for admins -*/ -new Handle: sas_admin_immunity_enabled = INVALID_HANDLE, - Handle: sas_admin_flag_scramblenow = INVALID_HANDLE, - Handle: sas_admin_flag_immunity = INVALID_HANDLE; - -/** -Cvars used for autoscramble -*/ -new Handle: sas_autoscramble_enabled = INVALID_HANDLE, - Handle: sas_autoscramble_minplayers = INVALID_HANDLE, - Handle: sas_autoscramble_mode = INVALID_HANDLE, - Handle: sas_autoscramble_winstreak = INVALID_HANDLE, - Handle: sas_autoscramble_steamroll = INVALID_HANDLE, - Handle: sas_autoscramble_frags = INVALID_HANDLE; - -/** -Cvars used for voting -*/ -new Handle: sas_vote_enabled = INVALID_HANDLE, - Handle: sas_vote_upcount = INVALID_HANDLE, - Handle: sas_vote_winpercent = INVALID_HANDLE, - Handle: sas_vote_mode = INVALID_HANDLE, - Handle: sas_vote_minplayers = INVALID_HANDLE; - -/** -Additional cvars -*/ -new Handle: sas_enabled = INVALID_HANDLE, - Handle: sas_timer_scrambledelay = INVALID_HANDLE, - Handle: TFGameModeArena = INVALID_HANDLE; - -/** -Timers -*/ -new Handle: g_hScrambleTimer = INVALID_HANDLE; - -/** - Player arrays - */ -new g_aPlayers[MAXPLAYERS + 1][PlayerData]; - -/** - Cvar variables - */ -new bool: g_bIsEnabled, - bool: g_bIsAutoScrambleEnabled, - bool: g_bIsVoteEnabled, - bool: g_bIsAdminImmunityEnabled; -new Float: g_fTimer_ScrambleDelay, - Float: g_fVote_UpCount, - Float: g_fVote_WinPercent; -new g_iAutoScramble_Minplayers, - g_iAutoScramble_Mode, - g_iAutoScramble_WinStreak, - g_iAutoScramble_SteamRoll, - g_iAutoScramble_Frags, - g_iVote_Mode, - g_iVote_MinPlayers; -new String: g_sScrambleNowFlag[5], - String: g_sAdminImmunityFlag[5]; - -/** -Other globals -*/ -new g_iMaxEntities, - g_iOwnerOffset; - -public Plugin:myinfo = -{ - name = "Simple AutoScrambler", - author = "Simple Plugins", - description = "Automatically scrambles the teams based upon a number of events.", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -}; - -public OnPluginStart() -{ - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook the game events - */ - LogAction(0, -1, "[SAS] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - switch (g_CurrentMod) - { - case GameType_TF: - { - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - } - case GameType_DOD: - { - HookEvent("dod_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_Post); - } - default: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_Post); - } - } - - /** - Create console variables - */ - CreateConVar("sas_version", PLUGIN_VERSION, "Simple AutoScrambler Version",FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - sas_enabled = CreateConVar("sas_enabled", "1", "Enable/Disable Simple AutoScrambler"); - sas_timer_scrambledelay = CreateConVar("sas_timer_scrambledelay", "5.0", "Delay used after a scramble has been started", _, true, 1.0, true, 30.0); - - /** - Cvars used for admins - */ - sas_admin_immunity_enabled = CreateConVar("sas_admin_immunity_enabled", "1", "Enable/Disable admin immunity for scrambles"); - sas_admin_flag_scramblenow = CreateConVar("sas_admin_flag_scramblenow", "z", "Admin flag to use for scramblenow function/command"); - sas_admin_flag_immunity = CreateConVar("sas_admin_flag_immunity", "z", "Admin flag to use for scramble immunity"); - - /** - Cvars used for autoscramble - */ - sas_autoscramble_enabled = CreateConVar("sas_autoscramble_enabled", "1", "Enable/Disable the autoscramble function"); - sas_autoscramble_minplayers = CreateConVar("sas_autoscramble_minplayers", "16", "Min players needed to start an autoscramble"); - sas_autoscramble_mode = CreateConVar("sas_autoscramble_mode", "1", "Scramble mode used when autoscrambling"); - sas_autoscramble_winstreak = CreateConVar("sas_autoscramble_winstreak", "5", "Max amount of wins in a row a team can achieve before an autoscramble starts"); - sas_autoscramble_steamroll = CreateConVar("sas_autoscramble_steamroll", "120", "Shortest amount of time a team can win by before an autoscramble starts (seconds)"); - sas_autoscramble_frags = CreateConVar("sas_autoscramble_frags", "1", "Min players needed to start a vote and scramble"); - - /** - Cvars used for voting - */ - sas_vote_enabled = CreateConVar("sas_vote_enabled", "1", "Enable/Disable voting for scramble"); - sas_vote_upcount = CreateConVar("sas_vote_upcount", "5", "Amount of people wanting a scramble before a vote starts. If less than 1 it will be considered a percentage. (ie 0.5 = 50% | 1 = 1 Player | 5 = 5 Players)"); - sas_vote_winpercent = CreateConVar("sas_vote_winpercent", "0.6", "Percentage of votes needed to scramble", _, true, 0.0, true, 1.0); - sas_vote_mode = CreateConVar("sas_vote_mode", "1", "Scramble mode used when a vote results in a scramble"); - sas_vote_minplayers = CreateConVar("sas_vote_minplayers", "16", "Min players needed to start a vote and scramble"); - - /** - Hook the console variables if they change - */ - HookConVarChange(sas_enabled, ConVarSettingsChanged); - HookConVarChange(sas_timer_scrambledelay, ConVarSettingsChanged); - HookConVarChange(sas_admin_immunity_enabled, ConVarSettingsChanged); - HookConVarChange(sas_admin_flag_scramblenow, ConVarSettingsChanged); - HookConVarChange(sas_admin_flag_immunity, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_enabled, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_minplayers, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_mode, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_winstreak, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_steamroll, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_frags, ConVarSettingsChanged); - HookConVarChange(sas_vote_enabled, ConVarSettingsChanged); - HookConVarChange(sas_vote_upcount, ConVarSettingsChanged); - HookConVarChange(sas_vote_winpercent, ConVarSettingsChanged); - HookConVarChange(sas_vote_mode, ConVarSettingsChanged); - HookConVarChange(sas_vote_minplayers, ConVarSettingsChanged); - - /** - Register the command - */ - RegConsoleCmd("sm_scramblenow", Command_ScrambleNow, "sm_scramblenow (mode): Scrambles the teams"); - - /** - Load translations and .cfg file - */ - LoadTranslations ("simpleautoscrambler.phrases"); - AutoExecConfig(true, "plugin.simpleautoscrambler"); - LogAction(0, -1, "[SAS] Simple AutoScrambler is loaded."); -} - -public OnAllPluginsLoaded() -{ - //something -} - -public OnLibraryRemoved(const String:name[]) -{ - //something -} - -public OnConfigsExecuted() -{ - - /** - Load up all the variable defaults - */ - LoadUpVariables(); - - /** - Log our activity - */ - if (g_bIsEnabled) - LogAction(0, -1, "Simple AutoScrambler is ENABLED"); - else - LogAction(0, -1, "Simple AutoScrambler is DISABLED"); -} - -public Action:Command_ScrambleNow(client, args) -{ - - /** - Make sure we are enabled - */ - if (!g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - Make sure the client is authorized to run this command. - */ - if (!SM_IsValidAdmin(client, g_sScrambleNowFlag)) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Make sure it's ok to scramble at this time - */ - if (!OkToScramble) - { - return Plugin_Handled; - } - - /** - Make sure it's ok to scramble at this time - */ - LogAction(0, -1, "[SAS] The scramblenow command was used"); - - /** - Scramble the teams - */ - StartAScramble(); - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public HookRoundStart(Handle:event, const String:name[], bool:dontBroadcast) -{ - -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - -} - -public Action:Timer_ScrambleTeams(Handle:timer, any:mode) -{ - - /** - Make sure it's still ok to scramble - */ - if (!OkToScramble) - { - return Plugin_Handled; - } - - - switch (mode) - { - case - - - - } - - - /** - Reset the handle because the timer is over and the callback is done - */ - g_hScrambleTimer = INVALID_HANDLE; - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - -} - -stock StartAScramble(mode) -{ - - /** - See if we are already started a scramble - */ - if (g_hScrambleTimer == INVALID_HANDLE) - { - - /** - There is a scramble in progress - */ - return; - - } - - /** - Report that a scramble is about to start - */ - PrintCenterTextAll("%T", "Scramble", LANG_SERVER); - - /** - Start a timer and log the action - */ - g_hScrambleTimer = CreateTimer(g_fTimer_ScrambleDelay, Timer_ScrambleTeams, mode, TIMER_FLAG_NO_MAPCHANGE); - LogAction(0, -1, "[SAS] A scamble timer was started"); -} - -stock bool:OkToScramble() -{ - -} - -stock LoadUpVariables() -{ - g_bIsEnabled = GetConVarBool(sas_enabled); - g_bIsAutoScrambleEnabled = GetConVarBool(sas_autoscramble_enabled); - g_bIsVoteEnabled = GetConVarBool(sas_vote_enabled); - g_bIsAdminImmunityEnabled = GetConVarBool(sas_admin_immunity_enabled); - g_iAutoScramble_Minplayers = GetConVarInt(sas_autoscramble_minplayers); - g_iAutoScramble_Mode = GetConVarInt(sas_autoscramble_mode); - g_iAutoScramble_WinStreak = GetConVarInt(sas_autoscramble_winstreak); - g_iAutoScramble_SteamRoll = GetConVarInt(sas_autoscramble_steamroll); - g_iAutoScramble_Frags = GetConVarInt(sas_autoscramble_frags); - g_iVote_Mode = GetConVarInt(sas_vote_mode); - g_iVote_MinPlayers = GetConVarInt(sas_vote_minplayers); - GetConVarString(sas_admin_flag_scramblenow, g_sScrambleNowFlag, sizeof(g_sScrambleNowFlag)); - GetConVarString(sas_admin_flag_immunity, g_sAdminImmunityFlag, sizeof(g_sAdminImmunityFlag)); - g_fTimer_ScrambleDelay = GetConVarFloat(sas_timer_scrambledelay); - g_fVote_UpCount = GetConVarFloat(sas_vote_upcount); - g_fVote_WinPercent = GetConVarFloat(sas_vote_winpercent); - g_iMaxEntities = GetMaxEntities(); - g_iOwnerOffset = FindSendPropInfo("CBaseObject", "m_hBuilder"); -} - -stock TF2_DestroyBuildings(client) -{ - - /** - We have to start a loop to check the owner of all the valid entities - */ - for (new i = MaxClients + 1; i <= g_iMaxEntities; i++) - { - if (!IsValidEntity(i)) - { - - /** - Not valid, continue to next one - */ - continue; - } - - /** - Get the name of the current entity - */ - decl String:sNetClass[32]; - GetEntityNetClass(i, sNetClass, sizeof(sNetClass)); - - /** - See if its something that an engineer would build - */ - if (strcmp(sNetClass, "CObjectSentrygun") == 0 - || strcmp(sNetClass, "CObjectTeleporter") == 0 - || strcmp(sNetClass, "CObjectDispenser") == 0) - { - - /** - It is, so lets check the owner - */ - if (GetEntDataEnt2(i, g_iOwnerOffset) == client) - { - - /** - It's the clients building, so we blow it up. - */ - SetVariantInt(9999); - AcceptEntityInput(i, "RemoveHealth"); - } - } - } -} \ No newline at end of file diff --git a/Simple Team Manager/addons/sourcemod/scripting/simple-chatcolors.sp b/Simple Team Manager/addons/sourcemod/scripting/simple-chatcolors.sp deleted file mode 100644 index 539d057..0000000 --- a/Simple Team Manager/addons/sourcemod/scripting/simple-chatcolors.sp +++ /dev/null @@ -1,496 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Chat Colors -Description: - Changes the colors of players chat based on config file -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#pragma semicolon 1 -#include -#include - -#define PLUGIN_VERSION "0.9.0.$Rev$" - -#define CHAT_SYMBOL '@' -#define TRIGGER_SYMBOL1 '!' -#define TRIGGER_SYMBOL2 '/' -#define CHAT_MAX_MESSAGE_LENGTH 1024 - -new Handle:g_hDebugCvar = INVALID_HANDLE; -new Handle:g_aGroupNames = INVALID_HANDLE; -new Handle:g_aGroupFlag = INVALID_HANDLE; -new Handle:g_aGroupNameColor = INVALID_HANDLE; -new Handle:g_aGroupTextColor = INVALID_HANDLE; - -new bool:g_bDebug = false; - -new g_iArraySize; - -new g_aPlayerColorIndex[MAXPLAYERS + 1] = { -1, ... }; - -public Plugin:myinfo = -{ - name = "Simple Chat Colors", - author = "Simple Plugins", - description = "Changes the colors of players chat based on config file.", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -}; - -/** -Sourcemod callbacks -*/ -public OnPluginStart() -{ - - /** - Need to create all of our console variables. - */ - CreateConVar("sm_chatcolors_version", PLUGIN_VERSION, "Simple Chat Colors", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - g_hDebugCvar = CreateConVar("sm_chatcolors_debug", "1", "Enable/Disable debugging information"); - - /** - Hook console variables - */ - HookConVarChange(g_hDebugCvar, ConVarSettingsChanged); - - /** - Need to register the commands we are going to use - */ - RegConsoleCmd("say", Command_Say); - RegConsoleCmd("say_team", Command_SayTeam); - RegAdminCmd("sm_reloadcolorsconfig", Command_Reload, ADMFLAG_GENERIC, "Reloads settings from config file"); - - /** - Create the arrays - */ - g_aGroupNames = CreateArray(256, 1); - g_aGroupFlag = CreateArray(15, 1); - g_aGroupNameColor = CreateArray(15, 1); - g_aGroupTextColor = CreateArray(15, 1); - - /** - Load the admins and colors from the config - */ - LoadAdminsAndColorsFromConfig(); - g_iArraySize = GetArraySize(g_aGroupNames); -} - -public OnConfigsExecuted() -{ - g_bDebug = GetConVarBool(g_hDebugCvar); - ReloadConfigFile(); -} - -public OnClientPostAdminCheck(client) -{ - - /** - Check the client to see if they are a admin - */ - CheckAdmin(client); -} - -public OnClientDisconnect(client) -{ - g_aPlayerColorIndex[client] = -1; -} - -/** -Commands -*/ -public Action:Command_Say(client, args) -{ - - /** - Make sure we are enabled. - */ - if (client == 0 || IsChatTrigger()) - { - return Plugin_Continue; - } - - if (g_aPlayerColorIndex[client] != -1) - { - - /** - The client is, so get the chat message and strip it down. - */ - decl String:sArg[CHAT_MAX_MESSAGE_LENGTH], - String:sChatMsg[CHAT_MAX_MESSAGE_LENGTH]; - - new bool:bAlive = IsPlayerAlive(client); - - GetCmdArgString(sArg, sizeof(sArg)); - StripQuotes(sArg); - TrimString(sArg); - new startidx; - if (sArg[strlen(sArg)-1] == '"') - { - sArg[strlen(sArg)-1] = '\0'; - startidx = 1; - } - - /** - Bug out if they are using the admin chat symbol (admin chat). If we are in CSS it may not find all the triggers, so we double check. - */ - if (sArg[startidx] == CHAT_SYMBOL || sArg[startidx] == TRIGGER_SYMBOL1 || sArg[startidx] == TRIGGER_SYMBOL2) - { - return Plugin_Continue; - } - - /** - Log the message for hlstatsx and other things. - */ - new iUserID = GetClientUserId(client); - decl String:sAuthID[64]; - GetClientAuthString(client, sAuthID, sizeof(sAuthID)); - LogToGame("\"%N<%i><%s><>\" say \"%s\"", client, iUserID, sAuthID, sArg); - - /** - Format the message. - */ - FormatMessage(client, 0, bAlive, sChatMsg, sArg, g_aPlayerColorIndex[client]); - - /** - Send the message. - */ - //SayText2(0, client, sChatMsg); - CPrintToChatAll(sChatMsg); - - /** - We are done, bug out, and stop the original chat message. - */ - return Plugin_Stop; - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -public Action:Command_SayTeam(client, args) -{ - - /** - Make sure we are enabled. - */ - if (client == 0 || IsChatTrigger()) - { - return Plugin_Continue; - } - - /** - Check the client to see if they are a admin - */ - if (g_aPlayerColorIndex[client] != -1) - { - - /** - The client is, so get the chat message and strip it down. - */ - decl String:sArg[CHAT_MAX_MESSAGE_LENGTH], - String:sChatMsg[CHAT_MAX_MESSAGE_LENGTH]; - - new bool:bAlive = IsPlayerAlive(client); - new iCurrentTeam = GetClientTeam(client); - - GetCmdArgString(sArg, sizeof(sArg)); - StripQuotes(sArg); - TrimString(sArg); - new startidx; - if (sArg[strlen(sArg)-1] == '"') - { - sArg[strlen(sArg)-1] = '\0'; - startidx = 1; - } - - /** - Bug out if they are using the admin chat symbol (admin chat). - */ - if (sArg[startidx] == CHAT_SYMBOL || sArg[startidx] == TRIGGER_SYMBOL1 || sArg[startidx] == TRIGGER_SYMBOL2) - { - return Plugin_Continue; - } - - /** - Log the message for hlstatsx and other things. - */ - new iUserID = GetClientUserId(client); - decl String:sAuthID[64]; - GetClientAuthString(client, sAuthID, sizeof(sAuthID)); - LogToGame("\"%N<%i><%s><>\" say_team \"%s\"", client, iUserID, sAuthID, sArg); - - /** - Format the message. - */ - FormatMessage(client, iCurrentTeam, bAlive, sChatMsg, sArg, g_aPlayerColorIndex[client]); - - /** - Send the message to the same team - */ - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientConnected(i) && IsClientInGame(i) && GetClientTeam(i) == iCurrentTeam) - { - CPrintToChat(client, sChatMsg); - } - } - - /** - We are done, bug out, and stop the original chat message. - */ - return Plugin_Stop; - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -public Action:Command_Reload(client, args) -{ - ReloadConfigFile(); - return Plugin_Handled; -} - -/** -Stock Functions -*/ -stock LoadAdminsAndColorsFromConfig() -{ - - /** - Make sure the config file is here and load it up - */ - new String:sConfigFile[256]; - BuildPath(Path_SM, sConfigFile, sizeof(sConfigFile), "configs/simple-chatcolors.cfg"); - if (!FileExists(sConfigFile)) - { - - /** - Config file doesn't exists, stop the plugin - */ - LogError("[SCC] Simple Chat Colors is not running! Could not find file %s", sConfigFile); - SetFailState("Could not find file %s", sConfigFile); - } - - /** - Create the arrays and variables - */ - new String:sGroupName[256]; - new String:sGroupFlag[15]; - new String:sGroupNameColor[15]; - new String:sGroupTextColor[15]; - - - /** - Load config file as a KeyValues file - */ - new Handle:kvChatColors = CreateKeyValues("admin_colors"); - FileToKeyValues(kvChatColors, sConfigFile); - - if (!KvGotoFirstSubKey(kvChatColors)) - { - return; - } - - /** - Load up all the groups in the file - */ - do - { - - /** - Get the section name; should be the "group" name - */ - KvGetSectionName(kvChatColors, sGroupName, sizeof(sGroupName)); - - - /** - Get the flags and colors - */ - KvGetString(kvChatColors, "flag", sGroupFlag, sizeof(sGroupFlag)); - KvGetString(kvChatColors, "namecolor", sGroupNameColor, sizeof(sGroupNameColor)); - KvGetString(kvChatColors, "textcolor", sGroupTextColor, sizeof(sGroupTextColor)); - - if (g_bDebug) - { - LogMessage("Group Name/SteamID: %s", sGroupName); - LogMessage("Flag String: %s", sGroupFlag); - LogMessage("Color on name: %s", sGroupNameColor); - LogMessage("Color of text: %s", sGroupTextColor); - } - - /** - Push the values to the arrays - */ - PushArrayString(g_aGroupNames, sGroupName); - PushArrayString(g_aGroupFlag, sGroupFlag); - PushArrayString(g_aGroupNameColor, sGroupNameColor); - PushArrayString(g_aGroupTextColor, sGroupTextColor); - } while (KvGotoNextKey(kvChatColors)); - - /** - Close our handle - */ - CloseHandle(kvChatColors); -} - -stock ReloadConfigFile() -{ - - /** - Clear the array - */ - ClearArray(g_aGroupNames); - ClearArray(g_aGroupFlag); - ClearArray(g_aGroupNameColor); - ClearArray(g_aGroupTextColor); - - /** - Load the admins, groups, and colors from the config - */ - LoadAdminsAndColorsFromConfig(); - g_iArraySize = GetArraySize(g_aGroupNames); - - /** - Recheck all the online players for assigned colors - */ - for (new index = 1; index <= MaxClients; index++) - { - if (IsClientConnected(index) && IsClientInGame(index)) - { - CheckAdmin(index); - } - } -} - -stock CheckAdmin(client) -{ - new String:sFlags[15]; - new String:sClientSteamID[64]; - new iGroupFlags; - new iFlags; - new iIndex = -1; - - /** - Look for a steamid first - */ - GetClientAuthString(client, sClientSteamID, sizeof(sClientSteamID)); - iIndex = FindStringInArray(g_aGroupNames, sClientSteamID); - if (iIndex != -1) - { - g_aPlayerColorIndex[client] = iIndex; - } - - /** - Didn't find one, check flags - */ - else - { - /** - Search for flag in groups - */ - - iFlags = GetUserFlagBits(client); - for (iIndex = 0; iIndex < g_iArraySize; iIndex++) - { - GetArrayString(g_aGroupFlag, iIndex, sFlags, sizeof(sFlags)); - iGroupFlags = ReadFlagString(sFlags); - if (iFlags & iGroupFlags) - { - g_aPlayerColorIndex[client] = iIndex; - break; - } - } - } - - if (g_bDebug) - { - PrintToChatAll("SteamID: %s", sClientSteamID); - PrintToChatAll("Array Index: %i", iIndex); - PrintToChatAll("Flag String: %s", sFlags); - PrintToChatAll("Flag Bits of Client: %i", iFlags); - PrintToChatAll("Flag Bits of Group: %i", iGroupFlags); - } -} - -stock FormatMessage(iClient, iTeam, bool:bAlive, String:sChatMsg[], const Sting:sMessage[], iArrayIndex) -{ - decl String:sDead[10], - String:sTeam[10], - String:sClientName[64]; - - GetClientName(iClient, sClientName, sizeof(sClientName)); - - if (iTeam != 0) - { - Format(sTeam, sizeof(sTeam), "(TEAM) "); - } - else - { - Format(sTeam, sizeof(sTeam), ""); - } - if (bAlive) - { - Format(sDead, sizeof(sDead), ""); - } - else - { - Format(sDead, sizeof(sDead), "*DEAD* "); - } - - new String:sNameColor[15]; - new String:sTextColor[15]; - GetArrayString(g_aGroupNameColor, iArrayIndex, sNameColor, sizeof(sNameColor)); - GetArrayString(g_aGroupTextColor, iArrayIndex, sTextColor, sizeof(sTextColor)); - - Format(sChatMsg, CHAT_MAX_MESSAGE_LENGTH, "{default}%s%s%s%s {default}: %s%s", sDead, sTeam, sNameColor, sClientName, sTextColor, sMessage); -} - -/** -Adjust the settings if a convar was changed -*/ -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (StringToInt(newValue) == 1) - { - g_bDebug = true; - } - else - { - g_bDebug = false; - } -} \ No newline at end of file diff --git a/Simple Team Manager/addons/sourcemod/scripting/simple-donatorbenefits.sp b/Simple Team Manager/addons/sourcemod/scripting/simple-donatorbenefits.sp deleted file mode 100644 index e3f6845..0000000 --- a/Simple Team Manager/addons/sourcemod/scripting/simple-donatorbenefits.sp +++ /dev/null @@ -1,1312 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Donator Benefits -Description: - Provides donator benefits to players -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include -#include - -#define PLUGIN_VERSION "1.1.$Rev$" - -#define CHAT_SYMBOL '@' -#define CHAT_MAX_MESSAGE_LENGTH 1024 - -enum PlayerData -{ - bool:bIsDonator, - bool:bQueue, - bool:bImmune, - iHealthCount, - iNewTeam -}; - -/** - Public convar handles - */ -new Handle:sdb_enabled = INVALID_HANDLE; -new Handle:sdb_donationflag = INVALID_HANDLE; -new Handle:sdb_soundfile = INVALID_HANDLE; -new Handle:sdb_joinsound_enabled = INVALID_HANDLE; -new Handle:sdb_joinpubmsg_enabled = INVALID_HANDLE; -new Handle:sdb_joinprivmsg_enabled = INVALID_HANDLE; -new Handle:sdb_chatcolors_enabled = INVALID_HANDLE; -new Handle:sdb_immunity_enabled = INVALID_HANDLE; -new Handle:sdb_ubercharge_enabled = INVALID_HANDLE; -new Handle:sdb_givehealth_enabled = INVALID_HANDLE; -new Handle:sdb_nofalldmg_enabled = INVALID_HANDLE; -new Handle:sdb_fastheavy_enabled = INVALID_HANDLE; -new Handle:sdb_swapteam_enabled = INVALID_HANDLE; -new Handle:sdb_chatcolor = INVALID_HANDLE; -new Handle:sdb_uberlevel = INVALID_HANDLE; -new Handle:sdb_healthcount = INVALID_HANDLE; -new Handle:sdb_healthbonus = INVALID_HANDLE; -new Handle:sdb_heavymultiplier = INVALID_HANDLE; - -/** -Create global enable/disable bools so we don't have to check the console variable on every call -*/ -new bool:g_bIsEnabled = true; -new bool:g_bIsJoinSoundEnabled = true; -new bool:g_bIsJoinPubMsgEnabled = true; -new bool:g_bIsJoinPrivMsgEnabled = true; -new bool:g_bIsChatColorsEnabled = true; -new bool:g_bIsImmuntyEnabled = true; -new bool:g_bIsUberChargeEnabled = true; -new bool:g_bIsGiveHealthEnabled = true; -new bool:g_bIsNoFallDmgEnabled = true; -new bool:g_bIsFastHeayEnabled = true; -new bool:g_bIsSwapTeamEnabled = true; - -/** - Player arrays - */ -new g_aPlayers[MAXPLAYERS + 1][PlayerData]; - - -/** -Rest of the globals -*/ -new bool:g_bRoundEnd = false; -new String:g_sCharDonatorFlag[5]; -new String:g_sSoundFile[PLATFORM_MAX_PATH]; -new String:g_sChatColor[11]; -new g_iHealthBonus; -new g_iHealthCount; -new g_iClassMaxHealth[TFClassType] = {0, 125, 125, 200, 175, 150, 300, 175, 125, 125}; -new g_fClassMaxSpeed[TFClassType] = {0, 400, 300, 240, 280, 320, 230, 300, 300, 300}; -new Float:g_fHeavyMultiplier = 0.0; -new Float:g_fUberLevel = 0.0; - -public Plugin:myinfo = -{ - name = "Simple Donation Benefits", - author = "Simple Plugins", - description = "Gives donators benefits to players", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -} - -public OnPluginStart() -{ - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook the game events - */ - LogAction(0, -1, "[SDB] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_connect", HookPlayerSpawn, EventHookMode_Pre); - HookEvent("player_spawn", HookPlayerSpawn, EventHookMode_Post); - HookEvent("player_death", HookPlayerDeath, EventHookMode_Post); - HookEvent("player_team", HookPlayerChangeTeam, EventHookMode_Post); - switch (g_CurrentMod) - { - case GameType_TF: - { - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - HookEvent("player_changeclass", HookPlayerClass, EventHookMode_Post); - } - case GameType_DOD: - { - HookEvent("dod_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_Post); - } - default: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - } - } - - /** - Create console variables - */ - CreateConVar("sdb_version", PLUGIN_VERSION, "Simple Donation Benefits", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - sdb_enabled = CreateConVar("sdb_enabled", "1", "Enable/Disable Simple Donation Benefits"); - sdb_donationflag = CreateConVar("sdb_donationflag", "a", "Flag ALREADY given to donators. Must be in char format"); - - /** - Create the enable/disable donator console variables - */ - sdb_joinsound_enabled = CreateConVar("sdb_joinsound_enabled", "1", "Enable/Disable donator join sound"); - sdb_joinpubmsg_enabled = CreateConVar("sdb_joinpubmsg_enabled", "1", "Enable/Disable public donator join message (replaces: as connected)"); - sdb_joinprivmsg_enabled = CreateConVar("sdb_joinprivmsg_enabled", "1", "Enable/Disable private donator join message (sent only to donator)"); - sdb_chatcolors_enabled = CreateConVar("sdb_chatcolors_enabled", "1", "Enable/Disable donator chat colors"); - sdb_immunity_enabled = CreateConVar("sdb_immunity_enabled", "1", "Enable/Disable donator round end immunity"); - sdb_ubercharge_enabled = CreateConVar("sdb_ubercharge_enabled", "1", "Enable/Disable donator medics starting with ubercharge"); - sdb_givehealth_enabled = CreateConVar("sdb_givehealth_enabled", "1", "Enable/Disable donator instant health bonus"); - sdb_nofalldmg_enabled = CreateConVar("sdb_nofalldmg_enabled", "1", "Enable/Disable no fall damage for donators"); - sdb_fastheavy_enabled = CreateConVar("sdb_fastheavy_enabled", "1", "Enable/Disable donator heavies moving faster while spinning"); - sdb_swapteam_enabled = CreateConVar("sdb_swampteam_enabled", "1", "Enable/Disable donator swap team ability"); - - /** - Create the donator setting console variables - */ - sdb_soundfile = CreateConVar("sdb_soundfile", "custom/donatorjoin.mp3", "The location of sound file"); - sdb_chatcolor = CreateConVar("sdb_chatcolor", "green", "Color to use for donator chat. Valid colors are green and lightgreen"); - sdb_uberlevel = CreateConVar("sdb_uberlevel", "0.5", "Uberlevel to give donator medic at spawn. 1.0 = full uber", _, true, 0.0, true, 1.0); - sdb_healthcount = CreateConVar("sdb_healthcount", "1", "Number of times a donator can use use instant health per life"); - sdb_healthbonus = CreateConVar("sdb_healthbonus", "100", "The amount of health to heal the donator"); - sdb_heavymultiplier = CreateConVar("sdb_heavyspeed", "0.5", "The speed multiplier for the fast heavy. Based on running speed. 1.0 = running speed. (Game Default is 0.20)", _, true, 0.0, true, 1.0); - - /** - Hook dukehacks calls - */ - dhAddClientHook(CHK_TakeDamage, Hacks_TakeDamageHook); - dhAddClientHook(CHK_PreThink, Hacks_PreThinkHook); - - /** - Hook the console variables if they change - */ - HookConVarChange(sdb_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_donationflag, ConVarSettingsChanged); - HookConVarChange(sdb_joinsound_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_joinpubmsg_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_joinprivmsg_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_chatcolors_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_immunity_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_ubercharge_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_givehealth_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_nofalldmg_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_swapteam_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_fastheavy_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_soundfile, ConVarSettingsChanged); - HookConVarChange(sdb_chatcolor, ConVarSettingsChanged); - HookConVarChange(sdb_uberlevel, ConVarSettingsChanged); - HookConVarChange(sdb_healthcount, ConVarSettingsChanged); - HookConVarChange(sdb_healthbonus, ConVarSettingsChanged); - HookConVarChange(sdb_heavymultiplier, ConVarSettingsChanged); - - /** - Register the commands - */ - RegConsoleCmd("sm_swapteams", Command_SwapTeam, "sm_swapteams <[0]instant/[1]queued>: Swaps your team to the other team"); - RegConsoleCmd("sm_ihealth", Command_InstantHealth, "sm_ihealth: Gives you a instant health pack"); - RegAdminCmd("sm_teaser", Command_Teaser, ADMFLAG_GENERIC,"sm_teaser <[0]add/[1]remove>: Gives temporary donator privilages to a player"); - RegConsoleCmd("say", Command_Say); - - RegConsoleCmd("sm_test", Command_TEST); - - /** - Load the translations - */ - LoadTranslations("common.phrases"); - LoadTranslations("simpledonatorbenefits.phrases"); - - /** - Load or create the config file - */ - AutoExecConfig(true, "plugin.simpledonatorbenefits"); - LogAction(0, -1, "[SDB] Simple Donator Benefits is loaded."); -} - -public OnAllPluginsLoaded() -{ - //something -} - -public OnLibraryRemoved(const String:name[]) -{ - //something -} - -public OnConfigsExecuted() -{ - /** - Load up all the variable defaults - */ - LoadUpVariables(); - - /** - If the join sound is enabled, prep the sound files - */ - if (g_bIsJoinSoundEnabled) - PrepSoundFile(); - - /** - Log our activity - */ - if (g_bIsEnabled) - LogAction(0, -1, "Simple Donation Benefits is ENABLED"); - else - LogAction(0, -1, "Simple Donation Benefits is DISABLED"); -} - -public OnClientPostAdminCheck(client) -{ - - /** - Check if the client is a donator - */ - if (SM_IsValidAdmin(client, g_sCharDonatorFlag)) - { - - /** - They are, so we set the player array to true and start a timer for the sound or add - */ - g_aPlayers[client][bIsDonator] = true; - if (g_bIsJoinSoundEnabled || g_bIsJoinPrivMsgEnabled) - { - CreateTimer(10.0, Timer_DonatorJoined, client, TIMER_FLAG_NO_MAPCHANGE); - } - } - else - { - /** - They aren't, so we set the player array to false - */ - g_aPlayers[client][bIsDonator] = false; - } -} - -public OnClientDisconnect_Post(client) -{ - - /** - Clean up the player variables - */ - CleanUpPlayer(client); -} - -public Action:Command_SwapTeam(client, args) -{ - - /** - Make sure we are enabled - */ - if (!g_bIsEnabled || !g_bIsSwapTeamEnabled) - { - return Plugin_Handled; - } - - /** - Make sure the command is not started by the server - */ - if (client == 0) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "PlayerLevelCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Make sure the player is a donator - */ - if (!g_aPlayers[client][bIsDonator]) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Lets make sure the client is one a team we can swap. - If he is we set the global array to the opposite team. - */ - new iTeam = GetClientTeam(client); - if (iTeam == g_aCurrentTeams[Team1]) - { - g_aPlayers[client][iNewTeam] = g_aCurrentTeams[Team2]; - } - else if (iTeam == g_aCurrentTeams[Team2]) - { - g_aPlayers[client][iNewTeam] = g_aCurrentTeams[Team1]; - } - else - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "InValidTeam", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check to see if we have command arguments. - */ - if (GetCmdArgs()) - { - - /** - We do, so lets get it and see if the client wants to be switched instantly or queued for death. - */ - decl String:sArg[5]; - GetCmdArg(1, sArg, sizeof(sArg)); - new iWantsQue = StringToInt(sArg); - if (iWantsQue && !g_aPlayers[client][bQueue]) - { - - /** - He wants the que and isn't already in it, set the global array. - */ - g_aPlayers[client][bQueue] = true; - ReplyToCommand(client, "\x01\x04[STM]\x01 %T", "PlayerQueue", LANG_SERVER); - } - else if (!iWantsQue) - { - - /** - He wants to be switched right now, lets call the stock function. - */ - SM_MovePlayer(client, g_aPlayers[client][iNewTeam]); - } - } - else - { - - /** - There are no command arguments so we build and display the swap menu. - */ - new Handle:hPlayerMenu = BuildSwapModeMenu(); - DisplayMenu(hPlayerMenu, client, MENU_TIME_FOREVER); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_InstantHealth(client, args) -{ - - /** - Make sure we are enabled - */ - if (!g_bIsEnabled || !g_bIsGiveHealthEnabled) - { - return Plugin_Handled; - } - - /** - Make sure the command is not started by the server - */ - if (client == 0) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "PlayerLevelCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Make sure the player is a donator - */ - if (!g_aPlayers[client][bIsDonator]) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check health count to see if the player has reached the max - */ - if (g_aPlayers[client][iHealthCount] >= g_iHealthCount) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "ReachedCount", LANG_SERVER); - return Plugin_Handled; - } - - /** - Get the class of the player and the max health for that class - */ - new iHealth = GetClientHealth(client); - new TFClassType:PlayerClass = TF2_GetPlayerClass(client); - new iMaxHealth = g_iClassMaxHealth[PlayerClass]; - - /** - Check to see if the player is at the max health of the class - */ - if (iHealth >= iMaxHealth) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "AtMaxHealth", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check the current health - */ - if (iHealth + g_iHealthBonus >= iMaxHealth) - { - - /** - Raise them to max health if the current health + bonus would go above it - */ - SetEntityHealth(client, iMaxHealth); - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "ToMaxHealth", LANG_SERVER); - } - else - { - - /** - Give them the instant health bonus - */ - SetEntityHealth(client, iHealth + g_iHealthBonus); - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "HealthBonus", LANG_SERVER); - } - - /** - Increase the count - */ - g_aPlayers[client][iHealthCount] += 1; - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_Teaser(client, args) -{ - - /** - Make sure we are enabled - */ - if (!g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - Check to see if we have command arguments. - */ - new iCmdArgs = GetCmdArgs(); - if (iCmdArgs == 0) - { - - /** - We don't so display the player menu. - */ - new Handle:hPlayerMenu = BuildPlayerMenu(); - DisplayMenu(hPlayerMenu, client, MENU_TIME_FOREVER); - return Plugin_Handled; - } - - /** - We have some arguments, see if we can find the player - */ - decl String:sPlayer[64]; - GetCmdArg(1, sPlayer, sizeof(sPlayer)); - new iTarget = FindTarget(client, sPlayer, true, true); - if (iTarget == -1 || !IsClientInGame(iTarget)) - { - - /** - We don't know who this is, so display the player menu. - */ - new Handle:hPlayerMenu = BuildPlayerMenu(); - DisplayMenu(hPlayerMenu, client, MENU_TIME_FOREVER); - } - else - { - /** - We found the player, see if we are supposed to turn it on or off. - */ - if (iCmdArgs >= 2) - { - decl String:sOn[3]; - GetCmdArg(2, sOn, sizeof(sOn)); - if (StringToInt(sOn)) - { - - /** - Turn temp benefits on. - */ - g_aPlayers[iTarget][bIsDonator] = true; - } - else - { - - /** - Turn temp benefits on. - */ - g_aPlayers[iTarget][bIsDonator] = false; - } - } - else - { - - /** - We don't know what to do, so just turn it on. - */ - g_aPlayers[iTarget][bIsDonator] = true; - } - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_Say(client, args) -{ - - /** - Make sure we are enabled. - */ - if (client == 0 || IsChatTrigger() || !g_bIsChatColorsEnabled || !g_bIsEnabled) - { - return Plugin_Continue; - } - - /** - Check the client to see if they are a donator. - */ - if (g_aPlayers[client][bIsDonator]) - { - - /** - The client is, so get the chat message and strip it down. - */ - decl String:sArg[CHAT_MAX_MESSAGE_LENGTH], - String:sChatMsg[CHAT_MAX_MESSAGE_LENGTH]; - new bool:bAlive = IsPlayerAlive(client); - GetCmdArgString(sArg, sizeof(sArg)); - StripQuotes(sArg); - TrimString(sArg); - new startidx; - if (sArg[strlen(sArg)-1] == '"') - { - sArg[strlen(sArg)-1] = '\0'; - startidx = 1; - } - - /** - Bug out if they are using the admin chat symbol (admin chat). - */ - if (sArg[startidx] == CHAT_SYMBOL) - { - return Plugin_Continue; - } - - /** - Format the message. - */ - FormatMessage(client, 0, bAlive, sChatMsg, sArg); - - /** - Send the message. - */ - SayText2(0, client, sChatMsg); - - /** - We are done, bug out, and stop the original chat message. - */ - return Plugin_Stop; - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -public Action:Hacks_TakeDamageHook(client, attacker, inflictor, Float:damage, &Float:multiplier, damagetype) -{ - - /** - Make sure we are enabled and the client is a donator. - */ - if (g_bIsEnabled && g_bIsNoFallDmgEnabled && g_aPlayers[client][bIsDonator]) - { - - /** - Check for fall damage. - */ - if (damagetype & DMG_FALL) - { - - /** - Cancel the fall damage and bug out. - */ - multiplier *= 0.0; - return Plugin_Changed; - } - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -public Action:Hacks_PreThinkHook(client) -{ - - /** - Make sure we are enabled and the client is a donator. - */ - if (!g_bIsEnabled || !g_bIsFastHeayEnabled || !g_aPlayers[client][bIsDonator]) - { - return Plugin_Continue; - } - - /** - Check the players class. We are looking for the heavy. - */ - new TFClassType:PlayerClass = TF2_GetPlayerClass(client); - if (PlayerClass == TFClass_Heavy) - { - - /** - We have a heavy, lets check the weapon. - */ - decl String:sWeaponCurrent[64]; - GetClientWeapon(client, sWeaponCurrent, sizeof(sWeaponCurrent)); - if (StrEqual(sWeaponCurrent, "tf_weapon_minigun", false)) - { - - /** - We have a minigun, check the heavies current weapon state to see if it's spinning. - */ - new iWeapon = GetPlayerWeaponSlot(client, 0); - new iWeaponState = GetEntProp(iWeapon, Prop_Send, "m_iWeaponState"); - if (iWeaponState > 0) - { - - /** - He is spinning, so lets change the heavies speed. - */ - new Float:fMaxSpeed = FloatMul(g_fHeavyMultiplier, float(g_fClassMaxSpeed[PlayerClass])); - SetEntPropFloat(client, Prop_Send, "m_flMaxspeed", fMaxSpeed); - } - } - } - - /** - We are done, bug out. - */ - // use Plugin_Continue (other options are ignored on PreThink hook) - return Plugin_Continue; -} - -public Action:HookPlayerConnect(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Make sure we are enabled. - */ - if (!g_bIsEnabled || !g_bIsJoinPubMsgEnabled || !dontBroadcast) - { - return Plugin_Continue; - } - - /** - Get our event variables and check the client. - */ - new iUserId = GetEventInt(event,"userid"); - new iClient = GetClientOfUserId(iUserId); - if (iClient != 0) - { - - /** - Get the info on the client and format the message. - */ - decl String:sClientName[255], - String:sAuthID[255], - String:sMsg[1024]; - - GetEventString(event, "name", sClientName, sizeof(sClientName)); - GetClientAuthString(iClient, sAuthID, sizeof(sAuthID)); - Format(sMsg, sizeof(sMsg), "%T", "PublicJoinMessage", LANG_SERVER, sClientName); - - /** - Print the message to the clients and do the normal functions. - */ - for (new i = 1; i <= MaxClients; i++) - { - if(IsClientConnected(i) && IsClientInGame(i)) - { - PrintToChat(i,"\x01\x05%s", sMsg); - PrintToConsole(i,"%s has connected.", sClientName); - } - } - LogToGame("\"%s<%d><%s><>\" entered the game", sClientName, iUserId, sAuthID); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public HookPlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled && g_bIsUberChargeEnabled) - { - - /** - Get the event variables and check the class for medic - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - if (TF2_GetPlayerClass(iClient) == TFClass_Medic) - { - - /** - Start a timer to get the medic the uber boost - */ - CreateTimer(0.25, Timer_PlayerUberDelay, iClient, TIMER_FLAG_NO_MAPCHANGE); - } - } -} - -public HookPlayerClass(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled && g_bIsUberChargeEnabled) - { - - /** - Get the event variables and check the class for medic - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - if (TF2_GetPlayerClass(iClient) == TFClass_Medic) - { - - /** - Start a timer to get the medic the uber boost - */ - CreateTimer(0.25, Timer_PlayerUberDelay, iClient, TIMER_FLAG_NO_MAPCHANGE); - } - } -} - -public HookPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled || g_bIsSwapTeamEnabled) - { - - /** - Get the event variables - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - new String:sWeapon[256]; - GetEventString(event, "weapon", sWeapon, sizeof(sWeapon)); - - /** - Bug out if world killed him. Means he changed team or something - */ - if (StrEqual(sWeapon, "world", false)) - { - g_aPlayers[iClient][bQueue] = false; - return; - } - - /** - If he is queued up, swap him - */ - if (g_aPlayers[iClient][bQueue]) - { - SM_MovePlayer(iClient, g_aPlayers[iClient][iNewTeam]); - } - } -} - -public HookPlayerChangeTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled || g_bIsSwapTeamEnabled) - { - - /** - Get the event variables - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - - /** - If he is queued up, clear the status - */ - if (g_aPlayers[iClient][bQueue]) - { - g_aPlayers[iClient][bQueue] = false; - } - } -} - -public HookRoundStart(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Set our variables. - */ - g_bRoundEnd = false; - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled && g_bIsImmuntyEnabled) - { - - /** - Get rid of their immunity. - */ - ProcessRoundEndImmunity(false); - } -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Set our variables. - */ - g_bRoundEnd = true; - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled && g_bIsImmuntyEnabled) - { - - /** - Give them their immunity. - */ - ProcessRoundEndImmunity(true); - } -} - -public Action:Timer_DonatorJoined(Handle:timer, any:client) -{ - - /** - Make sure sounds are enabled. - */ - if (g_bIsEnabled && g_bIsJoinSoundEnabled) - { - EmitSoundToClient(client, g_sSoundFile); - } - - /** - Make sure private messages are enabled. - */ - if (g_bIsJoinPrivMsgEnabled) - { - - /** - Send messages to the client. - */ - decl String:sMsg[1024]; - Format(sMsg, sizeof(sMsg), "%T", "PrivateJoinMessage", LANG_SERVER); - PrintToChat(client,"\x01\x05%s", sMsg); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Timer_PlayerUberDelay(Handle:timer, any:client) -{ - - /** - Make sure the client is still in game. - */ - if (IsClientInGame(client)) - { - - /** - Make sure the client is still a medic. - */ - if (TF2_GetPlayerClass(client) == TFClass_Medic) - { - - /** - Get the medgun weapon index - */ - new iIndex = GetPlayerWeaponSlot(client, 1); - if (iIndex > 0) - { - - /** - Set the uber level with the bonus. - */ - SetEntPropFloat(iIndex, Prop_Send, "m_flChargeLevel", g_fUberLevel); - } - } - } -} - -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (convar == sdb_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsEnabled = false; - } - else - { - g_bIsEnabled = true; - } - } - else if (convar == sdb_donationflag) - { - Format(g_sCharDonatorFlag, sizeof(g_sCharDonatorFlag), "%s", newValue); - } - else if (convar == sdb_soundfile) - { - Format(g_sSoundFile, sizeof(g_sSoundFile), "%s", newValue); - } - else if (convar == sdb_joinsound_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsJoinSoundEnabled = false; - } - else - { - g_bIsJoinSoundEnabled = true; - } - } - else if (convar == sdb_joinpubmsg_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsJoinPubMsgEnabled = false; - } - else - { - g_bIsJoinPubMsgEnabled = true; - } - } - else if (convar == sdb_joinprivmsg_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsJoinPrivMsgEnabled = false; - } - else - { - g_bIsJoinPrivMsgEnabled = true; - } - } - else if (convar == sdb_chatcolors_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsChatColorsEnabled = false; - } - else - { - g_bIsChatColorsEnabled = true; - } - } - else if (convar == sdb_immunity_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsImmuntyEnabled = false; - } - else - { - g_bIsImmuntyEnabled = true; - } - } - else if (convar == sdb_ubercharge_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsUberChargeEnabled = false; - } - else - { - g_bIsUberChargeEnabled = true; - } - } - else if (convar == sdb_givehealth_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsGiveHealthEnabled = false; - } - else - { - g_bIsGiveHealthEnabled = true; - } - } - else if (convar == sdb_nofalldmg_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsNoFallDmgEnabled = false; - } - else - { - g_bIsNoFallDmgEnabled = true; - } - } - else if (convar == sdb_fastheavy_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsFastHeayEnabled = false; - } - else - { - g_bIsFastHeayEnabled = true; - } - } - else if (convar == sdb_swapteam_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsSwapTeamEnabled = false; - } - else - { - g_bIsSwapTeamEnabled = true; - } - } - else if (convar == sdb_chatcolor) - { - Format(g_sChatColor, sizeof(g_sChatColor), "%s", newValue); - } - else if (convar == sdb_uberlevel) - { - g_fUberLevel = StringToFloat(newValue); - } - else if (convar == sdb_healthcount) - { - g_iHealthCount = StringToInt(newValue); - } - else if (convar == sdb_healthbonus) - { - g_iHealthBonus = StringToInt(newValue); - } - else if (convar == sdb_heavymultiplier) - { - g_fHeavyMultiplier = StringToFloat(newValue); - } -} - -stock LoadUpVariables() -{ - g_bIsEnabled = GetConVarBool(sdb_enabled); - g_bIsJoinSoundEnabled = GetConVarBool(sdb_enabled); - g_bIsJoinPubMsgEnabled = GetConVarBool(sdb_enabled); - g_bIsJoinPrivMsgEnabled = GetConVarBool(sdb_enabled); - g_bIsChatColorsEnabled = GetConVarBool(sdb_enabled); - g_bIsImmuntyEnabled = GetConVarBool(sdb_enabled); - g_bIsUberChargeEnabled = GetConVarBool(sdb_enabled); - g_bIsGiveHealthEnabled = GetConVarBool(sdb_enabled); - g_bIsNoFallDmgEnabled = GetConVarBool(sdb_enabled); - g_bIsFastHeayEnabled = GetConVarBool(sdb_enabled); - g_bIsSwapTeamEnabled = GetConVarBool(sdb_enabled); - GetConVarString(sdb_donationflag, g_sCharDonatorFlag, sizeof(g_sCharDonatorFlag)); - GetConVarString(sdb_soundfile, g_sSoundFile, sizeof(g_sSoundFile)); - GetConVarString(sdb_chatcolor, g_sChatColor, sizeof(g_sChatColor)); - g_bRoundEnd = false; - g_iHealthBonus = GetConVarInt(sdb_healthbonus); - g_iHealthCount = GetConVarInt(sdb_healthcount); - g_fHeavyMultiplier = GetConVarFloat(sdb_heavymultiplier); - g_fUberLevel = GetConVarFloat(sdb_uberlevel); -} - -stock PrepSoundFile() -{ - decl String:buffer[PLATFORM_MAX_PATH]; - PrecacheSound(g_sSoundFile, true); - Format(buffer, sizeof(buffer), "sound/%s", g_sSoundFile); - AddFileToDownloadsTable(buffer); -} - -stock CleanUpPlayer(client) -{ - g_aPlayers[client][bIsDonator] = false; - g_aPlayers[client][bQueue] = false; - g_aPlayers[client][bImmune] = false; - g_aPlayers[client][iNewTeam] = 0; - g_aPlayers[client][iHealthCount] = 0; -} - -stock ProcessRoundEndImmunity(bool:give) -{ - for (new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][bIsDonator]) - { - if (give) - { - SetEntProp(i, Prop_Data, "m_takedamage", 0, 1); - g_aPlayers[i][bImmune] = true; - } - else - { - SetEntProp(i, Prop_Data, "m_takedamage", 2, 1); - g_aPlayers[i][bImmune] = false; - } - } - } -} - -stock FormatMessage(iClient, iTeam, bool:bAlive, String:sChatMsg[], const Sting:sMessage[]) -{ - decl String:sDead[10], - String:sTeam[10], - String:sClientName[64]; - GetClientName(iClient, sClientName, sizeof(sClientName)); - if (iTeam != 0) - Format(sTeam, sizeof(sTeam), "(TEAM) "); - else - Format(sTeam, sizeof(sTeam), ""); - if (bAlive) - Format(sDead, sizeof(sDead), ""); - else - Format(sDead, sizeof(sDead), "*DEAD* "); - if (StrContains(g_sChatColor, "light", false) == -1) - Format(sChatMsg, CHAT_MAX_MESSAGE_LENGTH, "\x01%s%s\x03%s \x01: \x05%s", sDead, sTeam, sClientName, sMessage); - else - Format(sChatMsg, CHAT_MAX_MESSAGE_LENGTH, "\x01%s%s\x03%s \x01: \x04%s", sDead, sTeam, sClientName, sMessage); -} - -stock SayText2(target, author, const String:message[]) -{ - new Handle:hBf; - if (target == 0) - hBf = StartMessageAll("SayText2"); - else - hBf = StartMessageOne("SayText2", target); - if (hBf != INVALID_HANDLE) - { - BfWriteByte(hBf, author); - BfWriteByte(hBf, true); - BfWriteString(hBf, message); - EndMessage(); - } -} - -stock ProcessAdmins() -{ - for (new i = 1; i <= MaxClients; i++) - { - if (SM_IsValidAdmin(i, g_sCharDonatorFlag)) - { - g_aPlayers[i][bDonator] = true; - } - else - { - g_aPlayers[i][bDonator] = false; - } - } -} - -stock ProcessLate() -{ - if (g_bIsEnabled) - { - ProcessAdmins(); - PrepSoundFile(); - if (g_bRoundEnd && g_bIsImmuntyEnabled) - { - ProcessRoundEndImmunity(true); - } - if (!g_bIsImmuntyEnabled) - { - ProcessRoundEndImmunity(false); - } - } - else - { - ProcessRoundEndImmunity(false); - } -} - -public Menu_SwapMode(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, 64); - if (StringToInt(sSelection)) - g_aPlayers[param1][bQueue] = false; - else - g_aPlayers[param1][bQueue] = true; - if (!g_aPlayers[param1][bQueue]) - SM_MovePlayer(param1, g_aPlayers[param1][iNewTeam]); - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -public Menu_SelectPlayer(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[256]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - new iTarget = GetClientOfUserId(StringToInt(sSelection)); - if (g_aPlayers[iTarget][bIsDonator]) - g_aPlayers[iTarget][bIsDonator] = false; - else - g_aPlayers[iTarget][bIsDonator] = true; - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -stock Handle:BuildSwapModeMenu() -{ - new Handle:menu = CreateMenu(Menu_SwapMode); - SetMenuTitle(menu, "Select When to Swap:"); - AddMenuItem(menu, "0", "Instantly (Kills)"); - AddMenuItem(menu, "1", "Queue on next death"); - SetMenuExitBackButton(menu, false); - return menu; -} - -stock Handle:BuildPlayerMenu() -{ - new Handle:menu = CreateMenu(Menu_SelectPlayer); - AddTargetsToMenu(menu, 0, true, false); - SetMenuTitle(menu, "Select A Player:"); - SetMenuExitBackButton(menu, true); - return menu; -} - -public Action:Command_TEST(client, args) -{ - -} \ No newline at end of file diff --git a/Simple Team Manager/addons/sourcemod/scripting/simple-messagesuppression.sp b/Simple Team Manager/addons/sourcemod/scripting/simple-messagesuppression.sp deleted file mode 100644 index f7725a4..0000000 --- a/Simple Team Manager/addons/sourcemod/scripting/simple-messagesuppression.sp +++ /dev/null @@ -1,227 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Message Suppression -Description: - Blocks Specific Message Outputs -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include -#include - -#define SUPPRESS_VERSION "1.1.$Rev$" - -public Plugin:myinfo = -{ - name = "Simple Message Suppression", - author = "FlyingMongoose, psychonic", - description = "Blocks Specific Message Outputs", - version = SUPPRESS_VERSION, - url = "http://www.simple-plugins.com/" -} - -new Handle:cvarBlockSpectateMessage; -new Handle:cvarBlockDisconnectMessage; -new Handle:cvarBlockConnectMessage; -new Handle:cvarAdminShowMessages; -new iSpecTeam = 1; - - -public OnPluginStart() -{ - CreateConVar("suppress_version", SUPPRESS_VERSION, _, FCVAR_PLUGIN|FCVAR_NOTIFY|FCVAR_REPLICATED|FCVAR_SPONLY|FCVAR_DONTRECORD); - cvarBlockSpectateMessage = CreateConVar("sm_blockspectatemessage", "1", "If enabled it blocks the join team message if an administrator joins spectator", FCVAR_PLUGIN, true, 0.0, true, 1.0); - cvarBlockDisconnectMessage = CreateConVar("sm_blockdisconnectmessage", "1", "Blocks the disconnect message", FCVAR_PLUGIN, true, 0.0, true, 1.0); - cvarBlockConnectMessage = CreateConVar("sm_blockconnectmessage", "1", "If enabled it blocks the player connection message.", FCVAR_PLUGIN, true, 0.0, true, 1.0); - cvarAdminShowMessages = CreateConVar("sm_adminshowmessages", "1", "Shows disconnect/connect/team join messages for admins only (if disconnect message is set to be blocked)", FCVAR_PLUGIN, true, 0.0, true, 1.0); - HookEvent("player_team", ev_PlayerTeam, EventHookMode_Pre); - HookEvent("player_disconnect", ev_PlayerDisconnect, EventHookMode_Pre); - HookEvent("player_connect", ev_PlayerConnect, EventHookMode_Pre); - - new String:game_folder[64]; - GetGameFolderName(game_folder, sizeof(game_folder)) - - if (StrContains(game_folder, "insurgency", false) != -1) - { - iSpecTeam = 3; - } - else - { - new String:game_description[64]; - GetGameDescription(game_description, sizeof(game_description), true); - if (StrContains(game_description, "Insurgency", false) != -1) - { - iSpecTeam = 3; - } - } - - AutoExecConfig(true, "suppressmessage", "sourcemod"); -} - -public Action:ev_PlayerTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - if (GetConVarBool(cvarBlockSpectateMessage)) - { - if (!dontBroadcast && !GetEventBool(event, "silent")) - { - new iUserId = GetEventInt(event, "userid"); - new iClient = GetClientOfUserId(iUserId); - new iTeam = GetEventInt(event, "team"); - - if (iTeam == iSpecTeam && GetAdminFlag(GetUserAdmin(iClient), Admin_Kick)) - { - new iOldTeam = GetEventInt(event, "oldteam"); - new bool:bDisconnect = GetEventBool(event, "disconnect"); - new bool:bAutoteam = GetEventBool(event, "autoteam"); - decl String:strName[50]; - GetEventString(event, "name", strName, sizeof(strName)); - - if (iClient != 0) - { - if (GetConVarInt(cvarAdminShowMessages) == 1) - { - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientConnected(i) && IsClientInGame(i) && GetUserAdmin(i) != INVALID_ADMIN_ID) - { - PrintToChat(i,"%N joined team Spectator.", iClient); - PrintToConsole(i,"%N joined team Spectator.", iClient); - } - } - } - } - - new Handle:hEvent = CreateEvent("player_team"); - SetEventInt(hEvent, "userid", iUserId); - SetEventInt(hEvent, "team", iTeam); - SetEventInt(hEvent, "oldteam", iOldTeam); - SetEventBool(hEvent, "disconnect", bDisconnect); - SetEventBool(hEvent, "autoteam", bAutoteam); - SetEventBool(hEvent, "silent", true); - SetEventString(hEvent, "name", strName); - - FireEvent(hEvent, true); - - return Plugin_Handled; - } - } - } - return Plugin_Continue; -} -public Action:ev_PlayerConnect(Handle:event, const String:name[], bool:dontBroadcast) -{ - if (GetConVarBool(cvarBlockConnectMessage)) - { - if (!dontBroadcast) - { - decl String:strName[50]; - GetEventString(event, "name", strName, sizeof(strName)); - new iIndex = GetEventInt(event, "index"); - new iUserId = GetEventInt(event, "userid"); - new iClient = GetClientOfUserId(iUserId); - decl String:strNetworkId[50]; - GetEventString(event, "networkid", strNetworkId, sizeof(strNetworkId)); - decl String:strAddress[50]; - GetEventString(event, "address", strAddress, sizeof(strAddress)); - - if (iClient != 0) - { - if (GetConVarInt(cvarAdminShowMessages) == 1) - { - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientConnected(i) && IsClientInGame(i) && GetUserAdmin(i) != INVALID_ADMIN_ID) - { - PrintToChat(i,"%N has connected.", iClient); - PrintToConsole(i,"%N has connected.", iClient); - } - } - } - } - - new Handle:hEvent = CreateEvent("player_connect"); - SetEventString(hEvent, "name", strName); - SetEventInt(hEvent, "index", iIndex); - SetEventInt(hEvent, "userid", iUserId); - SetEventString(hEvent, "networkid", strNetworkId); - SetEventString(hEvent, "address", strAddress); - - FireEvent(hEvent, true); - - return Plugin_Handled; - } - } - return Plugin_Continue; -} -public Action:ev_PlayerDisconnect(Handle:event, const String:name[], bool:dontBroadcast) -{ - if (GetConVarBool(cvarBlockDisconnectMessage)) - { - if (!dontBroadcast) - { - new iUserId = GetEventInt(event, "userid"); - new iClient = GetClientOfUserId(iUserId); - decl String:strReason[50]; - GetEventString(event, "reason", strReason, sizeof(strReason)); - decl String:strName[50]; - GetEventString(event, "name", strName, sizeof(strName)); - decl String:strNetworkId[50]; - GetEventString(event, "networkid", strNetworkId, sizeof(strNetworkId)); - - if (iClient != 0) - { - if (GetConVarInt(cvarAdminShowMessages) == 1) - { - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientConnected(i) && IsClientInGame(i) && GetUserAdmin(i) != INVALID_ADMIN_ID) - { - PrintToChat(i, "%N has left the server.", iClient); - PrintToConsole(i, "Dropped %N from server (Disconnect by user.)", iClient); - } - } - } - } - - new Handle:hEvent = CreateEvent("player_disconnect"); - SetEventInt(hEvent, "userid", iUserId); - SetEventString(hEvent, "reason", strReason); - SetEventString(hEvent, "name", strName); - SetEventString(hEvent, "networkid", strNetworkId); - - FireEvent(hEvent, true); - - return Plugin_Handled; - } - } - - return Plugin_Continue; -} \ No newline at end of file diff --git a/Simple Team Manager/addons/sourcemod/scripting/simple-plugins.sp b/Simple Team Manager/addons/sourcemod/scripting/simple-plugins.sp deleted file mode 100644 index 4462b41..0000000 --- a/Simple Team Manager/addons/sourcemod/scripting/simple-plugins.sp +++ /dev/null @@ -1,785 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Plugins -Description: - Core plugin for Simple Plugins project -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#define CORE_PLUGIN_VERSION "1.1.$Rev$" - -#include - -enum e_PlayerInfo -{ - Handle:hForcedTeamPlugin = INVALID_HANDLE, - iForcedTeam = 0, - iBuddy = 0, - bool:bBuddyLocked = false -}; - -new Handle:g_fwdPlayerMoved; -new g_aPlayers[MAXPLAYERS + 1][e_PlayerInfo]; -new bool:g_bTeamsSwitched = false; - -/** -Setting our plugin information. -*/ -public Plugin:myinfo = -{ - name = "Simple Plugins Core Plugin", - author = "Simple Plugins", - description = "Core plugin for Simple Plugins", - version = CORE_PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -}; - -public bool:AskPluginLoad(Handle:myself, bool:late, String:error[], err_max) -{ - - /** - Register natives for other plugins - */ - CreateNative("SM_MovePlayer", Native_SM_MovePlayer); - CreateNative("SM_SetForcedTeam", Native_SM_SetForcedTeam); - CreateNative("SM_GetForcedTeam", Native_SM_GetForcedTeam); - CreateNative("SM_ClearForcedTeam", Native_SM_ClearForcedTeam); - CreateNative("SM_GetForcedPlayer", Native_SM_GetForcedPlayer); - CreateNative("SM_AssignBuddy", Native_SM_AssignBuddy); - CreateNative("SM_GetClientBuddy", Native_SM_GetClientBuddy); - CreateNative("SM_LockBuddy", Native_SM_LockBuddy); - CreateNative("SM_IsBuddyLocked", Native_SM_IsBuddyLocked); - CreateNative("SM_ClearBuddy", Native_SM_ClearBuddy); - CreateNative("SM_IsValidAdmin", Native_SM_IsValidAdmin); - CreateNative("SM_IsValidTeam", Native_SM_IsValidTeam); - RegPluginLibrary("simpleplugins"); - return true; -} - -public OnPluginStart() -{ - - CreateConVar("ssm_core_pl_ver", CORE_PLUGIN_VERSION, "Simple SourceMod Plugins Core Plugin Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - CreateConVar("ssm_core_inc_ver", CORE_INC_VERSION, "Simple SourceMod Plugins Core Include Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook some events to control forced players and check extensions - */ - decl String:sExtError[256]; - LogAction(0, -1, "[SSM] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_team", HookPlayerChangeTeam, EventHookMode_Pre); - switch (g_CurrentMod) - { - case GameType_CSS: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - new iExtStatus = GetExtensionFileStatus("game.cstrike.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SSM] Required extension was not found."); - LogAction(0, -1, "[SSM] Plugin FAILED TO LOAD."); - SetFailState("Required extension was not found."); - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SSM] Required extension is loaded with errors."); - LogAction(0, -1, "[SSM] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SSM] Plugin FAILED TO LOAD."); - SetFailState("Required extension is loaded with errors."); - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SSM] Required extension is loaded."); - } - } - case GameType_TF: - { - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_PostNoCopy); - HookUserMessage(GetUserMessageId("TextMsg"), UserMessageHook_Class, true); - new iExtStatus = GetExtensionFileStatus("game.tf2.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SSM] Required extension was not found."); - LogAction(0, -1, "[SSM] Plugin FAILED TO LOAD."); - SetFailState("Required extension was not found."); - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SSM] Required extension is loaded with errors."); - LogAction(0, -1, "[SSM] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SSM] Plugin FAILED TO LOAD."); - SetFailState("Required extension is loaded with errors."); - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SSM] Required extension is loaded."); - } - } - case GameType_DOD: - { - HookEvent("dod_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_PostNoCopy); - } - default: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - } - } - - /** - Load common translations - */ - LoadTranslations ("common.phrases"); - - /** - Create the global forward - */ - g_fwdPlayerMoved = CreateGlobalForward("SM_OnPlayerMoved", ET_Event, Param_Cell, Param_Cell, Param_Cell); -} - -public OnClientDisconnect(client) -{ - - /** - Cleanup clients/players buddy list - */ - if (!IsFakeClient(client)) - { - SM_ClearBuddy(client, true); - SM_LockBuddy(client, false); - } - SM_ClearForcedTeam(client); -} - -public HookRoundStart(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - See if the teams have been switched - */ - if (g_bTeamsSwitched) - { - - /** - Switch the teams the players are forced to - */ - for (new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][iForcedTeam] != 0) - { - if (g_aPlayers[i][iForcedTeam] == g_aCurrentTeams[Team1]) - { - g_aPlayers[i][iForcedTeam] = g_aCurrentTeams[Team2]; - } - else - { - g_aPlayers[i][iForcedTeam] = g_aCurrentTeams[Team1]; - } - } - } - } -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - g_bTeamsSwitched = false; -} - -public HookPlayerChangeTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get our event variables - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - new iTeam = GetEventInt(event, "team"); - - /** - See if the player is on the wrong team - */ - if (g_aPlayers[iClient][iForcedTeam] != 0 && g_aPlayers[iClient][iForcedTeam] != iTeam) - { - - /** - Move the player back to the forced team - */ - CreateTimer(1.0, Timer_ForcePlayerMove, iClient, TIMER_FLAG_NO_MAPCHANGE); - - /** - If the event was going to be broadcasted, we refire it so it is not broadcasted and stop this one - */ - if (!dontBroadcast) - { - new Handle:hEvent = CreateEvent("player_team"); - SetEventInt(hEvent, "userid", GetEventInt(event, "userid")); - SetEventInt(hEvent, "team", GetEventInt(event, "team")); - SetEventInt(hEvent, "oldteam", GetEventInt(event, "oldteam")); - SetEventBool(hEvent, "disconnect", GetEventBool(event, "disconnect")); - - if (g_CurrentMod == GameType_DOD || g_CurrentMod == GameType_L4D || g_CurrentMod == GameType_TF) - { - new String:sClientName[MAX_NAME_LENGTH + 1]; - GetClientName(client, sClientName, sizeof(sClientName)); - SetEventBool(hEvent, "autoteam", GetEventBool(event, "autoteam")); - SetEventBool(hEvent, "silent", true); - SetEventString(hEvent, "name", sClientName); - FireEvent(hEvent, true); - } - else - { - FireEvent(hEvent, true); - } - return Plugin_Handled; - } - } - return Plugin_Continue; -} - -public Action:UserMessageHook_Class(UserMsg:msg_id, Handle:bf, const players[], playersNum, bool:reliable, bool:init) -{ - new String:sMessage[120]; - BfReadString(bf, sMessage, sizeof(sMessage), true); - if (StrContains(sMessage, "#TF_TeamsSwitched", false) != -1) - { - g_bTeamsSwitched = true; - } - return Plugin_Continue; -} - -public Native_SM_MovePlayer(Handle:plugin, numParams) -{ - - /** - Get and check the client and team - */ - new iClient = GetNativeCell(1); - new iTeam = GetNativeCell(2); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (iTeam != g_aCurrentTeams[Spectator] && iTeam != g_aCurrentTeams[Team1] && iTeam != g_aCurrentTeams[Team2]) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid team %d", iTeam); - } - - MovePlayer(iClient, iTeam); - if (!IsClientObserver(iClient)) - { - RespawnPlayer(iClient); - } - - new fResult; - - Call_StartForward(g_fwdPlayerMoved); - Call_PushCell(plugin); - Call_PushCell(iClient); - Call_PushCell(iTeam); - Call_Finish(fResult); - - if (fResult != SP_ERROR_NONE) - { - return ThrowNativeError(fResult, "Forward failed"); - } - - return fResult; -} - -public Native_SM_SetForcedTeam(Handle:plugin, numParams) -{ - - /** - Get and check the client and team - */ - new iClient = GetNativeCell(1); - new iTeam = GetNativeCell(2); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (iTeam != g_aCurrentTeams[Spectator] && iTeam != g_aCurrentTeams[Team1] && iTeam != g_aCurrentTeams[Team2] && iTeam != g_aCurrentTeams[Unknown]) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid team %d", iTeam); - } - - new bool:bOverRide = GetNativeCell(3) ? true : false; - - if (!bOverRide && g_aPlayers[iClient][hForcedTeamPlugin] != INVALID_HANDLE && plugin != g_aPlayers[iClient][hForcedTeamPlugin]) - { - return false; - } - - g_aPlayers[iClient][hForcedTeamPlugin] = plugin; - g_aPlayers[iClient][iForcedTeam] = iTeam; - return true; -} - -public Native_SM_GetForcedTeam(Handle:plugin, numParams) -{ - - /** - Get and check the client - */ - new iClient = GetNativeCell(1); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - - /** - Get and set the plugin if they want it - */ - new Handle:hPlugin = GetNativeCell(2); - if (hPlugin != INVALID_HANDLE) - { - SetNativeCellRef(2, g_aPlayers[iClient][hForcedTeamPlugin]); - } - - /** - Return the forced team, this could be 0 - */ - return g_aPlayers[iClient][iForcedTeam]; -} - -public Native_SM_ClearForcedTeam(Handle:plugin, numParams) -{ - - /** - Get and check the client and team - */ - new iClient = GetNativeCell(1); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - - g_aPlayers[iClient][hForcedTeamPlugin] = INVALID_HANDLE; - g_aPlayers[iClient][iForcedTeam] = 0; - - return true; -} - -public Native_SM_GetForcedPlayer(Handle:plugin, numParams) -{ - - /** - Get and check the team - */ - new iTeam = GetNativeCell(1); - if (iTeam != g_aCurrentTeams[Spectator] && iTeam != g_aCurrentTeams[Team1] && iTeam != g_aCurrentTeams[Team2]) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid team %d", iTeam); - } - - /** - Start a loop to check for a player on the wrong team - Also make sure the plugin that set the forced team is the plugin that asked - */ - new iPlayer = 0; - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientInGame(i) - && GetClientTeam(i) != g_aPlayers[i][iForcedTeam] - && g_aPlayers[i][iForcedTeam] == iTeam - && g_aPlayers[i][hForcedTeamPlugin] == plugin) - { - iPlayer = i; - break; - } - } - - /** - Return the player we found, this could be 0 - */ - return iPlayer; -} - -public Native_SM_AssignBuddy(Handle:plugin, numParams) -{ - - /** - Get and check the client and player - */ - new iClient = GetNativeCell(1); - new iPlayer = GetNativeCell(2); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (iPlayer < 0 || iPlayer > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid player index (%d)", iPlayer); - } - if (!IsClientConnected(iPlayer)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Player %d is not connected", iPlayer); - } - if (!IsClientInGame(iPlayer)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Player %d is not in the game", iClient); - } - if (IsFakeClient(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Bots are not supported"); - } - - /** - See if we can override his setting - */ - new bool:bOverRide = GetNativeCell(3) ? true : false; - if (!bOverRide) - { - - /** - We can't override, so check if they are locked - */ - if (g_aPlayers[iClient][bBuddyLocked] || g_aPlayers[iPlayer][bBuddyLocked]) - { - - /** - We detected at least 1 lock, so we bug out - */ - return false; - } - } - - /** - Ready to set the buddies - */ - g_aPlayers[iClient][iBuddy] = iPlayer; - g_aPlayers[iPlayer][iBuddy] = iClient; - return true; -} - -public Native_SM_GetClientBuddy(Handle:plugin, numParams) -{ - - /** - Get and check the client - */ - new iClient = GetNativeCell(1); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (IsFakeClient(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Bots are not supported"); - } - - /** - Return the players buddy, this could be 0 - */ - return g_aPlayers[iClient][iBuddy]; -} - -public Native_SM_LockBuddy(Handle:plugin, numParams) -{ - - /** - Get and check the client - */ - new iClient = GetNativeCell(1); - new bool:bSetting = GetNativeCell(2) ? true : false; - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (IsFakeClient(iClient)) - { - return ThrowNativeError(SP_ERROR_NATIVE, "Bots are not supported"); - } - - g_aPlayers[iClient][bBuddyLocked] = bSetting; - return true; -} - -public Native_SM_IsBuddyLocked(Handle:plugin, numParams) -{ - - /** - Get and check the client - */ - new iClient = GetNativeCell(1); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (IsFakeClient(iClient)) - { - return ThrowNativeError(SP_ERROR_NATIVE, "Bots are not supported"); - } - - return g_aPlayers[iClient][bBuddyLocked]; -} - -public Native_SM_ClearBuddy(Handle:plugin, numParams) -{ - - /** - Get and check the client - */ - new iClient = GetNativeCell(1); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_NATIVE, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_NATIVE, "Client (%d) is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (IsFakeClient(iClient)) - { - return ThrowNativeError(SP_ERROR_NATIVE, "Bots are not supported"); - } - - /** - Get the clients buddy and see if we can override his setting - */ - new bool:bOverRide = GetNativeCell(2) ? true : false; - new iPlayer = g_aPlayers[iClient][iBuddy]; - - /** - There is no buddy, we don't care about anything else so bug out - */ - if (iPlayer == 0) - { - return true; - } - - /** - We determined he had a buddy, check the override setting - */ - if (!bOverRide) - { - - /** - We can't override, so check if they are locked - */ - if (g_aPlayers[iClient][bBuddyLocked] || g_aPlayers[iPlayer][bBuddyLocked]) - { - - /** - We detected at least 1 lock, so we bug out - */ - return false; - } - } - - /** - Ready to clear the buddies - */ - g_aPlayers[iClient][iBuddy] = 0; - g_aPlayers[iPlayer][iBuddy] = 0; - return true; -} - -public Native_SM_IsValidTeam(Handle:plugin, numParams) -{ - - /** - Get the team - */ - new iTeam = GetNativeCell(1); - - /** - Check the team - */ - if (iTeam == g_aCurrentTeams[Spectator] || iTeam == g_aCurrentTeams[Team1] || iTeam == g_aCurrentTeams[Team2]) - { - return true; - } - return false; -} - -public Native_SM_IsValidAdmin(Handle:plugin, numParams) -{ - /** - Get the client and flags - */ - new iClient = GetNativeCell(1); - decl String:sFlags[15]; - GetNativeString(2, sFlags, sizeof(sFlags)); - new ibFlags = ReadFlagString(sFlags); - - /** - Check the flags - */ - if ((GetUserFlagBits(iClient) & ibFlags) == ibFlags) - { - return true; - } - if (GetUserFlagBits(iClient) & ADMFLAG_ROOT) - { - return true; - } - return false; -} - -public Action:Timer_ForcePlayerMove(Handle:timer, any:iClient) -{ - - MovePlayer(iClient, g_aPlayers[iClient][iForcedTeam]); - - if (g_aPlayers[iClient][iForcedTeam] != g_aCurrentTeams[Spectator]) - { - RespawnPlayer(iClient); - } - - PrintToChat(iClient, "\x01\x04----------------------------------"); - PrintToChat(iClient, "\x01\x04You have been forced to this team."); - PrintToChat(iClient, "\x01\x04----------------------------------"); - - return Plugin_Handled; -} - -stock MovePlayer(iClient, iTeam) -{ - - /** - Change the client's team based on the mod - */ - switch (g_CurrentMod) - { - case GameType_CSS: - { - CS_SwitchTeam(iClient, iTeam); - } - default: - { - ChangeClientTeam(iClient, iTeam); - } - } -} - -stock RespawnPlayer(iClient) -{ - - /** - Respawn the client based on the mod - */ - switch (g_CurrentMod) - { - case GameType_CSS: - { - CS_RespawnPlayer(iClient); - } - case GameType_TF: - { - TF2_RespawnPlayer(iClient); - } - case GameType_INS: - { - FakeClientCommand(iClient, "kill"); - } - default: - { - // - } - } -} diff --git a/Simple Team Manager/addons/sourcemod/scripting/simple-roundimmunity.sp b/Simple Team Manager/addons/sourcemod/scripting/simple-roundimmunity.sp deleted file mode 100644 index 5f0bca3..0000000 --- a/Simple Team Manager/addons/sourcemod/scripting/simple-roundimmunity.sp +++ /dev/null @@ -1,947 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Round Immunity -Description: - Gives admins immunity during certain rounds -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or any later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#pragma semicolon 1 -#include -#include -#undef REQUIRE_EXTENSIONS -#undef AUTOLOAD_EXTENSIONS -#include -#include -#define REQUIRE_EXTENSIONS -#define AUTOLOAD_EXTENSIONS - -#define PLUGIN_VERSION "1.1.$Rev$" -#define SPECTATOR 1 -#define TEAM_RED 2 -#define TEAM_BLUE 3 - -#define COLOR_GREEN 0 -#define COLOR_BLACK 1 -#define COLOR_RED 2 -#define COLOR_BLUE 3 -#define COLOR_TEAM 4 -#define COLOR_RAINBOW 5 -#define COLOR_NONE 6 - -#define PLAYERCOND_SLOWED (1<<0) //1 -#define PLAYERCOND_ZOOMED (1<<1) //2 -#define PLAYERCOND_DISGUISING (1<<2) //4 -#define PLAYERCOND_DISGUISED (1<<3) //8 -#define PLAYERCOND_SPYCLOAK (1<<4) //16 -#define PLAYERCOND_UBERED (1<<5) //32 -#define PLAYERCOND_TELEPORTTRAIL (1<<6) //64 -#define PLAYERCOND_TAUNT (1<<7) //128 -// (1<<8) //256 -// (1<<9) //512 -#define PLAYERCOND_TELEPORTFLASH (1<<10) //1024 -#define PLAYERCOND_KRUBER (1<<11) //2048 -// (1<<12) //4096 -// (1<<13) //8192 -#define PLAYERCOND_BONKED (1<<14) //16384 (blame Neph if it doesn't work) -#define PLAYERCOND_BONKEDORDRINKSLOWDOWN (1<<15) //32768 -#define PLAYERCOND_HEALING (1<<16) //65536 -#define PLAYERCOND_BURNING (1<<17) //131072 -#define PLAYERCOND_FULLYCHARGEDBYMEDIC (1<<18) //262144 - -enum e_Cookies -{ - bEnabled, - iColor, - iMode -}; - -enum e_ColorNames -{ - Green, - Black, - Red, - Blue -}; - -enum e_ColorValues -{ - iRed, - iGreen, - iBlue -}; - -enum e_PlayerData -{ - Handle:hGodModeTimer, - Handle:hColorTimer, - bool:bIsAdmin, - bool:bIsImmune, - iCycleColor -}; - -/** - Global convar handles - */ -new Handle:sri_charadminflag = INVALID_HANDLE; -new Handle:sri_enabled = INVALID_HANDLE; -new Handle:sri_cookie_enabled = INVALID_HANDLE; -new Handle:sri_cookie_color = INVALID_HANDLE; -new Handle:sri_cookie_mode = INVALID_HANDLE; - -/** - Player arrays - */ -new g_aPlayers[MAXPLAYERS + 1][e_PlayerData]; -new g_aClientCookies[MAXPLAYERS + 1][e_Cookies]; - -/** - Global bools - */ -new bool:g_bLoadedLate = false; -new bool:g_bIsEnabled = true; -new bool:g_bRoundEnd = false; -new bool:g_bUseDukehacks = false; -new bool:g_bUseClientprefs = false; - -/** - Global strings/integers/floats - */ -new String:g_sCharAdminFlag[32]; -new g_iColors[e_ColorNames][e_ColorValues]; -new g_iClassMaxHealth[TFClassType] = {0, 125, 125, 200, 175, 150, 300, 175, 125, 125}; - -public Plugin:myinfo = -{ - name = "Simple Round Immunity", - author = "Simple Plugins", - description = "Gives admins immunity during certain rounds", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -} - -bool:AskPluginLoad(Handle:myself, bool:late, String:error[], err_max) -{ - g_bLoadedLate = late; - return true; -} - -public OnPluginStart() -{ - - /** - Create console variables - */ - CreateConVar("sri_version", PLUGIN_VERSION, "Simple Round Immunity", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - sri_enabled = CreateConVar("sri_enabled", "1", "Enable/Disable Admin immunity during certain round."); - sri_charadminflag = CreateConVar("sri_charadminflag", "a", "Admin flag to use for immunity (only one). Must be a in char format."); - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook some events and check extensions - */ - decl String:sExtError[256]; - LogAction(0, -1, "[SRI] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_spawn", HookPlayerSpawn, EventHookMode_Post); - HookEvent("player_hurt", HookPlayerHurt, EventHookMode_Pre); - switch (g_CurrentMod) - { - case GameType_CSS: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - new iExtStatus = GetExtensionFileStatus("game.cstrike.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SRI] Required extension was not found."); - LogAction(0, -1, "[SRI] Plugin FAILED TO LOAD."); - SetFailState("Required extension was not found."); - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SRI] Required extension is loaded with errors."); - LogAction(0, -1, "[SRI] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SRI] Plugin FAILED TO LOAD."); - SetFailState("Required extension is loaded with errors."); - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SRI] Required css extension is loaded."); - } - } - case GameType_TF: - { - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_PostNoCopy); - HookUserMessage(GetUserMessageId("TextMsg"), UserMessageHook_Class, true); - new iExtStatus = GetExtensionFileStatus("game.tf2.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SRI] Required extension was not found."); - LogAction(0, -1, "[SRI] Plugin FAILED TO LOAD."); - SetFailState("Required extension was not found."); - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SRI] Required extension is loaded with errors."); - LogAction(0, -1, "[SRI] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SRI] Plugin FAILED TO LOAD."); - SetFailState("Required extension is loaded with errors."); - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SRI] Required tf2 extension is loaded."); - } - iExtStatus = GetExtensionFileStatus("dukehacks.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SRI] Dukehacks extension was not found."); - LogAction(0, -1, "[SRI] Plugin continued to load, but that feature will not be used."); - g_bUseDukehacks = false; - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SRI] Dukehacks extension is loaded with errors."); - LogAction(0, -1, "[SRI] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SRI] Plugin continued to load, but that feature will not be used."); - g_bUseDukehacks = false; - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SRI] Dukehacks extension is loaded and will be used."); - g_bUseDukehacks = true; - dhAddClientHook(CHK_TakeDamage, Hacks_TakeDamageHook); - } - } - case GameType_DOD: - { - HookEvent("dod_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_PostNoCopy); - } - default: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - } - } - /** - Now lets check for client prefs extension - */ - new iExtStatus = GetExtensionFileStatus("clientprefs.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SRI] Client Preferences extension was not found."); - LogAction(0, -1, "[SRI] Plugin continued to load, but that feature will not be used."); - g_bUseClientprefs = false; - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SRI] Client Preferences extension is loaded with errors."); - LogAction(0, -1, "[SRI] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SRI] Plugin continued to load, but that feature will not be used."); - g_bUseClientprefs = false; - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SRI] Client Preferences extension is loaded, checking database."); - if (!SQL_CheckConfig(clientprefs)) - { - LogAction(0, -1, "[SRI] No 'clientprefs' database found. Check your database.cfg file."); - LogAction(0, -1, "[SRI] Plugin continued to load, but Client Preferences will not be used."); - g_bUseClientprefs = false; - } - g_bUseClientprefs = true; - - /** - Deal with client cookies - */ - sri_cookie_enabled = RegClientCookie("bri_client_enabled", "Enable/Disable your immunity during the bonus round.", CookieAccess_Public); - sri_cookie_color = RegClientCookie("bri_client_color", "Color to render when immune.", CookieAccess_Public); - sri_cookie_mode = RegClientCookie("bri_client_mode", "God mode to select", CookieAccess_Public); - SetCookieMenuItem(CookieMenu_TopMenu, sri_cookie_enabled, "Bonus Round Immunity"); - } - - HookConVarChange(sri_enabled, EnabledChanged); - - RegAdminCmd("sm_immunity", Command_Immunity, ADMFLAG_ROOT, "sm_immunity: Gives you immunity"); - - LoadColors(); - - AutoExecConfig(true, "plugin.simpleroundimmunity"); -} - -public OnAllPluginsLoaded() -{ - //something - // need to deal with the unloading of dukehacks, clientprefs, and simpleplugins - // should move hooking the client prefs cookies to a function to make sure they are done post plugin start if ext is loaded late -} - -public OnLibraryRemoved(const String:name[]) -{ - //something - // need to deal with the loading of dukehacks, clientprefs, and simpleplugins -} - -public OnConfigsExecuted() -{ - GetConVarString(sri_charadminflag, g_sCharAdminFlag, sizeof(g_sCharAdminFlag)); - g_bIsEnabled = GetConVarBool(sri_enabled); - g_bRoundEnd = false; -} - -/** - Client events - */ - -public OnClientPostAdminCheck(client) -{ - if (SM_IsValidAdmin(client, g_sCharAdminFlag)) - g_aPlayers[client][bIsAdmin] = true; - else - g_aPlayers[client][bIsAdmin] = false; -} - -public OnClientCookiesCached(client) -{ - decl String:sEnabled[2], String:sColor[4], String:sMode[2]; - GetClientCookie(client, sri_cookie_enabled, sEnabled, sizeof(sEnabled)); - GetClientCookie(client, sri_cookie_color, sColor, sizeof(sColor)); - GetClientCookie(client, sri_cookie_mode, sMode, sizeof(sMode)); - g_aClientCookies[client][bEnabled] = StringToInt(sEnabled); - g_aClientCookies[client][iColor] = StringToInt(sColor); - g_aClientCookies[client][iMode] = StringToInt(sMode); -} - -public OnClientDisconnect(client) -{ - CleanUp(client); -} - -/** - Commands - */ - -public Action:Command_Immunity(client, args) -{ - if (g_aPlayers[client][IsImmune]) - { - DisableImmunity(client); - } - else - { - EnableImmunity(client); - } - return Plugin_Handled; -} - -/** - Event hooks - */ - -public Action:Hacks_TakeDamageHook(client, attacker, inflictor, Float:damage, &Float:multiplier, damagetype) -{ - if (attacker == 0 || attacker >= MaxClients) - { - return Plugin_Continue; - } - if (g_aPlayers[client][IsImmune]) - { - new TFClassType:PlayerClass = TF2_GetPlayerClass(attacker); - if (PlayerClass == TFClass_Spy) - { - multiplier *= 0.0; - return Plugin_Changed; - } - } - return Plugin_Continue; -} - -public HookRoundStart(Handle:event, const String:name[], bool:dontBroadcast) -{ - g_bRoundEnd = false; - if (g_bIsEnabled) - { - for (new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][IsImmune]) - { - DisableImmunity(i); - } - } - } -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - g_bRoundEnd = true; - if (g_bIsEnabled) - { - for (new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][bIsAdmin]) - { - EnableImmunity(i); - } - } - } -} - -public HookPlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast) -{ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - if (g_bIsEnabled && g_aPlayers[iClient][bIsAdmin] && g_bRoundEnd) - { - EnableImmunity(iClient); - } -} - -public Action:HookPlayerHurt(Handle:event, const String:name[], bool:dontBroadcast) -{ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - if (g_aPlayers[iClient][IsImmune]) - { - SetEntityHealth(iClient, 2000); - return Plugin_Continue; - } - return Plugin_Continue; -} - -/** - Cookie menus - */ - -public CookieMenu_TopMenu(client, CookieMenuAction:action, any:info, String:buffer[], maxlen) -{ - if (action == CookieMenuAction_DisplayOption) - { - //don't think we need to do anything - } - else - { - new Handle:hMenu = CreateMenu(Menu_CookieSettings); - SetMenuTitle(hMenu, "Options (Current Setting)"); - if (g_aClientCookies[client][bEnabled]) - { - AddMenuItem(hMenu, "enable", "Enabled/Disable (Enabled)"); - } - else - { - AddMenuItem(hMenu, "enable", "Enabled/Disable (Disabled)"); - } - if (g_aClientCookies[client][iMode]) - { - AddMenuItem(hMenu, "mode", "Immunity Mode Setting (God Mode)"); - } - else - { - AddMenuItem(hMenu, "mode", "Immunity Mode Setting (Health)"); - } - switch (g_aClientCookies[client][iColor]) - { - case COLOR_GREEN: - { - AddMenuItem(hMenu, "color", "Color (Green)"); - } - case COLOR_BLACK: - { - AddMenuItem(hMenu, "color", "Color (Black)"); - } - case COLOR_RED: - { - AddMenuItem(hMenu, "color", "Color (Red)"); - } - case COLOR_BLUE: - { - AddMenuItem(hMenu, "color", "Color (Blue)"); - } - case COLOR_TEAM: - { - AddMenuItem(hMenu, "color", "Color (Team)"); - } - case COLOR_RAINBOW: - { - AddMenuItem(hMenu, "color", "Color (Rainbow)"); - } - case COLOR_NONE: - { - AddMenuItem(hMenu, "color", "Color (None)"); - } - } - SetMenuExitBackButton(hMenu, true); - DisplayMenu(hMenu, client, MENU_TIME_FOREVER); - } -} - -public Menu_CookieSettings(Handle:menu, MenuAction:action, param1, param2) -{ - new client = param1; - if (action == MenuAction_Select) - { - new String:sSelection[24]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "enable", false)) - { - new Handle:hMenu = CreateMenu(Menu_CookieSettingsEnable); - SetMenuTitle(hMenu, "Enable/Disable Round End Immunity"); - - if (g_aClientCookies[client][bEnabled]) - { - AddMenuItem(hMenu, "enable", "Enable (Set)"); - AddMenuItem(hMenu, "disable", "Disable"); - } - else - { - AddMenuItem(hMenu, "enable", "Enabled"); - AddMenuItem(hMenu, "disable", "Disable (Set)"); - } - - SetMenuExitBackButton(hMenu, true); - DisplayMenu(hMenu, client, MENU_TIME_FOREVER); - } - else if (StrEqual(sSelection, "mode", false)) - { - new Handle:hMenu = CreateMenu(Menu_CookieSettingsMode); - SetMenuTitle(hMenu, "Set Immunity Mode"); - - if (g_aClientCookies[client][iMode]) - { - AddMenuItem(hMenu, "god", "God Mode (Set)"); - AddMenuItem(hMenu, "health", "Health"); - } - else - { - AddMenuItem(hMenu, "god", "God Mode"); - AddMenuItem(hMenu, "health", "Health (Set)"); - } - - SetMenuExitBackButton(hMenu, true); - DisplayMenu(hMenu, client, MENU_TIME_FOREVER); - } - else - { - new Handle:hMenu = CreateMenu(Menu_CookieSettingsColors); - SetMenuTitle(hMenu, "Select Immunity Color"); - switch (g_aClientCookies[client][iColor]) - { - case COLOR_GREEN: - { - AddMenuItem(hMenu, "Green", "Green (Set)"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_BLACK: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black (Set)"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_RED: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red (Set)"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_BLUE: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue (Set)"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_TEAM: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color (Set)"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_RAINBOW: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow (Set)"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_NONE: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None (Set)"); - } - } - SetMenuExitBackButton(hMenu, true); - DisplayMenu(hMenu, client, MENU_TIME_FOREVER); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - ShowCookieMenu(client); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } -} - -public Menu_CookieSettingsEnable(Handle:menu, MenuAction:action, param1, param2) -{ - new client = param1; - if (action == MenuAction_Select) - { - new String:sSelection[24]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "enable", false)) - { - SetClientCookie(client, sri_cookie_enabled, "1"); - g_aClientCookies[client][bEnabled] = 1; - PrintToChat(client, "[SM] Bonus Round Immunity is ENABLED"); - } - else - { - SetClientCookie(client, sri_cookie_enabled, "0"); - g_aClientCookies[client][bEnabled] = 0; - PrintToChat(client, "[SM] Bonus Round Immunity is DISABLED"); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - ShowCookieMenu(client); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } -} - -public Menu_CookieSettingsColors(Handle:menu, MenuAction:action, param1, param2) -{ - new client = param1; - if (action == MenuAction_Select) - { - new String:sSelection[24]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "Green", false)) - { - SetClientCookie(client, sri_cookie_color, "0"); - g_aClientCookies[client][iColor] = COLOR_GREEN; - PrintToChat(client, "[SM] Bonus Round Immunity color set to GREEN"); - } - else if (StrEqual(sSelection, "Black", false)) - { - SetClientCookie(client, sri_cookie_color, "1"); - g_aClientCookies[client][iColor] = COLOR_BLACK; - PrintToChat(client, "[SM] Bonus Round Immunity color set to BLACK"); - } - else if (StrEqual(sSelection, "Red", false)) - { - SetClientCookie(client, sri_cookie_color, "2"); - g_aClientCookies[client][iColor] = COLOR_RED; - PrintToChat(client, "[SM] Bonus Round Immunity color set to RED"); - } - else if (StrEqual(sSelection, "Blue", false)) - { - SetClientCookie(client, sri_cookie_color, "3"); - g_aClientCookies[client][iColor] = COLOR_BLUE; - PrintToChat(client, "[SM] Bonus Round Immunity color set to BLUE"); - } - else if (StrEqual(sSelection, "Team", false)) - { - SetClientCookie(client, sri_cookie_color, "4"); - g_aClientCookies[client][iColor] = COLOR_TEAM; - PrintToChat(client, "[SM] Bonus Round Immunity color set to TEAM COLOR"); - } - else if (StrEqual(sSelection, "Rain", false)) - { - SetClientCookie(client, sri_cookie_color, "5"); - g_aClientCookies[client][iColor] = COLOR_RAINBOW; - PrintToChat(client, "[SM] Bonus Round Immunity color set to RAINBOW"); - } - else if (StrEqual(sSelection, "None", false)) - { - SetClientCookie(client, sri_cookie_color, "6"); - g_aClientCookies[client][iColor] = COLOR_NONE; - PrintToChat(client, "[SM] Bonus Round Immunity color set to NONE"); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - ShowCookieMenu(client); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } -} - -public Menu_CookieSettingsMode(Handle:menu, MenuAction:action, param1, param2) -{ - new client = param1; - if (action == MenuAction_Select) - { - new String:sSelection[24]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "god", false)) - { - SetClientCookie(client, sri_cookie_mode, "1"); - g_aClientCookies[client][iMode] = 1; - PrintToChat(client, "[SM] Bonus Round Immunity set to GOD MODE"); - } - else - { - SetClientCookie(client, sri_cookie_mode, "0"); - g_aClientCookies[client][iMode] = 0; - PrintToChat(client, "[SM] Bonus Round Immunity set to HEALTH BONUS"); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - ShowCookieMenu(client); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } -} - -/** -Timer functions - */ - -public Action:Timer_ChangeColor(Handle:timer, any:client) -{ - if (g_aPlayers[client][CycleColor]++ == 3) - { - g_aPlayers[client][CycleColor] = 0; - } - SetEntityRenderMode(client, RENDER_TRANSCOLOR); - SetEntityRenderColor(client, g_iColors[g_aPlayers[client][CycleColor]][iRed], g_iColors[g_aPlayers[client][CycleColor]][iGreen], g_iColors[g_aPlayers[client][CycleColor]][iBlue], 255); - return Plugin_Continue; -} - -public Action:Timer_UndoGodMode(Handle:timer, any:client) -{ - if (IsClientInGame(client)) - { - SetEntProp(client, Prop_Data, "m_takedamage", 2, 1); - } - g_aPlayers[iClient][hGodModeTimer] = INVALID_HANDLE; - return Plugin_Handled; -} - -/** -Stock functions . - */ - -stock CleanUp(iClient) -{ - g_aPlayers[iClient][bIsAdmin] = false; - DisableImmunity(iClient); -} - -stock EnableImmunity(iClient) -{ - SetEntityRenderMode(iClient, RENDER_TRANSCOLOR); - switch (g_aClientCookies[iClient][iColor]) - { - case COLOR_TEAM: - { - new iTeam = GetClientTeam(iClient); - SetEntityRenderColor(iClient, g_iColors[e_ColorNames:iTeam][iRed], g_iColors[e_ColorNames:iTeam][iGreen], g_iColors[e_ColorNames:iTeam][iBlue], 255); - } - case COLOR_RAINBOW: - { - if (g_aPlayers[iClient][hColorTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[iClient][hColorTimer]); - g_aPlayers[iClient][hColorTimer] = INVALID_HANDLE; - } - g_aPlayers[iClient][hColorTimer] = CreateTimer(0.2, Timer_ChangeColor, iClient, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); - } - case COLOR_NONE: - { - //We dont have to set a color - } - default: - { - SetEntityRenderColor(iClient, g_iColors[e_ColorNames:g_aClientCookies[iClient][iColor]][iRed], g_iColors[e_ColorNames:g_aClientCookies[iClient][iColor]][iGreen], g_iColors[e_ColorNames:g_aClientCookies[iClient][iColor]][iBlue], 255); - } - } - SetEntityHealth(iClient, 2000); - SetEntProp(iClient, Prop_Data, "m_takedamage", 0, 1); - g_aPlayers[iClient][hGodModeTimer] = CreateTimer(2.0, Timer_UndoGodMode, iClient); - g_aPlayers[iClient][IsImmune] = true; -} - -stock DisableImmunity(iClient) -{ - if (g_aPlayers[iClient][hGodModeTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[iClient][hGodModeTimer]); - g_aPlayers[iClient][hGodModeTimer] = INVALID_HANDLE; - } - if (g_aPlayers[iClient][hColorTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[iClient][hColorTimer]); - g_aPlayers[iClient][hColorTimer] = INVALID_HANDLE; - } - if (IsClientInGame(iClient)) - { - SetEntityRenderMode(iClient, RENDER_TRANSCOLOR); - SetEntityRenderColor(iClient, 255, 255, 255, 255); - new TFClassType:PlayerClass = TF2_GetPlayerClass(iClient); - new iMaxHealth = g_iClassMaxHealth[PlayerClass]; - SetEntityHealth(iClient, iMaxHealth); - } - g_aPlayers[iClient][CycleColor] = 0; - g_aPlayers[iClient][IsImmune] = false; -} - -stock LoadColors() -{ - g_iColors[Green][iRed] = 0; - g_iColors[Green][iGreen] = 255; - g_iColors[Green][iBlue] = 0; - - g_iColors[Black][iRed] = 10; - g_iColors[Black][iGreen] = 10; - g_iColors[Black][iBlue] = 0; - - g_iColors[Red][iRed] = 255; - g_iColors[Red][iGreen] = 0; - g_iColors[Red][iBlue] = 0; - - g_iColors[Blue][iRed] = 0; - g_iColors[Blue][iGreen] = 0; - g_iColors[Blue][iBlue] = 255; -} - -stock TF2_AddCond(client, cond) -{ - new Handle:cvar = FindConVar("sv_cheats"), bool:enabled = GetConVarBool(cvar), flags = GetConVarFlags(cvar); - if(!enabled) - { - SetConVarFlags(cvar, flags^FCVAR_NOTIFY); - SetConVarBool(cvar, true); - } - FakeClientCommand(client, "addcond %i", cond); - if(!enabled) - { - SetConVarBool(cvar, false); - SetConVarFlags(cvar, flags); - } -} - -stock TF2_RemoveCond(client, cond) -{ - new Handle:cvar = FindConVar("sv_cheats"), bool:enabled = GetConVarBool(cvar), flags = GetConVarFlags(cvar); - if(!enabled) - { - SetConVarFlags(cvar, flags^FCVAR_NOTIFY); - SetConVarBool(cvar, true); - } - FakeClientCommand(client, "removecond %i", cond); - if(!enabled) - { - SetConVarBool(cvar, false); - SetConVarFlags(cvar, flags); - } -} - -/** -Enabled hook - */ - -public EnabledChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (StringToInt(newValue) == 0) - { - UnhookEvent("player_spawn", HookPlayerSpawn, EventHookMode_Post); - UnhookEvent("teamplay_round_start", HookRoundStart, EventHookMode_Post); - UnhookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - for (new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][bIsAdmin] && g_aPlayers[i][IsImmune]) - { - DisableImmunity(i); - } - } - g_bIsEnabled = false; - } - else - { - HookEvent("player_spawn", HookPlayerSpawn, EventHookMode_Post); - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_Post); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - g_bIsEnabled = true; - } -} diff --git a/Simple Team Manager/addons/sourcemod/scripting/simple-spectate.sp b/Simple Team Manager/addons/sourcemod/scripting/simple-spectate.sp deleted file mode 100644 index 4108f8f..0000000 --- a/Simple Team Manager/addons/sourcemod/scripting/simple-spectate.sp +++ /dev/null @@ -1,2022 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Spectate -Description: - Spectate a player and follow them through death. -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include -#undef REQUIRE_EXTENSIONS -#undef AUTOLOAD_EXTENSIONS -#tryinclude -#define AUTOLOAD_EXTENSIONS -#define REQUIRE_EXTENSIONS - -#define PLUGIN_VERSION "1.2.1.$Rev$" - -#define SPECMODE_NONE 0 -#define SPECMODE_FIRSTPERSON 4 -#define SPECMODE_3RDPERSON 5 -#define SPECMODE_FREELOOK 6 -#define SPECMODE_CSS_FIRSTPERSON 3 -#define SPECMODE_CSS_3RDPERSON 4 -#define SPECMODE_CSS_FREELOOK 5 - -enum e_CvarHandles -{ - Handle:hHudMode, - Handle:hMenuType, - Handle:hRestrictHud, - Handle:hBan, - Handle:hBanPerm, - Handle:hBeacon, - Handle:hBlind, - Handle:hCheater, - Handle:hDrug, - Handle:hFreeze, - Handle:hFreezeBomb, - Handle:hKick, - Handle:hSlap, - Handle:hSlay, - Handle:hTimeBomb -}; - -enum e_CvarSettings -{ - bool:bHudMode, - bool:bMenuType, - bool:bRestrictHud, - bool:bBan, - bool:bBanPerm, - bool:bBeacon, - bool:bBlind, - bool:bCheater, - bool:bDrug, - bool:bFreeze, - bool:bFreezebomb, - bool:bKick, - bool:bSlap, - bool:bSlay, - bool:bTimeBomb -}; - -enum e_PluginSettings -{ - bool:bUseSteamBans, - bool:bUseSourceBans, - bool:bUseMySQLBans, - bool:bCanHUD, - bool:bUseDukehacks -}; - -enum e_Menus -{ - Handle:hSelectPlayer, - Handle:hBanTime, - Handle:hReason -}; - -enum e_Punishments -{ - Punish_None, - Punish_Ban, - Punish_Beacon, - Punish_Blind, - Punish_Cheater, - Punish_Drug, - Punish_Freeze, - Punish_FreezeBomb, - Punish_Kick, - Punish_Slap, - Punish_Slay, - Punish_TimeBomb -}; - -enum e_PlayerData -{ - bool:bIsDisplayingHud, - bool:bIsFlaggedCheater, - Handle:hHudTimer, - Handle:hTargetTimer, - iTargetIndex, - e_Punishments:TargetPunishment, - iBanTime -}; - -new Handle:sm_spectate_adminflag = INVALID_HANDLE; -new Handle:g_hAdminMenu = INVALID_HANDLE; -new Handle:g_hHud = INVALID_HANDLE; -new Handle:g_aPluginCvar[e_CvarHandles]; -new g_aPluginCvarSettings[e_CvarSettings]; -new g_aPluginSettings[e_PluginSettings]; -new g_aMenus[e_Menus]; -new g_aPlayers[MAXPLAYERS + 1][e_PlayerData]; -new String:g_sAdminFlags[16]; -new String:g_sPunishments[e_Punishments][15] = { "None", "Ban", "Beacon", "Blind", "Cheater", "Drug", "Freeze", "FreezeBomb", "Kick", "Slap", "Slay", "TimeBomb" }; - -public Plugin:myinfo = -{ - name = "Simple Spectate", - author = "Simple Plugins", - description = "Spectate a player and follow them through death.", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -}; - -/** -Sourcemod callbacks -*/ -public OnPluginStart() -{ - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook the game events - */ - LogAction(0, -1, "[SSPEC] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_team", HookPlayerChangeTeam, EventHookMode_Pre); - - /** - Need to create all of our console variables. - */ - CreateConVar("sm_spectate_version", PLUGIN_VERSION, "Sourcemod Spectate", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - g_aPluginCvar[hHudMode] = CreateConVar("sm_spectate_hudmode", "1", "Hud Mode: 0 = Hud Text | 1 = Panel/Menu (NOTE: The panel/menu will override other menus until canceled)"); - g_aPluginCvar[hMenuType] = CreateConVar("sm_spectate_menutype", "0", "Menu Mode: 0 = Panel | 1 = Menu"); - g_aPluginCvar[hRestrictHud] = CreateConVar("sm_spectate_restricthud", "0", "Restrict the hud to the admin flag provided"); - g_aPluginCvar[hBan] = CreateConVar("sm_spectate_ban", "1", "Enable/Disable ban option"); - g_aPluginCvar[hBanPerm] = CreateConVar("sm_spectate_banperm", "1", "Enable/Disable permanent ban option"); - g_aPluginCvar[hBeacon] = CreateConVar("sm_spectate_beacon", "1", "Enable/Disable beacon option"); - g_aPluginCvar[hBlind] = CreateConVar("sm_spectate_blind", "1", "Enable/Disable blind option"); - g_aPluginCvar[hCheater] = CreateConVar("sm_spectate_cheater", "1", "Enable/Disable cheater option"); - g_aPluginCvar[hDrug] = CreateConVar("sm_spectate_drug", "1", "Enable/Disable drug option"); - g_aPluginCvar[hFreeze] = CreateConVar("sm_spectate_freeze", "1", "Enable/Disable freeze option"); - g_aPluginCvar[hFreezeBomb] = CreateConVar("sm_spectate_freezebomb", "1", "Enable/Disable freezebomb option"); - g_aPluginCvar[hKick] = CreateConVar("sm_spectate_kick", "1", "Enable/Disable kick option"); - g_aPluginCvar[hSlap] = CreateConVar("sm_spectate_slap", "1", "Enable/Disable slap option"); - g_aPluginCvar[hSlay] = CreateConVar("sm_spectate_slay", "1", "Enable/Disable slay option"); - g_aPluginCvar[hTimeBomb] = CreateConVar("sm_spectate_timebomb", "1", "Enable/Disable timebomb option"); - - sm_spectate_adminflag = CreateConVar("sm_spectate_adminflag", "d", "Admin Flag to use for admin hud"); - - /** - Hook console variables - */ - new e_CvarHandles:iCvar; - for ( ; _:iCvar < sizeof(g_aPluginCvar); iCvar++) - { - HookConVarChange(g_aPluginCvar[iCvar], ConVarSettingsChanged); - } - - /** - Need to register the commands we are going to create and use. - */ - RegConsoleCmd("sm_spectate", Command_Spectate, "Spectate a player"); - RegConsoleCmd("sm_spec", Command_Spectate, "Spectate a player"); - RegConsoleCmd("sm_observe", Command_Spectate, "Spectate a player"); - RegConsoleCmd("sm_stopspec", Command_StopSpectate, "Stop Spectating a player"); - RegConsoleCmd("sm_endobserve", Command_StopSpectate, "Stop Spectating a player"); - RegConsoleCmd("sm_specinfo", Command_ToggleHud, "Toggles the hud display if in spectator"); - - /** - Now we have to deal with the admin menu. If the admin library is loaded call the function to add our items. - */ - new Handle:gTopMenu; - if (LibraryExists("adminmenu") && ((gTopMenu = GetAdminTopMenu()) != INVALID_HANDLE)) - { - OnAdminMenuReady(gTopMenu); - } - - /** - Deal with the hud - Thanks to Spray Trace plugin (http://forums.alliedmods.net/showthread.php?p=665448) - */ - new String:sHudGames[32]; - GetGameFolderName(sHudGames, sizeof(sHudGames)); - g_aPluginSettings[bCanHUD] = StrEqual(sHudGames,"tf",false) - || StrEqual(sHudGames,"hl2mp",false) - || StrEqual(sHudGames,"sourceforts",false) - || StrEqual(sHudGames,"obsidian",false) - || StrEqual(sHudGames,"left4dead",false) - || StrEqual(sHudGames,"l4d",false); - - if (g_aPluginSettings[bCanHUD]) - { - g_hHud = CreateHudSynchronizer(); - } - - /** - Load translations - */ - LoadTranslations ("common.phrases"); - LoadTranslations ("simplespectate.phrases"); - - /** - Create the config file - */ - AutoExecConfig(true); -} - -public OnConfigsExecuted() -{ - new e_CvarHandles:iCvar; - for ( ; _:iCvar < sizeof(g_aPluginCvarSettings); iCvar++) - { - g_aPluginCvarSettings[iCvar] = GetConVarBool(g_aPluginCvar[iCvar]); - } - - /* - Build the global menus - */ - g_aMenus[hSelectPlayer] = BuildSelectPlayerMenu(); - g_aMenus[hBanTime] = BuildBanTimeMenu(); - g_aMenus[hReason] = BuildReasonMenu(); - - GetConVarString(sm_spectate_adminflag, g_sAdminFlags, sizeof(g_sAdminFlags)); -} - -public OnAllPluginsLoaded() -{ - - /* - Check for steambans - */ - if (FindConVar("sbsrc_version") != INVALID_HANDLE) - { - g_aPluginSettings[bUseSteamBans] = true; - } - else - { - g_aPluginSettings[bUseSteamBans] = false; - } - - /* - Check for sourcebans - */ - if (FindConVar("sb_version") != INVALID_HANDLE) - { - g_aPluginSettings[bUseSourceBans] = true; - } - else - { - g_aPluginSettings[bUseSourceBans] = false; - } - - /* - Check for mysql bans - */ - if (FindConVar("mysql_bans_version") != INVALID_HANDLE) - { - g_aPluginSettings[bUseMySQLBans] = true; - } - else - { - g_aPluginSettings[bUseMySQLBans] = false; - } - - /* - Check for dukehacks - */ - new String:sExtError[256]; - new iExtStatus = GetExtensionFileStatus("dukehacks.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SSPEC] Dukehacks extension was not found."); - LogAction(0, -1, "[SSPEC] Plugin continued to load, but that feature will not be used."); - g_aPluginSettings[bUseDukehacks] = false; - } - else if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SSPEC] Dukehacks extension is loaded with errors."); - LogAction(0, -1, "[SSPEC] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SSPEC] Plugin continued to load, but that feature will not be used."); - g_aPluginSettings[bUseDukehacks] = false; - } - else if (iExtStatus == 1) - { - LogAction(0, -1, "[SSPEC] Dukehacks extension is loaded and will be used."); - g_aPluginSettings[bUseDukehacks] = true; - dhAddClientHook(CHK_TakeDamage, Hacks_TakeDamageHook); - } - - /* - Deal with some known plugin conflicts - */ - new Handle:hObserveClient = FindConVar("observe_version"); - if (hObserveClient != INVALID_HANDLE) - { - new String:sNewFile[PLATFORM_MAX_PATH + 1], String:sOldFile[PLATFORM_MAX_PATH + 1]; - BuildPath(Path_SM, sNewFile, sizeof(sNewFile), "plugins/disabled/observe.smx"); - BuildPath(Path_SM, sOldFile, sizeof(sOldFile), "plugins/observe.smx"); - - /** - Check if plugins/observe.smx exists, and if not, ignore - */ - if(!FileExists(sOldFile)) - { - return; - } - - /** - Check if plugins/disabled/observe.smx already exists, and if so, delete it - */ - if(FileExists(sNewFile)) - { - DeleteFile(sNewFile); - } - - /** - Unload plugins/observe.smx and move it to plugins/disabled/observe.smx - */ - LogAction(0, -1, "Detected the plugin ObserveClient"); - LogAction(0, -1, "ObserveClient plugin conflicts with Simple Spectate"); - LogAction(0, -1, "Unloading plugin and disabling ObserveClient plugin"); - ServerCommand("sm plugins unload observe"); - RenameFile(sNewFile, sOldFile); - } -} - -public OnLibraryRemoved(const String:name[]) -{ - if (StrEqual(name, "adminmenu")) - { - - /** - Looks like the admin menu was removed. Set the global. - */ - g_hAdminMenu = INVALID_HANDLE; - } - else if (StrEqual(name, "simpleplugins")) - { - //something - } -} - -public OnClientDisconnect(client) -{ - - /** - Cleanup the clients variables. - */ - ResetClient(client); - - /** - Run a loop and see if we are supposed to spectate this person (is a target) - */ - for(new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][iTargetIndex] == client) - { - - /** - Cleanup the clients variables. - */ - StopFollowingPlayer(i); - g_aPlayers[i][TargetPunishment] = Punish_None; - g_aPlayers[i][iBanTime] = 0; - } - } -} - -/** -Thirdparty callbacks -*/ -public SM_OnPlayerMoved(Handle:plugin, client, team) -{ - - /** - Make sure we called the move function - */ - if (plugin != GetMyHandle()) - { - return; - } - - //Nothing -} - -public Action:Hacks_TakeDamageHook(client, attacker, inflictor, Float:damage, &Float:multiplier, damagetype) -{ - - /** - Check for a valid client - */ - if (client > 0 && client <= MaxClients) - { - - /** - Check if the client taking damage is flagged as a cheater - */ - if (g_aPlayers[client][bIsFlaggedCheater]) - { - - /** - Check for fall damage and increase it - */ - if (damagetype & DMG_FALL) - { - multiplier *= 1000.0; - return Plugin_Changed; - } - } - } - - /** - Check for a valid attacker - */ - if (attacker > 0 && attacker <= MaxClients) - { - - /** - Check if the attacker causing the damage is flagged as a cheater - */ - if (g_aPlayers[attacker][bIsFlaggedCheater]) - { - - /** - Make sure they are not hurting themselves - */ - if (client != attacker) - { - - /** - Stop the damage - */ - multiplier *= 0.0; - return Plugin_Changed; - } - } - } - return Plugin_Continue; -} - -/** -Events -*/ -public Action:HookPlayerChangeTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get the client and team - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - new iTeam = GetEventInt(event, "team"); - - /** - Make sure it's a valid client - */ - if (iClient == 0) - { - return Plugin_Continue; - } - - /** - If it's a move to spectator start displaying the hud - */ - else if ((iTeam == g_aCurrentTeams[Spectator]) && (GetUserFlagBits(iClient) & ADMFLAG_GENERIC)) - { - StartDisplayingHud(iClient); - - /** - If the event was going to be broadcasted, we refire it so it is not broadcasted and stop this one - */ - if (!dontBroadcast) - { - new Handle:hEvent = CreateEvent("player_team"); - SetEventInt(hEvent, "userid", GetEventInt(event, "userid")); - SetEventInt(hEvent, "team", GetEventInt(event, "team")); - SetEventInt(hEvent, "oldteam", GetEventInt(event, "oldteam")); - SetEventBool(hEvent, "disconnect", GetEventBool(event, "disconnect")); - - if (g_CurrentMod == GameType_DOD || g_CurrentMod == GameType_L4D || g_CurrentMod == GameType_TF) - { - new String:sClientName[MAX_NAME_LENGTH + 1]; - GetClientName(client, sClientName, sizeof(sClientName)); - SetEventBool(hEvent, "autoteam", GetEventBool(event, "autoteam")); - SetEventBool(hEvent, "silent", true); - SetEventString(hEvent, "name", sClientName); - FireEvent(hEvent, true); - } - else - { - FireEvent(hEvent, true); - } - return Plugin_Handled; - } - } - - /** - Otherwise cleanup the client - */ - else - { - StopDisplayingHud(iClient); - StopFollowingPlayer(iClient); - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -/** -Commands -*/ -public Action:Command_Spectate(client, args) -{ - - /** - See if we already have a target (for toggling of command) - */ - if (g_aPlayers[client][iTargetIndex]) - { - - /** - We do, toggle it off - */ - StopFollowingPlayer(client); - - /** - We are done, bug out. - */ - return Plugin_Handled; - } - - /** - We don't... must want to enable it - See if we have some command arguments. - */ - new iCmdArgs = GetCmdArgs(); - if (iCmdArgs == 0) - { - - /** - We don't have any. Display the player menu. - */ - if (g_aPlayers[client][bIsDisplayingHud]) - { - StopDisplayingHud(client); - } - - DisplayMenu(BuildPlayerListMenu(), client, MENU_TIME_FOREVER); - return Plugin_Handled; - } - - /** - We have an argument. - Try to find the target. - */ - new String:sPlayer[128]; - GetCmdArg(1, sPlayer, sizeof(sPlayer)); - new iTarget = FindTarget(client, sPlayer, true, true); - if (iTarget == -1 || !IsClientInGame(iTarget)) - { - - /** - We couldn't find the target. Display the player menu. - */ - if (g_aPlayers[client][bIsDisplayingHud]) - { - StopDisplayingHud(client); - } - - DisplayMenu(BuildPlayerListMenu(), client, MENU_TIME_FOREVER); - return Plugin_Handled; - } - - /** - We found the target. - Call the stock function to spectate the target. - */ - StartFollowingPlayer(client, iTarget); - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_StopSpectate(client, args) -{ - - /** - Cleanup the clients variables. - */ - StopFollowingPlayer(client); - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_ToggleHud(client, args) -{ - - /** - Toggle the hud - */ - if (g_aPlayers[client][bIsDisplayingHud]) - { - StopDisplayingHud(client); - } - else - { - StartDisplayingHud(client); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -/** -Timers -*/ -public Action:Timer_ResetTarget(Handle:timer, any:client) -{ - - new iTargetID = GetEntPropEnt(client, Prop_Send, "m_hObserverTarget"); - - if (iTargetID != g_aPlayers[client][iTargetIndex] && IsPlayerAlive(g_aPlayers[client][iTargetIndex])) - { - - /** - Run the command to spectate the target from the clients prospectative. - */ - FakeClientCommandEx(client, "spec_player \"%N\"", g_aPlayers[client][iTargetIndex]); - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -public Action:Timer_UpdateHud(Handle:timer, any:client) -{ - - /** - Make sure the client is still in game and a spectator - */ - if (!IsClientConnected(client) || !IsClientInGame(client) || GetClientTeam(client) != g_aCurrentTeams[Spectator] || !g_aPlayers[client][bIsDisplayingHud]) - { - - /** - We are done, bug out - */ - g_aPlayers[client][hHudTimer] = INVALID_HANDLE; - g_aPlayers[client][bIsDisplayingHud] = false; - return Plugin_Stop; - } - /** - Get the target - */ - new iTarget = GetEntPropEnt(client, Prop_Send, "m_hObserverTarget"); - - /** - Check to make sure the target is valid - */ - if (iTarget <= 0 || iTarget > MaxClients) - { - return Plugin_Continue; - } - - /** - Get the spectator mode - */ - new iSpecMode = GetEntProp(client, Prop_Send, "m_iObserverMode"); - - /** - This is a double check to make sure we are in spec - If we are on a regular team, specmod would = none or zero - */ - if (iSpecMode == SPECMODE_NONE) - { - - /** - We are done, bug out - */ - g_aPlayers[client][hHudTimer] = INVALID_HANDLE; - g_aPlayers[client][bIsDisplayingHud] = false; - return Plugin_Stop; - } - - /** - Check the spectator mode - CSS has different index's so we have to check game type first - */ - if (g_CurrentMod == GameType_CSS) - { - switch (iSpecMode) - { - case SPECMODE_CSS_FIRSTPERSON: - { - //Do Nothing - } - case SPECMODE_CSS_3RDPERSON: - { - //Do Nothing - } - case SPECMODE_CSS_FREELOOK: - { - return Plugin_Continue; - } - } - } - else - { - switch (iSpecMode) - { - case SPECMODE_FIRSTPERSON: - { - //Do Nothing - } - case SPECMODE_3RDPERSON: - { - //Do Nothing - } - case SPECMODE_FREELOOK: - { - return Plugin_Continue; - } - } - } - - - /** - Display with the hud - */ - if (g_aPluginSettings[bCanHUD] && !g_aPluginCvarSettings[bHudMode]) - { - new String:sSteamID[64]; - GetClientAuthString(iTarget, sSteamID, sizeof(sSteamID)); - SetHudTextParams(0.04, 0.6, 0.5, 255, 50, 50, 255); - ShowSyncHudText(client, g_hHud, "%N [%s]", iTarget, sSteamID); - } - else if (g_aPluginCvarSettings[bHudMode]) - { - if (g_aPluginCvarSettings[bMenuType]) - { - DisplayMenu(BuildPlayerHudMenu(client, iTarget), client, 1); - } - else - { - new Handle:hPanel = BuildPlayerHudPanel(client, iTarget); - SendPanelToClient(hPanel, client, Panel_PlayerHud, 1); - CloseHandle(hPanel); - } - } - - /** - We are done, keep going! - */ - return Plugin_Continue; -} - -/** -Admin Menu Callbacks -*/ -public OnAdminMenuReady(Handle:topmenu) -{ - if (topmenu == g_hAdminMenu) - { - return; - } - g_hAdminMenu = topmenu; - new TopMenuObject:player_commands = FindTopMenuCategory(g_hAdminMenu, ADMINMENU_PLAYERCOMMANDS); - if (player_commands == INVALID_TOPMENUOBJECT) - { - return; - } - AddToTopMenu(g_hAdminMenu, - "sm_spectate", - TopMenuObject_Item, - AdminMenu_SpecPlayer, - player_commands, - "sm_spectate", - ADMFLAG_GENERIC); -} - -public AdminMenu_SpecPlayer(Handle:topmenu, TopMenuAction:action, TopMenuObject:object_id, param, String:buffer[], maxlength) -{ - if (action == TopMenuAction_DisplayOption) - { - - if (g_aPlayers[param][bIsDisplayingHud]) - { - StopDisplayingHud(param); - } - /** - See if we already have a target - */ - if (g_aPlayers[param][iTargetIndex]) - { - Format(buffer, maxlength, "Spectate(Disable)"); - } - else - { - Format(buffer, maxlength, "Spectate(Select Player)"); - } - } - else if (action == TopMenuAction_SelectOption) - { - - /** - See if we already have a target - */ - if (g_aPlayers[param][iTargetIndex]) - { - - /** - We do, toggle it off - */ - StopFollowingPlayer(param); - - /** - We are done, bug out. - */ - return; - } - else - { - DisplayMenu(BuildPlayerListMenu(), param, MENU_TIME_FOREVER); - } - } -} - -/** -Select Player Menu Callbacks -*/ -public Menu_PlayerList(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - /** - Get the selected player - */ - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - new iTarget = GetClientOfUserId(StringToInt(sSelection)); - - /** - Start following the player - */ - StartFollowingPlayer(param1, iTarget); - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_GENERIC) - { - - /** - Display the last admin menu - */ - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } - else if (param2 == MenuCancel_Exit && GetClientTeam(param1) == g_aCurrentTeams[Spectator]) - { - /** - They canceled the current menu, start the hud back up - */ - StartDisplayingHud(param1); - } - } - else if (action == MenuAction_End) - { - - /** - Not a global menu, close it - */ - CloseHandle(menu); - } -} - -public Menu_SelectPlayer(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - - /** - Get the selected player - */ - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (strcmp(sSelection, "Current", false) == 0) - { - /** - Get the current target - */ - new iTarget = GetEntPropEnt(param1, Prop_Send, "m_hObserverTarget"); - - /** - Check to make sure the target is valid - */ - if (iTarget <= 0 || iTarget > MaxClients) - { - PrintToChat(param1, "\x03[SM-SPEC]\x01 %t", "Invalid Target"); - DisplayMenu(BuildPlayerListMenu(), param1, MENU_TIME_FOREVER); - } - - /** - Start following the player - */ - StartFollowingPlayer(param1, iTarget); - } - else - { - - /** - They want to select a player, show the player list - */ - DisplayMenu(BuildPlayerListMenu(), param1, MENU_TIME_FOREVER); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - - /** - They canceled the current menu, start the hud back up - */ - StartDisplayingHud(param1); - } - } - else if (action == MenuAction_End) - { - /** - Its a global menu, leave it alive - */ - } -} - -/** -Punishment Menu Callbacks -*/ -public Menu_Punishments(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - - /** - Get the menu selection - */ - new String:sSelection[15]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - - /** - Search for the correct index - */ - new e_Punishments:Index = Punish_None; - for ( ; _:Index <= sizeof(g_sPunishments); Index++) - { - if (StrEqual(sSelection, g_sPunishments[Index])) - { - break; - } - } - - /** - Display the next menu - */ - if (Index == Punish_Ban) - { - - /** - Set the punishment index and display ban time menu - */ - g_aPlayers[param1][TargetPunishment] = Index; - DisplayMenu(g_aMenus[hBanTime], param1, MENU_TIME_FOREVER); - } - else if (Index == Punish_Cheater) - { - - /** - Ask for confirmation before we set punishment index - */ - new Handle:hPanel = BuildAdminCheaterPanel(); - SendPanelToClient(hPanel, param1, Panel_AdminCheater, MENU_TIME_FOREVER); - CloseHandle(hPanel); - } - else - { - - /** - Set the punishment index and display reason menu - */ - g_aPlayers[param1][TargetPunishment] = Index; - DisplayMenu(g_aMenus[hReason], param1, MENU_TIME_FOREVER); - } - } - else if (action == MenuAction_Cancel) - { - - /** - They canceled the current menu, start the hud back up - */ - StartDisplayingHud(param1); - } - else if (action == MenuAction_End) - { - - /** - Not a global menu, close it - */ - CloseHandle(menu); - } -} - -public Menu_BanTime(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - - /** - Get the menu selection - */ - new String:sSelection[15]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - - /** - Set the ban time global - */ - g_aPlayers[param1][iBanTime] = StringToInt(sSelection); - - /** - Display the reason menu - */ - DisplayMenu(g_aMenus[hReason], param1, MENU_TIME_FOREVER); - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - - /** - They canceled the current menu, start the hud back up - */ - StartDisplayingHud(param1); - } - } - else if (action == MenuAction_End) - { - /** - Its a global menu, leave it alive - */ - } -} - -public Menu_Reason(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - - /** - Get the menu selection - */ - new String:sSelection[15]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - - /** - Perform the punishment - */ - PerformPunishment(param1, g_aPlayers[param1][iTargetIndex], g_aPlayers[param1][TargetPunishment], sSelection, g_aPlayers[param1][iBanTime]); - - /** - Reactivate the hud if still in spectator - */ - if (GetClientTeam(param1) == g_aCurrentTeams[Spectator]) - { - StartDisplayingHud(param1); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - - /** - They canceled the current menu, start the hud back up - */ - StartDisplayingHud(param1); - } - } - else if (action == MenuAction_End) - { - /** - Its a global menu, leave it alive - */ - } -} - -public Panel_AdminCheater(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - if (param2 == 1) - { - - /** - Set the punishment index and display reason menu - */ - g_aPlayers[param1][TargetPunishment] = Punish_Cheater; - DisplayMenu(g_aMenus[hReason], param1, MENU_TIME_FOREVER); - } - else - { - - /** - Reactivate the hud if still in spectator - */ - if (GetClientTeam(param1) == g_aCurrentTeams[Spectator]) - { - StartDisplayingHud(param1); - } - } - } -} - -public Panel_PublicCheater(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - if (param2 == 1) - { - //Waiting for SB 2.0 and sb_submission to be published - } - else - { - - /** - Reactivate the hud if still in spectator - */ - if (GetClientTeam(param1) == g_aCurrentTeams[Spectator]) - { - StartDisplayingHud(param1); - } - } - } -} - -/** -Hud Menu/Panel Callbacks -*/ -public Menu_PlayerHud(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "stop", false)) - { - StopFollowingPlayer(param1); - } - else if (StrEqual(sSelection, "start", false)) - { - StopDisplayingHud(param1); - DisplayMenu(g_aMenus[hSelectPlayer], param1, MENU_TIME_FOREVER); - } - else if (StrEqual(sSelection, "removecheater", false)) - { - g_aPlayers[g_aPlayers[param1][iTargetIndex]][bIsFlaggedCheater] = false; - } - else if (StrEqual(sSelection, "punish", false)) - { - if (g_aPlayers[param1][iTargetIndex]) - { - StopDisplayingHud(param1); - DisplayMenu(BuildPunishmentMenu(param1), param1, MENU_TIME_FOREVER); - } - else - { - StopDisplayingHud(param1); - PrintToChat(param1, "\x03[SM-SPEC]\x01 %t", "Must Have Target"); - DisplayMenu(g_aMenus[hSelectPlayer], param1, MENU_TIME_FOREVER); - } - } - else if (StrEqual(sSelection, "reportcheater", false)) - { - if (g_aPlayers[param1][iTargetIndex]) - { - StopDisplayingHud(param1); - new Handle:hPanel = BuildPublicCheaterPanel(); - SendPanelToClient(hPanel, param1, Panel_PublicCheater, MENU_TIME_FOREVER); - CloseHandle(hPanel); - } - else - { - StopDisplayingHud(param1); - PrintToChat(param1, "\x03[SM-SPEC]\x01 %t", "Must Have Target"); - DisplayMenu(g_aMenus[hSelectPlayer], param1, MENU_TIME_FOREVER); - } - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_Interrupted) - { - if (GetClientMenu(param1) == MenuSource_External) - { - StopDisplayingHud(param1); - } - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } -} - -public Panel_PlayerHud(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - switch (param2) - { - case 1: - { - if (g_aPlayers[param1][iTargetIndex]) - { - StopFollowingPlayer(param1); - } - else - { - StopDisplayingHud(param1); - DisplayMenu(BuildSelectPlayerMenu(), param1, MENU_TIME_FOREVER); - } - } - case 2: - { - if (!g_aPlayers[param1][iTargetIndex]) - { - StopDisplayingHud(param1); - PrintToChat(param1, "\x03[SM-SPEC]\x01 %t", "Must Have Target"); - DisplayMenu(g_aMenus[hSelectPlayer], param1, MENU_TIME_FOREVER); - return; - } - - if ((GetUserFlagBits(param1) & ADMFLAG_GENERIC) || (GetUserFlagBits(param1) & ADMFLAG_ROOT)) - { - if (g_aPlayers[g_aPlayers[param1][iTargetIndex]][bIsFlaggedCheater] && (GetUserFlagBits(param1) & ADMFLAG_ROOT)) - { - //Remove cheater flag - g_aPlayers[g_aPlayers[param1][iTargetIndex]][bIsFlaggedCheater] = false; - } - else - { - //Punish menu - StopDisplayingHud(param1); - DisplayMenu(BuildPunishmentMenu(param1), param1, MENU_TIME_FOREVER); - } - } - else - { - //Report Cheater - new Handle:hPanel = BuildPublicCheaterPanel(); - SendPanelToClient(hPanel, param1, Panel_PublicCheater, MENU_TIME_FOREVER); - CloseHandle(hPanel); - } - } - case 3: - { - StopDisplayingHud(param1); - } - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_Interrupted) - { - if (GetClientMenu(param1) == MenuSource_External) - { - StopDisplayingHud(param1); - } - } - } -} - - -/** -Stock functions -*/ -stock StartFollowingPlayer(client, target) -{ - - /** - If we have an open timer, close it. - */ - if (g_aPlayers[client][hTargetTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[client][hTargetTimer]); - g_aPlayers[client][hTargetTimer] = INVALID_HANDLE; - } - - /** - Make sure the target is on a non spectator team, and the client != target - */ - if (client == target) - { - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Yourself"); - return; - } - new iTargetTeam = GetClientTeam(target); - if (iTargetTeam == g_aCurrentTeams[Spectator] || iTargetTeam == g_aCurrentTeams[Unknown]) - { - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Spectator"); - return; - } - - /** - Check to see if client is already a spectator - */ - if (GetClientTeam(client) != g_aCurrentTeams[Spectator]) - { - - /** - Client is not a spectator, lets move them to spec. - */ - SM_MovePlayer(client, g_aCurrentTeams[Spectator]); - } - - /** - If we are using steambans call sb_status - */ - if (g_aPluginSettings[bUseSteamBans]) - { - FakeClientCommandEx(client, "sb_status"); - } - - - /** - Set the global and start to spectate the target. - Making sure it's long enough to deal with moving the client to spec if we had to. - */ - new String:sTargetName[MAX_NAME_LENGTH + 1]; - GetClientName(target, sTargetName, sizeof(sTargetName)); - g_aPlayers[client][iTargetIndex] = target; - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Spectating", sTargetName); - g_aPlayers[client][hTargetTimer] = CreateTimer(0.5, Timer_ResetTarget, client, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); - if (!g_aPlayers[client][bIsDisplayingHud] && GetClientTeam(client) == g_aCurrentTeams[Spectator]) - { - StartDisplayingHud(client); - } -} - -stock StopFollowingPlayer(client) -{ - - /** - If we have an open timer, close it. - */ - if (g_aPlayers[client][hTargetTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[client][hTargetTimer]); - } - - /** - Tell the client we can't spec his target anymore... if they are in game. - */ - if (IsClientInGame(client) && g_aPlayers[client][iTargetIndex] != 0) - { - new String:sTargetName[MAX_NAME_LENGTH + 1]; - GetClientName(g_aPlayers[client][iTargetIndex], sTargetName, sizeof(sTargetName)); - if (!IsClientConnected(g_aPlayers[client][iTargetIndex]) || !IsClientInGame(g_aPlayers[client][iTargetIndex])) - { - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Target Left"); - } - else - { - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Stopped spectating", sTargetName); - } - } - - /** - Null the globals. - */ - g_aPlayers[client][iTargetIndex] = 0; - g_aPlayers[client][hTargetTimer] = INVALID_HANDLE; -} - -stock StartDisplayingHud(client) -{ - if (g_aPluginCvarSettings[bRestrictHud] && !SM_IsValidAdmin(client, g_sAdminFlags)) - { - return; - } - else - { - /** - Double check the hud timer - We should not have one, but if we do, lets cancel it for the current callback - */ - StopDisplayingHud(client); - - /** - Now we can safely display the hud and make sure the current stored handle is the current timer - */ - g_aPlayers[client][bIsDisplayingHud] = true; - g_aPlayers[client][hHudTimer] = CreateTimer(0.5, Timer_UpdateHud, client, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); - } -} - -stock StopDisplayingHud(client) -{ - if (g_aPlayers[client][hHudTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[client][hHudTimer]); - } - g_aPlayers[client][hHudTimer] = INVALID_HANDLE; - g_aPlayers[client][bIsDisplayingHud] = false; -} - -stock ResetClient(client) -{ - StopFollowingPlayer(client); - StopDisplayingHud(client); - - g_aPlayers[client][bIsFlaggedCheater] = false; - g_aPlayers[client][TargetPunishment] = Punish_None; - g_aPlayers[client][iBanTime] = -1; -} - -stock PerformPunishment(client, target, e_Punishments:punishment, const String:reason[], time = 300) -{ - new String:sTargetName[MAX_NAME_LENGTH + 1], - String:sTargetID[64]; - - /** - The target could have left the game by the time we get here - Check for a valid target - */ - if (!IsClientConnected(target) || !IsClientInGame(target)) - { - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Target Left"); - return; - } - - GetClientName(target, sTargetName, sizeof(sTargetName)); - GetClientAuthString(target, sTargetID, sizeof(sTargetID)); - - switch (punishment) - { - case Punish_Kick: - { - KickClient(g_aPlayers[client][iTargetIndex], "%s", reason); - } - case Punish_Ban: - { - if (g_aPluginSettings[bUseSourceBans]) - { - ClientCommand(client, "sm_ban #%d %d \"%s\"", GetClientUserId(target), time, reason); - } - else if (g_aPluginSettings[bUseMySQLBans]) - { - ClientCommand(client, "mysql_ban #%d %d \"%s\"", GetClientUserId(target), time, reason); - } - else - { - BanClient(target, time, BANFLAG_AUTHID, reason, reason); - } - } - case Punish_Cheater: - { - g_aPlayers[target][bIsFlaggedCheater] = true; - } - case Punish_Beacon: - { - ClientCommand(client, "sm_beacon \"%s\"", sTargetName); - } - case Punish_Blind: - { - ClientCommand(client, "sm_blind \"%s\"", sTargetName); - } - case Punish_Drug: - { - ClientCommand(client, "sm_drug \"%s\"", sTargetName); - } - case Punish_Freeze: - { - ClientCommand(client, "sm_freeze \"%s\"", sTargetName); - } - case Punish_FreezeBomb: - { - ClientCommand(client, "sm_freezebomb \"%s\"", sTargetName); - } - case Punish_Slap: - { - ClientCommand(client, "sm_slap \"%s\" 10", sTargetName); - } - case Punish_Slay: - { - ClientCommand(client, "sm_slay \"%s\"", sTargetName); - } - case Punish_TimeBomb: - { - ClientCommand(client, "sm_timebomb \"%s\"", sTargetName); - } - } - - if (punishment == Punish_Cheater) - { - LogAction(client, target, "[SM SPEC] %N marked %N(%s) with a %s flag for %s", client, target, sTargetID, g_sPunishments[punishment], reason); - } - else - { - ShowActivity(client, "%t", "Punished", sTargetName, g_sPunishments[punishment], reason); - LogAction(client, target, "[SM SPEC] %N punished %N(%s) with a %s for %s", client, target, sTargetID, g_sPunishments[punishment], reason); - } - - /** - Null the globals. - */ - g_aPlayers[client][TargetPunishment] = Punish_None; - g_aPlayers[client][iBanTime] = -1; -} - -/** -Build the menu of player names -*/ -stock Handle:BuildPlayerListMenu() -{ - new Handle:hMenu = CreateMenu(Menu_PlayerList); - AddTargetsToMenu(hMenu, 0, true, false); - SetMenuTitle(hMenu, "Select A Player:"); - SetMenuExitBackButton(hMenu, true); - return hMenu; -} - -/** -Build the select player menu (current or list of players) -*/ -stock Handle:BuildSelectPlayerMenu() -{ - new Handle:hMenu = CreateMenu(Menu_SelectPlayer); - SetMenuTitle(hMenu, "Select A Player:"); - AddMenuItem(hMenu, "Current", "Current Target"); - AddMenuItem(hMenu, "List", "Player List"); - SetMenuExitBackButton(hMenu, true); - return hMenu; -} - -/** -Build the punishmenu menu -*/ -stock Handle:BuildPunishmentMenu(iClient) -{ - new Handle:hMenu = CreateMenu(Menu_Punishments); - SetMenuTitle(hMenu, "Select A Punishment:"); - SetMenuExitBackButton(hMenu, true); - SetMenuExitButton(hMenu, true); - - if (g_aPluginCvarSettings[bKick] && ((GetUserFlagBits(iClient) & ADMFLAG_GENERIC) || (GetUserFlagBits(iClient) & ADMFLAG_ROOT))) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Kick], "Kick"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Kick], "Kick", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bBan] && ((GetUserFlagBits(iClient) & ADMFLAG_GENERIC) || (GetUserFlagBits(iClient) & ADMFLAG_ROOT))) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Ban], "Ban"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Ban], "Ban", ITEMDRAW_DISABLED); - } - - if (g_aPluginSettings[bUseDukehacks] && g_aPluginCvarSettings[bCheater] && (GetUserFlagBits(iClient) & ADMFLAG_ROOT)) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Cheater], "Flag As Cheater"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Cheater], "Flag As Cheater", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bBeacon]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Beacon], "Beacon"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Beacon], "Beacon", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bBlind]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Blind], "Blind"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Blind], "Blind", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bDrug]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Drug], "Drug"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Drug], "Drug", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bFreeze]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Freeze], "Freeze"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Freeze], "Freeze", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bFreezebomb]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_FreezeBomb], "Freeze Bomb"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_FreezeBomb], "Freeze Bomb", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bSlap]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Slap], "Slap"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Slap], "Slap", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bSlay]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Slay], "Slay"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Slay], "Slay", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bTimeBomb]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_TimeBomb], "Time Bomb"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_TimeBomb], "Time Bomb", ITEMDRAW_DISABLED); - } - - return hMenu; -} - -/** -Build the punishmenu menu -*/ -stock Handle:BuildBanTimeMenu() -{ - new Handle:hMenu = CreateMenu(Menu_BanTime); - SetMenuTitle(hMenu, "Select Ban Type:"); - - if (g_aPluginCvarSettings[bBanPerm]) - { - AddMenuItem(hMenu, "permban", "Permanent"); - } - else - { - AddMenuItem(hMenu, "permban", "Permanent", ITEMDRAW_DISABLED); - } - - AddMenuItem(hMenu, "10", "10 Minutes"); - AddMenuItem(hMenu, "30", "30 Minutes"); - AddMenuItem(hMenu, "60", "1 Hour"); - AddMenuItem(hMenu, "240", "4 Hours"); - AddMenuItem(hMenu, "1440", "1 Day"); - AddMenuItem(hMenu, "10080", "1 Week"); - - SetMenuExitBackButton(hMenu, true); - return hMenu; -} - -/** -Build the punishmenu menu -*/ -stock Handle:BuildReasonMenu() -{ - new Handle:hMenu = CreateMenu(Menu_Reason); - SetMenuTitle(hMenu, "Select A Reason:"); - - AddMenuItem(hMenu, "Abusive", "Abusive"); - AddMenuItem(hMenu, "Racism", "Racism"); - AddMenuItem(hMenu, "General cheating/exploits", "General cheating/exploits"); - AddMenuItem(hMenu, "Wallhack", "Wallhack"); - AddMenuItem(hMenu, "Aimbot", "Aimbot"); - AddMenuItem(hMenu, "Speedhacking", "Speedhacking"); - AddMenuItem(hMenu, "Mic spamming", "Mic spamming"); - AddMenuItem(hMenu, "Admin disrepect", "Admin disrepect"); - AddMenuItem(hMenu, "Camping", "Camping"); - AddMenuItem(hMenu, "Team killing", "Team killing"); - AddMenuItem(hMenu, "Unacceptable Spray", "Unacceptable Spray"); - AddMenuItem(hMenu, "Breaking Server Rules", "Breaking Server Rules"); - AddMenuItem(hMenu, "Other", "Other"); - - SetMenuExitBackButton(hMenu, true); - return hMenu; -} - -/** -Build the cheater displays -*/ -stock Handle:BuildAdminCheaterPanel() -{ - - /** - Create the menu and set the menu options. - */ - new Handle:hPanel = CreatePanel(); - SetPanelTitle(hPanel, "Simple Spectator:"); - - DrawPanelText(hPanel, "Are you sure you want to"); - DrawPanelText(hPanel, "flag this player as a cheater?"); - DrawPanelText(hPanel, "They will not be able to damage"); - DrawPanelText(hPanel, "anyone and die on fall damage."); - DrawPanelItem(hPanel, "Yes"); - DrawPanelItem(hPanel, "No"); - - return hPanel; -} - -stock Handle:BuildPublicCheaterPanel() -{ - - /** - Create the menu and set the menu options. - */ - new Handle:hPanel = CreatePanel(); - SetPanelTitle(hPanel, "Simple Spectator:"); - - DrawPanelText(hPanel, "Are you sure you want to"); - DrawPanelText(hPanel, "submit this player as a cheater?"); - DrawPanelItem(hPanel, "Yes (Not Implemented Yet)", ITEMDRAW_DISABLED); - DrawPanelItem(hPanel, "No"); - return hPanel; -} - -/** -Build the hud displays -*/ -stock Handle:BuildPlayerHudMenu(iClient, iTarget) -{ - - /** - Create all the string variables we will need - */ - new String:sTargetName[MAX_NAME_LENGTH + 1], - String:sTargetID[64], - String:sTargetIP[16]; - - new String:sDisplayName[MAX_NAME_LENGTH + 1], - String:sDisplayID[64], - String:sDisplayIP[64], - String:sDisplayFrags[16], - String:sDisplayDeaths[16]; - - new iTargetFrags, - iTargetDeaths; - - /** - Get the targets information - */ - GetClientName(iTarget, sTargetName, sizeof(sTargetName)); - GetClientIP(iTarget, sTargetIP, sizeof(sTargetIP)); - GetClientAuthString(iTarget, sTargetID, sizeof(sTargetID)); - iTargetFrags = GetClientFrags(iTarget); - iTargetDeaths = GetClientDeaths(iTarget); - - /** - Format the strings for the menu - */ - Format(sDisplayName, sizeof(sDisplayName), "Player: %s", sTargetName); - Format(sDisplayID, sizeof(sDisplayID), "Steam ID: %s", sTargetID); - Format(sDisplayIP, sizeof(sDisplayIP), "IP Address: %s", sTargetIP); - Format(sDisplayFrags, sizeof(sDisplayFrags), "Kills: %i", iTargetFrags); - Format(sDisplayDeaths, sizeof(sDisplayDeaths), "Deaths: %i", iTargetDeaths); - - /** - Create the menu and set the menu options. - */ - new Handle:hMenu = CreateMenu(Menu_PlayerHud); - SetMenuExitBackButton(hMenu, false); - SetMenuTitle(hMenu, "Simple Spectator"); - - AddMenuItem(hMenu, "name", sDisplayName, ITEMDRAW_DISABLED); - AddMenuItem(hMenu, "steamid", sDisplayID, ITEMDRAW_DISABLED); - - if (SM_IsValidAdmin(iClient, g_sAdminFlags)) - { - AddMenuItem(hMenu, "ip", sDisplayIP, ITEMDRAW_DISABLED); - } - - AddMenuItem(hMenu, "kills", sDisplayFrags, ITEMDRAW_DISABLED); - AddMenuItem(hMenu, "deaths", sDisplayDeaths, ITEMDRAW_DISABLED); - - if (g_aPlayers[iClient][iTargetIndex]) - { - AddMenuItem(hMenu, "stop", "Stop Following"); - } - else - { - AddMenuItem(hMenu, "start", "Follow Player"); - } - - if ((GetUserFlagBits(iClient) & ADMFLAG_GENERIC) || (GetUserFlagBits(iClient) & ADMFLAG_ROOT)) - { - if (g_aPlayers[iTarget][bIsFlaggedCheater] && (GetUserFlagBits(iClient) & ADMFLAG_ROOT)) - { - AddMenuItem(hMenu, "removecheater", "Remove Cheater Flag"); - } - else - { - if (CanUserTarget(iClient, iTarget)) - { - AddMenuItem(hMenu, "punish", "Punish Player"); - } - else - { - AddMenuItem(hMenu, "punish", "Punish Player (Immune)", ITEMDRAW_DISABLED); - } - } - } - else - { - AddMenuItem(hMenu, "reportcheater", "Report Cheater"); - } - - SetMenuPagination(hMenu, MENU_NO_PAGINATION); - SetMenuExitButton(hMenu, true); - return hMenu; -} - -stock Handle:BuildPlayerHudPanel(iClient, iTarget) -{ - - /** - Create all the string variables we will need - */ - new String:sTargetName[MAX_NAME_LENGTH + 1], - String:sTargetID[64], - String:sTargetIP[16]; - - new String:sDisplayName[MAX_NAME_LENGTH + 1], - String:sDisplayID[64], - String:sDisplayIP[64], - String:sDisplayFrags[16], - String:sDisplayDeaths[16]; - - new iTargetFrags, - iTargetDeaths; - - /** - Get the targets information - */ - GetClientName(iTarget, sTargetName, sizeof(sTargetName)); - GetClientIP(iTarget, sTargetIP, sizeof(sTargetIP)); - GetClientAuthString(iTarget, sTargetID, sizeof(sTargetID)); - iTargetFrags = GetClientFrags(iTarget); - iTargetDeaths = GetClientDeaths(iTarget); - - /** - Format the strings for the menu - */ - Format(sDisplayName, sizeof(sDisplayName), "Player: %s", sTargetName); - Format(sDisplayID, sizeof(sDisplayID), "Steam ID: %s", sTargetID); - Format(sDisplayIP, sizeof(sDisplayIP), "IP Address: %s", sTargetIP); - Format(sDisplayFrags, sizeof(sDisplayFrags), "Kills: %i", iTargetFrags); - Format(sDisplayDeaths, sizeof(sDisplayDeaths), "Deaths: %i", iTargetDeaths); - - /** - Create the menu and set the menu options. - */ - new Handle:hPanel = CreatePanel(); - SetPanelTitle(hPanel, "Simple Spectator"); - - DrawPanelText(hPanel, "Player Information:"); - DrawPanelText(hPanel, sDisplayName); - DrawPanelText(hPanel, sDisplayID); - if (SM_IsValidAdmin(iClient, g_sAdminFlags)) - { - DrawPanelText(hPanel, sDisplayIP); - } - - DrawPanelText(hPanel, sDisplayFrags); - DrawPanelText(hPanel, sDisplayDeaths); - - if (g_aPlayers[iClient][iTargetIndex]) - { - DrawPanelItem(hPanel, "Stop Following"); - } - else - { - DrawPanelItem(hPanel, "Follow Player"); - } - - if ((GetUserFlagBits(iClient) & ADMFLAG_GENERIC) || (GetUserFlagBits(iClient) & ADMFLAG_ROOT)) - { - if (g_aPlayers[iTarget][bIsFlaggedCheater] && (GetUserFlagBits(iClient) & ADMFLAG_ROOT)) - { - DrawPanelItem(hPanel, "Remove Cheater Flag"); - } - else - { - if (CanUserTarget(iClient, iTarget)) - { - DrawPanelItem(hPanel, "Punish Player"); - } - else - { - DrawPanelItem(hPanel, "Punish Player (Immune)", ITEMDRAW_DISABLED); - } - } - } - else - { - DrawPanelItem(hPanel, "Report Cheater"); - } - - DrawPanelItem(hPanel, "Close Hud Panel"); - return hPanel; -} - -/** -Adjust the settings if a convar was changed -*/ -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - for (new iCvar = 0 ; _:iCvar < sizeof(g_aPluginCvarSettings); iCvar++) - { - if (g_aPluginCvar[_:iCvar] == convar) - { - if (StringToInt(newValue) == 1) - { - g_aPluginCvarSettings[_:iCvar] = true; - } - else - { - g_aPluginCvarSettings[_:iCvar] = false; - } - } - } - - /* - ReBuild the global menu that depends on cvars - */ - g_aMenus[hBanTime] = BuildBanTimeMenu(); - - /** - Run a loop to reset the hud - */ - for(new i = 1; i <= MaxClients; i++) - { - StopDisplayingHud(i); - if (IsClientConnected(i) && IsClientInGame(i) && GetClientTeam(i) == g_aCurrentTeams[Spectator]) - { - StartDisplayingHud(i); - } - } -} diff --git a/Simple Team Manager/addons/sourcemod/scripting/simple-teambalancer.sp b/Simple Team Manager/addons/sourcemod/scripting/simple-teambalancer.sp deleted file mode 100644 index 3302255..0000000 --- a/Simple Team Manager/addons/sourcemod/scripting/simple-teambalancer.sp +++ /dev/null @@ -1,1797 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Team Balancer -Description: - Balances teams based upon player count - Player will not be balanced more than once in 5 (default) mins - Buddy system tries to keep buddies together - Ability to prioritize players - Ability to force players to accept the new team - Admins are immune -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include -#include - -#define PLUGIN_VERSION "2.1.$Rev$" - -enum PlayerData -{ - Handle:hBalanceTimer, - Handle:hForcedTimer, - bool:bSwitched, - bool:bFlagCarrier -}; - -/** - Global convar handles - */ -new Handle:stb_enabled = INVALID_HANDLE; -new Handle:stb_buddyenabled = INVALID_HANDLE; -new Handle:stb_logactivity = INVALID_HANDLE; -new Handle:stb_logactivity2 = INVALID_HANDLE; -new Handle:stb_unbalancelimit = INVALID_HANDLE; -new Handle:stb_deadonly = INVALID_HANDLE; -new Handle:stb_priorityenabled = INVALID_HANDLE; -new Handle:stb_uberlevel = INVALID_HANDLE; -new Handle:stb_balancedelay = INVALID_HANDLE; -new Handle:stb_livingplayerswitchdelay = INVALID_HANDLE; -new Handle:stb_livingplayercheckdelay = INVALID_HANDLE; -new Handle:stb_roundstartdelay = INVALID_HANDLE; -new Handle:stb_switchbackforced = INVALID_HANDLE; -new Handle:stb_adminflag = INVALID_HANDLE; -new Handle:stb_buddyrestriction = INVALID_HANDLE; -new Handle:stb_convarcontrol = INVALID_HANDLE; - -/** - Built-in cvars handles - */ -new Handle:stb_mp_autoteambalance = INVALID_HANDLE; -new Handle:stb_mp_teams_unbalance_limit = INVALID_HANDLE; -new Handle:TFGameModeArena = INVALID_HANDLE; - -/** - Timer handles - */ -new Handle:g_hBalanceTimer = INVALID_HANDLE; -new Handle:g_hLivingPlayerCheckTimer = INVALID_HANDLE; - -/** - Player arrays - */ -new g_aPlayers[MAXPLAYERS + 1][PlayerData]; - -/** -Global bools -*/ -new bool:g_bIsEnabled = true; -new bool:g_bPriorityPlayers = true; -new bool:g_bBuddyRestriction = false; -new bool:g_bLogActivity = false; -new bool:g_bLogActivity2 = false; -new bool:g_bDeadOnly = false; -new bool:g_bConVarControl = true; -new bool:g_bBuddyEnabled = true; -new bool:g_bBalanceInProgress = false; -new bool:g_bRoundStart = false; -new bool:g_bRoundEnd = false; -new bool:g_bSuddenDeath = false; -new bool:g_bIsArenaMode = false; - -/** - Global strings/integers/floats - */ -new g_iUnbalanceLimit, g_iLivingPlayerSwitchDelay, g_iLivingPlayerCheckDelay; -new g_iRoundStartDelay, g_iSwitchBackForced, g_iBalanceDelay; -new Float:g_fUberLevel; -new g_iOwnerOffset; -new String:g_sAdminFlag[5]; - -public Plugin:myinfo = -{ - name = "Simple Team Balancer", - author = "Simple Plugins", - description = "Balances teams based upon player count.", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -} - -public OnPluginStart() -{ - - /** - Create console variables - */ - CreateConVar("stb_version", PLUGIN_VERSION, "Simple Team Balancer", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - stb_enabled = CreateConVar("stb_enabled", "1", "Enable or Disable Simple Team Balancer", _, true, 0.0, true, 1.0); - stb_priorityenabled = CreateConVar("stb_priorityenabled", "1", "Enable or Disable the prioritization of living players", _, true, 0.0, true, 1.0); - stb_buddyrestriction = CreateConVar("stb_buddyrestriction", "0", "Enable or Disable Admin Only buddy lists", _, true, 0.0, true, 1.0); - stb_logactivity = CreateConVar("stb_logactivity", "0", "Enable or Disable the disaplying of events in the log", _, true, 0.0, true, 1.0); - stb_logactivity2 = CreateConVar("stb_logactivity2", "0", "Enable or Disable the disaplying of detailed events in the log (WILL SPAM LOG)", _, true, 0.0, true, 1.0); - stb_deadonly = CreateConVar("stb_deadonly", "0", "Enable or Disable the switching of only dead players", _, true, 0.0, true, 1.0); - stb_convarcontrol = CreateConVar("stb_convarcontrol", "1", "Enable or Disable the control of builtin console variables", _, true, 0.0, true, 1.0); - stb_buddyenabled = CreateConVar("stb_buddyenabled", "1", "Enable or Disable the buddy system", _, true, 0.0, true, 1.0); - stb_unbalancelimit = CreateConVar("stb_unbalancelimit", "2", "Amount of players teams are ALLOWED to be unbalanced by", _, true, 1.0, true, 32.0); - stb_balancedelay = CreateConVar("stb_balancedelay", "10", "Delay in seconds to start an autobalance"); - stb_livingplayerswitchdelay = CreateConVar("stb_livingplayerswitchdelay", "20", "Delay in seconds to switch living players once selected"); - stb_livingplayercheckdelay = CreateConVar("stb_livingplayercheckdelay", "10", "Delay in seconds to start checking living players once teams become unbalanced"); - stb_roundstartdelay = CreateConVar("stb_roundstartdelay", "15", "Delay in seconds to start balancing teams after the start of a round"); - stb_switchbackforced = CreateConVar("stb_switchbackforced", "300", "Amount of time in seconds to not switch a player twice and force the team if enabled"); - stb_uberlevel = CreateConVar("stb_uberlevel", "1.0", "Min uber level medic must have to have priority over other living players. Setting to 0 will rarely switch a living medic", _, true, 0.0, true, 1.0); - stb_adminflag = CreateConVar("stb_adminflag", "a", "Admin flag to use for immunity. Must be a in char format."); - stb_mp_autoteambalance = FindConVar("mp_autoteambalance"); - stb_mp_teams_unbalance_limit = FindConVar("mp_teams_unbalance_limit"); - - /** - Removing the notify tags from the built in cvars. We dont want spam. - */ - if (stb_mp_autoteambalance != INVALID_HANDLE) - { - SetConVarFlags(stb_mp_autoteambalance, GetConVarFlags(stb_mp_autoteambalance)^FCVAR_NOTIFY); - } - if (stb_mp_teams_unbalance_limit != INVALID_HANDLE) - { - SetConVarFlags(stb_mp_teams_unbalance_limit, GetConVarFlags(stb_mp_teams_unbalance_limit)^FCVAR_NOTIFY); - } - - /** - Hook console variables - */ - HookConVarChange(stb_enabled, ConVarSettingsChanged); - HookConVarChange(stb_priorityenabled, ConVarSettingsChanged); - HookConVarChange(stb_buddyrestriction, ConVarSettingsChanged); - HookConVarChange(stb_logactivity, ConVarSettingsChanged); - HookConVarChange(stb_logactivity2, ConVarSettingsChanged); - HookConVarChange(stb_deadonly, ConVarSettingsChanged); - HookConVarChange(stb_convarcontrol, ConVarSettingsChanged); - HookConVarChange(stb_buddyenabled, ConVarSettingsChanged); - HookConVarChange(stb_unbalancelimit, ConVarSettingsChanged); - HookConVarChange(stb_balancedelay, ConVarSettingsChanged); - HookConVarChange(stb_livingplayerswitchdelay, ConVarSettingsChanged); - HookConVarChange(stb_livingplayercheckdelay, ConVarSettingsChanged); - HookConVarChange(stb_roundstartdelay, ConVarSettingsChanged); - HookConVarChange(stb_switchbackforced, ConVarSettingsChanged); - HookConVarChange(stb_uberlevel, ConVarSettingsChanged); - HookConVarChange(stb_mp_autoteambalance, ConVarSettingsChanged); - HookConVarChange(stb_mp_teams_unbalance_limit, ConVarSettingsChanged); - - /** - Create console commands - */ - RegConsoleCmd("sm_buddy", Command_AddBalanceBuddy, "Add a balance buddy"); - RegConsoleCmd("sm_lockbuddy", Command_LockBuddy, "Locks your balance buddy selection"); - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook the game events - */ - LogAction(0, -1, "[STB] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_death", HookPlayerDeath, EventHookMode_Post); - HookEvent("player_team", HookPlayerChangeTeam, EventHookMode_Post); - switch (g_CurrentMod) - { - case GameType_TF: - { - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - HookEvent("teamplay_suddendeath_begin", HookSuddenDeathBegin, EventHookMode_PostNoCopy); - HookEvent("teamplay_flag_event", HookFlagEvent, EventHookMode_Post); - TFGameModeArena = FindConVar("tf_gamemode_arena"); - g_iOwnerOffset = FindSendPropInfo("CBaseObject", "m_hBuilder"); - } - case GameType_DOD: - { - HookEvent("dod_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_Post); - } - default: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - } - } - - /** - Load translations and .cfg file - */ - LoadTranslations ("simpleteambalancer.phrases"); - AutoExecConfig(true, "plugin.simpleteambalancer"); - LogAction(0, -1, "[STB] Simple Team Balancer is loaded."); -} - -public OnAllPluginsLoaded() -{ - //something -} - -public OnLibraryRemoved(const String:name[]) -{ - //something -} - -public OnConfigsExecuted() -{ - - /** - Load up global variables - */ - g_bIsEnabled = GetConVarBool(stb_enabled); - g_bBuddyEnabled = GetConVarBool(stb_buddyenabled); - g_bLogActivity = GetConVarBool(stb_logactivity); - g_bLogActivity2 = GetConVarBool(stb_logactivity2); - g_bDeadOnly = GetConVarBool(stb_deadonly); - g_bPriorityPlayers = GetConVarBool(stb_priorityenabled); - g_bBuddyRestriction = GetConVarBool(stb_buddyrestriction); - g_bConVarControl = GetConVarBool(stb_convarcontrol); - g_fUberLevel = GetConVarFloat(stb_uberlevel); - g_iUnbalanceLimit = GetConVarInt(stb_unbalancelimit); - g_iBalanceDelay = GetConVarInt(stb_balancedelay); - g_iLivingPlayerSwitchDelay = GetConVarInt(stb_livingplayerswitchdelay); - g_iLivingPlayerCheckDelay = GetConVarInt(stb_livingplayercheckdelay); - g_iRoundStartDelay = GetConVarInt(stb_roundstartdelay); - g_iSwitchBackForced = GetConVarInt(stb_switchbackforced); - GetConVarString(stb_adminflag, g_sAdminFlag, sizeof(g_sAdminFlag)); - - /** - Report enabled - */ - if (g_bIsEnabled) - { - LogAction(0, -1, "[STB] Simple Team Balancer is ENABLED."); - } - else - { - LogAction(0, -1, "[STB] Simple Team Balancer is DISABLED."); - } - - - /** - Report log activity - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Log Activity ENABLED."); - } - else - { - LogAction(0, -1, "[STB] Log Activity DISABLED."); - } - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Detailed Log Activity ENABLED."); - } - else - { - LogAction(0, -1, "[STB] Detailed Log Activity DISABLED."); - } -} - -public OnMapStart() -{ - - /** - Check for arena mode - */ - if (g_CurrentMod == GameType_TF && GetConVarBool(TFGameModeArena)) - { - g_bIsArenaMode = true; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Simple Team Balancer detected arena mode and will be bypassed"); - } - } - else - { - g_bIsArenaMode = false; - } - - /** - Reset the globals - */ - g_bBalanceInProgress = false; - g_bRoundStart = false; - g_bRoundEnd = false; - g_bSuddenDeath = false; - - /** - Set the built-in convars - */ - SetGameCvars(); -} - -public OnClientPostAdminCheck(client) -{ - - /** - Make sure its a valid connected client and buddy system is enabled - */ - if (client == 0 || !g_bIsEnabled || !IsClientConnected(client) || !g_bBuddyEnabled) - { - return; - } - - /** - Make sure if its set for admins only they have the flags - */ - if (g_bBuddyRestriction && !SM_IsValidAdmin(client, g_sAdminFlag)) - { - return; - } - - /** - Start the advertisement timer - */ - CreateTimer (60.0, Timer_WelcomeAdvert, client); -} - -public OnClientDisconnect(client) -{ - - /** - Call stock function to cleaup - */ - CleanUp(client); -} - -public OnClientDisconnect_Post(client) -{ - - /** - Determine if we need a balance - */ - if (OkToBalance() && IsUnbalanced() && !g_bBalanceInProgress) - { - - /** - No balance in progress but balance is needed - */ - StartABalance(); - } -} - -public SM_OnPlayerMoved(Handle:plugin, client, team) -{ - - /** - Make sure we called the move function - */ - if (plugin != GetMyHandle()) - { - if (g_bLogActivity2) - { - LogAction(0, client, "[STB] Callback was not started with current plugin, bugging out."); - } - return; - } - - /** - Get the players name and report the event - */ - decl String:sPlayerName[64]; - GetClientName(client, sPlayerName, sizeof(sPlayerName)); - if (g_bLogActivity) - { - LogAction(0, client, "[STB] Changed %s to team %i.", sPlayerName, team); - } - - /** - If we are in TF2 fire the bult-in team balance event - */ - if(g_CurrentMod == GameType_TF) - { - new Handle:event = CreateEvent("teamplay_teambalanced_player"); - SetEventInt(event, "player", client); - SetEventInt(event, "team", team); - FireEvent(event); - } - - /** - Notify the players - */ - PrintToChatAll("[SM] %T", "BalanceMessage", LANG_SERVER, sPlayerName); - - /** - Set the players variables and start a timer - */ - g_aPlayers[client][bSwitched] = true; - g_aPlayers[client][hForcedTimer] = CreateTimer(float(g_iSwitchBackForced), Timer_ForcedExpired, client, TIMER_FLAG_NO_MAPCHANGE); - - /** - We are done, log the completion and end the balance - */ - if (g_bLogActivity) - { - LogAction(0, client, "[STB] Balance finished."); - } - g_bBalanceInProgress = false; -} - -/* HOOKED EVENTS */ - -public HookPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get our event variables - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - decl String:sWeapon[64]; - GetEventString(event, "weapon", sWeapon, sizeof(sWeapon)); - - /** - Return if death was not caused by a player - This is the case when the player switches teams - */ - if (StrEqual(sWeapon, "world", false)) - { - return; - } - - - /** - Check if balance is needed - */ - if (IsClientInGame(iClient) && OkToBalance() && IsUnbalanced()) - { - new iSmallerTeam = GetSmallerTeam(); - - /** - Check if balance is in progress - */ - if (g_bBalanceInProgress) - { - - /** - There is a balance in progress - Check the player who died to see if he is supposed to be switched - */ - if (g_aPlayers[iClient][hBalanceTimer] != INVALID_HANDLE) - { - - /** - The player has a timer on him to switch him to other team - Stop the timer - */ - CloseHandle(g_aPlayers[iClient][hBalanceTimer]); - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - if (g_bLogActivity) - { - LogAction(0, iClient, "[STB] With a balance in progress the queued living player died and was switched."); - } - - /** - Call the stock change team function - */ - BalancePlayer(iClient, SM_GetForcedTeam(iClient)); - return; - } - - /** - Before we continue, lets make sure the client is switchable - */ - if (IsSwitchablePlayer(iClient, GetBiggerTeam())) - { - - /** - Now we check the buddy system - */ - if (g_bBuddyEnabled) - { - - /** - Buddy system is enabled, check to see if client has buddy - */ - new iBuddyIndex = SM_GetClientBuddy(iClient); - if (iBuddyIndex != 0 || !IsClientConnected(iBuddyIndex) || !IsClientInGame(iBuddyIndex)) - { - - /** - The client has a buddy, so we check to see if they are on same team - */ - if (GetClientTeam(iClient) == GetClientTeam(iBuddyIndex)) - { - - /** - They are, but we don't bug out, we still need to start a balance - */ - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] With a balance in progress a buddy on the right team was found and skipped."); - } - } - else - { - - /** - They are not on the same team - The buddy could be in spec, and that would make it not matter where he is, or the buddy is on the smaller team - */ - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] With a balance in progress a buddy on the wrong team was switched."); - } - BalancePlayer(iClient, iSmallerTeam); - return; - } - } - else - { - - /** - Client doesn't have a buddy, balance this player - */ - BalancePlayer(iClient, iSmallerTeam); - return; - } - } - else - { - - /** - Buddy system is not enabled, balance this player - */ - BalancePlayer(iClient, iSmallerTeam); - return; - } - } - } - else - { - - /** - If we get to here then we must need to start a balance - */ - StartABalance(); - } - } -} - -public HookPlayerChangeTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get our event variables. - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - new iTeam = GetEventInt(event, "team"); - - /** - Make sure its ok to balance. - */ - if (OkToBalance()) - { - - /** - See if the client that changed teams was set to with a balance. - */ - if (g_aPlayers[iClient][hBalanceTimer] != INVALID_HANDLE - && SM_GetForcedTeam(iClient) == iTeam - && g_bBalanceInProgress) - { - - /** - The client was set to be balanced, so we close the timer. - */ - CloseHandle(g_aPlayers[iClient][hBalanceTimer]); - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - - /** - Stop the balance. - */ - g_bBalanceInProgress = false; - return; - } - - /** - It's not likely that this team change can cause us to need a balance. - If it does, start one with a small dealy to deal with forced switch backs. - */ - if (IsUnbalanced() && !g_bBalanceInProgress) - { - CreateTimer(2.0, Timer_ChangeTeamBalanceDelay, _, TIMER_FLAG_NO_MAPCHANGE); - } - } -} - -public HookRoundStart(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Set the variables we need to start a round - */ - g_bRoundStart = true; - g_bRoundEnd = false; - g_bSuddenDeath = false; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Round Started"); - } - - /** - Start a delayed balance check at the start of the round - */ - CreateTimer(float(g_iRoundStartDelay), Timer_RoundStart); -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Set the variables we need at round end - */ - g_bRoundEnd = true; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Round Ended"); - } -} - -public HookSuddenDeathBegin(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Set the variables we need for sudden death - */ - g_bSuddenDeath = true; -} - -public HookFlagEvent(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get our event variables - */ - new iClient = GetEventInt(event, "player"); - new iFlagStatus = GetEventInt(event, "eventtype"); - - /** - Make sure we have a valid client - */ - if (!IsClientInGame(iClient)) - { - return; - } - - /** - Determine what kind of event this is - */ - switch (iFlagStatus) - { - case 1: - { - - /** - The flag was picked up - */ - g_aPlayers[iClient][bFlagCarrier] = true; - } - case 2: - { - - /** - The flag was capped - */ - g_aPlayers[iClient][bFlagCarrier] = false; - } - case 3: - { - - /** - The flag was defended, we don't have to do anything - */ - } - case 4: - { - - /** - The flag was dropped - */ - g_aPlayers[iClient][bFlagCarrier] = false; - } - } -} - -/* COMMAND EVENTS */ - -public Action:Command_AddBalanceBuddy(client, args) -{ - if (client == 0) - { - ReplyToCommand(client, "[SM] %T", "PlayerLevelCmd", LANG_SERVER); - return Plugin_Handled; - } - if (!g_bIsEnabled || !g_bBuddyEnabled) - { - ReplyToCommand(client, "[SM] %T", "CmdDisabled", LANG_SERVER); - return Plugin_Handled; - } - if (g_bBuddyRestriction) - { - if (!SM_IsValidAdmin(client, g_sAdminFlag)) - { - ReplyToCommand(client, "[SM] %T", "RestrictedBuddy", LANG_SERVER); - return Plugin_Handled; - } - } - decl String:sPlayerUserId[24]; - GetCmdArg(1, sPlayerUserId, sizeof(sPlayerUserId)); - new iPlayer = GetClientOfUserId(StringToInt(sPlayerUserId)); - if (!iPlayer || !IsClientInGame(iPlayer) || client == iPlayer) - { - if (client == iPlayer) - { - PrintHintText(client, "%T", "SelectSelf", LANG_SERVER); - } - ReplyToCommand(client, "[SM] Usage: buddy "); - new Handle:playermenu = BuildPlayerMenu(); - DisplayMenu(playermenu, client, MENU_TIME_FOREVER); - } - else - { - decl String:cName[128]; - decl String:bName[128]; - GetClientName(client, cName, sizeof(cName)); - GetClientName(iPlayer, bName, sizeof(bName)); - if (SM_IsBuddyLocked(iPlayer)) - { - ReplyToCommand(client, "[SM] %T", "PlayerLockedBuddyMsg", LANG_SERVER, bName); - return Plugin_Handled; - } - SM_AssignBuddy(client, iPlayer); - PrintHintText(client, "%T", "BuddyMsg", LANG_SERVER, bName); - PrintHintText(iPlayer, "%T", "BuddyMsg", LANG_SERVER, cName); - } - return Plugin_Handled; -} - -public Action:Command_LockBuddy(client, args) -{ - if (client == 0) - { - ReplyToCommand(client, "[SM] %T", "PlayerLevelCmd", LANG_SERVER); - return Plugin_Handled; - } - if (!g_bIsEnabled) - { - ReplyToCommand(client, "[SM] %T", "CmdDisabled", LANG_SERVER); - return Plugin_Handled; - } - if (g_bBuddyRestriction) - { - if (!SM_IsValidAdmin(client, g_sAdminFlag)) - { - ReplyToCommand(client, "[SM] %T", "RestrictedBuddy", LANG_SERVER); - return Plugin_Handled; - } - } - if (SM_IsBuddyLocked(client)) - { - SM_LockBuddy(client, false); - PrintHintText(client, "%T", "BuddyLockMsgDisabled", LANG_SERVER); - } - else - { - SM_LockBuddy(client, true); - PrintHintText(client, "%T", "BuddyLockMsgEnabled", LANG_SERVER); - } - return Plugin_Handled; -} - -/** -Stock functions . - */ - -stock bool:IsUnbalanced() -{ - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Checking if teams are unbalanced"); - } - new Team1Count = GetTeamClientCount(g_aCurrentTeams[Team1]); - new Team2Count = GetTeamClientCount(g_aCurrentTeams[Team2]); - new ubCount = RoundFloat(FloatAbs(float(Team1Count - Team2Count))); - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Team1:%i Team2:%i Difference:%i", Team1Count, Team2Count, ubCount); - } - if (ubCount > g_iUnbalanceLimit) - { - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Teams are unbalanced"); - } - return true; - } - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Teams are not unbalanced"); - } - return false; -} - -stock bool:OkToBalance() -{ - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Checking if OK to balance."); - } - new bool:bResult = false; - if (g_bIsEnabled && !g_bRoundStart && !g_bRoundEnd && !g_bIsArenaMode && !g_bSuddenDeath) - { - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Passed IF statement"); - LogAction(0, -1, "[STB] Now checking admins"); - } - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientInGame(i) && !SM_IsValidAdmin(i, g_sAdminFlag)) - { - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Found at least 1 non-admin"); - LogAction(0, -1, "[STB] OK to balance"); - } - bResult = true; - break; - } - } - if (!bResult && g_bLogActivity2) - { - LogAction(0, -1, "[STB] All admins online"); - } - } - if (!bResult && g_bLogActivity2) - { - LogAction(0, -1, "[STB] Not OK to balance"); - } - return bResult; -} - -stock bool:IsSwitchablePlayer(iClient, iBiggerTeam) -{ - - /** - Run the client thru some standard checks - */ - if (!IsClientInGame(iClient) - || SM_IsValidAdmin(iClient, g_sAdminFlag) - || g_aPlayers[iClient][bFlagCarrier] - || GetClientTeam(iClient) != iBiggerTeam - || g_aPlayers[iClient][bSwitched]) - { - - /** - The supplied client can't be switched - */ - return false; - } - - /** - The supplied client can be switched - */ - return true; -} - -stock bool:HasUber(iClient) -{ - - /** - First things first, make sure the client is a medic - */ - if(TF2_GetPlayerClass(iClient) == TFClass_Medic) - { - - /** - We can only check the active weapon, so make sure the client is holding the uber gun - */ - decl String:sWeaponName[32]; - GetClientWeapon(iClient, sWeaponName, sizeof(sWeaponName)); - if(StrEqual(sWeaponName, "tf_weapon_medigun")) - { - - /** - They are, so lets check the uber level of the gun - */ - new iEntityIndex = GetEntDataEnt2(iClient, FindSendPropInfo("CTFPlayer", "m_hActiveWeapon")); - new Float:fChargeLevel = GetEntDataFloat(iEntityIndex, FindSendPropInfo("CWeaponMedigun", "m_flChargeLevel")); - if (fChargeLevel >= g_fUberLevel) - { - - /** - The client supplied has an uber above the supplied level, return true - */ - if (g_bLogActivity2) - { - LogAction(0, iClient, "[STB] Found a medic with a uber and skipped him."); - } - return true; - } - } - } - - /** - The client supplied does not have an uber above the supplied level, return false - */ - return false; -} - -stock bool:HasBuildingsBuilt(iClient) -{ - - /** - We have to start a loop to check the owner of all the valid entities - */ - new iMaxEntities = GetMaxEntities(); - for (new i = MaxClients + 1; i <= iMaxEntities; i++) - { - if (!IsValidEntity(i)) - { - - /** - Not valid, continue to next one - */ - continue; - } - - /** - Get the name of the current entity - */ - decl String:sNetClass[32]; - GetEntityNetClass(i, sNetClass, sizeof(sNetClass)); - - /** - See if its something that an engineer would build - */ - if (strcmp(sNetClass, "CObjectSentrygun") == 0 - || strcmp(sNetClass, "CObjectTeleporter") == 0 - || strcmp(sNetClass, "CObjectDispenser") == 0) - { - - /** - It is, so lets check the owner - */ - if (GetEntDataEnt2(i, g_iOwnerOffset) == iClient) - { - - /** - The client supplied is the owner, return true - */ - if (g_bLogActivity2) - { - LogAction(0, iClient, "[STB] Found an engineer with buildings and skipped him."); - } - return true; - } - } - } - - /** - The client supplied didn't have any buildings, return false - */ - return false; -} - -stock StartABalance() -{ - - /** - See if we are already started a balance - */ - if (g_hBalanceTimer != INVALID_HANDLE) - { - - /** - We have, check if we still need to - */ - if (!IsUnbalanced() || !OkToBalance()) - { - - /** - We don't, stop the balance - It's almost impossible to reach this code, but we do it just in case - */ - CloseHandle(g_hBalanceTimer); - g_hBalanceTimer = INVALID_HANDLE; - g_bBalanceInProgress = false; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Balance delay timer was not needed and was killed before the callback."); - } - return; - } - else - { - - /** - We still need to balance - Bug out and wait for the current one to finish - */ - return; - } - } - - /** - Report that teams are unbalanced - */ - PrintToChatAll("[SM] %T", "UnBalanced", LANG_SERVER); - - /** - Check to see if we are supposed to delay the balance - */ - if (g_iBalanceDelay == 0) - { - - /** - Start the balance now - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Balance is now in progress."); - } - g_bBalanceInProgress = true; - g_hBalanceTimer = INVALID_HANDLE; - - /** - Check if we are allowed to scan living players - */ - if (!g_bDeadOnly) - { - - /** - We are allowed to, so we start a timer - */ - StartALivingPlayerTimer(); - - /** - Also report that we are now scanning dead players as well - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Now scanning dead players."); - } - } - else - { - - /** - We are not allowed to, so report that we are only scanning dead players - */ - if (g_bLogActivity) - LogAction(0, -1, "[STB] Only scanning dead players."); - } - - /** - We started the balance, bug out - */ - return; - } - - /** - We are supposed to delay the balance, start a balance timer - */ - g_hBalanceTimer = CreateTimer(float(g_iBalanceDelay), Timer_BalanceTeams, _, TIMER_FLAG_NO_MAPCHANGE); - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Teams are unbalanced. Balance delay timer started."); - } -} - -stock StartALivingPlayerTimer() -{ - - /** - Start a timer to check living players - */ - if (g_hLivingPlayerCheckTimer != INVALID_HANDLE) - { - - /** - If we for some reason already have one started, stop it. - */ - CloseHandle(g_hLivingPlayerCheckTimer); - g_hLivingPlayerCheckTimer = INVALID_HANDLE; - } - - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Living player balance delay timer started."); - } - g_hLivingPlayerCheckTimer = CreateTimer(float(g_iLivingPlayerCheckDelay), Timer_LivingPlayerCheck, _, TIMER_FLAG_NO_MAPCHANGE); -} - -stock FindSwitchablePlayer() -{ - - /** - Start a loop to find a switchable player - */ - new iPlayer; - new iBiggerTeam = GetBiggerTeam(); - for (new i = 1; i <= MaxClients; i++) - { - - /** - Check the stock function to see if we are allows to even switch the player - */ - if (!IsSwitchablePlayer(i, iBiggerTeam)) - { - continue; - } - - /** - If the mod is TF2 and they have Priority Players set check if the client has buildings or an uber - */ - if (g_CurrentMod == GameType_TF && g_bPriorityPlayers) - { - if (HasUber(i) || HasBuildingsBuilt(i)) - { - continue; - } - } - - /** - So far we are able we switch this player - Now we check the buddy system - */ - if (g_bBuddyEnabled) - { - - /** - Buddy system is enabled, check to see if client has buddy - */ - if (SM_GetClientBuddy(i) != 0) - { - - /** - The client has a buddy, so we check to see if they are on same team - */ - if (GetClientTeam(i) == GetClientTeam(SM_GetClientBuddy(i))) - { - - /** - They are, so we continue to next client - */ - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] With a balance in progress a buddy on the right team was found and skipped."); - } - continue; - } - else - { - - /** - They are not on the same team, set this client - The buddy could be in spec, and that would make it not matter where he is, or the buddy is on the smaller team - */ - iPlayer = i; - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] With a balance in progress a buddy on the wrong team was found."); - } - break; - } - } - else - { - - /** - The client does not have a buddy, set this client - */ - iPlayer = i; - break; - } - } - else - { - - /** - Buddy system is not enabled, set this client - */ - iPlayer = i; - break; - } - } - - /** - Return the client we set, this could be 0, but very unlikely - */ - return iPlayer; -} - -stock BalancePlayer(iClient, iTeam) -{ - new Handle:hPack = CreateDataPack(); - WritePackCell(hPack, iClient); - WritePackCell(hPack, iTeam); - CreateTimer(0.1, Timer_BalancePlayer, hPack, TIMER_FLAG_NO_MAPCHANGE); -} - -stock CleanUp(iClient) -{ - g_aPlayers[iClient][bFlagCarrier] = false; - g_aPlayers[iClient][bSwitched] = false; - if (g_aPlayers[iClient][hForcedTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[iClient][hForcedTimer]); - g_aPlayers[iClient][hForcedTimer] = INVALID_HANDLE; - if (g_bLogActivity) - { - LogAction(0, iClient, "[STB] Forced player disconnected, killing timer."); - } - } - if (g_aPlayers[iClient][hBalanceTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[iClient][hBalanceTimer]); - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - if (g_bLogActivity) - { - LogAction(0, iClient, "[STB] Living player set to be balanced disconnected, killing timer."); - } - } -} - -stock GetSmallerTeam() -{ - - /** - Get the count of players on each team - */ - new iCountT1 = GetTeamClientCount(g_aCurrentTeams[Team1]); - new iCountT2 = GetTeamClientCount(g_aCurrentTeams[Team2]); - - /** - Return the smaller team - */ - if (iCountT1 < iCountT2) - { - return g_aCurrentTeams[Team1]; - } - else if (iCountT1 > iCountT2) - { - return g_aCurrentTeams[Team2]; - } - return 0; -} - -stock GetBiggerTeam() -{ - - /** - Get the count of players on each team - */ - new iCountT1 = GetTeamClientCount(g_aCurrentTeams[Team1]); - new iCountT2 = GetTeamClientCount(g_aCurrentTeams[Team2]); - - /** - Return the bigger team - */ - if (iCountT1 > iCountT2) - { - return g_aCurrentTeams[Team1]; - } - else if (iCountT1 < iCountT2) - { - return g_aCurrentTeams[Team2]; - } - return 0; -} - -stock SetGameCvars() -{ - if (g_bConVarControl && g_bIsEnabled) - { - if (stb_mp_autoteambalance != INVALID_HANDLE) - { - SetConVarInt(stb_mp_autoteambalance, 0); - } - if (stb_mp_teams_unbalance_limit != INVALID_HANDLE) - { - SetConVarInt(stb_mp_teams_unbalance_limit, g_iUnbalanceLimit); - } - } -} - -/* TIMER FUNCTIONS */ - -public Action:Timer_ChangeTeamBalanceDelay(Handle:timer, any:data) -{ - - /** - Finally start one if it's still unbalanced - */ - if (IsUnbalanced() && !g_bBalanceInProgress) - { - StartABalance(); - } -} - -public Action:Timer_BalanceTeams(Handle:timer, any:data) -{ - - /** - See if we still need to balance the teams - */ - if (!IsUnbalanced() || !OkToBalance()) - { - - /** - We don't, kill the balance - */ - g_bBalanceInProgress = false; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Balance delay timer was not needed and died."); - } - g_hBalanceTimer = INVALID_HANDLE; - return Plugin_Handled; - } - - /** - We still need to balance the teams - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Teams are still unbalanced. Balance is now in progress."); - } - g_bBalanceInProgress = true; - - - /** - Check if we are allowed to scan living players - */ - if (!g_bDeadOnly) - { - - /** - We are allowed to, so we start a timer - */ - StartALivingPlayerTimer(); - - /** - Also report that we are now scanning dead players as well - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Now scanning dead players."); - } - } - else - { - - /** - We are not allowed to, so report that we are only scanning dead players - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Only scanning dead players."); - } - } - - g_hBalanceTimer = INVALID_HANDLE; - return Plugin_Handled; -} - -public Action:Timer_LivingPlayerCheck(Handle:timer, any:data) -{ - - /** - Check to see if we still need to balance the teams - */ - if (!IsUnbalanced() || !OkToBalance()) - { - - /** - We don't, kill it and bug out - */ - g_bBalanceInProgress = false; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Living player balance delay timer was not needed and died."); - } - g_hLivingPlayerCheckTimer = INVALID_HANDLE; - return Plugin_Handled; - } - - /** - Call the stock function to find a player we can switch - */ - new iPlayer = FindSwitchablePlayer(); - - /** - Check to see if we found a player - */ - if (iPlayer == 0) - { - - /** - In the unlikely event that the stock function didn't return a player - Start a loop to find a random player - */ - new iBiggerTeam = GetBiggerTeam(); - do - { - iPlayer = GetRandomInt(1, MaxClients); - } while (!IsSwitchablePlayer(iPlayer, iBiggerTeam)); - - if (g_bLogActivity) - { - LogAction(0, iPlayer, "[STB] Found a random living player."); - } - } - else - { - if (g_bLogActivity) - { - LogAction(0, iPlayer, "[STB] Found a living player."); - } - } - - /** - Now that we have a player assigned them to the smaller team - */ - new iSmallerTeam = GetSmallerTeam(); - SM_SetForcedTeam(iPlayer, iSmallerTeam, true); - - /** - Let the player know we could be switching him soon - */ - PrintHintText(iPlayer, "%T", "PlayerMessage", LANG_SERVER, g_iLivingPlayerSwitchDelay); - if (g_bLogActivity) - { - LogAction(0, iPlayer, "[STB] Living player placed on a timer."); - } - - /** - Create a timer to switch the player - */ - g_aPlayers[iPlayer][hBalanceTimer] = CreateTimer(float(g_iLivingPlayerSwitchDelay), Timer_LivingPlayerBalance, iPlayer, TIMER_FLAG_NO_MAPCHANGE); - - /** - Reset the timer handle - */ - g_hLivingPlayerCheckTimer = INVALID_HANDLE; - - /** - We are done, bug out - */ - return Plugin_Handled; -} - -public Action:Timer_LivingPlayerBalance(Handle:timer, any:iClient) -{ - - /** - Check to make sure we still need to balance - */ - if (!IsUnbalanced() || !OkToBalance()) - { - - /** - We don't need to balance, bug out - */ - g_bBalanceInProgress = false; - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - SM_ClearForcedTeam(iClient); - return Plugin_Handled; - } - - /** - We still need to balance, lets make sure we can still balance this player - */ - if (!IsClientConnected(iClient) || g_aPlayers[iClient][bFlagCarrier]) - { - g_bBalanceInProgress = false; - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - SM_ClearForcedTeam(iClient); - if (g_bLogActivity) - { - if (g_aPlayers[iClient][bFlagCarrier]) - { - LogAction(0, iClient, "[STB] Living player became flag carrier, balance restarted."); - } - else - { - LogAction(0, iClient, "[STB] Living player timer was not needed and died."); - } - } - return Plugin_Handled; - } - - /** - Clear to balance this player, so do it - */ - BalancePlayer(iClient, SM_GetForcedTeam(iClient)); - if (g_bLogActivity) - { - LogAction(0, iClient, "[STB] Living player was switched."); - } - - /** - We are done, bug out - */ - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - return Plugin_Handled; -} - -public Action:Timer_BalancePlayer(Handle:timer, Handle:pack) -{ - - /** - Rest the datapack and load the variables - */ - ResetPack(pack); - new iClient = ReadPackCell(pack); - new iUnBalancedTeam = ReadPackCell(pack); - - /** - We are done with you now - */ - CloseHandle(pack); - - /** - Check the team and make sure its a valid team - */ - if(!SM_IsValidTeam(iUnBalancedTeam)) - { - if (g_bLogActivity) - { - LogAction(0, iClient, "[STB] Balance failed due to invalid team number %i", iUnBalancedTeam); - } - return Plugin_Handled; - } - - /** - Use our core function to change the clients team - */ - SM_MovePlayer(iClient, iUnBalancedTeam); - - return Plugin_Handled; -} - -public Action:Timer_RoundStart(Handle:timer, any:data) -{ - g_bRoundStart = false; - if (OkToBalance() && IsUnbalanced() && !g_bBalanceInProgress) - { - StartABalance(); - } - return Plugin_Handled; -} - -public Action:Timer_ForcedExpired(Handle:timer, any:iClient) -{ - SM_ClearForcedTeam(iClient); - g_aPlayers[iClient][bSwitched] = false; - g_aPlayers[iClient][hForcedTimer] = INVALID_HANDLE; - return Plugin_Handled; -} - -public Action:Timer_WelcomeAdvert(Handle:timer, any:iClient) -{ - if (IsClientConnected(iClient) && IsClientInGame(iClient)) - { - PrintToChat (iClient, "\x01\x04[STB]\x01 %T", "BuddyWelcomeMsg1", LANG_SERVER); - PrintToChat (iClient, "\x01\x04[STB]\x01 %T", "BuddyWelcomeMsg2", LANG_SERVER); - PrintToChat (iClient, "\x01\x04[STB]\x01 %T", "BuddyWelcomeMsg3", LANG_SERVER); - } - return Plugin_Handled; -} - -/* CONSOLE VARIABLE CHANGE EVENT */ - -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (convar == stb_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsEnabled = false; - PrintToChatAll("[SM] %T", "Disabled", LANG_SERVER); - LogAction(0, -1, "[SimpleTeamBalancer] Disabled"); - } - else - { - g_bIsEnabled = true; - SetGameCvars(); - PrintToChatAll("[SM] %T", "Enabled", LANG_SERVER); - LogAction(0, -1, "[SimpleTeamBalancer] Enabled"); - } - } - else if (convar == stb_logactivity) - { - if (StringToInt(newValue) == 0) - { - g_bLogActivity = false; - LogAction(0, -1, "[STB] Log Activity DISABLED."); - } - else - { - g_bLogActivity = true; - LogAction(0, -1, "[STB] Log Activity ENABLED."); - } - } - else if (convar == stb_logactivity2) - { - if (StringToInt(newValue) == 0) - { - g_bLogActivity2 = false; - LogAction(0, -1, "[STB] Detailed Log Activity DISABLED."); - } - else - { - g_bLogActivity2 = true; - LogAction(0, -1, "[STB] Detailed Log Activity ENABLED."); - } - } - else if (convar == stb_convarcontrol) - { - if (StringToInt(newValue) == 0) - { - g_bConVarControl = false; - } - else - { - g_bConVarControl = true; - SetGameCvars(); - } - } - else if (convar == stb_deadonly) - { - if (StringToInt(newValue) == 0) - { - g_bDeadOnly = false; - } - else - { - g_bDeadOnly = true; - } - } - else if (convar == stb_priorityenabled) - { - if (StringToInt(newValue) == 0) - { - g_bPriorityPlayers = false; - } - else - { - g_bPriorityPlayers = true; - } - } - else if (convar == stb_buddyenabled) - { - if (StringToInt(newValue) == 0) - { - g_bBuddyEnabled = false; - } - else - { - g_bBuddyEnabled = true; - } - } - else if (convar == stb_buddyrestriction) - { - if (StringToInt(newValue) == 0) - { - g_bBuddyRestriction = false; - } - else - { - g_bBuddyRestriction = true; - } - } - else if (convar == stb_unbalancelimit) - { - g_iUnbalanceLimit = StringToInt(newValue); - SetGameCvars(); - } - else if (convar == stb_balancedelay) - { - g_iBalanceDelay = StringToInt(newValue); - } - else if (convar == stb_roundstartdelay) - { - g_iRoundStartDelay = StringToInt(newValue); - } - else if (convar == stb_livingplayerswitchdelay) - { - g_iLivingPlayerSwitchDelay = StringToInt(newValue); - } - else if (convar == stb_livingplayercheckdelay) - { - g_iLivingPlayerCheckDelay = StringToInt(newValue); - } - else if (convar == stb_uberlevel) - { - g_fUberLevel = StringToFloat(newValue); - } - else if (convar == stb_switchbackforced) - { - g_iSwitchBackForced = StringToInt(newValue); - } - else if (convar == stb_adminflag) - { - SetConVarString(stb_adminflag, newValue); - } - else if (convar == stb_mp_autoteambalance) - { - SetGameCvars(); - } - else if (convar == stb_mp_teams_unbalance_limit) - { - SetGameCvars(); - } -} - -/* MENU CODE */ - -stock Handle:BuildPlayerMenu() -{ - new Handle:menu = CreateMenu(Menu_SelectPlayer); - AddTargetsToMenu(menu, 0, true, false); - SetMenuTitle(menu, "Select A Player:"); - SetMenuExitButton(menu, true); - return menu; -} - -public Menu_SelectPlayer(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[24]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - new buddy = GetClientOfUserId(StringToInt(sSelection)); - if (param1 == buddy) { - PrintHintText(param1, "%T", "SelectSelf", LANG_SERVER); - } else if (!IsClientInGame(buddy)) { - PrintHintText(param1, "%T", "BuddyGone", LANG_SERVER); - } else { - decl String:cName[128]; - decl String:bName[128]; - GetClientName(param1, cName, sizeof(cName)); - GetClientName(buddy, bName, sizeof(bName)); - if (!SM_IsBuddyLocked(buddy)) { - SM_AssignBuddy(param1, buddy); - PrintHintText(param1, "%T", "BuddyMsg", LANG_SERVER, bName); - PrintHintText(buddy, "%T", "BuddyMsg", LANG_SERVER, cName); - } else - PrintHintText(param1, "%T", "PlayerLockedBuddyMsg", LANG_SERVER, bName); - } - } else if (action == MenuAction_End) { - CloseHandle(menu); - } -} \ No newline at end of file diff --git a/Simple Team Manager/addons/sourcemod/translations/simpledonatorbenefits.phrases.txt b/Simple Team Manager/addons/sourcemod/translations/simpledonatorbenefits.phrases.txt deleted file mode 100644 index 3826846..0000000 --- a/Simple Team Manager/addons/sourcemod/translations/simpledonatorbenefits.phrases.txt +++ /dev/null @@ -1,62 +0,0 @@ -"Phrases" -{ - "PlayerLevelCmd" - { - "en" "Command must be run at the player level" - "fr" "Cette commande doit être tapée en jeu" - "hu" "Ezt a parancsot jatekosi szinten kell futtatni!" - } - "RestrictedCmd" - { - "en" "You must be a donator or admin to run this command" - "fr" "Vous devez être un donateur ou un admin pour lancer cette commande" - "hu" "A parancs futtatasahoz admin, vagy tamogatoi szint szukseges!" - } - "InValidTeam" - { - "en" "You must be on red or blue to swap teams" - "fr" "Vous devez être RED ou BLU pour changer d'équipe" - "hu" "Jatekban kell lenned, hogy megcsereld a csapatokat!" - } - "PlayerQueue" - { - "en" "You have been queued to swap teams on next death" - "fr" "Vous avez été mis en attente pour changer d'équipe lors de votre prochaine mort" - "hu" "A kovetkezo halalnal csapatcsere lesz" - } - "PlayerSwitched" - { - "en" "Your team has been switched as requested" - "fr" "Vous avez changé d'équipe comme demandé" - "hu" "A keresnek eleget teve a csapatod meg lett csererlve" - } - "SwapTeamMsg" - { - "en" "Type /swapteam or !swapteam to swap your team!" - } - "ReachedCount" - { - "en" "You have reached your health limit. You must die before you can use it again" - } - "AtMaxHealth" - { - "en" "You are already at your maximum health!" - } - "ToMaxHealth" - { - "en" "Instant health bonus applied! You are not at your maximun health!" - } - "HealthBonus" - { - "en" "Instant health bonus applied!" - } - "PublicJoinMessage" - { - "#format" "{1:s}" - "en" "{1} a [donator] as joined the server" - } - "PrivateJoinMessage" - { - "en" "Thanks for donating!" - } -} \ No newline at end of file diff --git a/Simple Team Manager/addons/sourcemod/translations/simplespectate.phrases.txt b/Simple Team Manager/addons/sourcemod/translations/simplespectate.phrases.txt deleted file mode 100644 index 2d1a096..0000000 --- a/Simple Team Manager/addons/sourcemod/translations/simplespectate.phrases.txt +++ /dev/null @@ -1,42 +0,0 @@ -"Phrases" -{ - "Stopped spectating" - { - "#format" "{1:s}" - "en" "Stopped tracking player: {1}" - } - "Yourself" - { - "en" "You can't spectate yourself" - } - "Spectator" - { - "en" "You can't spectate another spectator" - } - "Spectating" - { - "#format" "{1:s}" - "en" "Now spectating {1}. Type !stopspec or /stopspec to stop spectating this player" - } - "Invalid Target" - { - "en" "Invalid target" - } - "Cant Target" - { - "en" "Can't target this player" - } - "Must Have Target" - { - "en" "You must be following/tracking a player to punish" - } - "Target Left" - { - "en" "The player you were following/tracking has left" - } - "Punished" - { - "#format" "{1:s}{2:s}{3:s}" - "en" "{1} was punished with a {2} for {3}" - } -} \ No newline at end of file diff --git a/Simple Team Manager/addons/sourcemod/translations/simpleteambalancer.phrases.txt b/Simple Team Manager/addons/sourcemod/translations/simpleteambalancer.phrases.txt deleted file mode 100644 index 03595fd..0000000 --- a/Simple Team Manager/addons/sourcemod/translations/simpleteambalancer.phrases.txt +++ /dev/null @@ -1,130 +0,0 @@ -"Phrases" -{ - "UnBalanced" - { - "en" "Teams are unbalanced and will be balanced shortly" - "fr" "Les équipes ne sont pas équilibrées et le seront bientôt" - "de" "Die Teams sind ungleich und werden in Kürze ausgeglichen" - "hu" "A csapatok nem kiegyenlitettek! Egyensuly beallitas kovetkezik!" - } - "Enabled" - { - "en" "Simple Team Balancer is ENABLED" - "fr" "Simple Team Balancer est ACTIVE" - "de" "Simple Team Balancer ist AKTIV" - "hu" "Az Egyszeru Csapat Egyensulytarto AKTIV!" - } - "Disabled" - { - "en" "Simple Team Balancer is DISABLED" - "fr" "Simple Team Balancer est DESACTIVE" - "de" "Simple Team Balancer ist INAKTIV" - "hu" "Az Egyszeru Csapat Egyensulytarto INAKTIV!" - } - "PlayerMessage" - { - "#format" "{1:i}" - "en" "You are going to be auto balanced in {1} seconds unless a dead player can be found" - "fr" "Vous passerez dans l'autre équipe dans {1} secondes si aucun joueur mort ne peut être trouvé dans cet intervalle" - "de" "Du wirst in {1} Sekunden zum automatischen Ausgleich herangezogen wenn kein toter Spieler gefunden werden kann" - "hu" "{1} masodpercen belul at leszel helyezve a masik csapatba, hacsak nem lesz addig egy halott jatekos!" - } - "BalanceMessage" - { - "#format" "{1:s}" - "en" "{1} was moved to the other team for game balance" - "fr" "{1} est passé dans l'autre équipe pour équilibrer la partie" - "de" "{1} wurde zum anderen Team verschoben um das Spiel auszugleichen" - "hu" "{1} at lett helyezve az egyensuly megtartasa erdekeben." - } - "PlayerLevelCmd" - { - "en" "Command must be run at the player level" - "fr" "La commande doit être lancée au niveau du joueur" - "de" "Das Kommando muss auf Spieler Ebene ausgeführt werden" - "hu" "Jatekosi szinten kell futtatni ezt a parancsot!" - } - "CmdDisabled" - { - "en" "Command is currently disabled" - "fr" "La commande est actuellement désactivée" - "de" "Das Kommando ist momentan inaktiv" - "hu" "A parancs jelenleg inaktiv" - } - "RestrictedBuddy" - { - "en" "You must be a donator or admin to add a balance buddy" - "fr" "Vous devez être un donateur ou un admin pour choisir un partenaire" - "de" "Du musst ein Spender oder Admin sein um einen Partner wählen zu können" - "hu" "Tamogato vagy admin kell hogy legyel, hogy 'Tarsat' jelolhess meg" - } - "SelectSelf" - { - "en" "You cannot be your own buddy" - "fr" "Vous ne pouvez pas être votre propre partenaire" - "de" "Du kannst nicht dein eigener Partner sein" - "hu" "Nem valaszthatod ki onmagad!" - } - "BuddyGone" - { - "en" "Your selected buddy has disconnected" - "fr" "Le partenaire que vous avez sélectionné s'est déconnecté" - "de" "Dein gewählter Partner hat die Verbindung getrennt" - "hu" "A valasztott 'Tarsad' kilepett" - } - "BuddyMsg" - { - "#format" "{1:s}" - "en" "You and {1} are now buddies" - "fr" "Vous et {1} êtes maintenant partenaires" - "de" "Du und {1} seid jetzt Partner" - "hu" "{1} es Te 'Tarsak' vagytok." - } - "BuddyLockMsgDisabled" - { - "en" "You can now be anyone's buddy" - "fr" "Vous pouvez à présent être le partenaire de n'importe qui" - "de" "Du kannst jetzt jedermanns Partner sein" - "hu" "Barkinek lehetsz a 'Tarsa'." - } - "BuddyLockMsgEnabled" - { - "en" "Buddy selection locked. Only you can change your buddy" - "fr" "Sélection de partenaire bloquée. Vous êtes le seul à pouvoir choisir votre partenaire" - "de" "Wahl des Partners gesperrt. Nur du kannst deinen Partner wechseln" - "hu" "Tars-lista lezarva. Csak Te tudod modositani a Tars-listadat." - } - "PlayerLockedBuddyMsg" - { - "#format" "{1:s}" - "en" "{1} has locked his buddy selection. Try again" - "fr" "{1} a bloqué sa sélection de partenaire. Essayez de nouveau." - "de" "{1} hat seine Wahl des Partners gesperrt. Versuche es erneut" - "hu" "{1} lezarta a Tars-listajat. Probald kesobb!" - } - "BuddyWelcomeMsg1" - { - "en" "Select a balance buddy and stay together during an autobalance!" - "fr" "Choisissez un partenaire et restez ensemble durant l'équilibrage automatique!" - "de" "Wähle einen Partner und bleibt zusammen während eines Ausgleichs" - "hu" "Valasz ki egy 'Tarsat' akivel egyuttmaradhatsz a csapatkiegyenlites alatt!" - } - "BuddyWelcomeMsg2" - { - "en" "/buddy or !buddy to select a balance buddy" - "fr" "/buddy or !buddy pour choisir un partenaire" - "de" "/buddy oder !buddy um einen Partner zu wählen" - "hu" "Hasznald a /buddy vagy !buddy parancsokat a 'Tars' kijelolesehez" - } - "BuddyWelcomeMsg3" - { - "en" "/lockbuddy or !lockbuddy to lock your selection" - "fr" "/lockbuddy or !lockbuddy pour bloquer votre sélection" - "de" "/lockbuddy oder !lockbuddy um deine Auswahl zu sperren" - "hu" "Hasznald a /lockbuddy vagy a !lockbuddy parancsokat a Tars-listad lezarasahoz" - } -} - - - - diff --git a/addons/sourcemod/configs/simple-alltalkmanager_events.cfg b/addons/sourcemod/configs/simple-alltalkmanager_events.cfg deleted file mode 100644 index b739cf0..0000000 --- a/addons/sourcemod/configs/simple-alltalkmanager_events.cfg +++ /dev/null @@ -1,43 +0,0 @@ -"game_events" -{ - "teamplay_round_start" - { - "reason" "Round Start" - "setting" "1" - } - "teamplay_setup_finished" - { - "reason" "Setup Period Ended" - "setting" "0" - } - "teamplay_overtime_begin" - { - "reason" "Overtime Began" - "setting" "1" - } - "teamplay_overtime_end" - { - "reason" "Overtime Ended" - "setting" "1" - } - "teamplay_round_win" - { - "reason" "Round Ended" - "setting" "1" - } - "teamplay_suddendeath_begin" - { - "reason" "Sudden Death Began" - "setting" "1" - } - "teamplay_suddendeath_end" - { - "reason" "Sudden Death Ended" - "setting" "1" - } - "teamplay_round_stalemate" - { - "reason" "Stalemate" - "setting" "1" - } -} \ No newline at end of file diff --git a/addons/sourcemod/configs/simple-chatcolors.cfg b/addons/sourcemod/configs/simple-chatcolors.cfg deleted file mode 100644 index 14b98c6..0000000 --- a/addons/sourcemod/configs/simple-chatcolors.cfg +++ /dev/null @@ -1,15 +0,0 @@ -"admin_colors" -{ - "groupname2" - { - "flag" "z" - "namecolor" "{green}" - "textcolor" "{olive}" - } - "groupname1" - { - "flag" "a" - "namecolor" "{teamcolor}" - "textcolor" "{green}" - } -} \ No newline at end of file diff --git a/addons/sourcemod/plugins/simple-alltalkmanager.smx b/addons/sourcemod/plugins/simple-alltalkmanager.smx deleted file mode 100644 index 6122756..0000000 Binary files a/addons/sourcemod/plugins/simple-alltalkmanager.smx and /dev/null differ diff --git a/addons/sourcemod/plugins/simple-donatorbenefits.smx b/addons/sourcemod/plugins/simple-donatorbenefits.smx deleted file mode 100644 index 821d61d..0000000 Binary files a/addons/sourcemod/plugins/simple-donatorbenefits.smx and /dev/null differ diff --git a/addons/sourcemod/plugins/simple-messagesuppression.smx b/addons/sourcemod/plugins/simple-messagesuppression.smx deleted file mode 100644 index cc20dad..0000000 Binary files a/addons/sourcemod/plugins/simple-messagesuppression.smx and /dev/null differ diff --git a/addons/sourcemod/plugins/simple-plugins.smx b/addons/sourcemod/plugins/simple-plugins.smx deleted file mode 100644 index ac307a3..0000000 Binary files a/addons/sourcemod/plugins/simple-plugins.smx and /dev/null differ diff --git a/addons/sourcemod/plugins/simple-spectate.smx b/addons/sourcemod/plugins/simple-spectate.smx deleted file mode 100644 index c6885b0..0000000 Binary files a/addons/sourcemod/plugins/simple-spectate.smx and /dev/null differ diff --git a/addons/sourcemod/plugins/simple-teambalancer.smx b/addons/sourcemod/plugins/simple-teambalancer.smx deleted file mode 100644 index 95beb01..0000000 Binary files a/addons/sourcemod/plugins/simple-teambalancer.smx and /dev/null differ diff --git a/addons/sourcemod/plugins/simple-teammanager.smx b/addons/sourcemod/plugins/simple-teammanager.smx deleted file mode 100644 index 81905ba..0000000 Binary files a/addons/sourcemod/plugins/simple-teammanager.smx and /dev/null differ diff --git a/addons/sourcemod/scripting/include/simple-plugins.inc b/addons/sourcemod/scripting/include/simple-plugins.inc deleted file mode 100644 index 8f21956..0000000 --- a/addons/sourcemod/scripting/include/simple-plugins.inc +++ /dev/null @@ -1,337 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Plugins -Description: - Included file for core plugin in the Simple Plugins project -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -*************************************************************************/ - -#if defined _simpleplugin_included - #endinput -#endif - -#define _simpleplugin_included - -#define CORE_INC_VERSION "1.1.$Rev$" - -#pragma semicolon 1 -#include -#undef REQUIRE_PLUGIN -#include -#define REQUIRE_PLUGIN -#undef REQUIRE_EXTENSIONS -#undef AUTOLOAD_EXTENSIONS -#tryinclude -#tryinclude -#tryinclude -#define AUTOLOAD_EXTENSIONS -#define REQUIRE_EXTENSIONS - -enum e_SupportedMods -{ - GameType_Unknown, - GameType_AOC, - GameType_CSS, - GameType_DOD, - GameType_FF, - GameType_HIDDEN, - GameType_HL2DM, - GameType_INS, - GameType_L4D, - GameType_NEO, - GameType_SGTLS, - GameType_TF, - GameType_ZPS -}; - -enum e_Teams -{ - Unknown, - Spectator, - Team1, - Team2 -}; - -new g_aCurrentTeams[e_Teams]; -new e_SupportedMods:g_CurrentMod; -new String:g_sGameName[e_SupportedMods][32] = { "Unknown", - "Age of Chivalry", - "Counter Strike", - "Day Of Defeat", - "Fortress Forever", - "Hidden: Source", - "Half Life 2: Deathmatch", - "Insurgency", - "Left 4 Dead", - "Neotokyo", - "Stargate TLS", - "Team Fortress 2", - "Zombie Panic: Source" - }; - -public SharedPlugin:_pl_simpleplugin = -{ - name = "simple-plugins", - file = "simple-plugins.smx", -#if defined REQUIRE_PLUGIN - required = 1 -#else - required = 0 -#endif -}; - -#if !defined REQUIRE_PLUGIN -public _pl_simpleplugin_SetNTVOptional() -{ - MarkNativeAsOptional("SM_MovePlayer"); - MarkNativeAsOptional("SM_SetForcedTeam"); - MarkNativeAsOptional("SM_GetForcedTeam"); - MarkNativeAsOptional("SM_ClearForcedTeam"); - MarkNativeAsOptional("SM_GetForcedPlayer"); - MarkNativeAsOptional("SM_AssignBuddy"); - MarkNativeAsOptional("SM_SearchBuddy"); - MarkNativeAsOptional("SM_LockBuddy"); - MarkNativeAsOptional("SM_IsBuddyLocked"); - MarkNativeAsOptional("SM_ClearBuddy"); - MarkNativeAsOptional("SM_IsValidAdmin"); - MarkNativeAsOptional("SM_IsValidTeam"); -} -#endif - -/********************************************************************** - * When a player has to moved - * - * @param plugin Plugin that initiated the move - * @param client The client index of the player that was moved - * @param team The team index the player was moved to - * @noreturn - **********************************************************************/ -forward SM_OnPlayerMoved(Handle:plugin, client, team); - -/********************************************************************** - * Move a player to the supplied team - * - * @param client The client index of the player to be moved - * @param team The team to move the player to - * @noreturn - * @error Invalid client or team index - **********************************************************************/ -native SM_MovePlayer(client, team); - -/********************************************************************** - * Move a player to the supplied team - * - * @param client The client index of the player to set - * @param team The team to move the to set - * @param override Whether or not to override another plugin - * @return True if successful, false if not - * @error Invalid client or team index - **********************************************************************/ -native SM_SetForcedTeam(client, team, bool:override = false); - -/********************************************************************** - * Gets the client's forced team index - * - * @param client The client index of the player to check - * @param plugin Optional: The plugin handle of the plugin - that set the team - * @return The team index of the forced team - Zero if no forced team - * @error Invalid client index - **********************************************************************/ -native SM_GetForcedTeam(client, &Handle:plugin = INVALID_HANDLE); - -/********************************************************************** - * Clears a client's forced team - * - * @param client The client index of the player to check - * @return True if successful, false if not - * @error Invalid client index - **********************************************************************/ -native SM_ClearForcedTeam(client); - -/********************************************************************** - * Gets a forced player on the wrong that is currently on the wrong team - * This will only return a player if the calling plugin assigned the team - * - * @param team The team index the player should be on - * @return The client index of the player - Zero if no player found - * @error Invalid client index - **********************************************************************/ -native SM_GetForcedPlayer(team); - -/********************************************************************** - * Assign a players buddy - * - * @param client The client index of the player to assign - * @param player The player index of the player to assign - * @param override Whether or not to override a player lock - * @return True if successful, false if not - * @error Invalid client or player index - **********************************************************************/ -native bool:SM_AssignBuddy(client, player, bool:override = false); - -/********************************************************************** - * Rturns the client's buddy - * - * @param client The client index of the player to assign - * @return The client index of the player's buddy - Zero if no buddy - * @error Invalid client index - **********************************************************************/ -native SM_GetClientBuddy(client); - -/********************************************************************** - * Set the buddy lock setting for a client - * - * @param client The client index of the player to assign - * @param setting Setting to set, True or False - * @return True if successful, false if not - * @error Invalid client index - **********************************************************************/ -native bool:SM_LockBuddy(client, bool:setting); - -/********************************************************************** - * Returns the buddy lock setting for a client - * - * @param client The client index of the player to assign - * @return True if locked, false if not - * @error Invalid client index - **********************************************************************/ -native bool:SM_IsBuddyLocked(client); - -/********************************************************************** - * Clear a players buddy - * - * @param client The client index of the player to clear - * @param override Whether or not to override a player lock - * @return True if successful, false if not - * @error Invalid client index - **********************************************************************/ -native bool:SM_ClearBuddy(client, bool:override = false); - -/********************************************************************** - * Determine if the player has the supplied flags - * ADMFLAG_ROOT will always return true - * - * @param client The client index of the player to assign - * @param flags The char flag(s) to check against - * @return True if valid, false if not - **********************************************************************/ -native bool:SM_IsValidAdmin(client, const String:flags[]); - - -/********************************************************************** - * Determine if the team is a valid team - * - * @param team The team index to determine if valid for - currently installed/supported mod - * @return True if valid, false if not - **********************************************************************/ -native bool:SM_IsValidTeam(team); - - -public e_SupportedMods:GetCurrentMod() -{ - new String:sGameType[64]; - GetGameFolderName(sGameType, sizeof(sGameType)); - - if (StrEqual(sGameType, "aoc", false)) - { - return GameType_AOC; - } - if (StrEqual(sGameType, "cstrike", false)) - { - return GameType_CSS; - } - if (StrEqual(sGameType, "dod", false)) - { - return GameType_DOD; - } - if (StrEqual(sGameType, "ff", false)) - { - return GameType_FF; - } - if (StrEqual(sGameType, "hidden", false)) - { - return GameType_HIDDEN; - } - if (StrEqual(sGameType, "hl2mp", false)) - { - return GameType_FF; - } - if (StrEqual(sGameType, "insurgency", false) || StrEqual(sGameType, "ins", false)) - { - return GameType_INS; - } - if (StrEqual(sGameType, "l4d", false)) - { - return GameType_L4D; - } - if (StrEqual(sGameType, "nts", false)) - { - return GameType_NEO; - } - if (StrEqual(sGameType, "sgtls", false)) - { - return GameType_SGTLS; - } - if (StrEqual(sGameType, "tf", false)) - { - return GameType_TF; - } - if (StrEqual(sGameType, "zps", false)) - { - return GameType_ZPS; - } - return GameType_Unknown; -} - -public LoadCurrentTeams() -{ - switch (g_CurrentMod) - { - case GameType_INS: - { - g_aCurrentTeams[Unknown] = 0; - g_aCurrentTeams[Spectator] = 3; - g_aCurrentTeams[Team1] = 1; - g_aCurrentTeams[Team2] = 2; - } - case default: - { - g_aCurrentTeams[Unknown] = 0; - g_aCurrentTeams[Spectator] = 1; - g_aCurrentTeams[Team1] = 2; - g_aCurrentTeams[Team2] = 3; - } - } -} diff --git a/addons/sourcemod/scripting/simple-alltalkmanager.sp b/addons/sourcemod/scripting/simple-alltalkmanager.sp deleted file mode 100644 index c848332..0000000 --- a/addons/sourcemod/scripting/simple-alltalkmanager.sp +++ /dev/null @@ -1,515 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple AllTalk Manager -Description: - Allows you to set alltalk at different times -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#pragma semicolon 1 -#include -#include - -#define PLUGIN_VERSION "1.4.$Rev$" - -new Handle:satm_enabled = INVALID_HANDLE; -new Handle:satm_threshold_enabled = INVALID_HANDLE; -new Handle:satm_player_threshold = INVALID_HANDLE; -new Handle:satm_threshold_setting = INVALID_HANDLE; -new Handle:satm_logactivity = INVALID_HANDLE; -new Handle:satm_alltalk = INVALID_HANDLE; - -new Handle:g_aEventNames = INVALID_HANDLE; -new Handle:g_aEventReasons = INVALID_HANDLE; -new Handle:g_aEventSettings = INVALID_HANDLE; - -new bool:g_bLastThreshold = false; -new bool:g_bEnabled = true; -new bool:g_bThresholdEnabled = true; -new bool:g_bIsSetupMap = false; -new bool:g_bIsGameTF2 = false; -new bool:g_bLogActivity = false; - -new g_iLastEventIndex; - -public Plugin:myinfo = -{ - name = "Simple AllTalk Manager", - author = "Simple Plugins", - description = "Allows you to set alltalk at different times", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -} - -/** -Sourcemod callbacks -*/ -public OnPluginStart() -{ - - /** - Need to create all of our console variables. - */ - CreateConVar("satm_version", PLUGIN_VERSION, "Simple AllTalk Manager", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - satm_enabled = CreateConVar("satm_enabled", "1", "Enables/Disables Simple AllTalk Manager", _, true, 0.0, true, 1.0); - satm_threshold_enabled = CreateConVar("satm_threshold_enabled", "1", "Enables/Disables player threshold", _, true, 0.0, true, 1.0); - satm_player_threshold = CreateConVar("satm_player_threshold", "8", "Amount of players for the threshold"); - satm_threshold_setting = CreateConVar("satm_threshold_setting", "1", "Enables/Disables all talk up to player threshold, with the opposite set after the threshold", _, true, 0.0, true, 1.0); - satm_logactivity = CreateConVar("satm_logactivity", "0", "Enables/Disables log activity", _, true, 0.0, true, 1.0); - satm_alltalk = FindConVar("sv_alltalk"); - - /** - Hook console variables - */ - HookConVarChange(satm_enabled, ConVarSettingsChanged); - HookConVarChange(satm_threshold_enabled, ConVarSettingsChanged); - HookConVarChange(satm_player_threshold, ConVarSettingsChanged); - HookConVarChange(satm_logactivity, ConVarSettingsChanged); - - /** - Remove the notify flag from all talk cvar since we do it - */ - SetConVarFlags(satm_alltalk, GetConVarFlags(satm_alltalk)~FCVAR_NOTIFY); - - /** - Get the game type. We only care if it's TF2 - */ - new String:sGameType[64]; - GetGameFolderName(sGameType, sizeof(sGameType)); - if (StrEqual(sGameType, "tf", false)) - { - g_bIsGameTF2 = true; - } - - /** - Create the arrays - */ - g_aEventNames = CreateArray(255, 1); - g_aEventReasons = CreateArray(255, 1); - g_aEventSettings = CreateArray(1, 1); - - /** - Need to register the commands we are going to create and use. - */ - RegAdminCmd("sm_reloadatconfig", Command_Reload, ADMFLAG_GENERIC, "Reloads settings from config file"); - - /** - Create the config file - */ - AutoExecConfig(true); - - /** - Load the events from the config - */ - LoadEventsFromConfig(); -} - -public OnConfigsExecuted() -{ - - /** - Load up the settings - */ - g_bEnabled = GetConVarBool(satm_enabled); - g_bLogActivity = GetConVarBool(satm_logactivity); - g_bThresholdEnabled = GetConVarBool(satm_threshold_enabled); -} - -public OnMapStart() -{ - - /** - Reset the globals - */ - g_iLastEventIndex = 0; - g_bLastThreshold = false; - - /** - Check the map type if we are in TF2 - */ - if (g_bIsGameTF2) - { - g_bIsSetupMap = IsSetupPeriodMap(); - } - - /** - Set AllTalk - */ - if (g_bEnabled) - { - SetConVarBool(satm_alltalk, true); - } -} - -public OnClientDisconnect_Post(client) -{ - if (g_bEnabled) - { - SetAllTalk(-1); - } -} - -public OnClientPostAdminCheck(client) -{ - if (g_bEnabled) - { - SetAllTalk(-1); - } - CreateTimer(2.0, Timer_ShowAllTalkStatus, client, TIMER_FLAG_NO_MAPCHANGE); -} - -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (convar == satm_enabled) - { - if (StringToInt(newValue)) - { - g_bEnabled = true; - } - else - { - g_bEnabled = false; - } - } - else if (convar == satm_threshold_enabled) - { - if (StringToInt(newValue)) - { - g_bThresholdEnabled = true; - } - else - { - g_bThresholdEnabled = false; - } - } - else if (convar == satm_logactivity) - { - if (StringToInt(newValue)) - { - g_bLogActivity = true; - } - else - { - g_bLogActivity = false; - } - } - if (g_bEnabled) - { - SetAllTalk(-1); - } -} - -/** -Commands -*/ -public Action:Command_Reload(client, args) -{ - - /** - Clear the array - */ - ClearArray(g_aEventNames); - ClearArray(g_aEventReasons); - ClearArray(g_aEventSettings); - - /** - Load the events from the config - */ - LoadEventsFromConfig(); - - return Plugin_Handled; -} - -/** -Game Event Hooks -*/ -public Hook_All_Events(Handle:event, const String:name[], bool:dontBroadcast) -{ - if (!g_bIsSetupMap) - { - if (StrEqual(name, "teamplay_round_start")) - { - if (FindStringInArray(g_aEventNames, "teamplay_setup_finished") != -1) - { - g_iLastEventIndex = FindStringInArray(g_aEventNames, "teamplay_setup_finished"); - if (g_bEnabled) - { - SetAllTalk(g_iLastEventIndex); - return; - } - } - } - } - g_iLastEventIndex = FindStringInArray(g_aEventNames, name); - if (g_bEnabled) - { - SetAllTalk(g_iLastEventIndex); - } -} - -/** -Timers -*/ -public Action:Timer_ShowAllTalkStatus(Handle:timer, any:client) -{ - if (IsClientConnected(client) && IsClientInGame(client)) - { - new bool:bSetting = GetConVarBool(satm_alltalk); - if (bSetting) - { - PrintToChat(client, "\x01\x04[SM] AllTalk is \x01[on]"); - } - else - { - PrintToChat(client, "\x01\x04[SM] AllTalk is \x01[off]"); - } - } -} - -/** -Stock Functions -*/ -stock LoadEventsFromConfig() -{ - - /** - Make sure the config file is here and load it up - */ - new String:sConfigFile[256]; - BuildPath(Path_SM, sConfigFile, sizeof(sConfigFile), "configs/simple-alltalkmanager_events.cfg"); - if (!FileExists(sConfigFile)) - { - - /** - Config file doesn't exists, stop the plugin - */ - LogError("[SATM] Simple AllTalk Manager is not running! Could not find file %s", sConfigFile); - SetFailState("Could not find file %s", sConfigFile); - } - - /** - Create the arrays and variables - */ - new String:sGameEventName[256]; - new String:sReason[256]; - new iSetting; - - /** - Load config file as a KeyValues file - */ - new Handle:kvGameEvents = CreateKeyValues("game_events"); - FileToKeyValues(kvGameEvents, sConfigFile); - - if (!KvGotoFirstSubKey(kvGameEvents)) - { - return; - } - - /** - Hook the game events and load the settings - */ - do - { - - /** - Get the section name; this should be the event name - */ - KvGetSectionName(kvGameEvents, sGameEventName, sizeof(sGameEventName)); - if (!HookEventEx(sGameEventName, Hook_All_Events, EventHookMode_PostNoCopy)) - { - - /** - Could not hook this event, stop the plugin - */ - SetFailState("Could not hook event %s", sGameEventName); - } - else - { - if (g_bLogActivity) - { - LogMessage("[SATM] Hooked event: %s", sGameEventName); - } - } - - /** - Get the reason string and setting - */ - KvGetString(kvGameEvents, "reason", sReason, sizeof(sReason)); - iSetting = KvGetNum(kvGameEvents, "setting"); - if (g_bLogActivity) - { - LogMessage("[SATM] Event reason string: %s", sReason); - LogMessage("[SATM] Event setting: %i", iSetting); - } - - /** - Push the values to the arrays - */ - PushArrayString(g_aEventNames, sGameEventName); - PushArrayString(g_aEventReasons, sReason); - PushArrayCell(g_aEventSettings, iSetting); - } while (KvGotoNextKey(kvGameEvents)); - - /** - Close our handle - */ - CloseHandle(kvGameEvents); -} - -stock SetAllTalk(index) -{ - new iPlayerThreshold = GetConVarInt(satm_player_threshold); - new bool:bThresholdMet = ((GetClientCount() >= iPlayerThreshold) ? true : false); - new bool:bSetting; - - if (g_bThresholdEnabled) - { - if (bThresholdMet) - { - if (index == -1) - { - if (bThresholdMet != g_bLastThreshold) - { - g_bLastThreshold = true; - bSetting = !GetConVarBool(satm_threshold_setting); - new bool:bLastSetting = GetArrayCell(g_aEventSettings, g_iLastEventIndex); - if (bLastSetting && !bSetting) - { - bSetting = GetArrayCell(g_aEventSettings, g_iLastEventIndex); - } - } - else - { - bSetting = GetArrayCell(g_aEventSettings, g_iLastEventIndex); - } - } - else - { - bSetting = GetArrayCell(g_aEventSettings, index); - } - } - else - { - g_bLastThreshold = false; - bSetting = GetConVarBool(satm_threshold_setting); - } - } - else - { - if (index != -1) - { - bSetting = GetArrayCell(g_aEventSettings, index); - } - } - - if (GetConVarBool(satm_alltalk) != bSetting) - { - - SetConVarBool(satm_alltalk, bSetting); - - new String:sReason[256]; - if (index == -1) - { - Format(sReason, sizeof(sReason), "Player Threshold"); - } - else - { - if (!g_bIsSetupMap) - { - new String:sCurrentEvent[256]; - GetArrayString(g_aEventNames, index, sCurrentEvent, sizeof(sCurrentEvent)); - if (StrEqual(sCurrentEvent, "teamplay_setup_finished")) - { - new iRoundStartIndex = FindStringInArray(g_aEventNames, "teamplay_round_start"); - if (iRoundStartIndex != -1) - { - GetArrayString(g_aEventReasons, iRoundStartIndex, sReason, sizeof(sReason)); - } - else - { - GetArrayString(g_aEventReasons, index, sReason, sizeof(sReason)); - } - } - else - { - GetArrayString(g_aEventReasons, index, sReason, sizeof(sReason)); - } - } - else - { - GetArrayString(g_aEventReasons, index, sReason, sizeof(sReason)); - } - } - - if (bSetting) - { - PrintToChatAll("\x01\x04[SM] AllTalk turned \x01[on] \x04due to:\x01 %s", sReason); - } - else - { - PrintToChatAll("\x01\x04[SM] AllTalk turned \x01[off] \x04due to:\x01 %s", sReason); - } - } -} - -stock bool:IsSetupPeriodMap() -{ - new iEnt = -1; - new String:sMapName[32]; - - GetCurrentMap(sMapName, sizeof(sMapName)); - - if (strncmp(sMapName, "cp_", 3, false) == 0) - { - new iTeam; - while ((iEnt = FindEntityByClassname(iEnt, "team_control_point")) != -1) - { - iTeam = GetEntProp(iEnt, Prop_Send, "m_iTeamNum"); - - /** - If there is a blu CP or a neutral CP, then it's not an attack/defend map - */ - if (iTeam != 2) - { - //this is a push map - return false; - } - } - //this is a attack/defend map - return true; - } - else if (strncmp(sMapName, "ctf_", 3, false) == 0) - { - //this is a ctf map - return false; - } - return false; -} diff --git a/addons/sourcemod/scripting/simple-autoscrambler.sp b/addons/sourcemod/scripting/simple-autoscrambler.sp deleted file mode 100644 index 6c6799e..0000000 --- a/addons/sourcemod/scripting/simple-autoscrambler.sp +++ /dev/null @@ -1,459 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple AutoScrambler -Description: - Automatically scrambles the teams based upon a number of events. -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include - -#define PLUGIN_VERSION "1.1.$Rev$" - -/** -Different scramble modes: - -1 = Full Scramble, dont restart round. -2 = Admins Immune, dont restart round. -3 = Full Scramble, restart round and reset scores. -4 = Admins Immune, restart round and reset scores. - -*/ - -/** -Different top player modes: - -1 = Divide Top 4 players on the two teams. -2 = Protect the Top 2 players on each team. - -*/ - -enum PlayerData -{ - Handle:hForcedTimer, - bool:bProtected; -}; - -/** -Cvars used for admins -*/ -new Handle: sas_admin_immunity_enabled = INVALID_HANDLE, - Handle: sas_admin_flag_scramblenow = INVALID_HANDLE, - Handle: sas_admin_flag_immunity = INVALID_HANDLE; - -/** -Cvars used for autoscramble -*/ -new Handle: sas_autoscramble_enabled = INVALID_HANDLE, - Handle: sas_autoscramble_minplayers = INVALID_HANDLE, - Handle: sas_autoscramble_mode = INVALID_HANDLE, - Handle: sas_autoscramble_winstreak = INVALID_HANDLE, - Handle: sas_autoscramble_steamroll = INVALID_HANDLE, - Handle: sas_autoscramble_frags = INVALID_HANDLE; - -/** -Cvars used for voting -*/ -new Handle: sas_vote_enabled = INVALID_HANDLE, - Handle: sas_vote_upcount = INVALID_HANDLE, - Handle: sas_vote_winpercent = INVALID_HANDLE, - Handle: sas_vote_mode = INVALID_HANDLE, - Handle: sas_vote_minplayers = INVALID_HANDLE; - -/** -Additional cvars -*/ -new Handle: sas_enabled = INVALID_HANDLE, - Handle: sas_timer_scrambledelay = INVALID_HANDLE, - Handle: TFGameModeArena = INVALID_HANDLE; - -/** -Timers -*/ -new Handle: g_hScrambleTimer = INVALID_HANDLE; - -/** - Player arrays - */ -new g_aPlayers[MAXPLAYERS + 1][PlayerData]; - -/** - Cvar variables - */ -new bool: g_bIsEnabled, - bool: g_bIsAutoScrambleEnabled, - bool: g_bIsVoteEnabled, - bool: g_bIsAdminImmunityEnabled; -new Float: g_fTimer_ScrambleDelay, - Float: g_fVote_UpCount, - Float: g_fVote_WinPercent; -new g_iAutoScramble_Minplayers, - g_iAutoScramble_Mode, - g_iAutoScramble_WinStreak, - g_iAutoScramble_SteamRoll, - g_iAutoScramble_Frags, - g_iVote_Mode, - g_iVote_MinPlayers; -new String: g_sScrambleNowFlag[5], - String: g_sAdminImmunityFlag[5]; - -/** -Other globals -*/ -new g_iMaxEntities, - g_iOwnerOffset; - -public Plugin:myinfo = -{ - name = "Simple AutoScrambler", - author = "Simple Plugins", - description = "Automatically scrambles the teams based upon a number of events.", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -}; - -public OnPluginStart() -{ - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook the game events - */ - LogAction(0, -1, "[SAS] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - switch (g_CurrentMod) - { - case GameType_TF: - { - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - } - case GameType_DOD: - { - HookEvent("dod_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_Post); - } - default: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_Post); - } - } - - /** - Create console variables - */ - CreateConVar("sas_version", PLUGIN_VERSION, "Simple AutoScrambler Version",FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - sas_enabled = CreateConVar("sas_enabled", "1", "Enable/Disable Simple AutoScrambler"); - sas_timer_scrambledelay = CreateConVar("sas_timer_scrambledelay", "5.0", "Delay used after a scramble has been started", _, true, 1.0, true, 30.0); - - /** - Cvars used for admins - */ - sas_admin_immunity_enabled = CreateConVar("sas_admin_immunity_enabled", "1", "Enable/Disable admin immunity for scrambles"); - sas_admin_flag_scramblenow = CreateConVar("sas_admin_flag_scramblenow", "z", "Admin flag to use for scramblenow function/command"); - sas_admin_flag_immunity = CreateConVar("sas_admin_flag_immunity", "z", "Admin flag to use for scramble immunity"); - - /** - Cvars used for autoscramble - */ - sas_autoscramble_enabled = CreateConVar("sas_autoscramble_enabled", "1", "Enable/Disable the autoscramble function"); - sas_autoscramble_minplayers = CreateConVar("sas_autoscramble_minplayers", "16", "Min players needed to start an autoscramble"); - sas_autoscramble_mode = CreateConVar("sas_autoscramble_mode", "1", "Scramble mode used when autoscrambling"); - sas_autoscramble_winstreak = CreateConVar("sas_autoscramble_winstreak", "5", "Max amount of wins in a row a team can achieve before an autoscramble starts"); - sas_autoscramble_steamroll = CreateConVar("sas_autoscramble_steamroll", "120", "Shortest amount of time a team can win by before an autoscramble starts (seconds)"); - sas_autoscramble_frags = CreateConVar("sas_autoscramble_frags", "1", "Min players needed to start a vote and scramble"); - - /** - Cvars used for voting - */ - sas_vote_enabled = CreateConVar("sas_vote_enabled", "1", "Enable/Disable voting for scramble"); - sas_vote_upcount = CreateConVar("sas_vote_upcount", "5", "Amount of people wanting a scramble before a vote starts. If less than 1 it will be considered a percentage. (ie 0.5 = 50% | 1 = 1 Player | 5 = 5 Players)"); - sas_vote_winpercent = CreateConVar("sas_vote_winpercent", "0.6", "Percentage of votes needed to scramble", _, true, 0.0, true, 1.0); - sas_vote_mode = CreateConVar("sas_vote_mode", "1", "Scramble mode used when a vote results in a scramble"); - sas_vote_minplayers = CreateConVar("sas_vote_minplayers", "16", "Min players needed to start a vote and scramble"); - - /** - Hook the console variables if they change - */ - HookConVarChange(sas_enabled, ConVarSettingsChanged); - HookConVarChange(sas_timer_scrambledelay, ConVarSettingsChanged); - HookConVarChange(sas_admin_immunity_enabled, ConVarSettingsChanged); - HookConVarChange(sas_admin_flag_scramblenow, ConVarSettingsChanged); - HookConVarChange(sas_admin_flag_immunity, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_enabled, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_minplayers, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_mode, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_winstreak, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_steamroll, ConVarSettingsChanged); - HookConVarChange(sas_autoscramble_frags, ConVarSettingsChanged); - HookConVarChange(sas_vote_enabled, ConVarSettingsChanged); - HookConVarChange(sas_vote_upcount, ConVarSettingsChanged); - HookConVarChange(sas_vote_winpercent, ConVarSettingsChanged); - HookConVarChange(sas_vote_mode, ConVarSettingsChanged); - HookConVarChange(sas_vote_minplayers, ConVarSettingsChanged); - - /** - Register the command - */ - RegConsoleCmd("sm_scramblenow", Command_ScrambleNow, "sm_scramblenow (mode): Scrambles the teams"); - - /** - Load translations and .cfg file - */ - LoadTranslations ("simpleautoscrambler.phrases"); - AutoExecConfig(true, "plugin.simpleautoscrambler"); - LogAction(0, -1, "[SAS] Simple AutoScrambler is loaded."); -} - -public OnAllPluginsLoaded() -{ - //something -} - -public OnLibraryRemoved(const String:name[]) -{ - //something -} - -public OnConfigsExecuted() -{ - - /** - Load up all the variable defaults - */ - LoadUpVariables(); - - /** - Log our activity - */ - if (g_bIsEnabled) - LogAction(0, -1, "Simple AutoScrambler is ENABLED"); - else - LogAction(0, -1, "Simple AutoScrambler is DISABLED"); -} - -public Action:Command_ScrambleNow(client, args) -{ - - /** - Make sure we are enabled - */ - if (!g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - Make sure the client is authorized to run this command. - */ - if (!SM_IsValidAdmin(client, g_sScrambleNowFlag)) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Make sure it's ok to scramble at this time - */ - if (!OkToScramble) - { - return Plugin_Handled; - } - - /** - Make sure it's ok to scramble at this time - */ - LogAction(0, -1, "[SAS] The scramblenow command was used"); - - /** - Scramble the teams - */ - StartAScramble(); - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public HookRoundStart(Handle:event, const String:name[], bool:dontBroadcast) -{ - -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - -} - -public Action:Timer_ScrambleTeams(Handle:timer, any:mode) -{ - - /** - Make sure it's still ok to scramble - */ - if (!OkToScramble) - { - return Plugin_Handled; - } - - - switch (mode) - { - case - - - - } - - - /** - Reset the handle because the timer is over and the callback is done - */ - g_hScrambleTimer = INVALID_HANDLE; - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - -} - -stock StartAScramble(mode) -{ - - /** - See if we are already started a scramble - */ - if (g_hScrambleTimer == INVALID_HANDLE) - { - - /** - There is a scramble in progress - */ - return; - - } - - /** - Report that a scramble is about to start - */ - PrintCenterTextAll("%T", "Scramble", LANG_SERVER); - - /** - Start a timer and log the action - */ - g_hScrambleTimer = CreateTimer(g_fTimer_ScrambleDelay, Timer_ScrambleTeams, mode, TIMER_FLAG_NO_MAPCHANGE); - LogAction(0, -1, "[SAS] A scamble timer was started"); -} - -stock bool:OkToScramble() -{ - -} - -stock LoadUpVariables() -{ - g_bIsEnabled = GetConVarBool(sas_enabled); - g_bIsAutoScrambleEnabled = GetConVarBool(sas_autoscramble_enabled); - g_bIsVoteEnabled = GetConVarBool(sas_vote_enabled); - g_bIsAdminImmunityEnabled = GetConVarBool(sas_admin_immunity_enabled); - g_iAutoScramble_Minplayers = GetConVarInt(sas_autoscramble_minplayers); - g_iAutoScramble_Mode = GetConVarInt(sas_autoscramble_mode); - g_iAutoScramble_WinStreak = GetConVarInt(sas_autoscramble_winstreak); - g_iAutoScramble_SteamRoll = GetConVarInt(sas_autoscramble_steamroll); - g_iAutoScramble_Frags = GetConVarInt(sas_autoscramble_frags); - g_iVote_Mode = GetConVarInt(sas_vote_mode); - g_iVote_MinPlayers = GetConVarInt(sas_vote_minplayers); - GetConVarString(sas_admin_flag_scramblenow, g_sScrambleNowFlag, sizeof(g_sScrambleNowFlag)); - GetConVarString(sas_admin_flag_immunity, g_sAdminImmunityFlag, sizeof(g_sAdminImmunityFlag)); - g_fTimer_ScrambleDelay = GetConVarFloat(sas_timer_scrambledelay); - g_fVote_UpCount = GetConVarFloat(sas_vote_upcount); - g_fVote_WinPercent = GetConVarFloat(sas_vote_winpercent); - g_iMaxEntities = GetMaxEntities(); - g_iOwnerOffset = FindSendPropInfo("CBaseObject", "m_hBuilder"); -} - -stock TF2_DestroyBuildings(client) -{ - - /** - We have to start a loop to check the owner of all the valid entities - */ - for (new i = MaxClients + 1; i <= g_iMaxEntities; i++) - { - if (!IsValidEntity(i)) - { - - /** - Not valid, continue to next one - */ - continue; - } - - /** - Get the name of the current entity - */ - decl String:sNetClass[32]; - GetEntityNetClass(i, sNetClass, sizeof(sNetClass)); - - /** - See if its something that an engineer would build - */ - if (strcmp(sNetClass, "CObjectSentrygun") == 0 - || strcmp(sNetClass, "CObjectTeleporter") == 0 - || strcmp(sNetClass, "CObjectDispenser") == 0) - { - - /** - It is, so lets check the owner - */ - if (GetEntDataEnt2(i, g_iOwnerOffset) == client) - { - - /** - It's the clients building, so we blow it up. - */ - SetVariantInt(9999); - AcceptEntityInput(i, "RemoveHealth"); - } - } - } -} \ No newline at end of file diff --git a/addons/sourcemod/scripting/simple-chatcolors.sp b/addons/sourcemod/scripting/simple-chatcolors.sp deleted file mode 100644 index 539d057..0000000 --- a/addons/sourcemod/scripting/simple-chatcolors.sp +++ /dev/null @@ -1,496 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Chat Colors -Description: - Changes the colors of players chat based on config file -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#pragma semicolon 1 -#include -#include - -#define PLUGIN_VERSION "0.9.0.$Rev$" - -#define CHAT_SYMBOL '@' -#define TRIGGER_SYMBOL1 '!' -#define TRIGGER_SYMBOL2 '/' -#define CHAT_MAX_MESSAGE_LENGTH 1024 - -new Handle:g_hDebugCvar = INVALID_HANDLE; -new Handle:g_aGroupNames = INVALID_HANDLE; -new Handle:g_aGroupFlag = INVALID_HANDLE; -new Handle:g_aGroupNameColor = INVALID_HANDLE; -new Handle:g_aGroupTextColor = INVALID_HANDLE; - -new bool:g_bDebug = false; - -new g_iArraySize; - -new g_aPlayerColorIndex[MAXPLAYERS + 1] = { -1, ... }; - -public Plugin:myinfo = -{ - name = "Simple Chat Colors", - author = "Simple Plugins", - description = "Changes the colors of players chat based on config file.", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -}; - -/** -Sourcemod callbacks -*/ -public OnPluginStart() -{ - - /** - Need to create all of our console variables. - */ - CreateConVar("sm_chatcolors_version", PLUGIN_VERSION, "Simple Chat Colors", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - g_hDebugCvar = CreateConVar("sm_chatcolors_debug", "1", "Enable/Disable debugging information"); - - /** - Hook console variables - */ - HookConVarChange(g_hDebugCvar, ConVarSettingsChanged); - - /** - Need to register the commands we are going to use - */ - RegConsoleCmd("say", Command_Say); - RegConsoleCmd("say_team", Command_SayTeam); - RegAdminCmd("sm_reloadcolorsconfig", Command_Reload, ADMFLAG_GENERIC, "Reloads settings from config file"); - - /** - Create the arrays - */ - g_aGroupNames = CreateArray(256, 1); - g_aGroupFlag = CreateArray(15, 1); - g_aGroupNameColor = CreateArray(15, 1); - g_aGroupTextColor = CreateArray(15, 1); - - /** - Load the admins and colors from the config - */ - LoadAdminsAndColorsFromConfig(); - g_iArraySize = GetArraySize(g_aGroupNames); -} - -public OnConfigsExecuted() -{ - g_bDebug = GetConVarBool(g_hDebugCvar); - ReloadConfigFile(); -} - -public OnClientPostAdminCheck(client) -{ - - /** - Check the client to see if they are a admin - */ - CheckAdmin(client); -} - -public OnClientDisconnect(client) -{ - g_aPlayerColorIndex[client] = -1; -} - -/** -Commands -*/ -public Action:Command_Say(client, args) -{ - - /** - Make sure we are enabled. - */ - if (client == 0 || IsChatTrigger()) - { - return Plugin_Continue; - } - - if (g_aPlayerColorIndex[client] != -1) - { - - /** - The client is, so get the chat message and strip it down. - */ - decl String:sArg[CHAT_MAX_MESSAGE_LENGTH], - String:sChatMsg[CHAT_MAX_MESSAGE_LENGTH]; - - new bool:bAlive = IsPlayerAlive(client); - - GetCmdArgString(sArg, sizeof(sArg)); - StripQuotes(sArg); - TrimString(sArg); - new startidx; - if (sArg[strlen(sArg)-1] == '"') - { - sArg[strlen(sArg)-1] = '\0'; - startidx = 1; - } - - /** - Bug out if they are using the admin chat symbol (admin chat). If we are in CSS it may not find all the triggers, so we double check. - */ - if (sArg[startidx] == CHAT_SYMBOL || sArg[startidx] == TRIGGER_SYMBOL1 || sArg[startidx] == TRIGGER_SYMBOL2) - { - return Plugin_Continue; - } - - /** - Log the message for hlstatsx and other things. - */ - new iUserID = GetClientUserId(client); - decl String:sAuthID[64]; - GetClientAuthString(client, sAuthID, sizeof(sAuthID)); - LogToGame("\"%N<%i><%s><>\" say \"%s\"", client, iUserID, sAuthID, sArg); - - /** - Format the message. - */ - FormatMessage(client, 0, bAlive, sChatMsg, sArg, g_aPlayerColorIndex[client]); - - /** - Send the message. - */ - //SayText2(0, client, sChatMsg); - CPrintToChatAll(sChatMsg); - - /** - We are done, bug out, and stop the original chat message. - */ - return Plugin_Stop; - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -public Action:Command_SayTeam(client, args) -{ - - /** - Make sure we are enabled. - */ - if (client == 0 || IsChatTrigger()) - { - return Plugin_Continue; - } - - /** - Check the client to see if they are a admin - */ - if (g_aPlayerColorIndex[client] != -1) - { - - /** - The client is, so get the chat message and strip it down. - */ - decl String:sArg[CHAT_MAX_MESSAGE_LENGTH], - String:sChatMsg[CHAT_MAX_MESSAGE_LENGTH]; - - new bool:bAlive = IsPlayerAlive(client); - new iCurrentTeam = GetClientTeam(client); - - GetCmdArgString(sArg, sizeof(sArg)); - StripQuotes(sArg); - TrimString(sArg); - new startidx; - if (sArg[strlen(sArg)-1] == '"') - { - sArg[strlen(sArg)-1] = '\0'; - startidx = 1; - } - - /** - Bug out if they are using the admin chat symbol (admin chat). - */ - if (sArg[startidx] == CHAT_SYMBOL || sArg[startidx] == TRIGGER_SYMBOL1 || sArg[startidx] == TRIGGER_SYMBOL2) - { - return Plugin_Continue; - } - - /** - Log the message for hlstatsx and other things. - */ - new iUserID = GetClientUserId(client); - decl String:sAuthID[64]; - GetClientAuthString(client, sAuthID, sizeof(sAuthID)); - LogToGame("\"%N<%i><%s><>\" say_team \"%s\"", client, iUserID, sAuthID, sArg); - - /** - Format the message. - */ - FormatMessage(client, iCurrentTeam, bAlive, sChatMsg, sArg, g_aPlayerColorIndex[client]); - - /** - Send the message to the same team - */ - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientConnected(i) && IsClientInGame(i) && GetClientTeam(i) == iCurrentTeam) - { - CPrintToChat(client, sChatMsg); - } - } - - /** - We are done, bug out, and stop the original chat message. - */ - return Plugin_Stop; - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -public Action:Command_Reload(client, args) -{ - ReloadConfigFile(); - return Plugin_Handled; -} - -/** -Stock Functions -*/ -stock LoadAdminsAndColorsFromConfig() -{ - - /** - Make sure the config file is here and load it up - */ - new String:sConfigFile[256]; - BuildPath(Path_SM, sConfigFile, sizeof(sConfigFile), "configs/simple-chatcolors.cfg"); - if (!FileExists(sConfigFile)) - { - - /** - Config file doesn't exists, stop the plugin - */ - LogError("[SCC] Simple Chat Colors is not running! Could not find file %s", sConfigFile); - SetFailState("Could not find file %s", sConfigFile); - } - - /** - Create the arrays and variables - */ - new String:sGroupName[256]; - new String:sGroupFlag[15]; - new String:sGroupNameColor[15]; - new String:sGroupTextColor[15]; - - - /** - Load config file as a KeyValues file - */ - new Handle:kvChatColors = CreateKeyValues("admin_colors"); - FileToKeyValues(kvChatColors, sConfigFile); - - if (!KvGotoFirstSubKey(kvChatColors)) - { - return; - } - - /** - Load up all the groups in the file - */ - do - { - - /** - Get the section name; should be the "group" name - */ - KvGetSectionName(kvChatColors, sGroupName, sizeof(sGroupName)); - - - /** - Get the flags and colors - */ - KvGetString(kvChatColors, "flag", sGroupFlag, sizeof(sGroupFlag)); - KvGetString(kvChatColors, "namecolor", sGroupNameColor, sizeof(sGroupNameColor)); - KvGetString(kvChatColors, "textcolor", sGroupTextColor, sizeof(sGroupTextColor)); - - if (g_bDebug) - { - LogMessage("Group Name/SteamID: %s", sGroupName); - LogMessage("Flag String: %s", sGroupFlag); - LogMessage("Color on name: %s", sGroupNameColor); - LogMessage("Color of text: %s", sGroupTextColor); - } - - /** - Push the values to the arrays - */ - PushArrayString(g_aGroupNames, sGroupName); - PushArrayString(g_aGroupFlag, sGroupFlag); - PushArrayString(g_aGroupNameColor, sGroupNameColor); - PushArrayString(g_aGroupTextColor, sGroupTextColor); - } while (KvGotoNextKey(kvChatColors)); - - /** - Close our handle - */ - CloseHandle(kvChatColors); -} - -stock ReloadConfigFile() -{ - - /** - Clear the array - */ - ClearArray(g_aGroupNames); - ClearArray(g_aGroupFlag); - ClearArray(g_aGroupNameColor); - ClearArray(g_aGroupTextColor); - - /** - Load the admins, groups, and colors from the config - */ - LoadAdminsAndColorsFromConfig(); - g_iArraySize = GetArraySize(g_aGroupNames); - - /** - Recheck all the online players for assigned colors - */ - for (new index = 1; index <= MaxClients; index++) - { - if (IsClientConnected(index) && IsClientInGame(index)) - { - CheckAdmin(index); - } - } -} - -stock CheckAdmin(client) -{ - new String:sFlags[15]; - new String:sClientSteamID[64]; - new iGroupFlags; - new iFlags; - new iIndex = -1; - - /** - Look for a steamid first - */ - GetClientAuthString(client, sClientSteamID, sizeof(sClientSteamID)); - iIndex = FindStringInArray(g_aGroupNames, sClientSteamID); - if (iIndex != -1) - { - g_aPlayerColorIndex[client] = iIndex; - } - - /** - Didn't find one, check flags - */ - else - { - /** - Search for flag in groups - */ - - iFlags = GetUserFlagBits(client); - for (iIndex = 0; iIndex < g_iArraySize; iIndex++) - { - GetArrayString(g_aGroupFlag, iIndex, sFlags, sizeof(sFlags)); - iGroupFlags = ReadFlagString(sFlags); - if (iFlags & iGroupFlags) - { - g_aPlayerColorIndex[client] = iIndex; - break; - } - } - } - - if (g_bDebug) - { - PrintToChatAll("SteamID: %s", sClientSteamID); - PrintToChatAll("Array Index: %i", iIndex); - PrintToChatAll("Flag String: %s", sFlags); - PrintToChatAll("Flag Bits of Client: %i", iFlags); - PrintToChatAll("Flag Bits of Group: %i", iGroupFlags); - } -} - -stock FormatMessage(iClient, iTeam, bool:bAlive, String:sChatMsg[], const Sting:sMessage[], iArrayIndex) -{ - decl String:sDead[10], - String:sTeam[10], - String:sClientName[64]; - - GetClientName(iClient, sClientName, sizeof(sClientName)); - - if (iTeam != 0) - { - Format(sTeam, sizeof(sTeam), "(TEAM) "); - } - else - { - Format(sTeam, sizeof(sTeam), ""); - } - if (bAlive) - { - Format(sDead, sizeof(sDead), ""); - } - else - { - Format(sDead, sizeof(sDead), "*DEAD* "); - } - - new String:sNameColor[15]; - new String:sTextColor[15]; - GetArrayString(g_aGroupNameColor, iArrayIndex, sNameColor, sizeof(sNameColor)); - GetArrayString(g_aGroupTextColor, iArrayIndex, sTextColor, sizeof(sTextColor)); - - Format(sChatMsg, CHAT_MAX_MESSAGE_LENGTH, "{default}%s%s%s%s {default}: %s%s", sDead, sTeam, sNameColor, sClientName, sTextColor, sMessage); -} - -/** -Adjust the settings if a convar was changed -*/ -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (StringToInt(newValue) == 1) - { - g_bDebug = true; - } - else - { - g_bDebug = false; - } -} \ No newline at end of file diff --git a/addons/sourcemod/scripting/simple-donatorbenefits.sp b/addons/sourcemod/scripting/simple-donatorbenefits.sp deleted file mode 100644 index e3f6845..0000000 --- a/addons/sourcemod/scripting/simple-donatorbenefits.sp +++ /dev/null @@ -1,1312 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Donator Benefits -Description: - Provides donator benefits to players -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include -#include - -#define PLUGIN_VERSION "1.1.$Rev$" - -#define CHAT_SYMBOL '@' -#define CHAT_MAX_MESSAGE_LENGTH 1024 - -enum PlayerData -{ - bool:bIsDonator, - bool:bQueue, - bool:bImmune, - iHealthCount, - iNewTeam -}; - -/** - Public convar handles - */ -new Handle:sdb_enabled = INVALID_HANDLE; -new Handle:sdb_donationflag = INVALID_HANDLE; -new Handle:sdb_soundfile = INVALID_HANDLE; -new Handle:sdb_joinsound_enabled = INVALID_HANDLE; -new Handle:sdb_joinpubmsg_enabled = INVALID_HANDLE; -new Handle:sdb_joinprivmsg_enabled = INVALID_HANDLE; -new Handle:sdb_chatcolors_enabled = INVALID_HANDLE; -new Handle:sdb_immunity_enabled = INVALID_HANDLE; -new Handle:sdb_ubercharge_enabled = INVALID_HANDLE; -new Handle:sdb_givehealth_enabled = INVALID_HANDLE; -new Handle:sdb_nofalldmg_enabled = INVALID_HANDLE; -new Handle:sdb_fastheavy_enabled = INVALID_HANDLE; -new Handle:sdb_swapteam_enabled = INVALID_HANDLE; -new Handle:sdb_chatcolor = INVALID_HANDLE; -new Handle:sdb_uberlevel = INVALID_HANDLE; -new Handle:sdb_healthcount = INVALID_HANDLE; -new Handle:sdb_healthbonus = INVALID_HANDLE; -new Handle:sdb_heavymultiplier = INVALID_HANDLE; - -/** -Create global enable/disable bools so we don't have to check the console variable on every call -*/ -new bool:g_bIsEnabled = true; -new bool:g_bIsJoinSoundEnabled = true; -new bool:g_bIsJoinPubMsgEnabled = true; -new bool:g_bIsJoinPrivMsgEnabled = true; -new bool:g_bIsChatColorsEnabled = true; -new bool:g_bIsImmuntyEnabled = true; -new bool:g_bIsUberChargeEnabled = true; -new bool:g_bIsGiveHealthEnabled = true; -new bool:g_bIsNoFallDmgEnabled = true; -new bool:g_bIsFastHeayEnabled = true; -new bool:g_bIsSwapTeamEnabled = true; - -/** - Player arrays - */ -new g_aPlayers[MAXPLAYERS + 1][PlayerData]; - - -/** -Rest of the globals -*/ -new bool:g_bRoundEnd = false; -new String:g_sCharDonatorFlag[5]; -new String:g_sSoundFile[PLATFORM_MAX_PATH]; -new String:g_sChatColor[11]; -new g_iHealthBonus; -new g_iHealthCount; -new g_iClassMaxHealth[TFClassType] = {0, 125, 125, 200, 175, 150, 300, 175, 125, 125}; -new g_fClassMaxSpeed[TFClassType] = {0, 400, 300, 240, 280, 320, 230, 300, 300, 300}; -new Float:g_fHeavyMultiplier = 0.0; -new Float:g_fUberLevel = 0.0; - -public Plugin:myinfo = -{ - name = "Simple Donation Benefits", - author = "Simple Plugins", - description = "Gives donators benefits to players", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -} - -public OnPluginStart() -{ - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook the game events - */ - LogAction(0, -1, "[SDB] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_connect", HookPlayerSpawn, EventHookMode_Pre); - HookEvent("player_spawn", HookPlayerSpawn, EventHookMode_Post); - HookEvent("player_death", HookPlayerDeath, EventHookMode_Post); - HookEvent("player_team", HookPlayerChangeTeam, EventHookMode_Post); - switch (g_CurrentMod) - { - case GameType_TF: - { - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - HookEvent("player_changeclass", HookPlayerClass, EventHookMode_Post); - } - case GameType_DOD: - { - HookEvent("dod_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_Post); - } - default: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - } - } - - /** - Create console variables - */ - CreateConVar("sdb_version", PLUGIN_VERSION, "Simple Donation Benefits", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - sdb_enabled = CreateConVar("sdb_enabled", "1", "Enable/Disable Simple Donation Benefits"); - sdb_donationflag = CreateConVar("sdb_donationflag", "a", "Flag ALREADY given to donators. Must be in char format"); - - /** - Create the enable/disable donator console variables - */ - sdb_joinsound_enabled = CreateConVar("sdb_joinsound_enabled", "1", "Enable/Disable donator join sound"); - sdb_joinpubmsg_enabled = CreateConVar("sdb_joinpubmsg_enabled", "1", "Enable/Disable public donator join message (replaces: as connected)"); - sdb_joinprivmsg_enabled = CreateConVar("sdb_joinprivmsg_enabled", "1", "Enable/Disable private donator join message (sent only to donator)"); - sdb_chatcolors_enabled = CreateConVar("sdb_chatcolors_enabled", "1", "Enable/Disable donator chat colors"); - sdb_immunity_enabled = CreateConVar("sdb_immunity_enabled", "1", "Enable/Disable donator round end immunity"); - sdb_ubercharge_enabled = CreateConVar("sdb_ubercharge_enabled", "1", "Enable/Disable donator medics starting with ubercharge"); - sdb_givehealth_enabled = CreateConVar("sdb_givehealth_enabled", "1", "Enable/Disable donator instant health bonus"); - sdb_nofalldmg_enabled = CreateConVar("sdb_nofalldmg_enabled", "1", "Enable/Disable no fall damage for donators"); - sdb_fastheavy_enabled = CreateConVar("sdb_fastheavy_enabled", "1", "Enable/Disable donator heavies moving faster while spinning"); - sdb_swapteam_enabled = CreateConVar("sdb_swampteam_enabled", "1", "Enable/Disable donator swap team ability"); - - /** - Create the donator setting console variables - */ - sdb_soundfile = CreateConVar("sdb_soundfile", "custom/donatorjoin.mp3", "The location of sound file"); - sdb_chatcolor = CreateConVar("sdb_chatcolor", "green", "Color to use for donator chat. Valid colors are green and lightgreen"); - sdb_uberlevel = CreateConVar("sdb_uberlevel", "0.5", "Uberlevel to give donator medic at spawn. 1.0 = full uber", _, true, 0.0, true, 1.0); - sdb_healthcount = CreateConVar("sdb_healthcount", "1", "Number of times a donator can use use instant health per life"); - sdb_healthbonus = CreateConVar("sdb_healthbonus", "100", "The amount of health to heal the donator"); - sdb_heavymultiplier = CreateConVar("sdb_heavyspeed", "0.5", "The speed multiplier for the fast heavy. Based on running speed. 1.0 = running speed. (Game Default is 0.20)", _, true, 0.0, true, 1.0); - - /** - Hook dukehacks calls - */ - dhAddClientHook(CHK_TakeDamage, Hacks_TakeDamageHook); - dhAddClientHook(CHK_PreThink, Hacks_PreThinkHook); - - /** - Hook the console variables if they change - */ - HookConVarChange(sdb_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_donationflag, ConVarSettingsChanged); - HookConVarChange(sdb_joinsound_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_joinpubmsg_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_joinprivmsg_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_chatcolors_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_immunity_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_ubercharge_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_givehealth_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_nofalldmg_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_swapteam_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_fastheavy_enabled, ConVarSettingsChanged); - HookConVarChange(sdb_soundfile, ConVarSettingsChanged); - HookConVarChange(sdb_chatcolor, ConVarSettingsChanged); - HookConVarChange(sdb_uberlevel, ConVarSettingsChanged); - HookConVarChange(sdb_healthcount, ConVarSettingsChanged); - HookConVarChange(sdb_healthbonus, ConVarSettingsChanged); - HookConVarChange(sdb_heavymultiplier, ConVarSettingsChanged); - - /** - Register the commands - */ - RegConsoleCmd("sm_swapteams", Command_SwapTeam, "sm_swapteams <[0]instant/[1]queued>: Swaps your team to the other team"); - RegConsoleCmd("sm_ihealth", Command_InstantHealth, "sm_ihealth: Gives you a instant health pack"); - RegAdminCmd("sm_teaser", Command_Teaser, ADMFLAG_GENERIC,"sm_teaser <[0]add/[1]remove>: Gives temporary donator privilages to a player"); - RegConsoleCmd("say", Command_Say); - - RegConsoleCmd("sm_test", Command_TEST); - - /** - Load the translations - */ - LoadTranslations("common.phrases"); - LoadTranslations("simpledonatorbenefits.phrases"); - - /** - Load or create the config file - */ - AutoExecConfig(true, "plugin.simpledonatorbenefits"); - LogAction(0, -1, "[SDB] Simple Donator Benefits is loaded."); -} - -public OnAllPluginsLoaded() -{ - //something -} - -public OnLibraryRemoved(const String:name[]) -{ - //something -} - -public OnConfigsExecuted() -{ - /** - Load up all the variable defaults - */ - LoadUpVariables(); - - /** - If the join sound is enabled, prep the sound files - */ - if (g_bIsJoinSoundEnabled) - PrepSoundFile(); - - /** - Log our activity - */ - if (g_bIsEnabled) - LogAction(0, -1, "Simple Donation Benefits is ENABLED"); - else - LogAction(0, -1, "Simple Donation Benefits is DISABLED"); -} - -public OnClientPostAdminCheck(client) -{ - - /** - Check if the client is a donator - */ - if (SM_IsValidAdmin(client, g_sCharDonatorFlag)) - { - - /** - They are, so we set the player array to true and start a timer for the sound or add - */ - g_aPlayers[client][bIsDonator] = true; - if (g_bIsJoinSoundEnabled || g_bIsJoinPrivMsgEnabled) - { - CreateTimer(10.0, Timer_DonatorJoined, client, TIMER_FLAG_NO_MAPCHANGE); - } - } - else - { - /** - They aren't, so we set the player array to false - */ - g_aPlayers[client][bIsDonator] = false; - } -} - -public OnClientDisconnect_Post(client) -{ - - /** - Clean up the player variables - */ - CleanUpPlayer(client); -} - -public Action:Command_SwapTeam(client, args) -{ - - /** - Make sure we are enabled - */ - if (!g_bIsEnabled || !g_bIsSwapTeamEnabled) - { - return Plugin_Handled; - } - - /** - Make sure the command is not started by the server - */ - if (client == 0) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "PlayerLevelCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Make sure the player is a donator - */ - if (!g_aPlayers[client][bIsDonator]) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Lets make sure the client is one a team we can swap. - If he is we set the global array to the opposite team. - */ - new iTeam = GetClientTeam(client); - if (iTeam == g_aCurrentTeams[Team1]) - { - g_aPlayers[client][iNewTeam] = g_aCurrentTeams[Team2]; - } - else if (iTeam == g_aCurrentTeams[Team2]) - { - g_aPlayers[client][iNewTeam] = g_aCurrentTeams[Team1]; - } - else - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "InValidTeam", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check to see if we have command arguments. - */ - if (GetCmdArgs()) - { - - /** - We do, so lets get it and see if the client wants to be switched instantly or queued for death. - */ - decl String:sArg[5]; - GetCmdArg(1, sArg, sizeof(sArg)); - new iWantsQue = StringToInt(sArg); - if (iWantsQue && !g_aPlayers[client][bQueue]) - { - - /** - He wants the que and isn't already in it, set the global array. - */ - g_aPlayers[client][bQueue] = true; - ReplyToCommand(client, "\x01\x04[STM]\x01 %T", "PlayerQueue", LANG_SERVER); - } - else if (!iWantsQue) - { - - /** - He wants to be switched right now, lets call the stock function. - */ - SM_MovePlayer(client, g_aPlayers[client][iNewTeam]); - } - } - else - { - - /** - There are no command arguments so we build and display the swap menu. - */ - new Handle:hPlayerMenu = BuildSwapModeMenu(); - DisplayMenu(hPlayerMenu, client, MENU_TIME_FOREVER); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_InstantHealth(client, args) -{ - - /** - Make sure we are enabled - */ - if (!g_bIsEnabled || !g_bIsGiveHealthEnabled) - { - return Plugin_Handled; - } - - /** - Make sure the command is not started by the server - */ - if (client == 0) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "PlayerLevelCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Make sure the player is a donator - */ - if (!g_aPlayers[client][bIsDonator]) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check health count to see if the player has reached the max - */ - if (g_aPlayers[client][iHealthCount] >= g_iHealthCount) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "ReachedCount", LANG_SERVER); - return Plugin_Handled; - } - - /** - Get the class of the player and the max health for that class - */ - new iHealth = GetClientHealth(client); - new TFClassType:PlayerClass = TF2_GetPlayerClass(client); - new iMaxHealth = g_iClassMaxHealth[PlayerClass]; - - /** - Check to see if the player is at the max health of the class - */ - if (iHealth >= iMaxHealth) - { - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "AtMaxHealth", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check the current health - */ - if (iHealth + g_iHealthBonus >= iMaxHealth) - { - - /** - Raise them to max health if the current health + bonus would go above it - */ - SetEntityHealth(client, iMaxHealth); - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "ToMaxHealth", LANG_SERVER); - } - else - { - - /** - Give them the instant health bonus - */ - SetEntityHealth(client, iHealth + g_iHealthBonus); - ReplyToCommand(client, "\x01\x04[SDB]\x01 %T", "HealthBonus", LANG_SERVER); - } - - /** - Increase the count - */ - g_aPlayers[client][iHealthCount] += 1; - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_Teaser(client, args) -{ - - /** - Make sure we are enabled - */ - if (!g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - Check to see if we have command arguments. - */ - new iCmdArgs = GetCmdArgs(); - if (iCmdArgs == 0) - { - - /** - We don't so display the player menu. - */ - new Handle:hPlayerMenu = BuildPlayerMenu(); - DisplayMenu(hPlayerMenu, client, MENU_TIME_FOREVER); - return Plugin_Handled; - } - - /** - We have some arguments, see if we can find the player - */ - decl String:sPlayer[64]; - GetCmdArg(1, sPlayer, sizeof(sPlayer)); - new iTarget = FindTarget(client, sPlayer, true, true); - if (iTarget == -1 || !IsClientInGame(iTarget)) - { - - /** - We don't know who this is, so display the player menu. - */ - new Handle:hPlayerMenu = BuildPlayerMenu(); - DisplayMenu(hPlayerMenu, client, MENU_TIME_FOREVER); - } - else - { - /** - We found the player, see if we are supposed to turn it on or off. - */ - if (iCmdArgs >= 2) - { - decl String:sOn[3]; - GetCmdArg(2, sOn, sizeof(sOn)); - if (StringToInt(sOn)) - { - - /** - Turn temp benefits on. - */ - g_aPlayers[iTarget][bIsDonator] = true; - } - else - { - - /** - Turn temp benefits on. - */ - g_aPlayers[iTarget][bIsDonator] = false; - } - } - else - { - - /** - We don't know what to do, so just turn it on. - */ - g_aPlayers[iTarget][bIsDonator] = true; - } - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_Say(client, args) -{ - - /** - Make sure we are enabled. - */ - if (client == 0 || IsChatTrigger() || !g_bIsChatColorsEnabled || !g_bIsEnabled) - { - return Plugin_Continue; - } - - /** - Check the client to see if they are a donator. - */ - if (g_aPlayers[client][bIsDonator]) - { - - /** - The client is, so get the chat message and strip it down. - */ - decl String:sArg[CHAT_MAX_MESSAGE_LENGTH], - String:sChatMsg[CHAT_MAX_MESSAGE_LENGTH]; - new bool:bAlive = IsPlayerAlive(client); - GetCmdArgString(sArg, sizeof(sArg)); - StripQuotes(sArg); - TrimString(sArg); - new startidx; - if (sArg[strlen(sArg)-1] == '"') - { - sArg[strlen(sArg)-1] = '\0'; - startidx = 1; - } - - /** - Bug out if they are using the admin chat symbol (admin chat). - */ - if (sArg[startidx] == CHAT_SYMBOL) - { - return Plugin_Continue; - } - - /** - Format the message. - */ - FormatMessage(client, 0, bAlive, sChatMsg, sArg); - - /** - Send the message. - */ - SayText2(0, client, sChatMsg); - - /** - We are done, bug out, and stop the original chat message. - */ - return Plugin_Stop; - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -public Action:Hacks_TakeDamageHook(client, attacker, inflictor, Float:damage, &Float:multiplier, damagetype) -{ - - /** - Make sure we are enabled and the client is a donator. - */ - if (g_bIsEnabled && g_bIsNoFallDmgEnabled && g_aPlayers[client][bIsDonator]) - { - - /** - Check for fall damage. - */ - if (damagetype & DMG_FALL) - { - - /** - Cancel the fall damage and bug out. - */ - multiplier *= 0.0; - return Plugin_Changed; - } - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -public Action:Hacks_PreThinkHook(client) -{ - - /** - Make sure we are enabled and the client is a donator. - */ - if (!g_bIsEnabled || !g_bIsFastHeayEnabled || !g_aPlayers[client][bIsDonator]) - { - return Plugin_Continue; - } - - /** - Check the players class. We are looking for the heavy. - */ - new TFClassType:PlayerClass = TF2_GetPlayerClass(client); - if (PlayerClass == TFClass_Heavy) - { - - /** - We have a heavy, lets check the weapon. - */ - decl String:sWeaponCurrent[64]; - GetClientWeapon(client, sWeaponCurrent, sizeof(sWeaponCurrent)); - if (StrEqual(sWeaponCurrent, "tf_weapon_minigun", false)) - { - - /** - We have a minigun, check the heavies current weapon state to see if it's spinning. - */ - new iWeapon = GetPlayerWeaponSlot(client, 0); - new iWeaponState = GetEntProp(iWeapon, Prop_Send, "m_iWeaponState"); - if (iWeaponState > 0) - { - - /** - He is spinning, so lets change the heavies speed. - */ - new Float:fMaxSpeed = FloatMul(g_fHeavyMultiplier, float(g_fClassMaxSpeed[PlayerClass])); - SetEntPropFloat(client, Prop_Send, "m_flMaxspeed", fMaxSpeed); - } - } - } - - /** - We are done, bug out. - */ - // use Plugin_Continue (other options are ignored on PreThink hook) - return Plugin_Continue; -} - -public Action:HookPlayerConnect(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Make sure we are enabled. - */ - if (!g_bIsEnabled || !g_bIsJoinPubMsgEnabled || !dontBroadcast) - { - return Plugin_Continue; - } - - /** - Get our event variables and check the client. - */ - new iUserId = GetEventInt(event,"userid"); - new iClient = GetClientOfUserId(iUserId); - if (iClient != 0) - { - - /** - Get the info on the client and format the message. - */ - decl String:sClientName[255], - String:sAuthID[255], - String:sMsg[1024]; - - GetEventString(event, "name", sClientName, sizeof(sClientName)); - GetClientAuthString(iClient, sAuthID, sizeof(sAuthID)); - Format(sMsg, sizeof(sMsg), "%T", "PublicJoinMessage", LANG_SERVER, sClientName); - - /** - Print the message to the clients and do the normal functions. - */ - for (new i = 1; i <= MaxClients; i++) - { - if(IsClientConnected(i) && IsClientInGame(i)) - { - PrintToChat(i,"\x01\x05%s", sMsg); - PrintToConsole(i,"%s has connected.", sClientName); - } - } - LogToGame("\"%s<%d><%s><>\" entered the game", sClientName, iUserId, sAuthID); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public HookPlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled && g_bIsUberChargeEnabled) - { - - /** - Get the event variables and check the class for medic - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - if (TF2_GetPlayerClass(iClient) == TFClass_Medic) - { - - /** - Start a timer to get the medic the uber boost - */ - CreateTimer(0.25, Timer_PlayerUberDelay, iClient, TIMER_FLAG_NO_MAPCHANGE); - } - } -} - -public HookPlayerClass(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled && g_bIsUberChargeEnabled) - { - - /** - Get the event variables and check the class for medic - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - if (TF2_GetPlayerClass(iClient) == TFClass_Medic) - { - - /** - Start a timer to get the medic the uber boost - */ - CreateTimer(0.25, Timer_PlayerUberDelay, iClient, TIMER_FLAG_NO_MAPCHANGE); - } - } -} - -public HookPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled || g_bIsSwapTeamEnabled) - { - - /** - Get the event variables - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - new String:sWeapon[256]; - GetEventString(event, "weapon", sWeapon, sizeof(sWeapon)); - - /** - Bug out if world killed him. Means he changed team or something - */ - if (StrEqual(sWeapon, "world", false)) - { - g_aPlayers[iClient][bQueue] = false; - return; - } - - /** - If he is queued up, swap him - */ - if (g_aPlayers[iClient][bQueue]) - { - SM_MovePlayer(iClient, g_aPlayers[iClient][iNewTeam]); - } - } -} - -public HookPlayerChangeTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled || g_bIsSwapTeamEnabled) - { - - /** - Get the event variables - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - - /** - If he is queued up, clear the status - */ - if (g_aPlayers[iClient][bQueue]) - { - g_aPlayers[iClient][bQueue] = false; - } - } -} - -public HookRoundStart(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Set our variables. - */ - g_bRoundEnd = false; - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled && g_bIsImmuntyEnabled) - { - - /** - Get rid of their immunity. - */ - ProcessRoundEndImmunity(false); - } -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Set our variables. - */ - g_bRoundEnd = true; - - /** - Make sure we are enabled. - */ - if (g_bIsEnabled && g_bIsImmuntyEnabled) - { - - /** - Give them their immunity. - */ - ProcessRoundEndImmunity(true); - } -} - -public Action:Timer_DonatorJoined(Handle:timer, any:client) -{ - - /** - Make sure sounds are enabled. - */ - if (g_bIsEnabled && g_bIsJoinSoundEnabled) - { - EmitSoundToClient(client, g_sSoundFile); - } - - /** - Make sure private messages are enabled. - */ - if (g_bIsJoinPrivMsgEnabled) - { - - /** - Send messages to the client. - */ - decl String:sMsg[1024]; - Format(sMsg, sizeof(sMsg), "%T", "PrivateJoinMessage", LANG_SERVER); - PrintToChat(client,"\x01\x05%s", sMsg); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Timer_PlayerUberDelay(Handle:timer, any:client) -{ - - /** - Make sure the client is still in game. - */ - if (IsClientInGame(client)) - { - - /** - Make sure the client is still a medic. - */ - if (TF2_GetPlayerClass(client) == TFClass_Medic) - { - - /** - Get the medgun weapon index - */ - new iIndex = GetPlayerWeaponSlot(client, 1); - if (iIndex > 0) - { - - /** - Set the uber level with the bonus. - */ - SetEntPropFloat(iIndex, Prop_Send, "m_flChargeLevel", g_fUberLevel); - } - } - } -} - -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (convar == sdb_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsEnabled = false; - } - else - { - g_bIsEnabled = true; - } - } - else if (convar == sdb_donationflag) - { - Format(g_sCharDonatorFlag, sizeof(g_sCharDonatorFlag), "%s", newValue); - } - else if (convar == sdb_soundfile) - { - Format(g_sSoundFile, sizeof(g_sSoundFile), "%s", newValue); - } - else if (convar == sdb_joinsound_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsJoinSoundEnabled = false; - } - else - { - g_bIsJoinSoundEnabled = true; - } - } - else if (convar == sdb_joinpubmsg_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsJoinPubMsgEnabled = false; - } - else - { - g_bIsJoinPubMsgEnabled = true; - } - } - else if (convar == sdb_joinprivmsg_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsJoinPrivMsgEnabled = false; - } - else - { - g_bIsJoinPrivMsgEnabled = true; - } - } - else if (convar == sdb_chatcolors_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsChatColorsEnabled = false; - } - else - { - g_bIsChatColorsEnabled = true; - } - } - else if (convar == sdb_immunity_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsImmuntyEnabled = false; - } - else - { - g_bIsImmuntyEnabled = true; - } - } - else if (convar == sdb_ubercharge_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsUberChargeEnabled = false; - } - else - { - g_bIsUberChargeEnabled = true; - } - } - else if (convar == sdb_givehealth_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsGiveHealthEnabled = false; - } - else - { - g_bIsGiveHealthEnabled = true; - } - } - else if (convar == sdb_nofalldmg_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsNoFallDmgEnabled = false; - } - else - { - g_bIsNoFallDmgEnabled = true; - } - } - else if (convar == sdb_fastheavy_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsFastHeayEnabled = false; - } - else - { - g_bIsFastHeayEnabled = true; - } - } - else if (convar == sdb_swapteam_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsSwapTeamEnabled = false; - } - else - { - g_bIsSwapTeamEnabled = true; - } - } - else if (convar == sdb_chatcolor) - { - Format(g_sChatColor, sizeof(g_sChatColor), "%s", newValue); - } - else if (convar == sdb_uberlevel) - { - g_fUberLevel = StringToFloat(newValue); - } - else if (convar == sdb_healthcount) - { - g_iHealthCount = StringToInt(newValue); - } - else if (convar == sdb_healthbonus) - { - g_iHealthBonus = StringToInt(newValue); - } - else if (convar == sdb_heavymultiplier) - { - g_fHeavyMultiplier = StringToFloat(newValue); - } -} - -stock LoadUpVariables() -{ - g_bIsEnabled = GetConVarBool(sdb_enabled); - g_bIsJoinSoundEnabled = GetConVarBool(sdb_enabled); - g_bIsJoinPubMsgEnabled = GetConVarBool(sdb_enabled); - g_bIsJoinPrivMsgEnabled = GetConVarBool(sdb_enabled); - g_bIsChatColorsEnabled = GetConVarBool(sdb_enabled); - g_bIsImmuntyEnabled = GetConVarBool(sdb_enabled); - g_bIsUberChargeEnabled = GetConVarBool(sdb_enabled); - g_bIsGiveHealthEnabled = GetConVarBool(sdb_enabled); - g_bIsNoFallDmgEnabled = GetConVarBool(sdb_enabled); - g_bIsFastHeayEnabled = GetConVarBool(sdb_enabled); - g_bIsSwapTeamEnabled = GetConVarBool(sdb_enabled); - GetConVarString(sdb_donationflag, g_sCharDonatorFlag, sizeof(g_sCharDonatorFlag)); - GetConVarString(sdb_soundfile, g_sSoundFile, sizeof(g_sSoundFile)); - GetConVarString(sdb_chatcolor, g_sChatColor, sizeof(g_sChatColor)); - g_bRoundEnd = false; - g_iHealthBonus = GetConVarInt(sdb_healthbonus); - g_iHealthCount = GetConVarInt(sdb_healthcount); - g_fHeavyMultiplier = GetConVarFloat(sdb_heavymultiplier); - g_fUberLevel = GetConVarFloat(sdb_uberlevel); -} - -stock PrepSoundFile() -{ - decl String:buffer[PLATFORM_MAX_PATH]; - PrecacheSound(g_sSoundFile, true); - Format(buffer, sizeof(buffer), "sound/%s", g_sSoundFile); - AddFileToDownloadsTable(buffer); -} - -stock CleanUpPlayer(client) -{ - g_aPlayers[client][bIsDonator] = false; - g_aPlayers[client][bQueue] = false; - g_aPlayers[client][bImmune] = false; - g_aPlayers[client][iNewTeam] = 0; - g_aPlayers[client][iHealthCount] = 0; -} - -stock ProcessRoundEndImmunity(bool:give) -{ - for (new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][bIsDonator]) - { - if (give) - { - SetEntProp(i, Prop_Data, "m_takedamage", 0, 1); - g_aPlayers[i][bImmune] = true; - } - else - { - SetEntProp(i, Prop_Data, "m_takedamage", 2, 1); - g_aPlayers[i][bImmune] = false; - } - } - } -} - -stock FormatMessage(iClient, iTeam, bool:bAlive, String:sChatMsg[], const Sting:sMessage[]) -{ - decl String:sDead[10], - String:sTeam[10], - String:sClientName[64]; - GetClientName(iClient, sClientName, sizeof(sClientName)); - if (iTeam != 0) - Format(sTeam, sizeof(sTeam), "(TEAM) "); - else - Format(sTeam, sizeof(sTeam), ""); - if (bAlive) - Format(sDead, sizeof(sDead), ""); - else - Format(sDead, sizeof(sDead), "*DEAD* "); - if (StrContains(g_sChatColor, "light", false) == -1) - Format(sChatMsg, CHAT_MAX_MESSAGE_LENGTH, "\x01%s%s\x03%s \x01: \x05%s", sDead, sTeam, sClientName, sMessage); - else - Format(sChatMsg, CHAT_MAX_MESSAGE_LENGTH, "\x01%s%s\x03%s \x01: \x04%s", sDead, sTeam, sClientName, sMessage); -} - -stock SayText2(target, author, const String:message[]) -{ - new Handle:hBf; - if (target == 0) - hBf = StartMessageAll("SayText2"); - else - hBf = StartMessageOne("SayText2", target); - if (hBf != INVALID_HANDLE) - { - BfWriteByte(hBf, author); - BfWriteByte(hBf, true); - BfWriteString(hBf, message); - EndMessage(); - } -} - -stock ProcessAdmins() -{ - for (new i = 1; i <= MaxClients; i++) - { - if (SM_IsValidAdmin(i, g_sCharDonatorFlag)) - { - g_aPlayers[i][bDonator] = true; - } - else - { - g_aPlayers[i][bDonator] = false; - } - } -} - -stock ProcessLate() -{ - if (g_bIsEnabled) - { - ProcessAdmins(); - PrepSoundFile(); - if (g_bRoundEnd && g_bIsImmuntyEnabled) - { - ProcessRoundEndImmunity(true); - } - if (!g_bIsImmuntyEnabled) - { - ProcessRoundEndImmunity(false); - } - } - else - { - ProcessRoundEndImmunity(false); - } -} - -public Menu_SwapMode(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, 64); - if (StringToInt(sSelection)) - g_aPlayers[param1][bQueue] = false; - else - g_aPlayers[param1][bQueue] = true; - if (!g_aPlayers[param1][bQueue]) - SM_MovePlayer(param1, g_aPlayers[param1][iNewTeam]); - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -public Menu_SelectPlayer(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[256]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - new iTarget = GetClientOfUserId(StringToInt(sSelection)); - if (g_aPlayers[iTarget][bIsDonator]) - g_aPlayers[iTarget][bIsDonator] = false; - else - g_aPlayers[iTarget][bIsDonator] = true; - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -stock Handle:BuildSwapModeMenu() -{ - new Handle:menu = CreateMenu(Menu_SwapMode); - SetMenuTitle(menu, "Select When to Swap:"); - AddMenuItem(menu, "0", "Instantly (Kills)"); - AddMenuItem(menu, "1", "Queue on next death"); - SetMenuExitBackButton(menu, false); - return menu; -} - -stock Handle:BuildPlayerMenu() -{ - new Handle:menu = CreateMenu(Menu_SelectPlayer); - AddTargetsToMenu(menu, 0, true, false); - SetMenuTitle(menu, "Select A Player:"); - SetMenuExitBackButton(menu, true); - return menu; -} - -public Action:Command_TEST(client, args) -{ - -} \ No newline at end of file diff --git a/addons/sourcemod/scripting/simple-messagesuppression.sp b/addons/sourcemod/scripting/simple-messagesuppression.sp deleted file mode 100644 index f7725a4..0000000 --- a/addons/sourcemod/scripting/simple-messagesuppression.sp +++ /dev/null @@ -1,227 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Message Suppression -Description: - Blocks Specific Message Outputs -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include -#include - -#define SUPPRESS_VERSION "1.1.$Rev$" - -public Plugin:myinfo = -{ - name = "Simple Message Suppression", - author = "FlyingMongoose, psychonic", - description = "Blocks Specific Message Outputs", - version = SUPPRESS_VERSION, - url = "http://www.simple-plugins.com/" -} - -new Handle:cvarBlockSpectateMessage; -new Handle:cvarBlockDisconnectMessage; -new Handle:cvarBlockConnectMessage; -new Handle:cvarAdminShowMessages; -new iSpecTeam = 1; - - -public OnPluginStart() -{ - CreateConVar("suppress_version", SUPPRESS_VERSION, _, FCVAR_PLUGIN|FCVAR_NOTIFY|FCVAR_REPLICATED|FCVAR_SPONLY|FCVAR_DONTRECORD); - cvarBlockSpectateMessage = CreateConVar("sm_blockspectatemessage", "1", "If enabled it blocks the join team message if an administrator joins spectator", FCVAR_PLUGIN, true, 0.0, true, 1.0); - cvarBlockDisconnectMessage = CreateConVar("sm_blockdisconnectmessage", "1", "Blocks the disconnect message", FCVAR_PLUGIN, true, 0.0, true, 1.0); - cvarBlockConnectMessage = CreateConVar("sm_blockconnectmessage", "1", "If enabled it blocks the player connection message.", FCVAR_PLUGIN, true, 0.0, true, 1.0); - cvarAdminShowMessages = CreateConVar("sm_adminshowmessages", "1", "Shows disconnect/connect/team join messages for admins only (if disconnect message is set to be blocked)", FCVAR_PLUGIN, true, 0.0, true, 1.0); - HookEvent("player_team", ev_PlayerTeam, EventHookMode_Pre); - HookEvent("player_disconnect", ev_PlayerDisconnect, EventHookMode_Pre); - HookEvent("player_connect", ev_PlayerConnect, EventHookMode_Pre); - - new String:game_folder[64]; - GetGameFolderName(game_folder, sizeof(game_folder)) - - if (StrContains(game_folder, "insurgency", false) != -1) - { - iSpecTeam = 3; - } - else - { - new String:game_description[64]; - GetGameDescription(game_description, sizeof(game_description), true); - if (StrContains(game_description, "Insurgency", false) != -1) - { - iSpecTeam = 3; - } - } - - AutoExecConfig(true, "suppressmessage", "sourcemod"); -} - -public Action:ev_PlayerTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - if (GetConVarBool(cvarBlockSpectateMessage)) - { - if (!dontBroadcast && !GetEventBool(event, "silent")) - { - new iUserId = GetEventInt(event, "userid"); - new iClient = GetClientOfUserId(iUserId); - new iTeam = GetEventInt(event, "team"); - - if (iTeam == iSpecTeam && GetAdminFlag(GetUserAdmin(iClient), Admin_Kick)) - { - new iOldTeam = GetEventInt(event, "oldteam"); - new bool:bDisconnect = GetEventBool(event, "disconnect"); - new bool:bAutoteam = GetEventBool(event, "autoteam"); - decl String:strName[50]; - GetEventString(event, "name", strName, sizeof(strName)); - - if (iClient != 0) - { - if (GetConVarInt(cvarAdminShowMessages) == 1) - { - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientConnected(i) && IsClientInGame(i) && GetUserAdmin(i) != INVALID_ADMIN_ID) - { - PrintToChat(i,"%N joined team Spectator.", iClient); - PrintToConsole(i,"%N joined team Spectator.", iClient); - } - } - } - } - - new Handle:hEvent = CreateEvent("player_team"); - SetEventInt(hEvent, "userid", iUserId); - SetEventInt(hEvent, "team", iTeam); - SetEventInt(hEvent, "oldteam", iOldTeam); - SetEventBool(hEvent, "disconnect", bDisconnect); - SetEventBool(hEvent, "autoteam", bAutoteam); - SetEventBool(hEvent, "silent", true); - SetEventString(hEvent, "name", strName); - - FireEvent(hEvent, true); - - return Plugin_Handled; - } - } - } - return Plugin_Continue; -} -public Action:ev_PlayerConnect(Handle:event, const String:name[], bool:dontBroadcast) -{ - if (GetConVarBool(cvarBlockConnectMessage)) - { - if (!dontBroadcast) - { - decl String:strName[50]; - GetEventString(event, "name", strName, sizeof(strName)); - new iIndex = GetEventInt(event, "index"); - new iUserId = GetEventInt(event, "userid"); - new iClient = GetClientOfUserId(iUserId); - decl String:strNetworkId[50]; - GetEventString(event, "networkid", strNetworkId, sizeof(strNetworkId)); - decl String:strAddress[50]; - GetEventString(event, "address", strAddress, sizeof(strAddress)); - - if (iClient != 0) - { - if (GetConVarInt(cvarAdminShowMessages) == 1) - { - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientConnected(i) && IsClientInGame(i) && GetUserAdmin(i) != INVALID_ADMIN_ID) - { - PrintToChat(i,"%N has connected.", iClient); - PrintToConsole(i,"%N has connected.", iClient); - } - } - } - } - - new Handle:hEvent = CreateEvent("player_connect"); - SetEventString(hEvent, "name", strName); - SetEventInt(hEvent, "index", iIndex); - SetEventInt(hEvent, "userid", iUserId); - SetEventString(hEvent, "networkid", strNetworkId); - SetEventString(hEvent, "address", strAddress); - - FireEvent(hEvent, true); - - return Plugin_Handled; - } - } - return Plugin_Continue; -} -public Action:ev_PlayerDisconnect(Handle:event, const String:name[], bool:dontBroadcast) -{ - if (GetConVarBool(cvarBlockDisconnectMessage)) - { - if (!dontBroadcast) - { - new iUserId = GetEventInt(event, "userid"); - new iClient = GetClientOfUserId(iUserId); - decl String:strReason[50]; - GetEventString(event, "reason", strReason, sizeof(strReason)); - decl String:strName[50]; - GetEventString(event, "name", strName, sizeof(strName)); - decl String:strNetworkId[50]; - GetEventString(event, "networkid", strNetworkId, sizeof(strNetworkId)); - - if (iClient != 0) - { - if (GetConVarInt(cvarAdminShowMessages) == 1) - { - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientConnected(i) && IsClientInGame(i) && GetUserAdmin(i) != INVALID_ADMIN_ID) - { - PrintToChat(i, "%N has left the server.", iClient); - PrintToConsole(i, "Dropped %N from server (Disconnect by user.)", iClient); - } - } - } - } - - new Handle:hEvent = CreateEvent("player_disconnect"); - SetEventInt(hEvent, "userid", iUserId); - SetEventString(hEvent, "reason", strReason); - SetEventString(hEvent, "name", strName); - SetEventString(hEvent, "networkid", strNetworkId); - - FireEvent(hEvent, true); - - return Plugin_Handled; - } - } - - return Plugin_Continue; -} \ No newline at end of file diff --git a/addons/sourcemod/scripting/simple-plugins.sp b/addons/sourcemod/scripting/simple-plugins.sp deleted file mode 100644 index 4462b41..0000000 --- a/addons/sourcemod/scripting/simple-plugins.sp +++ /dev/null @@ -1,785 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Plugins -Description: - Core plugin for Simple Plugins project -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#define CORE_PLUGIN_VERSION "1.1.$Rev$" - -#include - -enum e_PlayerInfo -{ - Handle:hForcedTeamPlugin = INVALID_HANDLE, - iForcedTeam = 0, - iBuddy = 0, - bool:bBuddyLocked = false -}; - -new Handle:g_fwdPlayerMoved; -new g_aPlayers[MAXPLAYERS + 1][e_PlayerInfo]; -new bool:g_bTeamsSwitched = false; - -/** -Setting our plugin information. -*/ -public Plugin:myinfo = -{ - name = "Simple Plugins Core Plugin", - author = "Simple Plugins", - description = "Core plugin for Simple Plugins", - version = CORE_PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -}; - -public bool:AskPluginLoad(Handle:myself, bool:late, String:error[], err_max) -{ - - /** - Register natives for other plugins - */ - CreateNative("SM_MovePlayer", Native_SM_MovePlayer); - CreateNative("SM_SetForcedTeam", Native_SM_SetForcedTeam); - CreateNative("SM_GetForcedTeam", Native_SM_GetForcedTeam); - CreateNative("SM_ClearForcedTeam", Native_SM_ClearForcedTeam); - CreateNative("SM_GetForcedPlayer", Native_SM_GetForcedPlayer); - CreateNative("SM_AssignBuddy", Native_SM_AssignBuddy); - CreateNative("SM_GetClientBuddy", Native_SM_GetClientBuddy); - CreateNative("SM_LockBuddy", Native_SM_LockBuddy); - CreateNative("SM_IsBuddyLocked", Native_SM_IsBuddyLocked); - CreateNative("SM_ClearBuddy", Native_SM_ClearBuddy); - CreateNative("SM_IsValidAdmin", Native_SM_IsValidAdmin); - CreateNative("SM_IsValidTeam", Native_SM_IsValidTeam); - RegPluginLibrary("simpleplugins"); - return true; -} - -public OnPluginStart() -{ - - CreateConVar("ssm_core_pl_ver", CORE_PLUGIN_VERSION, "Simple SourceMod Plugins Core Plugin Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - CreateConVar("ssm_core_inc_ver", CORE_INC_VERSION, "Simple SourceMod Plugins Core Include Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook some events to control forced players and check extensions - */ - decl String:sExtError[256]; - LogAction(0, -1, "[SSM] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_team", HookPlayerChangeTeam, EventHookMode_Pre); - switch (g_CurrentMod) - { - case GameType_CSS: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - new iExtStatus = GetExtensionFileStatus("game.cstrike.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SSM] Required extension was not found."); - LogAction(0, -1, "[SSM] Plugin FAILED TO LOAD."); - SetFailState("Required extension was not found."); - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SSM] Required extension is loaded with errors."); - LogAction(0, -1, "[SSM] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SSM] Plugin FAILED TO LOAD."); - SetFailState("Required extension is loaded with errors."); - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SSM] Required extension is loaded."); - } - } - case GameType_TF: - { - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_PostNoCopy); - HookUserMessage(GetUserMessageId("TextMsg"), UserMessageHook_Class, true); - new iExtStatus = GetExtensionFileStatus("game.tf2.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SSM] Required extension was not found."); - LogAction(0, -1, "[SSM] Plugin FAILED TO LOAD."); - SetFailState("Required extension was not found."); - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SSM] Required extension is loaded with errors."); - LogAction(0, -1, "[SSM] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SSM] Plugin FAILED TO LOAD."); - SetFailState("Required extension is loaded with errors."); - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SSM] Required extension is loaded."); - } - } - case GameType_DOD: - { - HookEvent("dod_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_PostNoCopy); - } - default: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - } - } - - /** - Load common translations - */ - LoadTranslations ("common.phrases"); - - /** - Create the global forward - */ - g_fwdPlayerMoved = CreateGlobalForward("SM_OnPlayerMoved", ET_Event, Param_Cell, Param_Cell, Param_Cell); -} - -public OnClientDisconnect(client) -{ - - /** - Cleanup clients/players buddy list - */ - if (!IsFakeClient(client)) - { - SM_ClearBuddy(client, true); - SM_LockBuddy(client, false); - } - SM_ClearForcedTeam(client); -} - -public HookRoundStart(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - See if the teams have been switched - */ - if (g_bTeamsSwitched) - { - - /** - Switch the teams the players are forced to - */ - for (new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][iForcedTeam] != 0) - { - if (g_aPlayers[i][iForcedTeam] == g_aCurrentTeams[Team1]) - { - g_aPlayers[i][iForcedTeam] = g_aCurrentTeams[Team2]; - } - else - { - g_aPlayers[i][iForcedTeam] = g_aCurrentTeams[Team1]; - } - } - } - } -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - g_bTeamsSwitched = false; -} - -public HookPlayerChangeTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get our event variables - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - new iTeam = GetEventInt(event, "team"); - - /** - See if the player is on the wrong team - */ - if (g_aPlayers[iClient][iForcedTeam] != 0 && g_aPlayers[iClient][iForcedTeam] != iTeam) - { - - /** - Move the player back to the forced team - */ - CreateTimer(1.0, Timer_ForcePlayerMove, iClient, TIMER_FLAG_NO_MAPCHANGE); - - /** - If the event was going to be broadcasted, we refire it so it is not broadcasted and stop this one - */ - if (!dontBroadcast) - { - new Handle:hEvent = CreateEvent("player_team"); - SetEventInt(hEvent, "userid", GetEventInt(event, "userid")); - SetEventInt(hEvent, "team", GetEventInt(event, "team")); - SetEventInt(hEvent, "oldteam", GetEventInt(event, "oldteam")); - SetEventBool(hEvent, "disconnect", GetEventBool(event, "disconnect")); - - if (g_CurrentMod == GameType_DOD || g_CurrentMod == GameType_L4D || g_CurrentMod == GameType_TF) - { - new String:sClientName[MAX_NAME_LENGTH + 1]; - GetClientName(client, sClientName, sizeof(sClientName)); - SetEventBool(hEvent, "autoteam", GetEventBool(event, "autoteam")); - SetEventBool(hEvent, "silent", true); - SetEventString(hEvent, "name", sClientName); - FireEvent(hEvent, true); - } - else - { - FireEvent(hEvent, true); - } - return Plugin_Handled; - } - } - return Plugin_Continue; -} - -public Action:UserMessageHook_Class(UserMsg:msg_id, Handle:bf, const players[], playersNum, bool:reliable, bool:init) -{ - new String:sMessage[120]; - BfReadString(bf, sMessage, sizeof(sMessage), true); - if (StrContains(sMessage, "#TF_TeamsSwitched", false) != -1) - { - g_bTeamsSwitched = true; - } - return Plugin_Continue; -} - -public Native_SM_MovePlayer(Handle:plugin, numParams) -{ - - /** - Get and check the client and team - */ - new iClient = GetNativeCell(1); - new iTeam = GetNativeCell(2); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (iTeam != g_aCurrentTeams[Spectator] && iTeam != g_aCurrentTeams[Team1] && iTeam != g_aCurrentTeams[Team2]) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid team %d", iTeam); - } - - MovePlayer(iClient, iTeam); - if (!IsClientObserver(iClient)) - { - RespawnPlayer(iClient); - } - - new fResult; - - Call_StartForward(g_fwdPlayerMoved); - Call_PushCell(plugin); - Call_PushCell(iClient); - Call_PushCell(iTeam); - Call_Finish(fResult); - - if (fResult != SP_ERROR_NONE) - { - return ThrowNativeError(fResult, "Forward failed"); - } - - return fResult; -} - -public Native_SM_SetForcedTeam(Handle:plugin, numParams) -{ - - /** - Get and check the client and team - */ - new iClient = GetNativeCell(1); - new iTeam = GetNativeCell(2); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (iTeam != g_aCurrentTeams[Spectator] && iTeam != g_aCurrentTeams[Team1] && iTeam != g_aCurrentTeams[Team2] && iTeam != g_aCurrentTeams[Unknown]) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid team %d", iTeam); - } - - new bool:bOverRide = GetNativeCell(3) ? true : false; - - if (!bOverRide && g_aPlayers[iClient][hForcedTeamPlugin] != INVALID_HANDLE && plugin != g_aPlayers[iClient][hForcedTeamPlugin]) - { - return false; - } - - g_aPlayers[iClient][hForcedTeamPlugin] = plugin; - g_aPlayers[iClient][iForcedTeam] = iTeam; - return true; -} - -public Native_SM_GetForcedTeam(Handle:plugin, numParams) -{ - - /** - Get and check the client - */ - new iClient = GetNativeCell(1); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - - /** - Get and set the plugin if they want it - */ - new Handle:hPlugin = GetNativeCell(2); - if (hPlugin != INVALID_HANDLE) - { - SetNativeCellRef(2, g_aPlayers[iClient][hForcedTeamPlugin]); - } - - /** - Return the forced team, this could be 0 - */ - return g_aPlayers[iClient][iForcedTeam]; -} - -public Native_SM_ClearForcedTeam(Handle:plugin, numParams) -{ - - /** - Get and check the client and team - */ - new iClient = GetNativeCell(1); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - - g_aPlayers[iClient][hForcedTeamPlugin] = INVALID_HANDLE; - g_aPlayers[iClient][iForcedTeam] = 0; - - return true; -} - -public Native_SM_GetForcedPlayer(Handle:plugin, numParams) -{ - - /** - Get and check the team - */ - new iTeam = GetNativeCell(1); - if (iTeam != g_aCurrentTeams[Spectator] && iTeam != g_aCurrentTeams[Team1] && iTeam != g_aCurrentTeams[Team2]) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid team %d", iTeam); - } - - /** - Start a loop to check for a player on the wrong team - Also make sure the plugin that set the forced team is the plugin that asked - */ - new iPlayer = 0; - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientInGame(i) - && GetClientTeam(i) != g_aPlayers[i][iForcedTeam] - && g_aPlayers[i][iForcedTeam] == iTeam - && g_aPlayers[i][hForcedTeamPlugin] == plugin) - { - iPlayer = i; - break; - } - } - - /** - Return the player we found, this could be 0 - */ - return iPlayer; -} - -public Native_SM_AssignBuddy(Handle:plugin, numParams) -{ - - /** - Get and check the client and player - */ - new iClient = GetNativeCell(1); - new iPlayer = GetNativeCell(2); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (iPlayer < 0 || iPlayer > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid player index (%d)", iPlayer); - } - if (!IsClientConnected(iPlayer)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Player %d is not connected", iPlayer); - } - if (!IsClientInGame(iPlayer)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Player %d is not in the game", iClient); - } - if (IsFakeClient(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Bots are not supported"); - } - - /** - See if we can override his setting - */ - new bool:bOverRide = GetNativeCell(3) ? true : false; - if (!bOverRide) - { - - /** - We can't override, so check if they are locked - */ - if (g_aPlayers[iClient][bBuddyLocked] || g_aPlayers[iPlayer][bBuddyLocked]) - { - - /** - We detected at least 1 lock, so we bug out - */ - return false; - } - } - - /** - Ready to set the buddies - */ - g_aPlayers[iClient][iBuddy] = iPlayer; - g_aPlayers[iPlayer][iBuddy] = iClient; - return true; -} - -public Native_SM_GetClientBuddy(Handle:plugin, numParams) -{ - - /** - Get and check the client - */ - new iClient = GetNativeCell(1); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (IsFakeClient(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Bots are not supported"); - } - - /** - Return the players buddy, this could be 0 - */ - return g_aPlayers[iClient][iBuddy]; -} - -public Native_SM_LockBuddy(Handle:plugin, numParams) -{ - - /** - Get and check the client - */ - new iClient = GetNativeCell(1); - new bool:bSetting = GetNativeCell(2) ? true : false; - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (IsFakeClient(iClient)) - { - return ThrowNativeError(SP_ERROR_NATIVE, "Bots are not supported"); - } - - g_aPlayers[iClient][bBuddyLocked] = bSetting; - return true; -} - -public Native_SM_IsBuddyLocked(Handle:plugin, numParams) -{ - - /** - Get and check the client - */ - new iClient = GetNativeCell(1); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_INDEX, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (IsFakeClient(iClient)) - { - return ThrowNativeError(SP_ERROR_NATIVE, "Bots are not supported"); - } - - return g_aPlayers[iClient][bBuddyLocked]; -} - -public Native_SM_ClearBuddy(Handle:plugin, numParams) -{ - - /** - Get and check the client - */ - new iClient = GetNativeCell(1); - if (iClient < 1 || iClient > MaxClients) - { - return ThrowNativeError(SP_ERROR_NATIVE, "Invalid client index (%d)", iClient); - } - if (!IsClientConnected(iClient)) - { - return ThrowNativeError(SP_ERROR_NATIVE, "Client (%d) is not connected", iClient); - } - if (!IsClientInGame(iClient)) - { - return ThrowNativeError(SP_ERROR_INDEX, "Client %d is not in the game", iClient); - } - if (IsFakeClient(iClient)) - { - return ThrowNativeError(SP_ERROR_NATIVE, "Bots are not supported"); - } - - /** - Get the clients buddy and see if we can override his setting - */ - new bool:bOverRide = GetNativeCell(2) ? true : false; - new iPlayer = g_aPlayers[iClient][iBuddy]; - - /** - There is no buddy, we don't care about anything else so bug out - */ - if (iPlayer == 0) - { - return true; - } - - /** - We determined he had a buddy, check the override setting - */ - if (!bOverRide) - { - - /** - We can't override, so check if they are locked - */ - if (g_aPlayers[iClient][bBuddyLocked] || g_aPlayers[iPlayer][bBuddyLocked]) - { - - /** - We detected at least 1 lock, so we bug out - */ - return false; - } - } - - /** - Ready to clear the buddies - */ - g_aPlayers[iClient][iBuddy] = 0; - g_aPlayers[iPlayer][iBuddy] = 0; - return true; -} - -public Native_SM_IsValidTeam(Handle:plugin, numParams) -{ - - /** - Get the team - */ - new iTeam = GetNativeCell(1); - - /** - Check the team - */ - if (iTeam == g_aCurrentTeams[Spectator] || iTeam == g_aCurrentTeams[Team1] || iTeam == g_aCurrentTeams[Team2]) - { - return true; - } - return false; -} - -public Native_SM_IsValidAdmin(Handle:plugin, numParams) -{ - /** - Get the client and flags - */ - new iClient = GetNativeCell(1); - decl String:sFlags[15]; - GetNativeString(2, sFlags, sizeof(sFlags)); - new ibFlags = ReadFlagString(sFlags); - - /** - Check the flags - */ - if ((GetUserFlagBits(iClient) & ibFlags) == ibFlags) - { - return true; - } - if (GetUserFlagBits(iClient) & ADMFLAG_ROOT) - { - return true; - } - return false; -} - -public Action:Timer_ForcePlayerMove(Handle:timer, any:iClient) -{ - - MovePlayer(iClient, g_aPlayers[iClient][iForcedTeam]); - - if (g_aPlayers[iClient][iForcedTeam] != g_aCurrentTeams[Spectator]) - { - RespawnPlayer(iClient); - } - - PrintToChat(iClient, "\x01\x04----------------------------------"); - PrintToChat(iClient, "\x01\x04You have been forced to this team."); - PrintToChat(iClient, "\x01\x04----------------------------------"); - - return Plugin_Handled; -} - -stock MovePlayer(iClient, iTeam) -{ - - /** - Change the client's team based on the mod - */ - switch (g_CurrentMod) - { - case GameType_CSS: - { - CS_SwitchTeam(iClient, iTeam); - } - default: - { - ChangeClientTeam(iClient, iTeam); - } - } -} - -stock RespawnPlayer(iClient) -{ - - /** - Respawn the client based on the mod - */ - switch (g_CurrentMod) - { - case GameType_CSS: - { - CS_RespawnPlayer(iClient); - } - case GameType_TF: - { - TF2_RespawnPlayer(iClient); - } - case GameType_INS: - { - FakeClientCommand(iClient, "kill"); - } - default: - { - // - } - } -} diff --git a/addons/sourcemod/scripting/simple-roundimmunity.sp b/addons/sourcemod/scripting/simple-roundimmunity.sp deleted file mode 100644 index 5f0bca3..0000000 --- a/addons/sourcemod/scripting/simple-roundimmunity.sp +++ /dev/null @@ -1,947 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Round Immunity -Description: - Gives admins immunity during certain rounds -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or any later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#pragma semicolon 1 -#include -#include -#undef REQUIRE_EXTENSIONS -#undef AUTOLOAD_EXTENSIONS -#include -#include -#define REQUIRE_EXTENSIONS -#define AUTOLOAD_EXTENSIONS - -#define PLUGIN_VERSION "1.1.$Rev$" -#define SPECTATOR 1 -#define TEAM_RED 2 -#define TEAM_BLUE 3 - -#define COLOR_GREEN 0 -#define COLOR_BLACK 1 -#define COLOR_RED 2 -#define COLOR_BLUE 3 -#define COLOR_TEAM 4 -#define COLOR_RAINBOW 5 -#define COLOR_NONE 6 - -#define PLAYERCOND_SLOWED (1<<0) //1 -#define PLAYERCOND_ZOOMED (1<<1) //2 -#define PLAYERCOND_DISGUISING (1<<2) //4 -#define PLAYERCOND_DISGUISED (1<<3) //8 -#define PLAYERCOND_SPYCLOAK (1<<4) //16 -#define PLAYERCOND_UBERED (1<<5) //32 -#define PLAYERCOND_TELEPORTTRAIL (1<<6) //64 -#define PLAYERCOND_TAUNT (1<<7) //128 -// (1<<8) //256 -// (1<<9) //512 -#define PLAYERCOND_TELEPORTFLASH (1<<10) //1024 -#define PLAYERCOND_KRUBER (1<<11) //2048 -// (1<<12) //4096 -// (1<<13) //8192 -#define PLAYERCOND_BONKED (1<<14) //16384 (blame Neph if it doesn't work) -#define PLAYERCOND_BONKEDORDRINKSLOWDOWN (1<<15) //32768 -#define PLAYERCOND_HEALING (1<<16) //65536 -#define PLAYERCOND_BURNING (1<<17) //131072 -#define PLAYERCOND_FULLYCHARGEDBYMEDIC (1<<18) //262144 - -enum e_Cookies -{ - bEnabled, - iColor, - iMode -}; - -enum e_ColorNames -{ - Green, - Black, - Red, - Blue -}; - -enum e_ColorValues -{ - iRed, - iGreen, - iBlue -}; - -enum e_PlayerData -{ - Handle:hGodModeTimer, - Handle:hColorTimer, - bool:bIsAdmin, - bool:bIsImmune, - iCycleColor -}; - -/** - Global convar handles - */ -new Handle:sri_charadminflag = INVALID_HANDLE; -new Handle:sri_enabled = INVALID_HANDLE; -new Handle:sri_cookie_enabled = INVALID_HANDLE; -new Handle:sri_cookie_color = INVALID_HANDLE; -new Handle:sri_cookie_mode = INVALID_HANDLE; - -/** - Player arrays - */ -new g_aPlayers[MAXPLAYERS + 1][e_PlayerData]; -new g_aClientCookies[MAXPLAYERS + 1][e_Cookies]; - -/** - Global bools - */ -new bool:g_bLoadedLate = false; -new bool:g_bIsEnabled = true; -new bool:g_bRoundEnd = false; -new bool:g_bUseDukehacks = false; -new bool:g_bUseClientprefs = false; - -/** - Global strings/integers/floats - */ -new String:g_sCharAdminFlag[32]; -new g_iColors[e_ColorNames][e_ColorValues]; -new g_iClassMaxHealth[TFClassType] = {0, 125, 125, 200, 175, 150, 300, 175, 125, 125}; - -public Plugin:myinfo = -{ - name = "Simple Round Immunity", - author = "Simple Plugins", - description = "Gives admins immunity during certain rounds", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -} - -bool:AskPluginLoad(Handle:myself, bool:late, String:error[], err_max) -{ - g_bLoadedLate = late; - return true; -} - -public OnPluginStart() -{ - - /** - Create console variables - */ - CreateConVar("sri_version", PLUGIN_VERSION, "Simple Round Immunity", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - sri_enabled = CreateConVar("sri_enabled", "1", "Enable/Disable Admin immunity during certain round."); - sri_charadminflag = CreateConVar("sri_charadminflag", "a", "Admin flag to use for immunity (only one). Must be a in char format."); - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook some events and check extensions - */ - decl String:sExtError[256]; - LogAction(0, -1, "[SRI] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_spawn", HookPlayerSpawn, EventHookMode_Post); - HookEvent("player_hurt", HookPlayerHurt, EventHookMode_Pre); - switch (g_CurrentMod) - { - case GameType_CSS: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - new iExtStatus = GetExtensionFileStatus("game.cstrike.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SRI] Required extension was not found."); - LogAction(0, -1, "[SRI] Plugin FAILED TO LOAD."); - SetFailState("Required extension was not found."); - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SRI] Required extension is loaded with errors."); - LogAction(0, -1, "[SRI] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SRI] Plugin FAILED TO LOAD."); - SetFailState("Required extension is loaded with errors."); - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SRI] Required css extension is loaded."); - } - } - case GameType_TF: - { - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_PostNoCopy); - HookUserMessage(GetUserMessageId("TextMsg"), UserMessageHook_Class, true); - new iExtStatus = GetExtensionFileStatus("game.tf2.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SRI] Required extension was not found."); - LogAction(0, -1, "[SRI] Plugin FAILED TO LOAD."); - SetFailState("Required extension was not found."); - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SRI] Required extension is loaded with errors."); - LogAction(0, -1, "[SRI] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SRI] Plugin FAILED TO LOAD."); - SetFailState("Required extension is loaded with errors."); - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SRI] Required tf2 extension is loaded."); - } - iExtStatus = GetExtensionFileStatus("dukehacks.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SRI] Dukehacks extension was not found."); - LogAction(0, -1, "[SRI] Plugin continued to load, but that feature will not be used."); - g_bUseDukehacks = false; - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SRI] Dukehacks extension is loaded with errors."); - LogAction(0, -1, "[SRI] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SRI] Plugin continued to load, but that feature will not be used."); - g_bUseDukehacks = false; - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SRI] Dukehacks extension is loaded and will be used."); - g_bUseDukehacks = true; - dhAddClientHook(CHK_TakeDamage, Hacks_TakeDamageHook); - } - } - case GameType_DOD: - { - HookEvent("dod_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_PostNoCopy); - } - default: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - } - } - /** - Now lets check for client prefs extension - */ - new iExtStatus = GetExtensionFileStatus("clientprefs.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SRI] Client Preferences extension was not found."); - LogAction(0, -1, "[SRI] Plugin continued to load, but that feature will not be used."); - g_bUseClientprefs = false; - } - if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SRI] Client Preferences extension is loaded with errors."); - LogAction(0, -1, "[SRI] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SRI] Plugin continued to load, but that feature will not be used."); - g_bUseClientprefs = false; - } - if (iExtStatus == 1) - { - LogAction(0, -1, "[SRI] Client Preferences extension is loaded, checking database."); - if (!SQL_CheckConfig(clientprefs)) - { - LogAction(0, -1, "[SRI] No 'clientprefs' database found. Check your database.cfg file."); - LogAction(0, -1, "[SRI] Plugin continued to load, but Client Preferences will not be used."); - g_bUseClientprefs = false; - } - g_bUseClientprefs = true; - - /** - Deal with client cookies - */ - sri_cookie_enabled = RegClientCookie("bri_client_enabled", "Enable/Disable your immunity during the bonus round.", CookieAccess_Public); - sri_cookie_color = RegClientCookie("bri_client_color", "Color to render when immune.", CookieAccess_Public); - sri_cookie_mode = RegClientCookie("bri_client_mode", "God mode to select", CookieAccess_Public); - SetCookieMenuItem(CookieMenu_TopMenu, sri_cookie_enabled, "Bonus Round Immunity"); - } - - HookConVarChange(sri_enabled, EnabledChanged); - - RegAdminCmd("sm_immunity", Command_Immunity, ADMFLAG_ROOT, "sm_immunity: Gives you immunity"); - - LoadColors(); - - AutoExecConfig(true, "plugin.simpleroundimmunity"); -} - -public OnAllPluginsLoaded() -{ - //something - // need to deal with the unloading of dukehacks, clientprefs, and simpleplugins - // should move hooking the client prefs cookies to a function to make sure they are done post plugin start if ext is loaded late -} - -public OnLibraryRemoved(const String:name[]) -{ - //something - // need to deal with the loading of dukehacks, clientprefs, and simpleplugins -} - -public OnConfigsExecuted() -{ - GetConVarString(sri_charadminflag, g_sCharAdminFlag, sizeof(g_sCharAdminFlag)); - g_bIsEnabled = GetConVarBool(sri_enabled); - g_bRoundEnd = false; -} - -/** - Client events - */ - -public OnClientPostAdminCheck(client) -{ - if (SM_IsValidAdmin(client, g_sCharAdminFlag)) - g_aPlayers[client][bIsAdmin] = true; - else - g_aPlayers[client][bIsAdmin] = false; -} - -public OnClientCookiesCached(client) -{ - decl String:sEnabled[2], String:sColor[4], String:sMode[2]; - GetClientCookie(client, sri_cookie_enabled, sEnabled, sizeof(sEnabled)); - GetClientCookie(client, sri_cookie_color, sColor, sizeof(sColor)); - GetClientCookie(client, sri_cookie_mode, sMode, sizeof(sMode)); - g_aClientCookies[client][bEnabled] = StringToInt(sEnabled); - g_aClientCookies[client][iColor] = StringToInt(sColor); - g_aClientCookies[client][iMode] = StringToInt(sMode); -} - -public OnClientDisconnect(client) -{ - CleanUp(client); -} - -/** - Commands - */ - -public Action:Command_Immunity(client, args) -{ - if (g_aPlayers[client][IsImmune]) - { - DisableImmunity(client); - } - else - { - EnableImmunity(client); - } - return Plugin_Handled; -} - -/** - Event hooks - */ - -public Action:Hacks_TakeDamageHook(client, attacker, inflictor, Float:damage, &Float:multiplier, damagetype) -{ - if (attacker == 0 || attacker >= MaxClients) - { - return Plugin_Continue; - } - if (g_aPlayers[client][IsImmune]) - { - new TFClassType:PlayerClass = TF2_GetPlayerClass(attacker); - if (PlayerClass == TFClass_Spy) - { - multiplier *= 0.0; - return Plugin_Changed; - } - } - return Plugin_Continue; -} - -public HookRoundStart(Handle:event, const String:name[], bool:dontBroadcast) -{ - g_bRoundEnd = false; - if (g_bIsEnabled) - { - for (new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][IsImmune]) - { - DisableImmunity(i); - } - } - } -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - g_bRoundEnd = true; - if (g_bIsEnabled) - { - for (new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][bIsAdmin]) - { - EnableImmunity(i); - } - } - } -} - -public HookPlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast) -{ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - if (g_bIsEnabled && g_aPlayers[iClient][bIsAdmin] && g_bRoundEnd) - { - EnableImmunity(iClient); - } -} - -public Action:HookPlayerHurt(Handle:event, const String:name[], bool:dontBroadcast) -{ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - if (g_aPlayers[iClient][IsImmune]) - { - SetEntityHealth(iClient, 2000); - return Plugin_Continue; - } - return Plugin_Continue; -} - -/** - Cookie menus - */ - -public CookieMenu_TopMenu(client, CookieMenuAction:action, any:info, String:buffer[], maxlen) -{ - if (action == CookieMenuAction_DisplayOption) - { - //don't think we need to do anything - } - else - { - new Handle:hMenu = CreateMenu(Menu_CookieSettings); - SetMenuTitle(hMenu, "Options (Current Setting)"); - if (g_aClientCookies[client][bEnabled]) - { - AddMenuItem(hMenu, "enable", "Enabled/Disable (Enabled)"); - } - else - { - AddMenuItem(hMenu, "enable", "Enabled/Disable (Disabled)"); - } - if (g_aClientCookies[client][iMode]) - { - AddMenuItem(hMenu, "mode", "Immunity Mode Setting (God Mode)"); - } - else - { - AddMenuItem(hMenu, "mode", "Immunity Mode Setting (Health)"); - } - switch (g_aClientCookies[client][iColor]) - { - case COLOR_GREEN: - { - AddMenuItem(hMenu, "color", "Color (Green)"); - } - case COLOR_BLACK: - { - AddMenuItem(hMenu, "color", "Color (Black)"); - } - case COLOR_RED: - { - AddMenuItem(hMenu, "color", "Color (Red)"); - } - case COLOR_BLUE: - { - AddMenuItem(hMenu, "color", "Color (Blue)"); - } - case COLOR_TEAM: - { - AddMenuItem(hMenu, "color", "Color (Team)"); - } - case COLOR_RAINBOW: - { - AddMenuItem(hMenu, "color", "Color (Rainbow)"); - } - case COLOR_NONE: - { - AddMenuItem(hMenu, "color", "Color (None)"); - } - } - SetMenuExitBackButton(hMenu, true); - DisplayMenu(hMenu, client, MENU_TIME_FOREVER); - } -} - -public Menu_CookieSettings(Handle:menu, MenuAction:action, param1, param2) -{ - new client = param1; - if (action == MenuAction_Select) - { - new String:sSelection[24]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "enable", false)) - { - new Handle:hMenu = CreateMenu(Menu_CookieSettingsEnable); - SetMenuTitle(hMenu, "Enable/Disable Round End Immunity"); - - if (g_aClientCookies[client][bEnabled]) - { - AddMenuItem(hMenu, "enable", "Enable (Set)"); - AddMenuItem(hMenu, "disable", "Disable"); - } - else - { - AddMenuItem(hMenu, "enable", "Enabled"); - AddMenuItem(hMenu, "disable", "Disable (Set)"); - } - - SetMenuExitBackButton(hMenu, true); - DisplayMenu(hMenu, client, MENU_TIME_FOREVER); - } - else if (StrEqual(sSelection, "mode", false)) - { - new Handle:hMenu = CreateMenu(Menu_CookieSettingsMode); - SetMenuTitle(hMenu, "Set Immunity Mode"); - - if (g_aClientCookies[client][iMode]) - { - AddMenuItem(hMenu, "god", "God Mode (Set)"); - AddMenuItem(hMenu, "health", "Health"); - } - else - { - AddMenuItem(hMenu, "god", "God Mode"); - AddMenuItem(hMenu, "health", "Health (Set)"); - } - - SetMenuExitBackButton(hMenu, true); - DisplayMenu(hMenu, client, MENU_TIME_FOREVER); - } - else - { - new Handle:hMenu = CreateMenu(Menu_CookieSettingsColors); - SetMenuTitle(hMenu, "Select Immunity Color"); - switch (g_aClientCookies[client][iColor]) - { - case COLOR_GREEN: - { - AddMenuItem(hMenu, "Green", "Green (Set)"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_BLACK: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black (Set)"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_RED: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red (Set)"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_BLUE: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue (Set)"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_TEAM: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color (Set)"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_RAINBOW: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow (Set)"); - AddMenuItem(hMenu, "None", "None"); - } - case COLOR_NONE: - { - AddMenuItem(hMenu, "Green", "Green"); - AddMenuItem(hMenu, "Black", "Black"); - AddMenuItem(hMenu, "Red", "Red"); - AddMenuItem(hMenu, "Blue", "Blue"); - AddMenuItem(hMenu, "Team", "Team Color"); - AddMenuItem(hMenu, "Rain", "Rainbow"); - AddMenuItem(hMenu, "None", "None (Set)"); - } - } - SetMenuExitBackButton(hMenu, true); - DisplayMenu(hMenu, client, MENU_TIME_FOREVER); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - ShowCookieMenu(client); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } -} - -public Menu_CookieSettingsEnable(Handle:menu, MenuAction:action, param1, param2) -{ - new client = param1; - if (action == MenuAction_Select) - { - new String:sSelection[24]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "enable", false)) - { - SetClientCookie(client, sri_cookie_enabled, "1"); - g_aClientCookies[client][bEnabled] = 1; - PrintToChat(client, "[SM] Bonus Round Immunity is ENABLED"); - } - else - { - SetClientCookie(client, sri_cookie_enabled, "0"); - g_aClientCookies[client][bEnabled] = 0; - PrintToChat(client, "[SM] Bonus Round Immunity is DISABLED"); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - ShowCookieMenu(client); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } -} - -public Menu_CookieSettingsColors(Handle:menu, MenuAction:action, param1, param2) -{ - new client = param1; - if (action == MenuAction_Select) - { - new String:sSelection[24]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "Green", false)) - { - SetClientCookie(client, sri_cookie_color, "0"); - g_aClientCookies[client][iColor] = COLOR_GREEN; - PrintToChat(client, "[SM] Bonus Round Immunity color set to GREEN"); - } - else if (StrEqual(sSelection, "Black", false)) - { - SetClientCookie(client, sri_cookie_color, "1"); - g_aClientCookies[client][iColor] = COLOR_BLACK; - PrintToChat(client, "[SM] Bonus Round Immunity color set to BLACK"); - } - else if (StrEqual(sSelection, "Red", false)) - { - SetClientCookie(client, sri_cookie_color, "2"); - g_aClientCookies[client][iColor] = COLOR_RED; - PrintToChat(client, "[SM] Bonus Round Immunity color set to RED"); - } - else if (StrEqual(sSelection, "Blue", false)) - { - SetClientCookie(client, sri_cookie_color, "3"); - g_aClientCookies[client][iColor] = COLOR_BLUE; - PrintToChat(client, "[SM] Bonus Round Immunity color set to BLUE"); - } - else if (StrEqual(sSelection, "Team", false)) - { - SetClientCookie(client, sri_cookie_color, "4"); - g_aClientCookies[client][iColor] = COLOR_TEAM; - PrintToChat(client, "[SM] Bonus Round Immunity color set to TEAM COLOR"); - } - else if (StrEqual(sSelection, "Rain", false)) - { - SetClientCookie(client, sri_cookie_color, "5"); - g_aClientCookies[client][iColor] = COLOR_RAINBOW; - PrintToChat(client, "[SM] Bonus Round Immunity color set to RAINBOW"); - } - else if (StrEqual(sSelection, "None", false)) - { - SetClientCookie(client, sri_cookie_color, "6"); - g_aClientCookies[client][iColor] = COLOR_NONE; - PrintToChat(client, "[SM] Bonus Round Immunity color set to NONE"); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - ShowCookieMenu(client); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } -} - -public Menu_CookieSettingsMode(Handle:menu, MenuAction:action, param1, param2) -{ - new client = param1; - if (action == MenuAction_Select) - { - new String:sSelection[24]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "god", false)) - { - SetClientCookie(client, sri_cookie_mode, "1"); - g_aClientCookies[client][iMode] = 1; - PrintToChat(client, "[SM] Bonus Round Immunity set to GOD MODE"); - } - else - { - SetClientCookie(client, sri_cookie_mode, "0"); - g_aClientCookies[client][iMode] = 0; - PrintToChat(client, "[SM] Bonus Round Immunity set to HEALTH BONUS"); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - ShowCookieMenu(client); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } -} - -/** -Timer functions - */ - -public Action:Timer_ChangeColor(Handle:timer, any:client) -{ - if (g_aPlayers[client][CycleColor]++ == 3) - { - g_aPlayers[client][CycleColor] = 0; - } - SetEntityRenderMode(client, RENDER_TRANSCOLOR); - SetEntityRenderColor(client, g_iColors[g_aPlayers[client][CycleColor]][iRed], g_iColors[g_aPlayers[client][CycleColor]][iGreen], g_iColors[g_aPlayers[client][CycleColor]][iBlue], 255); - return Plugin_Continue; -} - -public Action:Timer_UndoGodMode(Handle:timer, any:client) -{ - if (IsClientInGame(client)) - { - SetEntProp(client, Prop_Data, "m_takedamage", 2, 1); - } - g_aPlayers[iClient][hGodModeTimer] = INVALID_HANDLE; - return Plugin_Handled; -} - -/** -Stock functions . - */ - -stock CleanUp(iClient) -{ - g_aPlayers[iClient][bIsAdmin] = false; - DisableImmunity(iClient); -} - -stock EnableImmunity(iClient) -{ - SetEntityRenderMode(iClient, RENDER_TRANSCOLOR); - switch (g_aClientCookies[iClient][iColor]) - { - case COLOR_TEAM: - { - new iTeam = GetClientTeam(iClient); - SetEntityRenderColor(iClient, g_iColors[e_ColorNames:iTeam][iRed], g_iColors[e_ColorNames:iTeam][iGreen], g_iColors[e_ColorNames:iTeam][iBlue], 255); - } - case COLOR_RAINBOW: - { - if (g_aPlayers[iClient][hColorTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[iClient][hColorTimer]); - g_aPlayers[iClient][hColorTimer] = INVALID_HANDLE; - } - g_aPlayers[iClient][hColorTimer] = CreateTimer(0.2, Timer_ChangeColor, iClient, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); - } - case COLOR_NONE: - { - //We dont have to set a color - } - default: - { - SetEntityRenderColor(iClient, g_iColors[e_ColorNames:g_aClientCookies[iClient][iColor]][iRed], g_iColors[e_ColorNames:g_aClientCookies[iClient][iColor]][iGreen], g_iColors[e_ColorNames:g_aClientCookies[iClient][iColor]][iBlue], 255); - } - } - SetEntityHealth(iClient, 2000); - SetEntProp(iClient, Prop_Data, "m_takedamage", 0, 1); - g_aPlayers[iClient][hGodModeTimer] = CreateTimer(2.0, Timer_UndoGodMode, iClient); - g_aPlayers[iClient][IsImmune] = true; -} - -stock DisableImmunity(iClient) -{ - if (g_aPlayers[iClient][hGodModeTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[iClient][hGodModeTimer]); - g_aPlayers[iClient][hGodModeTimer] = INVALID_HANDLE; - } - if (g_aPlayers[iClient][hColorTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[iClient][hColorTimer]); - g_aPlayers[iClient][hColorTimer] = INVALID_HANDLE; - } - if (IsClientInGame(iClient)) - { - SetEntityRenderMode(iClient, RENDER_TRANSCOLOR); - SetEntityRenderColor(iClient, 255, 255, 255, 255); - new TFClassType:PlayerClass = TF2_GetPlayerClass(iClient); - new iMaxHealth = g_iClassMaxHealth[PlayerClass]; - SetEntityHealth(iClient, iMaxHealth); - } - g_aPlayers[iClient][CycleColor] = 0; - g_aPlayers[iClient][IsImmune] = false; -} - -stock LoadColors() -{ - g_iColors[Green][iRed] = 0; - g_iColors[Green][iGreen] = 255; - g_iColors[Green][iBlue] = 0; - - g_iColors[Black][iRed] = 10; - g_iColors[Black][iGreen] = 10; - g_iColors[Black][iBlue] = 0; - - g_iColors[Red][iRed] = 255; - g_iColors[Red][iGreen] = 0; - g_iColors[Red][iBlue] = 0; - - g_iColors[Blue][iRed] = 0; - g_iColors[Blue][iGreen] = 0; - g_iColors[Blue][iBlue] = 255; -} - -stock TF2_AddCond(client, cond) -{ - new Handle:cvar = FindConVar("sv_cheats"), bool:enabled = GetConVarBool(cvar), flags = GetConVarFlags(cvar); - if(!enabled) - { - SetConVarFlags(cvar, flags^FCVAR_NOTIFY); - SetConVarBool(cvar, true); - } - FakeClientCommand(client, "addcond %i", cond); - if(!enabled) - { - SetConVarBool(cvar, false); - SetConVarFlags(cvar, flags); - } -} - -stock TF2_RemoveCond(client, cond) -{ - new Handle:cvar = FindConVar("sv_cheats"), bool:enabled = GetConVarBool(cvar), flags = GetConVarFlags(cvar); - if(!enabled) - { - SetConVarFlags(cvar, flags^FCVAR_NOTIFY); - SetConVarBool(cvar, true); - } - FakeClientCommand(client, "removecond %i", cond); - if(!enabled) - { - SetConVarBool(cvar, false); - SetConVarFlags(cvar, flags); - } -} - -/** -Enabled hook - */ - -public EnabledChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (StringToInt(newValue) == 0) - { - UnhookEvent("player_spawn", HookPlayerSpawn, EventHookMode_Post); - UnhookEvent("teamplay_round_start", HookRoundStart, EventHookMode_Post); - UnhookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - for (new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][bIsAdmin] && g_aPlayers[i][IsImmune]) - { - DisableImmunity(i); - } - } - g_bIsEnabled = false; - } - else - { - HookEvent("player_spawn", HookPlayerSpawn, EventHookMode_Post); - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_Post); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - g_bIsEnabled = true; - } -} diff --git a/addons/sourcemod/scripting/simple-spectate.sp b/addons/sourcemod/scripting/simple-spectate.sp deleted file mode 100644 index 4108f8f..0000000 --- a/addons/sourcemod/scripting/simple-spectate.sp +++ /dev/null @@ -1,2022 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Spectate -Description: - Spectate a player and follow them through death. -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include -#undef REQUIRE_EXTENSIONS -#undef AUTOLOAD_EXTENSIONS -#tryinclude -#define AUTOLOAD_EXTENSIONS -#define REQUIRE_EXTENSIONS - -#define PLUGIN_VERSION "1.2.1.$Rev$" - -#define SPECMODE_NONE 0 -#define SPECMODE_FIRSTPERSON 4 -#define SPECMODE_3RDPERSON 5 -#define SPECMODE_FREELOOK 6 -#define SPECMODE_CSS_FIRSTPERSON 3 -#define SPECMODE_CSS_3RDPERSON 4 -#define SPECMODE_CSS_FREELOOK 5 - -enum e_CvarHandles -{ - Handle:hHudMode, - Handle:hMenuType, - Handle:hRestrictHud, - Handle:hBan, - Handle:hBanPerm, - Handle:hBeacon, - Handle:hBlind, - Handle:hCheater, - Handle:hDrug, - Handle:hFreeze, - Handle:hFreezeBomb, - Handle:hKick, - Handle:hSlap, - Handle:hSlay, - Handle:hTimeBomb -}; - -enum e_CvarSettings -{ - bool:bHudMode, - bool:bMenuType, - bool:bRestrictHud, - bool:bBan, - bool:bBanPerm, - bool:bBeacon, - bool:bBlind, - bool:bCheater, - bool:bDrug, - bool:bFreeze, - bool:bFreezebomb, - bool:bKick, - bool:bSlap, - bool:bSlay, - bool:bTimeBomb -}; - -enum e_PluginSettings -{ - bool:bUseSteamBans, - bool:bUseSourceBans, - bool:bUseMySQLBans, - bool:bCanHUD, - bool:bUseDukehacks -}; - -enum e_Menus -{ - Handle:hSelectPlayer, - Handle:hBanTime, - Handle:hReason -}; - -enum e_Punishments -{ - Punish_None, - Punish_Ban, - Punish_Beacon, - Punish_Blind, - Punish_Cheater, - Punish_Drug, - Punish_Freeze, - Punish_FreezeBomb, - Punish_Kick, - Punish_Slap, - Punish_Slay, - Punish_TimeBomb -}; - -enum e_PlayerData -{ - bool:bIsDisplayingHud, - bool:bIsFlaggedCheater, - Handle:hHudTimer, - Handle:hTargetTimer, - iTargetIndex, - e_Punishments:TargetPunishment, - iBanTime -}; - -new Handle:sm_spectate_adminflag = INVALID_HANDLE; -new Handle:g_hAdminMenu = INVALID_HANDLE; -new Handle:g_hHud = INVALID_HANDLE; -new Handle:g_aPluginCvar[e_CvarHandles]; -new g_aPluginCvarSettings[e_CvarSettings]; -new g_aPluginSettings[e_PluginSettings]; -new g_aMenus[e_Menus]; -new g_aPlayers[MAXPLAYERS + 1][e_PlayerData]; -new String:g_sAdminFlags[16]; -new String:g_sPunishments[e_Punishments][15] = { "None", "Ban", "Beacon", "Blind", "Cheater", "Drug", "Freeze", "FreezeBomb", "Kick", "Slap", "Slay", "TimeBomb" }; - -public Plugin:myinfo = -{ - name = "Simple Spectate", - author = "Simple Plugins", - description = "Spectate a player and follow them through death.", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -}; - -/** -Sourcemod callbacks -*/ -public OnPluginStart() -{ - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook the game events - */ - LogAction(0, -1, "[SSPEC] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_team", HookPlayerChangeTeam, EventHookMode_Pre); - - /** - Need to create all of our console variables. - */ - CreateConVar("sm_spectate_version", PLUGIN_VERSION, "Sourcemod Spectate", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - g_aPluginCvar[hHudMode] = CreateConVar("sm_spectate_hudmode", "1", "Hud Mode: 0 = Hud Text | 1 = Panel/Menu (NOTE: The panel/menu will override other menus until canceled)"); - g_aPluginCvar[hMenuType] = CreateConVar("sm_spectate_menutype", "0", "Menu Mode: 0 = Panel | 1 = Menu"); - g_aPluginCvar[hRestrictHud] = CreateConVar("sm_spectate_restricthud", "0", "Restrict the hud to the admin flag provided"); - g_aPluginCvar[hBan] = CreateConVar("sm_spectate_ban", "1", "Enable/Disable ban option"); - g_aPluginCvar[hBanPerm] = CreateConVar("sm_spectate_banperm", "1", "Enable/Disable permanent ban option"); - g_aPluginCvar[hBeacon] = CreateConVar("sm_spectate_beacon", "1", "Enable/Disable beacon option"); - g_aPluginCvar[hBlind] = CreateConVar("sm_spectate_blind", "1", "Enable/Disable blind option"); - g_aPluginCvar[hCheater] = CreateConVar("sm_spectate_cheater", "1", "Enable/Disable cheater option"); - g_aPluginCvar[hDrug] = CreateConVar("sm_spectate_drug", "1", "Enable/Disable drug option"); - g_aPluginCvar[hFreeze] = CreateConVar("sm_spectate_freeze", "1", "Enable/Disable freeze option"); - g_aPluginCvar[hFreezeBomb] = CreateConVar("sm_spectate_freezebomb", "1", "Enable/Disable freezebomb option"); - g_aPluginCvar[hKick] = CreateConVar("sm_spectate_kick", "1", "Enable/Disable kick option"); - g_aPluginCvar[hSlap] = CreateConVar("sm_spectate_slap", "1", "Enable/Disable slap option"); - g_aPluginCvar[hSlay] = CreateConVar("sm_spectate_slay", "1", "Enable/Disable slay option"); - g_aPluginCvar[hTimeBomb] = CreateConVar("sm_spectate_timebomb", "1", "Enable/Disable timebomb option"); - - sm_spectate_adminflag = CreateConVar("sm_spectate_adminflag", "d", "Admin Flag to use for admin hud"); - - /** - Hook console variables - */ - new e_CvarHandles:iCvar; - for ( ; _:iCvar < sizeof(g_aPluginCvar); iCvar++) - { - HookConVarChange(g_aPluginCvar[iCvar], ConVarSettingsChanged); - } - - /** - Need to register the commands we are going to create and use. - */ - RegConsoleCmd("sm_spectate", Command_Spectate, "Spectate a player"); - RegConsoleCmd("sm_spec", Command_Spectate, "Spectate a player"); - RegConsoleCmd("sm_observe", Command_Spectate, "Spectate a player"); - RegConsoleCmd("sm_stopspec", Command_StopSpectate, "Stop Spectating a player"); - RegConsoleCmd("sm_endobserve", Command_StopSpectate, "Stop Spectating a player"); - RegConsoleCmd("sm_specinfo", Command_ToggleHud, "Toggles the hud display if in spectator"); - - /** - Now we have to deal with the admin menu. If the admin library is loaded call the function to add our items. - */ - new Handle:gTopMenu; - if (LibraryExists("adminmenu") && ((gTopMenu = GetAdminTopMenu()) != INVALID_HANDLE)) - { - OnAdminMenuReady(gTopMenu); - } - - /** - Deal with the hud - Thanks to Spray Trace plugin (http://forums.alliedmods.net/showthread.php?p=665448) - */ - new String:sHudGames[32]; - GetGameFolderName(sHudGames, sizeof(sHudGames)); - g_aPluginSettings[bCanHUD] = StrEqual(sHudGames,"tf",false) - || StrEqual(sHudGames,"hl2mp",false) - || StrEqual(sHudGames,"sourceforts",false) - || StrEqual(sHudGames,"obsidian",false) - || StrEqual(sHudGames,"left4dead",false) - || StrEqual(sHudGames,"l4d",false); - - if (g_aPluginSettings[bCanHUD]) - { - g_hHud = CreateHudSynchronizer(); - } - - /** - Load translations - */ - LoadTranslations ("common.phrases"); - LoadTranslations ("simplespectate.phrases"); - - /** - Create the config file - */ - AutoExecConfig(true); -} - -public OnConfigsExecuted() -{ - new e_CvarHandles:iCvar; - for ( ; _:iCvar < sizeof(g_aPluginCvarSettings); iCvar++) - { - g_aPluginCvarSettings[iCvar] = GetConVarBool(g_aPluginCvar[iCvar]); - } - - /* - Build the global menus - */ - g_aMenus[hSelectPlayer] = BuildSelectPlayerMenu(); - g_aMenus[hBanTime] = BuildBanTimeMenu(); - g_aMenus[hReason] = BuildReasonMenu(); - - GetConVarString(sm_spectate_adminflag, g_sAdminFlags, sizeof(g_sAdminFlags)); -} - -public OnAllPluginsLoaded() -{ - - /* - Check for steambans - */ - if (FindConVar("sbsrc_version") != INVALID_HANDLE) - { - g_aPluginSettings[bUseSteamBans] = true; - } - else - { - g_aPluginSettings[bUseSteamBans] = false; - } - - /* - Check for sourcebans - */ - if (FindConVar("sb_version") != INVALID_HANDLE) - { - g_aPluginSettings[bUseSourceBans] = true; - } - else - { - g_aPluginSettings[bUseSourceBans] = false; - } - - /* - Check for mysql bans - */ - if (FindConVar("mysql_bans_version") != INVALID_HANDLE) - { - g_aPluginSettings[bUseMySQLBans] = true; - } - else - { - g_aPluginSettings[bUseMySQLBans] = false; - } - - /* - Check for dukehacks - */ - new String:sExtError[256]; - new iExtStatus = GetExtensionFileStatus("dukehacks.ext", sExtError, sizeof(sExtError)); - if (iExtStatus == -2) - { - LogAction(0, -1, "[SSPEC] Dukehacks extension was not found."); - LogAction(0, -1, "[SSPEC] Plugin continued to load, but that feature will not be used."); - g_aPluginSettings[bUseDukehacks] = false; - } - else if (iExtStatus == -1 || iExtStatus == 0) - { - LogAction(0, -1, "[SSPEC] Dukehacks extension is loaded with errors."); - LogAction(0, -1, "[SSPEC] Status reported was [%s].", sExtError); - LogAction(0, -1, "[SSPEC] Plugin continued to load, but that feature will not be used."); - g_aPluginSettings[bUseDukehacks] = false; - } - else if (iExtStatus == 1) - { - LogAction(0, -1, "[SSPEC] Dukehacks extension is loaded and will be used."); - g_aPluginSettings[bUseDukehacks] = true; - dhAddClientHook(CHK_TakeDamage, Hacks_TakeDamageHook); - } - - /* - Deal with some known plugin conflicts - */ - new Handle:hObserveClient = FindConVar("observe_version"); - if (hObserveClient != INVALID_HANDLE) - { - new String:sNewFile[PLATFORM_MAX_PATH + 1], String:sOldFile[PLATFORM_MAX_PATH + 1]; - BuildPath(Path_SM, sNewFile, sizeof(sNewFile), "plugins/disabled/observe.smx"); - BuildPath(Path_SM, sOldFile, sizeof(sOldFile), "plugins/observe.smx"); - - /** - Check if plugins/observe.smx exists, and if not, ignore - */ - if(!FileExists(sOldFile)) - { - return; - } - - /** - Check if plugins/disabled/observe.smx already exists, and if so, delete it - */ - if(FileExists(sNewFile)) - { - DeleteFile(sNewFile); - } - - /** - Unload plugins/observe.smx and move it to plugins/disabled/observe.smx - */ - LogAction(0, -1, "Detected the plugin ObserveClient"); - LogAction(0, -1, "ObserveClient plugin conflicts with Simple Spectate"); - LogAction(0, -1, "Unloading plugin and disabling ObserveClient plugin"); - ServerCommand("sm plugins unload observe"); - RenameFile(sNewFile, sOldFile); - } -} - -public OnLibraryRemoved(const String:name[]) -{ - if (StrEqual(name, "adminmenu")) - { - - /** - Looks like the admin menu was removed. Set the global. - */ - g_hAdminMenu = INVALID_HANDLE; - } - else if (StrEqual(name, "simpleplugins")) - { - //something - } -} - -public OnClientDisconnect(client) -{ - - /** - Cleanup the clients variables. - */ - ResetClient(client); - - /** - Run a loop and see if we are supposed to spectate this person (is a target) - */ - for(new i = 1; i <= MaxClients; i++) - { - if (g_aPlayers[i][iTargetIndex] == client) - { - - /** - Cleanup the clients variables. - */ - StopFollowingPlayer(i); - g_aPlayers[i][TargetPunishment] = Punish_None; - g_aPlayers[i][iBanTime] = 0; - } - } -} - -/** -Thirdparty callbacks -*/ -public SM_OnPlayerMoved(Handle:plugin, client, team) -{ - - /** - Make sure we called the move function - */ - if (plugin != GetMyHandle()) - { - return; - } - - //Nothing -} - -public Action:Hacks_TakeDamageHook(client, attacker, inflictor, Float:damage, &Float:multiplier, damagetype) -{ - - /** - Check for a valid client - */ - if (client > 0 && client <= MaxClients) - { - - /** - Check if the client taking damage is flagged as a cheater - */ - if (g_aPlayers[client][bIsFlaggedCheater]) - { - - /** - Check for fall damage and increase it - */ - if (damagetype & DMG_FALL) - { - multiplier *= 1000.0; - return Plugin_Changed; - } - } - } - - /** - Check for a valid attacker - */ - if (attacker > 0 && attacker <= MaxClients) - { - - /** - Check if the attacker causing the damage is flagged as a cheater - */ - if (g_aPlayers[attacker][bIsFlaggedCheater]) - { - - /** - Make sure they are not hurting themselves - */ - if (client != attacker) - { - - /** - Stop the damage - */ - multiplier *= 0.0; - return Plugin_Changed; - } - } - } - return Plugin_Continue; -} - -/** -Events -*/ -public Action:HookPlayerChangeTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get the client and team - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - new iTeam = GetEventInt(event, "team"); - - /** - Make sure it's a valid client - */ - if (iClient == 0) - { - return Plugin_Continue; - } - - /** - If it's a move to spectator start displaying the hud - */ - else if ((iTeam == g_aCurrentTeams[Spectator]) && (GetUserFlagBits(iClient) & ADMFLAG_GENERIC)) - { - StartDisplayingHud(iClient); - - /** - If the event was going to be broadcasted, we refire it so it is not broadcasted and stop this one - */ - if (!dontBroadcast) - { - new Handle:hEvent = CreateEvent("player_team"); - SetEventInt(hEvent, "userid", GetEventInt(event, "userid")); - SetEventInt(hEvent, "team", GetEventInt(event, "team")); - SetEventInt(hEvent, "oldteam", GetEventInt(event, "oldteam")); - SetEventBool(hEvent, "disconnect", GetEventBool(event, "disconnect")); - - if (g_CurrentMod == GameType_DOD || g_CurrentMod == GameType_L4D || g_CurrentMod == GameType_TF) - { - new String:sClientName[MAX_NAME_LENGTH + 1]; - GetClientName(client, sClientName, sizeof(sClientName)); - SetEventBool(hEvent, "autoteam", GetEventBool(event, "autoteam")); - SetEventBool(hEvent, "silent", true); - SetEventString(hEvent, "name", sClientName); - FireEvent(hEvent, true); - } - else - { - FireEvent(hEvent, true); - } - return Plugin_Handled; - } - } - - /** - Otherwise cleanup the client - */ - else - { - StopDisplayingHud(iClient); - StopFollowingPlayer(iClient); - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -/** -Commands -*/ -public Action:Command_Spectate(client, args) -{ - - /** - See if we already have a target (for toggling of command) - */ - if (g_aPlayers[client][iTargetIndex]) - { - - /** - We do, toggle it off - */ - StopFollowingPlayer(client); - - /** - We are done, bug out. - */ - return Plugin_Handled; - } - - /** - We don't... must want to enable it - See if we have some command arguments. - */ - new iCmdArgs = GetCmdArgs(); - if (iCmdArgs == 0) - { - - /** - We don't have any. Display the player menu. - */ - if (g_aPlayers[client][bIsDisplayingHud]) - { - StopDisplayingHud(client); - } - - DisplayMenu(BuildPlayerListMenu(), client, MENU_TIME_FOREVER); - return Plugin_Handled; - } - - /** - We have an argument. - Try to find the target. - */ - new String:sPlayer[128]; - GetCmdArg(1, sPlayer, sizeof(sPlayer)); - new iTarget = FindTarget(client, sPlayer, true, true); - if (iTarget == -1 || !IsClientInGame(iTarget)) - { - - /** - We couldn't find the target. Display the player menu. - */ - if (g_aPlayers[client][bIsDisplayingHud]) - { - StopDisplayingHud(client); - } - - DisplayMenu(BuildPlayerListMenu(), client, MENU_TIME_FOREVER); - return Plugin_Handled; - } - - /** - We found the target. - Call the stock function to spectate the target. - */ - StartFollowingPlayer(client, iTarget); - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_StopSpectate(client, args) -{ - - /** - Cleanup the clients variables. - */ - StopFollowingPlayer(client); - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_ToggleHud(client, args) -{ - - /** - Toggle the hud - */ - if (g_aPlayers[client][bIsDisplayingHud]) - { - StopDisplayingHud(client); - } - else - { - StartDisplayingHud(client); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -/** -Timers -*/ -public Action:Timer_ResetTarget(Handle:timer, any:client) -{ - - new iTargetID = GetEntPropEnt(client, Prop_Send, "m_hObserverTarget"); - - if (iTargetID != g_aPlayers[client][iTargetIndex] && IsPlayerAlive(g_aPlayers[client][iTargetIndex])) - { - - /** - Run the command to spectate the target from the clients prospectative. - */ - FakeClientCommandEx(client, "spec_player \"%N\"", g_aPlayers[client][iTargetIndex]); - } - - /** - We are done, bug out. - */ - return Plugin_Continue; -} - -public Action:Timer_UpdateHud(Handle:timer, any:client) -{ - - /** - Make sure the client is still in game and a spectator - */ - if (!IsClientConnected(client) || !IsClientInGame(client) || GetClientTeam(client) != g_aCurrentTeams[Spectator] || !g_aPlayers[client][bIsDisplayingHud]) - { - - /** - We are done, bug out - */ - g_aPlayers[client][hHudTimer] = INVALID_HANDLE; - g_aPlayers[client][bIsDisplayingHud] = false; - return Plugin_Stop; - } - /** - Get the target - */ - new iTarget = GetEntPropEnt(client, Prop_Send, "m_hObserverTarget"); - - /** - Check to make sure the target is valid - */ - if (iTarget <= 0 || iTarget > MaxClients) - { - return Plugin_Continue; - } - - /** - Get the spectator mode - */ - new iSpecMode = GetEntProp(client, Prop_Send, "m_iObserverMode"); - - /** - This is a double check to make sure we are in spec - If we are on a regular team, specmod would = none or zero - */ - if (iSpecMode == SPECMODE_NONE) - { - - /** - We are done, bug out - */ - g_aPlayers[client][hHudTimer] = INVALID_HANDLE; - g_aPlayers[client][bIsDisplayingHud] = false; - return Plugin_Stop; - } - - /** - Check the spectator mode - CSS has different index's so we have to check game type first - */ - if (g_CurrentMod == GameType_CSS) - { - switch (iSpecMode) - { - case SPECMODE_CSS_FIRSTPERSON: - { - //Do Nothing - } - case SPECMODE_CSS_3RDPERSON: - { - //Do Nothing - } - case SPECMODE_CSS_FREELOOK: - { - return Plugin_Continue; - } - } - } - else - { - switch (iSpecMode) - { - case SPECMODE_FIRSTPERSON: - { - //Do Nothing - } - case SPECMODE_3RDPERSON: - { - //Do Nothing - } - case SPECMODE_FREELOOK: - { - return Plugin_Continue; - } - } - } - - - /** - Display with the hud - */ - if (g_aPluginSettings[bCanHUD] && !g_aPluginCvarSettings[bHudMode]) - { - new String:sSteamID[64]; - GetClientAuthString(iTarget, sSteamID, sizeof(sSteamID)); - SetHudTextParams(0.04, 0.6, 0.5, 255, 50, 50, 255); - ShowSyncHudText(client, g_hHud, "%N [%s]", iTarget, sSteamID); - } - else if (g_aPluginCvarSettings[bHudMode]) - { - if (g_aPluginCvarSettings[bMenuType]) - { - DisplayMenu(BuildPlayerHudMenu(client, iTarget), client, 1); - } - else - { - new Handle:hPanel = BuildPlayerHudPanel(client, iTarget); - SendPanelToClient(hPanel, client, Panel_PlayerHud, 1); - CloseHandle(hPanel); - } - } - - /** - We are done, keep going! - */ - return Plugin_Continue; -} - -/** -Admin Menu Callbacks -*/ -public OnAdminMenuReady(Handle:topmenu) -{ - if (topmenu == g_hAdminMenu) - { - return; - } - g_hAdminMenu = topmenu; - new TopMenuObject:player_commands = FindTopMenuCategory(g_hAdminMenu, ADMINMENU_PLAYERCOMMANDS); - if (player_commands == INVALID_TOPMENUOBJECT) - { - return; - } - AddToTopMenu(g_hAdminMenu, - "sm_spectate", - TopMenuObject_Item, - AdminMenu_SpecPlayer, - player_commands, - "sm_spectate", - ADMFLAG_GENERIC); -} - -public AdminMenu_SpecPlayer(Handle:topmenu, TopMenuAction:action, TopMenuObject:object_id, param, String:buffer[], maxlength) -{ - if (action == TopMenuAction_DisplayOption) - { - - if (g_aPlayers[param][bIsDisplayingHud]) - { - StopDisplayingHud(param); - } - /** - See if we already have a target - */ - if (g_aPlayers[param][iTargetIndex]) - { - Format(buffer, maxlength, "Spectate(Disable)"); - } - else - { - Format(buffer, maxlength, "Spectate(Select Player)"); - } - } - else if (action == TopMenuAction_SelectOption) - { - - /** - See if we already have a target - */ - if (g_aPlayers[param][iTargetIndex]) - { - - /** - We do, toggle it off - */ - StopFollowingPlayer(param); - - /** - We are done, bug out. - */ - return; - } - else - { - DisplayMenu(BuildPlayerListMenu(), param, MENU_TIME_FOREVER); - } - } -} - -/** -Select Player Menu Callbacks -*/ -public Menu_PlayerList(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - /** - Get the selected player - */ - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - new iTarget = GetClientOfUserId(StringToInt(sSelection)); - - /** - Start following the player - */ - StartFollowingPlayer(param1, iTarget); - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_GENERIC) - { - - /** - Display the last admin menu - */ - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } - else if (param2 == MenuCancel_Exit && GetClientTeam(param1) == g_aCurrentTeams[Spectator]) - { - /** - They canceled the current menu, start the hud back up - */ - StartDisplayingHud(param1); - } - } - else if (action == MenuAction_End) - { - - /** - Not a global menu, close it - */ - CloseHandle(menu); - } -} - -public Menu_SelectPlayer(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - - /** - Get the selected player - */ - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (strcmp(sSelection, "Current", false) == 0) - { - /** - Get the current target - */ - new iTarget = GetEntPropEnt(param1, Prop_Send, "m_hObserverTarget"); - - /** - Check to make sure the target is valid - */ - if (iTarget <= 0 || iTarget > MaxClients) - { - PrintToChat(param1, "\x03[SM-SPEC]\x01 %t", "Invalid Target"); - DisplayMenu(BuildPlayerListMenu(), param1, MENU_TIME_FOREVER); - } - - /** - Start following the player - */ - StartFollowingPlayer(param1, iTarget); - } - else - { - - /** - They want to select a player, show the player list - */ - DisplayMenu(BuildPlayerListMenu(), param1, MENU_TIME_FOREVER); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - - /** - They canceled the current menu, start the hud back up - */ - StartDisplayingHud(param1); - } - } - else if (action == MenuAction_End) - { - /** - Its a global menu, leave it alive - */ - } -} - -/** -Punishment Menu Callbacks -*/ -public Menu_Punishments(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - - /** - Get the menu selection - */ - new String:sSelection[15]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - - /** - Search for the correct index - */ - new e_Punishments:Index = Punish_None; - for ( ; _:Index <= sizeof(g_sPunishments); Index++) - { - if (StrEqual(sSelection, g_sPunishments[Index])) - { - break; - } - } - - /** - Display the next menu - */ - if (Index == Punish_Ban) - { - - /** - Set the punishment index and display ban time menu - */ - g_aPlayers[param1][TargetPunishment] = Index; - DisplayMenu(g_aMenus[hBanTime], param1, MENU_TIME_FOREVER); - } - else if (Index == Punish_Cheater) - { - - /** - Ask for confirmation before we set punishment index - */ - new Handle:hPanel = BuildAdminCheaterPanel(); - SendPanelToClient(hPanel, param1, Panel_AdminCheater, MENU_TIME_FOREVER); - CloseHandle(hPanel); - } - else - { - - /** - Set the punishment index and display reason menu - */ - g_aPlayers[param1][TargetPunishment] = Index; - DisplayMenu(g_aMenus[hReason], param1, MENU_TIME_FOREVER); - } - } - else if (action == MenuAction_Cancel) - { - - /** - They canceled the current menu, start the hud back up - */ - StartDisplayingHud(param1); - } - else if (action == MenuAction_End) - { - - /** - Not a global menu, close it - */ - CloseHandle(menu); - } -} - -public Menu_BanTime(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - - /** - Get the menu selection - */ - new String:sSelection[15]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - - /** - Set the ban time global - */ - g_aPlayers[param1][iBanTime] = StringToInt(sSelection); - - /** - Display the reason menu - */ - DisplayMenu(g_aMenus[hReason], param1, MENU_TIME_FOREVER); - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - - /** - They canceled the current menu, start the hud back up - */ - StartDisplayingHud(param1); - } - } - else if (action == MenuAction_End) - { - /** - Its a global menu, leave it alive - */ - } -} - -public Menu_Reason(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - - /** - Get the menu selection - */ - new String:sSelection[15]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - - /** - Perform the punishment - */ - PerformPunishment(param1, g_aPlayers[param1][iTargetIndex], g_aPlayers[param1][TargetPunishment], sSelection, g_aPlayers[param1][iBanTime]); - - /** - Reactivate the hud if still in spectator - */ - if (GetClientTeam(param1) == g_aCurrentTeams[Spectator]) - { - StartDisplayingHud(param1); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack) - { - - /** - They canceled the current menu, start the hud back up - */ - StartDisplayingHud(param1); - } - } - else if (action == MenuAction_End) - { - /** - Its a global menu, leave it alive - */ - } -} - -public Panel_AdminCheater(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - if (param2 == 1) - { - - /** - Set the punishment index and display reason menu - */ - g_aPlayers[param1][TargetPunishment] = Punish_Cheater; - DisplayMenu(g_aMenus[hReason], param1, MENU_TIME_FOREVER); - } - else - { - - /** - Reactivate the hud if still in spectator - */ - if (GetClientTeam(param1) == g_aCurrentTeams[Spectator]) - { - StartDisplayingHud(param1); - } - } - } -} - -public Panel_PublicCheater(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - if (param2 == 1) - { - //Waiting for SB 2.0 and sb_submission to be published - } - else - { - - /** - Reactivate the hud if still in spectator - */ - if (GetClientTeam(param1) == g_aCurrentTeams[Spectator]) - { - StartDisplayingHud(param1); - } - } - } -} - -/** -Hud Menu/Panel Callbacks -*/ -public Menu_PlayerHud(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "stop", false)) - { - StopFollowingPlayer(param1); - } - else if (StrEqual(sSelection, "start", false)) - { - StopDisplayingHud(param1); - DisplayMenu(g_aMenus[hSelectPlayer], param1, MENU_TIME_FOREVER); - } - else if (StrEqual(sSelection, "removecheater", false)) - { - g_aPlayers[g_aPlayers[param1][iTargetIndex]][bIsFlaggedCheater] = false; - } - else if (StrEqual(sSelection, "punish", false)) - { - if (g_aPlayers[param1][iTargetIndex]) - { - StopDisplayingHud(param1); - DisplayMenu(BuildPunishmentMenu(param1), param1, MENU_TIME_FOREVER); - } - else - { - StopDisplayingHud(param1); - PrintToChat(param1, "\x03[SM-SPEC]\x01 %t", "Must Have Target"); - DisplayMenu(g_aMenus[hSelectPlayer], param1, MENU_TIME_FOREVER); - } - } - else if (StrEqual(sSelection, "reportcheater", false)) - { - if (g_aPlayers[param1][iTargetIndex]) - { - StopDisplayingHud(param1); - new Handle:hPanel = BuildPublicCheaterPanel(); - SendPanelToClient(hPanel, param1, Panel_PublicCheater, MENU_TIME_FOREVER); - CloseHandle(hPanel); - } - else - { - StopDisplayingHud(param1); - PrintToChat(param1, "\x03[SM-SPEC]\x01 %t", "Must Have Target"); - DisplayMenu(g_aMenus[hSelectPlayer], param1, MENU_TIME_FOREVER); - } - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_Interrupted) - { - if (GetClientMenu(param1) == MenuSource_External) - { - StopDisplayingHud(param1); - } - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } -} - -public Panel_PlayerHud(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - switch (param2) - { - case 1: - { - if (g_aPlayers[param1][iTargetIndex]) - { - StopFollowingPlayer(param1); - } - else - { - StopDisplayingHud(param1); - DisplayMenu(BuildSelectPlayerMenu(), param1, MENU_TIME_FOREVER); - } - } - case 2: - { - if (!g_aPlayers[param1][iTargetIndex]) - { - StopDisplayingHud(param1); - PrintToChat(param1, "\x03[SM-SPEC]\x01 %t", "Must Have Target"); - DisplayMenu(g_aMenus[hSelectPlayer], param1, MENU_TIME_FOREVER); - return; - } - - if ((GetUserFlagBits(param1) & ADMFLAG_GENERIC) || (GetUserFlagBits(param1) & ADMFLAG_ROOT)) - { - if (g_aPlayers[g_aPlayers[param1][iTargetIndex]][bIsFlaggedCheater] && (GetUserFlagBits(param1) & ADMFLAG_ROOT)) - { - //Remove cheater flag - g_aPlayers[g_aPlayers[param1][iTargetIndex]][bIsFlaggedCheater] = false; - } - else - { - //Punish menu - StopDisplayingHud(param1); - DisplayMenu(BuildPunishmentMenu(param1), param1, MENU_TIME_FOREVER); - } - } - else - { - //Report Cheater - new Handle:hPanel = BuildPublicCheaterPanel(); - SendPanelToClient(hPanel, param1, Panel_PublicCheater, MENU_TIME_FOREVER); - CloseHandle(hPanel); - } - } - case 3: - { - StopDisplayingHud(param1); - } - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_Interrupted) - { - if (GetClientMenu(param1) == MenuSource_External) - { - StopDisplayingHud(param1); - } - } - } -} - - -/** -Stock functions -*/ -stock StartFollowingPlayer(client, target) -{ - - /** - If we have an open timer, close it. - */ - if (g_aPlayers[client][hTargetTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[client][hTargetTimer]); - g_aPlayers[client][hTargetTimer] = INVALID_HANDLE; - } - - /** - Make sure the target is on a non spectator team, and the client != target - */ - if (client == target) - { - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Yourself"); - return; - } - new iTargetTeam = GetClientTeam(target); - if (iTargetTeam == g_aCurrentTeams[Spectator] || iTargetTeam == g_aCurrentTeams[Unknown]) - { - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Spectator"); - return; - } - - /** - Check to see if client is already a spectator - */ - if (GetClientTeam(client) != g_aCurrentTeams[Spectator]) - { - - /** - Client is not a spectator, lets move them to spec. - */ - SM_MovePlayer(client, g_aCurrentTeams[Spectator]); - } - - /** - If we are using steambans call sb_status - */ - if (g_aPluginSettings[bUseSteamBans]) - { - FakeClientCommandEx(client, "sb_status"); - } - - - /** - Set the global and start to spectate the target. - Making sure it's long enough to deal with moving the client to spec if we had to. - */ - new String:sTargetName[MAX_NAME_LENGTH + 1]; - GetClientName(target, sTargetName, sizeof(sTargetName)); - g_aPlayers[client][iTargetIndex] = target; - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Spectating", sTargetName); - g_aPlayers[client][hTargetTimer] = CreateTimer(0.5, Timer_ResetTarget, client, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); - if (!g_aPlayers[client][bIsDisplayingHud] && GetClientTeam(client) == g_aCurrentTeams[Spectator]) - { - StartDisplayingHud(client); - } -} - -stock StopFollowingPlayer(client) -{ - - /** - If we have an open timer, close it. - */ - if (g_aPlayers[client][hTargetTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[client][hTargetTimer]); - } - - /** - Tell the client we can't spec his target anymore... if they are in game. - */ - if (IsClientInGame(client) && g_aPlayers[client][iTargetIndex] != 0) - { - new String:sTargetName[MAX_NAME_LENGTH + 1]; - GetClientName(g_aPlayers[client][iTargetIndex], sTargetName, sizeof(sTargetName)); - if (!IsClientConnected(g_aPlayers[client][iTargetIndex]) || !IsClientInGame(g_aPlayers[client][iTargetIndex])) - { - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Target Left"); - } - else - { - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Stopped spectating", sTargetName); - } - } - - /** - Null the globals. - */ - g_aPlayers[client][iTargetIndex] = 0; - g_aPlayers[client][hTargetTimer] = INVALID_HANDLE; -} - -stock StartDisplayingHud(client) -{ - if (g_aPluginCvarSettings[bRestrictHud] && !SM_IsValidAdmin(client, g_sAdminFlags)) - { - return; - } - else - { - /** - Double check the hud timer - We should not have one, but if we do, lets cancel it for the current callback - */ - StopDisplayingHud(client); - - /** - Now we can safely display the hud and make sure the current stored handle is the current timer - */ - g_aPlayers[client][bIsDisplayingHud] = true; - g_aPlayers[client][hHudTimer] = CreateTimer(0.5, Timer_UpdateHud, client, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); - } -} - -stock StopDisplayingHud(client) -{ - if (g_aPlayers[client][hHudTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[client][hHudTimer]); - } - g_aPlayers[client][hHudTimer] = INVALID_HANDLE; - g_aPlayers[client][bIsDisplayingHud] = false; -} - -stock ResetClient(client) -{ - StopFollowingPlayer(client); - StopDisplayingHud(client); - - g_aPlayers[client][bIsFlaggedCheater] = false; - g_aPlayers[client][TargetPunishment] = Punish_None; - g_aPlayers[client][iBanTime] = -1; -} - -stock PerformPunishment(client, target, e_Punishments:punishment, const String:reason[], time = 300) -{ - new String:sTargetName[MAX_NAME_LENGTH + 1], - String:sTargetID[64]; - - /** - The target could have left the game by the time we get here - Check for a valid target - */ - if (!IsClientConnected(target) || !IsClientInGame(target)) - { - PrintToChat(client, "\x03[SM-SPEC]\x01 %t", "Target Left"); - return; - } - - GetClientName(target, sTargetName, sizeof(sTargetName)); - GetClientAuthString(target, sTargetID, sizeof(sTargetID)); - - switch (punishment) - { - case Punish_Kick: - { - KickClient(g_aPlayers[client][iTargetIndex], "%s", reason); - } - case Punish_Ban: - { - if (g_aPluginSettings[bUseSourceBans]) - { - ClientCommand(client, "sm_ban #%d %d \"%s\"", GetClientUserId(target), time, reason); - } - else if (g_aPluginSettings[bUseMySQLBans]) - { - ClientCommand(client, "mysql_ban #%d %d \"%s\"", GetClientUserId(target), time, reason); - } - else - { - BanClient(target, time, BANFLAG_AUTHID, reason, reason); - } - } - case Punish_Cheater: - { - g_aPlayers[target][bIsFlaggedCheater] = true; - } - case Punish_Beacon: - { - ClientCommand(client, "sm_beacon \"%s\"", sTargetName); - } - case Punish_Blind: - { - ClientCommand(client, "sm_blind \"%s\"", sTargetName); - } - case Punish_Drug: - { - ClientCommand(client, "sm_drug \"%s\"", sTargetName); - } - case Punish_Freeze: - { - ClientCommand(client, "sm_freeze \"%s\"", sTargetName); - } - case Punish_FreezeBomb: - { - ClientCommand(client, "sm_freezebomb \"%s\"", sTargetName); - } - case Punish_Slap: - { - ClientCommand(client, "sm_slap \"%s\" 10", sTargetName); - } - case Punish_Slay: - { - ClientCommand(client, "sm_slay \"%s\"", sTargetName); - } - case Punish_TimeBomb: - { - ClientCommand(client, "sm_timebomb \"%s\"", sTargetName); - } - } - - if (punishment == Punish_Cheater) - { - LogAction(client, target, "[SM SPEC] %N marked %N(%s) with a %s flag for %s", client, target, sTargetID, g_sPunishments[punishment], reason); - } - else - { - ShowActivity(client, "%t", "Punished", sTargetName, g_sPunishments[punishment], reason); - LogAction(client, target, "[SM SPEC] %N punished %N(%s) with a %s for %s", client, target, sTargetID, g_sPunishments[punishment], reason); - } - - /** - Null the globals. - */ - g_aPlayers[client][TargetPunishment] = Punish_None; - g_aPlayers[client][iBanTime] = -1; -} - -/** -Build the menu of player names -*/ -stock Handle:BuildPlayerListMenu() -{ - new Handle:hMenu = CreateMenu(Menu_PlayerList); - AddTargetsToMenu(hMenu, 0, true, false); - SetMenuTitle(hMenu, "Select A Player:"); - SetMenuExitBackButton(hMenu, true); - return hMenu; -} - -/** -Build the select player menu (current or list of players) -*/ -stock Handle:BuildSelectPlayerMenu() -{ - new Handle:hMenu = CreateMenu(Menu_SelectPlayer); - SetMenuTitle(hMenu, "Select A Player:"); - AddMenuItem(hMenu, "Current", "Current Target"); - AddMenuItem(hMenu, "List", "Player List"); - SetMenuExitBackButton(hMenu, true); - return hMenu; -} - -/** -Build the punishmenu menu -*/ -stock Handle:BuildPunishmentMenu(iClient) -{ - new Handle:hMenu = CreateMenu(Menu_Punishments); - SetMenuTitle(hMenu, "Select A Punishment:"); - SetMenuExitBackButton(hMenu, true); - SetMenuExitButton(hMenu, true); - - if (g_aPluginCvarSettings[bKick] && ((GetUserFlagBits(iClient) & ADMFLAG_GENERIC) || (GetUserFlagBits(iClient) & ADMFLAG_ROOT))) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Kick], "Kick"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Kick], "Kick", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bBan] && ((GetUserFlagBits(iClient) & ADMFLAG_GENERIC) || (GetUserFlagBits(iClient) & ADMFLAG_ROOT))) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Ban], "Ban"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Ban], "Ban", ITEMDRAW_DISABLED); - } - - if (g_aPluginSettings[bUseDukehacks] && g_aPluginCvarSettings[bCheater] && (GetUserFlagBits(iClient) & ADMFLAG_ROOT)) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Cheater], "Flag As Cheater"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Cheater], "Flag As Cheater", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bBeacon]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Beacon], "Beacon"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Beacon], "Beacon", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bBlind]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Blind], "Blind"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Blind], "Blind", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bDrug]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Drug], "Drug"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Drug], "Drug", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bFreeze]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Freeze], "Freeze"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Freeze], "Freeze", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bFreezebomb]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_FreezeBomb], "Freeze Bomb"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_FreezeBomb], "Freeze Bomb", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bSlap]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Slap], "Slap"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Slap], "Slap", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bSlay]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_Slay], "Slay"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_Slay], "Slay", ITEMDRAW_DISABLED); - } - - if (g_aPluginCvarSettings[bTimeBomb]) - { - AddMenuItem(hMenu, g_sPunishments[Punish_TimeBomb], "Time Bomb"); - } - else - { - AddMenuItem(hMenu, g_sPunishments[Punish_TimeBomb], "Time Bomb", ITEMDRAW_DISABLED); - } - - return hMenu; -} - -/** -Build the punishmenu menu -*/ -stock Handle:BuildBanTimeMenu() -{ - new Handle:hMenu = CreateMenu(Menu_BanTime); - SetMenuTitle(hMenu, "Select Ban Type:"); - - if (g_aPluginCvarSettings[bBanPerm]) - { - AddMenuItem(hMenu, "permban", "Permanent"); - } - else - { - AddMenuItem(hMenu, "permban", "Permanent", ITEMDRAW_DISABLED); - } - - AddMenuItem(hMenu, "10", "10 Minutes"); - AddMenuItem(hMenu, "30", "30 Minutes"); - AddMenuItem(hMenu, "60", "1 Hour"); - AddMenuItem(hMenu, "240", "4 Hours"); - AddMenuItem(hMenu, "1440", "1 Day"); - AddMenuItem(hMenu, "10080", "1 Week"); - - SetMenuExitBackButton(hMenu, true); - return hMenu; -} - -/** -Build the punishmenu menu -*/ -stock Handle:BuildReasonMenu() -{ - new Handle:hMenu = CreateMenu(Menu_Reason); - SetMenuTitle(hMenu, "Select A Reason:"); - - AddMenuItem(hMenu, "Abusive", "Abusive"); - AddMenuItem(hMenu, "Racism", "Racism"); - AddMenuItem(hMenu, "General cheating/exploits", "General cheating/exploits"); - AddMenuItem(hMenu, "Wallhack", "Wallhack"); - AddMenuItem(hMenu, "Aimbot", "Aimbot"); - AddMenuItem(hMenu, "Speedhacking", "Speedhacking"); - AddMenuItem(hMenu, "Mic spamming", "Mic spamming"); - AddMenuItem(hMenu, "Admin disrepect", "Admin disrepect"); - AddMenuItem(hMenu, "Camping", "Camping"); - AddMenuItem(hMenu, "Team killing", "Team killing"); - AddMenuItem(hMenu, "Unacceptable Spray", "Unacceptable Spray"); - AddMenuItem(hMenu, "Breaking Server Rules", "Breaking Server Rules"); - AddMenuItem(hMenu, "Other", "Other"); - - SetMenuExitBackButton(hMenu, true); - return hMenu; -} - -/** -Build the cheater displays -*/ -stock Handle:BuildAdminCheaterPanel() -{ - - /** - Create the menu and set the menu options. - */ - new Handle:hPanel = CreatePanel(); - SetPanelTitle(hPanel, "Simple Spectator:"); - - DrawPanelText(hPanel, "Are you sure you want to"); - DrawPanelText(hPanel, "flag this player as a cheater?"); - DrawPanelText(hPanel, "They will not be able to damage"); - DrawPanelText(hPanel, "anyone and die on fall damage."); - DrawPanelItem(hPanel, "Yes"); - DrawPanelItem(hPanel, "No"); - - return hPanel; -} - -stock Handle:BuildPublicCheaterPanel() -{ - - /** - Create the menu and set the menu options. - */ - new Handle:hPanel = CreatePanel(); - SetPanelTitle(hPanel, "Simple Spectator:"); - - DrawPanelText(hPanel, "Are you sure you want to"); - DrawPanelText(hPanel, "submit this player as a cheater?"); - DrawPanelItem(hPanel, "Yes (Not Implemented Yet)", ITEMDRAW_DISABLED); - DrawPanelItem(hPanel, "No"); - return hPanel; -} - -/** -Build the hud displays -*/ -stock Handle:BuildPlayerHudMenu(iClient, iTarget) -{ - - /** - Create all the string variables we will need - */ - new String:sTargetName[MAX_NAME_LENGTH + 1], - String:sTargetID[64], - String:sTargetIP[16]; - - new String:sDisplayName[MAX_NAME_LENGTH + 1], - String:sDisplayID[64], - String:sDisplayIP[64], - String:sDisplayFrags[16], - String:sDisplayDeaths[16]; - - new iTargetFrags, - iTargetDeaths; - - /** - Get the targets information - */ - GetClientName(iTarget, sTargetName, sizeof(sTargetName)); - GetClientIP(iTarget, sTargetIP, sizeof(sTargetIP)); - GetClientAuthString(iTarget, sTargetID, sizeof(sTargetID)); - iTargetFrags = GetClientFrags(iTarget); - iTargetDeaths = GetClientDeaths(iTarget); - - /** - Format the strings for the menu - */ - Format(sDisplayName, sizeof(sDisplayName), "Player: %s", sTargetName); - Format(sDisplayID, sizeof(sDisplayID), "Steam ID: %s", sTargetID); - Format(sDisplayIP, sizeof(sDisplayIP), "IP Address: %s", sTargetIP); - Format(sDisplayFrags, sizeof(sDisplayFrags), "Kills: %i", iTargetFrags); - Format(sDisplayDeaths, sizeof(sDisplayDeaths), "Deaths: %i", iTargetDeaths); - - /** - Create the menu and set the menu options. - */ - new Handle:hMenu = CreateMenu(Menu_PlayerHud); - SetMenuExitBackButton(hMenu, false); - SetMenuTitle(hMenu, "Simple Spectator"); - - AddMenuItem(hMenu, "name", sDisplayName, ITEMDRAW_DISABLED); - AddMenuItem(hMenu, "steamid", sDisplayID, ITEMDRAW_DISABLED); - - if (SM_IsValidAdmin(iClient, g_sAdminFlags)) - { - AddMenuItem(hMenu, "ip", sDisplayIP, ITEMDRAW_DISABLED); - } - - AddMenuItem(hMenu, "kills", sDisplayFrags, ITEMDRAW_DISABLED); - AddMenuItem(hMenu, "deaths", sDisplayDeaths, ITEMDRAW_DISABLED); - - if (g_aPlayers[iClient][iTargetIndex]) - { - AddMenuItem(hMenu, "stop", "Stop Following"); - } - else - { - AddMenuItem(hMenu, "start", "Follow Player"); - } - - if ((GetUserFlagBits(iClient) & ADMFLAG_GENERIC) || (GetUserFlagBits(iClient) & ADMFLAG_ROOT)) - { - if (g_aPlayers[iTarget][bIsFlaggedCheater] && (GetUserFlagBits(iClient) & ADMFLAG_ROOT)) - { - AddMenuItem(hMenu, "removecheater", "Remove Cheater Flag"); - } - else - { - if (CanUserTarget(iClient, iTarget)) - { - AddMenuItem(hMenu, "punish", "Punish Player"); - } - else - { - AddMenuItem(hMenu, "punish", "Punish Player (Immune)", ITEMDRAW_DISABLED); - } - } - } - else - { - AddMenuItem(hMenu, "reportcheater", "Report Cheater"); - } - - SetMenuPagination(hMenu, MENU_NO_PAGINATION); - SetMenuExitButton(hMenu, true); - return hMenu; -} - -stock Handle:BuildPlayerHudPanel(iClient, iTarget) -{ - - /** - Create all the string variables we will need - */ - new String:sTargetName[MAX_NAME_LENGTH + 1], - String:sTargetID[64], - String:sTargetIP[16]; - - new String:sDisplayName[MAX_NAME_LENGTH + 1], - String:sDisplayID[64], - String:sDisplayIP[64], - String:sDisplayFrags[16], - String:sDisplayDeaths[16]; - - new iTargetFrags, - iTargetDeaths; - - /** - Get the targets information - */ - GetClientName(iTarget, sTargetName, sizeof(sTargetName)); - GetClientIP(iTarget, sTargetIP, sizeof(sTargetIP)); - GetClientAuthString(iTarget, sTargetID, sizeof(sTargetID)); - iTargetFrags = GetClientFrags(iTarget); - iTargetDeaths = GetClientDeaths(iTarget); - - /** - Format the strings for the menu - */ - Format(sDisplayName, sizeof(sDisplayName), "Player: %s", sTargetName); - Format(sDisplayID, sizeof(sDisplayID), "Steam ID: %s", sTargetID); - Format(sDisplayIP, sizeof(sDisplayIP), "IP Address: %s", sTargetIP); - Format(sDisplayFrags, sizeof(sDisplayFrags), "Kills: %i", iTargetFrags); - Format(sDisplayDeaths, sizeof(sDisplayDeaths), "Deaths: %i", iTargetDeaths); - - /** - Create the menu and set the menu options. - */ - new Handle:hPanel = CreatePanel(); - SetPanelTitle(hPanel, "Simple Spectator"); - - DrawPanelText(hPanel, "Player Information:"); - DrawPanelText(hPanel, sDisplayName); - DrawPanelText(hPanel, sDisplayID); - if (SM_IsValidAdmin(iClient, g_sAdminFlags)) - { - DrawPanelText(hPanel, sDisplayIP); - } - - DrawPanelText(hPanel, sDisplayFrags); - DrawPanelText(hPanel, sDisplayDeaths); - - if (g_aPlayers[iClient][iTargetIndex]) - { - DrawPanelItem(hPanel, "Stop Following"); - } - else - { - DrawPanelItem(hPanel, "Follow Player"); - } - - if ((GetUserFlagBits(iClient) & ADMFLAG_GENERIC) || (GetUserFlagBits(iClient) & ADMFLAG_ROOT)) - { - if (g_aPlayers[iTarget][bIsFlaggedCheater] && (GetUserFlagBits(iClient) & ADMFLAG_ROOT)) - { - DrawPanelItem(hPanel, "Remove Cheater Flag"); - } - else - { - if (CanUserTarget(iClient, iTarget)) - { - DrawPanelItem(hPanel, "Punish Player"); - } - else - { - DrawPanelItem(hPanel, "Punish Player (Immune)", ITEMDRAW_DISABLED); - } - } - } - else - { - DrawPanelItem(hPanel, "Report Cheater"); - } - - DrawPanelItem(hPanel, "Close Hud Panel"); - return hPanel; -} - -/** -Adjust the settings if a convar was changed -*/ -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - for (new iCvar = 0 ; _:iCvar < sizeof(g_aPluginCvarSettings); iCvar++) - { - if (g_aPluginCvar[_:iCvar] == convar) - { - if (StringToInt(newValue) == 1) - { - g_aPluginCvarSettings[_:iCvar] = true; - } - else - { - g_aPluginCvarSettings[_:iCvar] = false; - } - } - } - - /* - ReBuild the global menu that depends on cvars - */ - g_aMenus[hBanTime] = BuildBanTimeMenu(); - - /** - Run a loop to reset the hud - */ - for(new i = 1; i <= MaxClients; i++) - { - StopDisplayingHud(i); - if (IsClientConnected(i) && IsClientInGame(i) && GetClientTeam(i) == g_aCurrentTeams[Spectator]) - { - StartDisplayingHud(i); - } - } -} diff --git a/addons/sourcemod/scripting/simple-teambalancer.sp b/addons/sourcemod/scripting/simple-teambalancer.sp deleted file mode 100644 index 3302255..0000000 --- a/addons/sourcemod/scripting/simple-teambalancer.sp +++ /dev/null @@ -1,1797 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Team Balancer -Description: - Balances teams based upon player count - Player will not be balanced more than once in 5 (default) mins - Buddy system tries to keep buddies together - Ability to prioritize players - Ability to force players to accept the new team - Admins are immune -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include -#include - -#define PLUGIN_VERSION "2.1.$Rev$" - -enum PlayerData -{ - Handle:hBalanceTimer, - Handle:hForcedTimer, - bool:bSwitched, - bool:bFlagCarrier -}; - -/** - Global convar handles - */ -new Handle:stb_enabled = INVALID_HANDLE; -new Handle:stb_buddyenabled = INVALID_HANDLE; -new Handle:stb_logactivity = INVALID_HANDLE; -new Handle:stb_logactivity2 = INVALID_HANDLE; -new Handle:stb_unbalancelimit = INVALID_HANDLE; -new Handle:stb_deadonly = INVALID_HANDLE; -new Handle:stb_priorityenabled = INVALID_HANDLE; -new Handle:stb_uberlevel = INVALID_HANDLE; -new Handle:stb_balancedelay = INVALID_HANDLE; -new Handle:stb_livingplayerswitchdelay = INVALID_HANDLE; -new Handle:stb_livingplayercheckdelay = INVALID_HANDLE; -new Handle:stb_roundstartdelay = INVALID_HANDLE; -new Handle:stb_switchbackforced = INVALID_HANDLE; -new Handle:stb_adminflag = INVALID_HANDLE; -new Handle:stb_buddyrestriction = INVALID_HANDLE; -new Handle:stb_convarcontrol = INVALID_HANDLE; - -/** - Built-in cvars handles - */ -new Handle:stb_mp_autoteambalance = INVALID_HANDLE; -new Handle:stb_mp_teams_unbalance_limit = INVALID_HANDLE; -new Handle:TFGameModeArena = INVALID_HANDLE; - -/** - Timer handles - */ -new Handle:g_hBalanceTimer = INVALID_HANDLE; -new Handle:g_hLivingPlayerCheckTimer = INVALID_HANDLE; - -/** - Player arrays - */ -new g_aPlayers[MAXPLAYERS + 1][PlayerData]; - -/** -Global bools -*/ -new bool:g_bIsEnabled = true; -new bool:g_bPriorityPlayers = true; -new bool:g_bBuddyRestriction = false; -new bool:g_bLogActivity = false; -new bool:g_bLogActivity2 = false; -new bool:g_bDeadOnly = false; -new bool:g_bConVarControl = true; -new bool:g_bBuddyEnabled = true; -new bool:g_bBalanceInProgress = false; -new bool:g_bRoundStart = false; -new bool:g_bRoundEnd = false; -new bool:g_bSuddenDeath = false; -new bool:g_bIsArenaMode = false; - -/** - Global strings/integers/floats - */ -new g_iUnbalanceLimit, g_iLivingPlayerSwitchDelay, g_iLivingPlayerCheckDelay; -new g_iRoundStartDelay, g_iSwitchBackForced, g_iBalanceDelay; -new Float:g_fUberLevel; -new g_iOwnerOffset; -new String:g_sAdminFlag[5]; - -public Plugin:myinfo = -{ - name = "Simple Team Balancer", - author = "Simple Plugins", - description = "Balances teams based upon player count.", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -} - -public OnPluginStart() -{ - - /** - Create console variables - */ - CreateConVar("stb_version", PLUGIN_VERSION, "Simple Team Balancer", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - stb_enabled = CreateConVar("stb_enabled", "1", "Enable or Disable Simple Team Balancer", _, true, 0.0, true, 1.0); - stb_priorityenabled = CreateConVar("stb_priorityenabled", "1", "Enable or Disable the prioritization of living players", _, true, 0.0, true, 1.0); - stb_buddyrestriction = CreateConVar("stb_buddyrestriction", "0", "Enable or Disable Admin Only buddy lists", _, true, 0.0, true, 1.0); - stb_logactivity = CreateConVar("stb_logactivity", "0", "Enable or Disable the disaplying of events in the log", _, true, 0.0, true, 1.0); - stb_logactivity2 = CreateConVar("stb_logactivity2", "0", "Enable or Disable the disaplying of detailed events in the log (WILL SPAM LOG)", _, true, 0.0, true, 1.0); - stb_deadonly = CreateConVar("stb_deadonly", "0", "Enable or Disable the switching of only dead players", _, true, 0.0, true, 1.0); - stb_convarcontrol = CreateConVar("stb_convarcontrol", "1", "Enable or Disable the control of builtin console variables", _, true, 0.0, true, 1.0); - stb_buddyenabled = CreateConVar("stb_buddyenabled", "1", "Enable or Disable the buddy system", _, true, 0.0, true, 1.0); - stb_unbalancelimit = CreateConVar("stb_unbalancelimit", "2", "Amount of players teams are ALLOWED to be unbalanced by", _, true, 1.0, true, 32.0); - stb_balancedelay = CreateConVar("stb_balancedelay", "10", "Delay in seconds to start an autobalance"); - stb_livingplayerswitchdelay = CreateConVar("stb_livingplayerswitchdelay", "20", "Delay in seconds to switch living players once selected"); - stb_livingplayercheckdelay = CreateConVar("stb_livingplayercheckdelay", "10", "Delay in seconds to start checking living players once teams become unbalanced"); - stb_roundstartdelay = CreateConVar("stb_roundstartdelay", "15", "Delay in seconds to start balancing teams after the start of a round"); - stb_switchbackforced = CreateConVar("stb_switchbackforced", "300", "Amount of time in seconds to not switch a player twice and force the team if enabled"); - stb_uberlevel = CreateConVar("stb_uberlevel", "1.0", "Min uber level medic must have to have priority over other living players. Setting to 0 will rarely switch a living medic", _, true, 0.0, true, 1.0); - stb_adminflag = CreateConVar("stb_adminflag", "a", "Admin flag to use for immunity. Must be a in char format."); - stb_mp_autoteambalance = FindConVar("mp_autoteambalance"); - stb_mp_teams_unbalance_limit = FindConVar("mp_teams_unbalance_limit"); - - /** - Removing the notify tags from the built in cvars. We dont want spam. - */ - if (stb_mp_autoteambalance != INVALID_HANDLE) - { - SetConVarFlags(stb_mp_autoteambalance, GetConVarFlags(stb_mp_autoteambalance)^FCVAR_NOTIFY); - } - if (stb_mp_teams_unbalance_limit != INVALID_HANDLE) - { - SetConVarFlags(stb_mp_teams_unbalance_limit, GetConVarFlags(stb_mp_teams_unbalance_limit)^FCVAR_NOTIFY); - } - - /** - Hook console variables - */ - HookConVarChange(stb_enabled, ConVarSettingsChanged); - HookConVarChange(stb_priorityenabled, ConVarSettingsChanged); - HookConVarChange(stb_buddyrestriction, ConVarSettingsChanged); - HookConVarChange(stb_logactivity, ConVarSettingsChanged); - HookConVarChange(stb_logactivity2, ConVarSettingsChanged); - HookConVarChange(stb_deadonly, ConVarSettingsChanged); - HookConVarChange(stb_convarcontrol, ConVarSettingsChanged); - HookConVarChange(stb_buddyenabled, ConVarSettingsChanged); - HookConVarChange(stb_unbalancelimit, ConVarSettingsChanged); - HookConVarChange(stb_balancedelay, ConVarSettingsChanged); - HookConVarChange(stb_livingplayerswitchdelay, ConVarSettingsChanged); - HookConVarChange(stb_livingplayercheckdelay, ConVarSettingsChanged); - HookConVarChange(stb_roundstartdelay, ConVarSettingsChanged); - HookConVarChange(stb_switchbackforced, ConVarSettingsChanged); - HookConVarChange(stb_uberlevel, ConVarSettingsChanged); - HookConVarChange(stb_mp_autoteambalance, ConVarSettingsChanged); - HookConVarChange(stb_mp_teams_unbalance_limit, ConVarSettingsChanged); - - /** - Create console commands - */ - RegConsoleCmd("sm_buddy", Command_AddBalanceBuddy, "Add a balance buddy"); - RegConsoleCmd("sm_lockbuddy", Command_LockBuddy, "Locks your balance buddy selection"); - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook the game events - */ - LogAction(0, -1, "[STB] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_death", HookPlayerDeath, EventHookMode_Post); - HookEvent("player_team", HookPlayerChangeTeam, EventHookMode_Post); - switch (g_CurrentMod) - { - case GameType_TF: - { - HookEvent("teamplay_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - HookEvent("teamplay_suddendeath_begin", HookSuddenDeathBegin, EventHookMode_PostNoCopy); - HookEvent("teamplay_flag_event", HookFlagEvent, EventHookMode_Post); - TFGameModeArena = FindConVar("tf_gamemode_arena"); - g_iOwnerOffset = FindSendPropInfo("CBaseObject", "m_hBuilder"); - } - case GameType_DOD: - { - HookEvent("dod_round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_Post); - } - default: - { - HookEvent("round_start", HookRoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - } - } - - /** - Load translations and .cfg file - */ - LoadTranslations ("simpleteambalancer.phrases"); - AutoExecConfig(true, "plugin.simpleteambalancer"); - LogAction(0, -1, "[STB] Simple Team Balancer is loaded."); -} - -public OnAllPluginsLoaded() -{ - //something -} - -public OnLibraryRemoved(const String:name[]) -{ - //something -} - -public OnConfigsExecuted() -{ - - /** - Load up global variables - */ - g_bIsEnabled = GetConVarBool(stb_enabled); - g_bBuddyEnabled = GetConVarBool(stb_buddyenabled); - g_bLogActivity = GetConVarBool(stb_logactivity); - g_bLogActivity2 = GetConVarBool(stb_logactivity2); - g_bDeadOnly = GetConVarBool(stb_deadonly); - g_bPriorityPlayers = GetConVarBool(stb_priorityenabled); - g_bBuddyRestriction = GetConVarBool(stb_buddyrestriction); - g_bConVarControl = GetConVarBool(stb_convarcontrol); - g_fUberLevel = GetConVarFloat(stb_uberlevel); - g_iUnbalanceLimit = GetConVarInt(stb_unbalancelimit); - g_iBalanceDelay = GetConVarInt(stb_balancedelay); - g_iLivingPlayerSwitchDelay = GetConVarInt(stb_livingplayerswitchdelay); - g_iLivingPlayerCheckDelay = GetConVarInt(stb_livingplayercheckdelay); - g_iRoundStartDelay = GetConVarInt(stb_roundstartdelay); - g_iSwitchBackForced = GetConVarInt(stb_switchbackforced); - GetConVarString(stb_adminflag, g_sAdminFlag, sizeof(g_sAdminFlag)); - - /** - Report enabled - */ - if (g_bIsEnabled) - { - LogAction(0, -1, "[STB] Simple Team Balancer is ENABLED."); - } - else - { - LogAction(0, -1, "[STB] Simple Team Balancer is DISABLED."); - } - - - /** - Report log activity - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Log Activity ENABLED."); - } - else - { - LogAction(0, -1, "[STB] Log Activity DISABLED."); - } - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Detailed Log Activity ENABLED."); - } - else - { - LogAction(0, -1, "[STB] Detailed Log Activity DISABLED."); - } -} - -public OnMapStart() -{ - - /** - Check for arena mode - */ - if (g_CurrentMod == GameType_TF && GetConVarBool(TFGameModeArena)) - { - g_bIsArenaMode = true; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Simple Team Balancer detected arena mode and will be bypassed"); - } - } - else - { - g_bIsArenaMode = false; - } - - /** - Reset the globals - */ - g_bBalanceInProgress = false; - g_bRoundStart = false; - g_bRoundEnd = false; - g_bSuddenDeath = false; - - /** - Set the built-in convars - */ - SetGameCvars(); -} - -public OnClientPostAdminCheck(client) -{ - - /** - Make sure its a valid connected client and buddy system is enabled - */ - if (client == 0 || !g_bIsEnabled || !IsClientConnected(client) || !g_bBuddyEnabled) - { - return; - } - - /** - Make sure if its set for admins only they have the flags - */ - if (g_bBuddyRestriction && !SM_IsValidAdmin(client, g_sAdminFlag)) - { - return; - } - - /** - Start the advertisement timer - */ - CreateTimer (60.0, Timer_WelcomeAdvert, client); -} - -public OnClientDisconnect(client) -{ - - /** - Call stock function to cleaup - */ - CleanUp(client); -} - -public OnClientDisconnect_Post(client) -{ - - /** - Determine if we need a balance - */ - if (OkToBalance() && IsUnbalanced() && !g_bBalanceInProgress) - { - - /** - No balance in progress but balance is needed - */ - StartABalance(); - } -} - -public SM_OnPlayerMoved(Handle:plugin, client, team) -{ - - /** - Make sure we called the move function - */ - if (plugin != GetMyHandle()) - { - if (g_bLogActivity2) - { - LogAction(0, client, "[STB] Callback was not started with current plugin, bugging out."); - } - return; - } - - /** - Get the players name and report the event - */ - decl String:sPlayerName[64]; - GetClientName(client, sPlayerName, sizeof(sPlayerName)); - if (g_bLogActivity) - { - LogAction(0, client, "[STB] Changed %s to team %i.", sPlayerName, team); - } - - /** - If we are in TF2 fire the bult-in team balance event - */ - if(g_CurrentMod == GameType_TF) - { - new Handle:event = CreateEvent("teamplay_teambalanced_player"); - SetEventInt(event, "player", client); - SetEventInt(event, "team", team); - FireEvent(event); - } - - /** - Notify the players - */ - PrintToChatAll("[SM] %T", "BalanceMessage", LANG_SERVER, sPlayerName); - - /** - Set the players variables and start a timer - */ - g_aPlayers[client][bSwitched] = true; - g_aPlayers[client][hForcedTimer] = CreateTimer(float(g_iSwitchBackForced), Timer_ForcedExpired, client, TIMER_FLAG_NO_MAPCHANGE); - - /** - We are done, log the completion and end the balance - */ - if (g_bLogActivity) - { - LogAction(0, client, "[STB] Balance finished."); - } - g_bBalanceInProgress = false; -} - -/* HOOKED EVENTS */ - -public HookPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get our event variables - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - decl String:sWeapon[64]; - GetEventString(event, "weapon", sWeapon, sizeof(sWeapon)); - - /** - Return if death was not caused by a player - This is the case when the player switches teams - */ - if (StrEqual(sWeapon, "world", false)) - { - return; - } - - - /** - Check if balance is needed - */ - if (IsClientInGame(iClient) && OkToBalance() && IsUnbalanced()) - { - new iSmallerTeam = GetSmallerTeam(); - - /** - Check if balance is in progress - */ - if (g_bBalanceInProgress) - { - - /** - There is a balance in progress - Check the player who died to see if he is supposed to be switched - */ - if (g_aPlayers[iClient][hBalanceTimer] != INVALID_HANDLE) - { - - /** - The player has a timer on him to switch him to other team - Stop the timer - */ - CloseHandle(g_aPlayers[iClient][hBalanceTimer]); - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - if (g_bLogActivity) - { - LogAction(0, iClient, "[STB] With a balance in progress the queued living player died and was switched."); - } - - /** - Call the stock change team function - */ - BalancePlayer(iClient, SM_GetForcedTeam(iClient)); - return; - } - - /** - Before we continue, lets make sure the client is switchable - */ - if (IsSwitchablePlayer(iClient, GetBiggerTeam())) - { - - /** - Now we check the buddy system - */ - if (g_bBuddyEnabled) - { - - /** - Buddy system is enabled, check to see if client has buddy - */ - new iBuddyIndex = SM_GetClientBuddy(iClient); - if (iBuddyIndex != 0 || !IsClientConnected(iBuddyIndex) || !IsClientInGame(iBuddyIndex)) - { - - /** - The client has a buddy, so we check to see if they are on same team - */ - if (GetClientTeam(iClient) == GetClientTeam(iBuddyIndex)) - { - - /** - They are, but we don't bug out, we still need to start a balance - */ - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] With a balance in progress a buddy on the right team was found and skipped."); - } - } - else - { - - /** - They are not on the same team - The buddy could be in spec, and that would make it not matter where he is, or the buddy is on the smaller team - */ - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] With a balance in progress a buddy on the wrong team was switched."); - } - BalancePlayer(iClient, iSmallerTeam); - return; - } - } - else - { - - /** - Client doesn't have a buddy, balance this player - */ - BalancePlayer(iClient, iSmallerTeam); - return; - } - } - else - { - - /** - Buddy system is not enabled, balance this player - */ - BalancePlayer(iClient, iSmallerTeam); - return; - } - } - } - else - { - - /** - If we get to here then we must need to start a balance - */ - StartABalance(); - } - } -} - -public HookPlayerChangeTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get our event variables. - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - new iTeam = GetEventInt(event, "team"); - - /** - Make sure its ok to balance. - */ - if (OkToBalance()) - { - - /** - See if the client that changed teams was set to with a balance. - */ - if (g_aPlayers[iClient][hBalanceTimer] != INVALID_HANDLE - && SM_GetForcedTeam(iClient) == iTeam - && g_bBalanceInProgress) - { - - /** - The client was set to be balanced, so we close the timer. - */ - CloseHandle(g_aPlayers[iClient][hBalanceTimer]); - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - - /** - Stop the balance. - */ - g_bBalanceInProgress = false; - return; - } - - /** - It's not likely that this team change can cause us to need a balance. - If it does, start one with a small dealy to deal with forced switch backs. - */ - if (IsUnbalanced() && !g_bBalanceInProgress) - { - CreateTimer(2.0, Timer_ChangeTeamBalanceDelay, _, TIMER_FLAG_NO_MAPCHANGE); - } - } -} - -public HookRoundStart(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Set the variables we need to start a round - */ - g_bRoundStart = true; - g_bRoundEnd = false; - g_bSuddenDeath = false; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Round Started"); - } - - /** - Start a delayed balance check at the start of the round - */ - CreateTimer(float(g_iRoundStartDelay), Timer_RoundStart); -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Set the variables we need at round end - */ - g_bRoundEnd = true; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Round Ended"); - } -} - -public HookSuddenDeathBegin(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Set the variables we need for sudden death - */ - g_bSuddenDeath = true; -} - -public HookFlagEvent(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get our event variables - */ - new iClient = GetEventInt(event, "player"); - new iFlagStatus = GetEventInt(event, "eventtype"); - - /** - Make sure we have a valid client - */ - if (!IsClientInGame(iClient)) - { - return; - } - - /** - Determine what kind of event this is - */ - switch (iFlagStatus) - { - case 1: - { - - /** - The flag was picked up - */ - g_aPlayers[iClient][bFlagCarrier] = true; - } - case 2: - { - - /** - The flag was capped - */ - g_aPlayers[iClient][bFlagCarrier] = false; - } - case 3: - { - - /** - The flag was defended, we don't have to do anything - */ - } - case 4: - { - - /** - The flag was dropped - */ - g_aPlayers[iClient][bFlagCarrier] = false; - } - } -} - -/* COMMAND EVENTS */ - -public Action:Command_AddBalanceBuddy(client, args) -{ - if (client == 0) - { - ReplyToCommand(client, "[SM] %T", "PlayerLevelCmd", LANG_SERVER); - return Plugin_Handled; - } - if (!g_bIsEnabled || !g_bBuddyEnabled) - { - ReplyToCommand(client, "[SM] %T", "CmdDisabled", LANG_SERVER); - return Plugin_Handled; - } - if (g_bBuddyRestriction) - { - if (!SM_IsValidAdmin(client, g_sAdminFlag)) - { - ReplyToCommand(client, "[SM] %T", "RestrictedBuddy", LANG_SERVER); - return Plugin_Handled; - } - } - decl String:sPlayerUserId[24]; - GetCmdArg(1, sPlayerUserId, sizeof(sPlayerUserId)); - new iPlayer = GetClientOfUserId(StringToInt(sPlayerUserId)); - if (!iPlayer || !IsClientInGame(iPlayer) || client == iPlayer) - { - if (client == iPlayer) - { - PrintHintText(client, "%T", "SelectSelf", LANG_SERVER); - } - ReplyToCommand(client, "[SM] Usage: buddy "); - new Handle:playermenu = BuildPlayerMenu(); - DisplayMenu(playermenu, client, MENU_TIME_FOREVER); - } - else - { - decl String:cName[128]; - decl String:bName[128]; - GetClientName(client, cName, sizeof(cName)); - GetClientName(iPlayer, bName, sizeof(bName)); - if (SM_IsBuddyLocked(iPlayer)) - { - ReplyToCommand(client, "[SM] %T", "PlayerLockedBuddyMsg", LANG_SERVER, bName); - return Plugin_Handled; - } - SM_AssignBuddy(client, iPlayer); - PrintHintText(client, "%T", "BuddyMsg", LANG_SERVER, bName); - PrintHintText(iPlayer, "%T", "BuddyMsg", LANG_SERVER, cName); - } - return Plugin_Handled; -} - -public Action:Command_LockBuddy(client, args) -{ - if (client == 0) - { - ReplyToCommand(client, "[SM] %T", "PlayerLevelCmd", LANG_SERVER); - return Plugin_Handled; - } - if (!g_bIsEnabled) - { - ReplyToCommand(client, "[SM] %T", "CmdDisabled", LANG_SERVER); - return Plugin_Handled; - } - if (g_bBuddyRestriction) - { - if (!SM_IsValidAdmin(client, g_sAdminFlag)) - { - ReplyToCommand(client, "[SM] %T", "RestrictedBuddy", LANG_SERVER); - return Plugin_Handled; - } - } - if (SM_IsBuddyLocked(client)) - { - SM_LockBuddy(client, false); - PrintHintText(client, "%T", "BuddyLockMsgDisabled", LANG_SERVER); - } - else - { - SM_LockBuddy(client, true); - PrintHintText(client, "%T", "BuddyLockMsgEnabled", LANG_SERVER); - } - return Plugin_Handled; -} - -/** -Stock functions . - */ - -stock bool:IsUnbalanced() -{ - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Checking if teams are unbalanced"); - } - new Team1Count = GetTeamClientCount(g_aCurrentTeams[Team1]); - new Team2Count = GetTeamClientCount(g_aCurrentTeams[Team2]); - new ubCount = RoundFloat(FloatAbs(float(Team1Count - Team2Count))); - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Team1:%i Team2:%i Difference:%i", Team1Count, Team2Count, ubCount); - } - if (ubCount > g_iUnbalanceLimit) - { - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Teams are unbalanced"); - } - return true; - } - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Teams are not unbalanced"); - } - return false; -} - -stock bool:OkToBalance() -{ - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Checking if OK to balance."); - } - new bool:bResult = false; - if (g_bIsEnabled && !g_bRoundStart && !g_bRoundEnd && !g_bIsArenaMode && !g_bSuddenDeath) - { - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Passed IF statement"); - LogAction(0, -1, "[STB] Now checking admins"); - } - for (new i = 1; i <= MaxClients; i++) - { - if (IsClientInGame(i) && !SM_IsValidAdmin(i, g_sAdminFlag)) - { - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] Found at least 1 non-admin"); - LogAction(0, -1, "[STB] OK to balance"); - } - bResult = true; - break; - } - } - if (!bResult && g_bLogActivity2) - { - LogAction(0, -1, "[STB] All admins online"); - } - } - if (!bResult && g_bLogActivity2) - { - LogAction(0, -1, "[STB] Not OK to balance"); - } - return bResult; -} - -stock bool:IsSwitchablePlayer(iClient, iBiggerTeam) -{ - - /** - Run the client thru some standard checks - */ - if (!IsClientInGame(iClient) - || SM_IsValidAdmin(iClient, g_sAdminFlag) - || g_aPlayers[iClient][bFlagCarrier] - || GetClientTeam(iClient) != iBiggerTeam - || g_aPlayers[iClient][bSwitched]) - { - - /** - The supplied client can't be switched - */ - return false; - } - - /** - The supplied client can be switched - */ - return true; -} - -stock bool:HasUber(iClient) -{ - - /** - First things first, make sure the client is a medic - */ - if(TF2_GetPlayerClass(iClient) == TFClass_Medic) - { - - /** - We can only check the active weapon, so make sure the client is holding the uber gun - */ - decl String:sWeaponName[32]; - GetClientWeapon(iClient, sWeaponName, sizeof(sWeaponName)); - if(StrEqual(sWeaponName, "tf_weapon_medigun")) - { - - /** - They are, so lets check the uber level of the gun - */ - new iEntityIndex = GetEntDataEnt2(iClient, FindSendPropInfo("CTFPlayer", "m_hActiveWeapon")); - new Float:fChargeLevel = GetEntDataFloat(iEntityIndex, FindSendPropInfo("CWeaponMedigun", "m_flChargeLevel")); - if (fChargeLevel >= g_fUberLevel) - { - - /** - The client supplied has an uber above the supplied level, return true - */ - if (g_bLogActivity2) - { - LogAction(0, iClient, "[STB] Found a medic with a uber and skipped him."); - } - return true; - } - } - } - - /** - The client supplied does not have an uber above the supplied level, return false - */ - return false; -} - -stock bool:HasBuildingsBuilt(iClient) -{ - - /** - We have to start a loop to check the owner of all the valid entities - */ - new iMaxEntities = GetMaxEntities(); - for (new i = MaxClients + 1; i <= iMaxEntities; i++) - { - if (!IsValidEntity(i)) - { - - /** - Not valid, continue to next one - */ - continue; - } - - /** - Get the name of the current entity - */ - decl String:sNetClass[32]; - GetEntityNetClass(i, sNetClass, sizeof(sNetClass)); - - /** - See if its something that an engineer would build - */ - if (strcmp(sNetClass, "CObjectSentrygun") == 0 - || strcmp(sNetClass, "CObjectTeleporter") == 0 - || strcmp(sNetClass, "CObjectDispenser") == 0) - { - - /** - It is, so lets check the owner - */ - if (GetEntDataEnt2(i, g_iOwnerOffset) == iClient) - { - - /** - The client supplied is the owner, return true - */ - if (g_bLogActivity2) - { - LogAction(0, iClient, "[STB] Found an engineer with buildings and skipped him."); - } - return true; - } - } - } - - /** - The client supplied didn't have any buildings, return false - */ - return false; -} - -stock StartABalance() -{ - - /** - See if we are already started a balance - */ - if (g_hBalanceTimer != INVALID_HANDLE) - { - - /** - We have, check if we still need to - */ - if (!IsUnbalanced() || !OkToBalance()) - { - - /** - We don't, stop the balance - It's almost impossible to reach this code, but we do it just in case - */ - CloseHandle(g_hBalanceTimer); - g_hBalanceTimer = INVALID_HANDLE; - g_bBalanceInProgress = false; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Balance delay timer was not needed and was killed before the callback."); - } - return; - } - else - { - - /** - We still need to balance - Bug out and wait for the current one to finish - */ - return; - } - } - - /** - Report that teams are unbalanced - */ - PrintToChatAll("[SM] %T", "UnBalanced", LANG_SERVER); - - /** - Check to see if we are supposed to delay the balance - */ - if (g_iBalanceDelay == 0) - { - - /** - Start the balance now - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Balance is now in progress."); - } - g_bBalanceInProgress = true; - g_hBalanceTimer = INVALID_HANDLE; - - /** - Check if we are allowed to scan living players - */ - if (!g_bDeadOnly) - { - - /** - We are allowed to, so we start a timer - */ - StartALivingPlayerTimer(); - - /** - Also report that we are now scanning dead players as well - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Now scanning dead players."); - } - } - else - { - - /** - We are not allowed to, so report that we are only scanning dead players - */ - if (g_bLogActivity) - LogAction(0, -1, "[STB] Only scanning dead players."); - } - - /** - We started the balance, bug out - */ - return; - } - - /** - We are supposed to delay the balance, start a balance timer - */ - g_hBalanceTimer = CreateTimer(float(g_iBalanceDelay), Timer_BalanceTeams, _, TIMER_FLAG_NO_MAPCHANGE); - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Teams are unbalanced. Balance delay timer started."); - } -} - -stock StartALivingPlayerTimer() -{ - - /** - Start a timer to check living players - */ - if (g_hLivingPlayerCheckTimer != INVALID_HANDLE) - { - - /** - If we for some reason already have one started, stop it. - */ - CloseHandle(g_hLivingPlayerCheckTimer); - g_hLivingPlayerCheckTimer = INVALID_HANDLE; - } - - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Living player balance delay timer started."); - } - g_hLivingPlayerCheckTimer = CreateTimer(float(g_iLivingPlayerCheckDelay), Timer_LivingPlayerCheck, _, TIMER_FLAG_NO_MAPCHANGE); -} - -stock FindSwitchablePlayer() -{ - - /** - Start a loop to find a switchable player - */ - new iPlayer; - new iBiggerTeam = GetBiggerTeam(); - for (new i = 1; i <= MaxClients; i++) - { - - /** - Check the stock function to see if we are allows to even switch the player - */ - if (!IsSwitchablePlayer(i, iBiggerTeam)) - { - continue; - } - - /** - If the mod is TF2 and they have Priority Players set check if the client has buildings or an uber - */ - if (g_CurrentMod == GameType_TF && g_bPriorityPlayers) - { - if (HasUber(i) || HasBuildingsBuilt(i)) - { - continue; - } - } - - /** - So far we are able we switch this player - Now we check the buddy system - */ - if (g_bBuddyEnabled) - { - - /** - Buddy system is enabled, check to see if client has buddy - */ - if (SM_GetClientBuddy(i) != 0) - { - - /** - The client has a buddy, so we check to see if they are on same team - */ - if (GetClientTeam(i) == GetClientTeam(SM_GetClientBuddy(i))) - { - - /** - They are, so we continue to next client - */ - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] With a balance in progress a buddy on the right team was found and skipped."); - } - continue; - } - else - { - - /** - They are not on the same team, set this client - The buddy could be in spec, and that would make it not matter where he is, or the buddy is on the smaller team - */ - iPlayer = i; - if (g_bLogActivity2) - { - LogAction(0, -1, "[STB] With a balance in progress a buddy on the wrong team was found."); - } - break; - } - } - else - { - - /** - The client does not have a buddy, set this client - */ - iPlayer = i; - break; - } - } - else - { - - /** - Buddy system is not enabled, set this client - */ - iPlayer = i; - break; - } - } - - /** - Return the client we set, this could be 0, but very unlikely - */ - return iPlayer; -} - -stock BalancePlayer(iClient, iTeam) -{ - new Handle:hPack = CreateDataPack(); - WritePackCell(hPack, iClient); - WritePackCell(hPack, iTeam); - CreateTimer(0.1, Timer_BalancePlayer, hPack, TIMER_FLAG_NO_MAPCHANGE); -} - -stock CleanUp(iClient) -{ - g_aPlayers[iClient][bFlagCarrier] = false; - g_aPlayers[iClient][bSwitched] = false; - if (g_aPlayers[iClient][hForcedTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[iClient][hForcedTimer]); - g_aPlayers[iClient][hForcedTimer] = INVALID_HANDLE; - if (g_bLogActivity) - { - LogAction(0, iClient, "[STB] Forced player disconnected, killing timer."); - } - } - if (g_aPlayers[iClient][hBalanceTimer] != INVALID_HANDLE) - { - CloseHandle(g_aPlayers[iClient][hBalanceTimer]); - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - if (g_bLogActivity) - { - LogAction(0, iClient, "[STB] Living player set to be balanced disconnected, killing timer."); - } - } -} - -stock GetSmallerTeam() -{ - - /** - Get the count of players on each team - */ - new iCountT1 = GetTeamClientCount(g_aCurrentTeams[Team1]); - new iCountT2 = GetTeamClientCount(g_aCurrentTeams[Team2]); - - /** - Return the smaller team - */ - if (iCountT1 < iCountT2) - { - return g_aCurrentTeams[Team1]; - } - else if (iCountT1 > iCountT2) - { - return g_aCurrentTeams[Team2]; - } - return 0; -} - -stock GetBiggerTeam() -{ - - /** - Get the count of players on each team - */ - new iCountT1 = GetTeamClientCount(g_aCurrentTeams[Team1]); - new iCountT2 = GetTeamClientCount(g_aCurrentTeams[Team2]); - - /** - Return the bigger team - */ - if (iCountT1 > iCountT2) - { - return g_aCurrentTeams[Team1]; - } - else if (iCountT1 < iCountT2) - { - return g_aCurrentTeams[Team2]; - } - return 0; -} - -stock SetGameCvars() -{ - if (g_bConVarControl && g_bIsEnabled) - { - if (stb_mp_autoteambalance != INVALID_HANDLE) - { - SetConVarInt(stb_mp_autoteambalance, 0); - } - if (stb_mp_teams_unbalance_limit != INVALID_HANDLE) - { - SetConVarInt(stb_mp_teams_unbalance_limit, g_iUnbalanceLimit); - } - } -} - -/* TIMER FUNCTIONS */ - -public Action:Timer_ChangeTeamBalanceDelay(Handle:timer, any:data) -{ - - /** - Finally start one if it's still unbalanced - */ - if (IsUnbalanced() && !g_bBalanceInProgress) - { - StartABalance(); - } -} - -public Action:Timer_BalanceTeams(Handle:timer, any:data) -{ - - /** - See if we still need to balance the teams - */ - if (!IsUnbalanced() || !OkToBalance()) - { - - /** - We don't, kill the balance - */ - g_bBalanceInProgress = false; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Balance delay timer was not needed and died."); - } - g_hBalanceTimer = INVALID_HANDLE; - return Plugin_Handled; - } - - /** - We still need to balance the teams - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Teams are still unbalanced. Balance is now in progress."); - } - g_bBalanceInProgress = true; - - - /** - Check if we are allowed to scan living players - */ - if (!g_bDeadOnly) - { - - /** - We are allowed to, so we start a timer - */ - StartALivingPlayerTimer(); - - /** - Also report that we are now scanning dead players as well - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Now scanning dead players."); - } - } - else - { - - /** - We are not allowed to, so report that we are only scanning dead players - */ - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Only scanning dead players."); - } - } - - g_hBalanceTimer = INVALID_HANDLE; - return Plugin_Handled; -} - -public Action:Timer_LivingPlayerCheck(Handle:timer, any:data) -{ - - /** - Check to see if we still need to balance the teams - */ - if (!IsUnbalanced() || !OkToBalance()) - { - - /** - We don't, kill it and bug out - */ - g_bBalanceInProgress = false; - if (g_bLogActivity) - { - LogAction(0, -1, "[STB] Living player balance delay timer was not needed and died."); - } - g_hLivingPlayerCheckTimer = INVALID_HANDLE; - return Plugin_Handled; - } - - /** - Call the stock function to find a player we can switch - */ - new iPlayer = FindSwitchablePlayer(); - - /** - Check to see if we found a player - */ - if (iPlayer == 0) - { - - /** - In the unlikely event that the stock function didn't return a player - Start a loop to find a random player - */ - new iBiggerTeam = GetBiggerTeam(); - do - { - iPlayer = GetRandomInt(1, MaxClients); - } while (!IsSwitchablePlayer(iPlayer, iBiggerTeam)); - - if (g_bLogActivity) - { - LogAction(0, iPlayer, "[STB] Found a random living player."); - } - } - else - { - if (g_bLogActivity) - { - LogAction(0, iPlayer, "[STB] Found a living player."); - } - } - - /** - Now that we have a player assigned them to the smaller team - */ - new iSmallerTeam = GetSmallerTeam(); - SM_SetForcedTeam(iPlayer, iSmallerTeam, true); - - /** - Let the player know we could be switching him soon - */ - PrintHintText(iPlayer, "%T", "PlayerMessage", LANG_SERVER, g_iLivingPlayerSwitchDelay); - if (g_bLogActivity) - { - LogAction(0, iPlayer, "[STB] Living player placed on a timer."); - } - - /** - Create a timer to switch the player - */ - g_aPlayers[iPlayer][hBalanceTimer] = CreateTimer(float(g_iLivingPlayerSwitchDelay), Timer_LivingPlayerBalance, iPlayer, TIMER_FLAG_NO_MAPCHANGE); - - /** - Reset the timer handle - */ - g_hLivingPlayerCheckTimer = INVALID_HANDLE; - - /** - We are done, bug out - */ - return Plugin_Handled; -} - -public Action:Timer_LivingPlayerBalance(Handle:timer, any:iClient) -{ - - /** - Check to make sure we still need to balance - */ - if (!IsUnbalanced() || !OkToBalance()) - { - - /** - We don't need to balance, bug out - */ - g_bBalanceInProgress = false; - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - SM_ClearForcedTeam(iClient); - return Plugin_Handled; - } - - /** - We still need to balance, lets make sure we can still balance this player - */ - if (!IsClientConnected(iClient) || g_aPlayers[iClient][bFlagCarrier]) - { - g_bBalanceInProgress = false; - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - SM_ClearForcedTeam(iClient); - if (g_bLogActivity) - { - if (g_aPlayers[iClient][bFlagCarrier]) - { - LogAction(0, iClient, "[STB] Living player became flag carrier, balance restarted."); - } - else - { - LogAction(0, iClient, "[STB] Living player timer was not needed and died."); - } - } - return Plugin_Handled; - } - - /** - Clear to balance this player, so do it - */ - BalancePlayer(iClient, SM_GetForcedTeam(iClient)); - if (g_bLogActivity) - { - LogAction(0, iClient, "[STB] Living player was switched."); - } - - /** - We are done, bug out - */ - g_aPlayers[iClient][hBalanceTimer] = INVALID_HANDLE; - return Plugin_Handled; -} - -public Action:Timer_BalancePlayer(Handle:timer, Handle:pack) -{ - - /** - Rest the datapack and load the variables - */ - ResetPack(pack); - new iClient = ReadPackCell(pack); - new iUnBalancedTeam = ReadPackCell(pack); - - /** - We are done with you now - */ - CloseHandle(pack); - - /** - Check the team and make sure its a valid team - */ - if(!SM_IsValidTeam(iUnBalancedTeam)) - { - if (g_bLogActivity) - { - LogAction(0, iClient, "[STB] Balance failed due to invalid team number %i", iUnBalancedTeam); - } - return Plugin_Handled; - } - - /** - Use our core function to change the clients team - */ - SM_MovePlayer(iClient, iUnBalancedTeam); - - return Plugin_Handled; -} - -public Action:Timer_RoundStart(Handle:timer, any:data) -{ - g_bRoundStart = false; - if (OkToBalance() && IsUnbalanced() && !g_bBalanceInProgress) - { - StartABalance(); - } - return Plugin_Handled; -} - -public Action:Timer_ForcedExpired(Handle:timer, any:iClient) -{ - SM_ClearForcedTeam(iClient); - g_aPlayers[iClient][bSwitched] = false; - g_aPlayers[iClient][hForcedTimer] = INVALID_HANDLE; - return Plugin_Handled; -} - -public Action:Timer_WelcomeAdvert(Handle:timer, any:iClient) -{ - if (IsClientConnected(iClient) && IsClientInGame(iClient)) - { - PrintToChat (iClient, "\x01\x04[STB]\x01 %T", "BuddyWelcomeMsg1", LANG_SERVER); - PrintToChat (iClient, "\x01\x04[STB]\x01 %T", "BuddyWelcomeMsg2", LANG_SERVER); - PrintToChat (iClient, "\x01\x04[STB]\x01 %T", "BuddyWelcomeMsg3", LANG_SERVER); - } - return Plugin_Handled; -} - -/* CONSOLE VARIABLE CHANGE EVENT */ - -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (convar == stb_enabled) - { - if (StringToInt(newValue) == 0) - { - g_bIsEnabled = false; - PrintToChatAll("[SM] %T", "Disabled", LANG_SERVER); - LogAction(0, -1, "[SimpleTeamBalancer] Disabled"); - } - else - { - g_bIsEnabled = true; - SetGameCvars(); - PrintToChatAll("[SM] %T", "Enabled", LANG_SERVER); - LogAction(0, -1, "[SimpleTeamBalancer] Enabled"); - } - } - else if (convar == stb_logactivity) - { - if (StringToInt(newValue) == 0) - { - g_bLogActivity = false; - LogAction(0, -1, "[STB] Log Activity DISABLED."); - } - else - { - g_bLogActivity = true; - LogAction(0, -1, "[STB] Log Activity ENABLED."); - } - } - else if (convar == stb_logactivity2) - { - if (StringToInt(newValue) == 0) - { - g_bLogActivity2 = false; - LogAction(0, -1, "[STB] Detailed Log Activity DISABLED."); - } - else - { - g_bLogActivity2 = true; - LogAction(0, -1, "[STB] Detailed Log Activity ENABLED."); - } - } - else if (convar == stb_convarcontrol) - { - if (StringToInt(newValue) == 0) - { - g_bConVarControl = false; - } - else - { - g_bConVarControl = true; - SetGameCvars(); - } - } - else if (convar == stb_deadonly) - { - if (StringToInt(newValue) == 0) - { - g_bDeadOnly = false; - } - else - { - g_bDeadOnly = true; - } - } - else if (convar == stb_priorityenabled) - { - if (StringToInt(newValue) == 0) - { - g_bPriorityPlayers = false; - } - else - { - g_bPriorityPlayers = true; - } - } - else if (convar == stb_buddyenabled) - { - if (StringToInt(newValue) == 0) - { - g_bBuddyEnabled = false; - } - else - { - g_bBuddyEnabled = true; - } - } - else if (convar == stb_buddyrestriction) - { - if (StringToInt(newValue) == 0) - { - g_bBuddyRestriction = false; - } - else - { - g_bBuddyRestriction = true; - } - } - else if (convar == stb_unbalancelimit) - { - g_iUnbalanceLimit = StringToInt(newValue); - SetGameCvars(); - } - else if (convar == stb_balancedelay) - { - g_iBalanceDelay = StringToInt(newValue); - } - else if (convar == stb_roundstartdelay) - { - g_iRoundStartDelay = StringToInt(newValue); - } - else if (convar == stb_livingplayerswitchdelay) - { - g_iLivingPlayerSwitchDelay = StringToInt(newValue); - } - else if (convar == stb_livingplayercheckdelay) - { - g_iLivingPlayerCheckDelay = StringToInt(newValue); - } - else if (convar == stb_uberlevel) - { - g_fUberLevel = StringToFloat(newValue); - } - else if (convar == stb_switchbackforced) - { - g_iSwitchBackForced = StringToInt(newValue); - } - else if (convar == stb_adminflag) - { - SetConVarString(stb_adminflag, newValue); - } - else if (convar == stb_mp_autoteambalance) - { - SetGameCvars(); - } - else if (convar == stb_mp_teams_unbalance_limit) - { - SetGameCvars(); - } -} - -/* MENU CODE */ - -stock Handle:BuildPlayerMenu() -{ - new Handle:menu = CreateMenu(Menu_SelectPlayer); - AddTargetsToMenu(menu, 0, true, false); - SetMenuTitle(menu, "Select A Player:"); - SetMenuExitButton(menu, true); - return menu; -} - -public Menu_SelectPlayer(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[24]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - new buddy = GetClientOfUserId(StringToInt(sSelection)); - if (param1 == buddy) { - PrintHintText(param1, "%T", "SelectSelf", LANG_SERVER); - } else if (!IsClientInGame(buddy)) { - PrintHintText(param1, "%T", "BuddyGone", LANG_SERVER); - } else { - decl String:cName[128]; - decl String:bName[128]; - GetClientName(param1, cName, sizeof(cName)); - GetClientName(buddy, bName, sizeof(bName)); - if (!SM_IsBuddyLocked(buddy)) { - SM_AssignBuddy(param1, buddy); - PrintHintText(param1, "%T", "BuddyMsg", LANG_SERVER, bName); - PrintHintText(buddy, "%T", "BuddyMsg", LANG_SERVER, cName); - } else - PrintHintText(param1, "%T", "PlayerLockedBuddyMsg", LANG_SERVER, bName); - } - } else if (action == MenuAction_End) { - CloseHandle(menu); - } -} \ No newline at end of file diff --git a/addons/sourcemod/scripting/simple-teammanager.sp b/addons/sourcemod/scripting/simple-teammanager.sp deleted file mode 100644 index 008f443..0000000 --- a/addons/sourcemod/scripting/simple-teammanager.sp +++ /dev/null @@ -1,1351 +0,0 @@ -/************************************************************************ -************************************************************************* -Simple Team Manager -Description: - Manges players and their team - Admin menu integration - Allows admins/donators to swap their teams (clears force)* - Allows admins to move players to a team (forced\unforced)* - Allows admins to scramble the teams* - *Works with Simple Team Balancer (if installed) -************************************************************************* -************************************************************************* -This file is part of Simple Plugins project. - -This plugin is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the License, or -later version. - -This plugin 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 plugin. If not, see . -************************************************************************* -************************************************************************* -File Information -$Id$ -$Author$ -$Revision$ -$Date$ -$LastChangedBy$ -$LastChangedDate$ -$URL$ -$Copyright: (c) Simple Plugins 2008-2009$ -************************************************************************* -************************************************************************* -*/ - -#include - -#define PLUGIN_VERSION "2.1.$Rev$" -#define VOTE_YES "##YES##" -#define VOTE_NO "##NO##" - -enum PlayerData -{ - iNewTeam, - bool:bQueue -}; - -new Handle:stm_enabled = INVALID_HANDLE; -new Handle:stm_logactivity = INVALID_HANDLE; -new Handle:stm_adminflag_swapteam = INVALID_HANDLE; -new Handle:stm_adminflag_moveplayer = INVALID_HANDLE; -new Handle:stm_adminflag_scramble = INVALID_HANDLE; -new Handle:stm_scrambledelay = INVALID_HANDLE; -new Handle:stm_voteenabled = INVALID_HANDLE; -new Handle:stm_votewin = INVALID_HANDLE; -new Handle:stm_votedelay = INVALID_HANDLE; -new Handle:stm_mp_bonusroundtime = INVALID_HANDLE; -new Handle:g_hAdminMenu = INVALID_HANDLE; -new Handle:g_hTimerPrepScramble = INVALID_HANDLE; -new Handle:g_hTimerClearScrambleForce = INVALID_HANDLE; - -new g_aPlayers[MAXPLAYERS + 1][PlayerData]; - -new bool:g_bIsEnabled = true; -new bool:g_bVoteEnabled = true; -new bool:g_bLogActivity = true; -new bool:g_bScrambleRoundEnd = false; -new g_iVoteDelay, g_iLastVoteTime, g_iTimeLeft; -new Float:g_fScrambleDelay, Float:g_fVoteWin; - -public Plugin:myinfo = -{ - name = "Simple Team Manager", - author = "Simple Plugins", - description = "Manages players and thier team.", - version = PLUGIN_VERSION, - url = "http://www.simple-plugins.com" -}; - -public OnPluginStart() -{ - - /** - Need to create all of our console variables. - */ - CreateConVar("stm_version", PLUGIN_VERSION, "Simple Team Manager Version",FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); - stm_enabled = CreateConVar("stm_enabled", "1", "Enable or Disable Simple Team Manager", _, true, 0.0, true, 1.0); - stm_logactivity = CreateConVar("stm_logactivity", "0", "Enable or Disable the disaplying of events in the log", _, true, 0.0, true, 1.0); - stm_adminflag_swapteam = CreateConVar("stm_adminflag_swapteam", "a", "Admin flag to use for the swapteam command. Must be a in char format."); - stm_adminflag_moveplayer = CreateConVar("stm_adminflag_moveplayer", "c", "Admin flag to use for the moveplayer command. Must be a in char format."); - stm_adminflag_scramble = CreateConVar("stm_adminflag_scramble", "c", "Admin flag to use for the scrambleteam command. Must be a in char format."); - stm_scrambledelay = CreateConVar("stm_scrambledelay", "15", "Delay to scramble teams"); - stm_voteenabled = CreateConVar("stm_voteenabled", "1", "Enable or Disable voting to scramble the teams", _, true, 0.0, true, 1.0); - stm_votewin = CreateConVar("stm_votewin", "0.45", "Win percentage vote must win by", _, true, 0.0, true, 1.0); - stm_votedelay = CreateConVar("stm_votedelay", "600", "Delay before another vote can be cast"); - stm_mp_bonusroundtime = FindConVar("mp_bonusroundtime"); - - - /** - Need deal with changes to the console variables after the plugin is loaded. - We could not do this and just call the actual console variable each time we need it, but it's not efficent. - */ - HookConVarChange(stm_enabled, ConVarSettingsChanged); - HookConVarChange(stm_logactivity, ConVarSettingsChanged); - HookConVarChange(stm_scrambledelay, ConVarSettingsChanged); - HookConVarChange(stm_voteenabled, ConVarSettingsChanged); - HookConVarChange(stm_votewin, ConVarSettingsChanged); - HookConVarChange(stm_votedelay, ConVarSettingsChanged); - - /** - Need to register the commands we are going to create and use. - */ - RegConsoleCmd("sm_swapteam", Command_SwapTeam, "sm_swapteam <[0]instant/[1]queued>: Swaps your team to the other team"); - RegConsoleCmd("sm_moveplayer", Command_MovePlayer, "sm_moveplayer <[0]instant/[1]ondeath> <[0]unforced/[1]forced>: Moves a player to the specified team"); - RegConsoleCmd("sm_scrambleteams", Command_ScrambleTeams, "sm_scrambleteams: <[0]now/[1]roundend> <[0]dontrestart/[1]restartround> Scrambles the current teams"); - RegConsoleCmd("sm_votescramble", Command_VoteScramble, "sm_votescramble: Starts a vote to scramble the teams"); - - /** - Get game type and load the team numbers - */ - g_CurrentMod = GetCurrentMod(); - LoadCurrentTeams(); - - /** - Hook the game events - */ - LogAction(0, -1, "[STM] Hooking events for [%s].", g_sGameName[g_CurrentMod]); - HookEvent("player_death", HookPlayerDeath, EventHookMode_Post); - HookEvent("player_team", HookPlayerChangeTeam, EventHookMode_Post); - switch (g_CurrentMod) - { - case GameType_TF: - { - HookEvent("teamplay_round_win", HookRoundEnd, EventHookMode_Post); - } - case GameType_DOD: - { - HookEvent("dod_round_win", HookRoundEnd, EventHookMode_Post); - } - default: - { - HookEvent("round_end", HookRoundEnd, EventHookMode_PostNoCopy); - } - } - - /** - Now we have to deal with the admin menu. If the admin library is loaded call the function to add our items. - */ - new Handle:gTopMenu; - if (LibraryExists("adminmenu") && ((gTopMenu = GetAdminTopMenu()) != INVALID_HANDLE)) - { - OnAdminMenuReady(gTopMenu); - } - - /** - Load translations and .cfg file - */ - LoadTranslations ("simpleteammanager.phrases"); - AutoExecConfig(true, "plugin.simpleteammanager"); - LogAction(0, -1, "[STM] Simple Team Manager is loaded."); -} - -public OnAllPluginsLoaded() -{ - //something -} - -public OnLibraryRemoved(const String:name[]) -{ - if (StrEqual(name, "adminmenu")) - { - - /** - Looks like the admin menu was removed. Set the global. - */ - g_hAdminMenu = INVALID_HANDLE; - } - else if (StrEqual(name, "simpleplugins")) - { - SetFailState("Required plugin Simple SourceMod Plugins Core was removed."); - } -} - -public OnConfigsExecuted() -{ - - /** - Once we loaded up all the console variables from the config file, lets now set all the global variables we will use. - */ - g_bIsEnabled = GetConVarBool(stm_enabled); - g_bLogActivity = GetConVarBool(stm_logactivity); - g_fScrambleDelay = GetConVarFloat(stm_scrambledelay); - g_iVoteDelay = GetConVarInt(stm_votedelay); - g_fVoteWin = GetConVarFloat(stm_votewin); - g_iLastVoteTime = RoundFloat(GetEngineTime()); - g_bScrambleRoundEnd = false; - g_hTimerClearScrambleForce = INVALID_HANDLE; - - /** - Report enabled - */ - if (g_bIsEnabled) - { - LogAction(0, -1, "[STM] Simple Team Manager is ENABLED."); - } - else - { - LogAction(0, -1, "[STM] Simple Team Manager is DISABLED."); - } - - if (g_bLogActivity) - { - LogAction(0, -1, "[STM] Log Activity ENABLED."); - } - else - { - LogAction(0, -1, "[STM] Log Activity DISABLED."); - } -} - -/* COMMANDS */ - -public Action:Command_SwapTeam(client, args) -{ - - /** - Make sure we are enabled, if not bug out. - */ - if (!g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - If this was ran from the console bug out. - */ - if (client == 0) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "PlayerLevelCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Make sure the client is authorized to run this command. - */ - decl String:sFlags[5]; - GetConVarString(stm_adminflag_swapteam, sFlags, sizeof(sFlags)); - if (!SM_IsValidAdmin(client, sFlags)) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Lets make sure the client is one a team we can swap. - If he is we set the global array to the opposite team. - */ - new iTeam = GetClientTeam(client); - if (iTeam == g_aCurrentTeams[Team1]) - { - g_aPlayers[client][iNewTeam] = g_aCurrentTeams[Team2]; - } - else if (iTeam == g_aCurrentTeams[Team2]) - { - g_aPlayers[client][iNewTeam] = g_aCurrentTeams[Team1]; - } - else - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "InValidTeam", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check to see if we have command arguments. - */ - if (GetCmdArgs()) - { - - /** - We do, so lets get it and see if the client wants to be switched instantly or queued for death. - */ - decl String:sArg[5]; - GetCmdArg(1, sArg, sizeof(sArg)); - new iWantsQue = StringToInt(sArg); - if (iWantsQue && !g_aPlayers[client][bQueue]) - { - - /** - He wants the que and isn't already in it, set the global array. - */ - g_aPlayers[client][bQueue] = true; - ReplyToCommand(client, "\x01\x04[STM]\x01 %T", "PlayerQueue", LANG_SERVER); - } - else if (!iWantsQue) - { - - /** - He wants to be switched right now, lets call the stock function. - */ - SM_MovePlayer(client, g_aPlayers[client][iNewTeam]); - } - } - else - { - - /** - There are no command arguments so we build and display the swap menu. - */ - DisplaySwapModeMenu(client, client); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_MovePlayer(client, args) -{ - - /** - Make sure we are enabled, if not bug out. - */ - if (!g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - Make sure the client is authorized to run this command. - */ - decl String:sFlags[5]; - GetConVarString(stm_adminflag_moveplayer, sFlags, sizeof(sFlags)); - if (!SM_IsValidAdmin(client, sFlags)) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check to see if we have command arguments. - */ - new iCmdArgs = GetCmdArgs(); - if (iCmdArgs == 0) - { - - /** - We don't. Build the player menu, display it, and bug out. - */ - DisplayPlayerMenu(client); - return Plugin_Handled; - } - - /** - Check the first argument - If should be a players name or userid. - */ - decl String:sPlayer[64]; - GetCmdArg(1, sPlayer, sizeof(sPlayer)); - new iPlayerIndex = FindTarget(client, sPlayer, true, true); - if (iPlayerIndex == -1 || !IsClientInGame(iPlayerIndex)) - { - - /** - We don't know who this is. Build the player menu, display it, and bug out. - */ - DisplayPlayerMenu(client); - return Plugin_Handled; - } - - /** - We have figured out the first argument, lets check the second. - If should be the team the client wants to put the player on. - */ - if (iCmdArgs >= 2) - { - - /** - We have a command argument at least, lets see if we can identify the team. - */ - decl String:sTeam[24]; - GetCmdArg(2, sTeam, sizeof(sTeam)); - - new iTeam = StringToInt(sTeam); - if (SM_IsValidTeam(iTeam)) - { - - /** - It's a vaild team so lets set the global array to the new team. - */ - g_aPlayers[iPlayerIndex][iNewTeam] = iTeam; - } - else - { - - /** - It's not a vaild team so set the menu to display to the team menu. - */ - DisplayTeamMenu(client, iPlayerIndex); - return Plugin_Handled; - } - } - else - { - /** - We were not given a team, display the team menu. - */ - DisplayTeamMenu(client, iPlayerIndex); - return Plugin_Handled; - } - - /** - Check to see if we were given any more command arguments and found a team. - */ - if (iCmdArgs < 3) - { - - /** - No more command arguments and found a team. - Now lets check to see if the player is a spectator. If he is there is no reason to ask if it's instant or on death... he can't die. - */ - if (!IsClientObserver(iPlayerIndex)) - { - - /** - Not a spectator so display the swapmode menu. - */ - DisplaySwapModeMenu(client, iPlayerIndex); - } - else - { - - /** - The player is a spectator. - We make sure the player is not set to switch on death, since a spec can't die. - */ - g_aPlayers[iPlayerIndex][bQueue] = false; - } - } - - /** - We have figured out the second argument, lets check the third. - If should be the how the client wants to move the player: instant/on death. - */ - if (iCmdArgs >= 3) - { - - /** - The client gave us a command argument, lets check it. - */ - decl String:sSwapMode[5]; - GetCmdArg(3, sSwapMode, sizeof(sSwapMode)); - new iWantsQue = StringToInt(sSwapMode); - if (iWantsQue) - { - - /** - The client wants to que the player, set the global array. - */ - g_aPlayers[iPlayerIndex][bQueue] = true; - } - else - { - - /** - The client doesn't want to que the player, set the global array. - */ - g_aPlayers[iPlayerIndex][bQueue] = false; - } - } - else - { - /** - No swapmode argument, display the menu - */ - DisplaySwapModeMenu(client, iPlayerIndex); - } - - if (iCmdArgs >= 4) - { - - /** - Since we are compiling for Simple Team Balancer, and given a 4th argument, lets check it. - If should be the if the client wants to force the player to that team. - */ - decl String:sPlayerForced[5]; - GetCmdArg(4, sPlayerForced, sizeof(sPlayerForced)); - new iForceHim = StringToInt(sPlayerForced); - if (iForceHim) - { - - /** - The client wants to force the player - */ - SM_SetForcedTeam(iPlayerIndex, g_aPlayers[iPlayerIndex][iNewTeam]); - } - else - { - - /** - The client doesn't want to force the player - */ - SM_ClearForcedTeam(iPlayerIndex); - } - } - else - { - - } - - /** - We found and processed all the arguments. - */ - if (!IsPlayerAlive(iPlayerIndex)) - { - - /** - The player is not alive or died during this process so we just move him. - */ - SM_MovePlayer(iPlayerIndex, g_aPlayers[iPlayerIndex][iNewTeam]); - } - else - { - if (!g_aPlayers[iPlayerIndex][bQueue]) - { - - /** - The player is alive and is not set to be queued so we just move him. - */ - SM_MovePlayer(iPlayerIndex, g_aPlayers[iPlayerIndex][iNewTeam]); - } - } - - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_ScrambleTeams(client, args) -{ - - /** - Make sure we are enabled, if not bug out. - */ - if (!g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - Make sure the client is authorized to run this command. - */ - decl String:sFlags[5]; - GetConVarString(stm_adminflag_scramble, sFlags, sizeof(sFlags)); - if (!SM_IsValidAdmin(client, sFlags)) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "RestrictedCmd", LANG_SERVER); - return Plugin_Handled; - } - - /** - Check if a scramble timer was already called, if so close it down. - */ - if (g_hTimerPrepScramble != INVALID_HANDLE) - { - CloseHandle(g_hTimerPrepScramble); - g_hTimerPrepScramble = INVALID_HANDLE; - } - - /** - Check if we have any command arguments. - If we don't we display the scramble menu and bug out. - */ - new iCmdArgs = GetCmdArgs(); - if (iCmdArgs == 0) - { - DisplayScrambleMenu(client); - return Plugin_Handled; - } - - /** - We have a command argument. - It should be whether or not to scramble at round end. - */ - decl String:sRoundEnd[5]; - GetCmdArg(1, sRoundEnd, sizeof(sRoundEnd)); - if (StringToInt(sRoundEnd)) - { - /** - The client wants to scramble at round end so we set the global bool. - */ - g_bScrambleRoundEnd = true; - } - else - { - g_bScrambleRoundEnd = false; - } - - /** - Check for another command argument. - It should be whether or not to restart the round. - */ - decl String:sRestartRound[5]; - new bool:bRestartRound = false; - GetCmdArg(1, sRestartRound, sizeof(sRestartRound)); - if (StringToInt(sRestartRound)) - { - bRestartRound = true; - } - - /** - Now we start the scramble timer. - */ - StartScrambleTimer(_, bRestartRound); - - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Command_VoteScramble(client, args) -{ - - /** - Make sure we are enabled, if not bug out. - */ - if (!g_bVoteEnabled || !g_bIsEnabled) - { - return Plugin_Handled; - } - - /** - Make sure there is a vote in progress, if so bug out. - */ - if (IsVoteInProgress()) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "VoteInProgress", LANG_SERVER); - return Plugin_Handled; - } - - /** - Make sure enough time has passed since the last vote. - */ - new iVoteTime = RoundFloat(GetEngineTime()); - if (iVoteTime - g_iLastVoteTime <= g_iVoteDelay) - { - ReplyToCommand(client, "\x01\x04[SM]\x01 %T", "ScrambleTime", LANG_SERVER); - return Plugin_Handled; - } - - /** - Enough time has passed so reset the global vote time to now. - */ - g_iLastVoteTime = iVoteTime; - - /** - Build the vote menu and send it to everyone. - */ - new Handle:hMenu = CreateMenu(Menu_VoteScramble); - SetMenuTitle(hMenu, "Scramble Teams?"); - AddMenuItem(hMenu, VOTE_YES, "Yes"); - AddMenuItem(hMenu, VOTE_NO, "No"); - SetMenuExitButton(hMenu, false); - VoteMenuToAll(hMenu, 20); - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -/* HOOKED EVENTS */ - -public HookPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Find out who died. - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - - /** - Find out how the client died. - */ - new String:sWeapon[64]; - GetEventString(event, "weapon", sWeapon, sizeof(sWeapon)); - if (StrEqual(sWeapon, "world", false)) - { - - /** - He died because he changed teams so cleanup and bug out. - */ - s_CleanUp(iClient); - return; - } - - /** - Find out if this player was queued to change teams. - */ - if (g_aPlayers[iClient][bQueue]) - { - /** - Looks like he was, so call the stock function to move him. - */ - SM_MovePlayer(iClient, g_aPlayers[iClient][iNewTeam]); - } -} - -public HookPlayerChangeTeam(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Find out who changed teams. - */ - new iClient = GetClientOfUserId(GetEventInt(event, "userid")); - - /** - If he was queued to switch teams we cleanup the variables. The client did it themself. - */ - if (g_aPlayers[iClient][bQueue]) - { - s_CleanUp(iClient); - } -} - -public HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) -{ - - /** - Get the amount of time left in the map. - */ - new iTimeLeft; - GetMapTimeLeft(iTimeLeft); - - /** - Check to see if we are supposed to scramble at the end of the round and that there is enough time left in the map. - */ - if (g_bScrambleRoundEnd && iTimeLeft >= 60) - { - - /** - Check to see if there is a scramble timer in action and if so close it down. - */ - if (g_hTimerPrepScramble != INVALID_HANDLE) - { - CloseHandle(g_hTimerPrepScramble); - g_hTimerPrepScramble = INVALID_HANDLE; - } - - /** - Determine the round end chat time and run the scramble 1 second before it ends. - */ - new Float:fDelay = GetConVarFloat(stm_mp_bonusroundtime); - fDelay -= 1.0; - StartScrambleTimer(fDelay); - } -} - -public OnClientPostAdminCheck(client) -{ - - /** - Determine if the client has the flag to use the swapteam command. - */ - decl String:sFlags[5]; - GetConVarString(stm_adminflag_swapteam, sFlags, sizeof(sFlags)); - if (SM_IsValidAdmin(client, sFlags)) - { - /** - The client does so lets create a timer to run an advertise to tell him about it. - */ - CreateTimer (60.0, Timer_WelcomeAdvert, client); - } -} - -public OnClientDisconnect(client) -{ - - /** - Cleanup the clients variables. - */ - s_CleanUp(client); -} - -public SM_OnPlayerMoved(Handle:plugin, client, team) -{ - - /** - Make sure we called the move function - */ - if (plugin != GetMyHandle()) - { - if (g_bLogActivity) - { - LogAction(0, client, "[STM] Callback was not started with current plugin, bugging out."); - } - return; - } - - decl String:sPlayerName[64]; - GetClientName(client, sPlayerName, sizeof(sPlayerName)); - - PrintToChat(client, "\x01\x04[SM]\x01 %T", "PlayerSwitched", LANG_SERVER); - - s_CleanUp(client); -} - -/* TIMER FUNCTIONS */ - -public Action:Timer_PrepTeamScramble(Handle:timer, any:data) -{ - new bool:bRestartRound = data; - /** - Call the scramble the teams stock function. - */ - PrepTeamScramble(bRestartRound); - - /** - Reset the timer handle so we know the timer is done. - */ - g_hTimerPrepScramble = INVALID_HANDLE; - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Timer_ScrambleTheTeams(Handle:timer, any:data) -{ - new iPlayers[MAXPLAYERS + 1]; - new iCount, i, bool:bTeam, bool:bRestartRound = data; - - /** - Get all the client index numbers of valid players - */ - for(i = 1; i <= MaxClients; i++) - { - if(IsClientInGame(i)) // && !IsFakeClient(i)) - { - iPlayers[iCount++] = i; - } - } - - /** - Randomly sort the players - */ - SortIntegers(iPlayers, iCount, Sort_Random); - - /** - Loop through all the players and assign each one to a team, alternating each time - */ - for(i = 0; i < iCount; i++) - { - if (!bRestartRound) - { - /** - We didn't want to restart the round, so we move them to spec 1 at a time. - */ - SM_MovePlayer(iPlayers[i], g_aCurrentTeams[Spectator]); - } - SM_MovePlayer(iPlayers[i], bTeam ? g_aCurrentTeams[Team2] : g_aCurrentTeams[Team1]); - SM_SetForcedTeam(iPlayers[i], bTeam ? g_aCurrentTeams[Team2] : g_aCurrentTeams[Team1], true); - bTeam = !bTeam; - } - - /** - Reset this variable since we completed a scramble - */ - g_bScrambleRoundEnd = false; - - if (g_hTimerClearScrambleForce != INVALID_HANDLE) - { - CloseHandle(g_hTimerClearScrambleForce); - g_hTimerClearScrambleForce = INVALID_HANDLE; - } - - g_hTimerClearScrambleForce = CreateTimer(300.0, Timer_ClearScrambleForce, _, TIMER_FLAG_NO_MAPCHANGE); - - ServerCommand("mp_timelimit %i", g_iTimeLeft / 60); - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Timer_ClearScrambleForce(Handle:timer, any:data) -{ - - for(new i = 1; i <= MaxClients; i++) - { - if(IsClientInGame(i)) // && !IsFakeClient(i)) - { - SM_ClearForcedTeam(i); - PrintToChat(i, "\x01\x04[SM]\x01 Your forced team status has been cleared"); - } - } - - g_hTimerClearScrambleForce = INVALID_HANDLE; - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -public Action:Timer_WelcomeAdvert(Handle:timer, any:client) -{ - - /** - Lets make sure the client is connected and actually in the game. - */ - if (IsClientConnected(client) && IsClientInGame(client)) - { - - /** - We are good to go so lets tell him about the swapteam command. - */ - PrintToChat (client, "\x01\x04[STM]\x01 %T", "SwapTeamMsg", LANG_SERVER); - } - - /** - We are done, bug out. - */ - return Plugin_Handled; -} - -/* STOCK FUNCTIONS */ - -stock s_CleanUp(iClient) -{ - - /** - Reset all the client variables - */ - g_aPlayers[iClient][bQueue] = false; - g_aPlayers[iClient][iNewTeam] = 0; -} - -stock StartScrambleTimer(Float:fdelay = 0.0, bool:bRestartRound = false) -{ - if (fdelay == 0.0) - { - fdelay = g_fScrambleDelay; - } - if (g_hTimerPrepScramble != INVALID_HANDLE) - { - CloseHandle(g_hTimerPrepScramble); - g_hTimerPrepScramble = INVALID_HANDLE; - } - PrintCenterTextAll("%T", "Scramble", LANG_SERVER); - g_hTimerPrepScramble = CreateTimer(fdelay, Timer_PrepTeamScramble, bRestartRound, TIMER_FLAG_NO_MAPCHANGE); -} - -stock PrepTeamScramble(bool:bRestartRound = false) -{ - new iPlayers[MAXPLAYERS + 1]; - new iCount; - - GetMapTimeLeft(g_iTimeLeft); - - if (bRestartRound) - { - - for(new i = 1; i <= MaxClients; i++) - { - if(IsClientInGame(i)) - // && !IsFakeClient(i)) - { - iPlayers[iCount++] = i; - SM_ClearForcedTeam(i); - SM_ClearBuddy(i); - SM_MovePlayer(i, g_aCurrentTeams[Spectator]); - } - } - } - else - { - //Can't move them all to spec at the same time - for(new i = 1; i <= MaxClients; i++) - { - if(IsClientInGame(i)) - // && !IsFakeClient(i)) - { - iPlayers[iCount++] = i; - SM_ClearForcedTeam(i); - SM_ClearBuddy(i); - //SM_MovePlayer(i, g_aCurrentTeams[Spectator]); - } - } - } - CreateTimer(4.0, Timer_ScrambleTheTeams, bRestartRound, TIMER_FLAG_NO_MAPCHANGE); -} - -/* CONSOLE VARIABLE CHANGE EVENT */ - -public ConVarSettingsChanged(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - if (convar == stm_enabled) { - if (StringToInt(newValue) == 0) { - g_bIsEnabled = false; - LogAction(0, -1, "[STM] Simple Team Manager is loaded and disabled."); - } else { - g_bIsEnabled = true; - LogAction(0, -1, "[STM] Simple Team Manager is loaded and enabled."); - } - } - else if (convar == stm_logactivity) { - if (StringToInt(newValue) == 0) { - g_bLogActivity = false; - LogAction(0, -1, "[STM] Log Activity DISABLED."); - } else { - g_bLogActivity = true; - LogAction(0, -1, "[STM] Log Activity ENABLED."); - } - } - else if (convar == stm_scrambledelay) - g_fScrambleDelay = StringToFloat(newValue); - else if (convar == stm_votewin) - g_fVoteWin = StringToFloat(newValue); - else if (convar == stm_votedelay) - g_iVoteDelay = StringToInt(newValue); - else if (convar == stm_voteenabled) { - if (StringToInt(newValue) == 0) - g_bVoteEnabled = false; - else - g_bVoteEnabled = true; - } -} - -/* MENU CODE */ - -public OnAdminMenuReady(Handle:topmenu) -{ - if (topmenu == g_hAdminMenu) - return; - g_hAdminMenu = topmenu; - new TopMenuObject:player_commands = FindTopMenuCategory(g_hAdminMenu, ADMINMENU_PLAYERCOMMANDS); - new TopMenuObject:server_commands = FindTopMenuCategory(g_hAdminMenu, ADMINMENU_SERVERCOMMANDS); - if (player_commands == INVALID_TOPMENUOBJECT) - return; - - AddToTopMenu(g_hAdminMenu, - "moveplayer", - TopMenuObject_Item, - AdminMenu_MovePlayer, - player_commands, - "moveplayer", - ADMFLAG_BAN); - - AddToTopMenu(g_hAdminMenu, - "scrambleteams", - TopMenuObject_Item, - AdminMenu_Scrambleteams, - server_commands, - "scrambleteams", - ADMFLAG_BAN); -} - -public AdminMenu_MovePlayer(Handle:topmenu, TopMenuAction:action, TopMenuObject:object_id, param, String:buffer[], maxlength) -{ - if (action == TopMenuAction_DisplayOption) - Format(buffer, maxlength, "Move Player"); - else if (action == TopMenuAction_SelectOption){ - DisplayPlayerMenu(param); - } -} - -public AdminMenu_Scrambleteams(Handle:topmenu, TopMenuAction:action, TopMenuObject:object_id, param, String:buffer[], maxlength) -{ - if (action == TopMenuAction_DisplayOption) - Format(buffer, maxlength, "Scramble Teams"); - else if (action == TopMenuAction_SelectOption) { - DisplayScrambleMenu(param); - } -} - -public Menu_SelectPlayer(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - DisplayTeamMenu(param1, GetClientOfUserId(StringToInt(sSelection))); - } else if (action == MenuAction_Cancel) { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -public Menu_SelectTeam(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new iTeam; - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - decl String:sIndex[64]; - if (SplitString(sSelection, "A", sIndex, sizeof(sIndex)) != -1) - iTeam = g_aCurrentTeams[Team1]; - else if (SplitString(sSelection, "B", sIndex, sizeof(sIndex)) != -1) - iTeam = g_aCurrentTeams[Team2]; - else { - SplitString(sSelection, "C", sIndex, sizeof(sIndex)); - iTeam = g_aCurrentTeams[Spectator]; - } - new iTarget = StringToInt(sIndex); - g_aPlayers[iTarget][iNewTeam] = iTeam; - DisplaySwapModeMenu(param1, iTarget); - } else if (action == MenuAction_Cancel) { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -public Menu_SwapMode(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - decl String:sIndex[64]; - - if (SplitString(sSelection, "A", sIndex, sizeof(sIndex)) == -1) - { - SplitString(sSelection, "B", sIndex, sizeof(sIndex)); - } - - new iTarget = StringToInt(sIndex); - - if (StrContains(sSelection, "A", true) != -1) - { - g_aPlayers[iTarget][bQueue] = false; - } - else if (StrContains(sSelection, "B", true) != -1) - { - g_aPlayers[iTarget][bQueue] = true; - } - - if (param1 == iTarget && !g_aPlayers[iTarget][bQueue]) - { - SM_MovePlayer(iTarget, g_aPlayers[iTarget][iNewTeam]); - } - else - { - DisplayForceModeMenu(param1, iTarget); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - { - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } - return; -} - -public Menu_ForceMode(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) - { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - decl String:sIndex[64]; - if (SplitString(sSelection, "A", sIndex, sizeof(sIndex)) == -1) - { - SplitString(sSelection, "B", sIndex, sizeof(sIndex)); - } - new iTarget = StringToInt(sIndex); - if (StrContains(sSelection, "A", true) != -1) - { - SM_ClearForcedTeam(iTarget); - } - else if (StrContains(sSelection, "B", true) != -1) - { - SM_SetForcedTeam(iTarget, g_aPlayers[iTarget][iNewTeam], true); - } - if (!g_aPlayers[iTarget][bQueue]) - { - SM_MovePlayer(iTarget, g_aPlayers[iTarget][iNewTeam]); - } - } - else if (action == MenuAction_Cancel) - { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - { - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } - } - else if (action == MenuAction_End) - { - CloseHandle(menu); - } - return; -} - -public Menu_VoteScramble(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_VoteEnd) { - new winning_votes, total_votes; - GetMenuVoteInfo(param2, winning_votes, total_votes); - if (param1 == 0) { - if (float(total_votes) / float(winning_votes) < g_fVoteWin) { - PrintToChatAll("\x01\x04[SM]\x01 %T", "VoteScramble2", LANG_SERVER, winning_votes, total_votes); - return; - } - PrintCenterTextAll("[SM] %T", "Scramble", LANG_SERVER); - PrintToChatAll("\x01\x04[SM]\x01 %T", "VoteScramble1", LANG_SERVER, winning_votes, total_votes); - StartScrambleTimer(); - } - if (param1 == 1) { - PrintToChatAll("\x01\x04[SM]\x01 %T", "VoteScramble2", LANG_SERVER, winning_votes, total_votes); - } - } - if (action == MenuAction_End) - CloseHandle(menu); -} - -public Menu_ScrambleTeams(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[64]; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "NOW", false)) - g_bScrambleRoundEnd = false; - else - g_bScrambleRoundEnd = true; - DisplayScrambleMenu2(param1); - } else if (action == MenuAction_Cancel) { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -public Menu_ScrambleTeams2(Handle:menu, MenuAction:action, param1, param2) -{ - if (action == MenuAction_Select) { - new String:sSelection[64]; - new bool:bRestartRound; - GetMenuItem(menu, param2, sSelection, sizeof(sSelection)); - if (StrEqual(sSelection, "NO", false)) - { - bRestartRound = false; - } - else - { - bRestartRound = true; - } - StartScrambleTimer(_, bRestartRound); - } else if (action == MenuAction_Cancel) { - if (param2 == MenuCancel_ExitBack && g_hAdminMenu != INVALID_HANDLE && GetUserFlagBits(param1) & ADMFLAG_BAN) - DisplayTopMenu(g_hAdminMenu, param1, TopMenuPosition_LastCategory); - } else if (action == MenuAction_End) - CloseHandle(menu); - return; -} - -stock DisplayScrambleMenu(iClient) -{ - new Handle:hMenu = CreateMenu(Menu_ScrambleTeams); - SetMenuTitle(hMenu, "Select When to Scramble:"); - AddMenuItem(hMenu, "NOW", "Instantly"); - AddMenuItem(hMenu, "END", "At Round End"); - SetMenuExitBackButton(hMenu, false); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} - -stock DisplayScrambleMenu2(iClient) -{ - new Handle:hMenu = CreateMenu(Menu_ScrambleTeams2); - SetMenuTitle(hMenu, "Select When to Scramble:"); - AddMenuItem(hMenu, "NO", "No Round Restart"); - AddMenuItem(hMenu, "YES", "Restart Round"); - SetMenuExitBackButton(hMenu, false); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} - -stock DisplaySwapModeMenu(iClient, iTarget) -{ - new Handle:hMenu = CreateMenu(Menu_SwapMode); - decl String:optionA[64]; - decl String:optionB[64]; - Format(optionA, sizeof(optionA), "%iA", iTarget); - Format(optionB, sizeof(optionB), "%iB", iTarget); - SetMenuTitle(hMenu, "Select When to Swap:"); - AddMenuItem(hMenu, optionA, "Instantly (Kills)"); - if (!IsClientObserver(iTarget)) - AddMenuItem(hMenu, optionB, "Queue on next death"); - SetMenuExitBackButton(hMenu, false); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} - -stock DisplayForceModeMenu(iClient, iTarget) -{ - new Handle:hMenu = CreateMenu(Menu_ForceMode); - decl String:optionA[64]; - decl String:optionB[64]; - Format(optionA, sizeof(optionA), "%iA", iTarget); - Format(optionB, sizeof(optionB), "%iB", iTarget); - SetMenuTitle(hMenu, "Select Force Mode:"); - AddMenuItem(hMenu, optionA, "UnForced"); - AddMenuItem(hMenu, optionB, "Forced"); - SetMenuExitBackButton(hMenu, false); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} - -stock DisplayTeamMenu(iClient, iTarget) -{ - new Handle:hMenu = CreateMenu(Menu_SelectTeam); - decl String:optionA[64]; - decl String:optionB[64]; - decl String:optionC[64]; - Format(optionA, sizeof(optionA), "%iA", iTarget); - Format(optionB, sizeof(optionB), "%iB", iTarget); - Format(optionC, sizeof(optionC), "%iC", iTarget); - SetMenuTitle(hMenu, "Select Team:"); - AddMenuItem(hMenu, optionA, "Team One"); - AddMenuItem(hMenu, optionB, "Team Two"); - AddMenuItem(hMenu, optionC, "Spectator"); - SetMenuExitBackButton(hMenu, false); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} - -stock DisplayPlayerMenu(iClient) -{ - new Handle:hMenu = CreateMenu(Menu_SelectPlayer); - AddTargetsToMenu(hMenu, 0, true, false); - SetMenuTitle(hMenu, "Select A Player:"); - SetMenuExitBackButton(hMenu, true); - DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER); -} diff --git a/addons/sourcemod/translations/simpledonatorbenefits.phrases.txt b/addons/sourcemod/translations/simpledonatorbenefits.phrases.txt deleted file mode 100644 index 3826846..0000000 --- a/addons/sourcemod/translations/simpledonatorbenefits.phrases.txt +++ /dev/null @@ -1,62 +0,0 @@ -"Phrases" -{ - "PlayerLevelCmd" - { - "en" "Command must be run at the player level" - "fr" "Cette commande doit être tapée en jeu" - "hu" "Ezt a parancsot jatekosi szinten kell futtatni!" - } - "RestrictedCmd" - { - "en" "You must be a donator or admin to run this command" - "fr" "Vous devez être un donateur ou un admin pour lancer cette commande" - "hu" "A parancs futtatasahoz admin, vagy tamogatoi szint szukseges!" - } - "InValidTeam" - { - "en" "You must be on red or blue to swap teams" - "fr" "Vous devez être RED ou BLU pour changer d'équipe" - "hu" "Jatekban kell lenned, hogy megcsereld a csapatokat!" - } - "PlayerQueue" - { - "en" "You have been queued to swap teams on next death" - "fr" "Vous avez été mis en attente pour changer d'équipe lors de votre prochaine mort" - "hu" "A kovetkezo halalnal csapatcsere lesz" - } - "PlayerSwitched" - { - "en" "Your team has been switched as requested" - "fr" "Vous avez changé d'équipe comme demandé" - "hu" "A keresnek eleget teve a csapatod meg lett csererlve" - } - "SwapTeamMsg" - { - "en" "Type /swapteam or !swapteam to swap your team!" - } - "ReachedCount" - { - "en" "You have reached your health limit. You must die before you can use it again" - } - "AtMaxHealth" - { - "en" "You are already at your maximum health!" - } - "ToMaxHealth" - { - "en" "Instant health bonus applied! You are not at your maximun health!" - } - "HealthBonus" - { - "en" "Instant health bonus applied!" - } - "PublicJoinMessage" - { - "#format" "{1:s}" - "en" "{1} a [donator] as joined the server" - } - "PrivateJoinMessage" - { - "en" "Thanks for donating!" - } -} \ No newline at end of file diff --git a/addons/sourcemod/translations/simplespectate.phrases.txt b/addons/sourcemod/translations/simplespectate.phrases.txt deleted file mode 100644 index 2d1a096..0000000 --- a/addons/sourcemod/translations/simplespectate.phrases.txt +++ /dev/null @@ -1,42 +0,0 @@ -"Phrases" -{ - "Stopped spectating" - { - "#format" "{1:s}" - "en" "Stopped tracking player: {1}" - } - "Yourself" - { - "en" "You can't spectate yourself" - } - "Spectator" - { - "en" "You can't spectate another spectator" - } - "Spectating" - { - "#format" "{1:s}" - "en" "Now spectating {1}. Type !stopspec or /stopspec to stop spectating this player" - } - "Invalid Target" - { - "en" "Invalid target" - } - "Cant Target" - { - "en" "Can't target this player" - } - "Must Have Target" - { - "en" "You must be following/tracking a player to punish" - } - "Target Left" - { - "en" "The player you were following/tracking has left" - } - "Punished" - { - "#format" "{1:s}{2:s}{3:s}" - "en" "{1} was punished with a {2} for {3}" - } -} \ No newline at end of file diff --git a/addons/sourcemod/translations/simpleteambalancer.phrases.txt b/addons/sourcemod/translations/simpleteambalancer.phrases.txt deleted file mode 100644 index 03595fd..0000000 --- a/addons/sourcemod/translations/simpleteambalancer.phrases.txt +++ /dev/null @@ -1,130 +0,0 @@ -"Phrases" -{ - "UnBalanced" - { - "en" "Teams are unbalanced and will be balanced shortly" - "fr" "Les équipes ne sont pas équilibrées et le seront bientôt" - "de" "Die Teams sind ungleich und werden in Kürze ausgeglichen" - "hu" "A csapatok nem kiegyenlitettek! Egyensuly beallitas kovetkezik!" - } - "Enabled" - { - "en" "Simple Team Balancer is ENABLED" - "fr" "Simple Team Balancer est ACTIVE" - "de" "Simple Team Balancer ist AKTIV" - "hu" "Az Egyszeru Csapat Egyensulytarto AKTIV!" - } - "Disabled" - { - "en" "Simple Team Balancer is DISABLED" - "fr" "Simple Team Balancer est DESACTIVE" - "de" "Simple Team Balancer ist INAKTIV" - "hu" "Az Egyszeru Csapat Egyensulytarto INAKTIV!" - } - "PlayerMessage" - { - "#format" "{1:i}" - "en" "You are going to be auto balanced in {1} seconds unless a dead player can be found" - "fr" "Vous passerez dans l'autre équipe dans {1} secondes si aucun joueur mort ne peut être trouvé dans cet intervalle" - "de" "Du wirst in {1} Sekunden zum automatischen Ausgleich herangezogen wenn kein toter Spieler gefunden werden kann" - "hu" "{1} masodpercen belul at leszel helyezve a masik csapatba, hacsak nem lesz addig egy halott jatekos!" - } - "BalanceMessage" - { - "#format" "{1:s}" - "en" "{1} was moved to the other team for game balance" - "fr" "{1} est passé dans l'autre équipe pour équilibrer la partie" - "de" "{1} wurde zum anderen Team verschoben um das Spiel auszugleichen" - "hu" "{1} at lett helyezve az egyensuly megtartasa erdekeben." - } - "PlayerLevelCmd" - { - "en" "Command must be run at the player level" - "fr" "La commande doit être lancée au niveau du joueur" - "de" "Das Kommando muss auf Spieler Ebene ausgeführt werden" - "hu" "Jatekosi szinten kell futtatni ezt a parancsot!" - } - "CmdDisabled" - { - "en" "Command is currently disabled" - "fr" "La commande est actuellement désactivée" - "de" "Das Kommando ist momentan inaktiv" - "hu" "A parancs jelenleg inaktiv" - } - "RestrictedBuddy" - { - "en" "You must be a donator or admin to add a balance buddy" - "fr" "Vous devez être un donateur ou un admin pour choisir un partenaire" - "de" "Du musst ein Spender oder Admin sein um einen Partner wählen zu können" - "hu" "Tamogato vagy admin kell hogy legyel, hogy 'Tarsat' jelolhess meg" - } - "SelectSelf" - { - "en" "You cannot be your own buddy" - "fr" "Vous ne pouvez pas être votre propre partenaire" - "de" "Du kannst nicht dein eigener Partner sein" - "hu" "Nem valaszthatod ki onmagad!" - } - "BuddyGone" - { - "en" "Your selected buddy has disconnected" - "fr" "Le partenaire que vous avez sélectionné s'est déconnecté" - "de" "Dein gewählter Partner hat die Verbindung getrennt" - "hu" "A valasztott 'Tarsad' kilepett" - } - "BuddyMsg" - { - "#format" "{1:s}" - "en" "You and {1} are now buddies" - "fr" "Vous et {1} êtes maintenant partenaires" - "de" "Du und {1} seid jetzt Partner" - "hu" "{1} es Te 'Tarsak' vagytok." - } - "BuddyLockMsgDisabled" - { - "en" "You can now be anyone's buddy" - "fr" "Vous pouvez à présent être le partenaire de n'importe qui" - "de" "Du kannst jetzt jedermanns Partner sein" - "hu" "Barkinek lehetsz a 'Tarsa'." - } - "BuddyLockMsgEnabled" - { - "en" "Buddy selection locked. Only you can change your buddy" - "fr" "Sélection de partenaire bloquée. Vous êtes le seul à pouvoir choisir votre partenaire" - "de" "Wahl des Partners gesperrt. Nur du kannst deinen Partner wechseln" - "hu" "Tars-lista lezarva. Csak Te tudod modositani a Tars-listadat." - } - "PlayerLockedBuddyMsg" - { - "#format" "{1:s}" - "en" "{1} has locked his buddy selection. Try again" - "fr" "{1} a bloqué sa sélection de partenaire. Essayez de nouveau." - "de" "{1} hat seine Wahl des Partners gesperrt. Versuche es erneut" - "hu" "{1} lezarta a Tars-listajat. Probald kesobb!" - } - "BuddyWelcomeMsg1" - { - "en" "Select a balance buddy and stay together during an autobalance!" - "fr" "Choisissez un partenaire et restez ensemble durant l'équilibrage automatique!" - "de" "Wähle einen Partner und bleibt zusammen während eines Ausgleichs" - "hu" "Valasz ki egy 'Tarsat' akivel egyuttmaradhatsz a csapatkiegyenlites alatt!" - } - "BuddyWelcomeMsg2" - { - "en" "/buddy or !buddy to select a balance buddy" - "fr" "/buddy or !buddy pour choisir un partenaire" - "de" "/buddy oder !buddy um einen Partner zu wählen" - "hu" "Hasznald a /buddy vagy !buddy parancsokat a 'Tars' kijelolesehez" - } - "BuddyWelcomeMsg3" - { - "en" "/lockbuddy or !lockbuddy to lock your selection" - "fr" "/lockbuddy or !lockbuddy pour bloquer votre sélection" - "de" "/lockbuddy oder !lockbuddy um deine Auswahl zu sperren" - "hu" "Hasznald a /lockbuddy vagy a !lockbuddy parancsokat a Tars-listad lezarasahoz" - } -} - - - - diff --git a/addons/sourcemod/translations/simpleteammanager.phrases.txt b/addons/sourcemod/translations/simpleteammanager.phrases.txt deleted file mode 100644 index f2093a7..0000000 --- a/addons/sourcemod/translations/simpleteammanager.phrases.txt +++ /dev/null @@ -1,92 +0,0 @@ -"Phrases" -{ - "PlayerLevelCmd" - { - "en" "Command must be run at the player level" - "fr" "Cette commande doit être tapée en jeu" - "hu" "Ezt a parancsot jatekosi szinten kell futtatni!" - } - "RestrictedCmd" - { - "en" "You must be a donator or admin to run this command" - "fr" "Vous devez être un donateur ou un admin pour lancer cette commande" - "hu" "A parancs futtatasahoz admin, vagy tamogatoi szint szukseges!" - } - "InValidTeam" - { - "en" "You must be on red or blue to swap teams" - "fr" "Vous devez être RED ou BLU pour changer d'équipe" - "hu" "Jatekban kell lenned, hogy megcsereld a csapatokat!" - } - "PlayerInValidTeam" - { - "en" "Player must be on red or blue to swap teams" - "fr" "Le joueur doit être RED ou BLU pour changer d'équipe" - "hu" "Valamelyik csapatban kell lenni, hogy csere legyen" - } - "PlayerQueue" - { - "en" "You have been queued to swap teams on next death" - "fr" "Vous avez été mis en attente pour changer d'équipe lors de votre prochaine mort" - "hu" "A kovetkezo halalnal csapatcsere lesz" - } - "PlayerSwitched" - { - "en" "Your team has been switched" - } - "PlayerSwitched1" - { - "en" "Your team has been switched as requested" - "fr" "Vous avez changé d'équipe comme demandé" - "hu" "A keresnek eleget teve a csapatod meg lett csererlve" - } - "PlayerSwitched2" - { - "en" "Your team has been switched by an Admin" - "fr" "Vous avez été changé d'équipe par un admin" - "hu" "Az Admin megcserelte a csapatodat!" - } - "SwapTeamMsg" - { - "en" "Type /swapteam or !swapteam to swap your team!" - } - "PlayerSwitched3" - { - "#format" "{1:s}" - "en" "{1}'s team has been switched" - "fr" "{1} a changé d'équipe" - "hu" "{1} csapata meg lett cserelve" - } - "Scramble" - { - "en" "Teams are about to be scrambled!" - "fr" "Les équipes vont être rééquilibrés" - "hu" "A csapatok hamarosan meg lesznek keverve!" - } - "VoteScramble1" - { - "#format" "{1:i}{2:i}" - "en" "Vote Scramble successful with {1} votes out of {2}" - "fr" "Le vote d'équilibrage des équipes a réussi avec {1} votes pour sur {2}" - "hu" "A szavazas sikeres volt, {1} szavazat a keveresre a {2} -bol" - } - "VoteScramble2" - { - "#format" "{1:i}{2:i}" - "en" "Vote Scramble failed with {1} votes out of {2}" - "fr" "Le vote d'équilibrage a échoué avec {1} votes pour sur {2}" - "hu" "A szavazas sikertelen volt, {1} szavazat a keveresre a {2} -bol" - } - "VoteInProgress" - { - "en" "A vote is currently in progress" - "fr" "Un vote est actuellement en cours" - "hu" "Egy szavazas mar fut!" - } - "ScrambleTime" - { - "en" "A vote was recently made, please wait" - "fr" "Un vote a déjà été fait récemment, réessayez plus tard" - "hu" "Nemreg volt szavazas, kerlek varj egy kicsit!" - } -} \ No newline at end of file