Jump to content

ThePope

Members
  • Posts

    26
  • Joined

  • Last visited

Everything posted by ThePope

  1. Hello, I have a problem that is starting to give me a headache. I'm learing Lua Scripting, so I took some scripts as examples and tried to build a carshop. Basic idea seems simple to me, list al the cars from an xml file and then, when a player clicks buy, compare his/her money to the costs and spawn the car. The shops are created without a fuss, also from an xml file. But when I do so with the cars, it seems to think there are no entries in the xml file?!. Here is my a piece of my xml file: <cars> <car id="602" price="15000" /> <car id="496" price="15000" /> <car id="401" price="15000" /> <car id="518" price="15000" /> <car id="527" price="15000" /> <car id="589" price="15000" /> <car id="419" price="15000" /> <car id="533" price="15000" /> <car id="526" price="15000" /> </cars> and this is the list function: outputChatBox( "Client: Creating car grid" ) oCarList = guiCreateGridList ( 0.03 , 0.07, 0.4, 0.8, true, oShopGUI ) oColumnCarName = guiGridListAddColumn( oCarList, "Car", 0.5 ) oColumnPrice = guiGridListAddColumn( oCarList, "Price", 0.3 ) oCarXml = xmlLoadFile("data\\cars.xml") if ( oCarXml ) then outputChatBox( "Client: Cars.xml loaded" ) --local oCarListRow = guiGridListAddRow( oCarList ) --guiGridListSetItemText( oCarList, oCarListRow, 1, "test", false, false ) --guiGridListSetItemText( oCarList, oCarListRow, 2, "123", false, false ) local iCarIndex = 0; while ( xmlFindChild( oCarXML, "vehicle", iCarIndex ) ~= false ) do outputChatBox( "Client: message 2" ) local oCar = xmlFindChild( oCarXML, "vehicle", iCarIndex ) local iCarID = xmlNodeGetAttribute( oCar, "id" ) local iCarPrice = xmlNodeGetAttribute( oCar, "price" ) local sCarName = getVehicleNameFromModel( iCarID ) local oCarListRow = guiGridListAddRow( oCarList ) guiGridListSetItemText( oCarList, oCarListRow, 1, ""..sCarName.."", false, false ) guiGridListSetItemText( oCarList, oCarListRow, 2, ""..iCarPice.."", false, false ) iCarIndex = iCarIndex + 1 end outputChatBox( "Client: cars added to list." ) as you can see, I also tried adding cars manually to the list and that worked fine. Can anyone help me, or point me in the right direction?
×
×
  • Create New...