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:
42
resources/[system]/runcode/runcode_sv.lua
Normal file
42
resources/[system]/runcode/runcode_sv.lua
Normal file
@@ -0,0 +1,42 @@
|
||||
function GetPrivs(source)
|
||||
return {
|
||||
canServer = IsPlayerAceAllowed(source, 'command.run'),
|
||||
canClient = IsPlayerAceAllowed(source, 'command.crun'),
|
||||
canSelf = IsPlayerAceAllowed(source, 'runcode.self'),
|
||||
}
|
||||
end
|
||||
|
||||
RegisterCommand('run', function(source, args, rawCommand)
|
||||
local res, err = RunCode('lua', rawCommand:sub(4))
|
||||
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)
|
||||
end, true)
|
||||
Reference in New Issue
Block a user