Jump to content

xml مساعدة بال


KaduRo

Recommended Posts

السلام عليكم

محتاج توضيح لل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 by Guest
Link to comment

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

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
  
  local xmlFile = xmlLoadFile ("testing.xml") or xmlCreateFile ( "testing.xml", "Players") -- 
     local PlayerData = xmlFindChild (xmlFile, acc, 0) or xmlCreateChild (xmlFile, acc) 
  

هذا الكودين استخدمتهم بدون تحقق ؟

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...