コード例 #1
0
        public async Task TowVehicle(IPlayer player, IVehicle vehicle)
        {
            try
            {
                if (player == null || !player.Exists || vehicle == null || !vehicle.Exists)
                {
                    return;
                }
                int charId = (int)player.GetCharacterMetaId();
                int vehId  = (int)vehicle.GetVehicleId();
                if (charId <= 0 || player.HasPlayerRopeCuffs() || player.HasPlayerHandcuffs() || player.IsPlayerUnconscious() || !ServerFactions.IsCharacterInAnyFaction(charId) || !vehicle.Position.IsInRange(Constants.Positions.AutoClubLosSantos_StoreVehPosition, 5f) || vehId <= 0)
                {
                    return;
                }
                if (ServerFactions.GetCharacterFactionId(charId) != 4)
                {
                    return;
                }
                int vehClass = ServerAllVehicles.GetVehicleClass(vehicle.Model);
                switch (vehClass)
                {
                case 0:     //Fahrzeuge
                    ServerVehicles.SetVehicleInGarage(vehicle, true, 10);
                    break;

                case 1:     //Boote
                    break;

                case 2:     //Flugzeuge
                    break;

                case 3:     //Helikopter
                    break;
                }
                ServerFactions.SetFactionBankMoney(4, ServerFactions.GetFactionBankMoney(4) + 1500); //ToDo: Anpassen
                HUDHandler.SendNotification(player, 2, 2000, "Fahrzeug erfolgreich verwahrt.");
                LoggingService.NewFactionLog(4, charId, vehId, "towVehicle", $"{Characters.GetCharacterName(charId)} hat das Fahrzeug mit der ID {vehId} abgeschleppt.");
            }
            catch (Exception e)
            {
                Alt.Log($"{e}");
            }
        }
コード例 #2
0
ファイル: DeathHandler.cs プロジェクト: h04X-2K/ValeaRP
 internal static void revive(IPlayer player)
 {
     try
     {
         if (player == null || !player.Exists)
         {
             return;
         }
         int charId = (int)player.GetCharacterMetaId();
         if (charId <= 0)
         {
             return;
         }
         player.EmitLocked("Client:Deathscreen:closeCEF");
         player.SetPlayerIsUnconscious(false);
         player.EmitLocked("Client:Ragdoll:SetPedToRagdoll", false, 2000);
         Characters.SetCharacterUnconscious(charId, false, 0);
         ServerFactions.SetFactionBankMoney(3, ServerFactions.GetFactionBankMoney(3) + 1500); //ToDo: Preis anpassen
     }
     catch (Exception e)
     {
         Alt.Log($"{e}");
     }
 }
