summaryrefslogtreecommitdiff
path: root/sourcemod/scripting/gokz-core/modes.sp
diff options
context:
space:
mode:
authornavewindre <nw@moneybot.cc>2023-12-04 18:06:10 +0100
committernavewindre <nw@moneybot.cc>2023-12-04 18:06:10 +0100
commitaef0d1c1268ab7d4bc18996c9c6b4da16a40aadc (patch)
tree43e766b51704f4ab8b383583bdc1871eeeb9c698 /sourcemod/scripting/gokz-core/modes.sp
parent38f1140c11724da05a23a10385061200b907cf6e (diff)
bbbbbbbbwaaaaaaaaaaa
Diffstat (limited to 'sourcemod/scripting/gokz-core/modes.sp')
-rw-r--r--sourcemod/scripting/gokz-core/modes.sp106
1 files changed, 106 insertions, 0 deletions
diff --git a/sourcemod/scripting/gokz-core/modes.sp b/sourcemod/scripting/gokz-core/modes.sp
new file mode 100644
index 0000000..ce6f8ae
--- /dev/null
+++ b/sourcemod/scripting/gokz-core/modes.sp
@@ -0,0 +1,106 @@
+static bool modeLoaded[MODE_COUNT];
+static int modeVersion[MODE_COUNT];
+static bool GOKZHitPerf[MAXPLAYERS + 1];
+static float GOKZTakeoffSpeed[MAXPLAYERS + 1];
+
+
+
+// =====[ PUBLIC ]=====
+
+bool GetModeLoaded(int mode)
+{
+ return modeLoaded[mode];
+}
+
+int GetModeVersion(int mode)
+{
+ return modeLoaded[mode] ? modeVersion[mode] : -1;
+}
+
+void SetModeLoaded(int mode, bool loaded, int version = -1)
+{
+ if (!modeLoaded[mode] && loaded)
+ {
+ modeLoaded[mode] = true;
+ modeVersion[mode] = version;
+ Call_GOKZ_OnModeLoaded(mode);
+ }
+ else if (modeLoaded[mode] && !loaded)
+ {
+ modeLoaded[mode] = false;
+ Call_GOKZ_OnModeUnloaded(mode);
+ }
+}
+
+int GetLoadedModeCount()
+{
+ int count = 0;
+ for (int mode = 0; mode < MODE_COUNT; mode++)
+ {
+ if (modeLoaded[mode])
+ {
+ count++;
+ }
+ }
+ return count;
+}
+
+int GetALoadedMode()
+{
+ for (int mode = 0; mode < MODE_COUNT; mode++)
+ {
+ if (GOKZ_GetModeLoaded(mode))
+ {
+ return mode;
+ }
+ }
+ return -1; // Uh-oh
+}
+
+bool GetGOKZHitPerf(int client)
+{
+ return GOKZHitPerf[client];
+}
+
+void SetGOKZHitPerf(int client, bool hitPerf)
+{
+ GOKZHitPerf[client] = hitPerf;
+}
+
+float GetGOKZTakeoffSpeed(int client)
+{
+ return GOKZTakeoffSpeed[client];
+}
+
+void SetGOKZTakeoffSpeed(int client, float takeoffSpeed)
+{
+ GOKZTakeoffSpeed[client] = takeoffSpeed;
+}
+
+
+
+// =====[ EVENTS ]=====
+
+void OnAllPluginsLoaded_Modes()
+{
+ if (GetLoadedModeCount() <= 0)
+ {
+ SetFailState("At least one GOKZ mode plugin is required.");
+ }
+}
+
+void OnPlayerSpawn_Modes(int client)
+{
+ GOKZHitPerf[client] = false;
+ GOKZTakeoffSpeed[client] = 0.0;
+}
+
+void OnOptionChanged_Mode(int client, Option option)
+{
+ if (option == Option_Mode)
+ {
+ // Remove speed when switching modes
+ Movement_SetVelocityModifier(client, 1.0);
+ Movement_SetVelocity(client, view_as<float>( { 0.0, 0.0, 0.0 } ));
+ }
+} \ No newline at end of file