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
|
/*
gokz-localranks Plugin Include
Website: https://bitbucket.org/kztimerglobalteam/gokz
*/
#if defined _gokz_localranks_included_
#endinput
#endif
#define _gokz_localranks_included_
// =====[ ENUMS ]=====
enum
{
RecordType_Nub = 0,
RecordType_Pro,
RecordType_NubAndPro,
RECORDTYPE_COUNT
};
// =====[ CONSTANTS ]=====
#define LR_CFG_MAP_POOL "cfg/sourcemod/gokz/gokz-localranks-mappool.cfg"
#define LR_CFG_SOUNDS "cfg/sourcemod/gokz/gokz-localranks-sounds.cfg"
#define LR_COMMAND_COOLDOWN 2.5
#define LR_MAP_TOP_CUTOFF 20
#define LR_PLAYER_TOP_CUTOFF 20
// =====[ FORWARDS ]=====
/**
* Called when a player's time has been processed by GOKZ Local Ranks.
*
* @param client Client index.
* @param steamID SteamID32 of the player (from GetSteamAccountID()).
* @param mapID MapID from the "Maps" database table.
* @param course Course number e.g. 0=main, 1='bonus1' etc.
* @param mode Player's movement mode.
* @param style Player's movement style.
* @param runTime Player's end time.
* @param teleportsUsed Number of teleportsUsed used by player.
* @param firstTime Whether this is player's first time on this course.
* @param pbDiff Difference between new time and PB in seconds (-'ve means beat PB).
* @param rank New rank of the player's PB time.
* @param maxRank New total number of players with times.
* @param firstTimePro Whether this is player's first PRO time on this course.
* @param pbDiffPro Difference between new time and PRO PB in seconds (-'ve means beat PB).
* @param rankPro New rank of the player's PB PRO time.
* @param maxRankPro New total number of players with PRO times.
*/
forward void GOKZ_LR_OnTimeProcessed(
int client,
int steamID,
int mapID,
int course,
int mode,
int style,
float runTime,
int teleportsUsed,
bool firstTime,
float pbDiff,
int rank,
int maxRank,
bool firstTimePro,
float pbDiffPro,
int rankPro,
int maxRankPro);
/**
* Called when a player sets a new local record.
*
* @param client Client index.
* @param steamID SteamID32 of the player (from GetSteamAccountID()).
* @param mapID MapID from the "Maps" table.
* @param course Course number e.g. 0=main, 1='bonus1' etc.
* @param mode Player's movement mode.
* @param style Player's movement style.
* @param recordType Type of record.
*/
forward void GOKZ_LR_OnNewRecord(
int client,
int steamID,
int mapID,
int course,
int mode,
int style,
int recordType,
float pbDiff,
int teleportsUsed);
/**
* Called when a player misses the server record time.
* Is called regardless of player's current run type.
*
* @param client Client index.
* @param recordTime Record time missed.
* @param course Course number e.g. 0=main, 1='bonus1' etc.
* @param mode Player's movement mode.
* @param style Player's movement style.
* @param recordType Type of record.
*/
forward void GOKZ_LR_OnRecordMissed(int client, float recordTime, int course, int mode, int style, int recordType);
/**
* Called when a player misses their personal best time.
* Is called regardless of player's current run type.
*
* @param client Client index.
* @param pbTime Personal best time missed.
* @param course Course number e.g. 0=main, 1='bonus1' etc.
* @param mode Player's movement mode.
* @param style Player's movement style.
* @param recordType Type of record.
*/
forward void GOKZ_LR_OnPBMissed(int client, float pbTime, int course, int mode, int style, int recordType);
// =====[ NATIVES ]=====
/**
* Gets whether player has missed the server record time.
*
* @param client Client index.
* @param timeType Which record time i.e. NUB or PRO.
* @return Whether player has missed the server record time.
*/
native bool GOKZ_LR_GetRecordMissed(int client, int timeType);
/**
* Gets whether player has missed their personal best time.
*
* @param client Client index.
* @param timeType Which PB time i.e. NUB or PRO.
* @return Whether player has missed their PB time.
*/
native bool GOKZ_LR_GetPBMissed(int client, int timeType);
/**
* Reopens the map top menu with the already selected parameters.
* Don't use if the client hasn't opened the map top menu before.
*
* @param client Client index.
*/
native void GOKZ_LR_ReopenMapTopMenu(int client);
// =====[ DEPENDENCY ]=====
public SharedPlugin __pl_gokz_localranks =
{
name = "gokz-localranks",
file = "gokz-localranks.smx",
#if defined REQUIRE_PLUGIN
required = 1,
#else
required = 0,
#endif
};
#if !defined REQUIRE_PLUGIN
public void __pl_gokz_localranks_SetNTVOptional()
{
MarkNativeAsOptional("GOKZ_LR_GetRecordMissed");
MarkNativeAsOptional("GOKZ_LR_GetPBMissed");
MarkNativeAsOptional("GOKZ_LR_ReopenMapTopMenu");
}
#endif
|