OnClientPreRender: Difference between revisions
Jump to navigation
Jump to search
(Created page with '__NOTOC__ {{Client event}} This event is triggered every time before GTA renders a new frame. ==Parameters== ''None'' ==Source== The source of th…') |
No edit summary |
||
(11 intermediate revisions by 8 users not shown) | |||
Line 4: | Line 4: | ||
==Parameters== | ==Parameters== | ||
'' | <syntaxhighlight lang="lua"> | ||
float timeSlice | |||
</syntaxhighlight> | |||
*'''timeSlice:''' The interval between this frame and the previous one in milliseconds (delta time). | |||
==Source== | ==Source== | ||
Line 13: | Line 16: | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function updateCamera () | function updateCamera () | ||
local x, y, z = getElementPosition ( | local x, y, z = getElementPosition ( localPlayer ) | ||
setCameraMatrix ( x, y, z + 50, x, y, z ) | setCameraMatrix ( x, y, z + 50, x, y, z ) | ||
end | end | ||
addEventHandler ( " | addEventHandler ( "onClientPreRender", root, updateCamera ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==Warning== | |||
This event and [[onClientRender]] will trigger whatever function it is attached to with every frame. Depending on the server's maximum FPS and what your computer might handle - you might end up triggering the function 30-60 times '''per second'''. | |||
As a result, this event may cause severe lag and/or even crashes if not used cautiously. | |||
==See Also== | ==See Also== | ||
===[[Game_Processing_Order|Game Processing Order]]=== | |||
===Other client events=== | ===Other client events=== | ||
{{Client_other_events}} | {{Client_other_events}} | ||
===Client event functions=== | ===Client event functions=== | ||
{{Client_event_functions}} | {{Client_event_functions}} |
Latest revision as of 17:24, 30 July 2020
This event is triggered every time before GTA renders a new frame.
Parameters
float timeSlice
- timeSlice: The interval between this frame and the previous one in milliseconds (delta time).
Source
The source of this event is the client's root element.
Example
This example makes the camera follow the player in a GTA2-like way.
function updateCamera () local x, y, z = getElementPosition ( localPlayer ) setCameraMatrix ( x, y, z + 50, x, y, z ) end addEventHandler ( "onClientPreRender", root, updateCamera )
Warning
This event and onClientRender will trigger whatever function it is attached to with every frame. Depending on the server's maximum FPS and what your computer might handle - you might end up triggering the function 30-60 times per second.
As a result, this event may cause severe lag and/or even crashes if not used cautiously.
See Also
Game Processing Order
Other client events
- onClientChatMessage
- onClientConsole
- onClientDebugMessage
- onClientExplosion
- onClientFileDownloadComplete
- onClientHUDRender
- onClientMinimize
- onClientMTAFocusChange
- onClientPedsProcessed
- onClientPlayerNetworkStatus
- onClientPreRender
- onClientRender
- onClientRestore
- onClientTransferBoxProgressChange
- onClientTransferBoxVisibilityChange
- onClientWorldSound
Client event functions
- triggerLatentServerEvent
- triggerServerEvent
- Shared
- addEvent
- addEventHandler
- cancelEvent
- cancelLatentEvent
- getEventHandlers
- getLatentEventHandles
- getLatentEventStatus
- removeEventHandler
- triggerEvent
- wasEventCancelled