DutchCaffeine Posted May 14, 2008 Posted May 14, 2008 Hello, I be new at multi theft auto and lua, and i think i do it very well But i have a problem with reading from a xml file. I have to ellements in the xml file: The text that will show in guiCreateMemo() The text that will show in guiCreateMemo() The xml file: <memo> Hello, \n\n In this tab "order" you can order the next things: \n\n 1. Vehicle's 2. Vehicle upgrade 3. Sell your vehicle's \n\n The max vehicle's to buy are 5! \n\n Nice driving, \n\n LexLife team. </memo> <buyMemo> Hello, \n\n In this tab you can buy a vehicle, but we are busy at the system so for now, you cant. \n\n Nice driving, \n\n LexLife team. </buyMemo> </text> The code where i want it to load: addEventHandler( "onClientResourceStart", g_this_root, function( theResource ) if theResource == getThisResource() then local x, y = guiGetScreenSize() vehicleWindow = guiCreateWindow(x / 2 - 310, y / 2 - 260, 620, 520, "LexLife - VehicleMenu", false) vehtabPanel = guiCreateTabPanel(0.01, 0.05, 0.98, 0.95, true, vehicleWindow) vehTab = {} vehTab.Tab = guiCreateTab("Vehicle info", vehtabPanel) vehTab.Messages = guiCreateLabel ( 0.68, 0.05, 0.45, 0.04, "Health: 1000%", true, vehTab.Tab ) vehTab.ownVehiclesSearch = guiCreateEdit ( 0.03, 0.05, 0.16, 0.04, "", true, vehTab.Tab ) vehTab2 = {} vehTab2.Tab = guiCreateTab("Order", vehtabPanel) vehTab2.Messages = guiCreateLabel(0.01, 0.0, 0.55, 0.03, "Here you can buy/sell/upgrade vehicles", true, vehTab2.Tab) vehTab2.buyCarbtn = guiCreateButton(0.01, 0.05, 0.25, 0.04, "Buy an car", true, vehTab2.Tab) vehTab2.sellCarbtn = guiCreateButton(0.01, 0.12, 0.25, 0.04, "Sell your vehicle", true, vehTab2.Tab) vehTab2.upgCarbtn = guiCreateButton(0.01, 0.18, 0.25, 0.04, "Upgrade your vehicle", true, vehTab2.Tab) Node = xmlLoadFile("client\\text\\vehicle_order_text.xml") MemoText = xmlNodeGetAttribute(Node, "memo") buyMemoText = xmlNodeGetAttribute(Node, "buyMemo") xmlUnloadFile(Node) vehTab2.Memo = guiCreateMemo(0.27, 0.05, 0.70, 0.80, MemoText, true, vehTab2.Tab) vehTab2.buyMemo = guiCreateMemo(0.27, 0.05, 0.70, 0.80, buyMemoText, true, vehTab2.Tab) guiSetVisible(vehTab2.buyMemo, false) addEventHandler( "onClientGUIClick", vehTab2.buyCarbtn, function() if source == vehTab2.buyCarbtn then guiSetVisible(vehTab2.Memo, false) guiSetVisible(vehTab2.buyMemo, true) end end ) showCursor(false) guiSetVisible(vehicleWindow, false) unbindKey("f1", "down") unbindKey("f2", "down") bindKey("f1", "down", showUi) bindKey("f2", "down", hideUi) end end ) I hope someone will help me out. Thanks, Alexander
DutchCaffeine Posted May 14, 2008 Author Posted May 14, 2008 Hello, I be new at multi theft auto and lua, and i think i do it very well But i have a problem with reading from a xml file. I have to ellements in the xml file: The text that will show in guiCreateMemo() The text that will show in guiCreateMemo() The xml file: Hello, \n\n In this tab "order" you can order the next things: \n\n 1. Vehicle's 2. Vehicle upgrade 3. Sell your vehicle's \n\n The max vehicle's to buy are 5! \n\n Nice driving, \n\n LexLife team. Hello, \n\n In this tab you can buy a vehicle, but we are busy at the system so for now, you cant. \n\n Nice driving, \n\n LexLife team. The code where i want it to load: addEventHandler( "onClientResourceStart", g_this_root, function( theResource ) if theResource == getThisResource() then local x, y = guiGetScreenSize() vehicleWindow = guiCreateWindow(x / 2 - 310, y / 2 - 260, 620, 520, "LexLife - VehicleMenu", false) vehtabPanel = guiCreateTabPanel(0.01, 0.05, 0.98, 0.95, true, vehicleWindow) vehTab = {} vehTab.Tab = guiCreateTab("Vehicle info", vehtabPanel) vehTab.Messages = guiCreateLabel ( 0.68, 0.05, 0.45, 0.04, "Health: 1000%", true, vehTab.Tab ) vehTab.ownVehiclesSearch = guiCreateEdit ( 0.03, 0.05, 0.16, 0.04, "", true, vehTab.Tab ) vehTab2 = {} vehTab2.Tab = guiCreateTab("Order", vehtabPanel) vehTab2.Messages = guiCreateLabel(0.01, 0.0, 0.55, 0.03, "Here you can buy/sell/upgrade vehicles", true, vehTab2.Tab) vehTab2.buyCarbtn = guiCreateButton(0.01, 0.05, 0.25, 0.04, "Buy an car", true, vehTab2.Tab) vehTab2.sellCarbtn = guiCreateButton(0.01, 0.12, 0.25, 0.04, "Sell your vehicle", true, vehTab2.Tab) vehTab2.upgCarbtn = guiCreateButton(0.01, 0.18, 0.25, 0.04, "Upgrade your vehicle", true, vehTab2.Tab) Node = xmlLoadFile("client\\text\\vehicle_order_text.xml") MemoText = xmlNodeGetAttribute(Node, "memo") buyMemoText = xmlNodeGetAttribute(Node, "buyMemo") xmlUnloadFile(Node) vehTab2.Memo = guiCreateMemo(0.27, 0.05, 0.70, 0.80, MemoText, true, vehTab2.Tab) vehTab2.buyMemo = guiCreateMemo(0.27, 0.05, 0.70, 0.80, buyMemoText, true, vehTab2.Tab) guiSetVisible(vehTab2.buyMemo, false) addEventHandler( "onClientGUIClick", vehTab2.buyCarbtn, function() if source == vehTab2.buyCarbtn then guiSetVisible(vehTab2.Memo, false) guiSetVisible(vehTab2.buyMemo, true) end end ) showCursor(false) guiSetVisible(vehicleWindow, false) unbindKey("f1", "down") unbindKey("f2", "down") bindKey("f1", "down", showUi) bindKey("f2", "down", hideUi) end end) I hope someone will help me out. Thanks, Alexander
DutchCaffeine Posted May 14, 2008 Author Posted May 14, 2008 Removed but still doesn't work. Need i to add in the meta.xml:
DutchCaffeine Posted May 14, 2008 Author Posted May 14, 2008 Removed but still doesn't work. Need i to add in the meta.xml:
Brophy Posted May 14, 2008 Posted May 14, 2008 try <xml> <node memo=" Hello, \n\n In this tab "order" you can order the next things: \n\n 1. Vehicle's 2. Vehicle upgrade 3. Sell your vehicle's \n\n The max vehicle's to buy are 5! \n\n Nice driving, \n\n LexLife team." /> <node buyMemo=" Hello, \n\n In this tab you can buy a vehicle, but we are busy at the system so for now, you cant. \n\n Nice driving, \n\n LexLife team." /> </xml> or you could split both them into seperate xml's and use this for each xml (or if you are feeling more adventurous, get lua to split them up from the same xml ) node = xmlLoadFile("hai.xml") nodetext = xmlNodeGetValue(node) and yes you will need to add to your meta.xml (remember to type run the command 'refresh' to make server load the meta.xml changes)
Brophy Posted May 14, 2008 Posted May 14, 2008 try >memo=" Hello, \n\n In this tab "order" you can order the next things: \n\n 1. Vehicle's 2. Vehicle upgrade 3. Sell your vehicle's \n\n The max vehicle's to buy are 5! \n\n Nice driving, \n\n LexLife team." />buyMemo=" Hello, \n\n In this tab you can buy a vehicle, but we are busy at the system so for now, you cant. \n\n Nice driving, \n\n LexLife team." />> or you could split both them into seperate xml's and use this for each xml (or if you are feeling more adventurous, get lua to split them up from the same xml ) node = xmlLoadFile("hai.xml")nodetext = xmlNodeGetValue(node) and yes you will need to add to your meta.xml (remember to type run the command 'refresh' to make server load the meta.xml changes)
DutchCaffeine Posted May 14, 2008 Author Posted May 14, 2008 Hello, Thanks, but still doesn't work. I've got the updated xml file: <memo wlcTxt="Hello, \n\n In this tab 'order' you can order the next things: \n\n 1. Vehicle's 2. Vehicle upgrade 3. Sell your vehicle's \n\n The max vehicle's to buy are 5! \n\n Nice driving, \n\n LexLife team." /> <memo buyTxt=" Hello, \n\n In this tab you can buy a vehicle, but we are busy at the system so for now, you cant. \n\n Nice driving, \n\n LexLife team." /> And the updated code: addEventHandler( "onClientResourceStart", g_this_root, function( theResource ) if theResource == getThisResource() then local x, y = guiGetScreenSize() vehicleWindow = guiCreateWindow(x / 2 - 310, y / 2 - 260, 620, 520, "LexLife - VehicleMenu", false) vehtabPanel = guiCreateTabPanel(0.01, 0.05, 0.98, 0.95, true, vehicleWindow) vehTab = {} vehTab.Tab = guiCreateTab("Vehicle info", vehtabPanel) vehTab.Messages = guiCreateLabel ( 0.68, 0.05, 0.45, 0.04, "Health: 1000%", true, vehTab.Tab ) vehTab.ownVehiclesSearch = guiCreateEdit ( 0.03, 0.05, 0.16, 0.04, "", true, vehTab.Tab ) vehTab2 = {} vehTab2.Tab = guiCreateTab("Order", vehtabPanel) vehTab2.Messages = guiCreateLabel(0.01, 0.0, 0.55, 0.03, "Here you can buy/sell/upgrade vehicles", true, vehTab2.Tab) vehTab2.buyCarbtn = guiCreateButton(0.01, 0.05, 0.25, 0.04, "Buy an car", true, vehTab2.Tab) vehTab2.sellCarbtn = guiCreateButton(0.01, 0.12, 0.25, 0.04, "Sell your vehicle", true, vehTab2.Tab) vehTab2.upgCarbtn = guiCreateButton(0.01, 0.18, 0.25, 0.04, "Upgrade your vehicle", true, vehTab2.Tab) Node = xmlLoadFile("client\\text\\vehicle_order_text.xml") nodetext = xmlNodeGetValue(Node) MemoText = xmlNodeGetAttribute(nodetext, "wlcTxt") buyMemoText = xmlNodeGetAttribute(nodetext, "buyTxt") xmlUnloadFile(Node) vehTab2.Memo = guiCreateMemo(0.27, 0.05, 0.70, 0.80, MemoText, true, vehTab2.Tab) vehTab2.buyMemo = guiCreateMemo(0.27, 0.05, 0.70, 0.80, buyMemoText, true, vehTab2.Tab) guiSetVisible(vehTab2.buyMemo, false) addEventHandler( "onClientGUIClick", vehTab2.buyCarbtn, function() if source == vehTab2.buyCarbtn then guiSetVisible(vehTab2.Memo, false) guiSetVisible(vehTab2.buyMemo, true) end end ) showCursor(false) guiSetVisible(vehicleWindow, false) unbindKey("f1", "down") unbindKey("f2", "down") bindKey("f1", "down", showUi) bindKey("f2", "down", hideUi) end end ) Alexander Edit: The line in meta.xml
DutchCaffeine Posted May 14, 2008 Author Posted May 14, 2008 Hello, Thanks, but still doesn't work. I've got the updated xml file: \n\n In this tab 'order' you can order the next things: \n\n 1. Vehicle's 2. Vehicle upgrade 3. Sell your vehicle's \n\n The max vehicle's to buy are 5! \n\n Nice driving, \n\n LexLife team." /> Hello, \n\n In this tab you can buy a vehicle, but we are busy at the system so for now, you cant. \n\n Nice driving, \n\n LexLife team." /> And the updated code: addEventHandler( "onClientResourceStart", g_this_root, function( theResource ) if theResource == getThisResource() then local x, y = guiGetScreenSize() vehicleWindow = guiCreateWindow(x / 2 - 310, y / 2 - 260, 620, 520, "LexLife - VehicleMenu", false) vehtabPanel = guiCreateTabPanel(0.01, 0.05, 0.98, 0.95, true, vehicleWindow) vehTab = {} vehTab.Tab = guiCreateTab("Vehicle info", vehtabPanel) vehTab.Messages = guiCreateLabel ( 0.68, 0.05, 0.45, 0.04, "Health: 1000%", true, vehTab.Tab ) vehTab.ownVehiclesSearch = guiCreateEdit ( 0.03, 0.05, 0.16, 0.04, "", true, vehTab.Tab ) vehTab2 = {} vehTab2.Tab = guiCreateTab("Order", vehtabPanel) vehTab2.Messages = guiCreateLabel(0.01, 0.0, 0.55, 0.03, "Here you can buy/sell/upgrade vehicles", true, vehTab2.Tab) vehTab2.buyCarbtn = guiCreateButton(0.01, 0.05, 0.25, 0.04, "Buy an car", true, vehTab2.Tab) vehTab2.sellCarbtn = guiCreateButton(0.01, 0.12, 0.25, 0.04, "Sell your vehicle", true, vehTab2.Tab) vehTab2.upgCarbtn = guiCreateButton(0.01, 0.18, 0.25, 0.04, "Upgrade your vehicle", true, vehTab2.Tab) Node = xmlLoadFile("client\\text\\vehicle_order_text.xml") nodetext = xmlNodeGetValue(Node) MemoText = xmlNodeGetAttribute(nodetext, "wlcTxt") buyMemoText = xmlNodeGetAttribute(nodetext, "buyTxt") xmlUnloadFile(Node) vehTab2.Memo = guiCreateMemo(0.27, 0.05, 0.70, 0.80, MemoText, true, vehTab2.Tab) vehTab2.buyMemo = guiCreateMemo(0.27, 0.05, 0.70, 0.80, buyMemoText, true, vehTab2.Tab) guiSetVisible(vehTab2.buyMemo, false) addEventHandler( "onClientGUIClick", vehTab2.buyCarbtn, function() if source == vehTab2.buyCarbtn then guiSetVisible(vehTab2.Memo, false) guiSetVisible(vehTab2.buyMemo, true) end end ) showCursor(false) guiSetVisible(vehicleWindow, false) unbindKey("f1", "down") unbindKey("f2", "down") bindKey("f1", "down", showUi) bindKey("f2", "down", hideUi) end end) Alexander Edit: The line in meta.xml
Brophy Posted May 14, 2008 Posted May 14, 2008 node = xmlLoadFile("client/text/vehicle_order_text.xml") MemoText = xmlNodeGetAttribute(node, "wlcTxt") buyMemoText = xmlNodeGetAttribute(node, "buyTxt") xmlUnloadFile(node)
Brophy Posted May 14, 2008 Posted May 14, 2008 node = xmlLoadFile("client/text/vehicle_order_text.xml") MemoText = xmlNodeGetAttribute(node, "wlcTxt")buyMemoText = xmlNodeGetAttribute(node, "buyTxt") xmlUnloadFile(node)
eAi Posted May 14, 2008 Posted May 14, 2008 That's not a valid xml file. All xml files must have a root node that contains every other node.
eAi Posted May 14, 2008 Posted May 14, 2008 That's not a valid xml file. All xml files must have a root node that contains every other node.
DutchCaffeine Posted May 14, 2008 Author Posted May 14, 2008 Oke, Thus for example: <language name="en"> <text name="scrWelcom">Text in here</text> <text name="scrWeapon">Weapon text in here</text> </language> Something like that? And how to load in to lua (client script)
DutchCaffeine Posted May 14, 2008 Author Posted May 14, 2008 Oke, Thus for example: Text in here Weapon text in here Something like that? And how to load in to lua (client script)
50p Posted May 15, 2008 Posted May 15, 2008 That's correct. If you want to read the file in client-side script the client has to download it first, therefore you have to include the file in the meta.xml ().
50p Posted May 15, 2008 Posted May 15, 2008 That's correct. If you want to read the file in client-side script the client has to download it first, therefore you have to include the file in the meta.xml ().
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