Skip to content

Commit

Permalink
Merge pull request #298 from Ciallo-Ani/master
Browse files Browse the repository at this point in the history
another fix for Trigger OnEndTouch issue that keeping velocity when using teleport command
  • Loading branch information
dPexxIAM authored Sep 10, 2021
2 parents 3c4d130 + 2b45947 commit fa14bef
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 9 deletions.
9 changes: 6 additions & 3 deletions addons/sourcemod/scripting/SurfTimer.sp
Original file line number Diff line number Diff line change
Expand Up @@ -1052,7 +1052,8 @@ float g_fLastOverlay[MAXPLAYERS + 1];
bool g_wrcpStage2Fix[MAXPLAYERS + 1];

// Is client trying to teleport inside a trigger_multiple
bool g_TeleInTriggerMultiple[MAXPLAYERS + 1];
//bool g_TeleInTriggerMultiple[MAXPLAYERS + 1];
bool g_bTeleByCommand[MAXPLAYERS + 1];

/*---------- Player location restoring ----------*/

Expand Down Expand Up @@ -1727,8 +1728,9 @@ public void OnMapStart()
{
SDKHook(iEnt, SDKHook_EndTouch, OnMultipleTrigger1);
SDKHook(iEnt, SDKHook_StartTouch, OnMultipleTrigger1);
SDKHook(iEnt, SDKHook_StartTouch, OnMultipleTrigger2);
SDKHook(iEnt, SDKHook_EndTouch, OnMultipleTrigger3);
/* SDKHook(iEnt, SDKHook_StartTouch, OnMultipleTrigger2);
SDKHook(iEnt, SDKHook_EndTouch, OnMultipleTrigger3); */
HookSingleEntityOutput(iEnt, "OnEndTouch", OnTriggerOutput);
PushArrayCell(g_hTriggerMultiple, iEnt);
}

Expand Down Expand Up @@ -1913,6 +1915,7 @@ public void OnClientPutInServer(int client)
SendConVarValue(client, g_hFootsteps, "0");

g_bReportSuccess[client] = false;
g_bTeleByCommand[client] = false;
g_fCommandLastUsed[client] = 0.0;

// fluffys set bools
Expand Down
3 changes: 2 additions & 1 deletion addons/sourcemod/scripting/surftimer/buttonpress.sp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ public void CL_OnStartTimerPress(int client)
g_iCurrentCheckpoint[client] = 0;
g_iCheckpointsPassed[client] = 0;
g_bIsValidRun[client] = false;
// Enable Trigger Output on Timer Restart
g_bTeleByCommand[client] = false;

if (!IsFakeClient(client))
{
Expand Down Expand Up @@ -113,7 +115,6 @@ public void CL_OnStartTimerPress(int client)
CPrintToChat(i, preMessage);
}
}

}

// Play Start Sound
Expand Down
13 changes: 12 additions & 1 deletion addons/sourcemod/scripting/surftimer/hooks.sp
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ public Action OnMultipleTrigger1(int entity, int client)
return Plugin_Continue;
}

public Action OnMultipleTrigger2(int entity, int client)
/* public Action OnMultipleTrigger2(int entity, int client)
{
if (g_iClientInZone[client][0] > 0) {
g_TeleInTriggerMultiple[client] = false;
Expand All @@ -731,6 +731,17 @@ public Action OnMultipleTrigger3(int entity, int client)
{
g_TeleInTriggerMultiple[client] = false;
return Plugin_Continue;
} */

public Action OnTriggerOutput(const char[] output, int caller, int activator, float delay)
{
// Block Output when player use a teleport command
if(g_bTeleByCommand[activator])
{
return Plugin_Handled;
}

return Plugin_Continue;
}

Expand Down
14 changes: 12 additions & 2 deletions addons/sourcemod/scripting/surftimer/misc.sp
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,10 @@ public void teleportClient(int client, int zonegroup, int zone, bool stopTime)
return;

// dpexx stop teleporting if in trigger_multiple
if (g_TeleInTriggerMultiple[client]){
/* if (g_TeleInTriggerMultiple[client]){
PrintToChat(client, "Teleport blocked");
return;
}
} */

if (!IsValidZonegroup(zonegroup))
{
Expand Down Expand Up @@ -163,6 +163,16 @@ public void teleportClient(int client, int zonegroup, int zone, bool stopTime)
g_iTicksOnGround[client] = 0;
g_bNewStage[client] = false;

// dpexx's hack fix for those startzone inside a trigger
if (g_iClientInZone[client][0] > 0)
{
g_bTeleByCommand[client] = false;
}
else
{
g_bTeleByCommand[client] = true;
}

// Check for spawn locations
int realZone;
if (zone < 0)
Expand Down
4 changes: 2 additions & 2 deletions addons/sourcemod/scripting/surftimer/surfzones.sp
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,9 @@ public Action EndTouchTrigger(int caller, int activator)

public void StartTouch(int client, int action[3])
{
if (g_iClientInZone[client][0] > 0){
/* if (g_iClientInZone[client][0] > 0){
g_TeleInTriggerMultiple[client] = false;
}
} */

if (IsValidClient(client))
{
Expand Down

0 comments on commit fa14bef

Please sign in to comment.