House Blips
This commit is contained in:
@@ -17,6 +17,9 @@ namespace ReallifeGamemode.Server.Managers
|
|||||||
private static readonly Dictionary<int, NetHandle> houseMarkers = new Dictionary<int, NetHandle>();
|
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> houseLabels = new Dictionary<int, NetHandle>();
|
||||||
private static readonly Dictionary<int, NetHandle> houseColShapes = 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<Client>> playerInColShape = new Dictionary<int, List<Client>>();
|
||||||
|
|
||||||
public static async void LoadHouses()
|
public static async void LoadHouses()
|
||||||
{
|
{
|
||||||
@@ -96,14 +99,22 @@ namespace ReallifeGamemode.Server.Managers
|
|||||||
{
|
{
|
||||||
if (loadUser) house = house.Refresh();
|
if (loadUser) house = house.Refresh();
|
||||||
|
|
||||||
|
playerInColShape[house.Id] = new List<Client>();
|
||||||
|
|
||||||
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));
|
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));
|
||||||
string text = $"~g~Zum Verkauf\n~s~{house.Type}\nPreis: ~y~{(house.Price == 0 ? "~r~Nicht verkäuflich" : house.Price.ToMoneyString())}";
|
string text = $"~g~Zum Verkauf\n~s~{house.Type}\nPreis: ~y~{(house.Price == 0 ? "~r~Nicht verkäuflich" : house.Price.ToMoneyString())}";
|
||||||
|
|
||||||
|
byte houseColor = 11;
|
||||||
if (house.OwnerId != null)
|
if (house.OwnerId != null)
|
||||||
{
|
{
|
||||||
text = $"{house.Type}\n~s~Besitzer: ~y~{house.Owner.Name}\n~s~Mietpreis: ~g~{house.RentalFee.ToMoneyString()}";
|
text = $"{house.Type}\n~s~Besitzer: ~y~{house.Owner.Name}\n~s~Mietpreis: ~g~{house.RentalFee.ToMoneyString()}";
|
||||||
|
houseColor = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
houseBlips[house.Id] = NAPI.Blip.CreateBlip(40, house.Position, 1.0f, houseColor, "Haus");
|
||||||
houseLabels[house.Id] = NAPI.TextLabel.CreateTextLabel(text, house.Position, 10f, 1f, 0, new Color(255, 255, 255));
|
houseLabels[house.Id] = NAPI.TextLabel.CreateTextLabel(text, house.Position, 10f, 1f, 0, new Color(255, 255, 255));
|
||||||
|
|
||||||
|
|
||||||
if (house.Price != 0)
|
if (house.Price != 0)
|
||||||
{
|
{
|
||||||
houseColShapes[house.Id] = NAPI.ColShape.CreateCylinderColShape(house.Position.Subtract(new Vector3(0, 0, 2)), 2.0f, 5f);
|
houseColShapes[house.Id] = NAPI.ColShape.CreateCylinderColShape(house.Position.Subtract(new Vector3(0, 0, 2)), 2.0f, 5f);
|
||||||
@@ -115,6 +126,14 @@ namespace ReallifeGamemode.Server.Managers
|
|||||||
|
|
||||||
private static void HouseManager_OnEntityExitColShape(ColShape colShape, Client client)
|
private static void HouseManager_OnEntityExitColShape(ColShape colShape, Client 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");
|
client.TriggerEvent("SERVER:CloseHouseMenu");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,6 +145,7 @@ namespace ReallifeGamemode.Server.Managers
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int houseId = houseColShapes.Where(p => p.Value.Value == colShape.Handle.Value).FirstOrDefault().Key;
|
int houseId = houseColShapes.Where(p => p.Value.Value == colShape.Handle.Value).FirstOrDefault().Key;
|
||||||
|
playerInColShape[houseId].Add(client);
|
||||||
House house = GetHouseById(houseId);
|
House house = GetHouseById(houseId);
|
||||||
User user = client.GetUser();
|
User user = client.GetUser();
|
||||||
|
|
||||||
@@ -178,6 +198,17 @@ namespace ReallifeGamemode.Server.Managers
|
|||||||
houseColShapes[house.Id].Entity<ColShape>().Delete();
|
houseColShapes[house.Id].Entity<ColShape>().Delete();
|
||||||
houseColShapes.Remove(house.Id);
|
houseColShapes.Remove(house.Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (houseBlips.ContainsKey(house.Id))
|
||||||
|
{
|
||||||
|
houseBlips[house.Id].Entity<Blip>().Delete();
|
||||||
|
houseBlips.Remove(house.Id);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (Client client in playerInColShape[house.Id])
|
||||||
|
{
|
||||||
|
client.TriggerEvent("SERVER:CloseHouseMenu");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[RemoteEvent("CLIENT:House_BuyHouse")]
|
[RemoteEvent("CLIENT:House_BuyHouse")]
|
||||||
|
|||||||
Reference in New Issue
Block a user