コード例 #1
0
        public void FactionCMD(IPlayer player, int charId, int id)
        {
            try
            {
                if (player == null || !player.Exists || player.GetCharacterMetaId() <= 0)
                {
                    return;
                }
                if (player.AdminLevel() <= 8)
                {
                    HUDHandler.SendNotification(player, 4, 5000, "Keine Rechte."); return;
                }
                if (ServerFactions.IsCharacterInAnyFaction(charId))
                {
                    ServerFactions.RemoveServerFactionMember(ServerFactions.GetCharacterFactionId(charId), charId);
                }

                ServerFactions.CreateServerFactionMember(id, charId, ServerFactions.GetFactionMaxRankCount(id), charId);
                player.SendChatMessage($"Done.");
            }
            catch (Exception e)
            {
                Alt.Log($"{e}");
            }
        }
コード例 #2
0
        public async Task WithdrawFactionMoney(IPlayer player, string type, int factionId, int moneyAmount) //Type: faction | company
        {
            try
            {
                if (player == null || !player.Exists || factionId <= 0 || moneyAmount < 1 || type == "")
                {
                    return;
                }
                if (type != "faction" && type != "company")
                {
                    return;
                }
                int charid = User.GetPlayerOnline(player);
                if (charid == 0)
                {
                    return;
                }

                if (type == "faction")
                {
                    if (!ServerFactions.IsCharacterInAnyFaction(charid))
                    {
                        HUDHandler.SendNotification(player, 4, 5000, "Du bist in keiner Fraktion und hast keine Berechtigung dazu."); return;
                    }
                    if (factionId != ServerFactions.GetCharacterFactionId(charid))
                    {
                        HUDHandler.SendNotification(player, 4, 5000, "Ein unerwarteter Fehler ist aufgetreten. [FACTIONBANK-001]"); return;
                    }
                    if (ServerFactions.GetCharacterFactionRank(charid) != ServerFactions.GetFactionMaxRankCount(factionId) && ServerFactions.GetCharacterFactionRank(charid) != ServerFactions.GetFactionMaxRankCount(factionId) - 1)
                    {
                        HUDHandler.SendNotification(player, 3, 5000, "Du hast nicht den benötigten Rang um auf das Fraktionskonto zuzugreifen."); return;
                    }
                    if (ServerFactions.GetFactionBankMoney(factionId) < moneyAmount)
                    {
                        HUDHandler.SendNotification(player, 3, 5000, "Soviel Geld ist auf dem Fraktionskonto nicht vorhanden."); return;
                    }
                    ServerFactions.SetFactionBankMoney(factionId, ServerFactions.GetFactionBankMoney(factionId) - moneyAmount);
                    CharactersInventory.AddCharacterItem(charid, "Bargeld", moneyAmount, "inventory");
                    HUDHandler.SendNotification(player, 2, 5000, $"Du hast erfolgreich {moneyAmount}$ vom Fraktionskonto abgebucht.");
                    LoggingService.NewFactionLog(factionId, charid, 0, "bank", $"{Characters.GetCharacterName(charid)} ({charid}) hat {moneyAmount}$ vom Fraktionskonto abgebucht.");
                    return;
                }
                else if (type == "company")
                {
                    if (!ServerCompanys.IsCharacterInAnyServerCompany(charid))
                    {
                        HUDHandler.SendNotification(player, 4, 5000, "Du bist in keinem Unternehmen und hast keine Berechtigung dazu."); return;
                    }
                    if (factionId != ServerCompanys.GetCharacterServerCompanyId(charid))
                    {
                        HUDHandler.SendNotification(player, 4, 5000, "Ein unerwarteter Fehler ist aufgetreten. [FACTIONBANK-0001]"); return;
                    }
                    if (ServerCompanys.GetCharacterServerCompanyRank(charid) < 1)
                    {
                        HUDHandler.SendNotification(player, 3, 5000, "Du hast nicht den benötigten Rang um auf das Unternehmenskonto zuzugreifen."); return;
                    }
                    if (ServerCompanys.GetServerCompanyMoney(factionId) < moneyAmount)
                    {
                        HUDHandler.SendNotification(player, 3, 5000, "Soviel Geld ist auf dem Unternehmenskonto nicht vorhanden."); return;
                    }
                    ServerCompanys.SetServerCompanyMoney(factionId, ServerCompanys.GetServerCompanyMoney(factionId) - moneyAmount);
                    CharactersInventory.AddCharacterItem(charid, "Bargeld", moneyAmount, "inventory");
                    HUDHandler.SendNotification(player, 2, 5000, $"Du hast erfolgreich {moneyAmount}$ vom Unternehmenskonto abgebucht.");
                    LoggingService.NewCompanyLog(factionId, charid, 0, "bank", $"{Characters.GetCharacterName(charid)} ({charid}) hat {moneyAmount} vom Unternehmenskonto abgebucht.");
                    return;
                }
            }
            catch (Exception e)
            {
                Alt.Log($"{e}");
            }
        }
