This repository has been archived by the owner on Jul 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
bhuddebugger.sp
82 lines (65 loc) · 2.31 KB
/
bhuddebugger.sp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#define PLUGIN_NAME "Bhud Debugger"
#define PLUGIN_AUTHOR "Snowy"
#define PLUGIN_DESCRIPTION "Shows the func_physbox/func_physbox_multiplayer/func_breakable/math_counter you are shooting at"
#define PLUGIN_VERSION "1.0"
#define PLUGIN_URL "https://github.com/gflclan-cs-go-ze/"
#include <sourcemod>
#include <sdktools>
#pragma semicolon 1
#pragma newdecls required
ConVar g_cBHUDenabled = null;
bool g_bBHUDenabled;
public Plugin myinfo =
{
name = PLUGIN_NAME,
author = PLUGIN_AUTHOR,
description = PLUGIN_DESCRIPTION,
version = PLUGIN_VERSION,
url = PLUGIN_URL
};
public void OnPluginStart()
{
g_cBHUDenabled = CreateConVar("bhud_debug", "1", "Enables/Disables debugging ent names");
HookEntityOutput("func_physbox", "OnHealthChanged", OnHealthChanged);
HookEntityOutput("func_physbox_multiplayer", "OnHealthChanged", OnHealthChanged);
HookEntityOutput("func_breakable", "OnHealthChanged", OnHealthChanged);
HookEntityOutput("math_counter", "OutValue", CounterOutValue);
g_cBHUDenabled.AddChangeHook(ConVarChange);
g_bBHUDenabled = g_cBHUDenabled.BoolValue;
}
public void ConVarChange(ConVar CVar, const char[] oldVal, const char[] newVal)
{
g_bBHUDenabled = g_cBHUDenabled.BoolValue;
}
public void OnHealthChanged(const char[] output, int entity, int activator, float delay)
{
if (activator > 0)
{
char targetname[32];
int HPvalue;
GetEntPropString(entity, Prop_Data, "m_iName", targetname, sizeof(targetname));
HPvalue = GetEntProp(entity, Prop_Data, "m_iHealth");
if(strlen(targetname) == 0)
Format(targetname, sizeof(targetname), "This Ent has no name!");
if (g_bBHUDenabled)
{
PrintToChatAll(" \x04Breakable: \x10%s \x04HP: \x10%d", targetname, HPvalue);
}
}
}
public void CounterOutValue(const char[] output, int entity, int activator, float delay)
{
if ((IsValidEntity(entity) || IsValidEdict(entity)) && activator > 0)
{
char targetname[32];
int HPvalue;
GetEntPropString(entity, Prop_Data, "m_iName", targetname, sizeof(targetname));
HPvalue = RoundToNearest(GetEntDataFloat(entity, FindDataMapInfo(entity, "m_OutValue")));
if(strlen(targetname) == 0)
Format(targetname, sizeof(targetname), "This Ent has no name!");
if (g_bBHUDenabled)
{
PrintToChatAll(" \x04MathCounter: \x10%s \x04HP: \x10%d", targetname, HPvalue);
}
}
}