OnClientPreRender: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (→‎Example: does't work with getLocalPlayer() as second argument in addEventHandler)
Line 15: Line 15:
This example makes the camera follow the player in a GTA2-like way.
This example makes the camera follow the player in a GTA2-like way.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
root = getRootElement ()
function updateCamera ()
function updateCamera ()
local x, y, z = getElementPosition ( getLocalPlayer () )
local x, y, z = getElementPosition ( getLocalPlayer () )

Revision as of 13:23, 7 August 2009

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.

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.

root = getRootElement ()
function updateCamera ()
	local x, y, z = getElementPosition ( getLocalPlayer () )
	setCameraMatrix ( x, y, z + 50, x, y, z )
end
addEventHandler ( "onClientPreRender", root, updateCamera )

See Also

Other client events


Client event functions

Shared