Skip to content

Commit

Permalink
Merge branch 'SirPlease:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
altair-sossai authored Dec 15, 2024
2 parents b201710 + b568e81 commit c83b888
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 71 deletions.
76 changes: 22 additions & 54 deletions addons/sourcemod/scripting/blockheatseekingchargers.sp
Original file line number Diff line number Diff line change
Expand Up @@ -14,73 +14,41 @@

#include <sourcemod>

#define PL_VERSION "1.2.1"

bool
IsInCharge[MAXPLAYERS + 1] = {false, ...};
#define PL_VERSION "1.3.2"

public Plugin myinfo =
{
name = "Blocks heatseeking chargers",
description = "Blocks heatseeking chargers",
author = "sheo",
author = "sheo, A1m`",
version = PL_VERSION,
url = "https://github.com/SirPlease/L4D2-Competitive-Rework"
}
};

public void OnPluginStart()
{
CreateConVar("l4d2_block_heatseeking_chargers_version", PL_VERSION, "Block heatseeking chargers fix version");

HookEvent("player_bot_replace", BotReplacesPlayer);
HookEvent("charger_charge_start", Event_ChargeStart);
HookEvent("charger_charge_end", Event_ChargeEnd);
HookEvent("player_spawn", Event_OnPlayerSpawn);
HookEvent("player_death", Event_OnPlayerDeath);

HookEvent("round_start", Event_Reset, EventHookMode_PostNoCopy);
HookEvent("round_end", Event_Reset, EventHookMode_PostNoCopy);
HookEvent("player_bot_replace", Event_PlayerBotReplace);
}

void ResetArray()
void Event_PlayerBotReplace(Event hEvent, const char[] sEntityName, bool bDontBroadcast)
{
for (int i = 0; i <= MaxClients; i++) {
IsInCharge[i] = false;
int iBot = GetClientOfUserId(hEvent.GetInt("bot"));
if (iBot < 1) {
return;
}
}

void Event_Reset(Event hEvent, const char[] sEntityName, bool bDontBroadcast)
{
ResetArray();
}

void Event_ChargeStart(Event hEvent, const char[] sEntityName, bool bDontBroadcast)
{
IsInCharge[GetClientOfUserId(hEvent.GetInt("userid"))] = true;
}

void Event_ChargeEnd(Event hEvent, const char[] sEntityName, bool bDontBroadcast)
{
IsInCharge[GetClientOfUserId(hEvent.GetInt("userid"))] = false;
}

void BotReplacesPlayer(Event hEvent, const char[] sEntityName, bool bDontBroadcast)
{
int iClient = GetClientOfUserId(hEvent.GetInt("player"));
if (iClient > 0 && IsInCharge[iClient]) {
int iBot = GetClientOfUserId(hEvent.GetInt("bot"));


int iAbility = GetEntPropEnt(iBot, Prop_Send, "m_customAbility");
if (iAbility == -1) {
return;
}

char sAbilityName[64];
GetEntityClassname(iAbility, sAbilityName, sizeof(sAbilityName));
if (strcmp(sAbilityName, "ability_charge") != 0) {
return;
}

if (GetEntProp(iAbility, Prop_Send, "m_isCharging", 1) > 0) {
SetEntityFlags(iBot, GetEntityFlags(iBot) | FL_FROZEN);
IsInCharge[iClient] = false;
}
}

void Event_OnPlayerSpawn(Event hEvent, const char[] sEntityName, bool bDontBroadcast)
{
IsInCharge[GetClientOfUserId(hEvent.GetInt("userid"))] = false;
}

void Event_OnPlayerDeath(Event hEvent, const char[] sEntityName, bool bDontBroadcast)
{
IsInCharge[GetClientOfUserId(hEvent.GetInt("userid"))] = false;
}
}
38 changes: 21 additions & 17 deletions addons/sourcemod/scripting/sv_consistency_fix.sp
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,20 @@
#pragma newdecls required

#include <sourcemod>
#include <colors>

bool
g_bIsEventHook;
g_bIsEventHook = false;

ConVar
g_hCvarServerMessageToggle,
g_hCvarServerWelcomeMessage;
g_hCvarServerMessageToggle = null,
g_hCvarServerWelcomeMessage = null;

public Plugin myinfo =
{
name = "sv_consistency fixes",
author = "step, Sir, A1m`",
description = "Fixes multiple sv_consistency issues.",
version = "1.4.1",
version = "1.4.3",
url = "https://github.com/SirPlease/L4D2-Competitive-Rework/"
};

Expand All @@ -26,7 +25,7 @@ public void OnPluginStart()
SetFailState("Couldn't find whitelist.cfg");
}

g_hCvarServerMessageToggle = g_hCvarServerWelcomeMessage = CreateConVar( \
g_hCvarServerMessageToggle = CreateConVar( \
"svctyfix_message_enable", \
"1.0", \
"Enable print message in console when player join.", \
Expand All @@ -46,12 +45,12 @@ public void OnPluginStart()
FCVAR_REPLICATED \
);

hConsistencyCheckInterval.SetInt(999999);

ToggleMessage();
g_hCvarServerMessageToggle.AddChangeHook(Cvar_Changed);

RegAdminCmd("sm_consistencycheck", Cmd_ConsistencyCheck, ADMFLAG_RCON, "Performs a consistency check on all players.");

hConsistencyCheckInterval.SetInt(999999);

LoadTranslations("common.phrases"); // Load translations (for targeting player)
}
Expand All @@ -63,11 +62,13 @@ void ToggleMessage()
HookEvent("player_connect_full", Event_PlayerConnectFull, EventHookMode_Post);
g_bIsEventHook = true;
}
} else {
if (g_bIsEventHook) {
UnhookEvent("player_connect_full", Event_PlayerConnectFull, EventHookMode_Post);
g_bIsEventHook = false;
}

return;
}

if (g_bIsEventHook) {
UnhookEvent("player_connect_full", Event_PlayerConnectFull, EventHookMode_Post);
g_bIsEventHook = false;
}
}

Expand All @@ -76,9 +77,9 @@ void Cvar_Changed(ConVar hConVar, const char[] sOldValue, const char[] sNewValue
ToggleMessage();
}

public void OnClientConnected(int client)
public void OnClientConnected(int iClient)
{
ClientCommand(client, "cl_consistencycheck");
ClientCommand(iClient, "cl_consistencycheck");
}

void Event_PlayerConnectFull(Event hEvent, const char[] sEventName, bool bDontBroadcast)
Expand Down Expand Up @@ -108,16 +109,19 @@ Action PrintWhitelist(Handle hTimer, any iUserId)
PrintToConsole(iClient, " ");
PrintToConsole(iClient, " ");
}

return Plugin_Stop;
}

Action Cmd_ConsistencyCheck(int iClient, int iArgs)
{
if (iArgs < 1) {
for (int i = 1; i <= MaxClients; i++) {
if (IsClientInGame(i) && !IsFakeClient(i)) {
ClientCommand(i, "cl_consistencycheck");
if (!IsClientInGame(i) || IsFakeClient(i)) {
continue;
}

ClientCommand(i, "cl_consistencycheck");
}

ReplyToCommand(iClient, "Started checking the consistency of files for all players!");
Expand Down

0 comments on commit c83b888

Please sign in to comment.