Skip to content

Commit

Permalink
Add l4d2_no_skip_getup_animation plugin and update shared_plugins.cfg
Browse files Browse the repository at this point in the history
  • Loading branch information
altair-sossai committed Sep 11, 2024
1 parent f0e3626 commit 9c056ed
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 0 deletions.
Binary file not shown.
81 changes: 81 additions & 0 deletions addons/sourcemod/scripting/l4d2_no_skip_getup_animation.sp
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#pragma semicolon 1
#pragma newdecls required

#include <sourcemod>

#define TEAM_SPECTATOR 1
#define TEAM_SURVIVOR 2

#define DELAY_TIME_IN_SECONDS 5.0

float LastDamageReceivedOn[MAXPLAYERS + 1];

public Plugin myinfo =
{
name = "L4D2 - No Skip Getup Animation",
author = "Altair Sossai",
description = "Prevents players from skipping the getup animation",
version = "1.0.0",
url = "https://github.com/SirPlease/L4D2-Competitive-Rework"
};

public void OnPluginStart()
{
AddCommandListener(Spectate_Callback, "sm_spectate");
AddCommandListener(Spectate_Callback, "sm_spec");
AddCommandListener(Spectate_Callback, "sm_s");
AddCommandListener(JoinTeam_Callback, "jointeam");

HookEvent("round_start", RoundStart_Event);
HookEvent("player_hurt", PlayerHurt_Event);

ClearLastDamageReceivedOn();
}

Action Spectate_Callback(int client, char[] command, int args)
{
return CanGoToSpec(client) ? Plugin_Continue : Plugin_Handled;
}

Action JoinTeam_Callback(int client, char[] command, int args)
{
if (args == 0)
return Plugin_Continue;

char buffer[128];
GetCmdArg(1, buffer, sizeof(buffer));

if (StrEqual("Survivors", buffer, false) || StrEqual("2", buffer, false))
return Plugin_Continue;

return CanGoToSpec(client) ? Plugin_Continue : Plugin_Handled;
}

void RoundStart_Event(Handle event, const char[] name, bool dontBroadcast)
{
ClearLastDamageReceivedOn();
}

void PlayerHurt_Event(Event event, const char[] name, bool dontBroadcast)
{
int client = GetClientOfUserId(GetEventInt(event, "userid"));

if (client <= 0 || client > MaxClients || !IsClientInGame(client) || GetClientTeam(client) != TEAM_SURVIVOR)
return;

LastDamageReceivedOn[client] = GetEngineTime();
}

void ClearLastDamageReceivedOn()
{
for (int i = 1; i <= MaxClients; i++)
LastDamageReceivedOn[i] = 0.0;
}

bool CanGoToSpec(int client)
{
if (GetClientTeam(client) != TEAM_SURVIVOR)
return true;

return (GetEngineTime() - LastDamageReceivedOn[client]) >= DELAY_TIME_IN_SECONDS;
}
1 change: 1 addition & 0 deletions cfg/cfgogl/zonemod/shared_plugins.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ sm plugins load optional/l4d2_playstats_sync.smx
sm plugins load optional/l4d2_ranking.smx
sm plugins load optional/l4d2_show_patent_icon.smx
sm plugins load optional/l4d2_localhost.smx
sm plugins load optional/l4d2_no_skip_getup_animation.smx

// Letzzzz go.
sm plugins load confoglcompmod.smx
Expand Down

0 comments on commit 9c056ed

Please sign in to comment.