Jaysds1 Posted April 26, 2011 Posted April 26, 2011 Every time I start my server it shows "There's an error near "<" " and there's no error, so I'm wondering if there's an upgrade or update on the News feed script.
Castillo Posted April 26, 2011 Posted April 26, 2011 CowTurbo, are you drunk? because that's the most useless post i ever seen.
Jaysds1 Posted April 26, 2011 Author Posted April 26, 2011 -- Client Side -- -- news feed function createNewsFeed() -- get the screen width and height local sWidth, sHeight = guiGetScreenSize() -- create the gridlist, using some maths to find the bottom-centre of the screen local Width,Height = 800,45 local X = (sWidth/2) - (Width/2) local Y = sHeight - (Height/2) -- the gridlist will act as the background to our news reel newsGridlist = guiCreateGridList(X,Y,Width,Height,false) -- create the label in the same place, but as a child of the gridlist -- also make it half the height of the gridlist, as half of the gridlist is off the bottom of the screen newsLabel = guiCreateLabel(X,Y,Width,Height/2,"Test text",false,newsGridlist) -- call our function to read the news out of the xml file loadNews() -- load the first news item in the table updateNewsItem(1) -- define a global variable called 'currentItem' with the value 1 currentItem = 1 end addEventHandler("onClientResourceStart",resourceRoot,createNewsFeed) function loadNews() local newsfile = xmlLoadFile("newsfeed.xml") if newsfile then -- loop through all the children of the root node (the "news" nodes) for index,itemNode in ipairs(xmlNodeGetChildren(newsfile)) do -- get the text (the news item) from the node local item = xmlNodeGetValue(itemNode) -- insert it into our newsItems table table.insert(newsItems,item) end xmlUnloadFile(newsfile) end end -- define our function with a newIndex parameter, so that we can pass which news item we want to show function updateNewsItem(newIndex) -- get the new news item from the table local item = newsItems[newIndex] -- update the label text guiSetText(newsLabel,item) -- update the 'currentItem' global variable currentItem = newIndex -- get the current dimensions of the gui label local width,height = guiGetSize(newsLabel,false) -- get the text width of the label local extent = guiLabelGetTextExtent(newsLabel) -- update the size of the label with the new width (we do not change the height) guiSetSize(newsLabel,extent,height,false) -- set the positon to the far right side of the gridlist, ready to scroll on to the left guiSetPosition(newsLabel,1,0,true) end addEventHandler("onClientRender",root,scrollNews) function scrollNews() local x,y = guiGetPosition(newsLabel,false) local labelWidth, labelHeight = guiGetSize(newsLabel,false) -- if the far right position of the label (x + labelWidth) is greater than or equal to 0 (ie: still showing on the gridlist) if ((x-1) + labelWidth) >= 0 then -- compensate for a small off-by-one bug in MTA if x <= 0 then x = x - 1 end -- update the position as normal guiSetPosition(newsLabel,x-1,y,false) -- otherwise, we move on to the next item and reset the position else -- get the total number of items in the 'newsItems' table local totalItems = #newsItems -- if the next item on our list does not exist in our table if (currentItem + 1) > totalItems then -- loop back to the first item in the list updateNewsItem(1) else -- otherwise move onto the next item in the list updateNewsItem(currentItem + 1) end end end --newsfeed.xml-- <root> <news>Visit [url=http://www.JWORLDSA.tk]http://www.JWORLDSA.tk[/url] for latest news.</news> <news>Still Updating</news> </root>
Castillo Posted April 26, 2011 Posted April 26, 2011 You'd forgot to tell me where's the error, line number.
Castillo Posted April 26, 2011 Posted April 26, 2011 I don't understand, where's the error? in newsfeed.xml or in the script part? Post an screenshot of your server console (when the error pop-ups)
Jaysds1 Posted April 26, 2011 Author Posted April 26, 2011 Here \newsfeed.xml:1: unexpected symbol near "<"
DakiLLa Posted April 26, 2011 Posted April 26, 2011 Here\newsfeed.xml:1: unexpected symbol near "<" lol, you shouldn't define this file in meta.xml. I assume you did something like ="newsfeed.xml" type="server" /> didn't you?
Castillo Posted April 27, 2011 Posted April 27, 2011 Not possible, because the XML files doesn't output errors like the normal scripts (as far as i know).
CowTurbo Posted April 27, 2011 Posted April 27, 2011 CowTurbo, are you drunk? because that's the most useless post i ever seen. im not drunk and im not idiot
CowTurbo Posted April 27, 2011 Posted April 27, 2011 as far as i konw 'lol' means laughting. Why else should i post 'lol' ?
proracer Posted April 27, 2011 Posted April 27, 2011 Press "PrintScreen" on keyboard if you have it and paste it in picture editor like Paint or something.
Jaysds1 Posted April 27, 2011 Author Posted April 27, 2011 This is what it said: [2011-04-25 13:49:25] SCRIPT ERROR: JS\news.xml:1: unexpected symbol near '<' [2011-04-25 13:49:25] WARNING: Loading script failed: JS\news.xml:1: unexpected symbol near '<' or
AGENT_STEELMEAT Posted April 28, 2011 Posted April 28, 2011 is WRONG, it should be .xmls are not scripts, therefore they do not use the script tag. rather, it is a file for the clientside script to read, so it gets the file tag. Only LUA scripts should get the script tag (.lua and .luac).
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