GetElementInterior: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 9: Line 9:


===Required Arguments===
===Required Arguments===
*'''theElement:''' The element in which you'd like to retrieve the interior of.
*'''theElement:''' The element of which you'd like to retrieve the interior


===Returns===
===Returns===
Returns an ''integer'' for the interior if 'theElement' is valid, ''false'' otherwise.
Returns an [[int]] for the interior if '''theElement''' is valid, ''false'' otherwise.


==Example==
==Example==
This example shows a player if he is outside or not, when he enters the command 'AmIOutside'.
This example shows a player if he is outside or not, when he enters the command 'AmIOutside'.
<section show="true" name="Server" class="server">
<section show="true" name="Server" class="server">
''This example will not work as it is in a Clientside script, due to different Event names or slightly different syntax.''
''This example will not work as is in a client side script, due to different event names or slightly different syntax.''
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function AmIOutside ( player, command )
function AmIOutside ( thePlayer, command )
  if ( getElementInterior(player) == 0 ) then
    if ( getElementInterior(thePlayer) == 0 ) then
    outputChatBox ( "Yes you are outside " .. getClientName(player), player )
        outputChatBox ( "Yes you are outside " .. getClientName(thePlayer), thePlayer )
  else
    else
    outputChatBox ( "No you aren't outside " .. getClientName(player), player )
        outputChatBox ( "No you aren't outside " .. getClientName(thePlayer), thePlayer )
  end
    end
end
end
addCommandHandler ( "AmIOutside", AmIOutside )
addCommandHandler ( "AmIOutside", AmIOutside )

Revision as of 20:02, 19 August 2007

This function allows you to retrieve the interior of any element. An interior is the current loaded place, 0 being outside.

Syntax

int getElementInterior ( element theElement )

Required Arguments

  • theElement: The element of which you'd like to retrieve the interior

Returns

Returns an int for the interior if theElement is valid, false otherwise.

Example

This example shows a player if he is outside or not, when he enters the command 'AmIOutside'.

Click to collapse [-]
Server

This example will not work as is in a client side script, due to different event names or slightly different syntax.

function AmIOutside ( thePlayer, command )
    if ( getElementInterior(thePlayer) == 0 ) then
        outputChatBox ( "Yes you are outside " .. getClientName(thePlayer), thePlayer )
    else
        outputChatBox ( "No you aren't outside " .. getClientName(thePlayer), thePlayer )
    end
end
addCommandHandler ( "AmIOutside", AmIOutside )

See Also