--//--------// Variables \\--------\\--

local api				= {}

local httpService		= game:GetService("HttpService")
local url				= "http://myLink"

local tileUnlockTime	= 1800

local lastGroupUpdate	= tick()
local lastUpdate		= 0
local updateQueue		= {}

local dataReady			= false
local data	= {
	group	= {};
	player	= {};
	tile	= {};
}

local indexes = {
	group	= {
		N	= "Name";
		AC	= "Acronym";
		O	= "OwnerId";
		A	= "Allies";
		E	= "EmblemId";
		RW	= "RaidWins";
		RL	= "RaidLosses";
		DW	= "DefenseWins";
		DL	= "DefenseLosses";
		T	= "Tier";
		P	= "PrimaryColor";
		S	= "SecondaryColor";
	};
	player	= {
		N	= "Name";
		G	= "GroupId";
		B	= "Banned";
		K	= "Kills";
		D	= "Deaths";
		A	= "Assists";
		P	= "Primary";
		S	= "Secondary";
		GO	= "GunsOwned";
	};
	tile	= {
		C	= "Coordinate";
		D	= "DefenderId";
		R	= "RaiderId";
		S	= "Servers";
		P	= "Players";
		ST	= "Status";
		TL	= "TimeLocked";
		LP	= "LastPing";
		B	= "Biome";
	};
}

More code, not sure if needed

	if success then
			updateQueue		= {}
			data["group"]	= {}
			data["tile"]	= {}
			data["player"]	= {}
			
			for _,v in pairs(requestedData[1]) do
				table.insert(data["group"], filter("Decode", v, "group"))
			end
			for _,v in pairs(requestedData[2]) do
				table.insert(data["tile"], filter("Decode", v, "tile"))
			end
			if numPlayers > 0 then
				for i = 3, numPlayers + 2 do
					if type(requestedData[i]) == "table" then
						table.insert(data["player"], filter("Decode", requestedData[i], "player"))
					end
				end
			end
			
			for _,tile in pairs(data["tile"]) do
				if tile["LastPing"] ~= 0 and os.time() - tile["LastPing"] >= 90 then
					api:set("tile", tile["Id"], {Servers = 0, Players = 0, LastPing = 0, RaiderId = 0, Status = (tile["Status"] == "Raid" and "Peace" or tile["Status"])})
				end
				if tile["Status"] == "Locked" and os.time() - tile["TimeLocked"] >= tileUnlockTime then
					api:set("tile", tile["Id"], {Status = "Peace", TimeLocked = 0})
				end
			end
			
			dataReady = true
		else
			print("Request failed: "..error)
		end
	end
	
	if tick() - lastGroupUpdate >= 120 then
		lastGroupUpdate = tick()
		for _,group in pairs(data["group"]) do
			local registeredAllies = {}
			local emblem = game:GetService("GroupService"):GetGroupInfoAsync(group["Id"]).EmblemUrl
			emblem = tonumber(string.sub(emblem,(string.find(emblem, "=") + 1)))
			for _,rbxGroupInfo in pairs(game:GetService("GroupService"):GetAlliesAsync(group["Id"]):GetCurrentPage()) do
				for _,ally in pairs(data["group"]) do
					if rbxGroupInfo["Id"] == ally["Id"] then
						table.insert(registeredAllies, rbxGroupInfo.Id)
					end
				end
			end
			if emblem ~= group["EmblemId"] then
				api:set("group", group["Id"], {EmblemId = emblem})
			end
			
			if #registeredAllies ~= #group["Allies"] then
				api:set("group", group["Id"], {Allies = registeredAllies})
			else
				local needUpdate = false
				for _,v in pairs(registeredAllies) do
					local found = false
					for _,x in pairs(group["Allies"]) do
						found = (found or (x == v))
					end
					if not found then
						needUpdate = true
					end
				end
				if needUpdate then
					api:set("group", group["Id"], {Allies = registeredAllies})
				end
			end
		end
	end
end

--//--------// Miscellaneous \\--------\\--

api:update()
repeat wait() until dataReady

--//--------// Module Setup \\--------\\--

return api

I don't want to give away all my code, so if this isn't enough let me know.

2 comments

0

Your question doesn't make any sense. What do you want to do?

0

I want to convert the group, player and tile indexes into a SQL database.