From 8f4f63bfaa2e5f341ff4c2f9086646ebefe06408 Mon Sep 17 00:00:00 2001 From: Logan Gartner Date: Fri, 25 Mar 2022 23:46:18 -0600 Subject: [PATCH] Added more helper functions --- sv_lsft.txt | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/sv_lsft.txt b/sv_lsft.txt index 0e5d4e8..52d4984 100644 --- a/sv_lsft.txt +++ b/sv_lsft.txt @@ -270,6 +270,48 @@ function core:log(...) print(core.colors.logo, "[L-SFT] ", color, unpack(message)) end +function core:logConsole(...) + 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.colors.error + elseif loglevel == log.WARNING then color = core.colors.warn + elseif loglevel == log.INFO then color = core.colors.info + elseif loglevel == log.TEXT then color = core.colors.text + end + + printConsole(core.colors.logo, "[L-SFT] ", color, unpack(message)) +end + +-- Get's a player's entity by searching for it via an inputted string +function core:get_entity(ply) + if type(ply) == "Player" then + return ply + elseif ply == "^" then + return owner() + end + + local targets = find.playersByName(ply) + + if #targets == 0 or targets == nil then + core:log(log.ERROR, "No targets found!") + return nil + elseif #targets > 1 then + local list = "" + for i, v in pairs(target) do + list = list..v..", " + end + + list:sub(1, -2) + core:log(log.ERROR, "Muliple targets found! ("..list..")") + return nil + end + + return targets[1] +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)