Add weapon tint sync

This commit is contained in:
Sardelka 2022-06-19 11:47:39 +08:00
parent 2a093d1da0
commit 9a9fb2870c
4 changed files with 10 additions and 2 deletions

View File

@ -322,6 +322,7 @@ namespace RageCoop.Client
c.OwnerID=packet.OwnerID; c.OwnerID=packet.OwnerID;
c.Clothes=packet.Clothes; c.Clothes=packet.Clothes;
c.WeaponComponents=packet.WeaponComponents; c.WeaponComponents=packet.WeaponComponents;
c.WeaponTint=packet.WeaponTint;
c.ModelHash=packet.ModelHash; c.ModelHash=packet.ModelHash;
c.LastStateSynced = Main.Ticked; c.LastStateSynced = Main.Ticked;
} }

View File

@ -65,6 +65,7 @@ namespace RageCoop.Client
Clothes=p.GetPedClothes(), Clothes=p.GetPedClothes(),
ModelHash=p.Model.Hash, ModelHash=p.Model.Hash,
WeaponComponents=p.Weapons.Current.GetWeaponComponents(), WeaponComponents=p.Weapons.Current.GetWeaponComponents(),
WeaponTint=(byte)Function.Call<int>(Hash.GET_PED_WEAPON_TINT_INDEX, p, p.Weapons.Current.Hash)
}; };
Send(packet, ConnectionChannel.PedSync); Send(packet, ConnectionChannel.PedSync);

View File

@ -61,6 +61,7 @@ namespace RageCoop.Client
/// </summary> /// </summary>
public Ped MainPed { get; internal set; } public Ped MainPed { get; internal set; }
internal int Health { get; set; } internal int Health { get; set; }
internal byte WeaponTint { get; set; }
internal bool _lastEnteringVehicle=false; internal bool _lastEnteringVehicle=false;
internal bool _lastSittingInVehicle=false; internal bool _lastSittingInVehicle=false;
private bool _lastRagdoll=false; private bool _lastRagdoll=false;
@ -600,6 +601,10 @@ namespace RageCoop.Client
_lastWeaponComponents = WeaponComponents; _lastWeaponComponents = WeaponComponents;
} }
if (Function.Call<int>(Hash.GET_PED_WEAPON_TINT_INDEX,MainPed,CurrentWeaponHash)!=WeaponTint)
{
Function.Call<int>(Hash.SET_PED_WEAPON_TINT_INDEX, MainPed, CurrentWeaponHash, WeaponTint);
}
} }
private void DisplayAiming() private void DisplayAiming()

View File

@ -24,7 +24,7 @@ namespace RageCoop.Core
public Dictionary<uint, bool> WeaponComponents { get; set; } public Dictionary<uint, bool> WeaponComponents { get; set; }
public byte WeaponTint { get;set; }
public override void Pack(NetOutgoingMessage message) public override void Pack(NetOutgoingMessage message)
@ -62,6 +62,7 @@ namespace RageCoop.Core
byteArray.Add(0x00); byteArray.Add(0x00);
} }
byteArray.Add(WeaponTint);
byte[] result = byteArray.ToArray(); byte[] result = byteArray.ToArray();
message.Write(result.Length); message.Write(result.Length);
@ -96,7 +97,7 @@ namespace RageCoop.Core
WeaponComponents.Add(reader.ReadUInt(), reader.ReadBool()); WeaponComponents.Add(reader.ReadUInt(), reader.ReadBool());
} }
} }
WeaponTint=reader.ReadByte();
#endregion #endregion
} }
} }