mirror of
https://github.com/citizenfx/cfx-server-data.git
synced 2025-12-12 06:14:09 +01:00
reorganize resource directories
This commit is contained in:
32
resources/[system]/runcode/runcode_shared.lua
Normal file
32
resources/[system]/runcode/runcode_shared.lua
Normal file
@@ -0,0 +1,32 @@
|
||||
local runners = {}
|
||||
|
||||
function runners.lua(arg)
|
||||
local code, err = load('return ' .. arg, '@runcode')
|
||||
|
||||
-- if failed, try without return
|
||||
if err then
|
||||
code, err = load(arg, '@runcode')
|
||||
end
|
||||
|
||||
if err then
|
||||
print(err)
|
||||
return nil, err
|
||||
end
|
||||
|
||||
local status, result = pcall(code)
|
||||
print(result)
|
||||
|
||||
if status then
|
||||
return result
|
||||
end
|
||||
|
||||
return nil, result
|
||||
end
|
||||
|
||||
function runners.js(arg)
|
||||
return table.unpack(exports[GetCurrentResourceName()]:runJS(arg))
|
||||
end
|
||||
|
||||
function RunCode(lang, str)
|
||||
return runners[lang](str)
|
||||
end
|
||||
Reference in New Issue
Block a user