コード例 #3
0
ファイル: TimerHandler.cs プロジェクト: h04X-2K/ValeaRP
        public static async void OnEntityTimer(object sender, ElapsedEventArgs e)
        {
            try
            {
                Console.WriteLine($"Timer - Thread = {Thread.CurrentThread.ManagedThreadId}");
                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();
                foreach (IVehicle Veh in Alt.Server.GetVehicles().ToList())
                {
                    if (Veh == null || !Veh.Exists)
                    {
                        continue;
                    }
                    using (var vRef = new VehicleRef(Veh))
                    {
                        if (!vRef.Exists)
                        {
                            continue;
                        }
                        lock (Veh)
                        {
                            if (Veh == null || !Veh.Exists)
                            {
                                continue;
                            }
                            ulong vehID = Veh.GetVehicleId();
                            if (vehID <= 0)
                            {
                                continue;
                            }
                            ServerVehicles.SaveVehiclePositionAndStates(Veh);
                            if (Veh.EngineOn == true)
                            {
                                ServerVehicles.SetVehicleFuel(Veh, ServerVehicles.GetVehicleFuel(Veh) - 0.03f);
                            }
                        }
                    }
                }

                stopwatch.Stop();
                Alt.Log($"OnEntityTimer: Vehicle Foreach benötigte: {stopwatch.Elapsed}");

                stopwatch.Reset();
                stopwatch.Start();
                foreach (IPlayer player in Alt.Server.GetPlayers().ToList())
                {
                    if (player == null)
                    {
                        continue;
                    }
                    using (var playerReference = new PlayerRef(player))
                    {
                        if (!playerReference.Exists)
                        {
                            return;
                        }
                        if (player == null || !player.Exists)
                        {
                            continue;
                        }
                        lock (player)
                        {
                            if (player == null || !player.Exists)
                            {
                                continue;
                            }
                            int charId = User.GetPlayerOnline(player);
                            if (charId > 0)
                            {
                                Characters.SetCharacterLastPosition(charId, player.Position, player.Dimension);
                                if (User.IsPlayerBanned(player))
                                {
                                    player.kickWithMessage($"Du bist gebannt. (Grund: {User.GetPlayerBanReason(player)}).");
                                }
                                Characters.SetCharacterHealth(charId, player.Health);
                                Characters.SetCharacterArmor(charId, player.Armor);
                                WeatherHandler.SetRealTime(player);
                                if (player.IsInVehicle)
                                {
                                    player.EmitLocked("Client:HUD:GetDistanceForVehicleKM"); HUDHandler.SendInformationToVehicleHUD(player);
                                }
                                Characters.IncreaseCharacterPaydayTime(charId);

                                if (Characters.IsCharacterUnconscious(charId))
                                {
                                    int unconsciousTime = Characters.GetCharacterUnconsciousTime(charId);
                                    if (unconsciousTime > 0)
                                    {
                                        Characters.SetCharacterUnconscious(charId, true, unconsciousTime - 1);
                                    }
                                    else if (unconsciousTime <= 0)
                                    {
                                        Characters.SetCharacterUnconscious(charId, false, 0);
                                        DeathHandler.closeDeathscreen(player);
                                        player.Spawn(new Position(355.54285f, -596.33405f, 28.75768f));
                                        player.Health = player.MaxHealth;
                                    }
                                }

                                if (Characters.IsCharacterFastFarm(charId))
                                {
                                    int fastFarmTime = Characters.GetCharacterFastFarmTime(charId);
                                    if (fastFarmTime > 0)
                                    {
                                        Characters.SetCharacterFastFarm(charId, true, fastFarmTime - 1);
                                    }
                                    else if (fastFarmTime <= 0)
                                    {
                                        Characters.SetCharacterFastFarm(charId, false, 0);
                                    }
                                }

                                if (Characters.IsCharacterInJail(charId))
                                {
                                    int jailTime = Characters.GetCharacterJailTime(charId);
                                    if (jailTime > 0)
                                    {
                                        Characters.SetCharacterJailTime(charId, true, jailTime - 1);
                                    }
                                    else if (jailTime <= 0)
                                    {
                                        if (CharactersWanteds.HasCharacterWanteds(charId))
                                        {
                                            int jailTimes = CharactersWanteds.GetCharacterWantedFinalJailTime(charId);
                                            int jailPrice = CharactersWanteds.GetCharacterWantedFinalJailPrice(charId);
                                            if (CharactersBank.HasCharacterBankMainKonto(charId))
                                            {
                                                int accNumber = CharactersBank.GetCharacterBankMainKonto(charId);
                                                int bankMoney = CharactersBank.GetBankAccountMoney(accNumber);
                                                CharactersBank.SetBankAccountMoney(accNumber, bankMoney - jailPrice);
                                                HUDHandler.SendNotification(player, 1, 7500, $"Durch deine Inhaftierung wurden dir {jailPrice}$ vom Konto abgezogen.");
                                            }
                                            HUDHandler.SendNotification(player, 1, 7500, $"Du sitzt nun für {jailTimes} Minuten im Gefängnis.");
                                            Characters.SetCharacterJailTime(charId, true, jailTimes);
                                            CharactersWanteds.RemoveCharacterWanteds(charId);
                                            player.Position = new Position(1691.4594f, 2565.7056f, 45.556763f);
                                            if (Characters.GetCharacterGender(charId) == false)
                                            {
                                                player.EmitLocked("Client:SpawnArea:setCharClothes", 11, 5, 0);
                                                player.EmitLocked("Client:SpawnArea:setCharClothes", 3, 5, 0);
                                                player.EmitLocked("Client:SpawnArea:setCharClothes", 4, 7, 15);
                                                player.EmitLocked("Client:SpawnArea:setCharClothes", 6, 7, 0);
                                                player.EmitLocked("Client:SpawnArea:setCharClothes", 8, 1, 88);
                                            }
                                            else
                                            {
                                            }
                                        }
                                        else
                                        {
                                            Characters.SetCharacterJailTime(charId, false, 0);
                                            Characters.SetCharacterCorrectClothes(player);
                                            player.Position = new Position(1846.022f, 2585.8945f, 45.657f);
                                            HUDHandler.SendNotification(player, 1, 2500, "Du wurdest aus dem Gefängnis entlassen.");
                                        }
                                    }
                                }

                                if (Characters.GetCharacterPaydayTime(charId) >= 60)
                                {
                                    Characters.IncreaseCharacterPlayTimeHours(charId);
                                    Characters.ResetCharacterPaydayTime(charId);
                                    if (CharactersBank.HasCharacterBankMainKonto(charId))
                                    {
                                        int accountNumber = CharactersBank.GetCharacterBankMainKonto(charId);
                                        CharactersBank.SetBankAccountMoney(accountNumber, CharactersBank.GetBankAccountMoney(accountNumber) + 250); //250$ Stütze
                                        ServerBankPapers.CreateNewBankPaper(accountNumber, DateTime.Now.ToString("d", CultureInfo.CreateSpecificCulture("de-DE")), DateTime.Now.ToString("t", CultureInfo.CreateSpecificCulture("de-DE")), "Eingehende Überweisung", "Staat", "Arbeitslosengeld", "+250$", "Unbekannt");

                                        if (!Characters.IsCharacterCrimeFlagged(charId) && Characters.GetCharacterJob(charId) != "None" && DateTime.Now.Subtract(Convert.ToDateTime(Characters.GetCharacterLastJobPaycheck(charId))).TotalHours >= 12 && !ServerFactions.IsCharacterInAnyFaction(charId))
                                        {
                                            if (Characters.GetCharacterJobHourCounter(charId) >= ServerJobs.GetJobNeededHours(Characters.GetCharacterJob(charId)) - 1)
                                            {
                                                int jobCheck = ServerJobs.GetJobPaycheck(Characters.GetCharacterJob(charId));
                                                Characters.SetCharacterLastJobPaycheck(charId, DateTime.Now);
                                                Characters.ResetCharacterJobHourCounter(charId);
                                                CharactersBank.SetBankAccountMoney(accountNumber, CharactersBank.GetBankAccountMoney(accountNumber) + jobCheck);
                                                ServerBankPapers.CreateNewBankPaper(accountNumber, DateTime.Now.ToString("d", CultureInfo.CreateSpecificCulture("de-DE")), DateTime.Now.ToString("t", CultureInfo.CreateSpecificCulture("de-DE")), "Eingehende Überweisung", "Arbeitsamt", $"Gehalt: {Characters.GetCharacterJob(charId)}", $"+{jobCheck}$", "Unbekannt");
                                                HUDHandler.SendNotification(player, 1, 5000, $"Gehalt erhalten (Beruf: {Characters.GetCharacterJob(charId)} | Gehalt: {jobCheck}$)");
                                            }
                                            else
                                            {
                                                Characters.IncreaseCharacterJobHourCounter(charId);
                                            }
                                        }

                                        if (ServerFactions.IsCharacterInAnyFaction(charId) && ServerFactions.IsCharacterInFactionDuty(charId))
                                        {
                                            int factionid       = ServerFactions.GetCharacterFactionId(charId);
                                            int factionPayCheck = ServerFactions.GetFactionRankPaycheck(factionid, ServerFactions.GetCharacterFactionRank(charId));
                                            if (ServerFactions.GetFactionBankMoney(factionid) >= factionPayCheck)
                                            {
                                                ServerFactions.SetFactionBankMoney(factionid, ServerFactions.GetFactionBankMoney(factionid) - factionPayCheck);
                                                CharactersBank.SetBankAccountMoney(accountNumber, CharactersBank.GetBankAccountMoney(accountNumber) + factionPayCheck);
                                                HUDHandler.SendNotification(player, 1, 5000, $"Du hast deinen Lohn i.H.v. {factionPayCheck}$ erhalten ({ServerFactions.GetFactionRankName(factionid, ServerFactions.GetCharacterFactionRank(charId))})");
                                                ServerBankPapers.CreateNewBankPaper(accountNumber, DateTime.Now.ToString("d", CultureInfo.CreateSpecificCulture("de-DE")), DateTime.Now.ToString("t", CultureInfo.CreateSpecificCulture("de-DE")), "Eingehende Überweisung", $"{ServerFactions.GetFactionFullName(factionid)}", $"Gehalt: {ServerFactions.GetFactionRankName(factionid, ServerFactions.GetCharacterFactionRank(charId))}", $"+{factionPayCheck}$", "Dauerauftrag");
                                                LoggingService.NewFactionLog(factionid, charId, 0, "paycheck", $"{Characters.GetCharacterName(charId)} hat seinen Lohn i.H.v. {factionPayCheck}$ erhalten ({ServerFactions.GetFactionRankName(factionid, ServerFactions.GetCharacterFactionRank(charId))}).");
                                            }
                                            else
                                            {
                                                HUDHandler.SendNotification(player, 3, 5000, $"Deine Fraktion hat nicht genügend Geld um dich zu bezahlen ({factionPayCheck}$).");
                                            }
                                        }

                                        var playerVehicles = ServerVehicles.ServerVehicles_.Where(x => x.id > 0 && x.charid == charId && x.plate.Contains("NL"));
                                        int taxMoney       = 0;
                                        foreach (var i in playerVehicles)
                                        {
                                            if (!i.plate.Contains("NL"))
                                            {
                                                continue;
                                            }
                                            taxMoney += ServerAllVehicles.GetVehicleTaxes(i.hash);
                                        }

                                        if (playerVehicles != null && taxMoney > 0)
                                        {
                                            if (CharactersBank.GetBankAccountMoney(accountNumber) < taxMoney)
                                            {
                                                HUDHandler.SendNotification(player, 3, 5000, $"Deine Fahrzeugsteuern konnten nicht abgebucht werden ({taxMoney}$)");
                                            }
                                            else
                                            {
                                                CharactersBank.SetBankAccountMoney(accountNumber, CharactersBank.GetBankAccountMoney(accountNumber) - taxMoney);
                                                ServerBankPapers.CreateNewBankPaper(accountNumber, DateTime.Now.ToString("d", CultureInfo.CreateSpecificCulture("de-DE")), DateTime.Now.ToString("t", CultureInfo.CreateSpecificCulture("de-DE")), "Ausgehende Überweisung", "Zulassungsamt", $"Fahrzeugsteuer", $"-{taxMoney}$", "Bankeinzug");
                                                HUDHandler.SendNotification(player, 1, 5000, $"Du hast deine Fahrzeugsteuern i.H.v. {taxMoney}$ bezahlt.");
                                            }
                                        }
                                    }
                                    else
                                    {
                                        HUDHandler.SendNotification(player, 3, 5000, $"Dein Einkommen konnte nicht überwiesen werden da du kein Hauptkonto hast.");
                                    }
                                }
                            }
                        }
                    }
                }
                stopwatch.Stop();
                Alt.Log($"OnEntityTimer: Player Foreach benötigte: {stopwatch.Elapsed}");
            }
            catch (Exception ex)
            {
                Alt.Log($"{ex}");
            }
        }
