GetCameraTarget: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
No edit summary
Line 1: Line 1:
{{Server function}}
{{Server client function}}
__NOTOC__
__NOTOC__
This function returns an [[element]] that corresponds to the current target of the specified player's camera (i.e. what it is following).  
This function returns an [[element]] that corresponds to the current target of the specified player's camera (i.e. what it is following).  
==Syntax==  
==Syntax==
<section class="server" name="Server" show="true">
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
element getCameraTarget ( player thePlayer )
element getCameraTarget ( player thePlayer )
Line 9: Line 10:
===Required Arguments===  
===Required Arguments===  
*'''thePlayer:''' The player whose camera you wish to receive the target of.
*'''thePlayer:''' The player whose camera you wish to receive the target of.
</section>
<section class="client" name="Client" show="true">
<syntaxhighlight lang="lua">
element getCameraTarget ()
</syntaxhighlight>
</section>


===Returns===
===Returns===
Line 14: Line 21:


==Example==  
==Example==  
This example checks wether a player's camera's target is another player, and returns true or false accordingly.
<section class="server" name="Server" show="true">
This example checks whether a player's camera's target is another player, and returns true or false accordingly.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function isTargetPlayer( thePlayer )
function isTargetPlayer( thePlayer )
Line 25: Line 33:
end
end
</syntaxhighlight>
</syntaxhighlight>
</section>
==See Also==
==See Also==
{{Camera functions}}
{{Camera functions}}

Revision as of 19:55, 9 October 2007

This function returns an element that corresponds to the current target of the specified player's camera (i.e. what it is following).

Syntax

Click to collapse [-]
Server
element getCameraTarget ( player thePlayer )

Required Arguments

  • thePlayer: The player whose camera you wish to receive the target of.
Click to collapse [-]
Client
element getCameraTarget ()

Returns

Returns an element if the function was successful, false otherwise.

Example

Click to collapse [-]
Server

This example checks whether a player's camera's target is another player, and returns true or false accordingly.

function isTargetPlayer( thePlayer )
    local target = getCameraTarget ( thePlayer )
    if ( getElementType ( target ) == "player" ) then   -- If target is a player
        return true                                     -- Return true
    else
        return false                                    -- Otherwise, return false.
    end
end

See Also