Bean666 Posted January 10, 2015 Share Posted January 10, 2015 i need help with the /ad command because all players can use it , i tried to use isObjectinACLGroup but i'd some problem with it . Code: function Announcement(thePlayer, commandName, ...) local players = getElementsByType("player") local playerName = getPlayerName ( thePlayer ) local chatContent = {...} for index, player in ipairs ( players ) do outputChatBox( "Announcement from " .. playerName.. ": " ..table.concat ( chatContent, " "), player, 255, 190, 105) end end addCommandHandler( "ad", Announcement ) Link to comment
xeon17 Posted January 10, 2015 Share Posted January 10, 2015 You can use this function local acls = { "Owner", "Developers", "Administators", "Moderators" , "Console" } function isAllownedPlayer(player) local account = getPlayerAccount(player) if (not account or isGuestAccount(account)) then return false end local accountName = getAccountName(account) for i, v in pairs ( acls ) do if ( isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( v ) ) ) then return true end end outputChatBox("#FFF000[sERVER]#FFFFFF You aren't an admin.", player, 255,255,255, true) return false end Link to comment
Bean666 Posted January 10, 2015 Author Share Posted January 10, 2015 Xeon , doesnt work for me.. it chats but still allows normal players to do the command . Link to comment
Mr_Moose Posted January 10, 2015 Share Posted January 10, 2015 "isObjectInACLGroup" requires many steps if used in a function called by a command handler, first argument is a player element which must be converted into an account object and then converted into a string. Try this: local accName = getAccountName ( getPlayerAccount ( client )) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" )) then -- Executed only for ACL group "Admin" end And make sure you replace "client" with the variable name of your player element and that the player is in the ACL group "Admin". Link to comment
xeon17 Posted January 10, 2015 Share Posted January 10, 2015 I'm sure my function is working , because i'm using this function long time. But you can try this too, addCommandHandler( "ad", Announcement,true) And later add the command "ad" in acl of admin acl , "command.ad" Link to comment
Anubhav Posted January 10, 2015 Share Posted January 10, 2015 local allowedGroups = { "Admin" } function isAllowed( player ) local acc = getPlayerAccount( player ) -- Check player's account if isGuestAccount( acc ) or not acc then -- See if it's a guest account or it's returning false return false -- Then return false end -- End the if statment local acc = getAccountName( acc ) -- Check player's account name for i, v in ipairs( allowedGroups ) do -- Loop through table if isObjectInACLGroup( "user."..acc, aclGetGroup( v ) ) then -- Check if he is in the group return true end end return false end function Announcement(thePlayer, commandName, ...) local players = getElementsByType("player") local playerName = getPlayerName ( thePlayer ) local chatContent = {...} if isAllowed( thePlayer ) ~= true then return end for index, player in ipairs ( players ) do outputChatBox( "Announcement from " .. playerName.. ": " ..table.concat ( chatContent, " "), player, 255, 190, 105) end end addCommandHandler( "ad", Announcement ) Explained ^ Link to comment
#DRAGON!FIRE Posted January 10, 2015 Share Posted January 10, 2015 addCommandHandler( "ad", function ( player, commandName, ... ) local pAccount = getPlayerAccount ( player ) if ( pAccount ) and ( not isGuestAccount ( pAccount ) ) then if ( isObjectInACLGroup ( "user."..getAccountName ( pAccount ), aclGetGroup ( "Admin" ) ) ) then -- your code end end end ) Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now