Jump to content

Admin announcement


enzopaul4

Recommended Posts

Posted (edited)


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
Posted (edited)

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

If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.

Posted (edited)
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

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

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