1
0
mirror of https://github.com/citizenfx/cfx-server-data.git synced 2025-01-11 08:25:08 +08:00
cfx-server-data/resources/[system]/runcode/runcode_sv.lua

42 lines
947 B
Lua
Raw Normal View History

function GetPrivs(source)
return {
canServer = IsPlayerAceAllowed(source, 'command.run'),
canClient = IsPlayerAceAllowed(source, 'command.crun'),
canSelf = IsPlayerAceAllowed(source, 'runcode.self'),
}
end
2017-09-05 17:58:39 +08:00
RegisterCommand('run', function(source, args, rawCommand)
local res, err = RunCode('lua', rawCommand:sub(4))
2017-09-05 17:58:39 +08:00
end, true)
RegisterCommand('crun', function(source, args, rawCommand)
if not source then
return
end
TriggerClientEvent('runcode:gotSnippet', source, -1, 'lua', rawCommand:sub(5))
end, true)
RegisterCommand('runcode', function(source, args, rawCommand)
if not source then
return
end
local df = LoadResourceFile(GetCurrentResourceName(), 'data.json')
local saveData = {}
if df then
saveData = json.decode(df)
end
local p = GetPrivs(source)
if not p.canServer and not p.canClient and not p.canSelf then
return
end
p.saveData = saveData
TriggerClientEvent('runcode:openUi', source, p)
2017-09-05 17:58:39 +08:00
end, true)