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 · 6 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.

@niekschoemaker
Copy link
Contributor

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

The problem still occurs as before even with additional parameterization.

This issue should not occur if both "networkObject" and "scriptHostObject" are false, make sure both of them are false since scriptHostObject forces networkObject to be true.

@tens0rfl0w
Copy link
Contributor

Forgot to reply in here, this was tested by a member of the Engineering Group and seems to indeed register the object as networked regardless of the supplied parameters (unlike GTA V where it works just fine).

Though, this is likely caused by native game code and not something done by RedM.

@draobrehtom
Copy link
Author

draobrehtom commented Oct 29, 2024

Additional info for the bug report: although the object becomes networked, it still remains invisible (doesn't exist) to other players.

Player 1 - Creator of the object with applied GetClosestObjectOfType native:

  • Object handle 2183426
  • Network ID 65
  • Command crun NetworkGetEntityFromNetworkId(65) applied for verification
    image

Player 2 - Observer:

  • Object handle unknown (doesn't exist)
  • Network ID doesn't exist
  • Command crun NetworkGetEntityFromNetworkId(65) applied for verification
    image

@d22tny
Copy link

d22tny commented Oct 30, 2024

Another big problem is if it's used, every client makes a copy of that invisible object, and after some time it kills the game ( ~ under 10 FPS ). Happened to me last year, i didn't know what was causing it and i stopped scripts one by one, i guessed that there's a problem with GetClosestObjectOfType but never looked into it.

A patch would be godly for this :D

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

4 participants