-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscrollhud.sp
More file actions
197 lines (159 loc) · 5.05 KB
/
scrollhud.sp
File metadata and controls
197 lines (159 loc) · 5.05 KB
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
#include <clientprefs>
#include <sdkhooks>
#include <sdktools>
#include <sourcemod>
#include <bhopstats>
#include <shavit/core>
#pragma semicolon 1
#pragma newdecls required
#define PLUGIN_VERSION "1337"
int g_iEarlyTicks[MAXPLAYERS + 1];
int g_iLateTicks[MAXPLAYERS + 1];
int g_iPerfed[MAXPLAYERS + 1];
int g_iFlopped[MAXPLAYERS + 1]; // av🥑cado — Today at 6:27 PM Okay, I, as the authority on scroll, have decided to call it a "flop".
int g_iGroundTicks[MAXPLAYERS + 1];
int g_iLastCmdnumOrSomeShit[MAXPLAYERS + 1]; // my brain is fried rn and i can't think of any way to do this properly
float g_fLastY[MAXPLAYERS + 1];
bool g_bJumped[MAXPLAYERS + 1];
bool g_bPostJump[MAXPLAYERS + 1];
bool g_bSecondHalfOfJump[MAXPLAYERS + 1];
bool g_bEarlyTicksResetable[MAXPLAYERS + 1];
Handle g_hScrollHudEnabled;
public Plugin myinfo =
{
name = "scroll hud",
author = "may",
description = "i love kaworu",
version = PLUGIN_VERSION,
url = "Your website URL/AlliedModders profile URL"
};
public void OnPluginStart()
{
RegConsoleCmd("sm_scrollhud", Command_ScrollHud, "i'm gay");
HookEvent("player_jump", Event_PlayerJump, EventHookMode);
g_hScrollHudEnabled = RegClientCookie("scrollhud_enabled", "Scroll Hud Enabled", CookieAccess_Protected);
}
public Action Command_ScrollHud(int client, int args)
{
if (AreClientCookiesCached(client))
{
char sCookieValue[12];
GetClientCookie(client, g_hScrollHudEnabled, sCookieValue, sizeof(sCookieValue));
int cookieValue = StringToInt(sCookieValue);
switch (cookieValue)
{
case 0:
{
cookieValue++;
Shavit_PrintToChat(client, "Scroll Hud has been enabled.");
}
case 1:
{
cookieValue--;
Shavit_PrintToChat(client, "Scroll Hud has been disabled.");
}
}
IntToString(cookieValue, sCookieValue, sizeof(sCookieValue));
SetClientCookie(client, g_hScrollHudEnabled, sCookieValue);
}
return Plugin_Handled;
}
public Action OnPlayerRunCmd(int client, int& buttons, int& impulse, float vel[3], float angles[3], int& weapon, int& subtype, int& cmdnum, int& tickcount, int& seed, int mouse[2])
{
if (DoScrollhud(client))
{
if (Bunnyhop_IsOnGround(client))
{
g_iGroundTicks[client]++;
}
float pos[3];
GetEntPropVector(client, Prop_Data, "m_vecOrigin", pos);
if (g_fLastY[client] > pos[2])
{
g_bSecondHalfOfJump[client] = true;
if (!(g_iLastCmdnumOrSomeShit[client] == cmdnum - 1))
{
g_bEarlyTicksResetable[client] = true;
}
g_iLastCmdnumOrSomeShit[client] = cmdnum;
}
if (buttons & IN_JUMP)
{
if (!g_bJumped[client] && g_bSecondHalfOfJump[client])
{
if (g_bEarlyTicksResetable[client])
{
g_iEarlyTicks[client] = 0;
g_bEarlyTicksResetable[client] = false;
}
g_iEarlyTicks[client]++;
}
if (!g_bSecondHalfOfJump[client])
{
g_iLateTicks[client]++;
}
if (g_bJumped[client])
{
g_iLateTicks[client] = 0;
g_bJumped[client] = false;
}
}
if (cmdnum % 5 == 0)
{
char secondln[32];
if (g_iLateTicks[client] > g_iEarlyTicks[client]) Format(secondln, sizeof(secondln), "Late (%i | %i)", g_iEarlyTicks[client], g_iLateTicks[client]);
else if (g_iEarlyTicks[client] > g_iLateTicks[client]) Format(secondln, sizeof(secondln), "Early (%i | %i)", g_iEarlyTicks[client], g_iLateTicks[client]);
else Format(secondln, sizeof(secondln), "Perfect (%i | %i)", g_iEarlyTicks[client], g_iLateTicks[client]);
if (g_iFlopped[client])
{
SetHudTextParams(-1.0, 0.4, GetTickInterval() * 5, 220, 20, 60, 255, 0, 0.0, 0.0);
ShowHudText(client, 5, "Flop (%i)\n%s", g_iFlopped[client], secondln);
}
else if (g_iPerfed[client])
{
SetHudTextParams(-1.0, 0.4, GetTickInterval() * 5, 0, 191, 255, 255, 0, 0.0, 0.0);
ShowHudText(client, 5, "Perf (%i)\n%s", g_iPerfed[client], secondln);
}
else
{
SetHudTextParams(-1.0, 0.4, GetTickInterval() * 5, 255, 255, 255, 255, 0, 0.0, 0.0);
ShowHudText(client, 5, "N/A");
}
}
g_fLastY[client] = pos[2];
}
}
public Action Event_PlayerJump(Event event, const char[] name, bool dontBroadcast)
{
int client = GetClientOfUserId(event.GetInt("userid"));
if (DoScrollhud(client))
{
g_bJumped[client] = true;
g_bPostJump[client] = true;
g_bSecondHalfOfJump[client] = false;
if (g_iGroundTicks[client] == 1)
{
g_iFlopped[client] = 0;
g_iPerfed[client]++;
}
else
{
g_iPerfed[client] = 0;
g_iFlopped[client]++;
}
CreateTimer(0.32, Timer_ResetJumpBool, client);
g_iGroundTicks[client] = 0;
}
}
public Action Timer_ResetJumpBool(Handle timer, int client)
{
g_bPostJump[client] = false;
}
bool DoScrollhud(int client)
{
char sCookieValue[12];
GetClientCookie(client, g_hScrollHudEnabled, sCookieValue, sizeof(sCookieValue));
int cookieValue = StringToInt(sCookieValue);
if (cookieValue && !Shavit_GetStyleSettingBool(Shavit_GetBhopStyle(client), "autobhop")) return true;
else return false;
}