GetCameraTarget: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 1: Line 1:
__NOTOC__  
{{Server function}}
__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==  
Line 13: Line 14:


==Example==  
==Example==  
This example checks wether a players cameras target is another player, and returns true or false accordingly.
This example checks wether a player's camera's target is another player, and returns true or false accordingly.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function isTargetPlayer( player )
function isTargetPlayer( thePlayer )
     local target = getCameraTarget( player )
     local target = getCameraTarget ( thePlayer )
     if ( getElementType ( target ) == "player" ) then --If target is a player
     if ( getElementType ( target ) == "player" ) then   -- If target is a player
         return true --Return true
         return true                                     -- Return true
     else
     else
         return false --Otherwise, return false.
         return false                                   -- Otherwise, return false.
     end
     end
end
end

Revision as of 17:07, 20 August 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

element getCameraTarget ( player thePlayer )

Required Arguments

  • thePlayer: The player whose camera you wish to receive the target of.

Returns

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

Example

This example checks wether 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