-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathshavit-groundticks.sp
77 lines (60 loc) · 2.34 KB
/
shavit-groundticks.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
#include <sourcemod>
#include <shavit>
#include <clientprefs>
public Plugin myinfo =
{
name = "[shavit] On Ground Ticks",
author = "appa",
description = "",
version = "1.0",
url = ""
}
bool gB_GroundTicksEnabled[MAXPLAYERS + 1];
bool gB_PlayerInZone[MAXPLAYERS + 1];
int gI_GroundTicks[MAXPLAYERS + 1];
Handle gH_GroundTicksCookie;
public void OnPluginStart()
{
RegConsoleCmd("sm_groundticks", Command_GroundTicks, "Toggles Ground Ticks Printing");
gH_GroundTicksCookie = RegClientCookie("GroundTicks_Enabled", "Ground Ticks Enabled", CookieAccess_Protected);
HookEvent("player_jump", OnPlayerJump);
}
public void OnClientCookiesCached(int client)
{
char sCookie[8];
GetClientCookie(client,gH_GroundTicksCookie, sCookie, sizeof(sCookie));
gB_GroundTicksEnabled[client] = view_as<bool>(StringToInt(sCookie));
}
public Action Command_GroundTicks(int client, int args)
{
gB_GroundTicksEnabled[client] = !gB_GroundTicksEnabled[client];
char sCookie[8];
IntToString(gB_GroundTicksEnabled[client], sCookie, sizeof(sCookie));
SetClientCookie(client, gH_GroundTicksCookie, sCookie);
Shavit_PrintToChat(client, "Ground Ticks %s.", gB_GroundTicksEnabled[client] ? "Enabled" : "Disabled");
}
public void Shavit_OnEnterZone(int client, int type, int track, int id, int entity, int data)
{
gB_PlayerInZone[client] = true;
gI_GroundTicks[client] = 0;
}
public void Shavit_OnLeaveZone(int client, int type, int track, int id, int entity, int data)
{
gB_PlayerInZone[client] = false;
}
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(gB_GroundTicksEnabled[client] && !gB_PlayerInZone[client] && !(buttons & IN_JUMP) && (GetEntityFlags(client) & FL_ONGROUND))
{
gI_GroundTicks[client]++;
}
}
public Action OnPlayerJump(Event event, const char[] name, bool dontBroadcast)
{
int client = GetClientOfUserId(GetEventInt(event, "userid"));
if(IsValidClient(client) && gB_GroundTicksEnabled[client] && Shavit_GetClientJumps(client) > 0 && gI_GroundTicks[client] > 0)
{
Shavit_PrintToChat(client, "On Ground For %d Ticks", gI_GroundTicks[client]);
gI_GroundTicks[client] = 0;
}
}