Repurpose g_aSpawnedProps, and remove some no longer needed stuff
This commit is contained in:
@@ -27,7 +27,7 @@ ConVar g_cvNotifyShot;
|
||||
ConVar g_cvNotifyTimer;
|
||||
ConVar g_cvUseMode;
|
||||
|
||||
ArrayList g_aSpawnedProps; // Tracks entity indices of props spawned by this plugin so we can unhook them
|
||||
ArrayList g_aSpawnedProps; // Tracks entity indices of props spawned by this plugin
|
||||
ArrayList g_aNotifyList;
|
||||
|
||||
int g_aPlayerPropColor[MAXPLAYERS + 1][3];
|
||||
@@ -142,8 +142,6 @@ public void OnPluginStart()
|
||||
|
||||
g_aSpawnedProps = new ArrayList();
|
||||
g_aNotifyList = new ArrayList();
|
||||
|
||||
HookEvent("round_end", Event_RoundEnd);
|
||||
}
|
||||
|
||||
public void OnEntityCreated(int entity, const char[] classname)
|
||||
@@ -154,8 +152,6 @@ public void OnEntityCreated(int entity, const char[] classname)
|
||||
|
||||
public void OnEntityDestroyed(int entity)
|
||||
{
|
||||
// Safety net: if a tracked prop is removed by any means other than DeleteProp()
|
||||
// (e.g. an explosion, another plugin, map cleanup), stop tracking it here too.
|
||||
if (entity <= 0 || g_aSpawnedProps == null)
|
||||
return;
|
||||
|
||||
@@ -166,27 +162,6 @@ public void OnEntityDestroyed(int entity)
|
||||
}
|
||||
}
|
||||
|
||||
public void Event_RoundEnd(Event event, const char[] name, bool dontBroadcast)
|
||||
{
|
||||
UnhookAllSpawnedProps();
|
||||
}
|
||||
|
||||
void UnhookAllSpawnedProps()
|
||||
{
|
||||
if (g_aSpawnedProps == null || !g_cvNotifyShot.BoolValue)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < g_aSpawnedProps.Length; i++)
|
||||
{
|
||||
int prop = g_aSpawnedProps.Get(i);
|
||||
if (IsValidEntity(prop))
|
||||
{
|
||||
SDKUnhook(prop, SDKHook_OnTakeDamage, OnPropTakeDamage);
|
||||
}
|
||||
}
|
||||
g_aSpawnedProps.Clear();
|
||||
}
|
||||
|
||||
public void OnMapStart()
|
||||
{
|
||||
g_Models.Rewind();
|
||||
@@ -226,8 +201,6 @@ public void OnMapEnd()
|
||||
delete(g_NpcMenu);
|
||||
g_NpcMenu = null;
|
||||
}
|
||||
|
||||
UnhookAllSpawnedProps();
|
||||
}
|
||||
|
||||
/* ----------------------------------- */
|
||||
@@ -545,15 +518,6 @@ void DeleteProp(int client){
|
||||
GetEdictClassname(DeleteIndex, classname, sizeof(classname));
|
||||
if(isAProp(classname))
|
||||
{
|
||||
if (g_cvNotifyShot.BoolValue)
|
||||
{
|
||||
int propIndex = g_aSpawnedProps.FindValue(DeleteIndex);
|
||||
if (propIndex != -1)
|
||||
{
|
||||
SDKUnhook(DeleteIndex, SDKHook_OnTakeDamage, OnPropTakeDamage);
|
||||
g_aSpawnedProps.Erase(propIndex);
|
||||
}
|
||||
}
|
||||
AcceptEntityInput(DeleteIndex, "Kill", -1, -1, 0);
|
||||
ShowActivity2(client, "\x01[SM] \x04", "deleted a prop.");
|
||||
LogAction(client, -1, "\"%L\" deleted a prop.", client);
|
||||
@@ -719,15 +683,16 @@ void prop_any_create(int client)
|
||||
AcceptEntityInput(prop, "TurnOn", prop, prop, 0);
|
||||
AcceptEntityInput(prop, "EnableCollision");
|
||||
|
||||
// Hook the prop so we can detect when it gets shot/damaged, and track it so we can unhook later
|
||||
// Hook the prop so we can detect when it gets shot/damaged
|
||||
if (g_cvNotifyShot.BoolValue)
|
||||
{
|
||||
SetEntityFlags(prop, FL_CLIENT); //Now youre thinking with portals
|
||||
SetEntProp(prop, Prop_Data, "m_iTeamNum", CS_TEAM_CT); // So it works with filtered triggers
|
||||
SDKHook(prop, SDKHook_OnTakeDamage, OnPropTakeDamage);
|
||||
g_aSpawnedProps.Push(prop);
|
||||
}
|
||||
|
||||
g_aSpawnedProps.Push(prop);
|
||||
|
||||
SetEntityRenderMode(prop, RENDER_TRANSCOLOR);
|
||||
if (g_aPlayerPropColor[client][0] == 256) // Rainbow
|
||||
{
|
||||
@@ -932,7 +897,6 @@ MRESReturn PlayerUse_Hook(int pThis)
|
||||
{
|
||||
int entHit = TR_GetEntityIndex(tr);
|
||||
|
||||
// This currently only works if sm_propspawner_notify_shot is enabled
|
||||
if (g_aSpawnedProps.FindValue(entHit) != -1)
|
||||
{
|
||||
switch (g_cvUseMode.IntValue)
|
||||
@@ -981,11 +945,9 @@ bool UsePushFilter(int entity, int contentsMask)
|
||||
return true;
|
||||
}
|
||||
|
||||
// No convar for this one rn, didn't find it necessary
|
||||
MRESReturn ForceVPhysicsCollide_Hook(int pThis, DHookReturn hReturn, DHookParam hParams)
|
||||
{
|
||||
int ent = hParams.Get(1);
|
||||
// Also only works with sm_propspawner_notify_shot 1 cause of this
|
||||
if (g_aSpawnedProps.FindValue(ent) != -1)
|
||||
{
|
||||
hReturn.Value = false;
|
||||
|
||||
Reference in New Issue
Block a user