Limited notify hud msg to 80 chars, limited it to once per frame and added a 2nd mode to sm_propspawner_notify_shot that will send the message to console instead
This commit is contained in:
@@ -134,7 +134,7 @@ public void OnPluginStart()
|
||||
RegAdminCmd("sm_propspawner", Command_MainMenu, ADMFLAG_CHANGEMAP); //g
|
||||
RegAdminCmd("sm_setpropcolor", Command_SetPropColor, ADMFLAG_CHANGEMAP, "Set PropSpawner color by RGB value, or \"rainbow\" for that.");
|
||||
|
||||
g_cvNotifyShot = CreateConVar("sm_propspawner_notify_shot", "0", "If set to 1, announces in chat when a plugin-spawned prop is shot.", FCVAR_NOTIFY, true, 0.0, true, 1.0);
|
||||
g_cvNotifyShot = CreateConVar("sm_propspawner_notify_shot", "0", "If set to 1, announces in chat when a plugin-spawned prop is shot.", FCVAR_NOTIFY, true, 0.0, true, 2.0);
|
||||
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.");
|
||||
@@ -724,18 +724,16 @@ public Action OnPropTakeDamage(int victim, int &attacker, int &inflictor, float
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
char g_szNotifyText[80];
|
||||
|
||||
void DisplayNotifyList()
|
||||
{
|
||||
static int channel = -1;
|
||||
static float lastDisplayTime = 0.0;
|
||||
if (g_cvNotifyShot.IntValue == 2)
|
||||
return;
|
||||
|
||||
// Change the channel every once in a while, to avoid conflicts with the map's game_text entities
|
||||
// (not really sure if sourcemod accounts for them when using -1 as channel but hopefully it does)
|
||||
if ((GetEngineTime() - lastDisplayTime) > g_cvNotifyTimer.FloatValue)
|
||||
channel = -1;
|
||||
static int tick = 0;
|
||||
|
||||
char text[255];
|
||||
strcopy(text, sizeof(text), "Shooting Couch:\n");
|
||||
strcopy(g_szNotifyText, sizeof(g_szNotifyText), "Shooting Couch:\n");
|
||||
|
||||
for (int i = g_aNotifyList.Length - 1; i >= 0; i--)
|
||||
{
|
||||
@@ -753,18 +751,16 @@ void DisplayNotifyList()
|
||||
|
||||
char clientName[32];
|
||||
GetClientName(buf.client, clientName, sizeof(clientName));
|
||||
StrCat(text, sizeof(text), clientName);
|
||||
StrCat(text, sizeof(text), "\n");
|
||||
StrCat(g_szNotifyText, sizeof(g_szNotifyText), clientName);
|
||||
StrCat(g_szNotifyText, sizeof(g_szNotifyText), "\n");
|
||||
}
|
||||
|
||||
SetHudTextParams(0.8, 0.2, g_cvNotifyTimer.FloatValue, 255, 255, 255, 255, 0, 0.0, 0.0, 0.0);
|
||||
for (int i = 1; i <= MaxClients; i++)
|
||||
if (tick != GetGameTickCount())
|
||||
{
|
||||
if (IsClientInGame(i))
|
||||
channel = ShowHudText(i, channel, text);
|
||||
// Wait a frame since other players might still shoot the couch this frame
|
||||
RequestFrame(DisplayNotifyList2);
|
||||
tick = GetGameTickCount();
|
||||
}
|
||||
|
||||
lastDisplayTime = GetEngineTime();
|
||||
}
|
||||
|
||||
void OnNotifyTimer(Handle timer, any data)
|
||||
@@ -830,6 +826,15 @@ void AddToNotifyList(int client)
|
||||
if (GetClientTeam(client) != CS_TEAM_CT)
|
||||
return;
|
||||
|
||||
// Just in case the buffer overflow in net message issue doesn't go away with the other fixes
|
||||
if (g_cvNotifyShot.IntValue == 2)
|
||||
{
|
||||
char clientName[32];
|
||||
GetClientName(client, clientName, sizeof(clientName));
|
||||
PrintToConsoleAll("[SM] %s is shooting the couch.", clientName);
|
||||
return;
|
||||
}
|
||||
|
||||
Handle timer = CreateTimer(g_cvNotifyTimer.FloatValue, OnNotifyTimer, client);
|
||||
int idx = FindInNotifyList(client);
|
||||
if (idx == -1)
|
||||
@@ -897,7 +902,7 @@ MRESReturn PlayerUse_Hook(int pThis)
|
||||
{
|
||||
int entHit = TR_GetEntityIndex(tr);
|
||||
|
||||
if (g_aSpawnedProps.FindValue(entHit) != -1)
|
||||
if (GetEntityMoveType(entHit) == MOVETYPE_VPHYSICS && g_aSpawnedProps.FindValue(entHit) != -1)
|
||||
{
|
||||
switch (g_cvUseMode.IntValue)
|
||||
{
|
||||
@@ -911,8 +916,11 @@ MRESReturn PlayerUse_Hook(int pThis)
|
||||
// Add to the shooting couch list
|
||||
case 2:
|
||||
{
|
||||
AddToNotifyList(pThis);
|
||||
DisplayNotifyList();
|
||||
if (g_cvNotifyShot.BoolValue)
|
||||
{
|
||||
AddToNotifyList(pThis);
|
||||
DisplayNotifyList();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -948,7 +956,7 @@ bool UsePushFilter(int entity, int contentsMask)
|
||||
MRESReturn ForceVPhysicsCollide_Hook(int pThis, DHookReturn hReturn, DHookParam hParams)
|
||||
{
|
||||
int ent = hParams.Get(1);
|
||||
if (g_aSpawnedProps.FindValue(ent) != -1)
|
||||
if (GetEntityMoveType(ent) == MOVETYPE_VPHYSICS && g_aSpawnedProps.FindValue(ent) != -1)
|
||||
{
|
||||
hReturn.Value = false;
|
||||
return MRES_Supercede;
|
||||
@@ -956,3 +964,23 @@ MRESReturn ForceVPhysicsCollide_Hook(int pThis, DHookReturn hReturn, DHookParam
|
||||
|
||||
return MRES_Ignored;
|
||||
}
|
||||
|
||||
void DisplayNotifyList2()
|
||||
{
|
||||
static int channel = -1;
|
||||
static float lastDisplayTime = 0.0;
|
||||
|
||||
// Change the channel every once in a while, to avoid conflicts with the map's game_text entities
|
||||
// (not really sure if sourcemod accounts for them when using -1 as channel but hopefully it does)
|
||||
if ((GetEngineTime() - lastDisplayTime) > (g_cvNotifyTimer.FloatValue * 2.0))
|
||||
channel = -1;
|
||||
|
||||
SetHudTextParams(0.8, 0.2, g_cvNotifyTimer.FloatValue, 255, 255, 255, 255, 0, 0.0, 0.0, 0.0);
|
||||
for (int i = 1; i <= MaxClients; i++)
|
||||
{
|
||||
if (IsClientInGame(i))
|
||||
channel = ShowHudText(i, channel, g_szNotifyText);
|
||||
}
|
||||
|
||||
lastDisplayTime = GetEngineTime();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user