Beispiel #1
0
 internal static void LeaveHotel(IPlayer player)
 {
     try
     {
         if (player == null || !player.Exists)
         {
             return;
         }
         int charId = User.GetPlayerOnline(player);
         if (charId <= 0)
         {
             return;
         }
         if (player.Dimension <= 0 || player.Dimension - 5000 < 0)
         {
             return;
         }
         int apartmentId = player.Dimension - 5000;
         int hotelId     = ServerHotels.GetHotelIdByApartmentId(apartmentId);
         if (hotelId <= 0 || apartmentId <= 0)
         {
             return;
         }
         if (!ServerHotels.ExistHotelApartment(hotelId, apartmentId))
         {
             HUDHandler.SendNotification(player, 3, 5000, "Ein unerwarteter Fehler ist aufgetreten [HOTEL-001]."); return;
         }
         player.Position  = ServerHotels.GetHotelPosition(hotelId, apartmentId);
         player.Dimension = 0;
     }
     catch (Exception e)
     {
         Alt.Log($"{e}");
     }
 }
Beispiel #2
0
 internal static void openStorage(IPlayer player)
 {
     try
     {
         if (player == null || !player.Exists)
         {
             return;
         }
         int charId = User.GetPlayerOnline(player);
         if (charId <= 0)
         {
             return;
         }
         if (!ServerHotels.HasCharacterAnApartment(charId))
         {
             return;
         }
         int dimension = player.Dimension;
         if (dimension <= 5000)
         {
             return;
         }
         int apartmentId = dimension - 5000;
         int hotelId     = ServerHotels.GetHotelIdByApartmentId(apartmentId);
         if (apartmentId <= 0 || hotelId <= 0 || !ServerHotels.ExistHotelApartment(hotelId, apartmentId))
         {
             return;
         }
         var hotelStorageContent = ServerHotels.GetServerHotelStorageItems(apartmentId); //Apartment Items
         var characterInvArray   = CharactersInventory.GetCharacterInventory(charId);    //Spieler Inventar
         player.EmitLocked("Client:FactionStorage:openCEF", charId, apartmentId, "hotel", characterInvArray, hotelStorageContent);
     }
     catch (Exception e)
     {
         Alt.Log($"{e}");
     }
 }
Beispiel #3
0
        public async Task PressU(IPlayer player)
        {
            try
            {
                lock (player)
                {
                    if (player == null || !player.Exists)
                    {
                        return;
                    }
                    int charId = User.GetPlayerOnline(player);
                    if (charId <= 0)
                    {
                        return;
                    }
                    if (player.HasPlayerHandcuffs() || player.HasPlayerRopeCuffs())
                    {
                        HUDHandler.SendNotification(player, 3, 5000, "Wie willst du das mit Handschellen/Fesseln machen?"); return;
                    }

                    ClassicColshape serverDoorLockCol = (ClassicColshape)ServerDoors.ServerDoorsLockColshapes_.FirstOrDefault(x => ((ClassicColshape)x).IsInRange((ClassicPlayer)player));
                    if (serverDoorLockCol != null)
                    {
                        var doorColData = ServerDoors.ServerDoors_.FirstOrDefault(x => x.id == (int)serverDoorLockCol.GetColShapeId());
                        if (doorColData != null)
                        {
                            string doorKey  = doorColData.doorKey;
                            string doorKey2 = doorColData.doorKey2;
                            if (doorKey == null || doorKey2 == null)
                            {
                                return;
                            }
                            if (!CharactersInventory.ExistCharacterItem(charId, doorKey, "inventory") && !CharactersInventory.ExistCharacterItem(charId, doorKey, "backpack") && !CharactersInventory.ExistCharacterItem(charId, doorKey2, "inventory") && !CharactersInventory.ExistCharacterItem(charId, doorKey2, "backpack"))
                            {
                                return;
                            }

                            if (!doorColData.state)
                            {
                                HUDHandler.SendNotification(player, 4, 1500, "Tür abgeschlossen.");
                            }
                            else
                            {
                                HUDHandler.SendNotification(player, 2, 1500, "Tür aufgeschlossen.");
                            }
                            doorColData.state = !doorColData.state;
                            Alt.EmitAllClients("Client:DoorManager:ManageDoor", doorColData.hash, new Position(doorColData.posX, doorColData.posY, doorColData.posZ), (bool)doorColData.state);
                            return;
                        }
                    }

                    if (player.Dimension >= 5000)
                    {
                        int houseInteriorCount = ServerHouses.GetMaxInteriorsCount();
                        for (var i = 1; i <= houseInteriorCount; i++)
                        {
                            if (player.Dimension >= 5000 && player.Dimension < 10000 && player.Position.IsInRange(ServerHouses.GetInteriorExitPosition(i), 2f))
                            {
                                //Hotel abschließen / aufschließen
                                if (player.Dimension - 5000 <= 0)
                                {
                                    continue;
                                }
                                int apartmentId = player.Dimension - 5000;
                                int hotelId     = ServerHotels.GetHotelIdByApartmentId(apartmentId);
                                if (hotelId <= 0 || apartmentId <= 0)
                                {
                                    continue;
                                }
                                if (!ServerHotels.ExistHotelApartment(hotelId, apartmentId))
                                {
                                    HUDHandler.SendNotification(player, 3, 5000, "Ein unerwarteter Fehler ist aufgetreten [HOTEL-001]."); return;
                                }
                                if (ServerHotels.GetApartmentOwner(hotelId, apartmentId) != charId)
                                {
                                    HUDHandler.SendNotification(player, 3, 5000, "Du hast keinen Schlüssel."); return;
                                }
                                HotelHandler.LockHotel(player, hotelId, apartmentId);
                                return;
                            }
                            else if (player.Dimension >= 10000 && player.Position.IsInRange(ServerHouses.GetInteriorExitPosition(i), 2f))
                            {
                                //Haus abschließen / aufschließen
                                if (player.Dimension - 10000 <= 0)
                                {
                                    continue;
                                }
                                int houseId = player.Dimension - 10000;
                                if (houseId <= 0)
                                {
                                    continue;
                                }
                                if (!ServerHouses.ExistHouse(houseId))
                                {
                                    HUDHandler.SendNotification(player, 3, 5000, "Ein unerwarteter Fehler ist aufgetreten [HOUSE-001]."); return;
                                }
                                if (ServerHouses.GetHouseOwner(houseId) != charId && !ServerHouses.IsCharacterRentedInHouse(charId, houseId))
                                {
                                    HUDHandler.SendNotification(player, 3, 5000, "Dieses Haus gehört nicht dir und / oder du bist nicht eingemietet."); return;
                                }
                                HouseHandler.LockHouse(player, houseId);
                                return;
                            }
                        }
                    }

                    var houseEntrance = ServerHouses.ServerHouses_.FirstOrDefault(x => ((ClassicColshape)x.entranceShape).IsInRange((ClassicPlayer)player));
                    if (houseEntrance != null)
                    {
                        HouseHandler.LockHouse(player, houseEntrance.id);
                    }
                }
            }
            catch (Exception e)
            {
                Alt.Log($"{e}");
            }
        }