aintaro Posted June 24, 2014 Share Posted June 24, 2014 Hello, What is the most efficient code : EXAMPLE 1 triggerClientEvent("eventName", getResourceRootElement(getThisResource()), afunction) triggerClientEvent("eventName", getRootElement(), afunction) thanks in advance, Greetz, Aintaro! Link to comment
ADCX Posted June 24, 2014 Share Posted June 24, 2014 That only changes the source of event that is triggered, so in first case it would be resource's root element, while in the other it would be regular root element (containing all other elements). I don't think this affects the efficiency at all, unless you are trying to parse some element as source, then it depends on what do you put as source. Link to comment
aintaro Posted June 25, 2014 Author Share Posted June 25, 2014 That only changes the source of event that is triggered, so in first case it would be resource's root element, while in the other it would be regular root element (containing all other elements). I don't think this affects the efficiency at all, unless you are trying to parse some element as source, then it depends on what do you put as source. Root executes faster than getrootelement () so thats why I was wondering if it could make a difference Link to comment
MIKI785 Posted June 25, 2014 Share Posted June 25, 2014 Im not sure about it but i read somewhere on wiki that having lots of event handlers handled to root usea more cpu. Dont forget that there are predefined variables root and resourceRoot. Link to comment
arezu Posted June 25, 2014 Share Posted June 25, 2014 I think that the higher up in element tree the element you are attaching with is, the slower it will take to trigger the event, but only if you are triggering with a child of the attached element. Like if you attach event to root, but trigger the event with a player as source element. Depending on how mta devs have implemented it, it may also take longer to trigger if you have many events that are attached to the same element than attaching to an element that doesn't have many events attached to it. But anways, resourceRoot should be more efficient than root. Though the difference in performance may be non-existent. Link to comment
cheez3d Posted June 25, 2014 Share Posted June 25, 2014 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
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