Skip to content

Commit

Permalink
Added 0.1 second delay to fix usage with Ofir's retakes plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
B3none authored May 1, 2023
1 parent f54997d commit 6ef0df0
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions addons/sourcemod/scripting/retakes_autoplant.sp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public Plugin myinfo =
name = "[Retakes] Autoplant",
author = "B3none",
description = "Automatically plant the bomb at the start of the round. This will work with all versions of the retakes plugin.",
version = "2.3.3",
version = "2.3.4",
url = "https://github.com/b3none"
};

Expand All @@ -45,6 +45,13 @@ public void OnPluginStart()
}

public Action OnRoundStart(Event eEvent, const char[] sName, bool bDontBroadcast)
{
// This delay is for compatability with ofir's retakes
CreateTimer(0.1, Timer_AutoplantBomb, _, TIMER_FLAG_NO_MAPCHANGE);
return Plugin_Continue;
}

public Action Timer_AutoplantBomb(Handle hTimer)
{
hasBombBeenDeleted = false;

Expand All @@ -59,7 +66,7 @@ public Action OnRoundStart(Event eEvent, const char[] sName, bool bDontBroadcast
{
bombsite = GetNearestBombsite(bomber);

int bomb = GetPlayerWeaponSlot(bomber, 4);
int bomb = GetPlayerWeaponSlot(bomber, CS_SLOT_C4);

hasBombBeenDeleted = SafeRemoveWeapon(bomber, bomb);

Expand All @@ -82,7 +89,7 @@ public void OnRoundEnd(Event event, const char[] sName, bool bDontBroadcast)

public Action PlantBomb(Handle timer, int client)
{
bombTimer = INVALID_HANDLE;
bombTimer = null;

if (IsValidClient(client) || !hasBombBeenDeleted)
{
Expand Down Expand Up @@ -168,7 +175,7 @@ stock int GetBomber()

stock bool HasBomb(int client)
{
return GetPlayerWeaponSlot(client, 4) != -1;
return GetPlayerWeaponSlot(client, CS_SLOT_C4) != -1;
}


Expand Down Expand Up @@ -215,7 +222,7 @@ void GroundEntity(int entity)
flAng[1] = 0.0;
flAng[2] = 0.0;
Handle hTrace = TR_TraceRayFilterEx(flPos, flAng, MASK_SHOT, RayType_Infinite, TraceFilterIgnorePlayers, entity);
if (hTrace != INVALID_HANDLE && TR_DidHit(hTrace))
if (hTrace != null && TR_DidHit(hTrace))
{
float endPos[3];
TR_GetEndPosition(endPos, hTrace);
Expand Down

0 comments on commit 6ef0df0

Please sign in to comment.