louie999 Posted October 3, 2015 Share Posted October 3, 2015 So I was making a safe zone system, I was just wondering, what is better, triggerClientEvent or setElementData?, my safe zone script works but I don't which of those is more efficient. Link to comment
UserToDelete Posted October 3, 2015 Share Posted October 3, 2015 create radarArea and use onClientRender, is more effective i think Link to comment
KariiiM Posted October 3, 2015 Share Posted October 3, 2015 So I was making a safe zone system, I was just wondering, what is better, triggerClientEvent or setElementData?, my safe zone script works but I don't which of those is more efficient. Both of them are useful in my opinion, it's just up to which data you want to trigger Link to comment
DeVo Posted October 3, 2015 Share Posted October 3, 2015 triggering a client event will use more CPU power, of course. Link to comment
Dealman Posted October 3, 2015 Share Posted October 3, 2015 triggering a client event will use more CPU power, of course. And you base this on what? It all depends on how it's set up. If you use setElementData and leave it as default - it will sync between all players. If you use triggerClientEvent you can simply trigger it for one client. All the server has to do is trigger the event, the client takes care of the rest of the event. While both work, I sincerely doubt triggerClientEvent uses "more CPU" than setElementData. Link to comment
KariiiM Posted October 3, 2015 Share Posted October 3, 2015 The wiki already explained everything Note: To save client CPU, you should avoid setting sourceElement to the root element where possible. Using resourceRoot is usually sufficient if the event is handled by the same resource on the client. Link to comment
DeVo Posted October 3, 2015 Share Posted October 3, 2015 triggering a client event will use more CPU power, of course. And you base this on what? It all depends on how it's set up. If you use setElementData and leave it as default - it will sync between all players. If you use triggerClientEvent you can simply trigger it for one client. All the server has to do is trigger the event, the client takes care of the rest of the event. While both work, I sincerely doubt triggerClientEvent uses "more CPU" than setElementData. There's a difference between sync(ing) and trigger(ing). Link to comment
Moderators IIYAMA Posted October 3, 2015 Moderators Share Posted October 3, 2015 This is circa my list of benefits between those two. triggerClientEvent Faster. (priority) Can have a sending to > target. Uses more bandwidth per player. Because of the high priority it can cause de-sync/time-outs when it is used frequently. (more than 30 per second, depending on your internet speed) setElementData Uses less bandwidth per player. (a lot less) Can be easier used between other scripts. Doesn't have a sending to > target. Uses more bandwidth depending on the player count.(total) Is slower. (priority) Remains intact after the resource stops. Legend:► Good ► Not good ► Both Link to comment
KariiiM Posted October 3, 2015 Share Posted October 3, 2015 This is circa my list of benefits between those two. triggerClientEvent Because of the high priority it can cause de-sync/time-outs when it is used frequently. (more than 30 per second, depending on your internet speed) As far as i know there's no relation between internet speed and trigger events ,the relation between them is the CPU and it's up to computer's processor Link to comment
Moderators IIYAMA Posted October 3, 2015 Moderators Share Posted October 3, 2015 Oh there is. You can simply test that by using an amount of triggerServerEvent's on the rate of the "onClientRender" event. If you have a normal pc, you will get disconnected before your game starts to crash. Link to comment
KariiiM Posted October 3, 2015 Share Posted October 3, 2015 Oh there is.If you have a normal pc, you will get disconnected before your game starts to crash. Yes, it happen when you enter to some servers are not scripted professionally, you feel with the FPS drop each time, if the FPS dropped that mean the usage of CPU used alot Link to comment
TAPL Posted October 3, 2015 Share Posted October 3, 2015 https://forum.multitheftauto.com/viewtopic.php?f=130&t=75051 Link to comment
Moderators IIYAMA Posted October 4, 2015 Moderators Share Posted October 4, 2015 Oh there is.If you have a normal pc, you will get disconnected before your game starts to crash. Yes, it happen when you enter to some servers are not scripted professionally, you feel with the FPS drop each time, if the FPS dropped that mean the usage of CPU used alot This has nothing to do with it. My fps will not drop when I execute a trigger event 100 times per second. Disconnecting and crashing is not the same thing. You will get disconnected when you lose connection with the server. And you will crash when your cpu can't handle it any more. And I don't crash, I only get disconnected. Which means my cpu is doing just fine. The only way you can know this, is by thinking logic or test it yourself. Link to comment
louie999 Posted October 4, 2015 Author Share Posted October 4, 2015 Thanks guys for the answers, I think I'll go with triggerClientEvent for my safe zone script Link to comment
KariiiM Posted October 4, 2015 Share Posted October 4, 2015 This has nothing to do with it. My fps will not drop when I execute a trigger event 100 times per second. Disconnecting and crashing is not the same thing. You will get disconnected when you lose connection with the server. And you will crash when your cpu can't handle it any more. And I don't crash, I only get disconnected. Which means my cpu is doing just fine. The only way you can know this, is by thinking logic or test it yourself. i'm talking about the normal computers Link to comment
Noki Posted October 5, 2015 Share Posted October 5, 2015 (edited) i'm talking about the normal computers I think you mean things like the specific server having a lot of DX drawings or possibly using a lot of memory (storing large tables in memory etc). Thanks guys for the answers, I think I'll go with triggerClientEvent for my safe zone script You could make your safe zone script entirely client-sided if you just wanted to stop player damage within a zone. Edit: changed a word because DirectX is in fact not an element Edited October 5, 2015 by Guest Link to comment
Moderators IIYAMA Posted October 5, 2015 Moderators Share Posted October 5, 2015 i'm talking about the normal computers New pc's only have more cores or a little bit extra ghz. But mta only uses 1 core. So also normal pc's can do that too. I am sure your pc can run this without crashing: setTimer(function () for i=1, 100 do triggerServerEvent("serverEvent",localPlayer) end end,1000,0) addEvent("serverEvent",true) addEventHandler("serverEvent",root, function () end) Link to comment
KariiiM Posted October 5, 2015 Share Posted October 5, 2015 i'm talking about the normal computers I think you mean things like the specific server having a lot of DX elements or possibly using a lot of memory (storing large tables in memory etc). Exactly, bad usage of scripting it may be a trouble to the player 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