summaryrefslogtreecommitdiff
path: root/sourcemod/scripting/gokz-racing.sp
blob: 416d28aeeb7a03565c74145f104bde88e238c7d1 (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
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
#include <sourcemod>

#include <gokz/core>
#include <gokz/racing>

#undef REQUIRE_EXTENSIONS
#undef REQUIRE_PLUGIN
#include <updater>

#pragma newdecls required
#pragma semicolon 1



public Plugin myinfo = 
{
	name = "GOKZ Racing", 
	author = "DanZay", 
	description = "Lets players race against each other", 
	version = GOKZ_VERSION, 
	url = GOKZ_SOURCE_URL
};

#define UPDATER_URL GOKZ_UPDATER_BASE_URL..."gokz-racing.txt"

#include "gokz-racing/announce.sp"
#include "gokz-racing/api.sp"
#include "gokz-racing/commands.sp"
#include "gokz-racing/duel_menu.sp"
#include "gokz-racing/race.sp"
#include "gokz-racing/race_menu.sp"
#include "gokz-racing/racer.sp"



// =====[ PLUGIN EVENTS ]=====

public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
{
	CreateNatives();
	RegPluginLibrary("gokz-racing");
	return APLRes_Success;
}

public void OnPluginStart()
{
	LoadTranslations("gokz-common.phrases");
	LoadTranslations("gokz-racing.phrases");
	
	CreateGlobalForwards();
	RegisterCommands();
	
	OnPluginStart_Race();
}

public void OnAllPluginsLoaded()
{
	if (LibraryExists("updater"))
	{
		Updater_AddPlugin(UPDATER_URL);
	}
}

public void OnLibraryAdded(const char[] name)
{
	if (StrEqual(name, "updater"))
	{
		Updater_AddPlugin(UPDATER_URL);
	}
}



// =====[ CLIENT EVENTS ]=====

public void OnClientPutInServer(int client)
{
	OnClientPutInServer_Racer(client);
}

public void OnClientDisconnect(int client)
{
	OnClientDisconnect_Racer(client);
}

public Action GOKZ_OnTimerStart(int client, int course)
{
	Action action = OnTimerStart_Racer(client, course);
	if (action != Plugin_Continue)
	{
		return action;
	}
	
	return Plugin_Continue;
}

public void GOKZ_OnTimerStart_Post(int client, int course)
{
	OnTimerStart_Post_Racer(client);
}

public void GOKZ_OnTimerEnd_Post(int client, int course, float time, int teleportsUsed)
{
	FinishRacer(client, course);
}

public Action GOKZ_OnMakeCheckpoint(int client)
{
	Action action = OnMakeCheckpoint_Racer(client);
	if (action != Plugin_Continue)
	{
		return action;
	}
	
	return Plugin_Continue;
}

public void GOKZ_OnMakeCheckpoint_Post(int client)
{
	OnMakeCheckpoint_Post_Racer(client);
}

public Action GOKZ_OnUndoTeleport(int client)
{
	Action action = OnUndoTeleport_Racer(client);
	if (action != Plugin_Continue)
	{
		return action;
	}
	
	return Plugin_Continue;
}

public void GOKZ_RC_OnFinish(int client, int raceID, int place)
{
	OnFinish_Announce(client, raceID, place);
	OnFinish_Race(raceID);
}

public void GOKZ_RC_OnSurrender(int client, int raceID)
{
	OnSurrender_Announce(client, raceID);
}

public void GOKZ_RC_OnRequestReceived(int client, int raceID)
{
	OnRequestReceived_Announce(client, raceID);
}

public void GOKZ_RC_OnRequestAccepted(int client, int raceID)
{
	OnRequestAccepted_Announce(client, raceID);
	OnRequestAccepted_Race(raceID);
}

public void GOKZ_RC_OnRequestDeclined(int client, int raceID, bool timeout)
{
	OnRequestDeclined_Announce(client, raceID, timeout);
	OnRequestDeclined_Race(raceID);
}



// =====[ OTHER EVENTS ]=====

public void GOKZ_RC_OnRaceStarted(int raceID)
{
	OnRaceStarted_Announce(raceID);
}

public void GOKZ_RC_OnRaceAborted(int raceID)
{
	OnRaceAborted_Announce(raceID);
}