kevenvz Posted November 9, 2013 Share Posted November 9, 2013 I got a too long outputChatBox string(I think) local commandsXML = xmlLoadFile("commands.xml") for index,node in pairs(xmlNodeGetChildren(commandsXML)) do if xmlNodeGetName(node) == "command" then checkSound(xmlNodeGetAttribute(node,"sound")) commands = commands..colorCode.." /"..xmlNodeGetAttribute(node,"commandName")..textColor end end addCommandHandler("chatcommands", function(player) outputChatBox(colorCode.."# "..textColor.."Available chatcommands:"..commands,player,255,255,255,true) end) Does anybody know how to fix it or something? Something like \r\n? Link to comment
csiguusz Posted November 9, 2013 Share Posted November 9, 2013 Read the commands into a table, and then output them from here, only one command for one outputChatBox. local commandsTable = {} local commandsXML = xmlLoadFile("commands.xml") for index,node in pairs(xmlNodeGetChildren(commandsXML)) do if xmlNodeGetName(node) == "command" then checkSound(xmlNodeGetAttribute(node,"sound")) commandsTable[ #commandsTable + 1 ] = colorCode.." /"..xmlNodeGetAttribute(node,"commandName")..textColor end end addCommandHandler("chatcommands", function(player) outputChatBox(colorCode.."# "..textColor.."Available chatcommands:",player,255,255,255,true) for i, v in ipairs ( commandsTable ) do outputChatBox ( v, player, 255, 255, 255, true ) end end) Link to comment
kevenvz Posted November 9, 2013 Author Share Posted November 9, 2013 Read the commands into a table, and then output them from here, only one command for one outputChatBox. local commandsTable = {} local commandsXML = xmlLoadFile("commands.xml") for index,node in pairs(xmlNodeGetChildren(commandsXML)) do if xmlNodeGetName(node) == "command" then checkSound(xmlNodeGetAttribute(node,"sound")) commandsTable[ #commandsTable + 1 ] = colorCode.." /"..xmlNodeGetAttribute(node,"commandName")..textColor end end addCommandHandler("chatcommands", function(player) outputChatBox(colorCode.."# "..textColor.."Available chatcommands:",player,255,255,255,true) for i, v in ipairs ( commandsTable ) do outputChatBox ( v, player, 255, 255, 255, true ) end end) But I want them to be in a straight line, like when the first line is full it goes to the next line etc.. Link to comment
csiguusz Posted November 9, 2013 Share Posted November 9, 2013 Then you have to brake it into lines by yourself. My solution: function linebreak ( t ) local line = "" local newTable = {} local i = 1 while i <= #t do while line:len () <= 120 and i <= #t do -- I'm not sure what is the character limit. You can try changing the value 120. line = line .. t[ i ] i = i + 1 end newTable[ #newTable + 1 ] = line line = "" end return newTable end local commandsTable = {} local commandsXML = xmlLoadFile("commands.xml") for index,node in pairs(xmlNodeGetChildren(commandsXML)) do if xmlNodeGetName(node) == "command" then checkSound(xmlNodeGetAttribute(node,"sound")) commandsTable[ #commandsTable + 1 ] = colorCode.." /"..xmlNodeGetAttribute(node,"commandName")..textColor end end commandsTable = linebreak ( commandsTable ) addCommandHandler("chatcommands", function(player) outputChatBox(colorCode.."# "..textColor.."Available chatcommands:",player,255,255,255,true) for i, v in ipairs ( commandsTable ) do outputChatBox ( v, player, 255, 255, 255, true ) end end) Link to comment
Gallardo9944 Posted November 10, 2013 Share Posted November 10, 2013 Character limit is 128 characters. 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