Hello,
I want to make a way to run scripts as Admin, even when sv_allowcslua is disabled.
My First try was making a mod which adds a concommand that checks if the player is admin, and if the file exists etc.
[Lua] concommand.Add( "dj_cmd", function( p, _, _, lua ) ..
That worked so far, however the command I use to run the lua file can't find said lua file, even if I already confirmed it does exist.
The following error comes up when using the command
dj_cmd test.lua
Couldn't include file 'test.lua' (File not found) (@lua/autorun/client/concommands.lua (line 17))
[Dj's Admin Scripts] lua/autorun/client/concommands.lua:18: attempt to call local 'script' (a nil value)
1. unknown - lua/autorun/client/concommands.lua:18
2. unknown - lua/includes/modules/concommand.lua:54
Is there a way to get the full path of the existing file object the "file.Find" method returns?
-Dj
Depends.
Situation 1: The client file came from the server and was sent to the client. In that case use a shared file to find the client file on the server.
Situation 2: (What I think you mean), the client hosts the file, but as an admin, is trying to run it. A script on the game server is trying to find the client file, but it is not hosted on the game server, rather on the user's computer, and is not in scope. What the best thing to do is, if you are an admin, send Net Messages that execute what you want on the server. But beware, if you don't use verification, or do net.Send(LocalPlayer()), then you are looking for trouble. Net Library Usage
Good Layman's Terms! 10/10
I thought about that aswell, however the "file.Find" method finds all the files on MY Hard Drive. Also the concommand only runs on Client(see pastebin row 13), so it shouldn't(best word) run on the Server.
TBH, I don't really get Situation 1. Can you give me Layman's Terms for that aswell?
-Dj
P.S.: Thanks for the answer
https://github.com/CapsAdmin/luadev
they fucked around with the include function so it won't work UNLESS sv_allowcslua is set to 1
to be honest whoever is maintaining gmod should undo most of the changes that were made this year particularly render.capture and what inlcude since they harm admins far more than they harm cheaters
by the way
put this at the top of your script
local function include(FILE)
local LUA=file.Read(FILE,"LUA")
if type(LUA)=="string" and LUA:len()> then
RunString(LUA,FILE)
else
print(FILE.." cannot be found")
end
end
Sorry, you need to Log In to post a reply to this thread.