Skip to content

Commit

Permalink
Update retakes_autoplant.sp
Browse files Browse the repository at this point in the history
  • Loading branch information
B3none authored Apr 12, 2019
1 parent c51e508 commit 91bf098
Showing 1 changed file with 44 additions and 28 deletions.
72 changes: 44 additions & 28 deletions scripting/retakes_autoplant.sp
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,13 @@
int bomber;
int bombsite;
bool hasBombBeenDeleted;

ConVar isPluginEnabled;
ConVar freezeTime;

float bombPosition[3];

Handle bombTimer;

int bombTicking;

ConVar isPluginEnabled;
ConVar freezeTime;

enum //Bombsites
{
BOMBSITE_INVALID = -1,
Expand All @@ -30,7 +27,7 @@ public Plugin myinfo =
name = "[Retakes] Autoplant",
author = "b3none",
description = "Autoplant the bomb for CS:GO Retakes.",
version = "2.1.0",
version = "2.1.1",
url = "https://github.com/b3none"
};

Expand All @@ -48,26 +45,31 @@ public void OnPluginStart()

public Action OnRoundStart(Event eEvent, const char[] sName, bool bDontBroadcast)
{
hasBombBeenDeleted = false;

bomber = GetBomber();

if (isPluginEnabled.BoolValue && IsValidClient(bomber))
{
bombsite = GetNearestBombsite(bomber);

int bomb = GetPlayerWeaponSlot(bomber, 4);

hasBombBeenDeleted = SafeRemoveWeapon(bomber, bomb);

GetClientAbsOrigin(bomber, bombPosition);

delete bombTimer;

bombTimer = CreateTimer(freezeTime.FloatValue, PlantBomb, bomber);
}

return Plugin_Continue;
hasBombBeenDeleted = false;

if (!isPluginEnabled.BoolValue)
{
return Plugin_Continue;
}

bomber = GetBomber();

if (IsValidClient(bomber))
{
bombsite = GetNearestBombsite(bomber);

int bomb = GetPlayerWeaponSlot(bomber, 4);

hasBombBeenDeleted = SafeRemoveWeapon(bomber, bomb);

GetClientAbsOrigin(bomber, bombPosition);

delete bombTimer;

bombTimer = CreateTimer(freezeTime.FloatValue, PlantBomb, bomber);
}

return Plugin_Continue;
}

public void OnRoundEnd(Event event, const char[] sName, bool bDontBroadcast)
Expand Down Expand Up @@ -168,9 +170,23 @@ stock bool SafeRemoveWeapon(int client, int weapon)

stock int GetBomber()
{
return GetEntProp(GetPlayerResourceEntity(), Prop_Send, "m_iPlayerC4");
for (int i = 1; i <= MaxClients; i++)
{
if (IsValidClient(i) && HasBomb(i))
{
return i;
}
}

return -1;
}

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


stock bool IsWarmup()
{
return GameRules_GetProp("m_bWarmupPeriod") == 1;
Expand Down

0 comments on commit 91bf098

Please sign in to comment.