🙄
Much better...
This commit is contained in:
@ -263,71 +263,7 @@ namespace CoopClient
|
||||
{
|
||||
ArtificialLagCounter = DateTime.Now;
|
||||
|
||||
#region SPEED
|
||||
byte speed = 0;
|
||||
if (Game.Player.Character.IsWalking)
|
||||
{
|
||||
speed = 1;
|
||||
}
|
||||
else if (Game.Player.Character.IsRunning)
|
||||
{
|
||||
speed = 2;
|
||||
}
|
||||
else if (Game.Player.Character.IsSprinting || Game.IsControlPressed(GTA.Control.Sprint))
|
||||
{
|
||||
speed = 3;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SHOOTING - AIMING
|
||||
bool aiming = player.IsAiming;
|
||||
bool shooting = player.IsShooting && player.Weapons.Current?.AmmoInClip != 0;
|
||||
|
||||
GTA.Math.Vector3 aimCoord = new GTA.Math.Vector3();
|
||||
if (aiming || shooting)
|
||||
{
|
||||
aimCoord = Util.RaycastEverything(new GTA.Math.Vector2(0, 0));
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region FLAG
|
||||
byte? flags = 0;
|
||||
|
||||
if (FullDebugSync)
|
||||
{
|
||||
flags |= (byte)PedDataFlags.LastSyncWasFull;
|
||||
}
|
||||
|
||||
if (aiming)
|
||||
{
|
||||
flags |= (byte)PedDataFlags.IsAiming;
|
||||
}
|
||||
|
||||
if (shooting)
|
||||
{
|
||||
flags |= (byte)PedDataFlags.IsShooting;
|
||||
}
|
||||
|
||||
if (player.IsReloading)
|
||||
{
|
||||
flags |= (byte)PedDataFlags.IsReloading;
|
||||
}
|
||||
|
||||
if (player.IsJumping)
|
||||
{
|
||||
flags |= (byte)PedDataFlags.IsJumping;
|
||||
}
|
||||
|
||||
if (player.IsRagdoll)
|
||||
{
|
||||
flags |= (byte)PedDataFlags.IsRagdoll;
|
||||
}
|
||||
|
||||
if (player.IsOnFire)
|
||||
{
|
||||
flags |= (byte)PedDataFlags.IsOnFire;
|
||||
}
|
||||
#endregion
|
||||
byte? flags = Util.GetPedFlags(player, FullDebugSync);
|
||||
|
||||
if (FullDebugSync)
|
||||
{
|
||||
@ -338,8 +274,8 @@ namespace CoopClient
|
||||
DebugSyncPed.Position = player.Position;
|
||||
DebugSyncPed.Rotation = player.Rotation;
|
||||
DebugSyncPed.Velocity = player.Velocity;
|
||||
DebugSyncPed.Speed = speed;
|
||||
DebugSyncPed.AimCoords = aimCoord;
|
||||
DebugSyncPed.Speed = Util.GetPedSpeed(player);
|
||||
DebugSyncPed.AimCoords = Util.GetPedAimCoords(player, false);
|
||||
DebugSyncPed.CurrentWeaponHash = (int)player.Weapons.Current.Hash;
|
||||
DebugSyncPed.LastSyncWasFull = (flags.Value & (byte)PedDataFlags.LastSyncWasFull) > 0;
|
||||
DebugSyncPed.IsAiming = (flags.Value & (byte)PedDataFlags.IsAiming) > 0;
|
||||
|
@ -346,72 +346,6 @@ namespace CoopClient
|
||||
{
|
||||
Ped player = Game.Player.Character;
|
||||
|
||||
#region SPEED
|
||||
byte speed = 0;
|
||||
if (Game.Player.Character.IsWalking)
|
||||
{
|
||||
speed = 1;
|
||||
}
|
||||
else if (Game.Player.Character.IsRunning)
|
||||
{
|
||||
speed = 2;
|
||||
}
|
||||
else if (Game.Player.Character.IsSprinting)
|
||||
{
|
||||
speed = 3;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SHOOTING - AIMING
|
||||
bool aiming = player.IsAiming;
|
||||
bool shooting = player.IsShooting && player.Weapons.Current?.AmmoInClip != 0;
|
||||
|
||||
Vector3 aimCoord = new Vector3();
|
||||
if (aiming || shooting)
|
||||
{
|
||||
aimCoord = Util.RaycastEverything(new Vector2(0, 0));
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Flags
|
||||
byte? flags = 0;
|
||||
|
||||
if (FullPlayerSync)
|
||||
{
|
||||
flags |= (byte)PedDataFlags.LastSyncWasFull;
|
||||
}
|
||||
|
||||
if (aiming)
|
||||
{
|
||||
flags |= (byte)PedDataFlags.IsAiming;
|
||||
}
|
||||
|
||||
if (shooting)
|
||||
{
|
||||
flags |= (byte)PedDataFlags.IsShooting;
|
||||
}
|
||||
|
||||
if (player.IsReloading)
|
||||
{
|
||||
flags |= (byte)PedDataFlags.IsReloading;
|
||||
}
|
||||
|
||||
if (player.IsJumping)
|
||||
{
|
||||
flags |= (byte)PedDataFlags.IsJumping;
|
||||
}
|
||||
|
||||
if (player.IsRagdoll)
|
||||
{
|
||||
flags |= (byte)PedDataFlags.IsRagdoll;
|
||||
}
|
||||
|
||||
if (player.IsOnFire)
|
||||
{
|
||||
flags |= (byte)PedDataFlags.IsOnFire;
|
||||
}
|
||||
#endregion
|
||||
|
||||
NetOutgoingMessage outgoingMessage = Client.CreateMessage();
|
||||
|
||||
if (FullPlayerSync)
|
||||
@ -425,10 +359,10 @@ namespace CoopClient
|
||||
Position = player.Position.ToLVector(),
|
||||
Rotation = player.Rotation.ToLVector(),
|
||||
Velocity = player.Velocity.ToLVector(),
|
||||
Speed = speed,
|
||||
AimCoords = aimCoord.ToLVector(),
|
||||
Speed = Util.GetPedSpeed(player),
|
||||
AimCoords = Util.GetPedAimCoords(player, false).ToLVector(),
|
||||
CurrentWeaponHash = (int)player.Weapons.Current.Hash,
|
||||
Flag = flags
|
||||
Flag = Util.GetPedFlags(player, true)
|
||||
}.PacketToNetOutGoingMessage(outgoingMessage);
|
||||
}
|
||||
else
|
||||
@ -440,10 +374,10 @@ namespace CoopClient
|
||||
Position = player.Position.ToLVector(),
|
||||
Rotation = player.Rotation.ToLVector(),
|
||||
Velocity = player.Velocity.ToLVector(),
|
||||
Speed = speed,
|
||||
AimCoords = aimCoord.ToLVector(),
|
||||
Speed = Util.GetPedSpeed(player),
|
||||
AimCoords = Util.GetPedAimCoords(player, false).ToLVector(),
|
||||
CurrentWeaponHash = (int)player.Weapons.Current.Hash,
|
||||
Flag = flags
|
||||
Flag = Util.GetPedFlags(player, false)
|
||||
}.PacketToNetOutGoingMessage(outgoingMessage);
|
||||
}
|
||||
|
||||
@ -455,70 +389,6 @@ namespace CoopClient
|
||||
|
||||
public void SendNpcData(Ped npc)
|
||||
{
|
||||
#region SPEED
|
||||
byte speed = 0;
|
||||
if (npc.IsWalking)
|
||||
{
|
||||
speed = 1;
|
||||
}
|
||||
else if (npc.IsRunning)
|
||||
{
|
||||
speed = 2;
|
||||
}
|
||||
else if (npc.IsSprinting)
|
||||
{
|
||||
speed = 3;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SHOOTING - AIMING
|
||||
bool aiming = npc.IsAiming;
|
||||
bool shooting = npc.IsShooting && npc.Weapons.Current?.AmmoInClip != 0;
|
||||
|
||||
Vector3 aimCoord = new Vector3();
|
||||
if (aiming || shooting)
|
||||
{
|
||||
aimCoord = Util.GetLastWeaponImpact(npc);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Flags
|
||||
byte? flags = 0;
|
||||
|
||||
// FullSync = true
|
||||
flags |= (byte)PedDataFlags.LastSyncWasFull;
|
||||
|
||||
if (shooting)
|
||||
{
|
||||
flags |= (byte)PedDataFlags.IsShooting;
|
||||
}
|
||||
|
||||
if (aiming)
|
||||
{
|
||||
flags |= (byte)PedDataFlags.IsAiming;
|
||||
}
|
||||
|
||||
if (npc.IsReloading)
|
||||
{
|
||||
flags |= (byte)PedDataFlags.IsReloading;
|
||||
}
|
||||
|
||||
if (npc.IsJumping)
|
||||
{
|
||||
flags |= (byte)PedDataFlags.IsJumping;
|
||||
}
|
||||
|
||||
if (npc.IsRagdoll)
|
||||
{
|
||||
flags |= (byte)PedDataFlags.IsRagdoll;
|
||||
}
|
||||
|
||||
if (npc.IsOnFire)
|
||||
{
|
||||
flags |= (byte)PedDataFlags.IsOnFire;
|
||||
}
|
||||
#endregion
|
||||
|
||||
NetOutgoingMessage outgoingMessage = Client.CreateMessage();
|
||||
|
||||
new FullSyncNpcPacket()
|
||||
@ -530,10 +400,10 @@ namespace CoopClient
|
||||
Position = npc.Position.ToLVector(),
|
||||
Rotation = npc.Rotation.ToLVector(),
|
||||
Velocity = npc.Velocity.ToLVector(),
|
||||
Speed = speed,
|
||||
AimCoords = aimCoord.ToLVector(),
|
||||
Speed = Util.GetPedSpeed(npc),
|
||||
AimCoords = Util.GetPedAimCoords(npc, true).ToLVector(),
|
||||
CurrentWeaponHash = (int)npc.Weapons.Current.Hash,
|
||||
Flag = flags
|
||||
Flag = Util.GetPedFlags(npc, true)
|
||||
}.PacketToNetOutGoingMessage(outgoingMessage);
|
||||
|
||||
Client.SendMessage(outgoingMessage, NetDeliveryMethod.ReliableOrdered);
|
||||
|
@ -11,6 +11,71 @@ namespace CoopClient
|
||||
{
|
||||
class Util
|
||||
{
|
||||
public static byte GetPedSpeed(Ped ped)
|
||||
{
|
||||
if (ped.IsWalking)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else if (ped.IsRunning)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
else if (ped.IsSprinting)
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static Vector3 GetPedAimCoords(Ped ped, bool isNpc)
|
||||
{
|
||||
bool aimOrShoot = ped.IsAiming || ped.IsShooting && ped.Weapons.Current?.AmmoInClip != 0;
|
||||
return aimOrShoot ? (isNpc ? GetLastWeaponImpact(ped) : RaycastEverything(new Vector2(0, 0))) : new Vector3();
|
||||
}
|
||||
|
||||
public static byte? GetPedFlags(Ped ped, bool fullSync)
|
||||
{
|
||||
byte? flags = 0;
|
||||
|
||||
if (fullSync)
|
||||
{
|
||||
flags |= (byte)PedDataFlags.LastSyncWasFull;
|
||||
}
|
||||
|
||||
if (ped.IsAiming)
|
||||
{
|
||||
flags |= (byte)PedDataFlags.IsAiming;
|
||||
}
|
||||
|
||||
if (ped.IsShooting && ped.Weapons.Current?.AmmoInClip != 0)
|
||||
{
|
||||
flags |= (byte)PedDataFlags.IsShooting;
|
||||
}
|
||||
|
||||
if (ped.IsReloading)
|
||||
{
|
||||
flags |= (byte)PedDataFlags.IsReloading;
|
||||
}
|
||||
|
||||
if (ped.IsJumping)
|
||||
{
|
||||
flags |= (byte)PedDataFlags.IsJumping;
|
||||
}
|
||||
|
||||
if (ped.IsRagdoll)
|
||||
{
|
||||
flags |= (byte)PedDataFlags.IsRagdoll;
|
||||
}
|
||||
|
||||
if (ped.IsOnFire)
|
||||
{
|
||||
flags |= (byte)PedDataFlags.IsOnFire;
|
||||
}
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
public static Dictionary<int, int> GetPedProps(Ped ped)
|
||||
{
|
||||
Dictionary<int, int> result = new Dictionary<int, int>();
|
||||
|
@ -233,13 +233,11 @@ namespace CoopServer
|
||||
}
|
||||
|
||||
// Get all players in range of ...
|
||||
private static List<NetConnection> GetAllInRange(LVector3 position, float range, string local = null)
|
||||
{
|
||||
if (local == null)
|
||||
private static List<NetConnection> GetAllInRange(LVector3 position, float range)
|
||||
{
|
||||
return new List<NetConnection>(MainNetServer.Connections.FindAll(e => Players[NetUtility.ToHexString(e.RemoteUniqueIdentifier)].Ped.IsInRangeOf(position, range)));
|
||||
}
|
||||
else
|
||||
private static List<NetConnection> GetAllInRange(LVector3 position, float range, string local)
|
||||
{
|
||||
return new List<NetConnection>(MainNetServer.Connections.FindAll(e =>
|
||||
{
|
||||
@ -247,7 +245,6 @@ namespace CoopServer
|
||||
return target != local && Players[target].Ped.IsInRangeOf(position, range);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
// Before we approve the connection, we must shake hands
|
||||
private void GetHandshake(NetConnection local, HandshakePacket packet)
|
||||
|
Reference in New Issue
Block a user