Initial commit
This commit is contained in:
commit
1b1621aedf
6 changed files with 278 additions and 0 deletions
10
LICENSE
Normal file
10
LICENSE
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2021 Logan Gartner
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
3
README.md
Normal file
3
README.md
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
# Logan's Starfall Toolkit
|
||||||
|
The spiritual successor to Not Admin Utilities.
|
||||||
|
A modular psuedoadmin utility for Garry's Mod servers with StarfallEx.
|
47
cl_lsft.txt
Normal file
47
cl_lsft.txt
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
--@name Logan's Starfall Toolkit
|
||||||
|
--@author logan2611
|
||||||
|
--@client
|
||||||
|
--@includedir lsft/modules/client
|
||||||
|
--@includedir lsft/modules/shared
|
||||||
|
|
||||||
|
--[[
|
||||||
|
_ ____ _____ _____
|
||||||
|
| | / ___|| ___|_ _|
|
||||||
|
| | _____ \___ \| |_ | |
|
||||||
|
| |___ |_____| ___) | _| | |
|
||||||
|
|_____| |____/|_| |_|
|
||||||
|
|
||||||
|
--]]
|
||||||
|
|
||||||
|
--[[
|
||||||
|
TODO: Literally everything
|
||||||
|
TODO: Update checker
|
||||||
|
TODO: On module load, grab default config values. Write changed values
|
||||||
|
prop.createSent(chip():getPos()+Vector(0,0,90),Angle(0,0,0),"Seat_Airboat",true)
|
||||||
|
--]]
|
||||||
|
|
||||||
|
if player() == owner() then
|
||||||
|
if not file.exists("lsftconf.txt") then
|
||||||
|
file.write("lsftconf.txt", "{}")
|
||||||
|
config = "{}"
|
||||||
|
else
|
||||||
|
config = file.read("lsftconf.txt")
|
||||||
|
end
|
||||||
|
|
||||||
|
net.start("LSFT-Config-Read")
|
||||||
|
net.writeStream(config)
|
||||||
|
net.send()
|
||||||
|
|
||||||
|
net.start("LSFT-Get-Config")
|
||||||
|
net.writeString("hello there!")
|
||||||
|
net.send()
|
||||||
|
|
||||||
|
net.receive("LSFT-Config-Write", function(data)
|
||||||
|
print("Got net message to write config, waiting for stream...")
|
||||||
|
net.readStream(function(data)
|
||||||
|
print("Stream finished, writing")
|
||||||
|
file.write("lsftconf.txt", data)
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
10
modules/server/hello.txt
Normal file
10
modules/server/hello.txt
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
--@name
|
||||||
|
--@author
|
||||||
|
--@server
|
||||||
|
|
||||||
|
core.modules.hello = {
|
||||||
|
version = 69420,
|
||||||
|
commands = {
|
||||||
|
helloworld = function() print("hi") end,
|
||||||
|
},
|
||||||
|
}
|
23
modules/server/serverinfo.txt
Normal file
23
modules/server/serverinfo.txt
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
--@name
|
||||||
|
--@author
|
||||||
|
--@server
|
||||||
|
|
||||||
|
do
|
||||||
|
function getServerInfo()
|
||||||
|
print(core.color_logo, "[L-SFT] ", core.color_text, "-------------------------")
|
||||||
|
print(core.color_logo, "[L-SFT] ", core.color_info, "Name: ", core.color_text, game.getHostname())
|
||||||
|
print(core.color_logo, "[L-SFT] ", core.color_info, "Players: ", core.color_text, #find.allPlayers().."/"..game.getMaxPlayers())
|
||||||
|
print(core.color_logo, "[L-SFT] ", core.color_info, "Map: ", core.color_text, game.getMap())
|
||||||
|
print(core.color_logo, "[L-SFT] ", core.color_info, "Tickrate: ", core.color_text, math.round(1/game.getTickInterval()).." t/s")
|
||||||
|
print(core.color_logo, "[L-SFT] ", core.color_info, "Is Dedicated: ", core.color_text, game.isDedicated())
|
||||||
|
print(core.color_logo, "[L-SFT] ", core.color_text, "-------------------------")
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
core.modules.serverinfo = {
|
||||||
|
version = 1,
|
||||||
|
commands = {
|
||||||
|
serverinfo = getServerInfo,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
end
|
185
sv_lsft.txt
Normal file
185
sv_lsft.txt
Normal file
|
@ -0,0 +1,185 @@
|
||||||
|
--@name Logan's Starfall Toolkit
|
||||||
|
--@author logan2611
|
||||||
|
--@server
|
||||||
|
--@include lsft/cl_lsft.txt
|
||||||
|
--@includedir lsft/modules/server
|
||||||
|
--@includedir lsft/modules/shared
|
||||||
|
--@clientmain lsft/cl_lsft.txt
|
||||||
|
|
||||||
|
-- SPAWN THIS ONE
|
||||||
|
|
||||||
|
--[[
|
||||||
|
_ ____ _____ _____
|
||||||
|
| | / ___|| ___|_ _|
|
||||||
|
| | _____ \___ \| |_ | |
|
||||||
|
| |___ |_____| ___) | _| | |
|
||||||
|
|_____| |____/|_| |_|
|
||||||
|
|
||||||
|
--]]
|
||||||
|
|
||||||
|
--[[
|
||||||
|
TODO: Literally everything
|
||||||
|
TODO: Update checker
|
||||||
|
TODO: On module load, grab default config values. Write changed values
|
||||||
|
TODO: Client can request config values
|
||||||
|
prop.createSent(chip():getPos()+Vector(0,0,90),Angle(0,0,0),"Seat_Airboat",true)
|
||||||
|
--]]
|
||||||
|
|
||||||
|
--[[
|
||||||
|
hook.add("PlayerSay", "CommandCheck", function(ply, str)
|
||||||
|
if ply==owner() and string.find(str,"^!") then
|
||||||
|
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
--]]
|
||||||
|
|
||||||
|
-- Main Module (Mostly loading modules and stuff)
|
||||||
|
core = {}
|
||||||
|
|
||||||
|
core.modules = {
|
||||||
|
core = {
|
||||||
|
version = 0.1,
|
||||||
|
commands = {
|
||||||
|
help = function() print("hi") end,
|
||||||
|
colors = function() print(""..core:get_config("core","color_logo")) end,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
core.config = {}
|
||||||
|
core.defaultconfig = {
|
||||||
|
core = {
|
||||||
|
command_prefix = "!n",
|
||||||
|
color_logo = Color(255,200,50),
|
||||||
|
color_text = Color(200,200,200),
|
||||||
|
color_info = Color(50,150,255),
|
||||||
|
color_warning = Color(255,150,50),
|
||||||
|
color_error = Color(255,50,50)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
log = {
|
||||||
|
ERROR=0,
|
||||||
|
WARNING=1,
|
||||||
|
INFO=2,
|
||||||
|
TEXT=3
|
||||||
|
}
|
||||||
|
|
||||||
|
function core:init(config)
|
||||||
|
-- If the streamed config exists and has stuff in it, use it instead of the empty one
|
||||||
|
if config != nil and #config > 0 then
|
||||||
|
core.config = config
|
||||||
|
end
|
||||||
|
|
||||||
|
core:load_modules()
|
||||||
|
|
||||||
|
core.color_logo = core:get_config("core","color_logo")
|
||||||
|
core.color_text = core:get_config("core","color_text")
|
||||||
|
core.color_info = core:get_config("core","color_info")
|
||||||
|
core.color_warning = core:get_config("core","color_warning")
|
||||||
|
core.color_error = core:get_config("core","color_error")
|
||||||
|
|
||||||
|
core:log(log.INFO, "Loaded v"..core.modules.core.version.." successfully")
|
||||||
|
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
function core:get_config(...)
|
||||||
|
local args = {...}
|
||||||
|
|
||||||
|
local cur = core.config
|
||||||
|
for arg in pairs(args) do
|
||||||
|
for i,v in pairs(cur) do
|
||||||
|
if i == args[arg] then
|
||||||
|
if type(v) == "table" then
|
||||||
|
--cur = cur[i]
|
||||||
|
cur = v
|
||||||
|
continue
|
||||||
|
else
|
||||||
|
return v
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local cur = core.defaultconfig
|
||||||
|
for arg in pairs(args) do
|
||||||
|
for i,v in pairs(cur) do
|
||||||
|
if i == args[arg] then
|
||||||
|
if type(v) == "table" then
|
||||||
|
--cur = cur[i]
|
||||||
|
cur = v
|
||||||
|
continue
|
||||||
|
else
|
||||||
|
return v
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
error("Config value requested, but no current or default entry exists!")
|
||||||
|
end
|
||||||
|
|
||||||
|
function core:load_modules()
|
||||||
|
dodir("lsft/modules/server")
|
||||||
|
dodir("lsft/modules/shared")
|
||||||
|
|
||||||
|
hook.add("PlayerSay", "CommandCheck", function(ply, str)
|
||||||
|
local prefix = core:get_config("core","command_prefix")
|
||||||
|
if ply == owner() and string.find(str, "^"..prefix) then
|
||||||
|
local command = string.sub(string.explode(" ", str)[1], #prefix+1)
|
||||||
|
|
||||||
|
for i, v in pairs(core.modules) do
|
||||||
|
for commandin, commandfunc in pairs(v["commands"]) do
|
||||||
|
if command == commandin then
|
||||||
|
commandfunc()
|
||||||
|
return ""
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--print(core.color_logo, "[L-SFT] ", core.color_error, "Error: \""..command.."\" is not a valid command!")
|
||||||
|
core:log(log.ERROR, "\""..command.."\" is not a valid command!")
|
||||||
|
|
||||||
|
return ""
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function core:log(...)
|
||||||
|
local args = {...}
|
||||||
|
local loglevel = args[1]
|
||||||
|
local message = { unpack(args, 2, #args) }
|
||||||
|
local color = Color(0,0,0)
|
||||||
|
|
||||||
|
if loglevel == log.ERROR then color = core.color_error
|
||||||
|
elseif loglevel == log.WARNING then color = core.color_warning
|
||||||
|
elseif loglevel == log.INFO then color = core.color_info
|
||||||
|
elseif loglevel == log.TEXT then color = core.color_text
|
||||||
|
end
|
||||||
|
|
||||||
|
print(core.defaultconfig.core.color_logo, "[L-SFT] ", color, unpack(message))
|
||||||
|
end
|
||||||
|
|
||||||
|
net.receive("LSFT-Config-Read", function(len, ply)
|
||||||
|
if ply == owner() then
|
||||||
|
-- Colors settings aren't loaded yet, so use dumb printing method with default colors (Don't ever do this >:c)
|
||||||
|
--print(core.defaultconfig.core.color_logo, "[L-SFT] ", core.defaultconfig.core.color_info, "Downloading configuration: 0%")
|
||||||
|
|
||||||
|
timer.create("ConfigProgress", 0.25, 0, function()
|
||||||
|
print(core.defaultconfig.core.color_logo, "[L-SFT] ", core.defaultconfig.core.color_info, "Downloading configuration: ", math.round(net.getStreamProgress() * 100, 2), "%")
|
||||||
|
end)
|
||||||
|
|
||||||
|
net.readStream(function(data)
|
||||||
|
timer.remove("ConfigProgress")
|
||||||
|
core:init(json.decode(data))
|
||||||
|
end)
|
||||||
|
else
|
||||||
|
print(core.defaultconfig.core.color_logo, "[L-SFT] ", core.defaultconfig.core.color_error, ply:getName().." is trying to give us a config")
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
net.receive("LSFT-Get-Config", function()
|
||||||
|
|
||||||
|
core:getConfig(unpack(net.readTable()))
|
||||||
|
end)
|
Loading…
Reference in a new issue