public async Task FactionStorageTakeItem(IPlayer player, int factionId, int charId, string itemName, int amount) { try { if (player == null || !player.Exists || factionId <= 0 || charId <= 0 || amount <= 0 || itemName == "" || itemName == "undefined") { return; } int cCharId = User.GetPlayerOnline(player); if (cCharId != charId) { return; } if (player.HasPlayerHandcuffs() || player.HasPlayerRopeCuffs()) { HUDHandler.SendNotification(player, 3, 5000, "Wie willst du das mit Handschellen/Fesseln machen?"); return; } if (!ServerFactions.IsCharacterInAnyFaction(charId)) { HUDHandler.SendNotification(player, 4, 5000, "Fehler: Du bist in keiner Fraktion."); return; } int cFactionId = ServerFactions.GetCharacterFactionId(charId); if (cFactionId != factionId) { return; } if (!ServerFactions.IsCharacterInFactionDuty(charId)) { HUDHandler.SendNotification(player, 4, 5000, "Fehler: Du bist nicht im Dienst."); return; } if (!ServerFactions.ExistServerFactionStorageItem(factionId, charId, itemName)) { HUDHandler.SendNotification(player, 4, 5000, "Fehler: Der Gegenstand existiert im Spind nicht."); return; } if (ServerFactions.GetServerFactionStorageItemAmount(factionId, charId, itemName) < amount) { HUDHandler.SendNotification(player, 4, 5000, "Fehler: Soviele Gegenstände sind nicht im Spind."); return; } float itemWeight = ServerItems.GetItemWeight(itemName) * amount; 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; } ServerFactions.RemoveServerFactionStorageItemAmount(factionId, charId, itemName, amount); LoggingService.NewFactionLog(factionId, charId, 0, "storage", $"{Characters.GetCharacterName(charId)} ({charId}) hat den Gegenstand '{itemName} ({amount}x)' aus seinem Spind entnommen."); if (invWeight + itemWeight <= 15f) { HUDHandler.SendNotification(player, 2, 5000, $"Du hast {itemName} ({amount}x) aus deinem Spind genommen (Lagerort: Inventar)."); CharactersInventory.AddCharacterItem(charId, itemName, amount, "inventory"); return; } if (Characters.GetCharacterBackpack(charId) != "None" && backpackWeight + itemWeight <= Characters.GetCharacterBackpackSize(Characters.GetCharacterBackpack(charId))) { HUDHandler.SendNotification(player, 2, 5000, $"Du hast {itemName} ({amount}x) aus deinem Spind genommen (Lagerort: Rucksack / Tasche)."); CharactersInventory.AddCharacterItem(charId, itemName, amount, "backpack"); return; } } catch (Exception e) { Alt.Log($"{e}"); } }