Novetus_src/AddonLoader.lua

160 lines
4.5 KiB
Lua
Raw Normal View History

2022-07-08 01:12:47 +03:00
-- put script names here
Addons = {"Utils", "ShadersCompatibility", "ServerWhitelist"}
2022-07-08 01:12:47 +03:00
-- DONT EDIT ANYTHING ELSE BELOW
CoreScriptName = "AddonLoader"
ParentClient = "2009E"
ParentFunctionScript = "Server"
2022-07-08 01:12:47 +03:00
Scripts = {}
function AddScript(name)
table.insert(Scripts, name)
end
for i,v in pairs(Addons) do
local fullname = "rbxasset://..//..//..//addons//".. v ..".lua"
AddScript(fullname)
end
Modules = {}
for i,v in pairs(Scripts) do
2022-07-12 03:35:21 +03:00
local success, response = pcall(function() dofile(v) end)
if (not success) then
print("AddonLoader: Failed to load script: " .. response)
else
local success2, response2 = pcall(function() _G.CSScript_AddModule(Modules) end)
if (not success2) then
print("AddonLoader: Failed to add script module: " .. response2)
end
2022-07-12 03:35:21 +03:00
end
2022-07-08 01:12:47 +03:00
end
function PreInit(Script, Client)
ParentClient = Client
ParentFunctionScript = Script
2022-07-08 01:12:47 +03:00
for i,v in pairs(Modules) do
local enabled = true
local s, r = pcall(function() enabled = v:IsEnabled(Script, Client) end)
if (enabled) then
local success, response = pcall(function() v:PreInit(Script, Client) end)
if (not success and not string.find(response, CoreScriptName)) then
print("AddonLoader: Failed to call PreInit: " .. response)
end
end
2022-07-08 01:12:47 +03:00
end
end
function PostInit()
for i,v in pairs(Modules) do
local enabled = true
local s, r = pcall(function() enabled = v:IsEnabled(ParentFunctionScript, ParentClient) end)
if (enabled) then
local success, response = pcall(function() v:PostInit() end)
if (not success and not string.find(response, CoreScriptName)) then
print("AddonLoader: Failed to call PostInit: " .. response)
end
end
end
end
function Update()
for i,v in pairs(Modules) do
local enabled = true
local s, r = pcall(function() enabled = v:IsEnabled(ParentFunctionScript, ParentClient) end)
if (enabled) then
local success, response = pcall(function() v:Update() end)
if (not success and not string.find(response, CoreScriptName)) then
print("AddonLoader: Failed to call Update: " .. response)
end
end
2022-07-08 01:12:47 +03:00
end
end
function OnLoadCharacter(Player, Appearance)
for i,v in pairs(Modules) do
local enabled = true
local s, r = pcall(function() enabled = v:IsEnabled(ParentFunctionScript, ParentClient) end)
if (enabled) then
local success, response = pcall(function() v:OnLoadCharacter(Player, Appearance) end)
if (not success and not string.find(response, CoreScriptName)) then
print("AddonLoader: Failed to call OnLoadCharacter: " .. response)
end
end
2022-07-08 01:12:47 +03:00
end
end
function OnPlayerAdded(Player)
for i,v in pairs(Modules) do
local enabled = true
local s, r = pcall(function() enabled = v:IsEnabled(ParentFunctionScript, ParentClient) end)
if (enabled) then
local success, response = pcall(function() v:OnPlayerAdded(Player) end)
if (not success and not string.find(response, CoreScriptName)) then
print("AddonLoader: Failed to call OnPlayerAdded: " .. response)
end
end
2022-07-08 01:12:47 +03:00
end
end
function OnPlayerRemoved(Player)
for i,v in pairs(Modules) do
local enabled = true
local s, r = pcall(function() enabled = v:IsEnabled(ParentFunctionScript, ParentClient) end)
if (enabled) then
local success, response = pcall(function() v:OnPlayerRemoved(Player) end)
if (not success and not string.find(response, CoreScriptName)) then
print("AddonLoader: Failed to call OnPlayerRemoved: " .. response)
end
end
2022-07-08 01:12:47 +03:00
end
end
function OnPlayerKicked(Player, Reason)
for i,v in pairs(Modules) do
local enabled = true
local s, r = pcall(function() enabled = v:IsEnabled(ParentFunctionScript, ParentClient) end)
if (enabled) then
local success, response = pcall(function() v:OnPlayerKicked(Player, Reason) end)
if (not success and not string.find(response, CoreScriptName)) then
print("AddonLoader: Failed to call OnPlayerKicked: " .. response)
end
end
2022-07-08 01:12:47 +03:00
end
end
function OnPrePlayerKicked(Player, Reason)
for i,v in pairs(Modules) do
local enabled = true
local s, r = pcall(function() enabled = v:IsEnabled(ParentFunctionScript, ParentClient) end)
if (enabled) then
local success, response = pcall(function() v:OnPrePlayerKicked(Player, Reason) end)
if (not success and not string.find(response, CoreScriptName)) then
print("AddonLoader: Failed to call OnPrePlayerKicked: " .. response)
end
end
2022-07-08 01:12:47 +03:00
end
end
_G.CSScript_PreInit=PreInit
_G.CSScript_PostInit=PostInit
_G.CSScript_Update=Update
2022-07-08 01:12:47 +03:00
_G.CSScript_OnLoadCharacter=OnLoadCharacter
_G.CSScript_OnPlayerAdded=OnPlayerAdded
_G.CSScript_OnPlayerRemoved=OnPlayerRemoved
_G.CSScript_OnPlayerKicked=OnPlayerKicked
2022-09-20 01:21:50 +03:00
_G.CSScript_OnPrePlayerKicked=OnPrePlayerKicked