This repository has been archived by the owner on Aug 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Modular_LS.inc
257 lines (226 loc) · 5.31 KB
/
Modular_LS.inc
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
#if defined _Modular_LS_included
#endinput
#endif
#define _Modular_LS_included
enum LSRL
{
LSRL_Admin,
LSRL_Tester,
LSRL_Donor,
LSRL_Member,
LSRL_Normal,
LSRL_Count
}
/**
* Get client level
*
* @param client Client Index
* @return User Level (-1 If Invalid Data)
*/
native int MLS_GetUserLevel(int client);
/**
* Get client prestige level
*
* @param client Client Index
* @return User Prestige (-1 If Invalid Data)
*/
native int MLS_GetUserPrestige(int client);
/**
* Get client rank
*
* @param client Client Index
* @return User Prestige (-1 If Invalid Data)
*/
native LSRL MLS_GetUserRank(int client);
/**
* Get client prestige colors
*
* @param colors[3] Int Array of 3 as Reference
* @param client Client Index
* @noreturn
*/
native void MLS_GetPrestigeColorRGB(int colors[3], int client);
/**
* Get client prestige colors
*
* @param color Int Reference
* @param client Client Index
* @return Color Hex
*/
native int MLS_GetPrestigeColorHex(int client);
/**
* Get client prestige title
*
* @param buffer Buffer Reference
* @param size Buffer Size
* @param client Client Index
* @noreturn
*/
native void MLS_GetPrestigeTitle(char[] buffer, int size, int client);
/**
* Get client rank title
*
* @param buffer Buffer Reference
* @param size Buffer Size
* @param client Client Index
* @noreturn
*/
native void MLS_GetRankTitle(char[] buffer, int size, int client);
/**
* Add XP to client
*
* @param client Client Index
* @param xp XP Value
* @param bonus Whether to consider other factors (playtime, membership, etc)
* @noreturn
*/
native void MLS_AddXP(int client, int xp, bool bonus = true);
/**
* Add XP to all clients
*
* @param xp XP Value
* @param bonus Whether to consider other factors (playtime, membership, etc)
* @noreturn
*/
stock void MLS_AddXPToAll(int xp, bool bonus = true)
{
for (int i = 1; i <= MaxClients; i++)
if (IsValidClient(i))
MLS_AddXP(i, xp, bonus);
}
/**
* Check if client data is loaded
*
* @param client Client Index
* @return True if loaded, false otherwise
*/
native bool MLS_IsLoaded(int client);
/**
* Called when data is loaded for a client
*
* @param client Client Index
* @noreturn
*/
forward void MLS_OnClientDataLoaded(int client);
/**
* Called whenever a client levels up
*
* @param client Client Index
* @param level Client Level
* @param prestige Client Prestige
* @noreturn
*/
forward void MLS_OnClientLeveledUp(int client, int level, int prestige);
/**
* Called whenever a client prestige
*
* @param client Client Index
* @param level Client Level (Should be always 0 on prestige)
* @param prestige Client Prestige
* @noreturn
*/
forward void MLS_OnClientPrestige(int client, int level, int prestige);
/**
* Print to client chat using core format
*
* @param client Client Index
* @param format Format
* @param ... Any additional formating data
* @noreturn
*/
native void MLS_PrintToClient(int client, const char[] format, any ...);
/**
* Checks if client is above or equal rank
*
* @param client Client Index
* @param prestige Prestige
* @param level Level
* @return True if passed, false otherwise
*/
stock bool IsAERank(int client, int prestige, int level)
{
if (!IsValidClient(client))
return false;
int EPrestige = MLS_GetUserPrestige(client);
if (EPrestige < prestige)
return false;
int ELevel = MLS_GetUserLevel(client);
if (EPrestige == prestige && ELevel < level)
return false;
return true;
}
/**
* Checks if it is a valid client
*
* @param client Client Index
* @param bAlive Check if alive
* @return True if valid, false if not
*/
stock bool IsValidClient(int client, bool bAlive = false)
{
if (client >= 1 && client <= MaxClients && IsClientConnected(client) && IsClientInGame(client) && !IsFakeClient(client) &&
(bAlive == false || IsPlayerAlive(client)))
{
return true;
}
return false;
}
/**
* Return random integer within range
*
* @param iMin Minimum Range
* @param iMax Max Range
* @return Random Integer within range
*/
stock int GetURandomIntRange(int iMin, int iMax)
{
return iMin + (GetURandomInt() % (iMax - iMin + 1));
}
/**
* Return true/false if lucky or not
*
* @param Chance A percentage to compare
* @return True if lucky, false otherwise
*/
stock bool IsLuckyPercentage(int Chance)
{
return (GetURandomIntRange(0, 99) < Chance);
}
/**
* Return true/false whether if both conditions match
*
* @param var1 Variable 1
* @param var2 Variable 2
* @param val1 Expected value for variable 1
* @param val2 Expected value for variable 2
* @return True if both pass, false otherwise
*/
stock bool DoubleEqual(int var1, int var2, int val1, int val2)
{
return (var1 == val1 && var2 == val2);
}
public SharedPlugin __pl_Modular_LS =
{
name = "Modular_LS",
file = "Modular_LS.smx",
#if defined REQUIRE_PLUGIN
required = 1,
#else
required = 0,
#endif
};
#if !defined REQUIRE_PLUGIN
public __pl_Modular_LS_SetNTVOptional()
{
MarkNativeAsOptional("MLS_GetUserLevel");
MarkNativeAsOptional("MLS_GetUserPrestige");
MarkNativeAsOptional("MLS_GetUserRank");
MarkNativeAsOptional("MLS_GetPrestigeColorRGB");
MarkNativeAsOptional("MLS_GetPrestigeColorHex");
MarkNativeAsOptional("MLS_GetPrestigeTitle");
MarkNativeAsOptional("MLS_GetRankTitle");
MarkNativeAsOptional("MLS_AddXP");
MarkNativeAsOptional("MLS_PrintToClient");
MarkNativeAsOptional("MLS_IsLoaded");
}
#endif