Thank you for replying, but setting cargo works fine, that's what i did already. I've got problems getting that data back.
Let me explain what i mean:
What i had:
Client
function setCargo(theTruck, cargoValue)
return triggerServerEvent ( "onTruckUpdate", theTruck, cargoValue ) --for setting cargo value, i.e. when i load the truck
end
--and
function getCargo(theTruck)
return getElementData(theTruck,"cargo") -- to get my data back, easy, one line
end
Server
addEvent("onTruckUpdate", true)
addEventHandler( "onTruckUpdate", getRootElement(), setTruckCargo)
function setTruckCargo ( theTruck, cargoValue )
setElementData(theTruck,"cargo",cargoValue, [b][color=#FF0000]true[/color][/b])
end
This works just fine, except for that true, which means that data will be synced with all clients immediately. I simply don't need that, because it's not urgent and i don't need it on all the clients at the same time.
But when i change it to false, switching the sync off, i can no longer use getElementData to retrieve the data from the server. To use the event system, i'll have to use two events ("query" and "reply") and lots of code instead of that simple <> line. Is there another way to grab my data from server without those two events?
In other words, is it possible to "request" data from server by a convenient way? Or at least, is it possible to write an encapsulated function, that would make a request and return all the values i need? Like:
function getMyData(theTruck)
--get the data from the server--
return myData
end