Jump to content

Problem with syncing


Recommended Posts

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 by #Black_Hawk
Link to comment

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 by StormFighter
Plus info
Link to comment

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

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