..:D&G:.. Posted February 3, 2015 Share Posted February 3, 2015 Hello guys, I am trying to make a teleport script for a friend, but its the first time I try to put the locations for teleporting in a table and get the data from there, here is what I done: locations = { { "lsairport", 1881.33533, -2420.99878, 13.55469 }, } function teleportPlayer(player, cmd, location) local player = getLocalPlayer() if not tostring(location) then outputChatBox("[sYNTAXA] /teleport [locatie]", 255, 255, 0) return end location = string.lower(tostring(location)) for i, v in ipairs(locations) do if locations[ v[1] ] then setElementLocation(player, v[2], v[3], v[4]) outputChatBox("Te-ai teleportat cu succes la teleport-ul: "..v[1], 255, 255, 0) else outputChatBox("Alege o locatie din urmatoarele:", 255, 255, 0) for k, v in pairs(locations) do outputChatBox(k, 255, 255, 0) end end end end addCommandHandler("teleport", teleportPlayer) I want the players to type in /teleport, and if they haven't entered the name of the location, they should get the list of locations. And if they did /teleport lsairport then their location should be set to the one from the table, next to the location name. I don't get any errors but also it doesn't work.. Any ideas guys? Thanks. Link to comment
Tomas Posted February 3, 2015 Share Posted February 3, 2015 locations = { { "lsairport", 1881.33533, -2420.99878, 13.55469 }, } function teleportPlayer(cmd, location) local player = getLocalPlayer() if not tostring(location) then outputChatBox("[sYNTAXA] /teleport [locatie]", 255, 255, 0) return end location = string.lower(tostring(location)) for i, v in ipairs(locations) do if v[1] == location then setElementPosition(player, v[2], v[3], v[4]) outputChatBox("Te-ai teleportat cu succes la teleport-ul: "..v[1], 255, 255, 0) else outputChatBox("Alege o locatie din urmatoarele:", 255, 255, 0) for k, v in pairs(locations) do outputChatBox(v[1], 255, 255, 0) end end end end addCommandHandler("teleport", teleportPlayer) Link to comment
..:D&G:.. Posted February 3, 2015 Author Share Posted February 3, 2015 It works thanks. SOLVED! Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now