Jump to content

Jaysds1

Members
  • Posts

    4,961
  • Joined

  • Last visited

Everything posted by Jaysds1

  1. -- 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>
  2. Jaysds1

    database

    ok, but how do you do the script for that.
  3. 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.
  4. Jaysds1

    database

    what is more easy?
  5. Jaysds1

    database

    so how do you create a bank database or house system?
  6. Jaysds1

    database

    How do you create a bank database and a house system?
  7. What should I edited in here? I created a gui with 2 buttons that should be linked to spawning a player. addEventHandler("onClientResourceStart",resourceRoot, function() GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Edit = {} GUIEditor_Progress = {} GUIEditor_Window[1] = guiCreateWindow(33,174,149,276,"Teams",false) guiSetAlpha(GUIEditor_Window[1],1) GUIEditor_Button[2] = guiCreateButton(46,172,67,31,"Freeroamer",false,GUIEditor_Window[1]) guiSetAlpha(GUIEditor_Button[2],1) GUIEditor_Edit[1] = guiCreateEdit(36,39,92,43,"Select a Team",false,GUIEditor_Window[1]) guiSetAlpha(GUIEditor_Edit[1],1) guiEditSetReadOnly(GUIEditor_Edit[1],true) GUIEditor_Progress[1] = guiCreateProgressBar(24,238,112,29,false,GUIEditor_Window[1]) guiSetAlpha(GUIEditor_Progress[1],1) guiProgressBarSetProgress(GUIEditor_Progress[1],100) end )
  8. I need help creating a button linking to a team, making a person/client spawn on that team.
  9. How do you create a spawn Window with 2 buttons saying (Freeroamer and Server Cops).
  10. I still don't know how does the gui script work?
×
×
  • Create New...