Search the Community

Showing results for tags 'xml'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Multi Theft Auto: San Andreas 1.x
    • Support for MTA:SA 1.x
    • User Guides
    • Open Source Contributors
    • Suggestions
    • Ban appeals
  • General MTA
    • News
    • Media
    • Site/Forum/Discord/Mantis/Wiki related
    • MTA Chat
    • Other languages
  • MTA Community
    • Scripting
    • Maps
    • Resources
    • Other Creations & GTA modding
    • Competitive gameplay
    • Servers
  • Other
  • Archive
  • Private Bugtracker

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


About Me


Gang


Location


Occupation


Interests

Found 22 results

  1. Tell me, what is better: MySQL, SQLite or XML? (You need to save (and retrieve) many user settings)
  2. Z4Zy

    Fix XML

    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 ?
  3. 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.
  4. anufis_ok

    XML

    Здравствуйте. Скачал я базу данных 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) Исправьте код если не трудно.
  5. anufis_ok

    XML Join

    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)
  6. السلام عليكم ورحمة الله وبركاتة كيف الحال ان شاء الله بخير انا الان بدي اسوي عملية نقل بيانات و اضن مو ضروري اقلكم الهدف حق النقل لأيش لانو ما رح يكون له فايدة بنسبة لطلبي انما انا بدي اعرف ايه افضل اني اخلي نفل البيانات من تطبيق اندرويد الى موقع باللغة Jason or XML والي يقلي واحدهمنهم يقلي ليش مشان استفيد واشوف اذا تتناسب مع الشغل حقي
  7. 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.
  8. 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:
  9. 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>
  10. i want save grid list rows to xml, and load from xml.. but how to make this?
  11. 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 .
  12. 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)
  13. Ahmed Ly

    help [xml]

    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 --]]
  14. 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
  15. 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 '=''
  16. 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 !
  17. 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?
  18. 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 ) ما بطول عليكم الكود شغال لكن يجيب اكثر من سياره هل اقدر اعرف السبب
  19. سلام عليكم ورحمة الله وبركاته شباب سؤال فقط كيف اسوي جريد لست فيها رو الرو هذا جبته من xml زي الفري روم مثلا
  20. Hi there, I am trying to implement a error system, and i am stuck on the problem, that xmlCreateChild overwrites the old node and so i cant get an error-list. Here is the Code: [lua]--------------------------------------------------Fehler in XML speichern-------------------------------------------------- function registerError( errorType, errorDescription ) local xmlErrorLog = xmlLoadFile( "errorLog.xml" ) if xmlErrorLog == false then xmlErrorLog = xmlCreateFile( "errorLog.xml", "errors" ) end local time = getRealTime( ) -- Die Zeit des Fehlers local timeString = "" .. time["year"]+1900 .. "." .. time["month"]+1 .. "." .. time["monthday"] .. "-" .. time["hour"] .. "." .. time["minute"] .. "." .. time["second"] local xmlNewError = xmlCreateChild( xmlErrorLog, timeString ) xmlNodeSetAttribute( xmlNewError, "type", errorType ) xmlNodeSetAttribute( xmlNewError, "description", errorDescription ) xmlSaveFile( xmlErrorLog ) xmlUnloadFile( xmlErrorLog ) end addEvent( "registerError" ) addEventHandler( "registerError", root, registerError )[/lua] The node should have been the timestamp, as the "new" node needs a new name, but it doesnt work (old nodes get overwriten). Edit: and somehow the [lua] [/lua] code syntax does not work? Sorry for that too!
  21. Hello guys! I have a weir issu (or just i don't see what is the problem) So i wanted to write a script which saves a table. But if i call my saveTable method it doesn't load the xml file just create one then overwrite it. And i don't have a clue why... function open( path, version ) --outputDebugString("XML: open called", 1) outputDebugString(rootNode, 1) rootNode = xmlLoadFile(path) outputDebugString(rootNode, 1) if (not rootNode) then outputDebugString(path) rootNode = xmlCreateFile(path, "root") xmlNodeSetAttribute(rootNode, "version", version) xmlCreateChild(rootNode, "tables") outputDebugString("XML: rootNode created", 2) else outputDebugString("XML: rootNode exist",2) local _version = xmlNodeGetAttribute (rootNode, "version") if(tostring(version) ~= _version) then close() outputDebugString("XML: Deleted",2) fileDelete(path) open(path, version) end end end function close( ) xmlSaveFile (rootNode) xmlUnloadFile (rootNode) rootNode = nil outputDebugString("XML: Save and Unload") end function saveTable (path, table, name, version) open(path, version) outputDebugString(rootNode) local tableNode = xmlCreateChildIfNotExist(xmlFindChild(rootNode, "tables", 0), name) outputDebugString(rootNode) saveTableRecursive(path, table, name, tableNode) outputDebugString(rootNode) close() outputDebugString("XML: Table lementve") end function saveTableRecursive (path, table, name, node) for k,v in pairs(table) do local vType = type(v) if (vType == "table") then local newNode = xmlCreateChild(node, k) outputDebugString("XML: Table recurssive") saveTableRecursive (path, v, name, newNode) elseif( (vType == "string") or (vType == "number") or (vType == "boolean") ) then local insertValue = xmlCreateChild(node, k) xmlNodeSetAttribute(insertValue, "type", vType) xmlNodeSetValue(insertValue, tostring(v)) else outputDebugString("XML: Not supported type: "..vType, 1) end end end function xmlCreateChildIfNotExist(parentNode, tagName) local child = xmlFindChild(parentNode, tagName, 0) if not child then child = xmlCreateChild(parentNode, tagName) end return child end local asd = { {x=2, y=5, width=100, height = 200}, {x=44, y=50, width=100, height = 30}, ["test"] = {x=2, y = 5, width = 100, height = false}, } saveTable(":xml/test1.xml", asd, "tesztTable", "1.0") saveTable(":xml/test1.xml", asd, "tesztTable2", "1.0") It fails on line 4. rootNode will be false. What do i do wrong or it is a known issue? PS.: If a got to the file open it and delete a few rows it founds it somewhy.
  22. Hey , this is my code , He don't create the XML file and i tried this : ( Only Client ) function createXML() if source == vehPanel.button[1] then settings = xmlCreateFile("savedsettings.xml","settings") if guiCheckBoxGetSelected(vehPanel.checkbox[1]) then xmlNodeSetAttribute(settings, "car", "true") else xmlNodeSetAttribute(settings, "car", "false") end end addEventHandler("onClientGUIClick", getRootElement(), createXML) And this : function createXML() settings = xmlCreateFile("savedsettings.xml","settings") if guiCheckBoxGetSelected(vehPanel.checkbox[1]) then xmlNodeSetAttribute(settings, "car", "true") else xmlNodeSetAttribute(settings, "car", "false") end end addEventHandler("onClientResourceStart", getRootElement(), createXML) And this : function createXML() local exists = fileExists ( "savedsettings.xml" ) if not exists then settings = xmlCreateFile("savedsettings.xml","settings") if guiCheckBoxGetSelected(vehPanel.checkbox[1]) then xmlNodeSetAttribute(settings, "car", "true") else xmlNodeSetAttribute(settings, "car", "false") end end addEventHandler("onClientResourceStart", getRootElement(), createXML) And no one create xml , i need some help please , this is the end code : function load() local currentFile = xmlLoadFile ("savedsettings.xml") if xmlNodeGetAttribute(currentFile, "car") == "true" then guiCheckBoxSetSelected(vehPanel.checkbox[1], true) veh1() end end load()