Jump to content

Pedestrians desync


Drakath

Recommended Posts

I think this might be the result of lack of updates for unsynced elements. The ped that is too far from all players to have a syncer will not be updated. Its AI might cause it to approach the player and they will be seen nearby client-side, despite the fact that they're actually further. When I make peds, I take care of unsynced ones by updating their position via script.

Link to comment

I use getElementSyncer (to find out if ped is unsynced) and setElementPosition, it puts the ped at specified position, updating it for all clients. Unfortunately, it also includes the clients that are far away and should not care, which is the waste of bandwidth when many peds are present, but inefficient is still better than broken.

Link to comment

I tried it in two ways. I can see that script changes their position but they somehow lose the syncer instantly and become immortal again.

Here are the ways I tried:

addEvent( "456", true ) 
function updatePosition(ped) 
if not getElementSyncer(ped) then 
local x, y, z = getElementPosition(ped) 
setElementPosition(ped, x+2, y+2, z+2) 
end 
end 
addEventHandler ( "456", getRootElement(), updatePosition ) 
  
  
addEvent( "123", true ) 
function updateSyncer(ped, target) 
setElementSyncer ( ped, target ) 
end 
addEventHandler ( "123", getRootElement(), updateSyncer ) 

Link to comment

They cannot be given a syncer if they're too far away, but if you keep them visible in their true position, you will avoid the situation when ped is near the player but still doesn't take damage. If you want them to take damage in any case, then you should sync it yourself when onClientPedDamage event is triggered.

Link to comment

That's what I did with

addEvent( "456", true ) 
function updatePosition(ped) 
if not getElementSyncer(ped) then 
local x, y, z = getElementPosition(ped) 
setElementPosition(ped, x+2, y+2, z+2) 
end 
end 
addEventHandler ( "456", getRootElement(), updatePosition ) 

If I update their position every time they move then it just keeps setting the same position making them not able to move at all. onClientPedDamage sounds more efficient but I'm not sure how should I do it. Should I trigger "456" event every time a ped takes damage or should I setElementSyncer every time a ped takes damage?

Link to comment

There is no magical way to make everything work the way you want. If you want server-side physics to keep all things working outside client sync range, you need to script them. Updating the position in the way I suggested prevents something what makes look sync worse, something that makes peds appear in positions where they're actually not. It prevents peds from being shown moving when they're not moving. Does it prevent peds from moving? No, because they're not actually moving in the first place.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...