Drakath Posted February 12, 2015 Share Posted February 12, 2015 I made a simple script that spawns peds around you. It seems like peds never get desynced when playing on flat surface as the airport. However, when I play on a bumpy surface like San Fierro, many peds get desynced. It seems like desynced peds always spawn on the sideways, I never seen a desynced pedestrian on the street. This probably means that they end up on sideways by falling under the ground. I don't know how it is possible since I use getGroundPosition. I know many scripts like the most popular script in the community (zombies script) somehow avoid desynced zombies. Does anyone know how I can do that in my script? Server: addEvent("makeped", true) function makeped (x, y, z) if math.random(1,2) == 1 then x = x + math.random(15,40) else x = x + math.random(-40,-15) end if math.random(1,2) == 1 then y = y + math.random(15,40) else y = y + math.random(-40,-15) end local ped = createPed (290, x, y, z+5, 0) setElementSyncer(ped, client) end addEventHandler("makeped", root, makeped) Client: function haha() local x, y, z = getElementPosition(localPlayer) triggerServerEvent("makeped", resourceRoot, x, y, getGroundPosition(x, y, z)) end setTimer(haha,math.random(2000,5000),0) Link to comment
JR10 Posted February 13, 2015 Share Posted February 13, 2015 I remember doing something similar using getGroundPosition, it was also buggy and sometimes they would spawn underground. I think I fixed it by increasing the z coordinate so that's above the ground at all possible cases. Try this: function haha() local x, y, z = getElementPosition(localPlayer) triggerServerEvent("makeped", root, x, y, getGroundPosition(x, y, z + 500)) end setTimer(haha,math.random(2000,5000),0) Link to comment
Drakath Posted February 13, 2015 Author Share Posted February 13, 2015 They still get desynced. In a few minutes there were already about 20 desynced peds on the sideways. Link to comment
JR10 Posted February 13, 2015 Share Posted February 13, 2015 Perhaps this will help: function haha() local x, y, z = getElementPosition(localPlayer) if math.random(1,2) == 1 then x = x + math.random(15,40) else x = x + math.random(-40,-15) end if math.random(1,2) == 1 then y = y + math.random(15,40) else y = y + math.random(-40,-15) end triggerServerEvent("makeped", root, x, y, getGroundPosition(x, y, z + 500)) end setTimer(haha,math.random(2000,5000),0) addEvent("makeped", true) function makeped (x, y, z) local ped = createPed (290, x, y, z+5, 0) setElementSyncer(ped, client) end addEventHandler("makeped", root, makeped) Link to comment
Drakath Posted February 13, 2015 Author Share Posted February 13, 2015 It worked, peds now spawn on rooftops instead of getting desynced! You are awesome, thank you It's kind of weird though, I always thought that the server is more reliable in setting the coordinates. Link to comment
JR10 Posted February 13, 2015 Share Posted February 13, 2015 The thing is (which I missed when I first posted) that you get the ground position of the current localPlayer's position, you then change it server-side so the original ground position (which is related to the localPlayer) is not the ground position of the ped's position. Link to comment
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