OnClientRender: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (See Also for other client events)
m (formatting)
 
(12 intermediate revisions by 9 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Client event}}  
{{Client event}}  
This event is triggered every time GTA renders a new frame. It is useful for clientside operations that have to be applied repeatedly with very short time differences between them.
This event is triggered every time GTA renders a new frame. It is required for the DirectX drawing functions, and also useful for other clientside operations that have to be applied repeatedly with very short time differences between them.
 
{{Warning|
This event and [[onClientPreRender]] 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.}}


==Parameters==
==Parameters==
Line 10: Line 15:


==Example==
==Example==
[[Category:Needs Example]]
This example makes the camera follow the player in a GTA2-like way. This will be a little bit laggy. If you want the camera to follow something (eg. player or vehicle) then use [[onClientPreRender]] instead.
<syntaxhighlight lang="lua">
function updateCamera()
local x, y, z = getElementPosition(localPlayer)
setCameraMatrix(x, y, z + 50, x, y, z)
end
addEventHandler("onClientRender", root, updateCamera)
</syntaxhighlight>


==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:47, 1 June 2025

This event is triggered every time GTA renders a new frame. It is required for the DirectX drawing functions, and also useful for other clientside operations that have to be applied repeatedly with very short time differences between them.

[[|link=|]] Warning: This event and onClientPreRender 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.

Parameters

None

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. This will be a little bit laggy. If you want the camera to follow something (eg. player or vehicle) then use onClientPreRender instead.

function updateCamera()
	local x, y, z = getElementPosition(localPlayer)
	setCameraMatrix(x, y, z + 50, x, y, z)
end
addEventHandler("onClientRender", root, updateCamera)

See Also

Game Processing Order

Other client events


Client event functions