Skip to content

Commit

Permalink
Moved Ammo additions into Inventory call delayed
Browse files Browse the repository at this point in the history
  • Loading branch information
TtroubleTT committed Aug 6, 2024
1 parent 43b6ea9 commit c0bf400
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions EXILED/Exiled.CustomRoles/API/Features/CustomRole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -537,22 +537,17 @@ public virtual void AddRole(Player player)
Log.Debug($"{Name}: Adding {itemName} to inventory.");
TryAddItem(player, itemName);
}
});

if (Ammo.Count > 0)
{
Timing.CallDelayed(
0.5f,
() =>
if (Ammo.Count > 0)
{
Log.Debug($"{Name}: Adding Ammo to {player.Nickname} inventory.");
foreach (AmmoType type in EnumUtils<AmmoType>.Values)
{
if (type != AmmoType.None)
player.SetAmmo(type, Ammo.ContainsKey(type) ? Ammo[type] == ushort.MaxValue ? InventoryLimits.GetAmmoLimit(type.GetItemType(), player.ReferenceHub) : Ammo[type] : (ushort)0);
}
});
}
}
});

Log.Debug($"{Name}: Setting health values.");
player.Health = MaxHealth;
Expand Down

0 comments on commit c0bf400

Please sign in to comment.