Datastore + MySqli

Hai, I’m not sure if anyone has done this before.
But i was wondering if anyone knew anyways.

I am currently storing all bans in-game and on my website, in my MySQLi, and checking in-game, if they are banned.

And when doing so, i was wondering if it’s possible to make it work along side DataStores.
Meaning, if i ban using an in game gui, it bans both in a DataStore, and using my MySQLi.
Making a failsafe of some sort, if DataStore or my database goes down.

I’ve relied too much on DataStore before, and it wasn’t as stable as i thought. (Note the serveruri is not pointing to the exact location, for security purposes)

I checked around on google, and on the Devforum, and the closest I’ve found is something like this, but it’s still not combining Datastore and Http.

Summary
serveruri = 'https://newstargeted.com/'
http = game:GetService('HttpService')

function RemoveFromGame(Player)
	Player:Kick("You have been kicked for exploiting")
end

game.Players.PlayerAdded:connect(function(Player)
	local result = http:GetAsync(serveruri..Player.userId)
	print(result)
	local result = http:JSONDecode(result)
	
	if result["error"] then
		print(result["error"])
	elseif result["banned"] == "true" then
		RemoveFromGame(Player)
		print('Player "'..Player.Name..'" is banned and therefore removed from the game.')
	elseif result["banned"] == "false" then
		print('Player "'..Player.Name..'" is not banned.')
	else
		print('Unkown response')
	end
end)

while wait(10) do
	for _,Player in pairs (game.Players:GetPlayers()) do
		local result = http:GetAsync(serveruri..Player.userId)
		print(result)
		local result = http:JSONDecode(result)
		
		if result["error"] then
			print(result["error"])
		elseif result["banned"] == "true" then
			RemoveFromGame(Player)
			print('Player "'..Player.Name..'" is banned and therefore removed from the game.')
		elseif result["banned"] == "false" then
			print('Player "'..Player.Name..'" is not banned.')
		else
			print('Unkown response')
		end
	end
end
2 Likes

I really hope anyone could share some light on this.
I’m also trying to make it work so if i do Either chat command to ban, or a gui ban, with text input.

Hello.

Assuming that you have a website hooked up with your MySQLi database, you can make a POST request to your websites URL with a JSONEncoded table and pick it up on your website with a language like Python and add to your MySQLi database using a package like “sqlite”.

Reference HTTP Requests here.

Hopefully this helps, good luck :slightly_smiling_face: