Added sm_propspawner_tier_requirement and sm_propspawner_button_tier_requirement
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include <sdkhooks>
|
||||
#include <dhooks>
|
||||
#include <cstrike>
|
||||
#include <unloze_playtime>
|
||||
|
||||
public Plugin myinfo =
|
||||
{
|
||||
@@ -26,6 +27,8 @@ KeyValues g_Models;
|
||||
ConVar g_cvNotifyShot;
|
||||
ConVar g_cvNotifyTimer;
|
||||
ConVar g_cvUseMode;
|
||||
ConVar g_cvPropShootTier;
|
||||
ConVar g_cvButtonPressTier;
|
||||
|
||||
ArrayList g_aSpawnedProps; // Tracks entity indices of props spawned by this plugin
|
||||
ArrayList g_aNotifyList;
|
||||
@@ -138,6 +141,8 @@ public void OnPluginStart()
|
||||
g_cvNotifyTimer = CreateConVar("sm_propspawner_notify_shot_timer", "0.5", "How long a player stays in the \"shooting couch\" list.");
|
||||
g_cvUseMode = CreateConVar("sm_propspawner_use_mode", "0", "What should happen when a prop is +use'd. " ...
|
||||
"0 = Normal. 1 = Disallow CTs moving plugin spawned props. 2 = Add player to notify list.");
|
||||
g_cvPropShootTier = CreateConVar("sm_propspawner_tier_requirement", "-1", "Tier needed for players to be able to move PropSpawner props.");
|
||||
g_cvButtonPressTier = CreateConVar("sm_propspawner_button_tier_requirement", "-1", "Tier needed for players to be able to press buttons.");
|
||||
AutoExecConfig(true, "PropSpawner");
|
||||
|
||||
g_aSpawnedProps = new ArrayList();
|
||||
@@ -147,7 +152,13 @@ public void OnPluginStart()
|
||||
public void OnEntityCreated(int entity, const char[] classname)
|
||||
{
|
||||
if (StrEqual(classname, "func_clip_vphysics") && g_ForceVPhysicsCollideSetup != INVALID_HANDLE)
|
||||
{
|
||||
DHookEntity(g_ForceVPhysicsCollideSetup, false, entity);
|
||||
}
|
||||
else if (StrEqual(classname, "func_button") && g_cvButtonPressTier.IntValue > -1)
|
||||
{
|
||||
SDKHook(entity, SDKHook_Use, OnButtonUse);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnEntityDestroyed(int entity)
|
||||
@@ -684,7 +695,7 @@ void prop_any_create(int client)
|
||||
AcceptEntityInput(prop, "EnableCollision");
|
||||
|
||||
// Hook the prop so we can detect when it gets shot/damaged
|
||||
if (g_cvNotifyShot.BoolValue)
|
||||
if (g_cvNotifyShot.BoolValue || g_cvPropShootTier.IntValue > -1)
|
||||
{
|
||||
SetEntityFlags(prop, FL_CLIENT); //Now youre thinking with portals
|
||||
SetEntProp(prop, Prop_Data, "m_iTeamNum", CS_TEAM_CT); // So it works with filtered triggers
|
||||
@@ -712,10 +723,13 @@ void prop_any_create(int client)
|
||||
|
||||
public Action OnPropTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype, int &weapon, float damageForce[3], float damagePosition[3], int damagecustom)
|
||||
{
|
||||
if (!g_cvNotifyShot.BoolValue)
|
||||
if (attacker < 1 || attacker > MaxClients || !IsClientInGame(attacker))
|
||||
return Plugin_Continue;
|
||||
|
||||
if (attacker < 1 || attacker > MaxClients || !IsClientInGame(attacker))
|
||||
if (GetClientTeam(client) == CS_TEAM_CT && GetPlayerTier_native(attacker) < g_cvPropShootTier.IntValue)
|
||||
return Plugin_Handled;
|
||||
|
||||
if (!g_cvNotifyShot.BoolValue)
|
||||
return Plugin_Continue;
|
||||
|
||||
AddToNotifyList(attacker);
|
||||
@@ -874,7 +888,7 @@ MRESReturn PlayerUse_Hook(int pThis)
|
||||
if (!sv_turbophysics.BoolValue)
|
||||
return MRES_Ignored;
|
||||
|
||||
if (g_cvUseMode.IntValue != 1 && g_cvUseMode.IntValue != 2)
|
||||
if (g_cvUseMode.IntValue != 1 && g_cvUseMode.IntValue != 2 && g_cvPropShootTier.IntValue <= -1)
|
||||
return MRES_Ignored;
|
||||
|
||||
// ZMs can always push it
|
||||
@@ -904,7 +918,11 @@ MRESReturn PlayerUse_Hook(int pThis)
|
||||
|
||||
if (GetEntityMoveType(entHit) == MOVETYPE_VPHYSICS && g_aSpawnedProps.FindValue(entHit) != -1)
|
||||
{
|
||||
switch (g_cvUseMode.IntValue)
|
||||
int mode = g_cvUseMode.IntValue;
|
||||
if (GetPlayerTier_native(pThis) < g_cvPropShootTier.IntValue)
|
||||
mode = 1;
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
// Prevent the prop from being moved
|
||||
case 1:
|
||||
@@ -984,3 +1002,15 @@ void DisplayNotifyList2()
|
||||
|
||||
lastDisplayTime = GetEngineTime();
|
||||
}
|
||||
|
||||
// To prevent people from early triggering on couch events. Not every map uses buttons for triggers however.
|
||||
Action OnButtonUse(int entity, int activator, int caller, UseType type, float value)
|
||||
{
|
||||
if (activator < 1 || activator > MaxClients || !IsClientInGame(activator))
|
||||
return Plugin_Continue;
|
||||
|
||||
if (GetClientTeam(client) == CS_TEAM_CT && GetPlayerTier_native(activator) < g_cvButtonPressTier.IntValue)
|
||||
return Plugin_Handled;
|
||||
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user