Not tested, but should work 🤷‍♂️😂

This commit is contained in:
EntenKoeniq
2021-07-11 04:45:56 +02:00
parent b4a03d99d2
commit 08af1a4ca3
4 changed files with 36 additions and 9 deletions

View File

@ -360,15 +360,18 @@ namespace CoopClient
return;
}
if (IsReloading && !Character.IsReloading)
{
Character.Task.ClearAll();
Character.Task.ReloadWeapon();
}
if (IsReloading)
{
return;
if (!Character.IsReloading)
{
Character.Task.ClearAll();
Character.Task.ReloadWeapon();
}
if (Character.IsInRange(Position, 0.5f))
{
return;
}
}
if (Character.Weapons.Current.Hash != (WeaponHash)CurrentWeaponHash)

View File

@ -28,7 +28,9 @@ namespace CoopClient.Entities
// Remove all NPCs with a last update older than npcThreshold or display this npc
foreach (KeyValuePair<string, EntitiesNpc> npc in new Dictionary<string, EntitiesNpc>(Main.Npcs))
{
if ((Environment.TickCount - npc.Value.LastUpdateReceived) > npcThreshold)
int tickCount = Environment.TickCount - npc.Value.LastUpdateReceived;
if (tickCount > 3500) // If the last update is older than 3.5s, then delete this npc completely
{
if (npc.Value.Character != null && npc.Value.Character.Exists() && npc.Value.Health > 0)
{
@ -43,6 +45,19 @@ namespace CoopClient.Entities
Main.Npcs.Remove(npc.Key);
}
else if (tickCount > 1500) // If the last update is older than 1.5s, then delete this npc temporarily
{
if (npc.Value.Character != null && npc.Value.Character.Exists() && npc.Value.Health > 0)
{
npc.Value.Character.Kill();
npc.Value.Character.Delete();
}
if (npc.Value.MainVehicle != null && npc.Value.MainVehicle.Exists() && npc.Value.MainVehicle.PassengerCount == 0)
{
npc.Value.MainVehicle.Delete();
}
}
else
{
npc.Value.DisplayLocally(null);
@ -57,7 +72,7 @@ namespace CoopClient.Entities
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(10)) // only 10 for now
.Take((Main.MainSettings.StreamedNpc > 20 || Main.MainSettings.StreamedNpc < 0) ? 0 : Main.MainSettings.StreamedNpc))
{
Main.MainNetworking.SendNpcData(ped);
}

View File

@ -98,6 +98,13 @@ namespace CoopClient
};
shareNpcsItem.Enabled = false;
NativeSliderItem streamedNpcsItem = new NativeSliderItem("Streamed Npcs", 20, MainSettings.StreamedNpc);
streamedNpcsItem.ValueChanged += (item, value) =>
{
MainSettings.StreamedNpc = streamedNpcsItem.Value;
Util.SaveSettings();
};
NativeCheckboxItem flipMenuItem = new NativeCheckboxItem("Flip menu", MainSettings.FlipMenu);
flipMenuItem.CheckboxChanged += (item, check) =>
{
@ -139,6 +146,7 @@ namespace CoopClient
MainMenu.Add(serverConnectItem);
MainMenu.AddSubMenu(MainSettingsMenu);
MainSettingsMenu.Add(shareNpcsItem);
MainSettingsMenu.Add(streamedNpcsItem);
MainSettingsMenu.Add(flipMenuItem);
#if DEBUG
MainSettingsMenu.Add(useDebugItem);

View File

@ -5,5 +5,6 @@
public string Username { get; set; } = "Player";
public string LastServerAddress { get; set; } = "127.0.0.1:4499";
public bool FlipMenu { get; set; } = false;
public int StreamedNpc { get; set; } = 10;
}
}