61 lines
1.5 KiB
Plaintext
61 lines
1.5 KiB
Plaintext
-- @shared
|
|
|
|
local PERMISSIONS_BUILDER = PERMISSIONS_BUILDER or {}
|
|
|
|
if CLIENT then
|
|
PERMISSIONS_BUILDER.list = PERMISSIONS_BUILDER.list or {}
|
|
|
|
local function onPermissionsGained()
|
|
PERMISSIONS_BUILDER:onPermissionsGained()
|
|
|
|
net.start("onPermissionsGained")
|
|
net.send()
|
|
end
|
|
|
|
function PERMISSIONS_BUILDER:add(permission)
|
|
if not table.hasValue(self.list, permission) then
|
|
table.insert(self.list, permission)
|
|
end
|
|
end
|
|
|
|
function PERMISSIONS_BUILDER:build(description)
|
|
description = description or ""
|
|
|
|
local allPermissionsGained = true
|
|
for k, v in pairs(self.list) do
|
|
if not hasPermission(v) then
|
|
allPermissionsGained = false
|
|
break
|
|
end
|
|
end
|
|
|
|
if allPermissionsGained then
|
|
onPermissionsGained()
|
|
else
|
|
setupPermissionRequest(self.list, description, true)
|
|
|
|
hook.add("permissionrequest", "PERMISSIONS_BUILDER_permissionrequest", function()
|
|
if permissionRequestSatisfied() then
|
|
onPermissionsGained()
|
|
end
|
|
end)
|
|
end
|
|
end
|
|
|
|
-- STUB
|
|
|
|
function PERMISSIONS_BUILDER:onPermissionsGained()
|
|
end
|
|
else
|
|
net.receive("onPermissionsGained", function(len, ply)
|
|
PERMISSIONS_BUILDER:onPermissionsGained(ply)
|
|
end)
|
|
|
|
-- STUB
|
|
|
|
function PERMISSIONS_BUILDER:onPermissionsGained(ply)
|
|
end
|
|
end
|
|
|
|
return PERMISSIONS_BUILDER
|