Exemplo n.º 1
0
 public async Task WithdrawMoney(IPlayer player, int houseId, int money)
 {
     try
     {
         if (player == null || !player.Exists || houseId <= 0 || money <= 0)
         {
             return;
         }
         int charId = (int)player.GetCharacterMetaId();
         if (charId <= 0)
         {
             return;
         }
         int dimension = player.Dimension;
         if (dimension <= 10000)
         {
             return;
         }
         int dhouseId = dimension - 10000;
         if (dhouseId <= 0 || dhouseId != houseId || !ServerHouses.ExistHouse(houseId))
         {
             return;
         }
         if (ServerHouses.GetHouseOwner(houseId) != charId)
         {
             HUDHandler.SendNotification(player, 4, 5000, "Fehler: Du bist nicht der Hausbesitzer."); return;
         }
         if (ServerHouses.GetHouseBankMoney(houseId) < money)
         {
             HUDHandler.SendNotification(player, 4, 5000, $"Fehler: Soviel Geld ist nicht im Tresor (Aktueller Stand: {ServerHouses.GetHouseBankMoney(houseId)}$)."); return;
         }
         ServerHouses.SetHouseBankMoney(houseId, ServerHouses.GetHouseBankMoney(houseId) - money);
         CharactersInventory.AddCharacterItem(charId, "Bargeld", money, "inventory");
         HUDHandler.SendNotification(player, 2, 2500, $"Du hast erfolgreich {money}$ aus dem Tresor entnommen.");
     }
     catch (Exception e)
     {
         Alt.Log($"{e}");
     }
 }
Exemplo n.º 2
0
        public async Task DepositMoney(IPlayer player, int houseId, int money)
        {
            if (player == null || !player.Exists || houseId <= 0 || money <= 0)
            {
                return;
            }
            int charId = (int)player.GetCharacterMetaId();

            if (charId <= 0)
            {
                return;
            }
            int dimension = player.Dimension;

            if (dimension <= 10000)
            {
                return;
            }
            int dhouseId = dimension - 10000;

            if (dhouseId <= 0 || dhouseId != houseId || !ServerHouses.ExistHouse(houseId))
            {
                return;
            }
            if (ServerHouses.GetHouseOwner(houseId) != charId)
            {
                HUDHandler.SendNotification(player, 4, 5000, "Fehler: Du bist nicht der Hausbesitzer."); return;
            }
            if (!CharactersInventory.ExistCharacterItem(charId, "Bargeld", "inventory") || CharactersInventory.GetCharacterItemAmount(charId, "Bargeld", "inventory") < money)
            {
                HUDHandler.SendNotification(player, 4, 3500, $"Fehler: Du hast nicht genügend Geld dabei ({money}$)."); return;
            }
            CharactersInventory.RemoveCharacterItemAmount(charId, "Bargeld", money, "inventory");
            ServerHouses.SetHouseBankMoney(houseId, ServerHouses.GetHouseBankMoney(houseId) + money);
            HUDHandler.SendNotification(player, 2, 2500, $"Du hast erfolgreich {money}$ in den Tresor gelagert.");
        }
Exemplo n.º 3
0
        public async Task BuyUpgrade(IPlayer player, int houseId, string upgrade)
        {
            try
            {
                if (player == null || !player.Exists || houseId <= 0)
                {
                    return;
                }
                if (upgrade != "alarm" && upgrade != "storage" && upgrade != "bank")
                {
                    return;
                }
                int charId = (int)player.GetCharacterMetaId();
                if (charId <= 0)
                {
                    return;
                }
                int dimension = player.Dimension;
                if (dimension <= 10000)
                {
                    return;
                }
                int dhouseId = dimension - 10000;
                if (dhouseId <= 0 || dhouseId != houseId || !ServerHouses.ExistHouse(houseId))
                {
                    return;
                }
                if (ServerHouses.GetHouseOwner(houseId) != charId)
                {
                    HUDHandler.SendNotification(player, 4, 5000, "Fehler: Du bist nicht der Hausbesitzer."); return;
                }
                switch (upgrade)
                {
                case "alarm":
                    if (ServerHouses.HasHouseAlarmUpgrade(houseId))
                    {
                        HUDHandler.SendNotification(player, 4, 2500, "Dein Haus besitzt bereits eine Alarmanlage."); return;
                    }
                    if (!ServerHouses.HasHouseBankUpgrade(houseId))
                    {
                        HUDHandler.SendNotification(player, 4, 2500, "Du hast noch keinen Tresor ausgebaut in dem genügend Geld ist (500$)."); return;
                    }
                    if (ServerHouses.GetHouseBankMoney(houseId) < 500)
                    {
                        HUDHandler.SendNotification(player, 4, 2500, "Dein Haustresor verfügt nicht über die Kosten (500$)."); return;
                    }
                    ServerHouses.SetHouseBankMoney(houseId, ServerHouses.GetHouseBankMoney(houseId) - 500);
                    ServerHouses.SetHouseUpgradeState(houseId, "alarm", true);
                    HUDHandler.SendNotification(player, 2, 2500, $"Du hast das Hausupgrade 'Alarmanlage' erfolgreich erworben.");
                    return;

                case "storage":
                    if (ServerHouses.HasHouseStorageUpgrade(houseId))
                    {
                        HUDHandler.SendNotification(player, 4, 2500, "Dein Haus besitzt bereits eine Lagermöglichkeit."); return;
                    }
                    if (!ServerHouses.HasHouseBankUpgrade(houseId))
                    {
                        HUDHandler.SendNotification(player, 4, 2500, "Du hast noch keinen Tresor ausgebaut in dem genügend Geld ist (1500$)."); return;
                    }
                    if (ServerHouses.GetHouseBankMoney(houseId) < 1500)
                    {
                        HUDHandler.SendNotification(player, 4, 2500, "Dein Haustresor verfügt nicht über die Kosten (1500$)."); return;
                    }
                    ServerHouses.SetHouseBankMoney(houseId, ServerHouses.GetHouseBankMoney(houseId) - 1500);
                    ServerHouses.SetHouseUpgradeState(houseId, "storage", true);
                    HUDHandler.SendNotification(player, 2, 2500, $"Du hast das Hausupgrade 'Lagerraum' erfolgreich erworben.");
                    return;

                case "bank":
                    if (ServerHouses.HasHouseBankUpgrade(houseId))
                    {
                        HUDHandler.SendNotification(player, 4, 2500, "Dein Haus besitzt bereits einen Tersor."); return;
                    }
                    if (!CharactersBank.HasCharacterBankMainKonto(charId))
                    {
                        HUDHandler.SendNotification(player, 4, 5000, "Du besitzt noch kein Hauptkonto in deiner Bank."); return;
                    }
                    int accNumber = CharactersBank.GetCharacterBankMainKonto(charId);
                    if (accNumber <= 0)
                    {
                        return;
                    }
                    if (CharactersBank.GetBankAccountMoney(accNumber) < 250)
                    {
                        HUDHandler.SendNotification(player, 4, 5000, "Dein Hauptkonto ist nicht ausreichend gedeckt (250$)."); return;
                    }
                    CharactersBank.SetBankAccountMoney(accNumber, CharactersBank.GetBankAccountMoney(accNumber) - 250);
                    ServerHouses.SetHouseUpgradeState(houseId, "bank", true);
                    HUDHandler.SendNotification(player, 2, 2500, $"Du hast das Hausupgrade 'Tresor' erfolgreich erworben.");
                    return;
                }
            }
            catch (Exception e)
            {
                Alt.Log($"{e}");
            }
        }