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
|
#include <sourcemod>
#include <geoip>
#include <gokz/core>
#include <gokz/localdb>
#undef REQUIRE_EXTENSIONS
#undef REQUIRE_PLUGIN
#include <gokz/jumpstats>
#include <updater>
#pragma newdecls required
#pragma semicolon 1
public Plugin myinfo =
{
name = "GOKZ Local DB",
author = "DanZay",
description = "Provides database for players, maps, courses and times",
version = GOKZ_VERSION,
url = GOKZ_SOURCE_URL
};
#define UPDATER_URL GOKZ_UPDATER_BASE_URL..."gokz-localdb.txt"
Database gH_DB = null;
DatabaseType g_DBType = DatabaseType_None;
bool gB_ClientSetUp[MAXPLAYERS + 1];
bool gB_ClientPostAdminChecked[MAXPLAYERS + 1];
bool gB_Cheater[MAXPLAYERS + 1];
int gI_PBJSCache[MAXPLAYERS + 1][MODE_COUNT][JUMPTYPE_COUNT][JUMPSTATDB_CACHE_COUNT];
bool gB_MapSetUp;
int gI_DBCurrentMapID;
#include "gokz-localdb/api.sp"
#include "gokz-localdb/commands.sp"
#include "gokz-localdb/options.sp"
#include "gokz-localdb/db/sql.sp"
#include "gokz-localdb/db/helpers.sp"
#include "gokz-localdb/db/cache_js.sp"
#include "gokz-localdb/db/create_tables.sp"
#include "gokz-localdb/db/save_js.sp"
#include "gokz-localdb/db/save_time.sp"
#include "gokz-localdb/db/set_cheater.sp"
#include "gokz-localdb/db/setup_client.sp"
#include "gokz-localdb/db/setup_database.sp"
#include "gokz-localdb/db/setup_map.sp"
#include "gokz-localdb/db/setup_map_courses.sp"
#include "gokz-localdb/db/timer_setup.sp"
// =====[ PLUGIN EVENTS ]=====
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
{
CreateNatives();
RegPluginLibrary("gokz-localdb");
return APLRes_Success;
}
public void OnPluginStart()
{
LoadTranslations("gokz-localdb.phrases");
CreateGlobalForwards();
RegisterCommands();
DB_SetupDatabase();
}
public void OnAllPluginsLoaded()
{
if (LibraryExists("updater"))
{
Updater_AddPlugin(UPDATER_URL);
}
char auth[32];
for (int client = 1; client <= MaxClients; client++)
{
if (IsClientAuthorized(client) && GetClientAuthId(client, AuthId_Engine, auth, sizeof(auth)))
{
OnClientAuthorized(client, auth);
}
}
}
public void OnLibraryAdded(const char[] name)
{
if (StrEqual(name, "updater"))
{
Updater_AddPlugin(UPDATER_URL);
}
}
// =====[ OTHER EVENTS ]=====
public void OnConfigsExecuted()
{
DB_SetupMap();
}
public void GOKZ_DB_OnMapSetup(int mapID)
{
DB_SetupMapCourses();
for (int client = 1; client < MAXPLAYERS + 1; client++)
{
if (IsValidClient(client) && !IsFakeClient(client) &&
gB_ClientPostAdminChecked[client] &&
GOKZ_GetOption(client, gC_DBOptionNames[DBOption_AutoLoadTimerSetup]) == DBOption_Enabled)
{
DB_LoadTimerSetup(client);
}
}
}
public void OnMapEnd()
{
gB_MapSetUp = false;
}
public void OnClientAuthorized(int client, const char[] auth)
{
DB_SetupClient(client);
}
public void OnClientPostAdminCheck(int client)
{
// We need this after OnClientPutInServer cause that's where the VBs get reset
gB_ClientPostAdminChecked[client] = true;
if (gB_MapSetUp && GOKZ_GetOption(client, gC_DBOptionNames[DBOption_AutoLoadTimerSetup]) == DBOption_Enabled)
{
DB_LoadTimerSetup(client);
}
}
public void GOKZ_DB_OnClientSetup(int client, int steamID, bool cheater)
{
DB_CacheJSPBs(client, steamID);
}
public void GOKZ_OnOptionsLoaded(int client)
{
if (gB_MapSetUp && gB_ClientPostAdminChecked[client] && GOKZ_GetOption(client, gC_DBOptionNames[DBOption_AutoLoadTimerSetup]) == DBOption_Enabled)
{
DB_LoadTimerSetup(client);
}
}
public void OnClientDisconnect(int client)
{
gB_ClientSetUp[client] = false;
gB_ClientPostAdminChecked[client] = false;
}
public void GOKZ_OnCourseRegistered(int course)
{
if (gB_MapSetUp)
{
DB_SetupMapCourse(course);
}
}
public void GOKZ_OnOptionsMenuReady(TopMenu topMenu)
{
OnOptionsMenuReady_Options();
OnOptionsMenuReady_OptionsMenu(topMenu);
}
public void GOKZ_OnTimerEnd_Post(int client, int course, float time, int teleportsUsed)
{
int mode = GOKZ_GetCoreOption(client, Option_Mode);
int style = GOKZ_GetCoreOption(client, Option_Style);
DB_SaveTime(client, course, mode, style, time, teleportsUsed);
}
public void GOKZ_JS_OnLanding(Jump jump)
{
OnLanding_SaveJumpstat(jump);
}
|