forked from MaDHouSe79/mh-adminzone
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbridge.lua
More file actions
77 lines (61 loc) · 2.29 KB
/
bridge.lua
File metadata and controls
77 lines (61 loc) · 2.29 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
77
-- Framework Bridge for QBCore and ESX compatibility
Framework = {}
if Config.Framework == 'qb' then
-- QBCore Framework
local QBCore = exports['qb-core']:GetCoreObject()
function Framework.GetPlayer(source)
return QBCore.Functions.GetPlayer(source)
end
function Framework.GetPlayerIdentifier(player)
return player.PlayerData.license
end
function Framework.GetPlayerName(player)
return player.PlayerData.charinfo.firstname .. ' ' .. player.PlayerData.charinfo.lastname
end
function Framework.HasPermission(source, permission)
return QBCore.Functions.HasPermission(source, permission) or IsPlayerAceAllowed(source, permission)
end
function Framework.RegisterCommand(name, help, args, argsrequired, callback, permission)
QBCore.Commands.Add(name, help, args, argsrequired, callback, permission)
end
function Framework.GetPlayers()
return QBCore.Functions.GetQBPlayers()
end
elseif Config.Framework == 'esx' then
-- ESX Framework
ESX = exports['es_extended']:getSharedObject()
function Framework.GetPlayer(source)
return ESX.GetPlayerFromId(source)
end
function Framework.GetPlayerIdentifier(player)
return player.identifier
end
function Framework.GetPlayerName(player)
return player.getName()
end
function Framework.HasPermission(source, permission)
local player = ESX.GetPlayerFromId(source)
if not player then return false end
-- Check if player has admin group
for _, group in ipairs(Config.AdminGroups) do
if player.getGroup() == group then
return true
end
end
-- Also check ACE permissions
return IsPlayerAceAllowed(source, permission)
end
function Framework.RegisterCommand(name, help, args, argsrequired, callback, permission)
ESX.RegisterCommand(name, permission, function(xPlayer, args, showError)
callback(xPlayer.source)
end, argsrequired, {
help = help,
arguments = args
})
end
function Framework.GetPlayers()
return ESX.GetExtendedPlayers()
end
else
print('^1[AdminZone] Invalid framework selected in config.lua. Please set Config.Framework to "qb" or "esx"^0')
end