Exemplo n.º 1
0
        internal void InvokePlayerReloadEvent(Player player, ref bool allow, Items.SynapseItem syncItemInfo)
        {
            var ev = new PlayerReloadEventArgs {
                Allow = allow, Item = syncItemInfo, Player = player
            };

            PlayerReloadEvent?.Invoke(ev);

            allow = ev.Allow;
        }
Exemplo n.º 2
0
        //Used by:
        //Tranquilizer
        //MedkitGun
        //SCP-127
        //Sniper
        //GrenadeLauncher
        //VaccinePistole
        private void OnReload(PlayerReloadEventArgs ev)
        {
            switch (ev.Item?.ID)
            {
            case (int)CustomItemType.Tranquilizer:
                ev.Allow = false;

                if (ev.Item.Durabillity >= PluginClass.TzConfig.MagazineSize || !PluginClass.TzConfig.Reloadable)
                {
                    return;
                }

                var reloadAmount = PluginClass.TzConfig.MagazineSize - ev.Item.Durabillity;

                if (ev.Player.AmmoBox[AmmoType.Ammo9x19] < reloadAmount * PluginClass.TzConfig.AmooNeededForOneShoot)
                {
                    reloadAmount = ev.Player.AmmoBox[AmmoType.Ammo9x19] / PluginClass.TzConfig.AmooNeededForOneShoot;
                }

                ev.Item.Durabillity += reloadAmount;
                ev.Player.AmmoBox[AmmoType.Ammo9x19] -= (ushort)(reloadAmount * PluginClass.TzConfig.AmooNeededForOneShoot);
                break;

            case (int)CustomItemType.MedkitGun:
                ev.Allow = false;

                if (!PluginClass.MedkitGunConfig.CanBeReloaded)
                {
                    return;
                }

                foreach (var medkit in ev.Player.Inventory.Items.Where(x => x.ID == (int)ItemType.Medkit))
                {
                    if (ev.Item.Durabillity >= PluginClass.MedkitGunConfig.MagazineSize)
                    {
                        return;
                    }

                    medkit.Destroy();
                    ev.Item.Durabillity++;
                }
                break;

            case (int)CustomItemType.Scp127:
                ev.Allow = false;
                break;

            case (int)CustomItemType.Sniper:
                ev.Allow = false;

                if (ev.Item.Durabillity >= PluginClass.SnConfig.MagazineSize)
                {
                    return;
                }

                reloadAmount = PluginClass.SnConfig.MagazineSize - ev.Item.Durabillity;

                if (ev.Player.AmmoBox[AmmoType.Ammo556x45] < reloadAmount * PluginClass.SnConfig.AmooNeededForOneShoot)
                {
                    reloadAmount = ev.Player.AmmoBox[AmmoType.Ammo556x45] / PluginClass.SnConfig.AmooNeededForOneShoot;
                }

                ev.Item.Durabillity += reloadAmount;
                ev.Player.AmmoBox[AmmoType.Ammo556x45] -= (ushort)(reloadAmount * PluginClass.SnConfig.AmooNeededForOneShoot);
                break;

            case (int)CustomItemType.GrenadeLauncher:
                ev.Allow = false;

                if (!PluginClass.GLConfig.CanBeReloaded)
                {
                    return;
                }

                foreach (var grenade in ev.Player.Inventory.Items.Where(x => x.ID == (int)ItemType.GrenadeHE))
                {
                    if (ev.Item.Durabillity >= PluginClass.GLConfig.MagazineSize)
                    {
                        return;
                    }

                    grenade.Destroy();
                    ev.Item.Durabillity++;
                }
                break;

            case (int)CustomItemType.VaccinePistole:
                ev.Allow = false;

                foreach (var scp500 in ev.Player.Inventory.Items.Where(x => x.ID == (int)ItemType.SCP500))
                {
                    if (ev.Item.Durabillity >= PluginClass.VPConfig.MagazineSize)
                    {
                        return;
                    }

                    scp500.Destroy();
                    ev.Item.Durabillity++;
                }
                break;
            }
        }
Exemplo n.º 3
0
 public void PlayerReload(PlayerReloadEventArgs e) => OnPlayerReload?.Invoke(this, e);