コード例 #1
0
 public async Task setRentState(IPlayer player, int houseId, string rentState)
 {
     try
     {
         if (player == null || !player.Exists || houseId <= 0)
         {
             return;
         }
         if (rentState != "true" && rentState != "false")
         {
             return;
         }
         int charId = (int)player.GetCharacterMetaId();
         if (charId <= 0)
         {
             return;
         }
         bool rentBool  = rentState == "true";
         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;
         }
         ServerHouses.SetHouseRentState(houseId, rentBool);
         if (rentBool)
         {
             HUDHandler.SendNotification(player, 2, 2500, $"Du hast den Mietstatus auf 'Mieter zulassen' gestellt."); return;
         }
         else
         {
             HUDHandler.SendNotification(player, 2, 2500, $"Du hast den Mietstatus auf 'Mieter nicht zulassen' gestellt."); return;
         }
     }
     catch (Exception e)
     {
         Alt.Log($"{e}");
     }
 }