From 7418b53f7b2c8bad7520ec9ee6ffdebde47fc7d8 Mon Sep 17 00:00:00 2001 From: Logan Gartner Date: Fri, 25 Mar 2022 23:42:42 -0600 Subject: [PATCH] Added admin module (blind, jail, strip, etc) --- modules/client/cl_admin.txt | 26 ++++ modules/server/sv_admin.txt | 293 ++++++++++++++++++++++++++++++++++++ 2 files changed, 319 insertions(+) create mode 100644 modules/client/cl_admin.txt create mode 100644 modules/server/sv_admin.txt diff --git a/modules/client/cl_admin.txt b/modules/client/cl_admin.txt new file mode 100644 index 0000000..ca9703f --- /dev/null +++ b/modules/client/cl_admin.txt @@ -0,0 +1,26 @@ +--@name +--@author +--@client + +do + blind = nil + + net.receive("LSFT-SBlind", function() + if net.readEntity() == player() then + if holograms.canSpawn() then + --print(holograms.hologramsLeft()) + blind = holograms.create(eyePos()-Vector(0,0,45), Angle(0,0,0), "models/holograms/hq_sphere.mdl", Vector(-5,5,5)) + blind:setParent(player(), player():lookupAttachment("chest")) + blind:setColor(Color(0,0,0)) + blind:suppressEngineLighting(true) + end + end + end) + + net.receive("LSFT-SUnblind", function() + if net.readEntity() == player() and blind ~= nil then + blind:remove() + blind = nil + end + end) +end \ No newline at end of file diff --git a/modules/server/sv_admin.txt b/modules/server/sv_admin.txt new file mode 100644 index 0000000..616dc87 --- /dev/null +++ b/modules/server/sv_admin.txt @@ -0,0 +1,293 @@ +--@name +--@author +--@server + +--[[ +TODO: Check if serverside hologram is there every n seconds and if not recreate it +TODO: Cloak(?), Slay (with multiple damage methods), Slap & Whip (with multiple damage methods), Freeze, Pseudogod, Ignite +--]] + +do + local players = {} + for i,v in pairs(find.allPlayers()) do + players[v] = {} + end + + -- Blind + + local function unblind(args) + local target = core:get_entity(args[1]) + if target == nil then + return + end + + if players[target].blind ~= nil then + players[target].blind:remove() + players[target].blind = nil + core:log(log.INFO, target:getName().." has been unblinded!") + else + core:log(log.ERROR, target:getName().." wasn't blinded!") + end + end + + local function unsblind(args) + local target = core:get_entity(args[1]) + if target == nil then + return + end + + net.start("LSFT-SUnblind") + net.writeEntity(target) + net.send() + -- Just gonna do some blind faith here, lazy + core:log(log.INFO, target:getName().." has been unblinded!") + end + + local function blind(args) + local target = core:get_entity(args[1]) + if target == nil then + return + end + + if players[target].blind ~= nil then + core:log(log.ERROR, target:getName().." is already blinded!") + return + end + + if holograms.canSpawn() then + --print(holograms.hologramsLeft()) + players[target].blind = holograms.create(target:getEyePos(), Angle(0,0,0), "models/holograms/hq_sphere.mdl", Vector(-5,5,5)) + players[target].blind:setParent(target, "chest") + players[target].blind:setColor(Color(0,0,0)) + players[target].blind:suppressEngineLighting(true) + + if args[2] ~= nil and tonumber(args[2]) > 0 then + timer.simple(tonumber(args[2]), function() + unblind({target}) + end) + end + + core:log(log.INFO, target:getName().." has been blinded "..((args[2] ~= nil and tonumber(args[2]) > 0) and "for "..tonumber(args[2]).." seconds!" or "indefinitely!")) + else + core:log(log.ERROR, target:getName().." could not be blinded!") + end + end + + local function sblind(args) + local target = core:get_entity(args[1]) + if target == nil then + return + end + + if args[2] ~= nil and tonumber(args[2]) > 0 then + timer.simple(tonumber(args[2]), function() + unsblind({target}) + end) + end + + net.start("LSFT-SBlind") + net.writeEntity(target) + net.send() + core:log(log.INFO, target:getName().." has been silently blinded "..((args[2] ~= nil and tonumber(args[2]) > 0) and "for "..tonumber(args[2]).." seconds!" or "indefinitely!")) + end + + + -- Jail + + local function unjail(args) + local target = core:get_entity(args[1]) + if target == nil then + return + end + + if timer.exists("Jail"..target:getSteamID64()) then + timer.remove("Jail"..target:getSteamID64()) + end + + if players[target].jail ~= nil then + if players[target].jail:isValid() then + players[target].jail:remove() + end + players[target].jail = nil + core:log(log.INFO, target:getName().." has been unjailed!") + else + core:log(log.ERROR, target:getName().." wasn't jailed!") + end + end + + local function jail(args) + local target = core:get_entity(args[1]) + if target == nil then + return + end + + if players[target].jail ~= nil then + core:log(log.ERROR, target:getName().." is already jailed!") + return + end + + local function createJail(target) + if prop.canSpawn() then + local jailprop = prop.create(target:getPos() + Vector(0,0,45), Angle(0,0,0), "models/hunter/misc/shell2x2.mdl", true) + --players[target].jail:setParent(target, "chest") + jailprop:setColor(Color(0,0,0,100)) + jailprop:setMaterial("models/debug/debugwhite") + jailprop:setMass(50000) + + return jailprop + end + end + + if prop.canSpawn() then + players[target].jail = createJail(target) + + timer.create("Jail"..target:getSteamID64(), 1, 0, function() + if not players[target].jail:isValid() then + players[target].jail = createJail(target) + core:log(log.WARNING, target:getName().."'s jail prop was removed! Correcting.") + end + if players[target].jail:isValid() and (target:getPos()+Vector(0,0,45)):getDistance(players[target].jail:getPos()) > 50 and not target:isNoclipped() then + players[target].jail:setPos(target:getPos()+Vector(0,0,45)) + end + end) + + if args[2] ~= nil and tonumber(args[2]) > 0 then + timer.simple(tonumber(args[2]), function() + unjail({target}) + end) + end + + core:log(log.INFO, target:getName().." has been jailed "..((args[2] ~= nil and tonumber(args[2]) > 0) and "for "..tonumber(args[2]).." seconds!" or "indefinitely!")) + else + core:log(log.ERROR, target:getName().." could not be jailed!") + end + end + + + -- Strip + + local function unstrip(args) + local target = core:get_entity(args[1]) + if target == nil then + return + end + + if players[target].strip ~= nil then + xpcall(hook.remove("tick", "Strip"..target:getSteamID64()), function() end) + + if players[target].strip:isValid() then + players[target].strip:remove() + end + + players[target].strip = nil + core:log(log.INFO, target:getName().." has been unstripped!") + else + core:log(log.ERROR, target:getName().." wasn't stripped!") + end + end + + local function strip(args) + local target = core:get_entity(args[1]) + if target == nil then + return + end + + if players[target].strip ~= nil then + core:log(log.ERROR, target:getName().." is already stripped!") + return + end + + -- Can probably make this it's own function outside of jail and strip + local function createStripJail(target) + if prop.canSpawn() then + local jailprop = prop.create(target:getPos() + Vector(0,0,45), Angle(0,0,0), "models/hunter/misc/sphere2x2.mdl", true) + --players[target].jail:setParent(target, "chest") + jailprop:setColor(Color(0,0,0,0)) + jailprop:setMaterial("models/debug/debugwhite") + jailprop:setMass(1) + jailprop:setNocollideAll(true) + + return jailprop + end + end + + if prop.canSpawn() then + players[target].strip = createStripJail(target) + + hook.add("tick", "Strip"..target:getSteamID64(), function() + if not players[target].strip:isValid() then + players[target].strip = createStripJail(target) + core:log(log.WARNING, target:getName().."'s strip prop was removed! Correcting.") + end + if players[target].strip:isValid() and not target:isNoclipped() then + players[target].strip:setPos(target:getPos()+Vector(0,0,45)) + end + end) + + if args[2] ~= nil and tonumber(args[2]) > 0 then + timer.simple(tonumber(args[2]), function() + unstrip({target}) + end) + end + + core:log(log.INFO, target:getName().." has been stripped "..((args[2] ~= nil and tonumber(args[2]) > 0) and "for "..tonumber(args[2]).." seconds!" or "indefinitely!")) + else + core:log(log.ERROR, target:getName().." could not be stripped!") + end + end + + + -- L-SFT Integration + + core.modules.admin = { + version = 1, + desc = "Provides pseudo-administrative functions.", + commands = { + --Blind + blind = { + usage = "blind [time]", + desc = "Prevents a player from seeing. Takes an optional amount of time in seconds.", + func = blind, + }, + unblind = { + usage = "unblind ", + desc = "Unblinds a blinded player.", + func = unblind, + }, + sblind = { + usage = "sblind [time]", + desc = "Prevents a player from seeing. Blinder is created clientside. Takes an optional amount of time in seconds.", + func = sblind, + }, + unsblind = { + usage = "unsblind ", + desc = "Unblinds a clientside blinded player.", + func = unsblind, + }, + + --Jail + jail = { + usage = "jail [time]", + desc = "Prevents a player from moving. Takes an optional amount of time in seconds.", + func = jail, + }, + unjail = { + usage = "unjail ", + desc = "Unjails a trapped player.", + func = unjail, + }, + + --Strip + strip = { + usage = "strip [time]", + desc = "Prevents a player from shooting. Takes an optional amount of time in seconds.", + func = strip, + }, + unstrip = { + usage = "unjail ", + desc = "Unstrips a stripped player.", + func = unstrip, + }, + }, + } +end \ No newline at end of file