GetWorldFromScreenPosition: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Client function}}
This function allows you to retrieve the world position coresponding to the 2D position on the screen.
This function allows you to retrieve the world position coresponding to the 2D position on the screen.


Line 15: Line 16:


==Example==
==Example==
<section name="Server" class="client" show="true">
This example binds the local player's "'''i'''" key to a function that creates an explosion in the middle of the screen.
This example binds the local player's "'''i'''" key to a function that creates an explosion in the middle of the screen.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
Line 23: Line 25:
bindKey ( "i", "down", "create explosion", explosion )
bindKey ( "i", "down", "create explosion", explosion )
</syntaxhighlight>
</syntaxhighlight>
</section>


==See Also==
==See Also==
{{World functions}}
{{World functions}}

Revision as of 15:04, 4 August 2007

This function allows you to retrieve the world position coresponding to the 2D position on the screen.

Syntax

float float float getWorldFromScreenPosition ( float x, float y )

Required Arguments

  • x: A float value between ? and ? indicating the x position on the screen.
  • y: A float value between ? and ? indicating the y position on the screen.

Returns

Returns three floats indicating the world position, x, y and z respectively, false otherwise.

Example

Click to collapse [-]
Server

This example binds the local player's "i" key to a function that creates an explosion in the middle of the screen.

function explosion ( key, keyState )
  local x, y, z = getWorldFromScreenPosition ( x, y, z, 0.5, 0.5 )
  createExplosion ( x, y, z, 11 )
end
bindKey ( "i", "down", "create explosion", explosion )

See Also