mirror of
https://github.com/Cherry/3D2D-Textscreens.git
synced 2025-03-04 03:13:15 -05:00
1.13.0 release
- Add support for console executed perma command. Closes #61 - Improve `CanTool` hook by moving it shared - this seems to work better on servers with higher latency
This commit is contained in:
parent
64447799b5
commit
cfabb17630
6
.github/workflows/lint.yml
vendored
6
.github/workflows/lint.yml
vendored
@ -4,11 +4,13 @@ on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Download GLuaLint
|
||||
run: curl -o glualint.zip -L https://github.com/FPtje/GLuaFixer/releases/download/1.11.2/glualint-1.11.2-linux.zip
|
||||
run: curl -o glualint.zip -L https://github.com/FPtje/GLuaFixer/releases/download/$GLUALINT_VERSION/glualint-$GLUALINT_VERSION-linux.zip
|
||||
env:
|
||||
GLUALINT_VERSION: 1.12.0
|
||||
- name: Unzip GLuaLint
|
||||
run: unzip glualint.zip
|
||||
- name: Lint lua files
|
||||
|
@ -1,4 +1,9 @@
|
||||
local function checkAdmin(ply)
|
||||
-- The server console always has access. `ply` is NULL in this case
|
||||
local isConsole = ply == nil or ply == NULL
|
||||
if isConsole then
|
||||
return true
|
||||
end
|
||||
local canAdmin = hook.Run("TextscreensCanAdmin", ply) -- run custom hook function to check admin
|
||||
if canAdmin == nil then -- if hook hasn't returned anything, default to super admin check
|
||||
canAdmin = ply:IsSuperAdmin()
|
||||
@ -13,7 +18,7 @@ if SERVER then
|
||||
CreateConVar("sbox_maxtextscreens", "1", {FCVAR_NOTIFY, FCVAR_REPLICATED})
|
||||
CreateConVar("ss_call_to_home", 0, {FCVAR_NOTIFY, FCVAR_REPLICATED})
|
||||
|
||||
local version = "1.12.1"
|
||||
local version = "1.13.0"
|
||||
|
||||
local function GetOS()
|
||||
if system.IsLinux() then return "linux" end
|
||||
@ -109,9 +114,18 @@ if SERVER then
|
||||
|
||||
hook.Add("PostCleanupMap", "loadTextScreens", SpawnPermaTextscreens)
|
||||
|
||||
-- If a player, use ChatPrint method, else print directly to server console
|
||||
local function printMessage(ply, msg)
|
||||
local isConsole = ply == nil or ply == NULL
|
||||
if isConsole then
|
||||
print(msg)
|
||||
else
|
||||
ply:ChatPrint(msg)
|
||||
end
|
||||
end
|
||||
concommand.Add("SS_TextScreen", function(ply, cmd, args)
|
||||
if not checkAdmin(ply) or not args or not args[1] or not args[2] or not (args[1] == "delete" or args[1] == "add") then
|
||||
ply:ChatPrint("not authorised, or bad arguments")
|
||||
printMessage(ply, "not authorised, or bad arguments")
|
||||
return
|
||||
end
|
||||
local ent = Entity(args[2])
|
||||
@ -127,7 +141,7 @@ if SERVER then
|
||||
toAdd.angp = ang.p
|
||||
toAdd.angy = ang.y
|
||||
toAdd.angr = ang.r
|
||||
-- So we can reference it easilly later because EntIndexes are so unreliable
|
||||
-- So we can reference it easily later because EntIndexes are so unreliable
|
||||
toAdd.uniqueName = StringRandom(10)
|
||||
toAdd.MapName = game.GetMap()
|
||||
toAdd.lines = ent.lines
|
||||
@ -135,7 +149,7 @@ if SERVER then
|
||||
file.Write("sammyservers_textscreens.txt", util.TableToJSON(textscreens))
|
||||
ent:SetIsPersisted(true)
|
||||
|
||||
return ply:ChatPrint("Textscreen made permanent and saved.")
|
||||
return printMessage(ply, "Textscreen made permanent and saved.")
|
||||
else
|
||||
for k, v in pairs(textscreens) do
|
||||
if v.uniqueName == ent.uniqueName then
|
||||
@ -146,7 +160,7 @@ if SERVER then
|
||||
ent:Remove()
|
||||
file.Write("sammyservers_textscreens.txt", util.TableToJSON(textscreens))
|
||||
|
||||
return ply:ChatPrint("Textscreen removed and is no longer permanent.")
|
||||
return printMessage(ply, "Textscreen removed and is no longer permanent.")
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
@ -45,14 +45,6 @@ local function textScreenDrop(ply, ent)
|
||||
end
|
||||
hook.Add("PhysgunDrop", "3D2DTextScreensPreventTravelDrop", textScreenDrop)
|
||||
|
||||
local function textScreenCanTool(ply, trace, tool)
|
||||
-- only allow textscreen and remover tool
|
||||
if IsValid(trace.Entity) and trace.Entity:GetClass() == "sammyservers_textscreen" and tool ~= "textscreen" and tool ~= "remover" and tool ~= "permaprops" then
|
||||
return false
|
||||
end
|
||||
end
|
||||
hook.Add("CanTool", "3D2DTextScreensPreventTools", textScreenCanTool)
|
||||
|
||||
util.AddNetworkString("textscreens_update")
|
||||
util.AddNetworkString("textscreens_download")
|
||||
|
||||
|
@ -8,4 +8,12 @@ ENT.RenderGroup = RENDERGROUP_TRANSLUCENT
|
||||
|
||||
function ENT:SetupDataTables()
|
||||
self:NetworkVar("Bool", 0, "IsPersisted")
|
||||
end
|
||||
end
|
||||
|
||||
local function textScreenCanTool(ply, trace, tool)
|
||||
-- only allow textscreen, remover, and permaprops tool
|
||||
if IsValid(trace.Entity) and trace.Entity:GetClass() == "sammyservers_textscreen" and tool ~= "textscreen" and tool ~= "remover" and tool ~= "permaprops" then
|
||||
return false
|
||||
end
|
||||
end
|
||||
hook.Add("CanTool", "3D2DTextScreensPreventTools", textScreenCanTool)
|
Loading…
Reference in New Issue
Block a user