Beispiel #1
0
        public void GiveKit(IServerPlayer player, string kitName)
        {
            var kit = GetLoadedKits().kits.Find(
                x => x.name == kitName
                );

            if (kit != null)
            {
                if (!player.HasPrivilege(Privilege.ignoreCooldowns))
                {
                    var cooldown =
                        GetCooldownManager().GetCooldown(player.PlayerUID, kitName);
                    if (cooldown > 0)
                    {
                        player.SendErr($"You must wait {cooldown} sec. to use this kit");
                        return;
                    }
                }
                if (!player.HasPrivilege($"{Privilege.kit}.{kit.name}"))
                {
                    player.SendErr($"You don't have access to kit {kit.name}");
                    return;
                }
                player.SendOk($"Giving kit {kit.name}");
                // TODO: if inventory full, should use player.Entity.World.SpawnItemEntity();
                kit.items.ForEach(
                    item => player.GiveItemStack(item.type, item.code, item.amount)
                    );
                GetCooldownManager().SetCooldown(player.PlayerUID, kitName, kit.delay);
            }
            else
            {
                player.SendErr($"{kitName} not found");
            }
        }