Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 10 additions & 19 deletions EXILED/Exiled.CustomRoles/API/Features/CustomRole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,16 @@ public virtual void AddRole(Player player)
Log.Debug($"{Name}: Adding {itemName} to inventory.");
TryAddItem(player, itemName);
}

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.");
Expand Down Expand Up @@ -910,25 +920,6 @@ private void OnInternalChangingRole(ChangingRoleEventArgs ev)
{
RemoveRole(ev.Player);
}
else if (Check(ev.Player))
{
Log.Debug($"{Name}: Checking ammo stuff {Ammo.Count}");
if (Ammo.Count > 0)
{
Log.Debug($"{Name}: Clearing ammo");
ev.Ammo.Clear();
Timing.CallDelayed(
0.5f,
() =>
{
foreach (AmmoType type in Enum.GetValues(typeof(AmmoType)))
{
if (type != AmmoType.None)
ev.Player.SetAmmo(type, Ammo.ContainsKey(type) ? Ammo[type] == ushort.MaxValue ? InventoryLimits.GetAmmoLimit(type.GetItemType(), ev.Player.ReferenceHub) : Ammo[type] : (ushort)0);
}
});
}
}
}

private void OnSpawningRagdoll(SpawningRagdollEventArgs ev)
Expand Down