Skip to content

Commit

Permalink
Updated weapon stripping to also remove a players armour (this should…
Browse files Browse the repository at this point in the history
… be handled by the allocator)
  • Loading branch information
B3none committed Jan 3, 2024
1 parent 3db3351 commit 76567c3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
12 changes: 12 additions & 0 deletions Modules/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,16 @@ public static void GiveAndSwitchToBomb(CCSPlayerController player)
player.GiveNamedItem(CsItem.Bomb);
NativeAPI.IssueClientCommand((int)player.UserId!, "slot5");
}

public static void RemoveHelmetAndHeavyArmour(CCSPlayerController player)
{
if (player.PlayerPawn.Value == null || player.PlayerPawn.Value.ItemServices == null)
{
return;
}

var itemServices = new CCSPlayer_ItemServices(player.PlayerPawn.Value.ItemServices.Handle);
itemServices.HasHelmet = false;
itemServices.HasHeavyArmor = false;
}
}
5 changes: 2 additions & 3 deletions RetakesPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -392,10 +392,9 @@ public HookResult OnRoundPostStart(EventRoundPoststart @event, GameEventInfo inf
}

// Strip the player of all of their weapons and the bomb before any spawn / allocation occurs.
// TODO: Figure out why this is crashing the server / undo workaround.
// player.RemoveWeapons();
Helpers.RemoveHelmetAndHeavyArmour(player);
Helpers.RemoveAllWeaponsAndEntities(player);

// Create a timer to do this as it would occasionally fire too early.
AddTimer(0.05f, () =>
{
Expand Down

0 comments on commit 76567c3

Please sign in to comment.