Jump to content

Help in AclGroupAddObject


Recommended Posts

Hey all, i'm having problem with adding an Object to an ACL group, i don't know why but when i use aclGroupAddObject it always returns FALSE maybe my code is wrong..

P.S.: i added the group the the acl and the resource has admin rights.

here's the code:

  
-- Server Side Script 
function addToGroup(group) 
     
    group = aclGetGroup(group) 
    if not (group == false) and not (group == nil) then 
        account = getPlayerAccount(source) 
        if not isGuestAccount(account) then 
            name = getAccountName(account) 
            add = aclGroupAddObject(group, "user"..name) 
            if add then 
                outputChatBox("The object has been added successfully to the group",getRootElement(),0,255,0,true) 
                triggerClientEvent(source,"hideall",source) 
            else 
                outputChatBox("This object is already in the group",source,255,0,0,true) 
            end 
        else 
            outputChatBox("You have to be registered before",source,255,0,0,true) 
        end 
    else 
        outputChatBox("The group doesn't exist in the ACL group",source,255,0,0,true) 
    end 
     
end 
addEvent("addToGroup",true) 
addEventHandler("addToGroup",getRootElement(), addToGroup) 
  

  
-- Client Side Script 
addEventHandler("onClientGUIClick",getRootElement(), 
    function() 
        if source == GUIEditor.button[1] then 
            group = "V.I.P" 
            triggerServerEvent("addToGroup", getLocalPlayer(), group) 
        end 
    end 
) 
  

Link to comment

Try this one :

-- Server Side Script 
function addToGroup( group )    
    group = aclGetGroup( group ) 
    if group == false or group == nil then 
        error( "The value of the 'group' is nil or false !" ) 
    end 
    account = getPlayerAccount( source ) 
    if not isGuestAccount( account ) then 
        local name = getAccountName( account ) 
        local add = aclGroupAddObject( group, "user."..name ) 
        if add then 
            outputChatBox( "The object has been added successfully to the group", root, 0, 255, 0, true ) 
            triggerClientEvent( source, "hideall", source ) 
        else 
            outputChatBox( "This object is already in the group", source, 255, 0, 0, true ) 
        end 
    else 
        outputChatBox( "You have to be registered before", source, 255, 0, 0, true ) 
    end 
else 
    outputChatBox( "The group doesn't exist in the ACL group", source, 255, 0, 0, true ) 
end 
addEvent( "addToGroup", true ) 
addEventHandler( "addToGroup", root, addToGroup ) 

Link to comment
Try this one :
-- Server Side Script 
function addToGroup( group )    
    group = aclGetGroup( group ) 
    if group == false or group == nil then 
        error( "The value of the 'group' is nil or false !" ) 
    end 
    account = getPlayerAccount( source ) 
    if not isGuestAccount( account ) then 
        local name = getAccountName( account ) 
        local add = aclGroupAddObject( group, "user."..name ) 
        if add then 
            outputChatBox( "The object has been added successfully to the group", root, 0, 255, 0, true ) 
            triggerClientEvent( source, "hideall", source ) 
        else 
            outputChatBox( "This object is already in the group", source, 255, 0, 0, true ) 
        end 
    else 
        outputChatBox( "You have to be registered before", source, 255, 0, 0, true ) 
    end 
else 
    outputChatBox( "The group doesn't exist in the ACL group", source, 255, 0, 0, true ) 
end 
addEvent( "addToGroup", true ) 
addEventHandler( "addToGroup", root, addToGroup ) 

Thanks it's working :D but i don't understand what did you do?

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...