Jump to content

Admin announcement


enzopaul4

Recommended Posts


function cuenta ( thePlayer )
local cuenta = getAccountName( getPlayerAccount(thePlayer) )
if isObjectInACLGroup("user."..cuenta, aclGetGroup("Admin")) then
    spaces(thePlayer)
elseif isObjectInACLGroup("user."..cuenta, aclGetGroup("SuperModerator")) then
    spaces(thePlayer)
elseif isObjectInACLGroup("user."..cuenta, aclGetGroup("Moderator")) then
    spaces(thePlayer)
    spaces(thePlayer)
elseif isObjectInACLGroup("user."..cuenta, aclGetGroup("Console")) then 
    spaces(thePlayer)
elseif isObjectInACLGroup("user."..cuenta, aclGetGroup("Administrator")) then 
    spaces(thePlayer)
else
outputChatBox("ACCESS DENIED, You are not Admin", thePlayer, 255, 0, 0, true) 
end
end
addCommandHandler("adm", cuenta)

function spaces(thePlayer)
outputChatBox("#ff0000~>#ff8c00Announcement:"..message, getRootElement(), 255, 255, 255, true)
end

->The error: adm/server.lua:22: attempt to concatenate global 'message' (a nill value

-> can you help me please , i am biginner in scripting

Edited by enzopaul4
Link to comment

The variable message is empty, thus it returns a nil value. As far as I can tell it's not defined anywhere. addCommandHandler stores all the messages as parameters, by using ... you can then store these in a table. You then use table.concat to concatenate them into a string. See this example;

function adminMessage(thePlayer, theCommand, ...)
	local playerName = getAccountName(getPlayerAccount(thePlayer))
	local messageParameters = {...}
	local fullString = table.concat(messageParameters, " ")
	
	if(isObjectInACLGroup("user."..playerName, aclGetGroup("Admin"))) then
		outputAdminMessage(thePlayer, fullString)
	elseif(isObjectInACLGroup("user."..playerName, aclGetGroup("SuperModerator"))) then
		outputAdminMessage(thePlayer, fullString)
	elseif(isObjectInACLGroup("user."..playerName, aclGetGroup("Moderator"))) then
		outputAdminMessage(thePlayer, fullString)
	elseif(isObjectInACLGroup("user."..playerName, aclGetGroup("Console"))) then 
		outputAdminMessage(thePlayer, fullString)
	elseif(isObjectInACLGroup("user."..playerName, aclGetGroup("Administrator"))) then 
		outputAdminMessage(thePlayer, fullString)
	else
	outputChatBox("ACCESS DENIED, You are not Admin", thePlayer, 255, 0, 0, true) 
	end
end
addCommandHandler("adm", adminMessage)

function outputAdminMessage(thePlayer, theMessage)
	outputChatBox("#ff0000~>#ff8c00Announcement: "..theMessage, root, 255, 255, 255, true)
end

 

Edited by Dealman
Link to comment
local aclGroup = {"Admin","SuperModerator","Moderator","Console","Administrator"}

function adminMessage(thePlayer, theCommand, ...)
    local account = getPlayerAccount(thePlayer)
    if account and not isGuestAccount(account) then 
        local accountName = getAccountName(account)
        local messageParameters = {...}
        local fullString = table.concat(messageParameters, " ")
        local passed = false
        for i=1 , #aclGroup do
            if(isObjectInACLGroup("user."..accountName, aclGetGroup(aclGroup[i]))) then
                outputAdminMessage(thePlayer, fullString)
                passed = true
                break
            end 
        end 
        if not passed then 
           outputChatBox("ACCESS DENIED, You are not Admin", thePlayer, 255, 0, 0, true) 
        end 
    end
end
addCommandHandler("adm", adminMessage)

function outputAdminMessage(thePlayer, theMessage)
   outputChatBox("#ff0000~>#ff8c00Announcement: "..theMessage, root, 255, 255, 255, true)
end

 

Edited by Walid
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...