Added more helper functions
This commit is contained in:
parent
78c804b683
commit
8f4f63bfaa
1 changed files with 42 additions and 0 deletions
42
sv_lsft.txt
42
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)
|
||||
|
|
Loading…
Reference in a new issue