コード例 #4
0
ファイル: Functions.cs プロジェクト: h04X-2K/ValeaRP
 public async Task GiveLicense(IPlayer player, int targetCharId, string licShort)
 {
     try
     {
         if (player == null || !player.Exists || targetCharId <= 0 || licShort == "")
         {
             return;
         }
         int charId = User.GetPlayerOnline(player);
         if (charId <= 0)
         {
             return;
         }
         if (player.HasPlayerHandcuffs() || player.HasPlayerRopeCuffs())
         {
             HUDHandler.SendNotification(player, 3, 5000, "Wie willst du das gefesselt machen?"); return;
         }
         if (!ServerFactions.IsCharacterInAnyFaction(charId))
         {
             HUDHandler.SendNotification(player, 3, 5000, "Du bist in keiner Fraktion."); return;
         }
         if (!ServerFactions.IsCharacterInFactionDuty(charId))
         {
             HUDHandler.SendNotification(player, 3, 5000, "Du bist nicht im Dienst."); return;
         }
         if (ServerFactions.GetCharacterFactionId(charId) != 5)
         {
             HUDHandler.SendNotification(player, 3, 5000, "Du bist kein Angehöriger der Fahrschule."); return;
         }
         var targetPlayer = Alt.Server.GetPlayers().ToList().FirstOrDefault(x => x.GetCharacterMetaId() == (ulong)targetCharId);
         if (targetPlayer == null || !targetPlayer.Exists)
         {
             return;
         }
         if (targetCharId != (int)targetPlayer.GetCharacterMetaId())
         {
             return;
         }
         if (!player.Position.IsInRange(targetPlayer.Position, 5f))
         {
             HUDHandler.SendNotification(player, 3, 5000, "Du bist zu weit entfernt."); return;
         }
         if (!CharactersLicenses.ExistServerLicense(licShort))
         {
             HUDHandler.SendNotification(player, 3, 5000, "Ein unerwarteter Fehler ist aufgetreten."); return;
         }
         if (CharactersLicenses.HasCharacterLicense(targetCharId, licShort))
         {
             HUDHandler.SendNotification(player, 3, 5000, "Der Spieler hat diese Lizenz bereits."); return;
         }
         if (!CharactersBank.HasCharacterBankMainKonto(targetCharId))
         {
             HUDHandler.SendNotification(player, 3, 5000, "Der Spieler besitzt kein Hauptkonto."); return;
         }
         int accNumber = CharactersBank.GetCharacterBankMainKonto(targetCharId);
         int licPrice  = CharactersLicenses.GetLicensePrice(licShort);
         if (CharactersBank.GetBankAccountLockStatus(accNumber))
         {
             HUDHandler.SendNotification(player, 3, 5000, "Das Hauptkonto des Spielers ist gesperrt."); return;
         }
         CharactersBank.SetBankAccountMoney(accNumber, CharactersBank.GetBankAccountMoney(accNumber) - licPrice);
         ServerBankPapers.CreateNewBankPaper(accNumber, DateTime.Now.ToString("d", CultureInfo.CreateSpecificCulture("de-DE")), DateTime.Now.ToString("t", CultureInfo.CreateSpecificCulture("de-DE")), "Ausgehende Überweisung", "Fahrschule", $"Lizenzkauf: {CharactersLicenses.GetFullLicenseName(licShort)}", $"-{licPrice}$", "Bankeinzug");
         CharactersLicenses.SetCharacterLicense(targetCharId, licShort, true);
         ServerFactions.SetFactionBankMoney(5, ServerFactions.GetFactionBankMoney(5) + licPrice);
         HUDHandler.SendNotification(player, 2, 2000, $"Sie haben dem Spieler {Characters.GetCharacterName(targetCharId)} die Lizenz '{CharactersLicenses.GetFullLicenseName(licShort)}' für eine Gebühr i.H.v. {licPrice}$ ausgestellt.");
         HUDHandler.SendNotification(targetPlayer, 2, 2000, $"Ihnen wurde die Lizenz '{CharactersLicenses.GetFullLicenseName(licShort)}' für eine Gebühr i.H.v. {licPrice}$ ausgestellt, diese wurde von Ihrem Hauptkonto abgebucht.");
     }
     catch (Exception e)
     {
         Alt.Log($"{e}");
     }
 }
