Update scripts
This commit is contained in:
parent
93a54d53a0
commit
06541d6897
47
RobloxScripts/Generic.lua
Normal file
47
RobloxScripts/Generic.lua
Normal file
|
@ -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)
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue