Search the Community
Showing results for tags 'onclientprerender'.
-
Render events enhancement Having a lot of render events in your resource? Easier attach and remove? Or do you want to pass arguments in to a function which is attached to a render event? Then this might be something for you. Syntax: addRenderEvent bool addRenderEvent(function functionVar [, string eventName, arguments ...]) Arguments: The function you want to attach/target. The event you want to use. ( "onClientRender", "onClientPreRender", "onClientHUDRender") If you do not fill in one of these three, it will automatic fallback to "onClientRender". Fool proof. Arguments you can pass to the target function. (which isn't possible with the default addEventHandler + onClientRender function) Returns: true when added, and false otherwise. Syntax: removeRenderEvent bool removeRenderEvent(function functionVar [, string eventName]) Arguments: The function you want to attach/target. The event you want to use. ( "onClientRender", "onClientPreRender", "onClientHUDRender") If you do not fill in one of these three, it will automatic fallback to "onClientRender". Fool proof. Returns: true if found + removed, and false otherwise. (Not recommended to execute this function every frame > performance) onClientPreRender + timeslice If you use "onClientPreRender", just like the default event, it will pass the timeSlice to the attached/targetted function. https://wiki.multitheftauto.com/wiki/OnClientPreRender I am not sure if attached is the right word for this example, because it isn't really attached to the event. It is saved in a table which gets looped every frame. Performance Is this code bad for performance? The answer to that is NO. I ran a test for it, and it seems that addRenderEvent used less CPU AFTER adding the events. (addRenderEvent: 31% CPU, addEventHandler 99/100% CPU) Adding the event will probably use more CPU, but that is only one execution. Feel free to re-test this example, I am interested how it would perform on your pc's. Performance test code (Not the source code ) Source code:
- 21 replies
-
- 12
-
- onclienthudrender
- onclientprerender
-
(and 1 more)
Tagged with: