Esempio n. 1
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}");
     }
 }
Esempio n. 2
0
 internal static void LeaveHouse(IPlayer player, int interiorId)
 {
     try
     {
         if (player == null || interiorId <= 0 || !player.Exists)
         {
             return;
         }
         int charId = (int)player.GetCharacterMetaId();
         if (charId <= 0)
         {
             return;
         }
         if (player.Dimension <= 0 || player.Dimension - 10000 <= 0)
         {
             return;
         }
         int houseId = player.Dimension - 10000;
         if (houseId <= 0)
         {
             return;
         }
         if (!ServerHouses.ExistHouse(houseId))
         {
             return;
         }
         Position housePos = ServerHouses.GetHouseEntrance(houseId);
         if (housePos == new Position(0, 0, 0))
         {
             return;
         }
         player.Position  = housePos;
         player.Dimension = 0;
     }
     catch (Exception e)
     {
         Alt.Log($"{e}");
     }
 }