feat(privileges): add privilege management for admin mods
Implement privilege registration and access checking for SAM, ULX, and FAdmin admin mods. Provides: - Registration of bladw_warn privilege with supported admin mods - BladW.Warn.HasAccess() function to check player permissions - Fallback to IsAdmin() if no admin mod is detected
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
BladW = BladW or {}
|
||||
BladW.Warn = BladW.Warn or {}
|
||||
|
||||
-- le droit géré par l'admin mod (SAM / ULX / FAdmin)
|
||||
local PRIV = "bladw_warn"
|
||||
BladW.Warn.Privilege = PRIV
|
||||
|
||||
-- enregistre le droit dans l'admin mod présent
|
||||
local function Register()
|
||||
if sam and sam.permissions and sam.permissions.add then
|
||||
pcall(sam.permissions.add, PRIV, "BladW Warn", "admin")
|
||||
end
|
||||
if ULib and ULib.ucl and ULib.ucl.registerAccess then
|
||||
pcall(ULib.ucl.registerAccess, PRIV, "admin", "Gérer les warns BladW", "BladW")
|
||||
end
|
||||
if FAdmin and FAdmin.Access and FAdmin.Access.AddPrivilege then
|
||||
pcall(FAdmin.Access.AddPrivilege, PRIV, 2)
|
||||
end
|
||||
end
|
||||
|
||||
hook.Add("SAM.LoadPermissions", "BladW:WarnPriv", Register)
|
||||
hook.Add("InitPostEntity", "BladW:WarnPriv", Register)
|
||||
Register()
|
||||
|
||||
-- ce joueur peut-il gérer les warns ?
|
||||
function BladW.Warn.HasAccess(ply)
|
||||
if not IsValid(ply) then return false end
|
||||
|
||||
if sam and sam.player and sam.player.has_permission then
|
||||
return sam.player.has_permission(ply, PRIV)
|
||||
end
|
||||
if ULib and ULib.ucl and ULib.ucl.query then
|
||||
return ULib.ucl.query(ply, PRIV)
|
||||
end
|
||||
if FAdmin and FAdmin.Access and FAdmin.Access.PlayerHasPrivilege then
|
||||
return FAdmin.Access.PlayerHasPrivilege(ply, PRIV)
|
||||
end
|
||||
|
||||
return ply:IsAdmin()
|
||||
end
|
||||
Reference in New Issue
Block a user