GetCameraTarget: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Undo revision 36307 by MOJRM-511 (talk))
(→‎Syntax: OOP syntax added)
Line 7: Line 7:
element getCameraTarget ( player thePlayer )
element getCameraTarget ( player thePlayer )
</syntaxhighlight>  
</syntaxhighlight>  
 
{{OOP||[[player]]:getCameraTarget|cameraTarget|setCameraTarget}}
===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.

Revision as of 05:45, 15 July 2014

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 )

OOP Syntax Help! I don't understand this!

Method: player:getCameraTarget(...)
Variable: .cameraTarget
Counterpart: setCameraTarget


Required Arguments

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

Returns

  • Returns an element of the target if the function was successful, or false if bad arguments were specified
  • Returns false if the camera is in Fixed mode and has no target.

Example

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

Click to collapse [-]
Server script
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