enzopaul4 Posted September 24, 2016 Share Posted September 24, 2016 (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 September 24, 2016 by enzopaul4 Link to comment
Dealman Posted September 24, 2016 Share Posted September 24, 2016 (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 September 24, 2016 by Dealman Link to comment
enzopaul4 Posted September 25, 2016 Author Share Posted September 25, 2016 Thank You! Link to comment
Walid Posted September 25, 2016 Share Posted September 25, 2016 (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 September 25, 2016 by Walid 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