CreateMarker: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (Reverted edits by MR.Mosa (talk) to last revision by JHXP)
Line 57: Line 57:
==Example==
==Example==
<section name="Example 1" class="server" show="true">
<section name="Example 1" class="server" show="true">
create Marker :
This example creates a marker next to the player when they type 'createmarker':
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
-- this function is called whenever someone types 'createmarker' in the console:
-- this function is called whenever someone types 'createmarker' in the console:
function consoleCreateMarker ( thePlayer, commandName )
function consoleCreateMarker ( thePlayer, commandName )
   if ( thePlayer ) then
   if ( thePlayer ) then
       local x, y, z = getElementPosition ( thePlayer ) -- Get Player Position
       local x, y, z = getElementPosition ( thePlayer ) -- get the player's position
       local theMarker = createMarker ( x + 2, y + 2, z, "cylinder", 1.5, 255, 255, 0, 170 ) -- create Marker
      -- create a cylindrical marker next to the player:
       if ( theMarker ) then
       local theMarker = createMarker ( x + 2, y + 2, z, "cylinder", 1.5, 255, 255, 0, 170 )
         outputConsole ( "Marker was done successfully", thePlayer )
       if ( theMarker ) then -- check if the marker was created successfully
       else  
         outputConsole ( "Marker created successfully", thePlayer )
         outputConsole ( "There error", thePlayer )
       else
         outputConsole ( "Failed to create marker", thePlayer )
       end
       end
   end
   end

Revision as of 16:15, 8 November 2016

This function creates a marker. A marker is a 3D model in the world that can highlight a particular point or area, often used to instruct players where to go to perform actions such as entering buildings.

There are various limits that govern the maximum number of each type that can be visible at once. These are:

  • Coronas: 32
  • Checkpoints, Rings, Cylinders and Arrows combined: 32

You are able to create as many markers as you wish (memory and element limit permitting), but the player will only be able to see the nearest ones up to the limit.

Syntax

Click to collapse [-]
Server
marker createMarker ( float x, float y, float z [, string theType = "checkpoint", float size = 4.0, int r = 0, int g = 0, int b = 255, int a = 255, visibleTo = getRootElement( ) ] )

OOP Syntax Help! I don't understand this!

Method: Marker(...)


Required 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.

Optional arguments

NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use. For more information on optional arguments, see optional arguments.

  • theType: The visual type of the marker to be created. Possible values:
    • "checkpoint": A race checkpoint. These are very tall, but not infinite, light pillars. Checkpoints snap to ground and become invisible after going over a certain Z height.
    • "ring": Doughnut shaped ring, normally used for aircraft.
    • "cylinder": Small glowing ground ring. These are the glow markers you walk into to activate missions or events in single player.
    • "arrow": Arrow pointing down. These are the arrows on the doors you can enter in single player, except MTA's are not animated by default.
    • "corona": A glowing ball of light.
  • size: The diameter of the marker to be created, in meters.
  • r: An integer number representing the amount of red to use in the colouring of the marker (0 - 255).
  • g: An integer number representing the amount of green to use in the colouring of the marker (0 - 255).
  • b: An integer number representing the amount of blue to use in the colouring of the marker (0 - 255).
  • a: An integer number representing the amount of alpha to use in the colouring of the marker (0 - 255 where 0 is transparent and 255 is opaque).
  • visibleTo: This defines which elements can see the marker. Defaults to visible to everyone. See visibility.
Click to collapse [-]
Client
marker createMarker ( float x, float y, float z [, string theType = "checkpoint", float size = 4.0, int r = 0, int g = 0, int b = 255, int a = 255 ] )

OOP Syntax Help! I don't understand this!

Method: Marker(...)


Required 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.

Optional arguments

NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use. For more information on optional arguments, see optional arguments.

  • theType: The visual type of the marker to be created. Possible values:
    • "checkpoint": A race checkpoint. These are very tall, but not infinite, light pillars. Checkpoints snap to ground and become invisible after going over a certain Z height.
    • "ring": Doughnut shaped ring, normally used for aircraft.
    • "cylinder": Small glowing ground ring. These are the glow markers you walk into to activate missions or events in single player.
    • "arrow": Arrow pointing down. These are the arrows on the doors you can enter in single player, except MTA's are not animated by default.
    • "corona": A glowing ball of light.
  • size: The diameter of the marker to be created, in meters.
  • r: An integer number representing the amount of red to use in the colouring of the marker (0 - 255).
  • g: An integer number representing the amount of green to use in the colouring of the marker (0 - 255).
  • b: An integer number representing the amount of blue to use in the colouring of the marker (0 - 255).
  • a: An integer number representing the amount of alpha to use in the colouring of the marker (0 - 255 where 0 is transparent and 255 is opaque).

Returns

Returns the marker element that was created, or false if the arguments are incorrect.

Example

Click to collapse [-]
Example 1

This example creates a marker next to the player when they type 'createmarker':

-- this function is called whenever someone types 'createmarker' in the console:
function consoleCreateMarker ( thePlayer, commandName )
   if ( thePlayer ) then
      local x, y, z = getElementPosition ( thePlayer ) -- get the player's position
      -- create a cylindrical marker next to the player:
      local theMarker = createMarker ( x + 2, y + 2, z, "cylinder", 1.5, 255, 255, 0, 170 )
      if ( theMarker ) then -- check if the marker was created successfully
         outputConsole ( "Marker created successfully", thePlayer )
      else
         outputConsole ( "Failed to create marker", thePlayer )
      end
   end
end
addCommandHandler ( "createmarker", consoleCreateMarker )

Markers types

Markers.png

See Also