#Black_Hawk Posted June 25, 2017 Share Posted June 25, 2017 (edited) hello guys i have a little question let's say i created a ped and when i create the ped there will be a trigger to create this ped to all players and with a timer to destroy this ped so how to make it synced for the new players ? like when i create the ped to all players at the server it works but how to make it working even when a new player enters the server ? with the same timer count i know that i can create a ped on server side, but i want to know how to make synced on client side codes: addCommandHandler ("ped", function () local x, y, z = getElementPosition (localPlayer) triggerServerEvent ("createPed", localPlayer, x, y, z) end ) addEvent ("pedCreated", true) addEventHandler ("pedCreated", root, function (x, y, z) local ped = createPed (7, x, y, z) setTimer (function (ped) destroyElement (ped) end, 5000, 1, ped) end ) addEvent ("createPed", true) addEventHandler ("createPed", root, function (x, y, z) triggerClientEvent (root, "pedCreated", source, x, y, z) end ) and let's say that i killed the ped, and if the ped died it will be destroyed to all players that can see the ped, but how about new players Edited June 25, 2017 by #Black_Hawk Link to comment
WorthlessCynomys Posted June 25, 2017 Share Posted June 25, 2017 (edited) Hello. I would solve this by storing the bed in a table for example and when a new player joins, trigger the createPed event for that playee with all the peds in the table, with a for loop maybe. It is important, that you have to delay the trigger, since client side scripts has to start when the player joins, unless server side events, which run immidiately. Edited June 25, 2017 by StormFighter Plus info Link to comment
#Black_Hawk Posted June 25, 2017 Author Share Posted June 25, 2017 ok but how is the timer gonna be updated ? is it like triggering event every second ? that will cause lag Link to comment
WorthlessCynomys Posted June 25, 2017 Share Posted June 25, 2017 addEventHandler("onPlayerJoin", root, function() setTimer(function() triggerClientEvent(source, "createPed", resourceRoot) end, 5000, 1) end ) Link to comment
#Black_Hawk Posted June 25, 2017 Author Share Posted June 25, 2017 no i meant the timer of destroying the ped Link to comment
WorthlessCynomys Posted June 25, 2017 Share Posted June 25, 2017 By updateing timer, you mean that you set the timer for the new player so it's 3 seconds, cuz 2 has passed, the ped will be destroyed after 3 seconds for the new player too? Link to comment
#Black_Hawk Posted June 25, 2017 Author Share Posted June 25, 2017 (edited) i putted 5 seconds just for example, but i want it even when i use a bigger number like 1 minute or 5 .. etc how to make it synced to new players ? Edited June 25, 2017 by #Black_Hawk Link to comment
WorthlessCynomys Posted June 25, 2017 Share Posted June 25, 2017 Wow... this got me... I'll think about it and if I got something, I'll write. What if you store the timers on the server, so when you trigger the createPed event you can send the timer, get it's details, get how much time is remaining to execute and then set the timer for the new player with the remaining time? 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