Jump to content

Command by ACL


Recommended Posts

I would like to know if it is possible to create a command to add or remove players from the ACL, for example, putting John in the police ACL.

Example:
/givePolice john
/give gang john
or take John off the ACL.

Example:
/removePolice john
/remove gang john


Briefly:
you type the command /givePolice john and the message "you added the player in the Police" will appear
or /removePolice and it will say "you removed the Police player"
Link to comment
function addPlayerToACLGroup(player,groupName)
    local account=getPlayerAccount(player);
    local group=aclGetGroup(groupName);
    if not(isGuestAccount(account))then
        if(group)then
            return aclGroupAddObject(group,"user."..getAccountName(account));
        end
    end
    return false
end

function removePlayerFromACLGroup(player,groupName)
    local account=getPlayerAccount(player);
    local group=aclGetGroup(groupName);
    if not(isGuestAccount(account))and(group)then
        local accountName=getAccountName(account);
        if(isObjectInACLGroup("user"..accountName,group))then
            return aclGroupRemoveObject(group,"user."..accountName);
        end
    end
    return false
end

addCommandHandler("givePolice",function(admin,_,playerName)
    if(hasObjectPermissionTo(admin,"general.ModifyOtherObjects"))then
        local player=getPlayerFromName(playerName);
        if(player)then
            addPlayerToACLGroup(player,"police");
        end
    end
end);

addCommandHandler("removePolice",function(admin,_,playerName)
    if(hasObjectPermissionTo(admin,"general.ModifyOtherObjects"))then
        local player=getPlayerFromName(playerName);
        if(player)then
            removePlayerFromACLGroup(player,"police");
        end
    end
end);

addCommandHandler("give",function(admin,_,groupName,playerName)
    if(hasObjectPermissionTo(admin,"general.ModifyOtherObjects"))then
        local group=aclGetGroup(groupName);
        local player=getPlayerFromName(playerName);
        if(group)and(player)then
            addPlayerToACLGroup(player,group);
        end
    end
end);

addCommandHandler("remove",function(admin,_,groupName,playerName)
    if(hasObjectPermissionTo(admin,"general.ModifyOtherObjects"))then
        local group=aclGetGroup(groupName);
        local player=getPlayerFromName(playerName);
        if(group)and(player)then
            removePlayerFromACLGroup(player,group);
        end
    end
end);

I haven't tried this, but it should work. By default it is made for administrators who can assign groups in the acl, by default it would be for the "Admin" group

Link to comment

Hello

you can create ACL Groups For Example "Police" then checks if his account in this group or not

local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) -- get his account name
if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Police" ) ) then

end

Cheers!

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...