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

GetClosestObjectOfType causes non-networked object to become networked #2833

Open
draobrehtom opened this issue Oct 3, 2024 · 2 comments
Open
Labels
bug RedM Issues/PRs related to RedM triage Needs a preliminary assessment to determine the urgency and required action

Comments

@draobrehtom
Copy link

draobrehtom commented Oct 3, 2024

What happened?

After calling the native function GetClosestObjectOfType on a non-networked object, the object unexpectedly becomes networked.

Expected result

The object should remain non-networked unless NetworkRegisterEntityAsNetworked is explicitly called.

Reproduction steps

  1. Use the following script to test the behavior:
-- client.lua
RegisterCommand('test', function()
    local hash = `p_watertower_sm_03_base`
    local coords = GetEntityCoords(PlayerPedId())
    RequestModel(hash)
    while not HasModelLoaded(hash) do
        Wait(0)
    end
    local object = CreateObjectNoOffset(hash, coords.x + 2.0, coords.y, coords.z)
    while not DoesEntityExist(object) do
        Wait(0)
    end
    Wait(1000)
    
    while not NetworkGetEntityIsNetworked(object) do
        Wait(0)
        GetClosestObjectOfType(coords.x, coords.y, coords.z, 10.0, hash)
    end
    DeleteEntity(object)
end)
  1. In the game, type /test.
  2. Confirm that the object is created.
  3. Wait 1 second. If the object is deleted after the delay, the bug has been reproduced.

Importancy

There's a workaround

Area(s)

RedM, Natives

Specific version(s)

RedM ver.10011/prod & ver.10191/canary
Server (Windows) 7290 & 10191

Additional information

No response

@draobrehtom draobrehtom added bug triage Needs a preliminary assessment to determine the urgency and required action labels Oct 3, 2024
@github-actions github-actions bot added the RedM Issues/PRs related to RedM label Oct 3, 2024
@tens0rfl0w
Copy link
Contributor

See: https://redm.disquse.me/natives/?_0xE143FA2249364369

The last parameter (networkObject) needs to be false to avoid having the object registered as a network object.

e.g. GetClosestObjectOfType(coords.x, coords.y, coords.z, 10.0, hash, false, false, false)

@draobrehtom
Copy link
Author

GetClosestObjectOfType(coords.x, coords.y, coords.z, 10.0, hash, false, false, false)

The problem still occurs as before even with additional parameterization.

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

No branches or pull requests

2 participants