Author Topic: [TUT] Creating a teleport marker  (Read 481 times)

0 Members and 0 Guests are viewing this topic.

Cream

  • Level 1
  • *
  • Posts: 1
  • Location: Kocaeli
    • View Profile
[TUT] Creating a teleport marker
« on: February 14, 2012, 09:31:02 pm »
First we need to create a marker.
Code: (Example Marker) [Select]
telemarker1 = createMarker ( x, y, z, "type", size, r, g, b, a )
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.
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).

Then, we need to add function:
Code: (Teleport) [Select]
function Teleport
    setElementPosition ( source, x, y, z, warp = true )
end
addEventHandler( "onMarkerHit", telemarker1, Teleport)
x: The x coordinate of the destination.
y: The y coordinate of the destination.
z: The z coordinate of the destination.
warp: teleports players, resetting any animations they were doing. Setting this to false preserves the current animation.

Now our script needs to look like this:
Code: (Example) [Select]
telemarker1 = createMarker ( -2596.625, 579.358, 15.626, "cylinder", 2.0, 255, 0, 0, 150 )

function Teleport
    setElementPosition ( source, 5540, 1020, 1240, false )
end
addEventHandler( "onMarkerHit", telemarker1, Teleport)
« Last Edit: February 14, 2012, 11:40:46 pm by V »

Share on Bluesky Share on Facebook


V

  • Server Owner
  • Level 3
  • ***
  • Posts: 76
    • View Profile
Re: [TUT] Creating a teleport marker
« Reply #1 on: February 14, 2012, 11:40:26 pm »
thank you for this useful tuttorial!