Feche1320 Posted October 16, 2014 Share Posted October 16, 2014 Hey guys, another of my big questions If I use getElementData in onClientRender, the client will call the server each time the frame is rendered or setElementData sends the data to the client when it is updated and it stores it clienside? Link to comment
manawydan Posted October 16, 2014 Share Posted October 16, 2014 you dont get problem with it, if you put in client or server, both will have it Link to comment
.:HyPeX:. Posted October 16, 2014 Share Posted October 16, 2014 Theorically as manawydan data is synchronized, this means the client will not call the server each time it wants to check the data, it will ask for the currently local-stored one wich can be itself modified by the server. Link to comment
Anubhav Posted October 16, 2014 Share Posted October 16, 2014 And I realy don't suggest to use getElementData with onClientRender. It can cause massive lag! Link to comment
John Smith Posted October 16, 2014 Share Posted October 16, 2014 It can cause massive lag! No Link to comment
Anubhav Posted October 16, 2014 Share Posted October 16, 2014 It can cause massive lag! No viewtopic.php?f=148&t=77161 Stop thinking it won't, it will decrease performence. You don't care right? See performence browser. Link to comment
John Smith Posted October 16, 2014 Share Posted October 16, 2014 It can cause massive lag! No viewtopic.php?f=148&t=77161 Stop thinking it won't, it will decrease performence. You don't care right? See performence browser. if you'd have some experience you'd know how to decrease that flaw to minimum. Link to comment
Dealman Posted October 16, 2014 Share Posted October 16, 2014 if you'd have some experience you'd know how to decrease that flaw to minimum. And you obviously know how to, don't you? Anyway, I disagree that using element data is bad. So long as you use it properly, the performance impact won't be too significant. What I disagree with however, is to use it with onClientRender. What people always seem to fail to realize, despite me editing the MTA Wiki - any code you use with onClientRender will be run with each frame. And generally, a game renders 30 to 60 frames per second, depending on your settings. I don't know why you'd have to set someone's data 30-60 times per second...? Link to comment
Feche1320 Posted October 16, 2014 Author Share Posted October 16, 2014 It's for a user panel, when panel is open stats are showed, when closed, not. Link to comment
Anubhav Posted October 16, 2014 Share Posted October 16, 2014 Still it will cause some small lags, why don't you just use a timer on each seconds. It will be better than onClientRender! Link to comment
Moderators IIYAMA Posted October 17, 2014 Moderators Share Posted October 17, 2014 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 Link to comment
Anubhav Posted October 17, 2014 Share Posted October 17, 2014 Actually you can also use onElementDataChange with a trigger! 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