مو مجرب
local ranksNumbers = {
{1,"Console","ConsoleData"},
{2,"Console2","Console2D"},
{3,"Admins","Admins29"},
}
function isRank(player,rank)
local playerAccount = getPlayerAccount ( player )
local groups = aclGetAccountGroups( playerAccount)
if not isGuestAccount ( playerAccount ) then
for i, v in ipairs(groups) do
local index = getIndexFromValue(v)
if index then
local otherIndex = getIndexFromValue(rank)
if (index <= otherIndex) then
status = true
return status
end
end
end
if (not status) then
return false
end
end
end
addCommandHandler("checkRank",
function(source)
local result = isRank(source,"Console2")
outputChatBox(tostring(result))
end
)
function getIndexFromValue(value)
for i, v in ipairs(ranksNumbers) do
if v[2] == value then
return v[1]
end
end
end
function aclGetAccountGroups ( account )
local acc = getAccountName ( account )
if ( not acc ) then return false end
local res = {}
acc = "user."..acc
local all = "user.*"
for ig, group in ipairs ( aclGroupList() ) do
for io, object in ipairs ( aclGroupListObjects ( group ) ) do
if ( ( acc == object ) or ( all == object ) ) then
table.insert ( res, aclGroupGetName ( group ) )
break
end
end
end
return res
end