コード例 #5
0
        public async Task buyShopItem(IPlayer player, int shopId, int amount, string itemname)
        {
            if (player == null || !player.Exists || shopId <= 0 || amount <= 0 || itemname == "")
            {
                return;
            }
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            if (player.HasPlayerHandcuffs() || player.HasPlayerRopeCuffs())
            {
                HUDHandler.SendNotification(player, 3, 5000, "Wie willst du das mit Handschellen/Fesseln machen?"); return;
            }
            if (!player.Position.IsInRange(ServerShops.GetShopPosition(shopId), 3f))
            {
                HUDHandler.SendNotification(player, 3, 5000, $"Du bist zu weit vom Shop entfernt."); return;
            }
            int charId = User.GetPlayerOnline(player);

            if (charId == 0)
            {
                return;
            }
            if (ServerShops.GetShopNeededLicense(shopId) != "None" && !Characters.HasCharacterPermission(charId, ServerShops.GetShopNeededLicense(shopId)))
            {
                HUDHandler.SendNotification(player, 3, 5000, $"Du hast hier keinen Zugriff drauf."); return;
            }
            float itemWeight     = ServerItems.GetItemWeight(itemname) * amount;
            float invWeight      = CharactersInventory.GetCharacterItemWeight(charId, "inventory");
            float backpackWeight = CharactersInventory.GetCharacterItemWeight(charId, "backpack");
            int   itemPrice      = ServerShopsItems.GetShopItemPrice(shopId, itemname) * amount;
            int   shopFaction    = ServerShops.GetShopFaction(shopId);

            if (ServerShopsItems.GetShopItemAmount(shopId, itemname) < amount)
            {
                HUDHandler.SendNotification(player, 3, 5000, $"Soviele Gegenstände hat der Shop nicht auf Lager."); return;
            }
            if (invWeight + itemWeight > 15f && backpackWeight + itemWeight > Characters.GetCharacterBackpackSize(Characters.GetCharacterBackpack(charId)))
            {
                HUDHandler.SendNotification(player, 3, 5000, $"Du hast nicht genug Platz in deinen Taschen."); return;
            }

            if (invWeight + itemWeight <= 15f)
            {
                if (shopFaction > 0 && shopFaction != 0)
                {
                    if (!ServerFactions.IsCharacterInAnyFaction(charId))
                    {
                        HUDHandler.SendNotification(player, 3, 2500, "Du hast hier keinen Zugriff drauf [CODE1-2]."); return;
                    }
                    if (ServerFactions.GetCharacterFactionId(charId) != shopFaction)
                    {
                        HUDHandler.SendNotification(player, 3, 2500, $"Du hast hier keinen Zugriff drauf (Gefordert: {shopFaction} - Deine: {ServerFactions.GetCharacterFactionId(charId)}."); return;
                    }
                    if (ServerFactions.GetFactionBankMoney(shopFaction) < itemPrice)
                    {
                        HUDHandler.SendNotification(player, 3, 2500, "Die Frakton hat nicht genügend Geld auf dem Fraktionskonto."); return;
                    }
                    ServerFactions.SetFactionBankMoney(shopFaction, ServerFactions.GetFactionBankMoney(shopFaction) - itemPrice);
                    LoggingService.NewFactionLog(shopFaction, charId, 0, "shop", $"{Characters.GetCharacterName(charId)} hat {itemname} ({amount}x) für {itemPrice}$ erworben.");
                }
                else
                {
                    if (!CharactersInventory.ExistCharacterItem(charId, "Bargeld", "inventory") || CharactersInventory.GetCharacterItemAmount(charId, "Bargeld", "inventory") < itemPrice)
                    {
                        HUDHandler.SendNotification(player, 3, 2500, "Du hast nicht genügend Geld dabei.");
                        return;
                    }
                    CharactersInventory.RemoveCharacterItemAmount(charId, "Bargeld", itemPrice, "inventory");
                }

                CharactersInventory.AddCharacterItem(charId, itemname, amount, "inventory");
                HUDHandler.SendNotification(player, 2, 5000, $"Du hast {itemname} ({amount}x) für {itemPrice} gekauft (Lagerort: Inventar).");
                stopwatch.Stop();
                if (stopwatch.Elapsed.Milliseconds > 30)
                {
                    Alt.Log($"{charId} - buyShopItem benötigte {stopwatch.Elapsed.Milliseconds}ms");
                }
                return;
            }

            if (Characters.GetCharacterBackpack(charId) != "None" && backpackWeight + itemWeight <= Characters.GetCharacterBackpackSize(Characters.GetCharacterBackpack(charId)))
            {
                if (shopFaction > 0 && shopFaction != 0)
                {
                    if (!ServerFactions.IsCharacterInAnyFaction(charId))
                    {
                        HUDHandler.SendNotification(player, 3, 2500, "Du hast hier keinen Zugriff drauf [CODE1]."); return;
                    }
                    if (ServerFactions.GetCharacterFactionId(charId) != shopFaction)
                    {
                        HUDHandler.SendNotification(player, 3, 2500, $"Du hast hier keinen Zugriff drauf (Gefordert: {shopFaction} - Deine: {ServerFactions.GetCharacterFactionId(charId)}."); return;
                    }
                    if (ServerFactions.GetFactionBankMoney(shopFaction) < itemPrice)
                    {
                        HUDHandler.SendNotification(player, 3, 2500, "Die Frakton hat nicht genügend Geld auf dem Fraktionskonto."); return;
                    }
                    ServerFactions.SetFactionBankMoney(shopFaction, ServerFactions.GetFactionBankMoney(shopFaction) - itemPrice);
                    LoggingService.NewFactionLog(shopFaction, charId, 0, "shop", $"{Characters.GetCharacterName(charId)} hat {itemname} ({amount}x) für {itemPrice}$ erworben.");
                }
                else
                {
                    if (!CharactersInventory.ExistCharacterItem(charId, "Bargeld", "inventory") || CharactersInventory.GetCharacterItemAmount(charId, "Bargeld", "inventory") < itemPrice)
                    {
                        HUDHandler.SendNotification(player, 3, 2500, "Du hast nicht genügend Geld dabei.");
                        return;
                    }
                    CharactersInventory.RemoveCharacterItemAmount(charId, "Bargeld", itemPrice, "inventory");
                }

                CharactersInventory.AddCharacterItem(charId, itemname, amount, "backpack");
                HUDHandler.SendNotification(player, 2, 5000, $"Du hast {itemname} ({amount}x) für {itemPrice} gekauft (Lagerort: Rucksack / Tasche).");
                stopwatch.Stop();
                if (stopwatch.Elapsed.Milliseconds > 30)
                {
                    Alt.Log($"{charId} - buyShopItem benötigte {stopwatch.Elapsed.Milliseconds}ms");
                }
                return;
            }
        }
コード例 #6
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}");
            }
        }