From 625442d2e3296bf7bba8fbbfd0564c0be3b25e90 Mon Sep 17 00:00:00 2001 From: Kaeno Date: Fri, 16 Feb 2024 16:14:11 +0000 Subject: [PATCH] Gets the value from server. No longer hard coded to 10 --- .../Patches/FixBrokenSpawnOnSandboxPatch.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/project/Aki.Custom/Patches/FixBrokenSpawnOnSandboxPatch.cs b/project/Aki.Custom/Patches/FixBrokenSpawnOnSandboxPatch.cs index ae0e74c..c2841fe 100644 --- a/project/Aki.Custom/Patches/FixBrokenSpawnOnSandboxPatch.cs +++ b/project/Aki.Custom/Patches/FixBrokenSpawnOnSandboxPatch.cs @@ -1,7 +1,9 @@ -using Aki.Reflection.Patching; +using Aki.Common.Http; +using Aki.Reflection.Patching; using Comfort.Common; using EFT; using HarmonyLib; +using Newtonsoft.Json; using System.Linq; using System.Reflection; using UnityEngine; @@ -28,12 +30,18 @@ namespace Aki.Custom.Patches return; } - var playerLocation = gameWorld.MainPlayer.Location; + var playerLocation = gameWorld.MainPlayer.Location; if (playerLocation == "Sandbox") { - Object.FindObjectsOfType().ToList().First(x => x.name == "ZoneSandbox").MaxPersonsOnPatrol = 10; + Object.FindObjectsOfType().ToList().First(x => x.name == "ZoneSandbox").MaxPersonsOnPatrol = GetMaxPatrolValueFromServer(); } } - } + + public static int GetMaxPatrolValueFromServer() + { + string json = RequestHandler.GetJson("/singleplayer/sandbox/maxpatrol"); + return JsonConvert.DeserializeObject(json); + } + } }