Removed slider for NPCs. Small bug fixes and changes

This commit is contained in:
EntenKoeniq
2021-12-13 17:48:00 +01:00
parent 1f963cb39e
commit 902a08066c
8 changed files with 22 additions and 39 deletions

View File

@ -228,11 +228,10 @@ namespace CoopClient
/// <summary>
/// ?
/// </summary>
public static void Configure(string playerName, bool shareNpcsWithPlayers, int streamedNpcs, bool disableTrafficSharing, bool debug = false)
public static void Configure(string playerName, bool shareNpcsWithPlayers, bool disableTrafficSharing, bool debug = false)
{
Main.MainSettings.Username = playerName;
Main.ShareNpcsWithPlayers = shareNpcsWithPlayers;
Main.MainSettings.StreamedNPCs = streamedNpcs;
Main.DisableTraffic = disableTrafficSharing;
#if DEBUG
Main.UseDebug = debug;

View File

@ -418,17 +418,16 @@ namespace CoopClient.Entities
{
if (MainVehicle == null || !MainVehicle.Exists() || MainVehicle.Model.Hash != CurrentVehicleModelHash)
{
Vehicle targetVehicle = World.GetClosestVehicle(Position, 7f, new Model[] { CurrentVehicleModelHash });
bool vehFound = false;
List<Vehicle> vehs = World.GetNearbyVehicles(Character, 7f, new Model[] { CurrentVehicleModelHash }).OrderBy(v => (v.Position - Character.Position).Length()).Take(3).ToList();
foreach (Vehicle veh in vehs)
if (targetVehicle != null)
{
if (veh.IsSeatFree((VehicleSeat)VehicleSeatIndex))
if (targetVehicle.IsSeatFree((VehicleSeat)VehicleSeatIndex))
{
MainVehicle = veh;
MainVehicle = targetVehicle;
vehFound = true;
break;
}
}
@ -442,7 +441,7 @@ namespace CoopClient.Entities
return;
}
MainVehicle = World.CreateVehicle(vehicleModel, VehiclePosition, VehicleRotation.Z);
MainVehicle = World.CreateVehicle(vehicleModel, VehiclePosition, VehicleRotation.W);
vehicleModel.MarkAsNoLongerNeeded();
}
}

View File

