CreateMarker: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 29: Line 29:
===Optional arguments===
===Optional arguments===
* '''type''': The visual type of the marker to be created. Possible values:
* '''type''': The visual type of the marker to be created. Possible values:
** '''"checkpoint"''': Race checkpoint. Very tall pillar, but it is not infinite. Checkpoints are inivisble after a certain Z height.
{{Marker_types}}
** '''"ring"''': Doughnut shaped ring. 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. It always attaches to ground-level.
** '''"arrow"''': Animated arrow pointing down. These are the arrows on the doors you can enter in single player.
** '''"corona"''': A glowing ball of light.
* '''size''': The diameter of the marker to be created, in meters.
* '''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).
* '''r''': An integer number representing the amount of red to use in the colouring of the marker (0 - 255).

Revision as of 12:53, 22 April 2007

Dialog-information.png This article needs checking.

Reason(s):
  • Arrow has an extreme bounce... it needs to be definable.
  • Detection radius is huge for all... can this be optional or adjusted to be smaller?
  • Corona (glow balls) dont show under black color 0, 0, 0 [essentially this is unfixable, eAi 09:40, 4 March 2007 (CST)]
  • Coronas don't always disappear client-side when they are destroyed. [should be fixed eAi 15:28, 14 October 2006 (CDT)]
  • Coronas disappear when using setMarkerColor on them --Erorr404 00:08, 3 March 2007 (CST)
  • Checkpoints always have the same alpha --Erorr404 00:28, 3 March 2007 (CST)


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: 64
  • Checkpoints, Rings, Cylinders and Arrows combined: 32

You are able to create as many markers as you wish (memory permitting), but the player will only be able to see a limited number of them at once if you go over the limit.

Syntax

marker createMarker ( float x, float y, float z, [string type, int size, int r, int g, int b, int a] )

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

  • type: 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).

Returns

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

Example

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

addCommandHandler ( "createmarker", "consoleCreateMarker" )
-- 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

Example 2: Create a marker at the coordinates 0, 0, 20:

createMarker ( 0, 0, 20 )

See Also