Search the Community
Showing results for tags 'xml'.
-
Hi, I'm using XML to create a LOG https://wiki.multitheftauto.com/wiki/XmlFindChild But the main problem here is just (1) XML Pictures: XML: https://pasteboard.co/YU2m4gpnuWqT.png But I get something output OutputChatBox: https://pasteboard.co/zHgbIs18AHiZ.png I want to show all XML data, not just 1 data I hope you understand what I mean
-
<catalog type="vehicle"> <group name="-----------------------------------------"> </group> <group name="# Carros Brasileiros"> <vehicle id="589" name="|- Mini Cooper" /> <vehicle id="587" name="|- Gol G6" /> <vehicle id="458" name="|- Gol G4" /> <vehicle id="402" name="|- Chevete" /> <vehicle id="540" name="|- Parati Surf" /> <vehicle id="479" name="|- Sonata" /> <vehicle id="543" name="|- Montana" /> <vehicle id="529" name="|- Fiat Stylo" /> <vehicle id="527" name="|- Gol GL" /> <vehicle id="545" name="|- Fusca" /> <vehicle id="605" name="|- Saveiro G4" /> <vehicle id="410" name="|- Parati Quadrada" /> <vehicle id="600" name="|- Saveiro G5" /> <vehicle id="551" name="|- Honda-civic" /> <vehicle id="558" name="|- Santana" /> <vehicle id="496" name="|- Voyage Quadrado" /> <vehicle id="" name="-----------------------------------------" /> </group> <group name="# Carros De Luxo"> <vehicle id="500" name="Mitsubishi Triton c/ Paredao" /> <vehicle id="405" name="BMW M5 " /> <vehicle id="480" name="Bugati " /> <vehicle id="400" name="Range Rover" /> <vehicle id="451" name="McLaren MP4" /> <vehicle id="" name="-------------------------------------------" /> </group> <group name="# Carros De Drift"> <vehicle id="555" name="|- Mitsubishi Evox" /> <vehicle id="562" name="|- BMW de Drift" /> <vehicle id="415" name="|- Skyline R34" /> <vehicle id="" name="------------------------------------------" /> </group> <group name="# Motos e Bikes"> <vehicle id="510" name="|- Bike Rebaixada" /> <vehicle id="461" name="|- Hornet" /> <vehicle id="522" name="|- Xj6 " /> <vehicle id="468" name="|- XT660 " /> <vehicle id="521" name="|- CB1000" /> <vehicle id="463" name="|- Harley" /> <vehicle id="586" name="|- 50cc " /> <vehicle id="" name="------------------------------------------" /> </group> <group name=""> <vehicle id="" name="" /> <vehicle id="" name="" /> <vehicle id="" name="" /> <vehicle id="" name="" /> <vehicle id="" name="" /> <vehicle id="" name="" /> <vehicle id="" name="" /> <vehicle id="" name="" /> </group> </catalog>
-
Map files Table of contents: Introduction How to read a map file? Broken map file, what to do? Editor bugged, what to do? Modify your maps outside of MTA Extra links Introduction A map-file! What is that? The name already gives away the definition. It is a file which contains a MTA map. The format makes maps portable, so that you can send them over to your friends. You can recognize map-files by the extension: .map Here is an example of a map: Syntax highlight When you open a map file in your text editor. The syntax highlight you should use is XML (HTML will work as well, but the semantic is different and could cause issues with auto complete features, that is if you have enabled those). Changing syntax highlight in for example Visual Studio Code. How to read a map file? Before we start, this is what we call a node: <tagName></tagName> If we take a closer look to the following map file: <map> <object id="object (bevgrnd03b_law) (1)" interior="0" collisions="true" alpha="255" doublesided="false" model="6094" scale="1" dimension="0" posX="635.234375" posY="-3827.2275390625" posZ="5" rotX="0" rotY="0" rotZ="0"></object> <object id="object (gaz9_law) (1)" interior="0" collisions="true" alpha="255" doublesided="false" model="6133" scale="1" dimension="0" posX="625.49114990234" posY="-3771.6955566406" posZ="11.479743003845" rotX="0" rotY="0" rotZ="0"></object> <object id="object (CE_grndPALCST03) (1)" interior="0" collisions="true" alpha="255" doublesided="false" model="13120" scale="1" dimension="0" posX="573.09802246094" posY="-3847.013671875" posZ="3.6442375183105" rotX="0" rotY="22" rotZ="352"></object> <object id="object (CE_grndPALCST03) (2)" interior="0" collisions="true" alpha="255" doublesided="false" model="13120" scale="1" dimension="0" posX="572.64624023438" posY="-3769.0698242188" posZ="4.9519920349121" rotX="0" rotY="21.99462890625" rotZ="343.24649047852"></object> <object id="object (CE_grndPALCST03) (3)" interior="0" collisions="true" alpha="255" doublesided="false" model="13120" scale="1" dimension="0" posX="669.66534423828" posY="-3856.0627441406" posZ="3.6442375183105" rotX="0" rotY="63.99462890625" rotZ="175.99389648438"></object> </map> > we see in there the map node: <map></map> When the map is loaded <map></map> will become our map element. And inside of the map node we see more nodes: <object id="object (bevgrnd03b_law) (1)" interior="0" collisions="true" alpha="255" doublesided="false" model="6094" scale="1" dimension="0" posX="635.234375" posY="-3827.2275390625" posZ="5" rotX="0" rotY="0" rotZ="0"></object> <object id="object (gaz9_law) (1)" interior="0" collisions="true" alpha="255" doublesided="false" model="6133" scale="1" dimension="0" posX="625.49114990234" posY="-3771.6955566406" posZ="11.479743003845" rotX="0" rotY="0" rotZ="0"></object> In this case these two nodes will become two in-game objects. Tagname <tagName></tagName> Each node in the map file will become an element in game. !important A node has a tag name. In this case I gave it the name: "tagName" This tag name specifies in MTA the element type. For example: If it has the name <object></object>, the element-type is an object. If it has the name <ped></ped>, the element-type is a ped. What if the tag name is not matching with one of these entities? (The list is not complete, the rest can be found in this class list, only if the XML syntax is implemented) Then the elements are considered custom elements. They are not visible in game. Custom elements Custom elements have their own purposes. You often see those custom elements used in game modes, for example stealth: <mercenaryspawn id="mercenaryspawn (1)" posX="635.58117675781" posY="-3770.458984375" posZ="18.97974395752" rotX="0" rotY="0" rotZ="0"></mercenaryspawn> The tagname for this node is "mercenaryspawn". The element that is produced after loading the map, is used as a spawnpoint for in a stealth map. Custom elements are invisible. Custom elements do have an orientation. The getElementsByType function can be used to get custom elements. Attributes Attributes are properties applied to a node. They are used to attach data to an element. Example: <entity name="IIYAMA" age="5" type="device" resolutionX="1920" resolutionY="1080" displaySize="31"></entity> An attribute exist out of two parts: <entity name="value"></entity> Name Value The name specifies if the node has the attribute. <entity name></entity> <entity age></entity> If the name is "name", then the node has the attribute "name". And if the name is "age", then the node has the attribute "age". The value will be used for the data for each attribute. <entity name="IIYAMA" age="5"></entity> Identifiers (ID) Every elements can have an identifier attribute, which is used to make it accessible for scripting functions. <tagName id="identifier"></tagName> The identifier of an element can be used in getElementByID to grant access to it. Even though identifiers normally should be unique for each individual, it is not the end of the world if they are not in MTA. They might also be considered as unnecessary for map files without scripts. Element specific attributes There are some attributes that do more than just applying properties. They will change the element appearance and orientation. For example this object: <object interior="0" collisions="true" alpha="255" doublesided="false" model="6094" scale="1" dimension="0" posX="635.234375" posY="-3827.2275390625" posZ="5" rotX="0" rotY="0" rotZ="0"></object> It will be created in interior 0. It will have collisions. (You can walk on it) Alpha. It's opacity is 100%. It is not doublesided. (When you stand inside of the object you can look through it. If doublesided is enabled the same colors/paint from the other side will be applied.) It's model is 6094. It is scaled 100%. (0.5 = 50%, 2 = 200%) Etc. If you want to know which attributes do have influence on the elements appearance and orientation, you have to look that up on the wiki. Here a small list of some those attributes: Broken map file, what to do? If your map file is broken. Step 1 Make a backup. + Always make a backup when re-editing your map. Settings can get lost! Step 2 The first thing you want to do, is just open it in a text-editor. Just give it a quick look and check for anything strange. The file could be empty or some strange values could be used. Do you want to know all the syntax rules (XML)? You can find a list right here: http://www.adobepress.com/articles/article.asp?p=1179145 Step 3 Remove the editor definition. This definition could cause problems in case of invalid characters. From: <map edf:definitions="COBDEF,editor_main"> <!-- Map elements --> </map> To: <map> <!-- Map elements --> </map> Step 4 If you can't find the problem, then you could validate the file. There are services out there that validate XML files. They can help you to find out where your file is broken. Validation tool by W3C: https://validator.w3.org/#validate_by_input Note: You need to do step 3 first. Else you can't parse the file. Step 5 In case of re-opening map files in the editor, but doesn't want to get open. Make a backup. Remove custom elements. See chapter How to read? Retry to open the file. Editor is bugged, what to do? Your editor could be bugged and you are not able to save the map or open a new one. The first thing you want to do is backup the editor_dump folder in your server. This folder is located between all your resources. server\mods\deathmatch\resources\editor_dump Rename the folder name. editor_dump > my_broken_map Stop the map editor. Check if there is a new editor_dump folder. If there is, rename that one as well. Start the map editor again. Modify your maps outside of MTA Sometimes you want to modify your maps without going back in to the editor. Your text-editor is in most cases the way to go. For example you want to move all objects to a new dimension. In Notepad++: Make a backup! (if you are new to this) Select in your file the part you want to replace: dimension="0" Commando: ctrl + H (replacement overlay) Fill in the replace field: dimension="1" Click on: replace ALL. Moving your map? There is a nice online tool that can help you with that: https://mtaclub.eu/converters Edit your map with the DOM (Document Object Model) Knowing JavaScript? Your browser inspector can be used to modify your maps at a higher level. (If you so desire) Extra links: Parent, child and how this is reflected in MTA https://wiki.multitheftauto.com/wiki/XML https://wiki.multitheftauto.com/wiki/Element_tree Elementdata <sync_map_element_data /> https://wiki.multitheftauto.com/wiki/Meta.xml Load maps (manually + including in meta.xml) https://wiki.multitheftauto.com/wiki/Meta.xml https://wiki.multitheftauto.com/wiki/LoadMapData Save maps https://wiki.multitheftauto.com/wiki/SaveMapData
-
I want to create a "system" to update any xml (or only the vehicles.xml) without restart the Freeroam. Like, i create a second resource with alls xml's ex: resouce1: freeroam, resource2 = xmllist, then i put in xml options in freeroam, the ':xmllist/vehicles.xml' for example. (everything alright) But, when i restart the xmllist, do not update the freeroam, and i want create a command or a way to "refresh" the xml/gridlist. I found a way, but it "duplicate" the freeroam window. function testeeetalkei() wndCreateVehicle = { 'wnd', text = 'Create vehicle', width = 300, controls = { { 'lst', id='vehicles', width=280, height=340, columns={ {text='Vehicle', attr='name'} }, rows={xml=':xmllist/vehicles.xml', attrs={'id', 'name'}}, onitemdoubleclick=createSelectedVehicle, DoubleClickSpamProtected=true, }, {'btn', id='create', onclick=createSelectedVehicle, ClickSpamProtected=true}, {'btn', id='close', closeswindow=true} } } wndMain = { 'wnd', text = 'FR GUI', x = 10, y = 150, width = 280, controls = { {'lbl', text='Local player'}, {'br'}, {'btn', id='kill', onclick=killLocalPlayer}, {'btn', id='skin', window=wndSkin}, {'btn', id='anim', window=wndAnim}, {'btn', id='weapon', window=wndWeapon}, {'btn', id='clothes', window=wndClothes}, {'btn', id='playergrav', text='grav', window=wndGravity}, {'btn', id='warp', window=wndWarp}, {'btn', id='stats', window=wndStats}, {'btn', id='bookmarks', window=wndBookmarks}, {'br'}, {'chk', id='jetpack', onclick=toggleJetPack}, {'chk', id='falloff', text='fall off bike', onclick=toggleFallOffBike}, {'br'}, {'chk', id='disablewarp', text='disable warp', onclick=toggleWarping}, {'chk', id='disableknife', text='disable knifing', onclick=toggleKnifing}, {'chk', id='antiram', text='anti-ramming (vehicle ghostmode)', onclick=toggleGhostmode}, {'br'}, {'lbl', text='Pos:'}, {'lbl', id='xpos', text='x', width=45}, {'lbl', id='ypos', text='y', width=45}, {'lbl', id='zpos', text='z', width=45}, {'btn', id='setpos', text='map', window=wndSetPos}, {'btn', id='setinterior', text='int', window=wndSetInterior}, {'br'}, {'br'}, {'lbl', text='Vehicles'}, {'br'}, {'lbl', text='Current:'}, {'lbl', id='curvehicle'}, {'br'}, {'btn', id='createvehicle', window=wndCreateVehicle, text='create'}, {'btn', id='repair', onclick=repairVehicle}, {'btn', id='flip', onclick=flipVehicle}, {'btn', id='upgrades', window=wndUpgrades}, {'btn', id='color', onclick=openColorPicker}, {'btn', id='paintjob', window=wndPaintjob}, {'br'}, {'chk', id='lightson', text='Lights on', onclick=forceLightsOn}, {'chk', id='lightsoff', text='Lights off', onclick=forceLightsOff}, {'br'}, {'br'}, {'lbl', text='Environment'}, {'br'}, {'btn', id='time', window=wndTime}, {'chk', id='freezetime', text='freeze', onclick=toggleFreezeTime}, {'btn', id='weather', window=wndWeather}, {'btn', id='speed', window=wndGameSpeed} }, oncreate = mainWndShow, onclose = mainWndClose } createWindow(wndMain, true) hideAllWindows() end addCommandHandler('test', testeeetalkei) this way, i restart the xmllist resource and /test and works, but duplicate the window, anyone know how to do this without duplicate or create a function to delete old window or only update the xml? idk how to do it (note: this code is in fr_client.Lua (clientside)) (note2: found some functions that work with xml: function _buildWindow(wnd, baseWnd, parentWnd) -- at line 141 in gui.Lua -- some code... if wnd.rows then -- at line 227 if wnd.rows.xml then -- get rows from xml bindGridListToTable(wnd, not gridListHasCache(wnd) and xmlToTable(wnd.rows.xml, wnd.rows.attrs) or false, wnd.expandlastlevel or wnd.expandlastlevel == nil) else -- rows hardcoded in window definition bindGridListToTable(wnd, not gridListHasCache(wnd) and wnd.rows or false, false) end end --- etc.. end )
-
This is the dumbest question I've ever asked on this forum, but I have problem even not only with this. So, how can I add scripts from different folders in my meta.xml? And in these scripts, how can I load xml files from different folders, too? Any idea? If yes, please, show me example I know, that I would use xml = xmlLoadFile("filename.xml") But how to load xml in different folders? Same <script src="script.Lua" type="server"/> But how to tell MTA to load script from different folder?
-
I tried to load a file, that is in a subfolder, nothing's happening, no errors in console. What's the problem (all code below)? Line of code in script, to load xml file: xml = xmlLoadFile("cars/saved.xml") meta.xml: <file src="cars/saved.xml"/> What's wrong? BTW, everything exists. IDK what's wrong with this, everything's is existing, file is assigned into xml. I clearly don't know what's worng.
-
Tell me, what is better: MySQL, SQLite or XML? (You need to save (and retrieve) many user settings)
-
Hello Everybody ! Please help me to fix below script with XML file. There's a XML file called 'codes.xml'. Inside of that XML file looks like below. <pass characters="1234" allowed="true" /> <pass characters="5678" allowed="true" /> <pass characters="9012" allowed="true" /> Characters shown in above XML is used as a security key for open a certain door. Each character set can be used only once. There's a LUA script which is not completed yet can be seen below. function open(player, command, code) if code then --- addCommandHandler("pass",open) Well. If any player command as /pass 5678 , then the door will be open as security code is inserted in the previous XML file. But I need your help to make this work. * When a player command, how to check that the security code is inserted in XML file ? * When the security code is right, how to change corresponding allowed node to false ?
-
Buenas a todos, Me ha surgido una duda cuando trate trabajar por primera vez con archivos de tipo 'XML'. Bueno, lo que pasa es que al intentar crear un archivo XML con la función xmlCreateFile (función compartida) en un archivo lua de tipo "server" el XML se crea con normalidad y aparece en mi resource; pero cuando intento crearlo en un archivo lua tipo client éste no aparece en mi resource. ¿Alguien sabe el porque?, no me tira ningún error y al parecer ejecuta la función de manera correcta, ¿Tiene algún sentido esto? Muchas gracias.
-
Здравствуйте. Скачал я базу данных xml, долго редактировал под свой сервер. Дело в том что я запретил команду логин,регистер и т.д. Мне нужно что бы xml база запускалась не когда игрок залогиниться а когда зайдёт на сервер. local ALLOW_SAVE = true; local SAVE_TIME = 60; function onPlayerLogin(_,account) if not xmlLoadFile("users/"..getAccountName(account)..".xml") then local XMLROOT = xmlCreateFile("users/"..getAccountName(account)..".xml","user"); xmlCreateChild(XMLROOT, "Nickname") xmlCreateChild(XMLROOT, "Money") xmlCreateChild(XMLROOT, "Skin") xmlSaveFile(XMLROOT); xmlUnloadFile(XMLROOT); else local XMLROOT = xmlLoadFile("users/"..getAccountName(account)..".xml"); local Money = xmlNodeGetValue (xmlFindChild( XMLROOT, "Money", 0 )); local Skin = xmlNodeGetValue (xmlFindChild( XMLROOT, "Skin", 0 )); setPlayerMoney(source,Money); setElementModel(source,Skin); xmlSaveFile(XMLROOT); xmlUnloadFile(XMLROOT); end setElementData(source,"account:name",getAccountName(account)) end function onPlayerLogout() local XMLROOT = xmlLoadFile("users/"..getElementData(source,"account:name")..".xml"); if XMLROOT then xmlNodeSetValue (xmlFindChild( XMLROOT, "Money", 0), getPlayerMoney(source)); xmlNodeSetValue (xmlFindChild( XMLROOT, "Skin", 0), getElementModel(source)); xmlSaveFile(XMLROOT); xmlUnloadFile(XMLROOT); end end function saveAllAccounts() for key, thePlayer in ipairs(getElementsByType("player")) do local XMLROOT = xmlLoadFile("users/"..getElementData(thePlayer,"account:name")..".xml"); if XMLROOT then xmlNodeSetValue (xmlFindChild( XMLROOT, "Money", 0), getPlayerMoney(thePlayer)); xmlNodeSetValue (xmlFindChild( XMLROOT, "Skin", 0), getElementModel(thePlayer)); xmlSaveFile(XMLROOT); xmlUnloadFile(XMLROOT); end end print(" "); print(" *** All accounts are saved! / Все аккаунты сохранены ***"); print(" "); end if ALLOW_SAVE then setTimer(saveAllAccounts,SAVE_TIME*60000,0) end addEventHandler("onResourceStop", getResourceRootElement(),saveAllAccounts) addEventHandler("onPlayerLogin", root,onPlayerLogin) addEventHandler("onPlayerLogout", root,onPlayerLogout) addEventHandler("onPlayerQuit", root,onPlayerLogout) Исправьте код если не трудно.
-
Hello.I need that players do not register and the code is saved and joined to the server. Help please. local ALLOW_SAVE = true; local SAVE_TIME = 60; function onPlayerLogin(_,account) if not xmlLoadFile("users/"..getAccountName(account)..".xml") then local XMLROOT = xmlCreateFile("users/"..getAccountName(account)..".xml","user"); xmlCreateChild(XMLROOT, "Nickname") xmlCreateChild(XMLROOT, "Money") xmlCreateChild(XMLROOT, "Skin") xmlSaveFile(XMLROOT); xmlUnloadFile(XMLROOT); else local XMLROOT = xmlLoadFile("users/"..getAccountName(account)..".xml"); local Money = xmlNodeGetValue (xmlFindChild( XMLROOT, "Money", 0 )); local Skin = xmlNodeGetValue (xmlFindChild( XMLROOT, "Skin", 0 )); setPlayerMoney(source,Money); setElementModel(source,Skin); xmlSaveFile(XMLROOT); xmlUnloadFile(XMLROOT); end setElementData(source,"account:name",getAccountName(account)) end function onPlayerLogout() local XMLROOT = xmlLoadFile("users/"..getElementData(source,"account:name")..".xml"); if XMLROOT then xmlNodeSetValue (xmlFindChild( XMLROOT, "Money", 0), getPlayerMoney(source)); xmlNodeSetValue (xmlFindChild( XMLROOT, "Skin", 0), getElementModel(source)); xmlSaveFile(XMLROOT); xmlUnloadFile(XMLROOT); end end function saveAllAccounts() for key, thePlayer in ipairs(getElementsByType("player")) do local XMLROOT = xmlLoadFile("users/"..getElementData(thePlayer,"account:name")..".xml"); if XMLROOT then xmlNodeSetValue (xmlFindChild( XMLROOT, "Money", 0), getPlayerMoney(thePlayer)); xmlNodeSetValue (xmlFindChild( XMLROOT, "Skin", 0), getElementModel(thePlayer)); xmlSaveFile(XMLROOT); xmlUnloadFile(XMLROOT); end end print(" "); print(" *** All accounts are saved! / Все аккаунты сохранены ***"); print(" "); end if ALLOW_SAVE then setTimer(saveAllAccounts,SAVE_TIME*60000,0) end addEventHandler("onResourceStop", getResourceRootElement(),saveAllAccounts) addEventHandler("onPlayerLogin", root,onPlayerLogin) addEventHandler("onPlayerLogout", root,onPlayerLogout) addEventHandler("onPlayerQuit", root,onPlayerLogout)
-
السلام عليكم ورحمة الله وبركاتة كيف الحال ان شاء الله بخير انا الان بدي اسوي عملية نقل بيانات و اضن مو ضروري اقلكم الهدف حق النقل لأيش لانو ما رح يكون له فايدة بنسبة لطلبي انما انا بدي اعرف ايه افضل اني اخلي نفل البيانات من تطبيق اندرويد الى موقع باللغة Jason or XML والي يقلي واحدهمنهم يقلي ليش مشان استفيد واشوف اذا تتناسب مع الشغل حقي
-
Hello, I'm trying to pass my server side settings defined in my meta.xml to the client. However, when passing the table of XML data to the client, the data does not persist. Here's my server side code: addEvent("onClientRequestResourceSettings", true) addEventHandler("onClientRequestResourceSettings", resourceRoot, function() local xml = xmlLoadFile("meta.xml") local settingsNode = xmlFindChild(xml, "settings", 0) if(settingsNode) then local settings = xmlNodeGetChildren(settingsNode) triggerClientEvent(client, "onServerProvideResourceSettings", resourceRoot, settings) end xmlUnloadFile(xml) end ) That above event is called client side when the resource starts. Here's the client side code: addEvent("onServerProvideResourceSettings", true) addEventHandler("onServerProvideResourceSettings", resourceRoot, function(theSettings) iprint("Settings provided: "..inspect(theSettings)) --Output: "Settings provided: { }" end ) However my settings table is not being passed to the client. When printing the output, it appears to be an empty table. I'm aware there is a limitation of passing xml data to the client, however as this is in fact a table data type, I wouldn't of thought there would be an issue? Can anyone point me in the right direction, or perhaps provide some better solutions for passing settings data from the meta.xml to the client? Cheers.
-
Olá senhores. Estou fazendo um script cujo menu GUI é construído a partir de informações de um arquivo.xml No arquivo.xml, estão os textos que devem aparecer nos botões e texto do painel. O problema é que em alguns botões, preciso colocar quebra de linha. (\n) [contra-barra + N) Se eu criar um botão dentro do script.lua e colocar um texto com quebra de linha, funciona normal. Porém se eu obter esse mesmo texto com quebra de linha do arquivo.xml, ele carrega \n no lugar da quebra de linha, como se o \n deixasse de funcionar. buttons[i][k] = guiCreateButton (250, 50*(k-1)-30, 150, 40, xmlACLValues[i][2], false, PainelTAG) O valor xmlACLValues[2] é igual a "recruta\n(membro)" e foi obtido do arquivo.xml. O botão é criado corretamente, porém a quebra de linha não funciona e o botão fica assim: Se eu setar o texto de dentro do script.lua, dai a quebra de linha funciona normal usando a mesma string "recruta\n(membro)". xmlACLValues[i][2] = "recruta\n(membro)" buttons[i][k] = guiCreateButton (250, 50*(k-1)-30, 150, 40, xmlACLValues[i][2], false, PainelTAG) Alguém sabe por que ocorre isso e como resolver? Já tentei usar tostring, string.gsub (parece tolice substituir um \n por outro \n mas eu tava na esperança de ele criar um \n novo que funcione.) Obs: Eu sei que é possível evitar isso entupindo de espaços até a segunda parte ir pra baixo, mas eu não queria fazer gambiarras. Arquivo.xml:
-
Eu to editando meu painel de criar base e to antes nao tinha como alterar a senha da base pelo painel e acabei criando 1 so que que estou com problema na hora de salvar no xml no caso substituir a senha que ja conta no xml por uma nova veja se esta correto e por favor me ajuda a resolver addEvent("editGate",true) addEventHandler("editGate",getRootElement(),function(baseName,gateName,pass) local xml = xmlLoadFile("Bases.xml") for i,node in pairs(xmlNodeGetChildren(xml))do if xmlNodeGetName(node) == baseName then local gateInfo = xmlFindChild(node,"baseName") local gate = xmlFindChild(gateInfo,"Gates") local gates = xmlFindChild(gate,gateName:gsub(" ","Space"),0) if gates then xmlNodeSetAttribute(gates,"pass",pass) end xmlSaveFile(xml) alert("Base edited!",source) end end xmlUnloadFile(xml) refreshGates(baseName) end) um exemplo do meu xml é esse aqui quando salva <Gates> <PortãoSpacedaSpaceFrente X="-95.199996948242" Y="-2180.1999511719" Z="30.5" RX="0" RY="0" RZ="0" openMode="Up/Down" objectScale="1" moveScale="5" pass="1" modelID="2938"></PortãoSpacedaSpaceFrente> <Teto X="-38.799999237061" Y="-2180.3000488281" Z="37.590000152588" RX="0" RY="0" RZ="180" openMode="West/East" objectScale="1" moveScale="-30" pass="2" modelID="6959"></Teto> </Gates>
-
Hi .. I've made a vending machine mod and I'm trying to make it shows up on marker in XML design, I already took an example of what I need, the bank_system has one what I did is copying the xml server file in that mod and edit it to make it right, well its confusing to me because I'm new at this, I pasted the whole code just in case, The problem is might be in Xmlserver.lua, exactly right here: function bankInit( ) local xml_root = xmlLoadFile( "bar.locations.xml" ) local banks = 0 while( xmlFindChild( xml_root, "bank", banks ) ) do local markerSize local tempID = banks+1 banksInfo[ tempID ] = { } local bank_node = xmlFindChild( xml_root, "bank", banks ) banksInfo[ tempID ].name = xmlNodeGetAttribute( bank_node, "name" ) banksInfo[ tempID ].useBlip = xmlNodeGetAttribute( bank_node, "blip" ) or true local bank_loc = xmlFindChild( bank_node, "location", 0 ) banksInfo[ tempID ].posX = tonumber( xmlNodeGetAttribute( bank_loc, "posX" ) ) banksInfo[ tempID ].posY = tonumber( xmlNodeGetAttribute( bank_loc, "posY" ) ) banksInfo[ tempID ].posZ = tonumber( xmlNodeGetAttribute( bank_loc, "posZ" ) ) banksInfo[ tempID ].interior = tonumber( xmlNodeGetAttribute( bank_loc, "interior" ) ) or 0; markerSize = tonumber( xmlNodeGetAttribute( bank_loc, "markerSize" ) ) or 2 banksInfo[ tempID ].marker = createMarker( banksInfo[ tempID ].posX, banksInfo[ tempID ].posY, banksInfo[ tempID ].posZ-.9, "cylinder", markerSize, 250, 0, 0, 100 ) setElementInterior( banksInfo[ tempID ].marker, banksInfo[ tempID ].interior ); if xmlNodeGetAttribute( bank_loc, "ATM" ) == "true" then local rot = tonumber( xmlNodeGetAttribute( bank_loc, "ATMRot" ) ) or 0.0 local x, y, z = banksInfo[ tempID ].posX, banksInfo[ tempID ].posY, banksInfo[ tempID ].posZ x = x + math.sin( math.rad( rot ) ) * .6 y = y + math.cos( math.rad( rot ) ) * .6 banksInfo[ tempID ].ATM = createObject( 2942, x, y, z-.35, 0, 0, (360-rot) ) setElementInterior( banksInfo[ tempID ].ATM, tonumber( xmlNodeGetAttribute( bank_loc, "interior" ) ) or 0 ) setElementParent( banksInfo[ tempID ].ATM, banksInfo[ tempID ].marker ) end banks = banks + 1 end <banks> <bank name="Western Onion ATM" > <location posX="2630.6667480469" posY="1655.393046875" posZ="11.0234375" ATM="true" interior="0" ATMRot="180.0" markerSize="1" /> </bank> </banks> I did a few small edits to make it work, but I actually can't detect the problem and why this is not working, Any help is appreciated .
-
eu estou fazendo um sistema de salvamento XML so que preciso de ajuda, ele nao esta setando o level e o EXP quando do o comando ou quando eu logo podem me ajuda? Nunca mexi com o XML OPS: o "XLevel" ja esta com os itens salvo nele, so falta setar function LoadLevels() xml = xmlLoadFile("XLevel.xml") for i,node in pairs(xmlNodeGetChildren(xml)) do if xmlNodeGetAttribute(node,"Account") == getAccountName(getPlayerAccount(source)) then setElementData(source,"level",tonumber(xmlNodeGetAttribute(node,"LV"))) setElementData(source,"experience",tonumber(xmlNodeGetAttribute(node,"EX"))) end end xmlUnloadFile(xml) end addEventHandler("onPlayerLogin",getRootElement(),LoadLevels) addCommandHandler("loglev",LoadLevels)
- 12 replies
-
function getfolderNameAndScripts (folder) tables = {} local xml = xmlLoadFile("meta.xml") local Nodes = xmlNodeGetChildren(xml) for i,node in ipairs(Nodes) do if xmlNodeGetName(node) == "script" then local script_Name = xmlNodeGetAttribute(node, "src") table.insert(tables,script_Name) output = "resources\\"..folder.."\\"..tables[#tables].. "" end end xmlUnloadFile(xml) return output end outputServerLog(""..getfolderNameAndScripts("acl").."") --[[ the code it's working good but its output last file .lua in meta.xml resources/acl/clinet.lua doesn't output in server log resources/acl/s.lua doesn't output in server log resources/acl/server.lua this file output in server log --]]
-
He echarías una mano te lo ruego? Me solucionarías estas líneas?... function debugJump() if PedControlState("jump") then Aqui el error ---- attempt to call global ´PedControlState´ (a nil value) setElementData(getLocalPlayer(), "jumping", true) setTimer(debugJump2, 650, 1) end end setTimer(debugJump, 100, 0) function debugJump2() setElementData(getLocalPlayer(), "jumping", false) end Y luego esta parece ser el mismo error que el de arriba: function debugShooting() if PedControlState("fire") then -- Error-- attempt to call global ´PedControlState´ (a nil value) local weapon = getPedWeapon(getLocalPlayer()) local noise = getWeaponNoise(weapon) or 0 setElementData(getLocalPlayer(), "shooting", noise) if shootTimer then killTimer(shootTimer) end shootTimer = setTimer(debugShooting2, 100, 1) end end setTimer(debugShooting, 100, 0) function debugShooting2() setElementData(getLocalPlayer(), "shooting", 0) shootTimer = false end
-
So, heres my table local twonodes = {"login", "rpteszt"} local thirdnodes = {[twonodes[1]] = {"username","password", "rememberMe"}, [twonodes[2]]={"rpteszt"}} local values = {thirdnodes[twonodes[1]]={"false"}} Seems good, right?Yeah, for u,but not for Lua... ERROR: Loading script failed: loginpanel/loginpanelC:112: '}' expected near '=''
- 10 replies
-
- lua
- lua tables
-
(and 2 more)
Tagged with:
-
Hello, I would like to get the last updates by an xml file and write it in a memo. But ; for this I need to pass lines. My xml : <settings> <news>something \n other</news> </settings> server : -- Server : function showNews(source) local settings = xmlLoadFile(":script/settings.xml") triggerClientEvent(source,"shownews",source,xmlNodeGetValue(xmlFindChild(settings, "news", 0))) end -- I made a bind a bind to this function somewhere else in my script and it work so, it's not the problem client : -- Client : function showNews(news_) if news then destroyElement(news) else local screenW, screenH = guiGetScreenSize() news = guiCreateMemo((screenW - 505) / 2, (screenH - 304) / 2, 505, 304, news_, false) end end addEvent("shownews",true) addEventHandler("shownews",getLocalPlayer(),showNews) So, when I push my key who is bind, I can see the memo, I can see the text but, I would like to see it like this : "something other" not like this "something \n" Thanks !
-
client: local localPlayer = getLocalPlayer() local playerName = getPlayerName(localPlayer) function noBinds() guiSetInputMode("no_binds_when_editing") end addEventHandler("onClientResourceStart", root, noBinds) function createLoginWindow() windowLogin = guiCreateWindow(0.3945,0.3646,0.2109,0.2018,"Magyar Play Szerver - Loginpanel by turbesz",true) guiSetSize(windowLogin, 270, 175, false) guiSetAlpha(windowLogin,1) labelUsername = guiCreateLabel(10,52,59,24,"Felh.név:",false,windowLogin) guiSetAlpha(labelUsername,1) guiLabelSetColor(labelUsername,255,255,255) guiLabelSetVerticalAlign(labelUsername,"center") guiLabelSetHorizontalAlign(labelUsername,"left",false) labelPassword = guiCreateLabel(10,86,59,24,"Jelszó:",false,windowLogin) guiSetAlpha(labelPassword,1) guiLabelSetColor(labelPassword,255,255,255) guiLabelSetVerticalAlign(labelPassword,"center") guiLabelSetHorizontalAlign(labelPassword,"left",false) labelInfo = guiCreateLabel(10,26,250,17,"Regizz, és jelentkezz be a játékhoz.",false,windowLogin) guiSetAlpha(labelInfo,1) guiLabelSetColor(labelInfo,255,255,255) guiLabelSetVerticalAlign(labelInfo,"top") guiLabelSetHorizontalAlign(labelInfo,"center",false) guiSetFont(labelInfo,"default-bold-small") editUsername = guiCreateEdit(79,52,181,25,"",false,windowLogin) guiSetAlpha(editUsername,1) guiEditSetMaxLength(editUsername, 50) editPassword = guiCreateEdit(79,86,181,25,"",false,windowLogin) guiSetAlpha(editPassword,1) guiEditSetMasked(editPassword, true) guiEditSetMaxLength(editPassword, 50) buttonLogin = guiCreateButton(10,121,120,21,"Bejelentkezés",false,windowLogin) guiSetAlpha(buttonLogin,1) buttonRegister = guiCreateButton(143,121,117,21,"Regisztrálás",false,windowLogin) guiSetAlpha(buttonRegister,1) buttonGuest = guiCreateButton(10,145,121,21,"Vendég",false,windowLogin) guiSetAlpha(buttonGuest,1) checkbox_save = guiCreateCheckBox(157,145,117,21,"Adatok mentése",false,false,windowLogin) guiSetFont(checkbox_save,"default-small") guiWindowSetSizable ( windowLogin, false ) guiSetVisible(windowLogin, false) addEventHandler("onClientGUIClick", buttonLogin, clientSubmitLogin, false) addEventHandler("onClientGUIClick", buttonRegister, clientSubmitRegister, false) local username, password = loadLoginFromXML() if not( username == "" or password == "") then guiCheckBoxSetSelected ( checkbox_save, true ) guiSetText ( editUsername, tostring(username)) guiSetText ( editPassword, tostring(password)) else guiCheckBoxSetSelected ( checkbox_save, false ) guiSetText ( editUsername, tostring(username)) guiSetText ( editPassword, tostring(password)) end end function loadLoginFromXML() local xml_save_log_File = xmlLoadFile ("files/xml/adatok.xml") if not xml_save_log_File then xml_save_log_File = xmlCreateFile("files/xml/adatok.xml", "login") end local usernameNode = xmlFindChild (xml_save_log_File, "username", 0) local passwordNode = xmlFindChild (xml_save_log_File, "password", 0) if usernameNode and passwordNode then return xmlNodeGetValue(usernameNode), xmlNodeGetValue(passwordNode) else return "", "" end xmlUnloadFile ( xml_save_log_File ) end function saveLoginToXML(username, password) local xml_save_log_File = xmlLoadFile ("files/xml/adatok.xml") if not xml_save_log_File then xml_save_log_File = xmlCreateFile("files/xml/adatok.xml", "login") end if (username ~= "") then local usernameNode = xmlFindChild (xml_save_log_File, "username", 0) if not usernameNode then usernameNode = xmlCreateChild(xml_save_log_File, "username") end xmlNodeSetValue (usernameNode, tostring(username)) end if (password ~= "") then local passwordNode = xmlFindChild (xml_save_log_File, "password", 0) if not passwordNode then passwordNode = xmlCreateChild(xml_save_log_File, "password") end xmlNodeSetValue (passwordNode, tostring(password)) end xmlSaveFile(xml_save_log_File) xmlUnloadFile (xml_save_log_File) end addEvent("saveLoginToXML", true) addEventHandler("saveLoginToXML", getRootElement(), saveLoginToXML) function resetSaveXML() local xml_save_log_File = xmlLoadFile ("files/xml/adatok.xml") if not xml_save_log_File then xml_save_log_File = xmlCreateFile("files/xml/adatok.xml", "login") end if (username ~= "") then local usernameNode = xmlFindChild (xml_save_log_File, "username", 0) if not usernameNode then usernameNode = xmlCreateChild(xml_save_log_File, "username") end end if (password ~= "") then local passwordNode = xmlFindChild (xml_save_log_File, "password", 0) if not passwordNode then passwordNode = xmlCreateChild(xml_save_log_File, "password") end xmlNodeSetValue (passwordNode, "") end xmlSaveFile(xml_save_log_File) xmlUnloadFile (xml_save_log_File) end addEvent("resetSaveXML", true) addEventHandler("resetSaveXML", getRootElement(), resetSaveXML) addEventHandler("onClientGUIClick",root, function () if source == buttonGuest then guiSetVisible ( windowLogin , false ) showCursor(false) end end ) function resourceStart() createLoginWindow() if (windowLogin ~= nil) then guiSetVisible(windowLogin, true) else outputChatBox("Whoops, valami error történt.") end showCursor(true) guiSetInputEnabled(true) end function clientSubmitLogin(button, state) if button == "left" and state == "up" then local username = guiGetText(editUsername) local password = guiGetText(editPassword) if username and password then triggerServerEvent("submitLogin", getRootElement(), localPlayer, username, password) else guiSetText(labelInfo, "Írj be felh.nevet és jelszót.") end end end function clientSubmitRegister(button, state) if button == "left" and state == "up" then local username = guiGetText(editUsername) local password = guiGetText(editPassword) if username and password then triggerServerEvent("submitRegister", getRootElement(), localPlayer, username, password) else guiSetText(labelInfo, "Írj be felh.nevet és jelszót.") end end end function hideLoginWindow() guiSetInputEnabled(false) guiSetVisible(windowLogin, false) showCursor(false) end function unknownError() guiSetText(labelInfo, "Ismeretlen hiba.") end function loginWrong() guiSetText(labelInfo, "Hibás adatok.") end function registerTaken() guiSetText(labelInfo, "Felhasználó név regisztrálva van.") end addEvent("hideLoginWindow", true) addEvent("unknownError", true) addEvent("loginWrong", true) addEvent("registerTaken", true) addEventHandler("hideLoginWindow", getRootElement(), hideLoginWindow) addEventHandler("unknownError", getRootElement(), unknownError) addEventHandler("loginWrong", getRootElement(), loginWrong) addEventHandler("registerTaken", getRootElement(), registerTaken) addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), resourceStart) fileDelete("client.lua") server: function loginHandler(player, username, password, checksave) local account = getAccount(username, password) if (account ~= false) then if (logIn(player, account, password) == true) then triggerClientEvent (player, "hideLoginWindow", getRootElement()) if checksave == true then triggerClientEvent(source,"saveLoginToXML",getRootElement(),username,password) else triggerClientEvent(source,"resetSaveXML",getRootElement(),username,password) end else triggerClientEvent (player, "unknownError", getRootElement()) end else triggerClientEvent (player, "loginWrong", getRootElement()) end end function registerHandler(player, username, password) local account = getAccount(username, password) if (account ~= false) then triggerClientEvent(player, "registerTaken", getRootElement()) else account = addAccount(username, password) if (logIn(player, account, password) == true) then triggerClientEvent(player, "hideLoginWindow", getRootElement()) else triggerClientEvent(player, "unknownError", getRootElement()) end end end addEvent("submitLogin", true) addEvent("submitRegister", true) addEventHandler("submitLogin", root, loginHandler) addEventHandler("submitRegister", root, registerHandler) why not save?
-
addEventHandler ( "onClientGUIDoubleClick", root, function ( ) local Selected = guiGridListGetSelectedItem ( GUIEditor.gridlist[7] ) local GetText = guiGridListGetItemText( GUIEditor.gridlist[7], Selected, 2 ) if source == GUIEditor.gridlist[7] then for Index, Node in ipairs ( xmlNodeGetChildren ( xml2 ) ) do if GetText == xmlNodeGetAttribute ( Node, "name" ) then guiGridListClear ( GUIEditor.gridlist[7] ) for Index, Node in ipairs ( xmlNodeGetChildren ( Node ) ) do local mk=Node or xmlNodeGetChildren ( Node ) local Row = guiGridListAddRow ( GUIEditor.gridlist[7] ) guiGridListSetItemText ( GUIEditor.gridlist[7], Row, 1, "#" .. Index, false, false ) guiGridListSetItemText ( GUIEditor.gridlist[7], Row, 2, xmlNodeGetAttribute ( mk, "name" ), false, false ) guiGridListSetItemData ( GUIEditor.gridlist[7], Row, 2, xmlNodeGetAttribute ( mk, "id" )) guiGridListSetItemColor ( GUIEditor.gridlist[7], Row, 1, 0, 191, 253 ) guiGridListSetItemColor ( GUIEditor.gridlist[7], Row, 2, 0, 191, 253 ) end elseif GetText == "..." then guiGridListClear ( GUIEditor.gridlist[7] ) for Index, Node in ipairs ( xmlNodeGetChildren ( xml2 ) ) do local Row = guiGridListAddRow ( GUIEditor.gridlist[7] ) guiGridListSetItemText ( GUIEditor.gridlist[7], Row, 1, "#" .. Index, false, false ) guiGridListSetItemText ( GUIEditor.gridlist[7], Row, 2, xmlNodeGetAttribute ( Node, "name" ), false, false ) guiGridListSetItemColor ( GUIEditor.gridlist[7], Row, 1, 0, 191, 253 ) guiGridListSetItemColor ( GUIEditor.gridlist[7], Row, 2, 0, 191, 253 ) end else if guiGridListGetItemData(GUIEditor.gridlist[7], Selected, 2) then local x,y,z=getElementPosition(lpl) local veh = createVehicle ( guiGridListGetItemData(GUIEditor.gridlist[7], Selected, 2), x+1.5, y+1.5, z+1.5, 0, 0, 0 ) end end end end end ) ما بطول عليكم الكود شغال لكن يجيب اكثر من سياره هل اقدر اعرف السبب