Skip to content

Commit

Permalink
add game end enforcer based on rounds
Browse files Browse the repository at this point in the history
fixes #16
  • Loading branch information
B3none authored Aug 14, 2019
1 parent 1d95b84 commit 0aee49a
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion scripting/retakes_instadefuse.sp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Handle hEndIfTooLate = null;
Handle hDefuseIfTime = null;
Handle hInfernoDuration = null;
Handle hTimer_MolotovThreatEnd = null;
ConVar hMaxrounds = null;

Handle fw_OnInstantDefusePre = null;
Handle fw_OnInstantDefusePost = null;
Expand All @@ -24,7 +25,7 @@ public Plugin myinfo =
name = "[Retakes] Instant Defuse",
author = "B3none",
description = "Allows a CT to instantly defuse the bomb when all Ts are dead and nothing can prevent the defusal.",
version = "1.3.2",
version = "1.4.0",
url = "https://github.com/b3none"
}

Expand All @@ -39,10 +40,12 @@ public void OnPluginStart()

HookEvent("player_death", Event_AttemptInstantDefuse, EventHookMode_PostNoCopy);
HookEvent("round_start", Event_RoundStart, EventHookMode_PostNoCopy);
HookEvent("round_end", Event_RoundEnd, EventHookMode_PostNoCopy);

hInfernoDuration = CreateConVar("instant_defuse_inferno_duration", "7.0", "If Valve ever changed the duration of molotov, this cvar should change with it.");
hEndIfTooLate = CreateConVar("instant_defuse_end_if_too_late", "1.0", "End the round if too late.", _, true, 0.0, true, 1.0);
hDefuseIfTime = CreateConVar("instant_defuse_if_time", "1.0", "Instant defuse if there is time to do so.", _, true, 0.0, true, 1.0);
hMaxrounds = FindConVar("mp_maxrounds");

// Added the forwards to allow other plugins to call this one.
fw_OnInstantDefusePre = CreateGlobalForward("InstantDefuse_OnInstantDefusePre", ET_Event, Param_Cell, Param_Cell);
Expand All @@ -65,6 +68,14 @@ public Action Event_RoundStart(Handle event, const char[] name, bool dontBroadca
}
}

public Action Event_RoundEnd(Handle event, const char[] name, bool dontBroadcast)
{
if ((CS_GetTeamScore(CS_TEAM_T) + CS_GetTeamScore(CS_TEAM_CT)) >= hMaxrounds.IntValue)
{
ForceEnd();
}
}

public Action Event_BombPlanted(Handle event, const char[] name, bool dontBroadcast)
{
g_c4PlantTime = GetGameTime();
Expand Down Expand Up @@ -291,6 +302,13 @@ void Frame_EndRound(int team)

AcceptEntityInput(RoundEndEntity, "Kill");
}

void ForceEnd()
{
int gameEndEntity = CreateEntityByName("game_end");

AcceptEntityInput(gameEndEntity, "EndGame");
}

stock int GetDefusingPlayer()
{
Expand Down

0 comments on commit 0aee49a

Please sign in to comment.