Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function table.save( tbl,filename )
- local charS,charE = " ","\n"
- local file,err
- if not filename then
- file = { write = function( self,newstr ) self.str = self.str..newstr end, str = "" }
- charS,charE = ""
- elseif filename == true or filename == 1 then
- charS,charE,file = "","",io.tmpfile()
- else
- file,err = io.open( filename, "w" )
- if err then return _,err end
- end
- local tables,lookup = { tbl },{ [tbl] = 1 }
- file:write( "return {"..charE )
- for idx,t in ipairs( tables ) do
- if filename and filename ~= true and filename ~= 1 then
- file:write( "-- Table: {"..idx.."}"..charE )
- end
- file:write( "{"..charE )
- local thandled = {}
- for i,v in ipairs( t ) do
- thandled[i] = true
- if type( v ) ~= "userdata" then
- if type( v ) == "table" then
- if not lookup[v] then
- table.insert( tables, v )
- lookup[v] = #tables
- end
- file:write( charS.."{"..lookup[v].."},"..charE )
- elseif type( v ) == "function" then
- file:write( charS.."loadstring("..exportstring(string.dump( v )).."),"..charE )
- else
- local value = ( type( v ) == "string" and exportstring( v ) ) or tostring( v )
- file:write( charS..value..","..charE )
- end
- end
- end
- for i,v in pairs( t ) do
- if (not thandled[i]) and type( v ) ~= "userdata" then
- if type( i ) == "table" then
- if not lookup[i] then
- table.insert( tables,i )
- lookup[i] = #tables
- end
- file:write( charS.."[{"..lookup[i].."}]=" )
- else
- local index = ( type( i ) == "string" and "["..exportstring( i ).."]" ) or string.format( "[%d]",i )
- file:write( charS..index.."=" )
- end
- if type( v ) == "table" then
- if not lookup[v] then
- table.insert( tables,v )
- lookup[v] = #tables
- end
- file:write( "{"..lookup[v].."},"..charE )
- elseif type( v ) == "function" then
- file:write( "loadstring("..exportstring(string.dump( v )).."),"..charE )
- else
- local value = ( type( v ) == "string" and exportstring( v ) ) or tostring( v )
- file:write( value..","..charE )
- end
- end
- end
- file:write( "},"..charE )
- end
- file:write( "}" )
- if not filename then
- return file.str.."--|"
- elseif filename == true or filename == 1 then
- file:seek ( "set" )
- return file:read( "*a" ).."--|"
- else
- file:close()
- return 1
- end
- end
- --// The Load Function
- function table.load( sfile )
- if string.sub( sfile,-3,-1 ) == "" then
- tables,err = loadstring( sfile )
- else
- tables,err = loadfile( sfile )
- end
- if err then return _,err
- end
- tables = tables()
- for idx = 1,#tables do
- local tolinkv,tolinki = {},{}
- for i,v in pairs( tables[idx] ) do
- if type( v ) == "table" and tables[v[1]] then
- table.insert( tolinkv,{ i,tables[v[1]] } )
- end
- if type( i ) == "table" and tables[i[1]] then
- table.insert( tolinki,{ i,tables[i[1]] } )
- end
- end
- for _,v in ipairs( tolinkv ) do
- tables[idx][v[1]] = v[2]
- end
- for _,v in ipairs( tolinki ) do
- tables[idx][v[2]],tables[idx][v[]] = tables[idx][v[1]],nil
- end
- end
- return tables[1]
- end
- end
- --[[End of Load and Save Functions]]--
- t = {}
- local NPCID = 1
- function Tablez_OnTalk(Unit, event, player)
- if (player:IsInCombat() == true) then
- player:SendAreaTriggerMessage("You are in combat!")
- player:GossipComplete()
- else
- Unit:GossipCreateMenu(100, player, 0)
- Unit:GossipMenuAddItem(0, "Teleport Menu's!", 50, 0)
- Unit:GossipMenuAddItem(1, "Set Coordinates", 51, 0)
- Unit:GossipMenuAddItem(8, "Reset Coordinates", 997, 1)
- Unit:GossipMenuAddItem(7, "Nevermind", 999, 0)
- Unit:GossipSendMenu(player)
- end
- end
- function Tablez_OnSelect(Unit, event, player, id, intid, Code, pMisc)
- if type(t[tostring(player)]) ~= "table" then
- t[tostring(player)] = {}
- end
- local plrtable = t[tostring(player)
- if (intid == 5) then
- t[tostring(player)]["Mapid1"] = (tonumber(Code))
- player:SendAreaTriggerMessage("|cFFFF0000[Success!]:|rSet Mapid to "..Code.."!")
- Unit:GossipCreateMenu(6, player, 3)
- Unit:GossipMenuAddItem(4, "Set X for teleport 1", 10, 1)
- Unit:GossipMenuAddItem(4, "Nevermind", 999, 1)
- Unit:GossipSendMenu(player)
- end
- if (intid == 6) then
- t[tostring(player)]["Mapid2"] = (tonumber(Code))
- player:SendAreaTriggerMessage("|cFFFF0000[Success!]:|rSet Mapid to "..Code.."!")
- Unit:GossipCreateMenu(100, player, 4)
- Unit:GossipMenuAddItem(4, "Set X for teleport 2", 11, 1)
- Unit:GossipMenuAddItem(4, "Nevermind", 999, 1)
- Unit:GossipSendMenu(player)
- end
- if (intid == 7) then
- t[tostring(player)]["Mapid3"] = (tonumber(Code))
- player:SendAreaTriggerMessage("|cFFFF0000[Success!]:|rSet Mapid to "..Code.."!")
- Unit:GossipCreateMenu(100, player, 5)
- Unit:GossipMenuAddItem(4, "Set X for teleport 3", 12, 1)
- Unit:GossipMenuAddItem(4, "Nevermind", 999, 1)
- Unit:GossipSendMenu(player)
- end
- if (intid == 8) then
- t[tostring(player)]["Mapid4"] = (tonumber(Code))
- player:SendAreaTriggerMessage("|cFFFF0000[Success!]:|rSet Mapid to "..Code.."!")
- Unit:GossipCreateMenu(100, player, 6)
- Unit:GossipMenuAddItem(4, "Set X for teleport 4", 13, 1)
- Unit:GossipMenuAddItem(4, "Nevermind", 999, 1)
- Unit:GossipSendMenu(player)
- end
- if (intid == 9) then
- t[tostring(player)]["Mapid5"] = (tonumber(Code))
- player:SendAreaTriggerMessage("|cFFFF0000[Success!]:|rSet Mapid to "..Code.."!")
- Unit:GossipCreateMenu(100, player, 7)
- Unit:GossipMenuAddItem(4, "Set X for teleport 5", 14, 1)
- Unit:GossipMenuAddItem(4, "Nevermind", 999, 1)
- Unit:GossipSendMenu(player)
- end
- if (intid == 10) then
- t[tostring(player)]["x1"] = (tonumber(Code))
- player:SendAreaTriggerMessage("|cFFFF0000[Success!]:|rSet X axis to "..Code.."!")
- Unit:GossipCreateMenu(100, player, 8)
- Unit:GossipMenuAddItem(4, "Set Y for teleport 1", 15, 1)
- Unit:GossipMenuAddItem(4, "Nevermind", 999, 1)
- Unit:GossipSendMenu(player)
- end
- if (intid == 11) then
- t[tostring(player)]["x2"] = (tonumber(Code))
- player:SendAreaTriggerMessage("|cFFFF0000[Success!]:|rSet X axis to "..Code.."!")
- Unit:GossipCreateMenu(100, player, 9)
- Unit:GossipMenuAddItem(4, "Set Y for teleport 2", 16, 1)
- Unit:GossipMenuAddItem(4, "Nevermind", 999, 1)
- Unit:GossipSendMenu(player)
- end
- if (intid == 12) then
- t[tostring(player)]["x3"] = (tonumber(Code))
- player:SendAreaTriggerMessage("|cFFFF0000[Success!]:|rSet X axis to "..Code.."!")
- Unit:GossipCreateMenu(100, player, 10)
- Unit:GossipMenuAddItem(4, "Set Y for teleport 3", 17, 1)
- Unit:GossipMenuAddItem(4, "Nevermind", 999, 1)
- Unit:GossipSendMenu(player)
- end
- if (intid == 13) then
- t[tostring(player)]["x4"] = (tonumber(Code))
- player:SendAreaTriggerMessage("|cFFFF0000[Success!]:|rSet X axis to "..Code.."!")
- Unit:GossipCreateMenu(100, player, 11)
- Unit:GossipMenuAddItem(4, "Set Y for teleport 4", 18, 1)
- Unit:GossipMenuAddItem(4, "Nevermind", 999, 1)
- Unit:GossipSendMenu(player)
- end
- if (intid == 14) then
- t[tostring(player)]["x5"] = (tonumber(Code))
- player:SendAreaTriggerMessage("|cFFFF0000[Success!]:|rSet X axis to "..Code.."!")
- Unit:GossipCreateMenu(100, player, 12)
- Unit:GossipMenuAddItem(4, "Set Y for teleport 5", 19, 1)
- Unit:GossipMenuAddItem(4, "Nevermind", 999, 1)
- Unit:GossipSendMenu(player)
- end
- if (intid == 15) then
- t[tostring(player)]["y1"] = (tonumber(Code))
- player:SendAreaTriggerMessage("|cFFFF0000[Success!]:|rSet Y axis to "..Code.."!")
- Unit:GossipCreateMenu(100, player, 13)
- Unit:GossipMenuAddItem(4, "Set Z for teleport 1", 20, 1)
- Unit:GossipMenuAddItem(4, "Nevermind", 999, 1)
- Unit:GossipSendMenu(player)
- end
- if (intid == 16) then
- t[tostring(player)]["y2"] = (tonumber(Code))
- player:SendAreaTriggerMessage("|cFFFF0000[Success!]:|rSet Y axis to "..Code.."!")
- Unit:GossipCreateMenu(100, player, 14)
- Unit:GossipMenuAddItem(4, "Set Z for teleport 2", 21, 1)
- Unit:GossipMenuAddItem(4, "Nevermind", 999, 1)
- Unit:GossipSendMenu(player)
- end
- if (intid == 17) then
- t[tostring(player)]["y3"] = (tonumber(Code))
- player:SendAreaTriggerMessage("|cFFFF0000[Success!]:|rSet Y axis to "..Code.."!")
- Unit:GossipCreateMenu(100, player, 15)
- Unit:GossipMenuAddItem(4, "Set Z for teleport 3", 22, 1)
- Unit:GossipMenuAddItem(4, "Nevermind", 999, 1)
- Unit:GossipSendMenu(player)
- end
- if (intid == 18) then
- t[tostring(player)]["y4"] = (tonumber(Code))
- player:SendAreaTriggerMessage("|cFFFF0000[Success!]:|rSet Y axis to "..Code.."!")
- Unit:GossipCreateMenu(100, player, 16)
- Unit:GossipMenuAddItem(4, "Set Z for teleport 4", 23, 1)
- Unit:GossipMenuAddItem(4, "Nevermind", 999, 1)
- Unit:GossipSendMenu(player)
- end
- if (intid == 19) then
- t[tostring(player)]["y5"] = (tonumber(Code))
- player:SendAreaTriggerMessage("|cFFFF0000[Success!]:|rSet Y axis to "..Code.."!")
- Unit:GossipCreateMenu(100, player, 17)
- Unit:GossipMenuAddItem(4, "Set Z for teleport 5", 24, 1)
- Unit:GossipMenuAddItem(4, "Nevermind", 999, 1)
- Unit:GossipSendMenu(player)
- end
- if (intid == 20) then
- t[tostring(player)]["z1"] = (tonumber(Code))
- player:SendAreaTriggerMessage("|cFFFF0000[Success!]:|rSet Z axis to "..Code.."!")
- player:GossipComplete()
- end
- if (intid == 21) then
- t[tostring(player)]["z2"] = (tonumber(Code))
- player:SendAreaTriggerMessage("|cFFFF0000[Success!]:|rSet Z axis to "..Code.."!")
- player:GossipComplete()
- end
- if (intid == 22) then
- t[tostring(player)]["z3"] = (tonumber(Code))
- player:SendAreaTriggerMessage("|cFFFF0000[Success!]:|rSet Z axis to "..Code.."!")
- player:GossipComplete()
- end
- if (intid == 23) then
- t[tostring(player)]["z4"] = (tonumber(Code))
- player:SendAreaTriggerMessage("|cFFFF0000[Success!]:|rSet Z axis to "..Code.."!")
- player:GossipComplete()
- end
- if (intid == 24) then
- t[tostring(player)]["z5"] = (tonumber(Code))
- player:SendAreaTriggerMessage("|cFFFF0000[Success!]:|rSet Z axis to "..Code.."!")
- player:GossipComplete()
- end
- if (intid == 50) then
- Unit:GossipCreateMenu(100, player, 1)
- Unit:GossipMenuAddItem(4, "Teleport 1", 101, 0)
- Unit:GossipMenuAddItem(4, "Teleport 2", 102, 0)
- Unit:GossipMenuAddItem(4, "Teleport 3", 103, 0)
- Unit:GossipMenuAddItem(4, "Teleport 4", 104, 0)
- Unit:GossipMenuAddItem(4, "Teleport 5", 105, 0)
- Unit:GossipMenuAddItem(7, "Back", 998, 0)
- Unit:GossipSendMenu(player)
- end
- if (intid == 51) then
- Unit:GossipCreateMenu(100, player, 18)
- Unit:GossipMenuAddItem(4, "Teleport Coords 1", 53, 0)
- Unit:GossipMenuAddItem(4, "Teleport Coords 2", 54, 0)
- Unit:GossipMenuAddItem(4, "Teleport Coords 3", 55, 0)
- Unit:GossipMenuAddItem(4, "Teleport Coords 4", 56, 0)
- Unit:GossipMenuAddItem(4, "Teleport Coords 5", 57, 0)
- Unit:GossipSendMenu(player)
- end
- if (intid == 52) then
- Unit:GossipCreateMenu(100, player, 2)
- Unit:GossipMenuAddItem(4, "Mapid 1", 5, 1)
- Unit:GossipMenuAddItem(4, "Mapid 2", 6, 1)
- Unit:GossipMenuAddItem(4, "Mapid 3", 7, 1)
- Unit:GossipMenuAddItem(4, "Mapid 4", 8, 1)
- Unit:GossipMenuAddItem(4, "Mapid 5", 9, 1)
- Unit:GossipMenuAddItem(7, "Back", 998, 0)
- Unit:GossipSendMenu(player)
- end
- if (intid == 53) then
- Unit:GossipCreateMenu(100, player, 19)
- Unit:GossipMenuAddItem(4, "Mapid 1", 5, 1)
- Unit:GossipMenuAddItem(4, "Nevermind", 999, 1)
- Unit:GossipSendMenu(player)
- end
- if (intid == 54) then
- Unit:GossipCreateMenu(100, player, 20)
- Unit:GossipMenuAddItem(4, "Mapid 2", 6, 1)
- Unit:GossipMenuAddItem(4, "Nevermind", 999, 1)
- Unit:GossipSendMenu(player)
- end
- if (intid == 55) then
- Unit:GossipCreateMenu(100, player, 21)
- Unit:GossipMenuAddItem(4, "Mapid 3", 7, 1)
- Unit:GossipMenuAddItem(4, "Nevermind", 999, 1)
- Unit:GossipSendMenu(player)
- end
- if (intid == 56) then
- Unit:GossipCreateMenu(100, player, 22)
- Unit:GossipMenuAddItem(4, "Mapid 4", 8, 1)
- Unit:GossipMenuAddItem(4, "Nevermind", 999, 1)
- Unit:GossipSendMenu(player)
- end
- if (intid == 57) then
- Unit:GossipCreateMenu(100, player, 23)
- Unit:GossipMenuAddItem(4, "Mapid 5", 9, 1)
- Unit:GossipMenuAddItem(4, "Nevermind", 999, 1)
- Unit:GossipSendMenu(player)
- end
- if (intid == 997) and
- Code == "Yes" then
- t[tostring(player)] = nil
- player:SendAreaTriggerMessage("|cFFFF0000[Success!]: Coordinates Reset!")
- player:GossipComplete()
- elseif
- (intid == 11) and
- Code == "No" then
- player:GossipComplete()
- end
- if (intid == 101) and
- plrtable["z1"] ~= nil then
- player:Teleport(plrtable["Mapid1"], plrtable["x1"], plrtable["y1"], plrtable["z1"])
- player:GossipComplete()
- elseif
- (intid == 101) and
- plrtable["z1"] == nil then
- player:SendAreaTriggerMessage("|cFFFF0000[Failure!]: Please insert all of the data in the fields")
- player:GossipComplete()
- end
- if (intid == 102) and
- plrtable["z2"] ~= nil then
- player:Teleport(plrtable["Mapid2"], plrtable["x2"], plrtable["y2"], plrtable["z2"])
- player:GossipComplete()
- elseif
- (intid == 102) and
- plrtable["z2"] == nil then
- player:SendAreaTriggerMessage("|cFFFF0000[Failure!]: Please insert all of the data in the fields")
- player:GossipComplete()
- end
- if (intid == 103) and
- plrtable["z3"] ~= nil then
- player:Teleport(plrtable["Mapid3"], plrtable["x3"], plrtable["y3"], plrtable["z3"])
- player:GossipComplete()
- elseif
- (intid == 103) and
- plrtable["z3"] == nil then
- player:SendAreaTriggerMessage("|cFFFF0000[Failure!]: Please insert all of the data in the fields")
- player:GossipComplete()
- end
- if (intid == 104) and
- plrtable["z4"] ~= nil then
- player:Teleport(plrtable["Mapid4"], plrtable["x4"], plrtable["y4"], plrtable["z4"])
- player:GossipComplete()
- elseif
- (intid == 104) and
- plrtable["z4"] == nil then
- player:SendAreaTriggerMessage("|cFFFF0000[Failure!]: Please insert all of the data in the fields")
- player:GossipComplete()
- end
- if (intid == 105) and
- plrtable["z5"] ~= nil then
- player:Teleport(plrtable["Mapid5"], plrtable["x5"], plrtable["y5"], plrtable["z5"])
- player:GossipComplete()
- elseif
- (intid == 105) and
- plrtable["z5"] == nil then
- player:SendAreaTriggerMessage("|cFFFF0000[Failure!]: Please insert all of the data in the fields")
- player:GossipComplete()
- end
- if (intid == 998) then
- Unit:GossipCreateMenu(100, player, 0)
- Unit:GossipMenuAddItem(0, "Teleport Menu's!", 50, 0)
- Unit:GossipMenuAddItem(1, "Set Coordinates", 51, 0)
- Unit:GossipMenuAddItem(8, "Reset Coordinates", 997, 1)
- Unit:GossipMenuAddItem(7, "Nevermind", 999, 0)
- Unit:GossipSendMenu(player)
- end
- if (intid == 99) then
- player:GossipComplete()
- end
- end
- RegisterUnitGossipEvent(NPCID, 4, "Table_OnTalk")
- RegisterUnitGossipEvent(NPCID, 5, "Table_OnSelect")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement