Esempio n. 1
0
        public static IEnumerator <float> _SetClass(ReferenceHub player, Subclass subclass)
        {
            List <int> indexesToRemove = new List <int>();

            if (subclass.role != RoleType.NtfCadet)
            {
                player.characterClassManager.SetPlayersClass(subclass.role, player.gameObject);
            }
            yield return(Timing.WaitForSeconds(MTFplus.Instance.Configs.delay));

            if (subclass.inventory.Count > 0)
            {
                player.inventory.items.Clear();

                foreach (ItemType item in subclass.inventory)
                {
                    player.inventory.AddNewItem(item);
                }
            }
#if ItemManager
            for (int i = 0; i < 16; i++)
            {
                if (subclass.imInv[i] < 0)
                {
                    continue;
                }
                if (!GrantCustomItem(player, subclass, subclass.imInv[i], i))
                {
                    MTFplus.Instance.Error("Custom item (ItemManager) with ID: " + subclass.imInv[i] + " doesn't exist/isn't installed!");
                    indexesToRemove.Add(i); // That's the index inside the inventory, and a coin was there as a placeholder
                }
            }
#endif
            try
            {
                player.ammoBox.Networkamount = string.Concat(new string[]
                {
                    subclass.ammo[0].ToString(),
                    ":",
                    subclass.ammo[1].ToString(),
                    ":",
                    subclass.ammo[2].ToString()
                });
            }
            catch (Exception e)
            {
                EXILED.Plugin.Error("Bruh momento\n" + e);
            }

#if ItemManager // Not even updated lol
            List <Smod2.API.Item> inv = player.GetInventory();
            foreach (int i in indexesToRemove)
            {
                inv[i].Remove();
            }
#endif
            try
            {
                if (subclass.maxHP > 0)
                {
                    player.playerStats.maxHP = subclass.maxHP;
                    player.playerStats.SetHPAmount(subclass.maxHP);
                }
                if (!string.IsNullOrWhiteSpace(subclass.broadcast))
                {
                    player.GetComponent <Broadcast>().TargetAddElement(player.characterClassManager.connectionToClient, subclass.broadcast, 5u, false);
                }
            }
            catch (Exception e)
            {
                EXILED.Plugin.Error(e.ToString());
            }
        }