Jump to content

How to select coordinates from table?


Cronoss

Recommended Posts

I want to make a system like this but I don't know how to make it :/

createPickup(blabla) -- This marks where the entry is
createPickup(blabla)

addEventHandler("onPlayerPickupHit", getRootElement(), function()
    cancelEvent() --prevents the pickups disappear
end)

-------------------This is the important part
local pickups = {
{"interior shop", 123,123,123,567,567,567},
{"interior hospital", 123,123,123,567,567},
}

createMarker(blablabla) -- invisible marker in the same position of the pickups
createMarker(blablabla)

function teleportToInterior()
  local x,y,z = getElementPosition(source)
  -- i dont know how to make the system associates the player's position with the table data, if the position it's the same from the 3 first coordinates, then it will save that info and...
  teleportFunction(dataX, dataY,dataZ) --when the function recognizes where the player is, a function that teleport the player to the next coords is called
  

  
  
	

 

Link to comment
local coordinates = {
  {interiorName = "Test 1", interiorX = 1, interiorY = 1, interiorZ = 1},
  {interiorName = "Test 2", interiorX = 2, interiorY = 2, interiorZ = 2},
  }


function testCommand(thePlayer, command)
   teleportFunction(thePlayer, 1) -- it will teleport the player to the first coordinates from the table
end
addCommandHandler("tpi", testCommand)



function teleportFunction(theElement, interiorID)
  if isElement(theElement) and getElementType(theElement) == "player" then
     setElementPosition(theElement, coordinates[interiorID].interiorX, coordinates[interiorID].interiorY, coordinates[interiorID].interiorZ)
  end
end

-- interiorID will result in coordinates[1].interiorX, coordinates[1].interiorY, coordinates[1].interiorZ for example
-- there are only 2 coordinates in table so the interiorID must be 1 or 2

I hope this is what you want and I didn't made a mistake

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