Ejemplo n.º 1
0
 public async Task StorageItem(IPlayer player, int houseId, string itemName, int itemAmount, string fromContainer)
 {
     try
     {
         if (player == null || !player.Exists || houseId <= 0 || itemName == "" || itemName == "undefined" || itemAmount <= 0 || fromContainer == "none" || fromContainer == "")
         {
             return;
         }
         int charId = (int)player.GetCharacterMetaId();
         if (charId <= 0)
         {
             return;
         }
         if (!ServerHouses.ExistHouse(houseId))
         {
             return;
         }
         if (!ServerHouses.HasHouseStorageUpgrade(houseId))
         {
             HUDHandler.SendNotification(player, 4, 5000, "Dieses Haus besitzt noch keinen ausgebauten Lagerplatz."); return;
         }
         if (player.Dimension - 10000 <= 0 || player.Dimension - 10000 != houseId)
         {
             return;
         }
         if (player.HasPlayerHandcuffs() || player.HasPlayerRopeCuffs())
         {
             HUDHandler.SendNotification(player, 3, 5000, "Wie willst du das mit Handschellen/Fesseln machen?"); return;
         }
         if (!CharactersInventory.ExistCharacterItem(charId, itemName, fromContainer))
         {
             HUDHandler.SendNotification(player, 4, 5000, "Fehler: Diesen Gegenstand besitzt du nicht."); return;
         }
         if (CharactersInventory.GetCharacterItemAmount(charId, itemName, fromContainer) < itemAmount)
         {
             HUDHandler.SendNotification(player, 4, 5000, "Fehler: Du hast nicht genügend Gegenstände davon dabei."); return;
         }
         if (CharactersInventory.IsItemActive(player, itemName))
         {
             HUDHandler.SendNotification(player, 4, 5000, "Fehler: Ausgerüstete Gegenstände können nicht umgelagert werden."); return;
         }
         float storageLimit = ServerHouses.GetInteriorStorageLimit(ServerHouses.GetHouseInteriorId(houseId));
         float itemWeight   = ServerItems.GetItemWeight(itemName) * itemAmount;
         if (ServerHouses.GetHouseStorageItemWeight(houseId) >= storageLimit || (ServerHouses.GetHouseStorageItemWeight(houseId) + itemWeight >= storageLimit))
         {
             HUDHandler.SendNotification(player, 3, 5000, $"Fehler: Soviel passt in das Hauslager nicht rein (maximal {storageLimit}kg Lagerplatz).");
             return;
         }
         CharactersInventory.RemoveCharacterItemAmount(charId, itemName, itemAmount, fromContainer);
         ServerHouses.AddServerHouseStorageItem(houseId, itemName, itemAmount);
         HUDHandler.SendNotification(player, 2, 5000, $"Der Gegenstand wurde erfolgreich eingelagert ({itemName} - {itemAmount}x).");
         //ToDo: Log Eintrag
     }
     catch (Exception e)
     {
         Alt.Log($"{e}");
     }
 }
Ejemplo n.º 2
0
 internal static void openStorage(IPlayer player)
 {
     try
     {
         if (player == null || !player.Exists)
         {
             return;
         }
         int charId = (int)player.GetCharacterMetaId();
         if (charId <= 0)
         {
             return;
         }
         int dimension = player.Dimension;
         if (dimension <= 10000)
         {
             return;
         }
         int houseId = dimension - 10000;
         if (houseId <= 0 || !ServerHouses.ExistHouse(houseId))
         {
             return;
         }
         if (!ServerHouses.HasHouseStorageUpgrade(houseId))
         {
             HUDHandler.SendNotification(player, 4, 5000, "Dieses Haus besitzt noch keinen ausgebauten Lagerplatz."); return;
         }
         int interiorId = ServerHouses.GetHouseInteriorId(houseId);
         if (interiorId <= 0)
         {
             return;
         }
         if (!player.Position.IsInRange(ServerHouses.GetInteriorStoragePosition(interiorId), 2f))
         {
             return;
         }
         var houseStorageContent = ServerHouses.GetServerHouseStorageItems(houseId);  //Haus Inventar
         var characterInvArray   = CharactersInventory.GetCharacterInventory(charId); //Spieler Inventar
         player.EmitLocked("Client:FactionStorage:openCEF", charId, houseId, "house", characterInvArray, houseStorageContent);
     }
     catch (Exception e)
     {
         Alt.Log($"{e}");
     }
 }
Ejemplo 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}");
            }
        }
Ejemplo n.º 4
0
        public async Task TakeItem(IPlayer player, int houseId, string itemName, int itemAmount)
        {
            try
            {
                if (player == null || !player.Exists || houseId <= 0 | itemAmount <= 0 || itemName == "" || itemName == "undefined")
                {
                    return;
                }
                int charId = (int)player.GetCharacterMetaId();
                if (charId <= 0)
                {
                    return;
                }
                if (!ServerHouses.ExistHouse(houseId))
                {
                    return;
                }
                if (!ServerHouses.HasHouseStorageUpgrade(houseId))
                {
                    HUDHandler.SendNotification(player, 4, 5000, "Dieses Haus besitzt noch keinen ausgebauten Lagerplatz."); return;
                }
                if (player.Dimension - 10000 <= 0 || player.Dimension - 10000 != houseId)
                {
                    return;
                }
                if (player.HasPlayerHandcuffs() || player.HasPlayerRopeCuffs())
                {
                    HUDHandler.SendNotification(player, 3, 5000, "Wie willst du das mit Handschellen/Fesseln machen?"); return;
                }
                if (!ServerHouses.ExistServerHouseStorageItem(houseId, itemName))
                {
                    HUDHandler.SendNotification(player, 4, 5000, "Fehler: Der Gegenstand existiert im Hauslager nicht."); return;
                }
                if (ServerHouses.GetServerHouseStorageItemAmount(houseId, itemName) < itemAmount)
                {
                    HUDHandler.SendNotification(player, 4, 5000, "Fehler: Soviele Gegenstände sind nicht im Hauslager."); return;
                }
                float itemWeight     = ServerItems.GetItemWeight(itemName) * itemAmount;
                float invWeight      = CharactersInventory.GetCharacterItemWeight(charId, "inventory");
                float backpackWeight = CharactersInventory.GetCharacterItemWeight(charId, "backpack");
                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;
                }
                ServerHouses.RemoveServerHouseStorageItemAmount(houseId, itemName, itemAmount);
                //ToDo: Log Eintrag
                if (invWeight + itemWeight <= 15f)
                {
                    HUDHandler.SendNotification(player, 2, 5000, $"Du hast {itemName} ({itemAmount}x) aus dem Hauslager genommen (Lagerort: Inventar).");
                    CharactersInventory.AddCharacterItem(charId, itemName, itemAmount, "inventory");
                    return;
                }

                if (Characters.GetCharacterBackpack(charId) != "None" && backpackWeight + itemWeight <= Characters.GetCharacterBackpackSize(Characters.GetCharacterBackpack(charId)))
                {
                    HUDHandler.SendNotification(player, 2, 5000, $"Du hast {itemName} ({itemAmount}x) aus dem Hauslager genommen (Lagerort: Rucksack / Tasche).");
                    CharactersInventory.AddCharacterItem(charId, itemName, itemAmount, "backpack");
                    return;
                }
            }
            catch (Exception e)
            {
                Alt.Log($"{e}");
            }
        }