Skip to content

Commit

Permalink
Merge pull request #448 from KZGlobalTeam/dev
Browse files Browse the repository at this point in the history
3.5.3
  • Loading branch information
zealain authored Jan 14, 2023
2 parents d894aaf + 32386c5 commit ff8d433
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 8 deletions.
2 changes: 2 additions & 0 deletions addons/sourcemod/scripting/gokz-core/map/zones.sp
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,13 @@ static void ProcessStartZoneEndTouch(int client, int course)
}

GOKZ_StartTimer(client, course, true);
GOKZ_ResetVirtualButtonPosition(client, true);
}

static void ProcessEndZoneStartTouch(int client, int course)
{
GOKZ_EndTimer(client, course);
GOKZ_ResetVirtualButtonPosition(client, false);
}

static int GetStartZoneBonusNumber(int entity)
Expand Down
7 changes: 7 additions & 0 deletions addons/sourcemod/scripting/gokz-core/natives.sp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ void CreateNatives()
CreateNative("GOKZ_TeleportToSearchStart", Native_TeleportToSearchStart);
CreateNative("GOKZ_GetVirtualButtonPosition", Native_GetVirtualButtonPosition);
CreateNative("GOKZ_SetVirtualButtonPosition", Native_SetVirtualButtonPosition);
CreateNative("GOKZ_ResetVirtualButtonPosition", Native_ResetVirtualButtonPosition);
CreateNative("GOKZ_LockVirtualButtons", Native_LockVirtualButtons);
CreateNative("GOKZ_GetStartPosition", Native_GetStartPosition);
CreateNative("GOKZ_SetStartPosition", Native_SetStartPosition);
Expand Down Expand Up @@ -238,6 +239,12 @@ public int Native_SetVirtualButtonPosition(Handle plugin, int numParams)
return 0;
}

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

public int Native_LockVirtualButtons(Handle plugin, int numParams)
{
LockVirtualButtons(GetNativeCell(1));
Expand Down
2 changes: 1 addition & 1 deletion addons/sourcemod/scripting/gokz-core/timer/timer.sp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ bool TimerStart(int client, int course, bool allowMidair = false, bool playSound
|| !IsPlayerValidMoveType(client)
|| !allowMidair && (!Movement_GetOnGround(client) || JustLanded(client))
|| allowMidair && !Movement_GetOnGround(client) && (!GOKZ_GetValidJump(client) || GOKZ_GetHitPerf(client))
|| (GOKZ_GetTimerRunning(client) && GOKZ_GetCourse(client) != course && GetVirtualStartCourse(client) != course))
|| (GOKZ_GetTimerRunning(client) && GOKZ_GetCourse(client) != course))
{
return false;
}
Expand Down
22 changes: 15 additions & 7 deletions addons/sourcemod/scripting/gokz-core/timer/virtual_buttons.sp
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ bool GetHasVirtualEndButton(int client)
return hasVirtualEndButton[client];
}

int GetVirtualStartCourse(int client)
{
return virtualStartCourse[client];
}

bool ToggleVirtualButtonsLock(int client)
{
virtualButtonsLocked[client] = !virtualButtonsLocked[client];
Expand Down Expand Up @@ -76,7 +71,6 @@ void SetVirtualButtonPosition(int client, float position[3], int course, bool is
virtualStartCourse[client] = course;
virtualStartOrigin[client] = position;
hasVirtualStartButton[client] = true;

}
else
{
Expand All @@ -86,7 +80,21 @@ void SetVirtualButtonPosition(int client, float position[3], int course, bool is
}
}


void ResetVirtualButtonPosition(int client, bool isStart)
{
if (isStart)
{
virtualStartCourse[client] = -1;
virtualStartOrigin[client] = {0.0, 0.0, 0.0};
hasVirtualStartButton[client] = false;
}
else
{
virtualEndCourse[client] = -1;
virtualEndOrigin[client] = {0.0, 0.0, 0.0};
hasVirtualEndButton[client] = false;
}
}

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

Expand Down
9 changes: 9 additions & 0 deletions addons/sourcemod/scripting/include/gokz/core.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1169,6 +1169,14 @@ native int GOKZ_GetVirtualButtonPosition(int client, float position[3], bool isS
*/
native void GOKZ_SetVirtualButtonPosition(int client, const float position[3], int course, bool isStart);

/**
* Resets the player's virtual button.
*
* @param client Client index.
* @param isStart True to get the start button position, false for the end button.
*/
native void GOKZ_ResetVirtualButtonPosition(int client, bool isStart);

/**
* Locks the virtual button position of a player.
*
Expand Down Expand Up @@ -1779,6 +1787,7 @@ public void __pl_gokz_core_SetNTVOptional()
MarkNativeAsOptional("GOKZ_TeleportToSearchStart");
MarkNativeAsOptional("GOKZ_GetVirtualButtonPosition");
MarkNativeAsOptional("GOKZ_SetVirtualButtonPosition");
MarkNativeAsOptional("GOKZ_ResetVirtualButtonPosition");
MarkNativeAsOptional("GOKZ_LockVirtualButtons");
MarkNativeAsOptional("GOKZ_GetStartPosition");
MarkNativeAsOptional("GOKZ_SetStartPosition");
Expand Down

0 comments on commit ff8d433

Please sign in to comment.