Ruga Posted January 31, 2013 Share Posted January 31, 2013 (edited) код должен сохранять пароль и логин зарег-ся игроков, дебаг молчит, а код не работает(( вот код xml если нужно скину весь скрипт function loadLoginFromXML() local xmlsavelogFile = xmlLoadFile ("files/xml/userdata.xml") if not xmlsavelogFile then xmlsavelogFile = xmlCreateFile("files/xml/userdata.xml", "login") end local usernameNode = xmlFindChild (xmlsavelogFile, "username") local passwordNode = xmlFindChild (xmlsavelogFile, "password") if usernameNode and passwordNode then return xmlNodeGetValue(usernameNode), xmlNodeGetValue(passwordNode) else return "", "" end xmlUnloadFile ( xmlsavelogFile ) end function saveLoginToXML(username, password) local xmlsavelogFile = xmlLoadFile ("files/xml/userdata.xml") if not xmlsavelogFile then xmlsavelogFile = xmlCreateFile("files/xml/userdata.xml", "login") end if (username ~= "") then local usernameNode = xmlFindChild (xmlsavelogFile, "username") if not usernameNode then usernameNode = xmlCreateChild(xmlsavelogFile, "username") end xmlNodeSetValue (usernameNode, tostring(username)) end if (password ~= "") then local passwordNode = xmlFindChild (xmlsavelogFile, "password") if not passwordNode then passwordNode = xmlCreateChild(xmlsavelogFile, "password") end xmlNodeSetValue (passwordNode, tostring(password)) end xmlSaveFile(xmlsavelogFile) xmlUnloadFile (xmlsavelogFile) end addEvent("saveLoginToXML", true) addEventHandler("saveLoginToXML", getRootElement(), saveLoginToXML) function resetSaveXML() local xmlsavelogFile = xmlLoadFile ("files/xml/userdata.xml") if not xmlsavelogFile then xmlsavelogFile = xmlCreateFile("files/xml/userdata.xml", "login") end if (username ~= "") then local usernameNode = xmlFindChild (xmlsavelogFile, "username") if not usernameNode then usernameNode = xmlCreateChild(xmlsavelogFile, "username") end end if (password ~= "") then local passwordNode = xmlFindChild (xmlsavelogFile, "password") if not passwordNode then passwordNode = xmlCreateChild(xmlsavelogFile, "password") end xmlNodeSetValue (passwordNode, "") end xmlSaveFile(xmlsavelogFile) xmlUnloadFile (xmlsavelogFile) end addEvent("resetSaveXML") addEventHandler("resetSaveXML", getRootElement(), resetSaveXML) Edited March 27, 2013 by Guest Link to comment
DakiLLa Posted January 31, 2013 Share Posted January 31, 2013 local usernameNode = xmlFindChild (xmlsavelogFile, "username", 0) local passwordNode = xmlFindChild (xmlsavelogFile, "password", 0) Попробуйте так. Link to comment
Ruga Posted February 4, 2013 Author Share Posted February 4, 2013 не удаеться решить проблему, что есть nil что нет, жуть Link to comment
Kenix Posted February 5, 2013 Share Posted February 5, 2013 https://forum.multitheftauto.com/viewtop ... 332d3c7145 И так же у функции xmlFindChild 3ий аргумент - обязательный. Link to comment
Ruga Posted March 27, 2013 Author Share Posted March 27, 2013 ошибки исправил, но все равно отказался от этого скрипта, за советы спасибо)))) Link to comment
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