Skip to content

Commit

Permalink
fix: do not strip bomb
Browse files Browse the repository at this point in the history
  • Loading branch information
derkalle4 committed Jan 7, 2025
1 parent 7f70328 commit 2e0027a
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions src/RollTheDice+DiceStripWeapons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,23 @@ private Dictionary<string, string> DiceStripWeapons(CCSPlayerController player,
{ "playerName", player.PlayerName }
};
var playerWeapons = playerPawn.WeaponServices!;
bool hasC4 = false;
foreach (var weapon in playerWeapons.MyWeapons)
{
// ignore unknown weapons
if (weapon.Value == null || weapon.Value != null && weapon.Value.DesignerName == null) continue;
if (weapon.Value!.DesignerName == CsItem.C4.ToString().ToLower()
|| weapon.Value!.DesignerName == CsItem.Bomb.ToString().ToLower())
|| weapon.Value!.DesignerName == CsItem.Bomb.ToString().ToLower()
|| weapon.Value!.DesignerName == $"weapon_{CsItem.C4.ToString().ToLower()}"
|| weapon.Value!.DesignerName == $"weapon_{CsItem.Bomb.ToString().ToLower()}")
{
// change weapon to currently active weapon
playerPawn.WeaponServices.ActiveWeapon.Raw = weapon.Raw;
// drop active weapon
player.DropActiveWeapon();
hasC4 = true;
}
}
AddTimer(0.1f, () =>
{
if (player == null || !player.IsValid) return;
player.RemoveWeapons();
player.GiveNamedItem("weapon_knife");
});

player.RemoveWeapons();
player.GiveNamedItem(CsItem.Knife);
if (hasC4)
player.GiveNamedItem(CsItem.C4);
return new Dictionary<string, string>
{
{"_translation_player", "DiceStripWeaponsPlayer"},
Expand Down

0 comments on commit 2e0027a

Please sign in to comment.