Jump to content

[Solved] Setting an element data to a marker


victormgons

Recommended Posts

Hi... I'm trying to set an ID to a marker. I set the ID in client-side, but I can't load in server-side.

Client-side:

  
id = 1 
mk1 = createMarker(x,y,z-1,"cylinder",3.5,0,255,0,170) 
setElementData(mk1,"ID",id) 

Server-side:

for _,mark in pairs(getElementsByType("marker")) do 
  if getElementData(mark,"ID") then 
    outputChatBox(ID,getRootElement()) 
  end 
end 

But it doesn't output nothing... But if I put all in client-side, or in server-side it works, but I need it like this...

Can anyone help me please?

Edited by Guest
Link to comment

Output is nothing because ID isn't defined. Use this code. It outputs marker id or false

  
for _,mark in pairs(getElementsByType("marker")) do 
  if getElementData(mark,"ID") then 
       outputChatBox(getElementData(mark,"ID"),getRootElement()) 
  else 
      outputChatBox(getElementData(mark,"ID"),getRootElement()) 
  end 
end 
  

Link to comment
for _,mark in pairs(getElementsByType("marker")) do 
  if getElementData(mark,"ID") then 
    outputChatBox(ID,getRootElement()) 
  end 
end 

You can't get the string "ID" inside getElementData without defining it

It won't solve the problem. He won't be able to get his client-side marker on the server.

Link to comment

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