KaduRo Posted February 28, 2015 Share Posted February 28, 2015 (edited) السلام عليكم محتاج توضيح للxml وكيفية استخدامها , انا حاولت اجرب المثال في الويكي , بس تطلع لي مشكلة @xmlNodeGetAttribute [expected xml-node at argument 1 , got boolean] وطبعآ تظهر لي لكل xmlNodeGetAttribute استخدمته وهذا الكود كما نسخته xml - "528" posX="123.4" posY="456.7" posZ="12.3" rot="90.0" /> lua - server side - الكود القديم (فيها المشكلة ) ء local xml = getResourceConfig("testing.xml") -- غيرت اسم الملف هنا local carmodel = xmlNodeGetAttribute(xml, "model") local carX = xmlNodeGetAttribute(xml, "posX") local carY = xmlNodeGetAttribute(xml, "posY") local carZ = xmlNodeGetAttribute(xml, "posZ") local carA = xmlNodeGetAttribute(xml, "rot") outputChatBox(tostring(carX)) الكود الجديد بعد حلها local xml = xmlLoadFile("testing.xml") -- هنا ابحث عن الملف local Child = xmlFindChild(xml , "car" , 0) -- استخرجت الجزء "سيارة" من الملف local carmodel = xmlNodeGetAttribute(Child, "model") -- واضفته في الملفات local carX = xmlNodeGetAttribute(Child, "posX") local carY = xmlNodeGetAttribute(Child, "posY") local carZ = xmlNodeGetAttribute(Child, "posZ") local carA = xmlNodeGetAttribute(Child, "rot") outputChatBox(tostring(carX)) -- تحربة الملف Edited February 28, 2015 by Guest Link to comment
KaduRo Posted February 28, 2015 Author Share Posted February 28, 2015 عفوآ , تم حل المشكلة , وشرحها فوق ! Link to comment
KaduRo Posted February 28, 2015 Author Share Posted February 28, 2015 xmlطيب يا شباب تجيني مشكلة , تصيب ملف ال Resource 'ملف السكربت' start was requested (Failed to start resource item testing.xml which is required) وهذا الكود addCommandHandler("1" , function (source) local xmlFile = xmlLoadFile("testing.xml") local PlayerData = xmlFindChild(xmlFile , tostring(getAccountName(getPlayerAccount(source))) , 0) if not PlayerData then PlayerData = xmlCreateChild(xmlFile , tostring(getAccountName(getPlayerAccount(source)))) local PlayerMoney = xmlNodeSetAttribute(PlayerData , "Money" , getPlayerMoney(source)) end PlayerMoney = xmlNodeGetAttribute(PlayerData , "Money") xmlNodeSetAttribute(PlayerData , "Money " , getPlayerMoney(source)) xmlSaveFile(xmlFile) xmlUnloadFile(xmlFile) end ) بعد تشغيل السكربت xmlملف ال "1000" Money="1000" >-- طبعآ هنا غيرت الاكاونت طبعآ اول شيء يكون الا اكس ام ال فارغ , وبعد ما اسوي السكربت يحفظ البيانات , ولما اعيد تشغيل السكربت يخرب السكربت + كيف اقدر امنع تكرار Money ? Link to comment
KaduRo Posted March 1, 2015 Author Share Posted March 1, 2015 ممكن احد يشوف حل للمشكلة , او يعلمني الطريقة شلون ؟ Link to comment
The Killer Posted March 1, 2015 Share Posted March 1, 2015 addCommandHandler("1", function (plr) if not isGuestAccount (getPlayerAccount (plr)) then local xmlFile = xmlLoadFile ("testing.xml") or xmlCreateFile ( "testing.xml", "Players") local acc = getAccountName(getPlayerAccount(plr)) local PlayerData = xmlFindChild (xmlFile, acc, 0) or xmlCreateChild (xmlFile, acc) local PlayerMoney = xmlNodeGetAttribute (PlayerData, "Money") xmlNodeSetAttribute (PlayerData, "Money", getPlayerMoney(plr)) xmlSaveFile (xmlFile) xmlUnloadFile (xmlFile) end end ) Link to comment
KaduRo Posted March 1, 2015 Author Share Posted March 1, 2015 local xmlFile = xmlLoadFile ("testing.xml") or xmlCreateFile ( "testing.xml", "Players") -- local PlayerData = xmlFindChild (xmlFile, acc, 0) or xmlCreateChild (xmlFile, acc) هذا الكودين استخدمتهم بدون تحقق ؟ Link to comment
The Killer Posted March 1, 2015 Share Posted March 1, 2015 if هنا اضفت تحقق , بدون بحيث انه يتحقق اذا كان الملف الموجود , لو مو موجود يصنع واحد ثاني if بشكل اسرع , بدون اضافة 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