Jump to content

Markers


Lloyd Logan

Recommended Posts

Posted

When someone enters a marker, you would use

onMarkerHit(themarkertheyentered)

But if I have many markers, how can I use this so that if they enter any of these markers, one event is triggered (onMarkerHit)

If you need an Intermediate scripter feel free to PM me as I will accept "almost" any job, STATUS: UNAVAILABLE

SCOTLAND, my hometown, and the Home of GTA!

Posted
Create a dummy element with createElement and set this elemenet as parent of your markers with setElementParent. Then define your onMarkerHit event handler attached to the dummy element.

Dummy element has to be a real element, or can be made up?

If you need an Intermediate scripter feel free to PM me as I will accept "almost" any job, STATUS: UNAVAILABLE

SCOTLAND, my hometown, and the Home of GTA!

Posted
Create a dummy element with createElement and set this elemenet as parent of your markers with setElementParent. Then define your onMarkerHit event handler attached to the dummy element.

Dummy element has to be a real element, or can be made up?

EDIT: Nevermind, I understand now thanks!

If you need an Intermediate scripter feel free to PM me as I will accept "almost" any job, STATUS: UNAVAILABLE

SCOTLAND, my hometown, and the Home of GTA!

Posted

Read the wiki page. What you make with that function won't be a real entity in the world, it will youst behave like an element.

Eg.:

local marker1, marker2 = createMarker ( ... ), createMarker ( ... ) 
local ele = createElement ( "markers" ) 
setElementParent ( marker1, ele ) 
setElementParent ( marker2, ele ) 
  
addEventHandler ( "onMarkerHit", ele, 
    function () 
        outputChatBox ( "hit" ) 
    end ) 

Edit: Great! You are welcome.

Owner of [HUN]Magyar Play Szerver 1.4, IP: 31.220.43.153:22003

Posted
Read the wiki page. What you make with that function won't be a real entity in the world, it will youst behave like an element.

Eg.:

local marker1, marker2 = createMarker ( ... ), createMarker ( ... ) 
local ele = createElement ( "markers" ) 
setElementParent ( marker1, ele ) 
setElementParent ( marker2, ele ) 
  
addEventHandler ( "onMarkerHit", ele, 
    function () 
        outputChatBox ( "hit" ) 
    end ) 

Edit: Great! You are welcome.

I have quite a number of markers, is there any easier way of doing

local marker1, marker2 = createMarker ( ... ), createMarker ( ... ) 
local ele = createElement ( "markers" ) 
setElementParent ( marker1, ele ) 
setElementParent ( marker2, ele ) 

If you need an Intermediate scripter feel free to PM me as I will accept "almost" any job, STATUS: UNAVAILABLE

SCOTLAND, my hometown, and the Home of GTA!

Posted

A loop?

local markers = { 
    createMarker ( ... ), 
    createMarker ( ... ), 
    createMarker ( ... ) 
} 
  
for i, v in ipairs ( markers ) do 
    setElementParent ( v, ele ) 
end 

Owner of [HUN]Magyar Play Szerver 1.4, IP: 31.220.43.153:22003

Posted
A loop?
local markers = { 
    createMarker ( ... ), 
    createMarker ( ... ), 
    createMarker ( ... ) 
} 
  
for i, v in ipairs ( markers ) do 
    setElementParent ( v, ele ) 
end 

Thank you!

A quick question,

what does;

for i, v in ipairs ( markers ) do 

mean?

If you need an Intermediate scripter feel free to PM me as I will accept "almost" any job, STATUS: UNAVAILABLE

SCOTLAND, my hometown, and the Home of GTA!

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...