protected virtual void OnReloadingWeapon(ReloadingWeaponEventArgs ev) { if (CheckItem(ev.Player.CurrentItem)) { ev.IsAllowed = false; Log.Debug($"{ev.Player.Nickname} is reloading a {Name}!", Plugin.Singleton.Config.Debug); int remainingInClip = ClipSize - (int)ev.Player.CurrentItem.durability; int currentAmmoAmount = (int)ev.Player.Ammo[ev.Player.ReferenceHub.weaponManager.weapons[ev.Player.ReferenceHub.weaponManager.curWeapon].ammoType]; int amountToReload = ClipSize - remainingInClip; if (currentAmmoAmount >= 0) { ev.Player.ReferenceHub.weaponManager.scp268.ServerDisable(); Reload(ev.Player); int amountAfterReload = currentAmmoAmount - amountToReload; if (amountAfterReload < 0) { ev.Player.Ammo[ev.Player.ReferenceHub.weaponManager.weapons[ev.Player.ReferenceHub.weaponManager.curWeapon].ammoType] = 0; } else { ev.Player.Ammo[ev.Player.ReferenceHub.weaponManager.weapons[ev.Player.ReferenceHub.weaponManager.curWeapon].ammoType] = (uint)(currentAmmoAmount - amountToReload); } ev.Player.Inventory.items.ModifyDuration(ev.Player.Inventory.GetItemIndex(), ClipSize); Log.Debug($"{ev.Player.Nickname} - {ev.Player.CurrentItem.durability} - {ev.Player.Ammo[ev.Player.ReferenceHub.weaponManager.weapons[ev.Player.ReferenceHub.weaponManager.curWeapon].ammoType]}", Plugin.Singleton.Config.Debug); Timing.CallDelayed(4.5f, () => { Reload(ev.Player); }); } } }
internal void OnReloadWeapon(ReloadingWeaponEventArgs ev) { if (!config.Weapon.canReloadWeaponGlobal && !config.Weapon.canReloadWeapon[ev.Player.Role]) { ev.IsAllowed = false; } }
private static bool Prefix(WeaponManager __instance, bool animationOnly) { try { if (!__instance._iawRateLimit.CanExecute(false)) { return(false); } int itemIndex = __instance._hub.inventory.GetItemIndex(); if (itemIndex < 0 || itemIndex >= __instance._hub.inventory.items.Count || (__instance.curWeapon < 0 || __instance._hub.inventory.curItem != __instance.weapons[__instance.curWeapon].inventoryID) || __instance._hub.inventory.items[itemIndex].durability >= (double)__instance.weapons[__instance.curWeapon].maxAmmo) { return(false); } var ev = new ReloadingWeaponEventArgs(API.Features.Player.Get(__instance.gameObject), animationOnly); Player.OnReloadingWeapon(ev); return(ev.IsAllowed); } catch (Exception e) { Exiled.API.Features.Log.Error($"Exiled.Events.Patches.Events.Player.ReloadingWeapon: {e}\n{e.StackTrace}"); return(true); } }
public async void OnReloadingWeapon(ReloadingWeaponEventArgs ev) { if (Instance.Config.EventsToLog.ReloadingPlayerWeapon && (!ev.Player.DoNotTrack || !Instance.Config.ShouldRespectDoNotTrack)) { await Network.SendAsync(new RemoteCommand("log", "gameEvents", string.Format(Language.Reloaded, ev.Player.Nickname, Instance.Config.ShouldLogUserIds ? ev.Player.UserId : Language.Redacted, ev.Player.CurrentItem.id, ev.Player.Role))).ConfigureAwait(false); } }
protected override void OnReloadingWeapon(ReloadingWeaponEventArgs ev) { if (CheckItem(ev.Player.CurrentItem)) { ev.IsAllowed = false; } }
/// <inheritdoc/> protected override void OnReloading(ReloadingWeaponEventArgs ev) { if (UseGrenades) { ev.IsAllowed = false; if (ev.Player.CurrentItem.durability >= ClipSize) { return; } Log.Debug($"{ev.Player.Nickname} is reloading a {Name}!", CustomItems.Instance.Config.IsDebugEnabled); foreach (Inventory.SyncItemInfo item in ev.Player.Inventory.items.ToList()) { if (item.id != ItemType.GrenadeFrag) { continue; } if (TryGet(item, out CustomItem cItem)) { if (IgnoreModdedGrenades) { continue; } if (cItem is CustomGrenade customGrenade) { loadedCustomGrenade = customGrenade; } } ev.Player.ReferenceHub.weaponManager.scp268.ServerDisable(); ev.Player.ReloadWeapon(); ev.Player.Inventory.items.ModifyDuration(ev.Player.Inventory.GetItemIndex(), ClipSize); Log.Debug($"{ev.Player.Nickname} successfully reloaded a {Name}.", CustomItems.Instance.Config.IsDebugEnabled); Timing.CallDelayed(4.5f, () => { ev.Player.ReloadWeapon(); }); ev.Player.RemoveItem(item); break; } Log.Debug($"{ev.Player.Nickname} was unable to reload their {Name} - No grenades in inventory.", CustomItems.Instance.Config.IsDebugEnabled); } else { base.OnReloading(ev); } }
/// <inheritdoc/> protected override void OnReloading(ReloadingWeaponEventArgs ev) { if (UseGrenades) { ev.IsAllowed = false; if (!(ev.Player.CurrentItem is Firearm firearm) || firearm.Ammo >= ClipSize) { return; } Log.Debug($"{Name}.{nameof(OnReloading)}: {ev.Player.Nickname} is reloading!", CustomItems.Instance.Config.IsDebugEnabled); foreach (Item item in ev.Player.Items.ToList()) { Log.Debug($"{Name}.{nameof(OnReloading)}: Found item: {item.Type} - {item.Serial}", CustomItems.Instance.Config.IsDebugEnabled); if (item.Type != ItemType.GrenadeHE && item.Type != ItemType.GrenadeFlash && item.Type != ItemType.SCP018) { continue; } if (TryGet(item, out CustomItem cItem)) { if (IgnoreModdedGrenades) { continue; } if (cItem is CustomGrenade customGrenade) { loadedCustomGrenade = customGrenade; } } ev.Player.DisableEffect(EffectType.Invisible); ev.Player.Connection.Send(new RequestMessage(ev.Firearm.Serial, RequestType.Reload)); Timing.CallDelayed(3f, () => firearm.Ammo = ClipSize); loadedGrenade = item.Type == ItemType.GrenadeFlash ? GrenadeType.Flashbang : item.Type == ItemType.GrenadeHE ? GrenadeType.FragGrenade : GrenadeType.Scp018; Log.Debug($"{Name}.{nameof(OnReloading)}: {ev.Player.Nickname} successfully reloaded. Grenade type: {loadedGrenade} IsCustom: {loadedCustomGrenade != null}", CustomItems.Instance.Config.IsDebugEnabled); ev.Player.RemoveItem(item); return; } Log.Debug($"{Name}.{nameof(OnReloading)}: {ev.Player.Nickname} was unable to reload - No grenades in inventory.", CustomItems.Instance.Config.IsDebugEnabled); } }
internal void ReloadingWeapon(ReloadingWeaponEventArgs ev) { if (Plugin.Instance.Config.ReloadingWeapon == "") { return; } string message = Plugin.Instance.Config.ReloadingWeapon.Replace("%player%", ev.Player.ToString()); if (Plugin.Instance.Config.debug_to_console) { Log.Debug(message: "[ " + Plugin.Instance.Config.player_name + "] " + message); } Plugin.sendWebHook(Plugin.Instance.Config.player_url, message, Plugin.Instance.Config.player_name); }
// Token: 0x06000009 RID: 9 RVA: 0x0000252F File Offset: 0x0000072F private static void HandleWeaponReload(ReloadingWeaponEventArgs ev) { if (SameThings.ReduceAmmo) { return; } if (SameThings.NoInfAmmoTeam.Contains((int)ev.Player.Team)) { return; } //ev.Player.ReferenceHub.ammoBox.Networkamount = "101:101:101"; /*ev.Player.SetAmmo(AmmoType.Nato556, 101); * ev.Player.SetAmmo(AmmoType.Nato762, 101); * ev.Player.SetAmmo(AmmoType.Nato9, 101);*/ }
private static bool Prefix(WeaponManager __instance, bool animationOnly) { if (!__instance._iawRateLimit.CanExecute(false)) { return(false); } int itemIndex = __instance._hub.inventory.GetItemIndex(); if (itemIndex < 0 || itemIndex >= __instance._hub.inventory.items.Count || (__instance.curWeapon < 0 || __instance._hub.inventory.curItem != __instance.weapons[__instance.curWeapon].inventoryID) || __instance._hub.inventory.items[itemIndex].durability >= (double)__instance.weapons[__instance.curWeapon].maxAmmo) { return(false); } var ev = new ReloadingWeaponEventArgs(API.Features.Player.Get(__instance.gameObject), animationOnly); Player.OnReloadingWeapon(ev); return(ev.IsAllowed); }
/// <summary> /// Invoked before reloading a weapon. /// </summary> /// <param name="ev">The <see cref="ReloadingWeaponEventArgs"/> instance.</param> public static void OnReloadingWeapon(ReloadingWeaponEventArgs ev) => ReloadingWeapon.InvokeSafely(ev);
/// <inheritdoc cref="Exiled.Events.Handlers.Player.OnReloadingWeapon(ReloadingWeaponEventArgs)"/> public void OnReloading(ReloadingWeaponEventArgs ev) { Log.Info($"{ev.Player.Nickname} is reloading their {ev.Firearm.Type}. They have {ev.Firearm.Ammo} ammo. Using ammo type {ev.Firearm.AmmoType}"); }
/// <inheritdoc/> protected override void OnReloading(ReloadingWeaponEventArgs ev) => ev.IsAllowed = false;