Jump to content

Script problem


Volltron

Recommended Posts

Posted

I wanted to make a script so that admins can chat between them 


function adminMessage(thePlayer, cmd, ...)
    local message = table.concat ( { ... }, " " );
    local name = getPlayerName(thePlayer)
    local accName = getAccountName ( getPlayerAccount ( thePlayer ) )
    local tableadmin = { }     
        if (isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) )) then
            table.insert(tableadmin,thePlayer)
                for i,admins in ipairs(tableadmin) do
                outputChatBox("#04B486[ADMIN-CHAT]"..name..": #FFFFFF"..message, admins, 255, 255, 255, true)
                end
        end
end
addCommandHandler("adminchat",  adminMessage)
     

I would really apreciate it if someone could help me

Posted (edited)

You are on the right track, except that you never actually loop through the admins, you just loop through a table that has only 1 element in it, the user that executed the command.

function adminMessage(thePlayer, cmd, ...)
	local message = table.concat ( { ... }, " " );
	local name = getPlayerName(thePlayer)
	local accName = getAccountName ( getPlayerAccount ( thePlayer ) )
	for k, adm in ipairs(getElementsByType("player")) do
    	local acc = getAccountName ( getPlayerAccount ( adm ) )
    		if isObjectInACLGroup ("user."..acc, aclGetGroup ( "Admin" ) ) then
    			outputChatBox("#04B486[ADMIN-CHAT]"..name..": #FFFFFF"..message, adm, 255, 255, 255, true)
     		end
   	end
end
addCommandHandler("adminchat",  adminMessage)

(not tested)

Edited by pa3ck

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