Jump to content

[HELP] set Player ACL Group


Recommended Posts

function findPlayer( namepart ) 
    local player = getPlayerFromName( namepart ) 
    if player then 
        return player 
    end 
    for _,player in pairs( getElementsByType 'player' ) do 
        if string.find( string.gsub( getPlayerName( player ):lower( ),"#%x%x%x%x%x%x", "" ), namepart:lower( ), 1, true ) then 
            return player 
        end 
    end 
    return false 
end 
  
addCommandHandler('setacl',function(source,_,player,aclgroup)
    local find = findPlayer( player ) 
    if find then
    	local playerAccount = getPlayerAccount(player)
      	aclGroupAddObject (aclGetGroup(""..aclgroup..""), "user."..playerAccount)
    end
 end)
    	

 

Edited by Galactix
Link to comment
addCommandHandler('setacl',function(source,_,player,aclgroup)
    local find = findPlayer( player ) 
    if find then
    	local playerAccount = getPlayerAccount(player)
      	aclGroupAddObject (aclGetGroup(""..aclgroup..""), "user."..playerAccount)
      	outputChatBox("The account "..playerAccount.." has been successfully added to the "..aclgroup.." group!", player)
    end
 end)

 

Link to comment
addCommandHandler('setacl',function(source,_,player,aclgroup)
    local find = findPlayer( player ) 
    if find then
      	 local playerAccount = getPlayerAccount(find)
      	 local accName = getAccountName ( playerAccount )
    	 if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then  	 
      		 aclGroupAddObject (aclGetGroup(""..aclgroup..""), "user."..accName)
      		 outputChatBox("Your ACL group has been changed to "..aclgroup.."!", player)
        else
        	outputChatBox("You are not allowed to use this command!", player, 255,0,0)
        end
    end
 end)

 

Edited by Galactix
Link to comment
  1. function findPlayer( namepart )
  2. local player = getPlayerFromName( namepart )
  3. if player then
  4. return player
  5. end
  6. for _,player in pairs( getElementsByType 'player' ) do
  7. if string.find( string.gsub( getPlayerName( player ):lower( ),"#%x%x%x%x%x%x", "" ), namepart:lower( ), 1, true ) then
  8. return player
  9. end
  10. end
  11. return false
  12. end
  13.  
  14.  
  15. addCommandHandler('setacl',function(source,_,player,aclgroup)
  16. local find = findPlayer( player )
  17. if find then
  18. local playerAccount = getPlayerAccount(find)
  19. local accName = getAccountName ( playerAccount )
  20. if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then
  21. aclGroupAddObject (aclGetGroup(""..aclgroup..""), "user."..accName)
  22. outputChatBox("Your ACL group has been changed to "..aclgroup.."!", player)
  23. else
  24. outputChatBox("You are not allowed to use this command!", player, 255,0,0)
  25. end
  26. end
  27. end)

this script is not working :(

 

Link to comment
addCommandHandler('setacl',function(source,_,player,aclgroup)
    local find = findPlayer( player ) 
    if find then
      	 local playerAccount = getPlayerAccount(find)
      	 local accName = getAccountName ( playerAccount )
    	 if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Owner" ) ) then  	 
      		 aclGroupAddObject (aclGetGroup(""..aclgroup..""), "user."..accName)
      		 outputChatBox("Your ACL group has been changed to "..aclgroup.."!", source)
        else
        	outputChatBox("You are not allowed to use this command!", source, 255,0,0)
        end
    end
 end)

Also, make sure that the resource you are using has admin rights.

Edited by Galactix
Link to comment

ok wait!

the error :

[2018-07-09 22:39:33] SetAcl restarted successfully
[2018-07-09 22:39:36] WARNING: SetAcl\server.lua:2: Bad argument @ 'getPlayerFromName' [Expected string at argument 1, got nil]
[2018-07-09 22:39:36] ERROR: SetAcl\server.lua:7: attempt to index local 'namepart' (a nil value)

 

when use this script :
[2018-07-09 22:40:09] WARNING: SetAcl\server.lua:23: Bad argument @ 'outputChatBox' [Expected element at argument 2, got string 'MR_ThinkeR']

this is my server side:

 

 

function findPlayer( namepart ) 
    local player = getPlayerFromName( namepart ) 
    if player then 
        return player 
    end 
    for _,player in pairs( getElementsByType 'player' ) do 
        if string.find( string.gsub( getPlayerName( player ):lower( ),"#%x%x%x%x%x%x", "" ), namepart:lower( ), 1, true ) then 
            return player 
        end 
    end 
    return false 
end 
  
addCommandHandler('setacl',function(source,_,player,aclgroup)
    local find = findPlayer( player ) 
    if find then
           local playerAccount = getPlayerAccount(find)
           local accName = getAccountName ( playerAccount )
         if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then       
               aclGroupAddObject (aclGetGroup(""..aclgroup..""), "user."..accName)
               outputChatBox("Your ACL group has been changed to "..aclgroup.."!", player)
        else
            outputChatBox("You are not allowed to use this command!", player, 255,0,0)
        end
    end
 end)

Link to comment
function findPlayer( namepart ) 
    local player = getPlayerFromName( namepart ) 
    if player then 
        return player 
    end 
    for _,player in pairs( getElementsByType 'player' ) do 
        if string.find( string.gsub( getPlayerName( player ):lower( ),"#%x%x%x%x%x%x", "" ), namepart:lower( ), 1, true ) then 
            return player 
        end 
    end 
    return false 
end 
  
addCommandHandler('setacl',function(source,_,player,aclgroup)
    local find = findPlayer( player ) 
    if find then
           local playerAccount = getPlayerAccount(find)
           local accName = getAccountName ( playerAccount )
         if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then       
               aclGroupAddObject (aclGetGroup(""..aclgroup..""), "user."..accName)
               outputChatBox("Your ACL group has been changed to "..aclgroup.."!", find)
        else
            outputChatBox("You are not allowed to use this command!", source, 255,0,0)
        end
      else
      outputChatBox("Player not found!", source, 255,0,0)
    end
 end) 

 

Link to comment

now errors are :

[2018-07-09 22:51:24] WARNING: SetAcl\server.lua:2: Bad argument @ 'getPlayerFromName' [Expected string at argument 1, got nil]
[2018-07-09 22:51:24] ERROR: SetAcl\server.lua:7: attempt to index local 'namepart' (a nil value)

Link to comment
addCommandHandler('setskin',function(source,_,player,skinid)
    local find = findPlayer( player ) 
    if find then
           local playerAccount = getPlayerAccount(source)
           local accName = getAccountName ( playerAccount )
         if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then       
               setElementModel ( find, skinid )
               outputChatBox("Your skin was changed to "..skinid.." by the admin "..accName.."!", find)
        else
            outputChatBox("You are not allowed to use this command!", source, 255,0,0)
        end
      else
      outputChatBox("Player not found!", source, 255,0,0)
    end
 end) 

And you get the error because the player you want to change the ACL is not online.

 

Don't forget to add a little "Thanks" for the help

Edited by Galactix
  • Thanks 1
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...