Scripting Moderators ds1-e Posted June 3, 2019 Scripting Moderators Share Posted June 3, 2019 Hey, as topic say, which is better to use? Let's say i need to check something every 5 seconds, unlimited times. Will be better to use setTimer, every 5 seconds, and unlimited executes or check that in OnClientRender, like: my_variable == true then getTickCount() and do my stuff? Link to comment
Moderators Patrick Posted June 3, 2019 Moderators Share Posted June 3, 2019 setTimer (i think) 1 Link to comment
Moderators IIYAMA Posted June 3, 2019 Moderators Share Posted June 3, 2019 (edited) 1 active timer = setTimer 1 active timer + dx countdown = getTickCount 500+ active timers = (getTickCount or 1 global setTimer ) passive timers = getTickCount It depends on the quantity, precision and the functionality you want to use next to it. And yes with onClientRender you have to mind reducing the check amount. I can send you an example how I build my global lua timer, if you want. Edited June 3, 2019 by IIYAMA 1 Link to comment
Scripting Moderators ds1-e Posted June 3, 2019 Author Scripting Moderators Share Posted June 3, 2019 (edited) 1 hour ago, IIYAMA said: 1 active timer = setTimer 1 active timer + dx countdown = getTickCount 500+ active timers = (getTickCount or 1 global setTimer ) passive timers = getTickCount It depends on the quantity, precision and the functionality you want to use next to it. And yes with onClientRender you have to mind reducing the check amount. I can send you an example how I build my global lua timer, if you want. Why not. In total i will have less than 5 time task. (all of them will be active if needed - only.) local painTick = getTickCount() -- OnClientRender if playerTable.player.pain then -- only if boolean == true if getTickCount() - painTick > 3000 then painTick = getTickCount() -- do my stuff. end end end Edited June 3, 2019 by majqq Link to comment
Moderators IIYAMA Posted June 3, 2019 Moderators Share Posted June 3, 2019 2 hours ago, majqq said: Why not. In total i will have less than 5 time task. (all of them will be active if needed - only.) local painTick = getTickCount() -- OnClientRender if playerTable.player.pain then -- only if boolean == true if getTickCount() - painTick > 3000 then painTick = getTickCount() -- do my stuff. end end end Because the addEventHandler + "onClientRender" will use more memory than a timer. Unless you have already attached an addEventHandler . Then it is more or less two function call's every frame vs a timer. Link to comment
Scripting Moderators ds1-e Posted June 3, 2019 Author Scripting Moderators Share Posted June 3, 2019 (edited) 15 minutes ago, IIYAMA said: Because the addEventHandler + "onClientRender" will use more memory than a timer. Unless you have already attached an addEventHandler . Then it is more or less two function call's every frame vs a timer. It's already attached to onClientRender within render events. Edited June 3, 2019 by majqq 1 Link to comment
Moderators IIYAMA Posted June 3, 2019 Moderators Share Posted June 3, 2019 5 minutes ago, majqq said: It's already attached to onClientRender within render events. Then it would be fine. 1 Link to comment
Scripting Moderators ds1-e Posted June 8, 2019 Author Scripting Moderators Share Posted June 8, 2019 On 03/06/2019 at 21:42, IIYAMA said: Then it would be fine. Hey, i would like to know if using (local) variables, have any affect on performance, in onClientRender. For example. Code like this: local table = {value = 12000} -- onClientRender local value = table.value dxDrawText(value) It's better than this? Or it doesn't really matter. local table = {value = 12000} -- onClientRender dxDrawText(table.value) Link to comment
Moderators IIYAMA Posted June 8, 2019 Moderators Share Posted June 8, 2019 8 hours ago, majqq said: Hey, i would like to know if using (local) variables, have any affect on performance, in onClientRender. For example. Code like this: local table = {value = 12000} -- onClientRender local value = table.value dxDrawText(value) It's better than this? Or it doesn't really matter. local table = {value = 12000} -- onClientRender dxDrawText(table.value) Using a variable in this case might boost a very little performance. But not in a way that it will matter too much. A case where it will actually have a significant effect: local table = {value = 12000} -- onClientRender local value = table.value dxDrawText(value) dxDrawText(value) -- boost ! These steps will be reduced to 1x instead of 2x. (1. Using the table reference to find the table object. Not sure if this actually takes more time than a numeric value.) 2. Searching in the table. Which takes time. 1 Link to comment
Scripting Moderators ds1-e Posted July 22, 2019 Author Scripting Moderators Share Posted July 22, 2019 On 03/06/2019 at 18:07, IIYAMA said: I can send you an example how I build my global Lua timer, if you want. Hey, if you could send it, this would be nice. Besides, i need to ask about other thing. I am thinking if i should choose client or server for that. I will use setTimer or getTickCount(), to make time function. First of all send trigger from server and later decrease it, each 1 minute. Here's the problem, because i don't know if i should decrease it on client, and send trigger to server, or simply do it on server-side (this is in setTimer case), about getTickCount() i am forced to do this on client anyways. I'm afraid if this is secure thing. I store all of data in tables (which are more secure than elementData, or i am wrong?), on server and client. Besides i've secured all of my triggers. Link to comment
Moderators IIYAMA Posted July 22, 2019 Moderators Share Posted July 22, 2019 (edited) 1 hour ago, majqq said: Hey, if you could send it, this would be nice. Besides, i need to ask about other thing. I am thinking if i should choose client or server for that. I will use setTimer or getTickCount(), to make time function. First of all send trigger from server and later decrease it, each 1 minute. Here's the problem, because i don't know if i should decrease it on client, and send trigger to server, or simply do it on server-side (this is in setTimer case), about getTickCount() i am forced to do this on client anyways. I'm afraid if this is secure thing. I store all of data in tables (which are more secure than elementData, or i am wrong?), on server and client. Besides i've secured all of my triggers. I will send it you, when I am back from my holiday. Please send me a reminder during the coming weekend. Elementdata is indeed something with more risks. Clients can edit element data from each element, no restrictions. Potential risks: cheat engine stuff, custom cached scripts loaded with loadstring, staff with executed command rights and downloaded resources. I don't know what exactly you are going to build, but if the values shouldn't be edited on clientside, then don't edit them clientside. The server is the teacher and all the students have to listen and shut up, until they have a question or suggestion. Edited July 22, 2019 by IIYAMA 1 Link to comment
Scripting Moderators ds1-e Posted July 30, 2019 Author Scripting Moderators Share Posted July 30, 2019 On 22/07/2019 at 18:17, IIYAMA said: I will send it you, when I am back from my holiday. Please send me a reminder during the coming weekend. Elementdata is indeed something with more risks. Clients can edit element data from each element, no restrictions. Potential risks: cheat engine stuff, custom cached scripts loaded with loadstring, staff with executed command rights and downloaded resources. I don't know what exactly you are going to build, but if the values shouldn't be edited on clientside, then don't edit them clientside. The server is the teacher and all the students have to listen and shut up, until they have a question or suggestion. Hey You told me to remind you about that, and here I am. Link to comment
Moderators IIYAMA Posted July 30, 2019 Moderators Share Posted July 30, 2019 11 hours ago, majqq said: Hey You told me to remind you about that, and here I am. Ah yea, did send you it. 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