Drakath Posted August 7, 2014 Posted August 7, 2014 I have a zombie script and one bug really annoys me. Sometimes pedestrians gets desynchronized and you can't kill them. Is there any workaround for this?
Mr_Moose Posted August 7, 2014 Posted August 7, 2014 You're getting errors in your headshot resource. Can't see the line number on debug script in your video clear enough but line 6 or 8, attempt to compare number with boolean. Something goes wrong there and the event seems to be cancelled basically.
Drakath Posted August 7, 2014 Author Posted August 7, 2014 Sorry about the debugscript, it doesn't have anything to do with this.
DiSaMe Posted August 7, 2014 Posted August 7, 2014 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.
Drakath Posted August 7, 2014 Author Posted August 7, 2014 Could you post the part of your script where you update their position? Are you using setElementSyncer?
DiSaMe Posted August 7, 2014 Posted August 7, 2014 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.
Drakath Posted August 8, 2014 Author Posted August 8, 2014 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 )
DiSaMe Posted August 8, 2014 Posted August 8, 2014 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.
Drakath Posted August 8, 2014 Author Posted August 8, 2014 They weren't too far away, they were just about 30 meters away. Anyway, how can I keep them visible in their true position?
Drakath Posted August 9, 2014 Author Posted August 9, 2014 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?
DiSaMe Posted August 9, 2014 Posted August 9, 2014 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.
Drakath Posted August 9, 2014 Author Posted August 9, 2014 I don't really care where is their actual position. I just want them to take damage.
Drakath Posted August 10, 2014 Author Posted August 10, 2014 Well, as much as I tried to get it back to sync, it didn't work. They change their position and get desynced again so the best solution I found is using destroyElement for every unsynced ped.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now