Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NetworkAllowLocalEntityAttachment not working as expected #3218

Open
draobrehtom opened this issue Mar 7, 2025 · 1 comment
Open

NetworkAllowLocalEntityAttachment not working as expected #3218

draobrehtom opened this issue Mar 7, 2025 · 1 comment
Labels
bug triage Needs a preliminary assessment to determine the urgency and required action

Comments

@draobrehtom
Copy link

draobrehtom commented Mar 7, 2025

What happened?

When using NetworkAllowLocalEntityAttachment, it doesn't work. This problem was previously described in this issue. Feel free to close this issue and re-open the old one if needed.

One major difference from the previous issue: the bug did not occur in build 2372. However, it now happens in both build 2372 and 2545, as well as in newer builds.

Current Behavior:

2022-06-14_13-03-54.mp4

Expected Behavior:

2022-06-14_13-18-57.mp4

Code to Reproduce:

local delete = {}

RegisterCommand('attachself', function()
    RequestModel(`v_corp_bk_chair2`)
    local coords = vector3(810.84, -3035.94, 5.74)
    local chair = CreateObject(`v_corp_bk_chair2`, coords.x, coords.y, coords.z, false, false, false)
    table.insert(delete, chair)

    NetworkAllowLocalEntityAttachment(PlayerPedId(), true)
    AttachEntityToEntity(
        PlayerPedId(), chair, 0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, false, false, false, false, 0, true
    )

    while true do
        Wait(0)
        
        i = GetNetworkTimeAccurate() / 10

        local offsetPos = vector3(math.cos(math.rad(i)), math.sin(math.rad(i)), 0.0) * 4
        SetEntityCoords(
            chair, 
            coords + offsetPos + vector3(0.0, 0.0, 0.0 + math.sin(i/50) / 2),
            false, false, false, false
        )
    end
end, false)

AddEventHandler('onResourceStop', function(name)
    if GetCurrentResourceName() == name then
        for _, b in pairs(delete) do
            DeleteEntity(b)
        end
    end
end)

Expected result

Native should attach player without lags

Reproduction steps

  1. Use the attached code in the description.
  2. Connect to the server with two players (both can be on the same PC using -cl2).
  3. Place both players at the testing location. You can use the following code to teleport:
SetEntityCoords(PlayerPedId(), 810.84, -3035.94, 5.74)
  1. On Player 1 (P1), execute the command /attachself.
  2. On Player 2 (P2), observe the behavior.

Importancy

Unknown

Area(s)

FiveM, Natives

Specific version(s)

Tested on game builds 2372 and 3258 - same issue on both. Tested on server artifacts 13079.

Additional information

No response

@draobrehtom draobrehtom added bug triage Needs a preliminary assessment to determine the urgency and required action labels Mar 7, 2025
@draobrehtom
Copy link
Author

A workaround is available using NetworkSetEntityCanBlend, though the synchronization could be smoother:

RegisterCommand('fixattach', function(source, args)
    local serverId = tonumber(args[1])
    if not serverId then
        print("ERROR: Usage /fixattach <serverid of player who ran /attachself>")
        return
    end

    local ped = GetPlayerPed(GetPlayerFromServerId(serverId))
    NetworkSetEntityCanBlend(ped, false)
end)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug triage Needs a preliminary assessment to determine the urgency and required action
Projects
None yet
Development

No branches or pull requests

1 participant