コード例 #3
0
ファイル: KeyHandler.cs プロジェクト: h04X-2K/ValeaRP
        public async Task PressE(IPlayer player)
        {
            lock (player)
            {
                if (player == null || !player.Exists)
                {
                    return;
                }
                int charId = User.GetPlayerOnline(player);
                if (charId == 0)
                {
                    return;
                }

                ClassicColshape farmCol = (ClassicColshape)ServerFarmingSpots.ServerFarmingSpotsColshapes_.FirstOrDefault(x => ((ClassicColshape)x).IsInRange((ClassicPlayer)player));
                if (farmCol != null && !player.IsInVehicle)
                {
                    if (player.HasPlayerHandcuffs() || player.HasPlayerRopeCuffs())
                    {
                        HUDHandler.SendNotification(player, 3, 5000, "Wie willst du das mit Handschellen/Fesseln machen?"); return;
                    }
                    if (player.GetPlayerFarmingActionMeta() != "None")
                    {
                        return;
                    }
                    var farmColData = ServerFarmingSpots.ServerFarmingSpots_.FirstOrDefault(x => x.id == (int)farmCol.GetColShapeId());

                    if (farmColData != null)
                    {
                        if (farmColData.neededItemToFarm != "None")
                        {
                            if (!CharactersInventory.ExistCharacterItem(charId, farmColData.neededItemToFarm, "inventory") && !CharactersInventory.ExistCharacterItem(charId, farmColData.neededItemToFarm, "backpack"))
                            {
                                HUDHandler.SendNotification(player, 3, 3500, $"Zum Farmen benötigst du: {farmColData.neededItemToFarm}."); return;
                            }
                        }
                        player.SetPlayerFarmingActionMeta("farm");
                        FarmingHandler.FarmFieldAction(player, farmColData.itemName, farmColData.itemMinAmount, farmColData.itemMaxAmount, farmColData.animation, farmColData.duration);
                        return;
                    }
                }

                ClassicColshape farmProducerCol = (ClassicColshape)ServerFarmingSpots.ServerFarmingProducerColshapes_.FirstOrDefault(x => ((ClassicColshape)x).IsInRange((ClassicPlayer)player));
                if (farmProducerCol != null && !player.IsInVehicle)
                {
                    if (player.GetPlayerFarmingActionMeta() != "None")
                    {
                        HUDHandler.SendNotification(player, 3, 5000, $"Warte einen Moment."); return;
                    }
                    var farmColData = ServerFarmingSpots.ServerFarmingProducer_.FirstOrDefault(x => x.id == (int)farmProducerCol.GetColShapeId());
                    if (farmColData != null)
                    {
                        FarmingHandler.ProduceItem(player, farmColData.neededItem, farmColData.producedItem, farmColData.neededItemAmount, farmColData.producedItemAmount, farmColData.duration);
                        return;
                    }
                }

                if (((ClassicColshape)Minijobs.Elektrolieferant.Main.startJobShape).IsInRange((ClassicPlayer)player))
                {
                    Minijobs.Elektrolieferant.Main.StartMinijob(player);
                    return;
                }

                if (((ClassicColshape)Minijobs.Pilot.Main.startJobShape).IsInRange((ClassicPlayer)player))
                {
                    Minijobs.Pilot.Main.TryStartMinijob(player);
                    return;
                }

                if (((ClassicColshape)Minijobs.Müllmann.Main.startJobShape).IsInRange((ClassicPlayer)player))
                {
                    Minijobs.Müllmann.Main.StartMinijob(player);
                    return;
                }

                if (((ClassicColshape)Minijobs.Busfahrer.Main.startJobShape).IsInRange((ClassicPlayer)player))
                {
                    Minijobs.Busfahrer.Main.TryStartMinijob(player);
                    return;
                }

                var houseEntrance = ServerHouses.ServerHouses_.FirstOrDefault(x => ((ClassicColshape)x.entranceShape).IsInRange((ClassicPlayer)player));
                if (houseEntrance != null)
                {
                    HouseHandler.openEntranceCEF(player, houseEntrance.id);
                    return;
                }

                var hotelPos = ServerHotels.ServerHotels_.FirstOrDefault(x => player.Position.IsInRange(new Position(x.posX, x.posY, x.posZ), 2f));
                if (hotelPos != null && !player.IsInVehicle)
                {
                    HotelHandler.openCEF(player, hotelPos);
                    return;
                }

                if (player.Dimension >= 5000)
                {
                    int houseInteriorCount = ServerHouses.GetMaxInteriorsCount();
                    for (var i = 1; i <= houseInteriorCount; i++)
                    {
                        if (i > houseInteriorCount || i <= 0)
                        {
                            continue;
                        }
                        if ((player.Dimension >= 5000 && player.Dimension < 10000) && player.Position.IsInRange(ServerHouses.GetInteriorExitPosition(i), 2f))
                        {
                            //Apartment Leave
                            HotelHandler.LeaveHotel(player);
                            return;
                        }
                        else if ((player.Dimension >= 5000 && player.Dimension < 10000) && player.Position.IsInRange(ServerHouses.GetInteriorStoragePosition(i), 2f))
                        {
                            //Apartment Storage
                            HotelHandler.openStorage(player);
                            return;
                        }
                        else if (player.Dimension >= 10000 && player.Position.IsInRange(ServerHouses.GetInteriorExitPosition(i), 2f))
                        {
                            //House Leave
                            HouseHandler.LeaveHouse(player, i);
                            return;
                        }
                        else if (player.Dimension >= 10000 && player.Position.IsInRange(ServerHouses.GetInteriorStoragePosition(i), 2f))
                        {
                            //House Storage
                            HouseHandler.openStorage(player);
                            return;
                        }
                        else if (player.Dimension >= 10000 && player.Position.IsInRange(ServerHouses.GetInteriorManagePosition(i), 2f))
                        {
                            //Hausverwaltung
                            HouseHandler.openManageCEF(player);
                            return;
                        }
                    }
                }

                var teleportsPos = ServerItems.ServerTeleports_.FirstOrDefault(x => player.Position.IsInRange(new Position(x.posX, x.posY, x.posZ), 1.5f));
                if (teleportsPos != null && !player.IsInVehicle)
                {
                    player.Position = new Position(teleportsPos.targetX, teleportsPos.targetY, teleportsPos.targetZ + 0.5f);
                    return;
                }

                var shopPos = ServerShops.ServerShops_.FirstOrDefault(x => player.Position.IsInRange(new Position(x.posX, x.posY, x.posZ), 3f));
                if (shopPos != null && !player.IsInVehicle)
                {
                    if (player.HasPlayerHandcuffs() || player.HasPlayerRopeCuffs())
                    {
                        HUDHandler.SendNotification(player, 3, 5000, "Wie willst du das mit Handschellen/Fesseln machen?"); return;
                    }
                    ShopHandler.openShop(player, shopPos);
                    return;
                }

                var garagePos = ServerGarages.ServerGarages_.FirstOrDefault(x => player.Position.IsInRange(new Position(x.posX, x.posY, x.posZ), 2f));
                if (garagePos != null && !player.IsInVehicle)
                {
                    GarageHandler.OpenGarageCEF(player, garagePos.id);
                    return;
                }

                var clothesStoragePos = ServerClothesStorages.ServerClothesStorages_.ToList().FirstOrDefault(x => player.Position.IsInRange(new Position(x.posX, x.posY, x.posZ), 5f));
                if (clothesStoragePos != null && !player.IsInVehicle)
                {
                    ServerClothesStorages.RequestClothesStorage((ClassicPlayer)player, clothesStoragePos.id);
                    return;
                }

                var clothesShopPos = ServerClothesShops.ServerClothesShops_.FirstOrDefault(x => player.Position.IsInRange(new Position(x.posX, x.posY, x.posZ), 6f));
                if (clothesShopPos != null && !player.IsInVehicle)
                {
                    ShopHandler.openClothesShop((ClassicPlayer)player, clothesShopPos.id);
                    return;
                }

                var tattooShop = ServerTattooShops.ServerTattooShops_.ToList().FirstOrDefault(x => x.owner != 0 && player.Position.IsInRange(new Position(x.pedX, x.pedY, x.pedZ), 2.5f));
                if (tattooShop != null && !player.IsInVehicle)
                {
                    ShopHandler.openTattooShop((ClassicPlayer)player, tattooShop);
                    return;
                }

                var vehicleShopPos = ServerVehicleShops.ServerVehicleShops_.FirstOrDefault(x => player.Position.IsInRange(new Position(x.pedX, x.pedY, x.pedZ), 2f));
                if (vehicleShopPos != null && !player.IsInVehicle)
                {
                    if (vehicleShopPos.neededLicense != "None" && !Characters.HasCharacterPermission(charId, vehicleShopPos.neededLicense))
                    {
                        HUDHandler.SendNotification(player, 3, 5000, $"Du hast hier keinen Zugriff drauf."); return;
                    }
                    ShopHandler.OpenVehicleShop(player, vehicleShopPos.name, vehicleShopPos.id);
                    return;
                }

                var bankPos = ServerBanks.ServerBanks_.FirstOrDefault(x => player.Position.IsInRange(new Position(x.posX, x.posY, x.posZ), 1f));
                if (bankPos != null && !player.IsInVehicle)
                {
                    if (bankPos.zoneName == "Maze Bank Fraktion")
                    {
                        if (!ServerFactions.IsCharacterInAnyFaction(charId))
                        {
                            return;
                        }
                        if (ServerFactions.GetCharacterFactionRank(charId) != ServerFactions.GetFactionMaxRankCount(ServerFactions.GetCharacterFactionId(charId)) && ServerFactions.GetCharacterFactionRank(charId) != ServerFactions.GetFactionMaxRankCount(ServerFactions.GetCharacterFactionId(charId)) - 1)
                        {
                            return;
                        }
                        player.EmitLocked("Client:FactionBank:createCEF", "faction", ServerFactions.GetCharacterFactionId(charId), ServerFactions.GetFactionBankMoney(ServerFactions.GetCharacterFactionId(charId)));
                        return;
                    }
                    else if (bankPos.zoneName == "Maze Bank Company")
                    {
                        if (!ServerCompanys.IsCharacterInAnyServerCompany(charId))
                        {
                            return;
                        }
                        if (ServerCompanys.GetCharacterServerCompanyRank(charId) != 1 && ServerCompanys.GetCharacterServerCompanyRank(charId) != 2)
                        {
                            HUDHandler.SendNotification(player, 3, 5000, "Du hast kein Unternehmen auf welches du zugreifen kannst."); return;
                        }
                        player.EmitLocked("Client:FactionBank:createCEF", "company", ServerCompanys.GetCharacterServerCompanyId(charId), ServerCompanys.GetServerCompanyMoney(ServerCompanys.GetCharacterServerCompanyId(charId)));
                        return;
                    }
                    else
                    {
                        var bankArray = CharactersBank.GetCharacterBankAccounts(charId);
                        player.EmitLocked("Client:Bank:createBankAccountManageForm", bankArray, bankPos.zoneName);
                        return;
                    }
                }

                var barberPos = ServerBarbers.ServerBarbers_.FirstOrDefault(x => player.Position.IsInRange(new Position(x.posX, x.posY, x.posZ), 2f));
                if (barberPos != null && !player.IsInVehicle)
                {
                    player.EmitLocked("Client:Barber:barberCreateCEF", Characters.GetCharacterHeadOverlays(charId));
                    return;
                }

                if (player.Position.IsInRange(Constants.Positions.VehicleLicensing_Position, 3f))
                {
                    if (player.HasPlayerHandcuffs() || player.HasPlayerRopeCuffs())
                    {
                        HUDHandler.SendNotification(player, 3, 5000, "Wie willst du das mit Handschellen/Fesseln machen?"); return;
                    }
                    VehicleHandler.OpenLicensingCEF(player);
                    return;
                }

                if (ServerFactions.IsCharacterInAnyFaction(charId))
                {
                    int factionId      = ServerFactions.GetCharacterFactionId(charId);
                    var factionDutyPos = ServerFactions.ServerFactionPositions_.FirstOrDefault(x => x.factionId == factionId && x.posType == "duty" && player.Position.IsInRange(new Position(x.posX, x.posY, x.posZ), 2f));
                    if (factionDutyPos != null && !player.IsInVehicle)
                    {
                        bool isDuty = ServerFactions.IsCharacterInFactionDuty(charId);
                        ServerFactions.SetCharacterInFactionDuty(charId, !isDuty);
                        if (isDuty)
                        {
                            HUDHandler.SendNotification(player, 2, 5000, "Du hast dich erfolgreich vom Dienst abgemeldet.");
                        }
                        else
                        {
                            HUDHandler.SendNotification(player, 2, 5000, "Du hast dich erfolgreich zum Dienst angemeldet.");
                        }
                        if (factionId == 2 || factionId == 12)
                        {
                            SmartphoneHandler.RequestLSPDIntranet((ClassicPlayer)player);
                        }
                        return;
                    }

                    var factionStoragePos = ServerFactions.ServerFactionPositions_.FirstOrDefault(x => x.factionId == factionId && x.posType == "storage" && player.Position.IsInRange(new Position(x.posX, x.posY, x.posZ), 2f));
                    if (factionStoragePos != null && !player.IsInVehicle)
                    {
                        if (player.HasPlayerHandcuffs() || player.HasPlayerRopeCuffs())
                        {
                            HUDHandler.SendNotification(player, 3, 5000, "Wie willst du das mit Handschellen/Fesseln machen?"); return;
                        }
                        bool isDuty = ServerFactions.IsCharacterInFactionDuty(charId);
                        if (isDuty)
                        {
                            var factionStorageContent = ServerFactions.GetServerFactionStorageItems(factionId, charId); //Fraktionsspind Items
                            var CharacterInvArray     = CharactersInventory.GetCharacterInventory(charId);              //Spieler Inventar
                            player.EmitLocked("Client:FactionStorage:openCEF", charId, factionId, "faction", CharacterInvArray, factionStorageContent);
                            return;
                        }
                    }

                    var factionServicePhonePos = ServerFactions.ServerFactionPositions_.ToList().FirstOrDefault(x => x.factionId == factionId && x.posType == "servicephone" && player.Position.IsInRange(new Position(x.posX, x.posY, x.posZ), 2f));
                    if (factionServicePhonePos != null && !player.IsInVehicle && ServerFactions.IsCharacterInFactionDuty(charId))
                    {
                        ServerFactions.UpdateCurrentServicePhoneOwner(factionId, charId);
                        ServerFactions.sendMsg(factionId, $"{Characters.GetCharacterName(charId)} hat das Leitstellentelefon deiner Fraktion übernommen.");
                        return;
                    }
                }

                if (player.Position.IsInRange(Constants.Positions.Jobcenter_Position, 2.5f) && !Characters.IsCharacterCrimeFlagged(charId) && !player.IsInVehicle) //Arbeitsamt
                {
                    TownhallHandler.createJobcenterBrowser(player);
                    return;
                }

                if (player.Position.IsInRange(Constants.Positions.TownhallHouseSelector, 2.5f))
                {
                    TownhallHandler.openHouseSelector(player);
                    return;
                }

                if (player.Position.IsInRange(Constants.Positions.IdentityCardApply, 2.5f) && Characters.GetCharacterAccState(charId) == 0 && !player.IsInVehicle) //Rathaus IdentityCardApply
                {
                    TownhallHandler.tryCreateIdentityCardApplyForm(player);
                    return;
                }
            }
        }