summaryrefslogtreecommitdiff
path: root/sourcemod/scripting/gokz-localdb/api.sp
blob: a4bc29c34f721a9bfe5436940cad0cccbafe9771 (plain)
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
static GlobalForward H_OnDatabaseConnect;
static GlobalForward H_OnClientSetup;
static GlobalForward H_OnMapSetup;
static GlobalForward H_OnTimeInserted;
static GlobalForward H_OnJumpstatPB;



// =====[ FORWARDS ]=====

void CreateGlobalForwards()
{
	H_OnDatabaseConnect = new GlobalForward("GOKZ_DB_OnDatabaseConnect", ET_Ignore, Param_Cell);
	H_OnClientSetup = new GlobalForward("GOKZ_DB_OnClientSetup", ET_Ignore, Param_Cell, Param_Cell, Param_Cell);
	H_OnMapSetup = new GlobalForward("GOKZ_DB_OnMapSetup", ET_Ignore, Param_Cell);
	H_OnTimeInserted = new GlobalForward("GOKZ_DB_OnTimeInserted", ET_Ignore, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell);
	H_OnJumpstatPB = new GlobalForward("GOKZ_DB_OnJumpstatPB", ET_Ignore, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell);
}

void Call_OnDatabaseConnect()
{
	Call_StartForward(H_OnDatabaseConnect);
	Call_PushCell(g_DBType);
	Call_Finish();
}

void Call_OnClientSetup(int client, int steamID, bool cheater)
{
	Call_StartForward(H_OnClientSetup);
	Call_PushCell(client);
	Call_PushCell(steamID);
	Call_PushCell(cheater);
	Call_Finish();
}

void Call_OnMapSetup()
{
	Call_StartForward(H_OnMapSetup);
	Call_PushCell(gI_DBCurrentMapID);
	Call_Finish();
}

void Call_OnTimeInserted(int client, int steamID, int mapID, int course, int mode, int style, int runTimeMS, int teleportsUsed)
{
	Call_StartForward(H_OnTimeInserted);
	Call_PushCell(client);
	Call_PushCell(steamID);
	Call_PushCell(mapID);
	Call_PushCell(course);
	Call_PushCell(mode);
	Call_PushCell(style);
	Call_PushCell(runTimeMS);
	Call_PushCell(teleportsUsed);
	Call_Finish();
}

void Call_OnJumpstatPB(int client, int jumptype, int mode, float distance, int block, int strafes, float sync, float pre, float max, int airtime)
{
	Call_StartForward(H_OnJumpstatPB);
	Call_PushCell(client);
	Call_PushCell(jumptype);
	Call_PushCell(mode);
	Call_PushCell(distance);
	Call_PushCell(block);
	Call_PushCell(strafes);
	Call_PushCell(sync);
	Call_PushCell(pre);
	Call_PushCell(max);
	Call_PushCell(airtime);
	Call_Finish();
}



// =====[ NATIVES ]=====

void CreateNatives()
{
	CreateNative("GOKZ_DB_GetDatabase", Native_GetDatabase);
	CreateNative("GOKZ_DB_GetDatabaseType", Native_GetDatabaseType);
	CreateNative("GOKZ_DB_IsClientSetUp", Native_IsClientSetUp);
	CreateNative("GOKZ_DB_IsMapSetUp", Native_IsMapSetUp);
	CreateNative("GOKZ_DB_GetCurrentMapID", Native_GetCurrentMapID);
	CreateNative("GOKZ_DB_IsCheater", Native_IsCheater);
	CreateNative("GOKZ_DB_SetCheater", Native_SetCheater);
}

public int Native_GetDatabase(Handle plugin, int numParams)
{
	if (gH_DB == null)
	{
		return view_as<int>(gH_DB);
	}
	return view_as<int>(CloneHandle(gH_DB));
}

public int Native_GetDatabaseType(Handle plugin, int numParams)
{
	return view_as<int>(g_DBType);
}

public int Native_IsClientSetUp(Handle plugin, int numParams)
{
	return view_as<int>(gB_ClientSetUp[GetNativeCell(1)]);
}

public int Native_IsMapSetUp(Handle plugin, int numParams)
{
	return view_as<int>(gB_MapSetUp);
}

public int Native_GetCurrentMapID(Handle plugin, int numParams)
{
	return gI_DBCurrentMapID;
}

public int Native_IsCheater(Handle plugin, int numParams)
{
	return view_as<int>(gB_Cheater[GetNativeCell(1)]);
}

public int Native_SetCheater(Handle plugin, int numParams)
{
	DB_SetCheater(GetNativeCell(1), GetNativeCell(2));
	return 0;
}