From f3162bd28938a32638dd2e1d20cd298b30262cf2 Mon Sep 17 00:00:00 2001 From: hydrant Date: Sun, 30 May 2021 14:34:42 +0200 Subject: [PATCH 1/5] fix hanf --- ReallifeGamemode.Client/drugs/hanf.ts | 91 +++++++++++-------- .../Managers/HanfManager.cs | 26 ++++-- ReallifeGamemode.Server/Util/GlobalHelper.cs | 2 +- 3 files changed, 70 insertions(+), 49 deletions(-) diff --git a/ReallifeGamemode.Client/drugs/hanf.ts b/ReallifeGamemode.Client/drugs/hanf.ts index fb816e44..4e3bc4de 100644 --- a/ReallifeGamemode.Client/drugs/hanf.ts +++ b/ReallifeGamemode.Client/drugs/hanf.ts @@ -333,50 +333,61 @@ export default function hanfSystem(globalData: IGlobalData) { let hanfDataIdToObjectMap: Map = new Map(); let hanfDataIdToTextLabelMap: Map = new Map(); - mp.events.add("SERVER:Hanf_UpdateHanf", (dataJsonArr: string[]) => { - var dataJson = dataJsonArr.join(''); - var data: Array = >JSON.parse(dataJson) + let currentHanfUpdateJsonData: Map = new Map(); - var newPlants = data.filter(d => currentHanfData.filter(x => x.Id === d.Id).length == 0); - var removedPlants = currentHanfData.filter(d => data.filter(x => x.Id === d.Id).length == 0); - var existingPlants = data.filter(d => currentHanfData.filter(x => x.Id === d.Id).length == 1); - - newPlants.forEach(plant => { - var model = getPlantModel(plant); - var object = mp.objects.new(getPlantModel(plant), new mp.Vector3(plant.X, plant.Y, plant.Z)); - hanfDataIdToObjectMap.set(plant.Id, object); - - var textLabel = mp.labels.new(getPlantText(plant), new mp.Vector3(plant.X, plant.Y, plant.Z + 1), { - los: true, - drawDistance: 2 - }); - hanfDataIdToTextLabelMap.set(plant.Id, textLabel); - }); - - removedPlants.forEach(plant => { - var object = hanfDataIdToObjectMap.get(plant.Id); - hanfDataIdToObjectMap.delete(plant.Id); - object.destroy(); - var textLabel = hanfDataIdToTextLabelMap.get(plant.Id); - textLabel.destroy(); - hanfDataIdToTextLabelMap.delete(plant.Id); - }); - - existingPlants.forEach(plant => { - var object = hanfDataIdToObjectMap.get(plant.Id); - var model = getPlantModel(plant); - if (model != object.model) { - object.destroy(); - var object = mp.objects.new(model, new mp.Vector3(plant.X, plant.Y, plant.Z)); - hanfDataIdToObjectMap.delete(plant.Id); - hanfDataIdToObjectMap.set(plant.Id, object); + mp.events.add("SERVER:Hanf_UpdateHanf", (currentIndex: number, totalData: number, currentData: string) => { + currentHanfUpdateJsonData.set(currentIndex, currentData); + if (currentHanfUpdateJsonData.size == totalData) { + var jsonData: string = ""; + for (var i = 0; i < totalData; i++) { + jsonData += currentHanfUpdateJsonData.get(i); } - var textLabel = hanfDataIdToTextLabelMap.get(plant.Id); - textLabel.text = getPlantText(plant); - }); + currentHanfUpdateJsonData.clear(); - currentHanfData = data; + var data: Array = >JSON.parse(jsonData) + + var newPlants = data.filter(d => currentHanfData.filter(x => x.Id === d.Id).length == 0); + var removedPlants = currentHanfData.filter(d => data.filter(x => x.Id === d.Id).length == 0); + var existingPlants = data.filter(d => currentHanfData.filter(x => x.Id === d.Id).length == 1); + + newPlants.forEach(plant => { + var model = getPlantModel(plant); + var object = mp.objects.new(getPlantModel(plant), new mp.Vector3(plant.X, plant.Y, plant.Z)); + hanfDataIdToObjectMap.set(plant.Id, object); + + var textLabel = mp.labels.new(getPlantText(plant), new mp.Vector3(plant.X, plant.Y, plant.Z + 1), { + los: true, + drawDistance: 2 + }); + hanfDataIdToTextLabelMap.set(plant.Id, textLabel); + }); + + removedPlants.forEach(plant => { + var object = hanfDataIdToObjectMap.get(plant.Id); + hanfDataIdToObjectMap.delete(plant.Id); + object.destroy(); + var textLabel = hanfDataIdToTextLabelMap.get(plant.Id); + textLabel.destroy(); + hanfDataIdToTextLabelMap.delete(plant.Id); + }); + + existingPlants.forEach(plant => { + var object = hanfDataIdToObjectMap.get(plant.Id); + var model = getPlantModel(plant); + if (model != object.model) { + object.destroy(); + var object = mp.objects.new(model, new mp.Vector3(plant.X, plant.Y, plant.Z)); + hanfDataIdToObjectMap.delete(plant.Id); + hanfDataIdToObjectMap.set(plant.Id, object); + } + + var textLabel = hanfDataIdToTextLabelMap.get(plant.Id); + textLabel.text = getPlantText(plant); + }); + + currentHanfData = data; + } }); function getPlantModel(plant: CannabisData): number { diff --git a/ReallifeGamemode.Server/Managers/HanfManager.cs b/ReallifeGamemode.Server/Managers/HanfManager.cs index 9f7e5f7a..7a22c942 100644 --- a/ReallifeGamemode.Server/Managers/HanfManager.cs +++ b/ReallifeGamemode.Server/Managers/HanfManager.cs @@ -281,21 +281,29 @@ namespace ReallifeGamemode.Server.Managers }).ToList(); _currentCannabisData = activePlants; - - NAPI.Pools.GetAllPlayers().ForEach(p => - { - UpdateHanfForPlayer(p, activePlants); - }); + UpdateHanfForPlayer(); } - public static void UpdateHanfForPlayer(Player player, List cannabisData = null) + public static void UpdateHanfForPlayer(Player player = null, List cannabisData = null) { cannabisData ??= _currentCannabisData; string jsonStr = JsonConvert.SerializeObject(cannabisData); - List parts = GetChunks(jsonStr, 500); + string[] parts = GetChunks(jsonStr, 5000).ToArray(); - player.TriggerEvent("SERVER:Hanf_UpdateHanf", parts); + int totalData = parts.Length; + + for (int i = 0; i < totalData; i++) + { + if (player != null) + { + player.TriggerEvent("SERVER:Hanf_UpdateHanf", i, totalData, parts[i]); + } + else + { + NAPI.ClientEvent.TriggerClientEventForAll("SERVER:Hanf_UpdateHanf", i, totalData, parts[i]); + } + } } public static List GetChunks(string value, int chunkSize) @@ -648,6 +656,8 @@ namespace ReallifeGamemode.Server.Managers InventoryManager.RemoveUserItem(user, cannabisUserItem, amount); dbContext.SaveChanges(); + dbContext.SaveChanges(); + logger.LogInformation("Player {0} sold {1} cannabis to the server for {2} dollars", player.Name, amount, price); player.SendNotification($"Du hast ~g~{amount} Hanfblüten~s~ für ~g~{price.ToMoneyString()}~s~ verkauft"); diff --git a/ReallifeGamemode.Server/Util/GlobalHelper.cs b/ReallifeGamemode.Server/Util/GlobalHelper.cs index 94849ec3..eabb0df6 100644 --- a/ReallifeGamemode.Server/Util/GlobalHelper.cs +++ b/ReallifeGamemode.Server/Util/GlobalHelper.cs @@ -16,7 +16,7 @@ namespace ReallifeGamemode.Server.Util { "balboistderbeste", "Hurra! Hurra! Der Balbo ist jetzt da! (balbo)" }, { "AirMake", "The fresh breeze of the stone is back. (AirMake)" }, { "raviatex", "I'll remember you all in therapy. (aviate)" }, - { "datgame__", "KOPF ENTWICKLUNG!! (hydrant)" }, + { "datgame__", "ja (hydrant)" }, { "Roachkook", "2head Entwickler ist wieder online (kookroach)" } }; From 7292a3c456ea2fe84a7c21a98ae2f850669fe83c Mon Sep 17 00:00:00 2001 From: hydrant Date: Sun, 30 May 2021 14:40:01 +0200 Subject: [PATCH 2/5] aviate nachricht --- ReallifeGamemode.Server/Util/GlobalHelper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ReallifeGamemode.Server/Util/GlobalHelper.cs b/ReallifeGamemode.Server/Util/GlobalHelper.cs index eabb0df6..cdc8f66c 100644 --- a/ReallifeGamemode.Server/Util/GlobalHelper.cs +++ b/ReallifeGamemode.Server/Util/GlobalHelper.cs @@ -15,7 +15,7 @@ namespace ReallifeGamemode.Server.Util { "iCroniX", "Life of Malle - Eimer für Alle - Alle für Malle - Böllern! (CroniX)" }, { "balboistderbeste", "Hurra! Hurra! Der Balbo ist jetzt da! (balbo)" }, { "AirMake", "The fresh breeze of the stone is back. (AirMake)" }, - { "raviatex", "I'll remember you all in therapy. (aviate)" }, + { "raviatex", "was zitterstn so (aviate)" }, { "datgame__", "ja (hydrant)" }, { "Roachkook", "2head Entwickler ist wieder online (kookroach)" } }; From cdf91b97227985efa4052af0240f9bd03afda3d0 Mon Sep 17 00:00:00 2001 From: hydrant Date: Sun, 30 May 2021 14:41:08 +0200 Subject: [PATCH 3/5] prelex nachricht --- ReallifeGamemode.Server/Util/GlobalHelper.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ReallifeGamemode.Server/Util/GlobalHelper.cs b/ReallifeGamemode.Server/Util/GlobalHelper.cs index cdc8f66c..172757eb 100644 --- a/ReallifeGamemode.Server/Util/GlobalHelper.cs +++ b/ReallifeGamemode.Server/Util/GlobalHelper.cs @@ -17,7 +17,8 @@ namespace ReallifeGamemode.Server.Util { "AirMake", "The fresh breeze of the stone is back. (AirMake)" }, { "raviatex", "was zitterstn so (aviate)" }, { "datgame__", "ja (hydrant)" }, - { "Roachkook", "2head Entwickler ist wieder online (kookroach)" } + { "Roachkook", "2head Entwickler ist wieder online (kookroach)" }, + { "Prelex", "zigaretten (Makkaroni)" } }; public static int newbiePlayedMinutesThreshold = 30 * 60; From d7da402f57343efd5475826bb440f0b3e039ed98 Mon Sep 17 00:00:00 2001 From: "michael.reiswich" Date: Sun, 30 May 2021 14:36:23 +0200 Subject: [PATCH 4/5] boote anderer spawn --- .../Managers/VehicleManager.cs | 146 ++++++++++++++++-- 1 file changed, 131 insertions(+), 15 deletions(-) diff --git a/ReallifeGamemode.Server/Managers/VehicleManager.cs b/ReallifeGamemode.Server/Managers/VehicleManager.cs index b3939ebc..f6bc6317 100644 --- a/ReallifeGamemode.Server/Managers/VehicleManager.cs +++ b/ReallifeGamemode.Server/Managers/VehicleManager.cs @@ -911,6 +911,23 @@ namespace ReallifeGamemode.Server.Managers VehicleRespawnPoints.Add(pos19); VehicleRespawnPoints.Add(pos20); #endregion add_VehicleRespawnPoints + + #region add_BootRespawnPoints + VehicleRespawnPoints.Add(Boot1); + VehicleRespawnPoints.Add(Boot2); + VehicleRespawnPoints.Add(Boot3); + VehicleRespawnPoints.Add(Boot4); + VehicleRespawnPoints.Add(Boot5); + #endregion add_BootRespawnPoints + /* + #region add_PlaneRespawnPoints + VehicleRespawnPoints.Add(plane1); + VehicleRespawnPoints.Add(plane2); + VehicleRespawnPoints.Add(plane3); + VehicleRespawnPoints.Add(plane4); + VehicleRespawnPoints.Add(plane5); + #endregion add_PlaneRespawnPoints + */ } private static readonly Dictionary _serverVehicles = new Dictionary(); @@ -1135,17 +1152,32 @@ namespace ReallifeGamemode.Server.Managers if (sV is UserVehicle uV) { - - foreach (VehicleRespawnPoint point in VehicleRespawnPoints) + if(vehicle.Class == 14) //boot { - if (!NAPI.Pools.GetAllVehicles().Any(v => v.Position.DistanceTo(point.Position) < 1)) + foreach (VehicleRespawnPoint point in BootRespawnPoints) { - sV.PositionX = point.Position.X; - sV.PositionY = point.Position.Y; - sV.PositionZ = point.Position.Z; - sV.Heading = point.Heading; - dbContext.SaveChanges(); - break; + if (!NAPI.Pools.GetAllVehicles().Any(v => v.Position.DistanceTo(point.Position) < 1)) + { + sV.PositionX = point.Position.X; + sV.PositionY = point.Position.Y; + sV.PositionZ = point.Position.Z; + sV.Heading = point.Heading; + dbContext.SaveChanges(); + break; + } + } + }else { + foreach (VehicleRespawnPoint point in VehicleRespawnPoints) + { + if (!NAPI.Pools.GetAllVehicles().Any(v => v.Position.DistanceTo(point.Position) < 1)) + { + sV.PositionX = point.Position.X; + sV.PositionY = point.Position.Y; + sV.PositionZ = point.Position.Z; + sV.Heading = point.Heading; + dbContext.SaveChanges(); + break; + } } } User user = dbContext.Users.Find(uV.UserId); @@ -1164,7 +1196,6 @@ namespace ReallifeGamemode.Server.Managers } } - [RemoteEvent("CLIENT:setMarkerBehindVehicle")] public void setVectorBehindVehicle(Player player, int id, string jsonX, string jsonY, string jsonZ) { @@ -1172,7 +1203,7 @@ namespace ReallifeGamemode.Server.Managers Vector3 vector3 = new Vector3(Convert.ToSingle((double)JsonConvert.DeserializeObject(jsonX)), Convert.ToSingle((double)JsonConvert.DeserializeObject(jsonY)), Convert.ToSingle((double)JsonConvert.DeserializeObject(jsonZ))); vehicle.AddMarkerBehind(vector3); } - #region spawnpositions-vehicleInWater + #region spawnpositions-Vehicle public static List VehicleRespawnPoints = new List(); @@ -1321,12 +1352,97 @@ namespace ReallifeGamemode.Server.Managers new Vector3(-345.78, -931.86, 31.08), //Heading -110.89556 }.AsReadOnly(); */ - #endregion spawnpositions-vehicleInWater + #endregion spawnpositions-Vehicle - [RemoteEvent("CheckWater")] - public static void CheckWater(Player player, int id) + #region spawnpositions-Boot + + public static List BootRespawnPoints = new List(); + + VehicleRespawnPoint Boot1 = new VehicleRespawnPoint() { - CheckVehicleDeath(id); + Position = new Vector3(-999.68, -1397.92, -0.53), + Heading = 19.44f + }; + + + VehicleRespawnPoint Boot2 = new VehicleRespawnPoint() + { + Position = new Vector3(-999.24, -1395.28, 0.53), + Heading = 22.01f + }; + + + VehicleRespawnPoint Boot3 = new VehicleRespawnPoint() + { + Position = new Vector3(-981.93, -1393.21, 0.53), + Heading = 22.01f + }; + + + VehicleRespawnPoint Boot4 = new VehicleRespawnPoint() + { + Position = new Vector3(-974.31, -1389.88, 0.53), + Heading = 19.46f + }; + + + VehicleRespawnPoint Boot5 = new VehicleRespawnPoint() + { + Position = new Vector3(-964.71, -1388.49, 0.53), + Heading = 21.17f + }; + + #endregion spawnpositions- + + + /* #region spawnpositions-Plane + + public static List PlaneRespawnPoints = new List(); + + VehicleRespawnPoint plane1 = new VehicleRespawnPoint() + { + Position = new Vector3(-999.68, -1397.92, -0.53), + Heading = 19.44f + }; + + + VehicleRespawnPoint plane2 = new VehicleRespawnPoint() + { + Position = new Vector3(-999.24, -1395.28, 0.53), + Heading = 22.01f + }; + + + VehicleRespawnPoint plane3 = new VehicleRespawnPoint() + { + Position = new Vector3(-981.93, -1393.21, 0.53), + Heading = 22.01f + }; + + + VehicleRespawnPoint plane4 = new VehicleRespawnPoint() + { + Position = new Vector3(-974.31, -1389.88, 0.53), + Heading = 19.46f + }; + + + VehicleRespawnPoint plane5 = new VehicleRespawnPoint() + { + Position = new Vector3(-964.71, -1388.49, 0.53), + Heading = 21.17f + }; + + #endregion spawnpositions-Plane + */ + [RemoteEvent("CheckWater")] + public static void CheckWater(Player player, Vehicle vehicle) + { + if(vehicle.Class == 14) //boot + { + return; + } + CheckVehicleDeath(vehicle.Id); } } } From 12b8c7e8101baadc32923a6337730e975ace8f48 Mon Sep 17 00:00:00 2001 From: "michael.reiswich" Date: Sun, 30 May 2021 14:39:23 +0200 Subject: [PATCH 5/5] ups --- ReallifeGamemode.Server/Managers/VehicleManager.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ReallifeGamemode.Server/Managers/VehicleManager.cs b/ReallifeGamemode.Server/Managers/VehicleManager.cs index f6bc6317..fedef485 100644 --- a/ReallifeGamemode.Server/Managers/VehicleManager.cs +++ b/ReallifeGamemode.Server/Managers/VehicleManager.cs @@ -913,11 +913,11 @@ namespace ReallifeGamemode.Server.Managers #endregion add_VehicleRespawnPoints #region add_BootRespawnPoints - VehicleRespawnPoints.Add(Boot1); - VehicleRespawnPoints.Add(Boot2); - VehicleRespawnPoints.Add(Boot3); - VehicleRespawnPoints.Add(Boot4); - VehicleRespawnPoints.Add(Boot5); + BootRespawnPoints.Add(Boot1); + BootRespawnPoints.Add(Boot2); + BootRespawnPoints.Add(Boot3); + BootRespawnPoints.Add(Boot4); + BootRespawnPoints.Add(Boot5); #endregion add_BootRespawnPoints /* #region add_PlaneRespawnPoints