Novetus_src/defaultaddons/ServerWhitelist.lua

65 lines
1.6 KiB
Lua
Raw Normal View History

2022-08-02 23:51:21 +03:00
local this = {}
--https://www.tutorialspoint.com/how-to-search-for-an-item-in-a-lua-list
function Set(list)
local set = {}
for _, l in ipairs(list) do set[l] = true end
return set
end
-- DONT EDIT ANYTHING ELSE ABOVE
2022-08-06 22:33:14 +03:00
-- add player tripcodes here in quotes seperated by commas
2022-08-02 23:51:21 +03:00
local tripcodeList = Set {}
2022-08-09 03:01:23 +03:00
-- set this to true to enable the whitelist
local whitelistEnabled = false
2022-08-02 23:51:21 +03:00
-- DONT EDIT ANYTHING ELSE BELOW
function this:Name()
return "Server Whitelist"
end
function this:IsEnabled(Script, Client)
if (Script == "Server") then
return true
else
return false
2022-08-02 23:51:21 +03:00
end
end
function this:OnPlayerAdded(Player)
if (whitelistEnabled == true) then
2022-08-02 23:51:21 +03:00
local hasTripcode = false
for _,newVal in pairs(Player:children()) do
if (newVal.Name == "Tripcode") then
if (newVal.Value ~= "") then
hasTripcode = true
end
end
end
if (hasTripcode and tripcodeList[Player.Tripcode.Value]) then
print("Player '" .. Player.Name .. "' is in whitelist!")
else
print("Player '" .. Player.Name .. "' not in whitelist. Kicking.")
Server = game:GetService("NetworkServer")
for _,Child in pairs(Server:children()) do
name = "ServerReplicator|"..Player.Name.."|"..Player.userId.."|"..Player.AnonymousIdentifier.Value
if (Server:findFirstChild(name) ~= nil and Child.Name == name) then
--delayed to fix 2011 client crash
delay(0.3, function() Child:CloseConnection() print("Player '" .. Player.Name .. "' Kicked. Reason: Not in whitelist") end)
2022-08-02 23:51:21 +03:00
end
end
end
end
end
function AddModule(t)
print("AddonLoader: Adding " .. this:Name())
table.insert(t, this)
end
_G.CSScript_AddModule=AddModule