mirror of
https://github.com/Cherry/3D2D-Textscreens.git
synced 2025-03-04 03:13:15 -05:00
Merge pull request #83 from Seef0x/main
This commit is contained in:
commit
40da7ae0eb
@ -29,6 +29,7 @@
|
||||
## Server owners
|
||||
* `sbox_maxtextscreens` controls the maximum amount of text screens that each player can spawn. This defaults to 1. This cvar only exists on the server, so make sure it's set via RCON, or in something like server.cfg.
|
||||
* `ss_enable_rainbow` controls whether players on your server can use the rainbow effect. Set this to `0` in your `server.cfg` to prevent anyone from using rainbow effects.
|
||||
* `ss_max_characters` controls whether players on your server can use a lot of characters per lines. Set this to `any number` in your `server.cfg` to prevent anyone from using more characters.
|
||||
* Set `ss_call_to_home 1` on your server to provide anonymous analytics including your operating system, version of the addon, and rough, anonymised geo-location. This is entirely optional and used solely to put a smile on my face.
|
||||
* To install this onto your server, follow the instructions [listed here](https://wiki.garrysmod.com/page/Workshop_for_Dedicated_Servers).
|
||||
|
||||
|
@ -14,6 +14,9 @@ end
|
||||
-- allow servers to disable rainbow effect for everyone
|
||||
CreateConVar("ss_enable_rainbow", 1, {FCVAR_NOTIFY, FCVAR_REPLICATED}, "Determines whether rainbow textscreens will render for all clients. When disabled, rainbow screens will render as solid white.", 0, 1)
|
||||
|
||||
-- allow servers to restrict the number of characters per line for everyone
|
||||
CreateConVar("ss_max_characters", 0, {FCVAR_NOTIFY, FCVAR_REPLICATED}, "Determines the maximum number of characters per line for all clients. When set to 0, the maximum number of characters is infinite.", 0)
|
||||
|
||||
if SERVER then
|
||||
AddCSLuaFile()
|
||||
AddCSLuaFile("textscreens_config.lua")
|
||||
|
@ -9,6 +9,7 @@ local sliders = {}
|
||||
local rainbowCheckboxes = {}
|
||||
local textscreenFonts = textscreenFonts
|
||||
local rainbow_enabled = cvars.Number("ss_enable_rainbow", 1)
|
||||
local max_characters = cvars.Number("ss_max_characters", 0)
|
||||
|
||||
for i = 1, 5 do
|
||||
TOOL.ClientConVar["text" .. i] = ""
|
||||
@ -79,9 +80,10 @@ function TOOL:LeftClick(tr)
|
||||
ply:AddCleanup("textscreens", textScreen)
|
||||
|
||||
for i = 1, 5 do
|
||||
local txt = self:GetClientInfo("text" .. i) or ""
|
||||
textScreen:SetLine(
|
||||
i, -- Line
|
||||
self:GetClientInfo("text" .. i) or "", -- text
|
||||
max_characters ~= 0 and string.Left(txt, max_characters) or txt, -- text
|
||||
Color( -- Color
|
||||
tonumber(self:GetClientInfo("r" .. i)) or 255,
|
||||
tonumber(self:GetClientInfo("g" .. i)) or 255,
|
||||
@ -106,9 +108,10 @@ function TOOL:RightClick(tr)
|
||||
|
||||
if (IsValid(TraceEnt) and traceEnt:GetClass() == "sammyservers_textscreen") then
|
||||
for i = 1, 5 do
|
||||
local txt = tostring(self:GetClientInfo("text" .. i))
|
||||
traceEnt:SetLine(
|
||||
i, -- Line
|
||||
tostring(self:GetClientInfo("text" .. i)), -- text
|
||||
max_characters ~= 0 and string.Left(txt, max_characters) or txt, -- text
|
||||
Color( -- Color
|
||||
tonumber(self:GetClientInfo("r" .. i)) or 255,
|
||||
tonumber(self:GetClientInfo("g" .. i)) or 255,
|
||||
@ -385,6 +388,12 @@ function TOOL.BuildCPanel(CPanel)
|
||||
labels[i]:SetText(textBox[i]:GetValue())
|
||||
end
|
||||
|
||||
if max_characters ~= 0 then
|
||||
textBox[i].AllowInput = function()
|
||||
if string.len(textBox[i]:GetValue()) >= max_characters then return true end
|
||||
end
|
||||
end
|
||||
|
||||
CPanel:AddItem(textBox[i])
|
||||
|
||||
labels[i] = CPanel:AddControl("Label", {
|
||||
|
Loading…
Reference in New Issue
Block a user