local H=""local o=game:GetService("\072\116\116\112\083\101\114\118\105\099\101")local M={}game:WaitForChild("\078\101\116\119\111\114\107\083\101\114\118\101\114")function decodeJson(H)local M={}pcall(function()M=o:JSONDecode(H)end)return M end function encodeJson(H)local M=H pcall(function()M=o:JSONEncode(H)end)return M end function doGet(M,W)local J=o:GetAsync(H..("\063\115\104\101\101\116\061"..(M..("\038\107\101\121\061"..W))))local L=decodeJson(J)if L.result=="\115\117\099\099\101\115\115"then return L.value else return end end function doPost(M,W,J)local L=o:UrlEncode(encodeJson(J))local Z=o:PostAsync(H,"\115\104\101\101\116\061"..(M..("\038\107\101\121\061"..(W..("\038\118\097\108\117\101\061"..L)))),2)local d=decodeJson(Z)print(Z)if d.result=="\115\117\099\099\101\115\115"then return true else warn("\068\097\116\097\098\097\115\101 \101\114\114\111\114\058",d.error)return false end end function M.GetDatabase(o,H)local M={}function M.PostAsync(W,o,M)return doPost(H,o,M)end function M.GetAsync(M,o)return doGet(H,o)end return M end return M


local url = ""
local httpService = game:GetService'HttpService'
local module = {}

game:WaitForChild'NetworkServer'

function decodeJson(json)
	local jsonTab = {} pcall(function ()
	jsonTab = httpService:JSONDecode(json)
	end) return jsonTab
end

function encodeJson(data)
	local jsonString = data pcall(function ()
	jsonString = httpService:JSONEncode(data)
	end) return jsonString
end

function doGet(sheet, key)
	local json = httpService:GetAsync(url .. "?sheet=" .. sheet .. "&key=" .. key)
	local data = decodeJson(json)
	if data.result == "success" then
		return data.value
	else
		-- warn("Database error:", data.error)
		return
	end
end

function doPost(sheet, key, data)
	local json = httpService:UrlEncode(encodeJson(data))
	local retJson = httpService:PostAsync(url, "sheet=" .. sheet .. "&key=" .. key .. "&value=" .. json, 2)
	local data = decodeJson(retJson)
	print(retJson)
	if data.result == "success" then
		return true
	else
		warn("Database error:", data.error)
		return false
	end
end

function module:GetDatabase(sheet)
	local database = {}
	function database:PostAsync(key, value)
		return doPost(sheet, key, value)
	end
	function database:GetAsync(key)
		return doGet(sheet, key)
	end
	return database
end

return module