@ -37,14 +37,14 @@ namespace CoopClient.Entities
{
if ((tickCount - npc.Value.LastUpdateReceived) > 3000)
{
if (npc.Value.Character != null && npc.Value.Character.Exists() && npc.Value.Health > 0)
if (npc.Value.Character != null && npc.Value.Character.Exists() && !npc.Value.Character.IsDead)
{
npc.Value.Character.Kill();
npc.Value.Character.MarkAsNoLongerNeeded();
npc.Value.Character.Delete();
}
if (npc.Value.MainVehicle != null && npc.Value.MainVehicle.Exists() && npc.Value.MainVehicle.IsSeatFree(VehicleSeat.Driver) && npc.Value.MainVehicle.PassengerCount == 0)
if (npc.Value.MainVehicle != null && npc.Value.MainVehicle.Exists() && !npc.Value.MainVehicle.IsDead && npc.Value.MainVehicle.IsSeatFree(VehicleSeat.Driver) && npc.Value.MainVehicle.PassengerCount == 0)
{
npc.Value.MainVehicle.MarkAsNoLongerNeeded();
npc.Value.MainVehicle.Delete();
@ -66,9 +66,8 @@ namespace CoopClient.Entities
{
// Send all npcs from the current player
foreach (Ped ped in World.GetNearbyPeds(Game.Player.Character.Position, 150f)
.Where(p => p.Handle != Game.Player.Character.Handle && !p.IsDead && p.RelationshipGroup != Main.RelationshipGroup)
.OrderBy(p => (p.Position - Game.Player.Character.Position).Length())
.Take((Main.MainSettings.StreamedNPCs > 30 || Main.MainSettings.StreamedNPCs < 0) ? 0 : Main.MainSettings.StreamedNPCs))
.Where(p => p.Handle != Game.Player.Character.Handle && p.RelationshipGroup != Main.RelationshipGroup)
.OrderBy(p => (p.Position - Game.Player.Character.Position).Length()))
{
Main.MainNetworking.SendNpcData(ped);
}

View File

@ -14,8 +14,7 @@ namespace CoopClient.Menus.Sub
};
private readonly NativeCheckboxItem DisableTraffic = new NativeCheckboxItem("Disable Traffic (NPCs/Vehicles)", "Local traffic only", Main.DisableTraffic);
private readonly NativeCheckboxItem ShareNpcsItem = new NativeCheckboxItem("Share NPCs", "30 NPCs = 1mb / 9 seconds (UPLOAD)", Main.ShareNpcsWithPlayers) { Enabled = false };
private readonly NativeSliderItem StreamedNPCsItem = new NativeSliderItem($"Streamed NPCs ({Main.MainSettings.StreamedNPCs})", 30, Main.MainSettings.StreamedNPCs > 30 ? 30 : Main.MainSettings.StreamedNPCs);
private readonly NativeCheckboxItem ShareNPCsItem = new NativeCheckboxItem("Share NPCs", "~y~WARNING:~s~ High network traffic! (Every 5 seconds = 1mb or more)", Main.ShareNpcsWithPlayers) { Enabled = false };
private readonly NativeCheckboxItem FlipMenuItem = new NativeCheckboxItem("Flip menu", Main.MainSettings.FlipMenu);
#if DEBUG
private readonly NativeCheckboxItem UseDebugItem = new NativeCheckboxItem("Debug", Main.UseDebug);
@ -28,8 +27,7 @@ namespace CoopClient.Menus.Sub
public Settings()
{
DisableTraffic.CheckboxChanged += DisableTrafficCheckboxChanged;
ShareNpcsItem.CheckboxChanged += (item, check) => { Main.ShareNpcsWithPlayers = ShareNpcsItem.Checked; };
StreamedNPCsItem.ValueChanged += StreamedNpcsValueChanged;
ShareNPCsItem.CheckboxChanged += (item, check) => { Main.ShareNpcsWithPlayers = ShareNPCsItem.Checked; };
FlipMenuItem.CheckboxChanged += FlipMenuCheckboxChanged;
#if DEBUG
UseDebugItem.CheckboxChanged += UseDebugCheckboxChanged;
@ -37,8 +35,7 @@ namespace CoopClient.Menus.Sub
#endif
MainMenu.Add(DisableTraffic);
MainMenu.Add(ShareNpcsItem);
MainMenu.Add(StreamedNPCsItem);
MainMenu.Add(ShareNPCsItem);
MainMenu.Add(FlipMenuItem);
#if DEBUG
MainMenu.Add(UseDebugItem);
@ -52,26 +49,19 @@ namespace CoopClient.Menus.Sub
if (DisableTraffic.Checked)
{
if (ShareNpcsItem.Checked)
if (ShareNPCsItem.Checked)
{
ShareNpcsItem.Checked = false;
ShareNPCsItem.Checked = false;
}
ShareNpcsItem.Enabled = false;
ShareNPCsItem.Enabled = false;
}
else if (Main.NpcsAllowed && !ShareNpcsItem.Enabled)
else if (Main.NpcsAllowed && !ShareNPCsItem.Enabled)
{
ShareNpcsItem.Enabled = true;
ShareNPCsItem.Enabled = true;
}
}
internal void StreamedNpcsValueChanged(object a, System.EventArgs b)
{
Main.MainSettings.StreamedNPCs = StreamedNPCsItem.Value;
Util.SaveSettings();
StreamedNPCsItem.Title = string.Format("Streamed NPCs ({0})", Main.MainSettings.StreamedNPCs);
}
internal void FlipMenuCheckboxChanged(object a, System.EventArgs b)
{
#if !NON_INTERACTIVE

View File

@ -21,9 +21,5 @@
/// Don't use it!
/// </summary>
public bool FlipMenu { get; set; } = false;
/// <summary>
/// Don't use it!
/// </summary>
public int StreamedNPCs { get; set; } = 15;
}
}

View File

@ -96,7 +96,7 @@ namespace CoopClient
Function.Call((Hash)0xF796359A959DF65D, false); //Display distant vehicles
Function.Call(Hash.DISABLE_VEHICLE_DISTANTLIGHTS, true);
foreach (Ped ped in World.GetAllPeds().Where(p => p.RelationshipGroup != "SYNCPED"))
foreach (Ped ped in World.GetAllPeds().Where(p => p.RelationshipGroup != "SYNCPED" && !p.IsPlayer))
{
ped.CurrentVehicle?.Delete();
ped.Kill();

View File

@ -3,7 +3,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<AssemblyVersion>1.0.2.0001</AssemblyVersion>
<AssemblyVersion>1.0.3.0001</AssemblyVersion>
<FileVersion>1.0.0.0</FileVersion>
<RepositoryUrl>https://github.com/GTACOOP-R/GTACoop-R</RepositoryUrl>
</PropertyGroup>

View File

@ -88,7 +88,7 @@ namespace CoopServer
try
{
string data = await httpClient.GetStringAsync("https://ipinfo.io/json");
string data = await httpClient.GetStringAsync("https://wimip.info/json");
info = JsonConvert.DeserializeObject<IpInfo>(data);
}