Client
Using canary?
No
Windows version:
20H2 19042.804
Server
Operating system:
Windows Server 2012 R2 Datacenter
Artifact version:
Server: 3539
Incident
Summary:
CreateWeaponObject not sync well when use with attach. The attached entity just floating around.
Expected behavior:
API.CreateWeaponObject should sync normally, just like World.CreateProp.
Actual behavior:
- https://i.imgur.com/qVcCIoF.mp4 (I’ve tested recently and it still behave like this video)
Steps to reproduce:
using CitizenFX.Core;
using CitizenFX.Core.Native;
// create weapon object
var weaponHandle = API.CreateWeaponObject(
(uint) weapon.Hash,
1,
Game.PlayerPed.Position.X,
Game.PlayerPed.Position.Y,
Game.PlayerPed.Position.Z - 50,
true,
1f,
0);
var entity = Entity.FromHandle(weaponHandle);
// set tint
API.SetWeaponObjectTintIndex(weaponHandle, (int) weapon.Tint);
// misc
entity.IsPersistent = true;
API.SetEntityCollision(weaponHandle, true, false);
// attach
entity.AttachTo(
Game.PlayerPed.Bones[info.Bone],
info.Position,
info.Rotation);
// register to network
API.NetworkRegisterEntityAsNetworked(weaponHandle);
var weaponNetId = API.NetworkGetNetworkIdFromEntity(weaponHandle);
API.SetNetworkIdCanMigrate(weaponNetId, true);
API.SetNetworkIdExistsOnAllMachines(weaponNetId, true);
Server/Client?
Client-Side Script (C#)
Files for repro (if any):
github repo
Any additional info:
It seems to be a long standing issue and I’ve tested recent days and it still behave buggy. Or maybe it’s rather a rarely used API?