From 5484eec6124316381391695d8d06fc78d12cf3ce Mon Sep 17 00:00:00 2001 From: navewindre Date: Wed, 15 Nov 2023 22:04:53 +0100 Subject: onechance, one opportunity --- sourcemod/scripting/game_manager.sp | 66 +++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/sourcemod/scripting/game_manager.sp b/sourcemod/scripting/game_manager.sp index 5d0c250..ec6d198 100644 --- a/sourcemod/scripting/game_manager.sp +++ b/sourcemod/scripting/game_manager.sp @@ -2,6 +2,8 @@ #include #include #include +#include +#include #define PLUGIN_VERSION "1.0.0" #define MAX_FILE_LEN 80 @@ -15,6 +17,7 @@ public Plugin:myinfo = url = "networkheaven.net" }; +new g_oneChanceDone = false; new g_maxrounds; new g_roundCount; new bool:halftime; @@ -48,6 +51,7 @@ public OnConfigsExecuted(){ public OnPluginStart() { HookEvent("round_start", Event_RoundStart); HookEvent("round_end", Event_RoundEnd); + HookEvent("player_death", Event_PlayerDeath); g_h_mp_startmoney = FindConVar("mp_startmoney"); g_h_mp_maxrounds = FindConVar("mp_maxrounds"); @@ -60,6 +64,66 @@ public OnPluginStart() { SetFailState("m_iAccount offset not found"); } +public Event_PlayerDeath( Handle:event, const String:name[], bool dontBroadcast ) { + CreateTimer( 0.15, OneChance, 0 ); +} + +public Action:OneChance(Handle:timer, any:unused) { + if( g_roundCount != g_maxrounds ) + return; + + if( g_oneChanceDone ) + return; + + new ctAlive = 0; + new tAlive = 0; + + new clutcherT = 0; + new clutcherCT = 0; + + for( new i = 1; i <= MaxClients; ++i ) { + if( !IsClientInGame(i) || !IsPlayerAlive(i) ) + continue; + + new playerTeam = GetClientTeam(i); + if( playerTeam == CS_TEAM_CT ) { + ++ctAlive; + if( ctAlive > 1 ) + clutcherCT = 0; + else + clutcherCT = i; + } + else if( playerTeam == CS_TEAM_T ) { + ++tAlive; + if( tAlive > 1 ) + clutcherT = 0; + else + clutcherT = i; + } + } + + if( !(tAlive == 1 && ctAlive > 2) && !(ctAlive == 1 && tAlive > 2) ) + return; + + new clutcher = clutcherT ? clutcherT : clutcherCT; + decl String:clutcherName[64]; + GetClientName(clutcher, clutcherName, sizeof(clutcherName)); + + PrintToChatAll( "\x01%s \x04has one chance, one opportunity. will they seize it, or will they let it slip?", clutcherName ); + Client_RemoveAllWeapons( clutcher ); + Client_GiveWeapon( clutcher, "weapon_knife", true); + Client_GiveWeapon( clutcher, "weapon_awp", false); + Client_GiveWeapon( clutcher, "weapon_deagle", false); + GivePlayerItem( clutcher, "weapon_flashbang"); + GivePlayerItem( clutcher, "weapon_flashbang"); + + SetEntityHealth( clutcher, 100); + Client_SetArmor( clutcher, 100); + SetEntProp( clutcher, Prop_Send, "m_bHasHelmet", 1, 1); + + g_oneChanceDone = true; +} + // RoundStart gets the maptime // Checks to see if halftime has passed, if not then make sure halftime is 0 // Setting halftime false here as well since in some occasions when extending map @@ -69,6 +133,8 @@ public Event_RoundStart( Handle:event, const String:name[], bool:dontBroadcast ) new wepIdx; new playerTeam; + g_oneChanceDone = false; + g_CtScore = GetTeamScore(CS_TEAM_CT); g_TScore = GetTeamScore(CS_TEAM_T); -- cgit v1.2.3