Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 21/11/22 in all areas

  1. ----- Server ---- local objects = {} --- comando para crear o destruir el objeto y almacenar en la tabla addCommandHandler("water", function(player) if not objects[player] then objects[player] = createObject(1221, 0, 0, 0) else destroyElement(objects[player]) objects[player] = nil end --- mandamos al client todos los objetos triggerClientEvent("water_walk", root, objects) end ) ---- si un jugador entra al server necesitamos mandarle la tabla de objetos addEventHandler("onPlayerResourceStart", root, function(loadedResource) if loadedResource == resource then triggerClientEvent(source, "water_walk", source, objects) end end ) ----- Client ---- local objects = {} addEvent("water_walk", true) addEventHandler("water_walk", root, function(o) objects = o ---- removemos el render por si la tabla esta vacia removeEventHandler("onClientRender", root, managewaterwalk) if objects and --- Si la tabla no esta vacía y hay al menos un objeto iniciamos el render for _, object, in pairs(objects) do if object then addEventHandler("onClientRender", root, managewaterwalk) return end end end end ) function managewaterwalk() for player, object in pairs(objects) do local x, y, z = getElementPosition(player) setElementPosition(object, x, y, z - .5) end end PD: no lo he probado así que me avisas si te sirve
    1 point
  2. Hello, you are on the wrong forum im afraid. This forum is about Mta sa which is a mod to play san andreas online. Nothing to do with fiveM ?
    1 point
  3. Puedes mover la función 'waterOn' a server-side, al momento de usar el comando triggearlo a todos los jugadores conectados para luego desde client-side obtener a ese jugador guardado en una variable quizás para luego renderizar los objetos debajo de él. Otra es no triggearlo, sino al momento de usar el comando adherirle al jugador alguna key con elementData para sincronizarlo tanto client-side como server-side, y desde client-side hacer un loop de jugadores dentro del evento render con la condición de la 'key' elementData que te mencioné y así crear los objetos debajo de él para que todos logren verlo. No sé que tan óptimo podría ser eso, pero es una idea así rápida. Espero se entienda ?
    1 point
  4. Como tal puede crear el comando en el lado del cliente, despues lo pasas al server guardas el objecto en una tabla, despues lo vuelves a triggear al cliente.
    1 point
  5. The important thing is that you check if the elementdata has changed. Elementdata has it's own update rate(so NO not every frame), but it will also update when you set the elementdata to the same value. "Why does it updates(synchronisation) when the value is the same?" Because serverside/clientside can use the elementdata without synchronisation, so it has to be updated on the other side too. Can simply be reduced with: if getElementData(element,"key") ~= newData then setElementData(element,"key",newData) end The update rate of elementdata is very quick, so getTickCount() can reduce the amount of updates. local nextUpdate = 0 addEventHandler("onClientRender",root, function () local timeNow = getTickCount() if timeNow > nextUpdate then nextUpdate = timeNow+1000 outputChatBox("update!!!!!") end end) Elementdata can be handy but you have to be careful how many times you execute it (on both sides).
    1 point
×
×
  • Create New...