Skip to content

Commit ad5a35e

Browse files
committed
Update 1.0
1 parent 29e6872 commit ad5a35e

File tree

4 files changed

+340
-0
lines changed

4 files changed

+340
-0
lines changed
9.63 KB
Binary file not shown.
Lines changed: 235 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,235 @@
1+
#pragma semicolon 1
2+
#include <clientprefs>
3+
4+
public Plugin myinfo =
5+
{
6+
name = "Shower of Health",
7+
version = "1.0",
8+
description = "Shower of your hp",
9+
author = "ღ λŌK0ЌЭŦ ღ ™",
10+
url = "https://github.com/IL0co"
11+
}
12+
13+
static const char SPACE[][][] = {{"", "", "", "", "", "", ""},
14+
{"", " ", " ", " ", " ", " ", " "},
15+
{"", " ", " ", " ", " ", " ", " "},
16+
{"", " ", " ", " ", " ", " ", " "},
17+
{"", " ", " ", " ", " ", " ", " "},
18+
{"", " ", " ", " ", " ", " ", " "},
19+
{"", " ", " ", " ", " ", " ", " "},
20+
{"", " ", " ", " ", " ", " ", " "}};
21+
22+
char oldValue[MAXPLAYERS+1][5][16];
23+
int iHealthNow[MAXPLAYERS+1];
24+
float iTime[MAXPLAYERS+1];
25+
26+
bool g_bHUD[MAXPLAYERS+1];
27+
28+
Handle g_hCookie, iHud, iTimer[MAXPLAYERS+1];
29+
30+
ConVar cvar_cCount,
31+
cvar_cType,
32+
cvar_cTimeClean,
33+
cvar_cTimeUpdate,
34+
cvar_cTypePoss,
35+
cvar_cHudColor,
36+
cvar_cHudPoss,
37+
cvar_cTimeHide,
38+
cvar_cEnable;
39+
40+
int cCount, cType, cTypePoss, cHudColor[4];
41+
float cTimeClean, cTimeUpdate, cHudPoss[2], cTimeHide;
42+
bool cEnable;
43+
44+
public void OnPluginStart()
45+
{
46+
iHud = CreateHudSynchronizer();
47+
g_hCookie = RegClientCookie("shower_health", "shower_health", CookieAccess_Private);
48+
SetCookieMenuItem(CreditsCookieHandler, 0, "shower_health");
49+
for(int i = 1; i <= MaxClients; i++) if(IsClientInGame(i) && IsClientAuthorized(i))
50+
OnClientCookiesCached(i);
51+
52+
(cvar_cEnable = CreateConVar("sm_shower_health_enable", "1", "RU: Включен ли плагин?\nEN: Enabled plugin?", _, true, 0.0, true, 1.0)).AddChangeHook(CVarChanged);
53+
cEnable = cvar_cEnable.BoolValue;
54+
55+
(cvar_cCount = CreateConVar("sm_shower_health_count", "5", "RU: Количество столбиков\nEN: Number of posts", _, true, 1.0, true, 5.0)).AddChangeHook(CVarChanged);
56+
cCount = cvar_cCount.IntValue;
57+
58+
(cvar_cType = CreateConVar("sm_shower_health_type", "2", "RU: На сколько смещать каждую новую строчку? (в пробелах)\nEN: How much to shift each new line? (in spaces)", _, true, 0.0, true, 7.0)).AddChangeHook(CVarChanged);
59+
cType = cvar_cType.IntValue;
60+
61+
(cvar_cTypePoss = CreateConVar("sm_shower_health_type_poss", "0", "RU: Куда уходит лесенка начиная от прицела?, 0 - в левый низ, 1 - в правый вверх, 2 - в правый низ, 3 - в левый вверх\nEN: Where does the ladder go from the sight ?, 0 - to the left bottom, 1 - to the right up, 2 - to the right bottom, 3 - to the left up", _, true, 0.0, true, 3.0)).AddChangeHook(CVarChanged);
62+
cTypePoss = cvar_cTypePoss.IntValue;
63+
64+
(cvar_cTimeClean = CreateConVar("sm_shower_health_clean_time", "2.0", "RU: Время очищения истории\nEN: History Cleansing Time", _, true, 0.1)).AddChangeHook(CVarChanged);
65+
cTimeClean = cvar_cTimeClean.FloatValue;
66+
67+
(cvar_cTimeUpdate = CreateConVar("sm_shower_health_update_time", "0.5", "Время проверки изменения хп. Требуется рестарт плагина!\nEN: Check time changes hp. Restart plugin required!", _, true, 0.1)).AddChangeHook(CVarChanged);
68+
cTimeUpdate = cvar_cTimeUpdate.FloatValue;
69+
70+
(cvar_cHudColor = CreateConVar("sm_shower_health_rgba", "255 0 255 255", "RU: RGBA цвет худа\nEN: RGBA color hud")).AddChangeHook(CVarChanged);
71+
SetHUDColor(cvar_cHudColor);
72+
73+
(cvar_cHudPoss = CreateConVar("sm_shower_health_poss", "0.38 0.5", "RU: XY позиция худа\nEN: XY hud position")).AddChangeHook(CVarChanged);
74+
SetHUDPosition(cvar_cHudPoss);
75+
76+
(cvar_cTimeHide = CreateConVar("sm_shower_health_hide_time", "2.0", "RU: Время скрытия худа\nEN: Hud hiding time", _, true, 0.1)).AddChangeHook(CVarChanged);
77+
cTimeHide = cvar_cTimeHide.FloatValue;
78+
79+
AutoExecConfig(true, "shower_health");
80+
81+
CreateTimer(cTimeUpdate, timerhealthOut, _, TIMER_REPEAT);
82+
LoadTranslations("shower_base.phrases");
83+
}
84+
85+
public void CVarChanged(ConVar cvar, const char[] oldVal, const char[] newVal)
86+
{
87+
if(cvar == cvar_cCount) cCount = cvar.IntValue;
88+
else if(cvar == cvar_cType) cType = cvar.IntValue;
89+
else if(cvar == cvar_cTypePoss) cTypePoss = cvar.IntValue;
90+
else if(cvar == cvar_cTimeClean) cTimeClean = cvar.FloatValue;
91+
else if(cvar == cvar_cTimeHide) cTimeHide = cvar.FloatValue;
92+
else if(cvar == cvar_cEnable) cEnable = cvar.BoolValue;
93+
else if(cvar == cvar_cHudColor) SetHUDColor(cvar);
94+
else if(cvar == cvar_cHudPoss) SetHUDPosition(cvar);
95+
}
96+
97+
public Action timerhealthOut(Handle timer)
98+
{
99+
if(!cEnable) return;
100+
for(int client = 1; client <= MaxClients; client++) if(IsClientInGame(client) && g_bHUD[client])
101+
{
102+
char textBuff[256];
103+
int currHealth, health;
104+
105+
health = GetEntProp(client, Prop_Send, "m_iHealth");
106+
currHealth = health-iHealthNow[client];
107+
108+
if(iHealthNow[client] != health || health != 100 && currHealth != 0)
109+
{
110+
iTime[client] = cTimeClean;
111+
iTimer[client] = CreateTimer(0.1, TimerDamege_Clean, GetClientUserId(client), TIMER_REPEAT);
112+
113+
if(health > iHealthNow[client]) Format(oldValue[client][0], sizeof(oldValue[][]), "+%i", currHealth);
114+
else Format(oldValue[client][0], sizeof(oldValue[][]), "%i", currHealth);
115+
116+
switch(cTypePoss)
117+
{
118+
case 0: Procc_Left_Down(client, textBuff, sizeof(textBuff));
119+
case 1: Procc_Right_Up(client, textBuff, sizeof(textBuff));
120+
case 2: Procc_Right_Down(client, textBuff, sizeof(textBuff));
121+
case 3: Procc_Left_Up(client, textBuff, sizeof(textBuff));
122+
}
123+
124+
for(int poss = cCount-1; poss > 0; poss--)
125+
oldValue[client][poss] = oldValue[client][poss-1];
126+
127+
SetHudTextParams(cHudPoss[0], cHudPoss[1], cTimeHide, cHudColor[0], cHudColor[1], cHudColor[2], cHudColor[3], 0, 0.0, 0.1, 0.1);
128+
ShowSyncHudText(client, iHud, textBuff);
129+
130+
iHealthNow[client] = health;
131+
}
132+
}
133+
}
134+
135+
public Action TimerDamege_Clean(Handle timer, any client)
136+
{
137+
client = GetClientOfUserId(client);
138+
139+
if(!client || !IsClientInGame(client) || iTimer[client] != timer)
140+
return Plugin_Stop;
141+
142+
if((iTime[client] -= 0.1) <= 0.0)
143+
{
144+
for(int poss = 0; poss < cCount; poss++)
145+
oldValue[client][poss][0] = '\0';
146+
147+
return Plugin_Stop;
148+
}
149+
150+
return Plugin_Continue;
151+
}
152+
153+
public void OnClientCookiesCached(int client)
154+
{
155+
char szValue[4];
156+
GetClientCookie(client, g_hCookie, szValue, sizeof(szValue));
157+
if(!szValue[0]) g_bHUD[client] = true;
158+
else g_bHUD[client] = view_as<bool>(StringToInt(szValue));
159+
}
160+
161+
public void CreditsCookieHandler(int client, CookieMenuAction action, any info, char[] buffer, int maxlen)
162+
{
163+
if(!cEnable) return;
164+
switch (action)
165+
{
166+
case CookieMenuAction_DisplayOption:
167+
{
168+
SetGlobalTransTarget(client);
169+
FormatEx(buffer, maxlen, "%t%t", g_bHUD[client] ? "Plus" : "Minus", "Health");
170+
}
171+
case CookieMenuAction_SelectOption:
172+
{
173+
if(g_bHUD[client]) SetClientCookie(client, g_hCookie, "0");
174+
else SetClientCookie(client, g_hCookie, "1");
175+
176+
g_bHUD[client] = !g_bHUD[client];
177+
178+
ShowCookieMenu(client);
179+
}
180+
}
181+
}
182+
183+
stock void Procc_Right_Up(int client, char[] textBuff, int size = 256)
184+
{
185+
for(int poss = cCount; poss > 0; poss--)
186+
{
187+
if(oldValue[client][poss-1][0])
188+
Format(textBuff, size, "%s\n%s%s", textBuff, SPACE[cType][poss], oldValue[client][poss-1]);
189+
else
190+
Format(textBuff, size, "%s\n%s", textBuff, SPACE[cType][poss]);
191+
}
192+
}
193+
194+
stock void Procc_Left_Down(int client, char[] textBuff, int size = 256)
195+
{
196+
for(int poss = 0, poss2 = cCount; poss < cCount; poss++, poss2--) if(oldValue[client][poss][0])
197+
{
198+
Format(textBuff, size, "%s\n%s%s", textBuff, SPACE[cType][poss2], oldValue[client][poss]);
199+
}
200+
}
201+
stock void Procc_Right_Down(int client, char[] textBuff, int size = 256)
202+
{
203+
for(int poss = 0, poss2 = cCount; poss < cCount; poss++, poss2--) if(oldValue[client][poss][0])
204+
{
205+
Format(textBuff, size, "%s\n%s%s", textBuff, SPACE[cType][poss], oldValue[client][poss]);
206+
}
207+
}
208+
209+
stock void Procc_Left_Up(int client, char[] textBuff, int size = 256)
210+
{
211+
for(int poss = 0, poss2 = cCount; poss < cCount; poss++, poss2--)
212+
{
213+
if(oldValue[client][poss2-1][0])
214+
Format(textBuff, size, "%s\n%s%s", textBuff, SPACE[cType][poss], oldValue[client][poss2-1]);
215+
else
216+
Format(textBuff, size, "%s\n%s", textBuff, SPACE[cType][poss]);
217+
}
218+
}
219+
220+
stock void SetHUDColor(ConVar cvar)
221+
{
222+
char buffer[16], clr[4][4];
223+
cvar.GetString(buffer, sizeof(buffer));
224+
ExplodeString(buffer, " ", clr, 4, 4);
225+
for(int i; i <= 3; i++) cHudColor[i] = StringToInt(clr[i]);
226+
}
227+
228+
stock void SetHUDPosition(ConVar cvar)
229+
{
230+
char buffer[16], pos[2][8];
231+
cvar.GetString(buffer, sizeof(buffer));
232+
ExplodeString(buffer, " ", pos, 2, 8);
233+
cHudPoss[0] = StringToFloat(pos[0]);
234+
cHudPoss[1] = StringToFloat(pos[1]);
235+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
"Phrases"
2+
{
3+
"Plus"
4+
{
5+
"en" "[ + ] "
6+
}
7+
"Minus"
8+
{
9+
"en" "[ - ] "
10+
}
11+
"Health"
12+
{
13+
"en" "Ladder of health"
14+
"ru" "Лестница здоровья"
15+
"ua" "Сходи здоров’я"
16+
}
17+
"Armor"
18+
{
19+
"en" "Ladder of armor"
20+
"ru" "Лестница брони"
21+
"ua" "Сходи броні"
22+
}
23+
"Damage"
24+
{
25+
"en" "Ladder of damage"
26+
"ru" "Лестница ущерба"
27+
"ua" "Драбина пошкодження"
28+
}
29+
"Killed"
30+
{
31+
"en" "KILLED"
32+
"ru" "УБИЛ"
33+
"ua" "УБИЛ"
34+
}
35+
}

cfg/sourcemod/shower_health.cfg

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// This file was auto-generated by SourceMod (v1.10.0.6422)
2+
// ConVars for plugin "shower_health.smx"
3+
4+
5+
// RU: Время очищения истории
6+
// EN: History Cleansing Time
7+
// -
8+
// Default: "2.0"
9+
// Minimum: "0.100000"
10+
sm_shower_health_clean_time "2.0"
11+
12+
// RU: Количество столбиков
13+
// EN: Number of posts
14+
// -
15+
// Default: "5"
16+
// Minimum: "1.000000"
17+
// Maximum: "5.000000"
18+
sm_shower_health_count "5"
19+
20+
// RU: Включен ли плагин?
21+
// EN: Enabled plugin?
22+
// -
23+
// Default: "1"
24+
// Minimum: "0.000000"
25+
// Maximum: "1.000000"
26+
sm_shower_health_enable "1"
27+
28+
// RU: Время скрытия худа
29+
// EN: Hud hiding time
30+
// -
31+
// Default: "2.0"
32+
// Minimum: "0.100000"
33+
sm_shower_health_hide_time "2.0"
34+
35+
// RU: XY позиция худа
36+
// EN: XY hud position
37+
// -
38+
// Default: "0.38 0.5"
39+
sm_shower_health_poss "0.38 0.5"
40+
41+
// RU: RGBA цвет худа
42+
// EN: RGBA color hud
43+
// -
44+
// Default: "255 0 255 255"
45+
sm_shower_health_rgba "255 0 255 255"
46+
47+
// RU: На сколько смещать каждую новую строчку? (в пробелах)
48+
// EN: How much to shift each new line? (in spaces)
49+
// -
50+
// Default: "2"
51+
// Minimum: "0.000000"
52+
// Maximum: "7.000000"
53+
sm_shower_health_type "2"
54+
55+
// RU: Куда уходит лесенка начиная от прицела?, 0 - в левый низ, 1 - в правый вверх, 2 - в правый низ, 3 - в левый вверх
56+
// EN: Where does the ladder go from the sight ?, 0 - to the lef
57+
// -
58+
// Default: "0"
59+
// Minimum: "0.000000"
60+
// Maximum: "3.000000"
61+
sm_shower_health_type_poss "0"
62+
63+
// Время проверки изменения хп. Требуется рестарт плагина!
64+
// EN: Check time changes hp. Restart plugin required!
65+
// -
66+
// Default: "0.5"
67+
// Minimum: "0.100000"
68+
sm_shower_health_update_time "0.5"
69+
70+

0 commit comments

Comments
 (0)