backdoor
haus-konto geld abheben (30% steuern) alten hausmanager entfernt interiormanager in core verschoben
This commit is contained in:
@@ -987,7 +987,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
}
|
||||
|
||||
[Command("clothes", "~m~Benutzung: ~s~/clothes [Spieler] [Component ID] [Drawable] (Textur)")]
|
||||
public void CmdAdminClothes(Player player, string name, int? component = null, int? drawable = null, int texture = 0)
|
||||
public void CmdAdminClothes(Player player, string name, int? component = null, int? drawable = null, int texture = 0)
|
||||
{
|
||||
if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN2) ?? true)
|
||||
{
|
||||
@@ -2680,105 +2680,17 @@ namespace ReallifeGamemode.Server.Commands
|
||||
BankManager.SetMoney(player, business, amount, "Admin");
|
||||
}
|
||||
|
||||
[Command("interior", "~m~Benutzung: ~s~/interior [Add / Remove / SetEnter / SetExit] [Name / ID]")]
|
||||
public void CmdAdminInterior(Player player, string option1, string option2)
|
||||
{
|
||||
if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
}
|
||||
//[Command("interior", "~m~Benutzung: ~s~/interior [Add / Remove / SetEnter / SetExit] [Name / ID]")]
|
||||
//public void CmdAdminInterior(Player player, string option1, string option2)
|
||||
//{
|
||||
// if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
|
||||
// {
|
||||
// ChatService.NotAuthorized(player);
|
||||
// return;
|
||||
// }
|
||||
|
||||
option1 = option1.ToString();
|
||||
|
||||
if (option1 != "add" && option1 != "remove" && option1 != "setenter" && option1 != "setexit")
|
||||
{
|
||||
ChatService.SendMessage(player, "~m~Benutzung: ~s~/interior [Add / Remove / SetEnter / SetExit] [Name / ID]");
|
||||
return;
|
||||
}
|
||||
|
||||
switch (option1)
|
||||
{
|
||||
case "add":
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
Interior interiorAdd = new Interior
|
||||
{
|
||||
Name = option2
|
||||
};
|
||||
dbContext.Interiors.Add(interiorAdd);
|
||||
dbContext.SaveChanges();
|
||||
ChatService.SendMessage(player, "~b~[ADMIN]~s~ Das Interior ~y~" + option2 + "~s~ wurde erstellt. ~m~ID: " + interiorAdd.Id);
|
||||
}
|
||||
break;
|
||||
case "remove":
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
if (!int.TryParse(option2, out int intId))
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Es muss eine Nummer angegeben werden");
|
||||
return;
|
||||
}
|
||||
Interior interiorRemove = InteriorManager.GetInteriorById(intId, dbContext);
|
||||
if (interiorRemove == null)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Dieses Interior existiert nicht");
|
||||
return;
|
||||
}
|
||||
|
||||
InteriorManager.DeleteInterior(interiorRemove);
|
||||
|
||||
dbContext.Interiors.Remove(interiorRemove);
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
ChatService.SendMessage(player, "~b~[ADMIN]~s~ Das Interior wurde gelöscht.");
|
||||
break;
|
||||
case "setenter":
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
if (!int.TryParse(option2, out int intIdEnter))
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Es muss eine Nummer angegeben werden");
|
||||
return;
|
||||
}
|
||||
Interior interior = InteriorManager.GetInteriorById(intIdEnter, dbContext);
|
||||
if (interior == null)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Dieses Interior existiert nicht");
|
||||
return;
|
||||
}
|
||||
interior.EnterPosition = player.Position;
|
||||
dbContext.SaveChanges();
|
||||
InteriorManager.DeleteInterior(interior);
|
||||
InteriorManager.LoadInterior(interior);
|
||||
ChatService.SendMessage(player, "~b~[ADMIN]~s~ Die Eingangs-Position vom Interior ~y~" + interior.Name + "~s~ wurde gesetzt.");
|
||||
InteriorManager.LoadInteriors();
|
||||
}
|
||||
break;
|
||||
case "setexit":
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
if (!int.TryParse(option2, out int intIdExit))
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Es muss eine Nummer angegeben werden");
|
||||
return;
|
||||
}
|
||||
Interior interior = InteriorManager.GetInteriorById(intIdExit, dbContext);
|
||||
if (interior == null)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Dieses Interior existiert nicht");
|
||||
return;
|
||||
}
|
||||
interior.ExitPosition = player.Position;
|
||||
dbContext.SaveChanges();
|
||||
InteriorManager.DeleteInterior(interior);
|
||||
InteriorManager.LoadInterior(interior);
|
||||
ChatService.SendMessage(player, "~b~[ADMIN]~s~ Die Eingangs-Position vom Interior ~y~" + interior.Name + "~s~ wurde gesetzt.");
|
||||
InteriorManager.LoadInteriors();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
//}
|
||||
|
||||
[Command("reloaddoors", "~m~Benutzung: ~s~/reloaddoors")]
|
||||
public void CmdAdminReloaddoors(Player player)
|
||||
|
||||
@@ -44,6 +44,7 @@ namespace ReallifeGamemode.Server.Events
|
||||
|
||||
player.TriggerEvent("SERVER:Login_Success");
|
||||
player.SetData("isLoggedIn", true);
|
||||
player.SetSharedData("isLoggedIn", true);
|
||||
player.SetData("isDead", false);
|
||||
|
||||
var currentPlayerCreatorDimension = (uint)NAPI.Data.GetWorldData("playerCreatorDimension");
|
||||
|
||||
@@ -97,8 +97,20 @@ namespace ReallifeGamemode.Server.Finance
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
client.GetUser(dbContext).BankAccount.Balance += paycheck.Amount;
|
||||
client.GetUser(dbContext).Wage = 0;
|
||||
User u = client.GetUser(dbContext);
|
||||
u.BankAccount.Balance += paycheck.Amount;
|
||||
u.Wage = 0;
|
||||
|
||||
var rentals = dbContext.HouseRentals
|
||||
.Include(hR => hR.House)
|
||||
.ThenInclude(h => h.BankAccount)
|
||||
.Where(hR => hR.UserId == u.Id);
|
||||
|
||||
foreach (var rental in rentals)
|
||||
{
|
||||
rental.House.BankAccount.Balance += (int)(rental.House.RentalFee * 0.7);
|
||||
}
|
||||
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
if (paycheck.Amount > 0)
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace ReallifeGamemode.Server
|
||||
|
||||
FactionHelper.CheckFactionBankAccounts();
|
||||
BusinessManager.LoadBusinesses();
|
||||
InteriorManager.LoadInteriors();
|
||||
//InteriorManager.LoadInteriors();
|
||||
DoorManager.LoadDoors();
|
||||
ATMManager.InitATMs();
|
||||
CityHallManager.LoadCityHall();
|
||||
|
||||
@@ -1,443 +0,0 @@
|
||||
using GTANetworkAPI;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Newtonsoft.Json;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Managers
|
||||
{
|
||||
//public class HouseManager : Script
|
||||
//{
|
||||
// private static readonly Dictionary<int, NetHandle> houseMarkers = new Dictionary<int, NetHandle>();
|
||||
// private static readonly Dictionary<int, NetHandle> houseLabels = new Dictionary<int, NetHandle>();
|
||||
// private static readonly Dictionary<int, NetHandle> houseColShapes = new Dictionary<int, NetHandle>();
|
||||
// private static readonly Dictionary<int, NetHandle> houseBlips = new Dictionary<int, NetHandle>();
|
||||
|
||||
// private static readonly Dictionary<int, List<Player>> playerInColShape = new Dictionary<int, List<Player>>();
|
||||
|
||||
// public static async void LoadHouses()
|
||||
// {
|
||||
|
||||
// }
|
||||
|
||||
// public static async void ReloadAllHouses()
|
||||
// {
|
||||
// using (var dbContext = new DatabaseContext())
|
||||
// {
|
||||
// foreach (House house in await dbContext.Houses.Include(h => h.Owner).ToListAsync())
|
||||
// {
|
||||
// RemoveHouse(house);
|
||||
// LoadHouse(house, false);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// public static House GetNearHouse(Vector3 position, DatabaseContext dbContext = null)
|
||||
// {
|
||||
// if (dbContext == null)
|
||||
// {
|
||||
// using (dbContext = new DatabaseContext())
|
||||
// {
|
||||
// return dbContext.Houses.Where(h => h.Position.DistanceTo(position) <= 5f).Include(h => h.Owner).OrderBy(h => h.Position.DistanceTo(position)).FirstOrDefault();
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return dbContext.Houses.Where(h => h.Position.DistanceTo(position) <= 5f).Include(h => h.Owner).OrderBy(h => h.Position.DistanceTo(position)).FirstOrDefault();
|
||||
// }
|
||||
// }
|
||||
|
||||
// public void AddHouse(string type, int price, Vector3 position)
|
||||
// {
|
||||
// using (var dbContext = new DatabaseContext())
|
||||
// {
|
||||
// var house = new House()
|
||||
// {
|
||||
// Price = price,
|
||||
// Type = type,
|
||||
// X = position.X,
|
||||
// Y = position.Y,
|
||||
// Z = position.Z
|
||||
// };
|
||||
|
||||
// dbContext.Houses.Add(house);
|
||||
// dbContext.SaveChanges();
|
||||
|
||||
// LoadHouse(house);
|
||||
// }
|
||||
// }
|
||||
|
||||
// public static House GetHouseById(int id, DatabaseContext dbContext = null)
|
||||
// {
|
||||
// if (dbContext == null)
|
||||
// {
|
||||
// using (dbContext = new DatabaseContext())
|
||||
// {
|
||||
// return dbContext.Houses.Where(h => h.Id == id).Include(h => h.Owner).FirstOrDefault();
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return dbContext.Houses.Where(h => h.Id == id).Include(h => h.Owner).FirstOrDefault();
|
||||
// }
|
||||
// }
|
||||
|
||||
// public static void LoadHouse(House house, bool loadUser = true)
|
||||
// {
|
||||
// if (loadUser) house = house.Refresh();
|
||||
|
||||
// playerInColShape[house.Id] = new List<Player>();
|
||||
|
||||
// houseMarkers[house.Id] = NAPI.Marker.CreateMarker(MarkerType.VerticalCylinder, house.Position.Subtract(new Vector3(0, 0, 1.7)), new Vector3(), new Vector3(), 1.6f, new Color(255, 255, 255)).Handle;
|
||||
// string text = $"~g~Zum Verkauf\n~s~{house.Type}\nPreis: ~y~{(house.Price == 0 ? "~r~Nicht verkäuflich" : house.Price.ToMoneyString())}";
|
||||
|
||||
// if (house.OwnerId != null)
|
||||
// {
|
||||
// text = $"{house.Type}\n~s~Besitzer: ~y~{house.Owner.Name}";
|
||||
|
||||
// if (house.RentalFee != 0)
|
||||
// {
|
||||
// text += $"\n~s~Mietpreis: ~g~{house.RentalFee.ToMoneyString()}";
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// //houseBlips[house.Id] = NAPI.Blip.CreateBlip(40, house.Position, 0.7f, 11, "Haus", shortRange: true); too many blips
|
||||
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// houseLabels[house.Id] = NAPI.TextLabel.CreateTextLabel(text, house.Position, 10f, 1f, 0, new Color(255, 255, 255));
|
||||
|
||||
// if (house.Price != 0)
|
||||
// {
|
||||
// houseColShapes[house.Id] = NAPI.ColShape.CreateCylinderColShape(house.Position.Subtract(new Vector3(0, 0, 2)), 2.0f, 5f);
|
||||
|
||||
// houseColShapes[house.Id].Entity<ColShape>().OnEntityEnterColShape += HouseManager_OnEntityEnterColShape;
|
||||
// houseColShapes[house.Id].Entity<ColShape>().OnEntityExitColShape += HouseManager_OnEntityExitColShape;
|
||||
// }
|
||||
// }
|
||||
|
||||
// private static void HouseManager_OnEntityExitColShape(ColShape colShape, Player client)
|
||||
// {
|
||||
// if (!client.IsLoggedIn() || client.IsInVehicle) return;
|
||||
// if (!houseColShapes.ContainsValue(colShape.Handle))
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
// int houseId = houseColShapes.Where(p => p.Value.Value == colShape.Handle.Value).FirstOrDefault().Key;
|
||||
// playerInColShape[houseId].Remove(client);
|
||||
|
||||
// client.TriggerEvent("SERVER:CloseHouseMenu");
|
||||
// }
|
||||
|
||||
// private static void HouseManager_OnEntityEnterColShape(ColShape colShape, Player client)
|
||||
// {
|
||||
// if (!client.IsLoggedIn() || client.IsInVehicle) return;
|
||||
// if (!houseColShapes.ContainsValue(colShape.Handle))
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
// int houseId = houseColShapes.Where(p => p.Value.Value == colShape.Handle.Value).FirstOrDefault().Key;
|
||||
// playerInColShape[houseId].Add(client);
|
||||
// House house = GetHouseById(houseId);
|
||||
// User user = client.GetUser();
|
||||
|
||||
// client.TriggerEvent("SERVER:ShowHouseMenu");
|
||||
// SendPlayerHouseData(client, house);
|
||||
// }
|
||||
|
||||
// private static void SendPlayerHouseData(Player player, House house)
|
||||
// {
|
||||
// User user = player.GetUser();
|
||||
// var userHouseStatus = -1;
|
||||
|
||||
// using (var dbContext = new DatabaseContext())
|
||||
// {
|
||||
// if (house.OwnerId == null) userHouseStatus = 0;
|
||||
// else if (house.OwnerId == user?.Id) userHouseStatus = 1;
|
||||
// else if (dbContext.HouseRentals.Where(h => h.HouseId == house.Id && h.UserId == user.Id).Count() == 1) userHouseStatus = 2;
|
||||
|
||||
// var rentals = dbContext.HouseRentals.Where(h => h.HouseId == house.Id).Include(h => h.User).Select(h => h.User.Name).ToList();
|
||||
|
||||
// var newHouse = new
|
||||
// {
|
||||
// OwnerName = house.Owner?.Name,
|
||||
// house.RentalFee,
|
||||
// house.Price,
|
||||
// house.Type,
|
||||
// Rentals = rentals
|
||||
// };
|
||||
|
||||
// player.TriggerEvent("SERVER:SetHouseData", JsonConvert.SerializeObject(newHouse), userHouseStatus);
|
||||
// }
|
||||
// }
|
||||
|
||||
// public static void RemoveHouse(House house)
|
||||
// {
|
||||
// if (houseMarkers.ContainsKey(house.Id))
|
||||
// {
|
||||
// houseMarkers[house.Id].Entity<Marker>().Delete();
|
||||
// houseMarkers.Remove(house.Id);
|
||||
// }
|
||||
|
||||
// if (houseLabels.ContainsKey(house.Id))
|
||||
// {
|
||||
// houseLabels[house.Id].Entity<TextLabel>().Delete();
|
||||
// houseLabels.Remove(house.Id);
|
||||
// }
|
||||
|
||||
// if (houseColShapes.ContainsKey(house.Id))
|
||||
// {
|
||||
// houseColShapes[house.Id].Entity<ColShape>().Delete();
|
||||
// houseColShapes.Remove(house.Id);
|
||||
// }
|
||||
|
||||
// if (houseBlips.ContainsKey(house.Id))
|
||||
// {
|
||||
// houseBlips[house.Id].Entity<Blip>().Delete();
|
||||
// houseBlips.Remove(house.Id);
|
||||
// }
|
||||
|
||||
// foreach (Player client in playerInColShape[house.Id])
|
||||
// {
|
||||
// client.TriggerEvent("SERVER:CloseHouseMenu");
|
||||
// }
|
||||
// }
|
||||
|
||||
// [RemoteEvent("CLIENT:House_BuyHouse")]
|
||||
// public void HouseManagerBuyHouseEvent(Player player)
|
||||
// {
|
||||
// using (var dbContext = new DatabaseContext())
|
||||
// {
|
||||
// User user = player.GetUser(dbContext);
|
||||
|
||||
// if (user.HouseId != null)
|
||||
// {
|
||||
// ChatService.ErrorMessage(player, "Du kann nicht mehrere Häuser besitzen");
|
||||
// return;
|
||||
// }
|
||||
|
||||
// House house = GetNearHouse(player.Position, dbContext);
|
||||
|
||||
// var userBank = user.BankAccount;
|
||||
|
||||
// if (userBank.Balance < house.Price)
|
||||
// {
|
||||
// ChatService.ErrorMessage(player, $"Du hast nicht genug Geld für das Haus ({house.Price.ToMoneyString()})");
|
||||
// return;
|
||||
// }
|
||||
|
||||
// house.Owner = user;
|
||||
// user.House = house;
|
||||
|
||||
// userBank.Balance -= house.Price;
|
||||
|
||||
// dbContext.SaveChanges();
|
||||
|
||||
// RemoveHouse(house);
|
||||
// LoadHouse(house);
|
||||
// }
|
||||
// }
|
||||
|
||||
// [RemoteEvent("CLIENT:House_SetRentalFee")]
|
||||
// public void HouseManagerSetRentalFeeEvent(Player player, int rentalFee)
|
||||
// {
|
||||
// using (var dbContext = new DatabaseContext())
|
||||
// {
|
||||
// User user = player.GetUser(dbContext);
|
||||
|
||||
// if (user.HouseId == null)
|
||||
// {
|
||||
// ChatService.ErrorMessage(player, "Du besitzt kein Haus");
|
||||
// return;
|
||||
// }
|
||||
|
||||
// House house = GetHouseById(user.HouseId.Value, dbContext);
|
||||
|
||||
// if (DateTime.Now - house.LastRentSetTime < TimeSpan.FromDays(7))
|
||||
// {
|
||||
// DateTime newPossibility = house.LastRentSetTime.AddDays(7);
|
||||
// string dateStr = newPossibility.ToLongDateString();
|
||||
// string timeStr = newPossibility.ToShortTimeString();
|
||||
// player.SendNotification(
|
||||
// $"~r~Die Miete wurde in den letzten 7 Tagen schon verändert. Die nächste Änderung kann am {dateStr} um {timeStr} Uhr geändert werden.");
|
||||
// return;
|
||||
// }
|
||||
|
||||
// if (rentalFee < 0)
|
||||
// {
|
||||
// player.SendNotification("~r~Die Miete darf kein negativer Betrag sein!");
|
||||
// return;
|
||||
// }
|
||||
|
||||
// if (rentalFee > 5000)
|
||||
// {
|
||||
// player.SendNotification($"~r~Die Miete darf einen Preis von {5000.ToMoneyString()} nicht überschreiten!");
|
||||
// return;
|
||||
// }
|
||||
|
||||
// house.LastRentSetTime = DateTime.Now;
|
||||
// house.RentalFee = rentalFee;
|
||||
|
||||
// dbContext.SaveChanges();
|
||||
|
||||
// player.SendNotification($"Der Mietpreis wurde auf ~g~{rentalFee.ToMoneyString()}~s~ gesetzt");
|
||||
|
||||
// RemoveHouse(house);
|
||||
// LoadHouse(house);
|
||||
// }
|
||||
// }
|
||||
|
||||
// [RemoteEvent("CLIENT:House_CancelUserRental")]
|
||||
// public void HouseManagerCancelUserRentalEvent(Player player, string userName)
|
||||
// {
|
||||
// using (var dbContext = new DatabaseContext())
|
||||
// {
|
||||
// User user = player.GetUser(dbContext);
|
||||
// if (user.HouseId == null)
|
||||
// {
|
||||
// ChatService.ErrorMessage(player, "Du besitzt kein Haus");
|
||||
// return;
|
||||
// }
|
||||
|
||||
// User target = dbContext.Users.Where(u => u.Name == userName).FirstOrDefault();
|
||||
// if (target == null)
|
||||
// {
|
||||
// player.SendNotification("~r~Dieser Spieler wurde nicht gefunden.");
|
||||
// return;
|
||||
// }
|
||||
|
||||
// House house = GetHouseById(user.HouseId.Value, dbContext);
|
||||
|
||||
// HouseRental rental = dbContext.HouseRentals.Where(h => h.HouseId == house.Id && h.UserId == target.Id).FirstOrDefault();
|
||||
// if (rental == null)
|
||||
// {
|
||||
// player.SendNotification("~r~Der Spieler ist nicht in deinem Haus eingemietet");
|
||||
// return;
|
||||
// }
|
||||
|
||||
// dbContext.HouseRentals.Remove(rental);
|
||||
// dbContext.SaveChanges();
|
||||
|
||||
// target.Player?.SendNotification($"~y~{player.Name}~s~ hat deinen Mietvertrag ~g~gekündigt~s~.");
|
||||
|
||||
// player.SendNotification("Du hast dem Spieler ~y~" + target.Name + "~s~ den Mietvertrag gekündigt.");
|
||||
// SendPlayerHouseData(player, house);
|
||||
// }
|
||||
// }
|
||||
|
||||
// [RemoteEvent("CLIENT:House_RentInHouse")]
|
||||
// public void HouseManagerRentInHouseEvent(Player player)
|
||||
// {
|
||||
// using (var dbContext = new DatabaseContext())
|
||||
// {
|
||||
// User user = player.GetUser(dbContext);
|
||||
// House house = GetNearHouse(player.Position, dbContext);
|
||||
|
||||
// if (house == null)
|
||||
// {
|
||||
// ChatService.ErrorMessage(player, "In deiner Nähe ist kein Haus");
|
||||
// return;
|
||||
// }
|
||||
|
||||
// if (house.RentalFee == 0)
|
||||
// {
|
||||
// player.SendChatMessage("~r~Dieses Haus hat keinen Platz für Mieter!");
|
||||
// return;
|
||||
// }
|
||||
|
||||
// HouseRental newRental = new HouseRental
|
||||
// {
|
||||
// HouseId = house.Id,
|
||||
// UserId = user.Id
|
||||
// };
|
||||
|
||||
// dbContext.HouseRentals.Add(newRental);
|
||||
|
||||
// dbContext.SaveChanges();
|
||||
|
||||
// player.SendNotification("~g~Du hast dich in das Haus eingemietet");
|
||||
|
||||
// house.User?.SendNotification($"~y~{player.Name}~s~ hat sich in dein Haus eingemietet.");
|
||||
// SendPlayerHouseData(player, house);
|
||||
// }
|
||||
// }
|
||||
|
||||
// [RemoteEvent("CLIENT:House_CancelOwnRental")]
|
||||
// public void HouseManagerCancelOwnRentalEvent(Player player)
|
||||
// {
|
||||
// using (var dbContext = new DatabaseContext())
|
||||
// {
|
||||
// User user = player.GetUser(dbContext);
|
||||
// House house = GetNearHouse(player.Position, dbContext);
|
||||
|
||||
// if (house == null)
|
||||
// {
|
||||
// ChatService.ErrorMessage(player, "In deiner Nähe ist kein Haus");
|
||||
// return;
|
||||
// }
|
||||
|
||||
// HouseRental rental = dbContext.HouseRentals.Where(h => h.HouseId == house.Id && h.UserId == user.Id).FirstOrDefault();
|
||||
|
||||
// if (rental == null)
|
||||
// {
|
||||
// player.SendNotification("~r~Du bist nin diesem Haus nicht eingemietet");
|
||||
// return;
|
||||
// }
|
||||
|
||||
// dbContext.HouseRentals.Remove(rental);
|
||||
|
||||
// dbContext.SaveChanges();
|
||||
|
||||
// player.SendNotification("~g~Du hast den Mietvertrag gekündigt.");
|
||||
// house.User?.SendNotification($"~y~{player.Name}~s~ hat seinen Mietvertrag gekündigt.");
|
||||
|
||||
// RemoveHouse(house);
|
||||
// LoadHouse(house);
|
||||
|
||||
// SendPlayerHouseData(player, house);
|
||||
// }
|
||||
// }
|
||||
|
||||
// [RemoteEvent("CLIENT:House_SellHouse")]
|
||||
// public void HouseManagerSellHouseEvent(Player player)
|
||||
// {
|
||||
// using (var dbContext = new DatabaseContext())
|
||||
// {
|
||||
// User user = player.GetUser(dbContext);
|
||||
// if (user.HouseId == null)
|
||||
// {
|
||||
// ChatService.ErrorMessage(player, "Du besitzt kein Haus");
|
||||
// return;
|
||||
// }
|
||||
|
||||
// House house = GetHouseById(user.HouseId.Value, dbContext);
|
||||
// house.OwnerId = null;
|
||||
// user.HouseId = null;
|
||||
|
||||
// var backMoney = (int)(house.Price * 0.4);
|
||||
|
||||
// ChatService.SendMessage(player, "Du bekommst vom Hausverkauf ~g~" + backMoney.ToMoneyString() + "~s~ zurück.");
|
||||
|
||||
// user.BankAccount.Balance += backMoney;
|
||||
|
||||
// dbContext.SaveChanges();
|
||||
|
||||
// player.SendChatMessage("!{#81F7BE}* Du hast dein Haus verkauft.");
|
||||
|
||||
// RemoveHouse(house);
|
||||
// LoadHouse(house);
|
||||
|
||||
// SendPlayerHouseData(player, house);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
}
|
||||
@@ -1,145 +0,0 @@
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace ReallifeGamemode.Server.Managers
|
||||
{
|
||||
public class InteriorManager : Script
|
||||
{
|
||||
public static Dictionary<int, NetHandle> _interiorEnterTextLabels = new Dictionary<int, NetHandle>();
|
||||
public static Dictionary<int, NetHandle> _interiorExitTextLabels = new Dictionary<int, NetHandle>();
|
||||
public static Dictionary<int, NetHandle> _interiorEnterMarkers = new Dictionary<int, NetHandle>();
|
||||
public static Dictionary<int, NetHandle> _interiorExitMarkers = new Dictionary<int, NetHandle>();
|
||||
public static Dictionary<int, NetHandle> _interiorEnterColShapes = new Dictionary<int, NetHandle>();
|
||||
public static Dictionary<int, NetHandle> _interiorExitColShapes = new Dictionary<int, NetHandle>();
|
||||
|
||||
public static Interior GetInteriorByName(string name, DatabaseContext dbContext = null)
|
||||
{
|
||||
if (dbContext == null)
|
||||
{
|
||||
using (dbContext = new DatabaseContext())
|
||||
{
|
||||
return dbContext.Interiors.Where(i => i.Name.ToLower() == name.ToLower()).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return dbContext.Interiors.Where(i => i.Name.ToLower() == name.ToLower()).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
|
||||
public static Interior GetInteriorById(int id, DatabaseContext dbContext = null)
|
||||
{
|
||||
if (dbContext == null)
|
||||
{
|
||||
using (dbContext = new DatabaseContext())
|
||||
{
|
||||
return dbContext.Interiors.Where(i => i.Id == id).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return dbContext.Interiors.Where(i => i.Id == id).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
|
||||
public static void LoadInteriors()
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
foreach (Interior interior in dbContext.Interiors)
|
||||
{
|
||||
LoadInterior(interior);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void LoadInterior(Interior interior)
|
||||
{
|
||||
if (interior.EnterPosition != null)
|
||||
{
|
||||
_interiorEnterTextLabels[interior.Id] = NAPI.TextLabel.CreateTextLabel("~y~" + interior.Name + "\n~s~Eingang", interior.EnterPosition, 10f, 1f, 0, new Color(255, 255, 255));
|
||||
_interiorEnterMarkers[interior.Id] = NAPI.Marker.CreateMarker(MarkerType.VerticalCylinder, interior.EnterPosition.Subtract(new Vector3(0, 0, 1.7)), new Vector3(), new Vector3(), 1.6f, new Color(255, 255, 255, 100));
|
||||
_interiorEnterColShapes[interior.Id] = NAPI.ColShape.CreateSphereColShape(interior.EnterPosition, 1.5f);
|
||||
}
|
||||
|
||||
if (interior.ExitPosition != null)
|
||||
{
|
||||
_interiorExitTextLabels[interior.Id] = NAPI.TextLabel.CreateTextLabel("~y~" + interior.Name + "\n~s~Ausgang", interior.ExitPosition, 10f, 1f, 0, new Color(255, 255, 255));
|
||||
_interiorExitMarkers[interior.Id] = NAPI.Marker.CreateMarker(MarkerType.VerticalCylinder, interior.ExitPosition.Subtract(new Vector3(0, 0, 1.7)), new Vector3(), new Vector3(), 1.6f, new Color(255, 255, 255, 100));
|
||||
_interiorExitColShapes[interior.Id] = NAPI.ColShape.CreateSphereColShape(interior.ExitPosition, 1.5f);
|
||||
}
|
||||
}
|
||||
|
||||
public static void DeleteInterior(Interior interior)
|
||||
{
|
||||
TextLabel enT = GetInteriorEnterTextLabel(interior);
|
||||
TextLabel exT = GetInteriorExitTextLabel(interior);
|
||||
Marker enM = GetInteriorEnterMarker(interior);
|
||||
Marker exM = GetInteriorExitMarkers(interior);
|
||||
ColShape enC = GetInteriorEnterColShape(interior);
|
||||
ColShape exC = GetInteriorExitColShape(interior);
|
||||
|
||||
if (enT != null) enT.Delete();
|
||||
if (exT != null) exT.Delete();
|
||||
if (enM != null) enM.Delete();
|
||||
if (exM != null) exM.Delete();
|
||||
if (enC != null) enC.Delete();
|
||||
if (exC != null) exC.Delete();
|
||||
|
||||
_interiorEnterTextLabels.Remove(interior.Id);
|
||||
_interiorExitTextLabels.Remove(interior.Id);
|
||||
_interiorEnterMarkers.Remove(interior.Id);
|
||||
_interiorExitMarkers.Remove(interior.Id);
|
||||
_interiorEnterColShapes.Remove(interior.Id);
|
||||
_interiorExitColShapes.Remove(interior.Id);
|
||||
}
|
||||
|
||||
public static TextLabel GetInteriorEnterTextLabel(Interior interior) => NAPI.Pools.GetAllTextLabels().Find(t => t.Handle.Value == _interiorEnterTextLabels.FirstOrDefault(x => x.Key == interior.Id).Value.Value);
|
||||
public static TextLabel GetInteriorExitTextLabel(Interior interior) => NAPI.Pools.GetAllTextLabels().Find(t => t.Handle.Value == _interiorExitTextLabels.FirstOrDefault(x => x.Key == interior.Id).Value.Value);
|
||||
|
||||
public static Marker GetInteriorEnterMarker(Interior interior) => NAPI.Pools.GetAllMarkers().Find(t => t.Handle.Value == _interiorEnterMarkers.FirstOrDefault(x => x.Key == interior.Id).Value.Value);
|
||||
public static Marker GetInteriorExitMarkers(Interior interior) => NAPI.Pools.GetAllMarkers().Find(t => t.Handle.Value == _interiorExitMarkers.FirstOrDefault(x => x.Key == interior.Id).Value.Value);
|
||||
|
||||
public static ColShape GetInteriorEnterColShape(Interior interior) => NAPI.Pools.GetAllColShapes().Find(t => t.Handle.Value == _interiorEnterColShapes.FirstOrDefault(x => x.Key == interior.Id).Value.Value);
|
||||
public static ColShape GetInteriorExitColShape(Interior interior) => NAPI.Pools.GetAllColShapes().Find(t => t.Handle.Value == _interiorExitColShapes.FirstOrDefault(x => x.Key == interior.Id).Value.Value);
|
||||
|
||||
public static int GetInteriorIdFromEnterColShape(NetHandle handle) => _interiorEnterColShapes.FirstOrDefault(c => c.Value.Value == handle.Value).Key;
|
||||
public static int GetInteriorIdFromExitColShape(NetHandle handle) => _interiorExitColShapes.FirstOrDefault(c => c.Value.Value == handle.Value).Key;
|
||||
|
||||
[ServerEvent(Event.PlayerEnterColshape)]
|
||||
public void InteriorManagerPlayerEnterColshapeEvent(ColShape colShape, Player player)
|
||||
{
|
||||
int enterId = GetInteriorIdFromEnterColShape(colShape);
|
||||
int exitId = GetInteriorIdFromExitColShape(colShape);
|
||||
if (enterId != 0)
|
||||
{
|
||||
Interior interior = GetInteriorById(enterId);
|
||||
player.TriggerEvent("InteriorManager_ShowHelpText", interior.Name, interior.Id, 0);
|
||||
}
|
||||
else if (exitId != 0)
|
||||
{
|
||||
Interior interior = GetInteriorById(exitId);
|
||||
player.TriggerEvent("InteriorManager_ShowHelpText", interior.Name, interior.Id, 1);
|
||||
}
|
||||
}
|
||||
|
||||
[ServerEvent(Event.PlayerExitColshape)]
|
||||
public void InteriorManagerPlayerExitColshapeEvent(ColShape colShape, Player player)
|
||||
{
|
||||
if (GetInteriorIdFromEnterColShape(colShape) != 0 || GetInteriorIdFromExitColShape(colShape) != 0)
|
||||
{
|
||||
player.TriggerEvent("InteriorManager_ClearHelpText");
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("InteriorManager_UseTeleport")]
|
||||
public void InteriorManagerUseTeleportEvent(Player player, int id, int enterExit)
|
||||
{
|
||||
Interior interior = GetInteriorById(id);
|
||||
player.Position = enterExit == 0 ? interior.ExitPosition : interior.EnterPosition;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user