Skip to content

Commit

Permalink
0.3.0 (#36)
Browse files Browse the repository at this point in the history
* Add runString function
* Add VExtensions/tests to test E2 code through vex_test
* Add vex_version, which tells you the version on the server + The most recent release.
* Overhaul printGlobal, remove printglobal burstmax convar.
* Add burstManager_sh in modules
* Add tests in modules/server
Closes #27
  • Loading branch information
Vurv78 authored Jan 24, 2021
1 parent b5a9238 commit 5aee6d4
Show file tree
Hide file tree
Showing 17 changed files with 477 additions and 223 deletions.
27 changes: 14 additions & 13 deletions lua/autorun/client/printglobal_cl.lua
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
-- PrintGlobal by Vurv (363590853140152321)

-- These are replicated from the server, so you cannot edit them but you can access their values.
CreateConVar("vex_printglobal_charmax_sv","350",FCVAR_REPLICATED,"The amount of chars that can be sent with the e2function printGlobal()",0,2000)
CreateConVar("vex_printglobal_argmax_sv","50",FCVAR_REPLICATED,"The amount of arguments that can be sent with the e2function printGlobal()",0,255)
CreateConVar("vex_printglobal_burst_sv","4",FCVAR_REPLICATED,"How many times printGlobal can be used in a second.")
CreateConVar("vex_printglobal_charmax_sv","500",FCVAR_REPLICATED,"The amount of chars that can be sent with the e2function printGlobal()",0,2000)
CreateConVar("vex_printglobal_argmax_sv","100",FCVAR_REPLICATED,"The amount of arguments that can be sent with the e2function printGlobal()",0,255)
CreateClientConVar("vex_printglobal_enable_cl","1",true,true,"Allows players to print messages to your chat with expression2")

local CV_GlobalChat = CreateClientConVar("vex_printglobal_enable_cl","1",true,true,"Allows players to print messages to your chat with expression2")
local printf = vex.printf

local function warnClient(sender)
print(string.format("%s is printing to your chat with printGlobal.\nTo disable printGlobal for yourself, use the convar vex_printglobal_enable_cl and set it to 0",IsValid(sender) and sender:GetName() or "Unknown Player"))
printf("%s is printing to your chat with printGlobal.\nTo disable printGlobal for yourself, use the convar vex_printglobal_enable_cl and set it to 0",IsValid(sender) and sender:GetName() or "Unknown Player")
end

local readUInt = net.ReadUInt
local readString = net.ReadString

vex.net_Receive("printglobal", function()
-- We don't check the convar here, the server does that.
local sender = net.ReadEntity()
warnClient(sender)
local args = net.ReadInt(9)
if sender ~= LocalPlayer() then warnClient(sender) end
local result = {}
for I = 1,args do
table.insert(result,net.ReadColor())
table.insert(result,net.ReadString())
for I = 1,readUInt(9), 2 do
result[I] = Color( readUInt(8), readUInt(8), readUInt(8) )
result[I+1] = readString()
end
chat.AddText( unpack( result ) )
chat.AddText( unpack( result ) )
end)
File renamed without changes.
3 changes: 3 additions & 0 deletions lua/entities/gmod_wire_expression2/core/custom/cl_vexdocs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ desc("hideChatPly(en)","Hides the chat of the player given [e] with n as 1 or 0
desc("try(s)","Tries to run the given string as UDF. Returns a table with the first element being a number 1 or 0 stating whether it ran successfully, and the second element being either the error message or the return value of the given UDF function. Does not throw error if UDF is undefined. Like pcall")
desc("try(st)","Works like the try(s) function, but also allows to pass arguments to the function in the form of table, make sure UDF's first argument is of type table")

desc("runString(s)","Runs E2 code. Don't use this in any chat commands unless only you can use it or you make sure people don't run malicious things like concmd!")
desc("runString(sn)","runString(s), but if n is not 0, the script runs in safe mode, and if the script errors, will return the error string, else \"\"")

--[[
____ _ __ ______ __ __ __
/ __ \ _____ (_)____ / /_ / ____// /____ / /_ ____ _ / /
Expand Down
Loading

0 comments on commit 5aee6d4

Please sign in to comment.