SetElementInterior: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (flaw in example)
mNo edit summary
Line 5: Line 5:
==Syntax==
==Syntax==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool setElementInterior ( element theElement, int interior, [float x, float y, float z] )
bool setElementInterior ( element theElement, int interior [, float x, float y, float z] )
</syntaxhighlight>
</syntaxhighlight>


Line 21: Line 21:


==Example==
==Example==
<section name="Server" class="server" show="false">
<section name="Server" class="server" show="true">
In this example, if a player were to type /interior 1, they would be teleported into this interior
In this example, if a player were to type /interior 1, they would be teleported into this interior
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
Line 31: Line 31:
   else
   else
     --They didn't give one, so set them to the interior they wanted, but don't teleport them.
     --They didn't give one, so set them to the interior they wanted, but don't teleport them.
     setElementInterior ( source, interior )
     setElementInterior ( source, 0 )
   end
   end
end
end
Line 38: Line 38:
</section>
</section>


<section name="Client" class="client" show="false">
<section name="Client" class="client" show="true">
In this example, if a player were to type /interior 1, they would be teleported into this interior
In this example, if a player were to type /interior 1, they would be teleported into this interior
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
Line 48: Line 48:
   else
   else
     --They didn't give one, so set them to the interior they wanted, but don't teleport them.
     --They didn't give one, so set them to the interior they wanted, but don't teleport them.
     setElementInterior ( getLocalPlayer(), interior )
     setElementInterior ( getLocalPlayer(), 0 )
   end
   end
end
end

Revision as of 20:30, 14 August 2009

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

Syntax

bool setElementInterior ( element theElement, int interior [, float x, float y, float z] )

Required Arguments

  • theElement: The element in which you'd like to set the interior of.
  • interior: The interior you want to set the element to. Valid values are 0 to 255.

Returns

Returns true if theElement and interior are valid arguments, false otherwise.

Optional Arguments

  • x: A floating point number representing the X coordinate on the map.
  • y: A floating point number representing the Y coordinate on the map.
  • z: A floating point number representing the Z coordinate on the map.

Example

Click to collapse [-]
Server

In this example, if a player were to type /interior 1, they would be teleported into this interior

function interior ( source, commandName, interior )
  --Let's see if they gave an interior ID
  if ( interior ) then
    --They did, so lets assign them to that interior and teleport them there (all in 1 function call!)
    setElementInterior ( source, interior, 2233.91, 1714.73, 1011.38 )
  else
    --They didn't give one, so set them to the interior they wanted, but don't teleport them.
    setElementInterior ( source, 0 )
  end
end
addCommandHandler ( "interior", interior )
Click to collapse [-]
Client

In this example, if a player were to type /interior 1, they would be teleported into this interior

function interior ( commandName, interior )
  --Let's see if they gave a interior ID
  if ( interior ) then
    --They did, so let's assign them to that interior and teleport them there (all in 1 function call!)
    setElementInterior ( getLocalPlayer(), interior, 2233.91, 1714.73, 1011.38 )
  else
    --They didn't give one, so set them to the interior they wanted, but don't teleport them.
    setElementInterior ( getLocalPlayer(), 0 )
  end
end
addCommandHandler ( "interior", interior )

See Also