From 06541d68975de247c44d33e2f1387e9c16190513 Mon Sep 17 00:00:00 2001 From: ChrisChrome Date: Tue, 20 Aug 2024 15:08:12 -0600 Subject: [PATCH] Update scripts --- RobloxScripts/Generic.lua | 47 ++++++++++++++++++++++++++++++++++ RobloxScripts/ParcelLoader.lua | 8 +++--- 2 files changed, 50 insertions(+), 5 deletions(-) create mode 100644 RobloxScripts/Generic.lua diff --git a/RobloxScripts/Generic.lua b/RobloxScripts/Generic.lua new file mode 100644 index 0000000..757b23f --- /dev/null +++ b/RobloxScripts/Generic.lua @@ -0,0 +1,47 @@ +local Players = game:GetService("Players") +local DataStoreService = game:GetService("DataStoreService") +local DataStore = DataStoreService:GetDataStore("bannedUsers") +local HttpService = game:GetService("HttpService") +local banMsg = "NOTICE\nYou have been banned from this game. If you believe this is a mistake, please contact the game owner." +local apiBase = "https://bans.kcadev.org/" + +-- Function to check the player's user ID on join +local function onPlayerAdded(player) + local userId = player.UserId + -- ask the api if the user id is banned, if it times out in 5 seconds, check the datastore, if they aren't in the datastore assume they aren't banned + local success, response = pcall(function() + return HttpService:GetAsync(apiBase .. "api/v1/check/" .. tostring(game.PlaceId) .. "/" .. tostring(userId), true) + end) + + local banned = false + local reason = "No reason provided" + + if success then + local data = HttpService:JSONDecode(response) + if data.banned then + banned = true + reason = data.reason + DataStore:SetAsync(userId, reason) + end + else + local success, response = pcall(function() + return DataStore:GetAsync(userId) + end) + + if success then + if response then + banned = true + reason = response + end + end + end + + -- Check if the user ID is in the bannedPlayers table + if banned then + local text = "\n" .. banMsg .. "\nReason: " .. reason; + player:Kick(text) + end +end + +-- Connect the function to the PlayerAdded event +Players.PlayerAdded:Connect(onPlayerAdded) \ No newline at end of file diff --git a/RobloxScripts/ParcelLoader.lua b/RobloxScripts/ParcelLoader.lua index 5265ab6..fe55e53 100644 --- a/RobloxScripts/ParcelLoader.lua +++ b/RobloxScripts/ParcelLoader.lua @@ -2,17 +2,15 @@ local Players = game:GetService("Players") local DataStoreService = game:GetService("DataStoreService") local DataStore = DataStoreService:GetDataStore("bannedUsers") local HttpService = game:GetService("HttpService") -local banMsg = "NOTICE\nYou have been banned from this experience." -local apiBase = "https://you.ban.api.example.com" -local placeId = game.PlaceId -local placeName = game:GetService("MarketplaceService"):GetProductInfo(placeId).Name +local banMsg = "NOTICE\nYou have been banned from this game. If you believe this is a mistake, please contact the game owner." +local apiBase = "https://bans.kcadev.org/" -- Function to check the player's user ID on join local function onPlayerAdded(player) local userId = player.UserId -- ask the api if the user id is banned, if it times out in 5 seconds, check the datastore, if they aren't in the datastore assume they aren't banned local success, response = pcall(function() - return HttpService:GetAsync(apiBase .. "api/v1/check/" .. placeId .. "/" .. userId, true) + return HttpService:GetAsync(apiBase .. "api/v1/check/" .. tostring(game.PlaceId) .. "/" .. tostring(userId), true) end) local banned = false