예제 #1
0
        public static string GetCharacterTabletApps(int charId)
        {
            if (charId == 0)
            {
                return("");
            }

            var items = CharactersTabletApps_.Where(x => x.charId == charId).Select(x => new
            {
                x.weather,
                x.news,
                x.banking,
                x.lifeinvader,
                x.vehicles,
                x.events,
                company = ServerCompanys.IsCharacterInAnyServerCompany(charId),
                x.notices,
                factionmanager = ServerFactions.IsCharacterInAnyFaction(charId) && (ServerFactions.GetCharacterFactionRank(charId) >= ServerFactions.GetFactionMaxRankCount(ServerFactions.GetCharacterFactionId(charId)) - 2),
                lspdapp        = ServerFactions.IsCharacterInAnyFaction(charId) && ServerFactions.IsCharacterInFactionDuty(charId) && ServerFactions.GetCharacterFactionId(charId) == 2,
                lsfdapp        = ServerFactions.IsCharacterInAnyFaction(charId) && ServerFactions.IsCharacterInFactionDuty(charId) && ServerFactions.GetCharacterFactionId(charId) == 3,
                aclsapp        = ServerFactions.IsCharacterInAnyFaction(charId) && ServerFactions.IsCharacterInFactionDuty(charId) && ServerFactions.GetCharacterFactionId(charId) == 4,
                justiceapp     = ServerFactions.IsCharacterInAnyFaction(charId) && ServerFactions.IsCharacterInFactionDuty(charId) && ServerFactions.GetCharacterFactionId(charId) == 1,
            }).ToList();

            return(JsonConvert.SerializeObject(items));
        }
예제 #2
0
        public static void RequestClothesStorage(ClassicPlayer player, int storageId)
        {
            try
            {
                if (player == null || !player.Exists || player.CharacterId <= 0 || storageId <= 0)
                {
                    return;
                }
                int storageFaction = GetStorageFaction(storageId);
                int gender         = Convert.ToInt32(Characters.GetCharacterGender(player.CharacterId));
                if (storageFaction > 0 && (!ServerFactions.IsCharacterInAnyFaction(player.CharacterId) || ServerFactions.GetCharacterFactionId(player.CharacterId) != storageFaction))
                {
                    return;
                }
                var userClothes = CharactersClothes.CharactersOwnedClothes_.ToList().Where(x => x.charId == player.CharacterId).Select(x => new
                {
                    x.clothesName,
                    clothesType = ServerClothes.GetClothesType(x.clothesName),
                    clothesDraw = ServerClothes.GetClothesDraw(x.clothesName),
                    clothesTex  = ServerClothes.GetClothesTexture(x.clothesName),
                }).ToList();

                var userCount  = (int)userClothes.Count;
                var iterations = Math.Floor((decimal)(userCount / 25));
                var rest       = userCount % 25;
                for (var i = 0; i < iterations; i++)
                {
                    var skip = i * 25;
                    player.EmitLocked("Client:ClothesStorage:sendItemsToClient", JsonConvert.SerializeObject(userClothes.Skip(skip).Take(25).ToList()));
                }
                if (rest != 0)
                {
                    player.EmitLocked("Client:ClothesStorage:sendItemsToClient", JsonConvert.SerializeObject(userClothes.Skip((int)iterations * 25).ToList()));
                }

                if (storageFaction > 0)
                {
                    var factionClothes = ServerFactionClothes_.ToList().Where(x => x.faction == storageFaction).Select(x => new
                    {
                        x.clothesName,
                        clothesType = ServerClothes.GetClothesType(x.clothesName),
                        clothesDraw = ServerClothes.GetClothesDraw(x.clothesName),
                        clothesTex  = ServerClothes.GetClothesTexture(x.clothesName),
                    }).ToList();
                    var factionCount      = (int)factionClothes.Count;
                    var factioniterations = Math.Floor((decimal)(factionCount / 25));
                    var factionrest       = factionCount % 25;
                    for (var i = 0; i < factioniterations; i++)
                    {
                        var factionskip = i * 25;
                        player.EmitLocked("Client:ClothesStorage:sendItemsToClient", JsonConvert.SerializeObject(factionClothes.Skip(factionskip).Take(25).ToList()));
                    }
                    if (factionrest != 0)
                    {
                        player.EmitLocked("Client:ClothesStorage:sendItemsToClient", JsonConvert.SerializeObject(factionClothes.Skip((int)factioniterations * 25).ToList()));
                    }
                }

                var availableClothes = ServerClothes.ServerClothes_.ToList().Where(x => x.type == "Torso" && x.gender == gender).Select(x => new
                {
                    x.clothesName,
                    clothesType = x.type,
                    clothesDraw = x.draw,
                    clothesTex  = x.texture,
                }).ToList();

                var torsoCount      = (int)availableClothes.Count;
                var torsoIterations = Math.Floor((decimal)(torsoCount / 25));
                var torsoRest       = torsoCount % 25;
                for (var i = 0; i < torsoIterations; i++)
                {
                    var torsoskip = i * 25;
                    player.EmitLocked("Client:ClothesStorage:sendItemsToClient", JsonConvert.SerializeObject(availableClothes.Skip(torsoskip).Take(25).ToList()));
                }
                if (torsoRest != 0)
                {
                    player.EmitLocked("Client:ClothesStorage:sendItemsToClient", JsonConvert.SerializeObject(availableClothes.Skip((int)torsoIterations * 25).ToList()));
                }

                player.EmitLocked("Client:ClothesStorage:createCEF");
            }
            catch (Exception e)
            {
                Alt.Log($"{e}");
            }
        }