-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.lua
More file actions
76 lines (63 loc) · 2.69 KB
/
server.lua
File metadata and controls
76 lines (63 loc) · 2.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
local QBCore = exports['qb-core']:GetCoreObject()
local function DebugPrint(message)
if Config.debug then
print(message)
end
end
print('[pulsar-PEDMENU] Server script loaded')
-- Check if player is admin
local function IsPlayerAdmin(source)
DebugPrint('Checking permissions for source: ' .. source)
local identifiers = GetPlayerIdentifiers(source)
DebugPrint('Identifiers: ' .. json.encode(identifiers))
local aceCommandAll = IsPlayerAceAllowed(source, 'command')
local acePedmenu = IsPlayerAceAllowed(source, 'command.pedmenu')
DebugPrint('ACE command: ' .. tostring(aceCommandAll))
DebugPrint('ACE command.pedmenu: ' .. tostring(acePedmenu))
if aceCommandAll or acePedmenu then
DebugPrint('Permission granted via ACE')
return true
end
local Player = QBCore.Functions.GetPlayer(source)
if not Player then
DebugPrint('Player not found!')
return false
end
DebugPrint('Player found: ' .. Player.PlayerData.citizenid)
DebugPrint('PlayerData.permission: ' .. tostring(Player.PlayerData.permission))
DebugPrint('Groups to check: ' .. json.encode(Config.AdminGroups))
-- Method 1: Check Player.PlayerData.permission directly
if Player.PlayerData.permission then
DebugPrint('Permission found in PlayerData: ' .. Player.PlayerData.permission)
for _, group in ipairs(Config.AdminGroups) do
if Player.PlayerData.permission == group then
DebugPrint('Permission granted via PlayerData! Group: ' .. group)
return true
end
end
end
-- Method 2: Check using QBCore.Functions.HasPermission
for _, group in ipairs(Config.AdminGroups) do
DebugPrint('Checking group with HasPermission: ' .. group)
local hasPerm = QBCore.Functions.HasPermission(source, group)
DebugPrint('HasPermission result for ' .. group .. ': ' .. tostring(hasPerm))
if hasPerm then
DebugPrint('Permission granted for group: ' .. group)
return true
end
end
DebugPrint('No permission found')
return false
end
-- Event to open menu (with admin check)
RegisterNetEvent('pulsar-pedmenu:server:checkPermission', function()
local src = source
DebugPrint('Event checkPermission received from source: ' .. src)
if IsPlayerAdmin(src) then
DebugPrint('Permission OK - Opening menu')
TriggerClientEvent('pulsar-pedmenu:client:open', src)
else
DebugPrint('Permission DENIED')
TriggerClientEvent('QBCore:Notify', src, 'You do not have permission to use this command', 'error')
end
end)