[b]THIS IS FOR GMOD13 ONLY![/b]
Ok so I posted this in waywo last night, have since improved it, and at this point I feel that it's good/stable enough to be released over here.
[B]What is it:[/B]
This is a script that overrides the include() function and adds two new console commands: "lua_fileload" and "lua_webload". Both the overridden include() function and the fileload command act exactly like their legit counter-parts, so your code will not need any modifications. It also auto executes everything inside the lua/autorun/client folder just like gmod used to do.
All in all, it pretty much keeps everything the same but allows you to run your clientside scripts on servers that have the "sv_allowcslua" convar set to 0.
[B]How to Use:[/B]
1) Stick the bellow code into a lua file somewhere [B][U]*OTHER*[/U][/B] than /autorun/client.
[lua]--Override Functions
function include(path, root)
if (root == nil or root == "LUA_PATH" ) then
path = "lua/"..path
root = "GAME"
elseif(root == "GAME") then
path = path
elseif(root == "DATA") then
path = "data/"..path
else
path = path
root = "GAME"
end
local test = CompileString(file.Read(path, root), path, false)
if (type(test) == "string") then
ErrorNoHalt("Error: "..test)
else
test()
end
print("Loaded: "..path)
end
function runWebFile(adress)
http.Fetch(adress, function(content)
RunString(content)
end)
print("Fetched From: "..adress)
end
--add con commands
concommand.Add("lua_webload", function(p,c,a)
runWebFile(a[1])
end)
--concommand.Remove("lua_openscript_cl")
function auto(command, args)
args = string.sub(args,2)
local files, dirs = file.Find("lua/"..args.."*", "GAME")
table.Add(dirs, files)
local commands = string.Explode("/", args)
local str = commands[table.Count(commands)]
table.foreach(dirs, function(key, value)
dirs[key] = command.." "..args..string.sub(value, string.len(str) + 1)
end)
return dirs
end
concommand.Add("lua_fileload", function(p,c,a) include(a[1]) end, auto)
--auto execute autorun folder
local ranFiles = {}
function autorun()
local files, directories = file.Find("lua/autorun/client/*.lua","GAME")
for i,v in pairs(files) do
if(!table.HasValue(ranFiles, v)) then
table.insert(ranFiles, v)
include("autorun/client/"..v)
end
end
if (table.Count(ranFiles) == table.Count(files)) then
timer.Stop("Retry")
end
end
timer.Create("Reatry", 0.5, 0, autorun)
--let user know were done
print("Finished Autorun.")
chat.AddText("Bypasses Loaded!")[/lua]
2) Add the following line to your autoexec.cfg file (if you don't have one, make it) and rename both #KEY# and #PATH# (keep the single quotes around the path) to whatever you want.
[code]bind #KEY# "lua_run_cl RunString(file.Read('#PATH#', LUA_PATH))"[/code]
3) Once you connect to a sever, hit the key that you put in above. The script will then load the overrides and run you'r autorun folder (Note: Anything that runs on the "Initiliaze" hook will not run).
4) To run any scripts just use the "lua_fileload" command just like you would use "lua_openscript_cl". It's fully predicted to!
I realize that this is a fairly basic tool and that anyone with a decent amount of lua knowledge could make something similar, but I figured I might as well save you folks some time by releasing my version. If you guys have any suggestions/bugs please post them here.
Edit: It appears that the lua plugin is writing the multi-digit numbers like it writes the single digit ones, with one number per line or something.
Didn't garry say he was going to block lua_run_cl if sv_allowcslua was set to 0 (or whichever value blocks running clientside lua)?
As of the next beta update lua_run_cl is blocked with sv_allowcslua 0, check the last update thread for garrys post if you want proof.
[QUOTE=Drakehawke;37622314]As of the next beta update lua_run_cl is blocked with sv_allowcslua 0, check the last update thread for garrys post if you want proof.[/QUOTE]
Well that's just completely retarded....
Why doesn't Garry just default SE to off? If servers want SE on, they can turn the server convar to 1.
[QUOTE=Fisheater;38209349]Why doesn't Garry just default SE to off? If servers want SE on, they can turn the server convar to 1.[/QUOTE]
Why don't servers who don't want SE on disable it?
Why would lua_run_cl ever work in the first place while sv_allowcslua is 0?
[QUOTE=JustSoFaded;38209848]Why would lua_run_cl ever work in the first place while sv_allowcslua is 0?[/QUOTE]
it was a bug in the beta
I know Garry is trying to prevent hacks and all, but now in most servers I can't use my custom huds.
[QUOTE=Fisheater;38210008]I know Garry is trying to prevent hacks and all, but now in most servers I can't use my custom huds.[/QUOTE]
So what you are saying is you bypassed SE to use custom huds ?
Or do you mean, back then where script enforcing was off by default you could use them without problems ?
The second item you said. I guess it's time for me to starting making more server-side addons.
Sorry, you need to Log In to post a reply to this thread.