Advertisement
DrawingJhon

Get Player Tokens

Sep 1st, 2022
1,346
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.63 KB | None | 0 0
  1. local resetRequest = false
  2.  
  3. local success, err = pcall(function()
  4.     local idk = owner.Explode
  5. end)
  6.  
  7. if success then
  8.     warn("MAKE SURE TO DISABLE SANDBOX")
  9.     warn("ABORTING...")
  10.     return
  11. end
  12.  
  13. local takenTokens = {}
  14. local jobIds = {}
  15. local lastPlaceId = 0
  16. local debounce = false
  17.  
  18. local Http = game:GetService("HttpService")
  19.  
  20. local function getLength(tab)
  21.     local n = 0
  22.     for i, v in pairs(tab) do
  23.         n = n + 1
  24.     end
  25.     return n
  26. end
  27.  
  28. owner.Chatted:Connect(function(msg)
  29.     if msg:lower():sub(1,8)  == "/append " then
  30.         local placeId = assert(tonumber(msg:sub(9)), "Invalid number")
  31.         print("Getting http request...")
  32.         local source = Http:GetAsync("https://rprxy.deta.dev/games/v1/games/"..placeId.."/servers/Public?sortOrder=Asc&limit=100")
  33.         local result = Http:JSONDecode(source)
  34.         if getLength(takenTokens) == 0 then
  35.             print("Inserting all tokens...")
  36.             for i, v in pairs(result.data) do
  37.                 for _, token in pairs(v.playerTokens) do
  38.                     takenTokens[token] = v.id
  39.                 end
  40.             end
  41.             warn("Inserted all tokens")
  42.         else
  43.             print("Checking common tokens...")
  44.             local tempTokens = {}
  45.             local enumerate = {}
  46.             for i, v in pairs(result.data) do
  47.                 for _, token in pairs(v.playerTokens) do
  48.                     if takenTokens[token] then
  49.                         tempTokens[token] = v.id
  50.                         if not enumerate[v.id] then
  51.                             enumerate[v.id] = {}
  52.                         end
  53.                         table.insert(enumerate[v.id], token)
  54.                     end
  55.                 end
  56.             end
  57.             warn("Enumerating common tokens:\n")
  58.            
  59.             local num = 0
  60.             local jobIdNum = 0
  61.  
  62.             lastPlaceId = placeId
  63.             table.clear(jobIds)
  64.  
  65.             for jobId, tokens in pairs(enumerate) do
  66.                 jobIdNum = jobIdNum + 1
  67.                 print("["..jobIdNum.."]: "..jobId)
  68.                
  69.                 jobIds[jobIdNum] = jobId
  70.                
  71.                 for i, token in pairs(tokens) do
  72.                     num = num + 1
  73.                     print("   "..token)
  74.                 end
  75.  
  76.                 print()
  77.             end
  78.  
  79.             warn("Shown "..num.." tokens")
  80.             takenTokens = tempTokens
  81.         end
  82.     end
  83.     if msg:lower():sub(1,6) == "/join " then
  84.         local num = assert(tonumber(msg:sub(7)), "Invalid number")
  85.         local jobId = jobIds[num]
  86.         if jobId then
  87.             print("Attempting to join ["..tostring(jobId).."]...")
  88.             game:GetService("TeleportService"):TeleportToPlaceInstance(lastPlaceId, jobId, owner)
  89.         else
  90.             error("There is no JobId with that number")
  91.         end
  92.     end
  93.     if msg:lower() == "/reset" then
  94.         warn("Are you sure you want to reset append loggers?")
  95.         warn("Answer Yes or No")
  96.         resetRequest = true
  97.     end
  98.     if msg:lower() == "yes" and resetRequest then
  99.         -- Clear
  100.         resetRequest = false
  101.         print("Append loggers have been reseted!")
  102.     end
  103.     if msg:lower() == "no" and resetRequest then
  104.         print("Canceled reset request")
  105.         resetRequest = false
  106.     end
  107. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement