コード例 #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}");
     }
 }
コード例 #2
0
 public async Task EnterHouse(IPlayer player, int houseId)
 {
     try
     {
         if (player == null || houseId <= 0 || !player.Exists)
         {
             return;
         }
         int charId = (int)player.GetCharacterMetaId();
         if (charId <= 0)
         {
             return;
         }
         if (!ServerHouses.ExistHouse(houseId))
         {
             return;
         }
         if (!player.Position.IsInRange(ServerHouses.GetHouseEntrance(houseId), 2f))
         {
             return;
         }
         if (ServerHouses.GetHouseOwner(houseId) <= 0)
         {
             HUDHandler.SendNotification(player, 4, 5000, "Dieses Haus gehört Niemanden."); return;
         }
         if (ServerHouses.IsHouseLocked(houseId))
         {
             HUDHandler.SendNotification(player, 4, 5000, "Das Haus ist abgeschlossen."); return;
         }
         int interiorId = ServerHouses.GetHouseInteriorId(houseId);
         if (interiorId <= 0)
         {
             return;
         }
         Position targetPos = ServerHouses.GetInteriorExitPosition(interiorId);
         if (targetPos == new Position(0, 0, 0))
         {
             return;
         }
         player.Position  = targetPos;
         player.Dimension = 10000 + houseId;
     }
     catch (Exception e)
     {
         Alt.Log($"{e}");
     }
 }
コード例 #3
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}");
     }
 }