Sparrow Posted January 6, 2012 Share Posted January 6, 2012 I do admin chat script hours ago, it work well but my problem is how set the text in admin chat showed only for admins (admin and moderators) I try but I fail, nothing won't work, what is the function needed for this? thanks Link to comment
Castillo Posted January 6, 2012 Share Posted January 6, 2012 Post your code, how do you expect us to help you if you don't. Link to comment
Sparrow Posted January 6, 2012 Author Share Posted January 6, 2012 this is it: function adminChat(thePlayer,_,...) local text = table.concat({...}, "") local name = getPlayerName(thePlayer) local accName = getAccountName (getPlayerAccount (thePlayer)) if (isObjectInACLGroup ("user." .. accName, aclGetGroup("Admin")) or isObjectInACLGroup ("user." .. accName, aclGetGroup ("SuperModerator")) or isObjectInACLGroup ("user." .. accName, aclGetGroup ("Moderator")) ) then outputChatBox ("#FF0000(Admin Chat) "..name..": #FFFFFF"..text, getRootElement(), 255, 255, 255, true) end end addCommandHandler("ac", adminChat) Link to comment
Castillo Posted January 6, 2012 Share Posted January 6, 2012 function adminChat(thePlayer,_,...) local text = table.concat({...}, " ") local name = getPlayerName(thePlayer) local accName = getAccountName (getPlayerAccount (thePlayer)) if ( isObjectInACLGroup ("user.".. accName, aclGetGroup("Admin")) or isObjectInACLGroup ("user." .. accName, aclGetGroup ("SuperModerator")) or isObjectInACLGroup ("user." .. accName, aclGetGroup ("Moderator")) ) then for index, player in ipairs(getElementsByType("player")) do local accName = getAccountName (getPlayerAccount (player)) if ( isObjectInACLGroup ("user." .. accName, aclGetGroup("Admin")) or isObjectInACLGroup ("user." .. accName, aclGetGroup ("SuperModerator")) or isObjectInACLGroup ("user." .. accName, aclGetGroup ("Moderator")) ) then outputChatBox ("#FF0000(Admin Chat) "..tostring(name)..": #FFFFFF"..tostring(text), player, 255, 255, 255, true) end end end end addCommandHandler("ac", adminChat) Link to comment
Sparrow Posted January 6, 2012 Author Share Posted January 6, 2012 I test this, players also can see what I write Link to comment
Castillo Posted January 6, 2012 Share Posted January 6, 2012 My bad, I forgot to change something, copy it again. Link to comment
Kenix Posted January 6, 2012 Share Posted January 6, 2012 Try function adminChat( thePlayer,_,... ) local text = table.concat( {...}, "" ) local name = getPlayerName( thePlayer ) for _,v in pairs( getPlayersInGroup( accName ) ) do outputChatBox ("#FF0000(Admin Chat) "..tostring( name )..": #FFFFFF"..tostring( text ), v, 255, 255, 255, true) end end addCommandHandler("ac", adminChat) function getPlayersInGroup( accName ) local Table = { } for _,v in pairs( getElementsByType( "player" ) ) do local accName = getAccountName ( getPlayerAccount ( v ) ) if isObjectInACLGroup ( "user." .. tostring( accName ), aclGetGroup( "Admin" ) ) or isObjectInACLGroup ( "user." .. tostring( accName ), aclGetGroup ( "SuperModerator" ) ) or isObjectInACLGroup ( "user." .. tostring( accName ), aclGetGroup ( "Moderator" ) ) then table.insert( Table,v ) end end return Table end Code updated recheck it Link to comment
Sparrow Posted January 6, 2012 Author Share Posted January 6, 2012 thank you, it's working. (both working) Link to comment
TwiX! Posted January 6, 2012 Share Posted January 6, 2012 this code.. will not work "spaces" "I will kill u" only - "iwillkillu" Link to comment
Castillo Posted January 6, 2012 Share Posted January 6, 2012 True, use this: function adminChat( thePlayer,_,... ) local text = table.concat( {...}, " " ) local name = getPlayerName( thePlayer ) for _,v in pairs( getPlayersInGroup( accName ) ) do outputChatBox ("#FF0000(Admin Chat) "..tostring( name )..": #FFFFFF"..tostring( text ), v, 255, 255, 255, true) end end addCommandHandler("ac", adminChat) function getPlayersInGroup( accName ) local Table = { } for _,v in pairs( getElementsByType( "player" ) ) do local accName = getAccountName ( getPlayerAccount ( v ) ) if isObjectInACLGroup ( "user." .. tostring( accName ), aclGetGroup( "Admin" ) ) or isObjectInACLGroup ( "user." .. tostring( accName ), aclGetGroup ( "SuperModerator" ) ) or isObjectInACLGroup ( "user." .. tostring( accName ), aclGetGroup ( "Moderator" ) ) then table.insert( Table,v ) end end return Table 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