Jump to content

[Help]xmlLoadFile Furniture list مشكلة تحميل الملف


#Hulk

Recommended Posts

18 hours ago, Default#^ said:

'onClientDoubleClick'
guiGridListGetSelectedItem
guiGridListGetItemText
getElementPosition
triggerServerEvent
createObject

 

--Client
local screenW, screenH = guiGetScreenSize()
wnd2 = guiCreateWindow((screenW - 276) / 2, (screenH - 338) / 2, 276, 338, "Furniture System List", false)
guiWindowSetSizable(wnd2, false)
guiSetVisible(wnd2,false)
gr1 = guiCreateGridList(9, 24, 257, 231, false, wnd2)
guiGridListAddColumn(gr1, "ID", 0.5)
col = guiGridListAddColumn(gr1, "Name", 0.5)
getit = guiCreateButton(75, 265, 127, 28, "Get it", false, wnd2)
cl2 = guiCreateButton(75, 300, 127, 28, "Close", false, wnd2)
guiGridListSetSelectionMode(gr1,2)


addEventHandler( "onClientGUIDoubleClick", gr1,
addEventHandler('onClientGUIClick',getit,
function()
if source == getit then
guiGridListGetItemText ( gr1, guiGridListGetSelectedItem ( gr1 ), 1 )
triggerServerEvent('send',localPlayer,x,y,z)
end
end
)
)

function getXMLNodes(xmlfile,nodename)
   local xml = xmlLoadFile(xmlfile)
   if xml then
      local ntable={}
      local a = 0
      while xmlFindChild(xml,nodename,a) do
         table.insert(ntable,a+1)
         ntable[a+1]={}
         local attrs = xmlNodeGetAttributes ( xmlFindChild(xml,nodename,a) )
         for name,value in pairs ( attrs ) do
            table.insert(ntable[a+1],name)
            ntable[a+1][name]=value
         end
         
         ntable[a+1]["nodevalue"]=xmlNodeGetValue(xmlFindChild(xml,nodename,a))
 
         a=a+1
      end
      return ntable
   else
      return {}
   end
end

for k,v in ipairs ( getXMLNodes ( "objects.xml" , "obj" ) ) do 
local row = guiGridListAddRow ( gr1 ) ;
guiGridListSetItemText ( gr1 , row , 1 , v.name , false , false ) 
guiGridListSetItemText ( gr1 , row , 2 , v.model , false , false ) 
guiGridListGetItemText ( gr1, guiGridListGetSelectedItem ( gr1 ), 1 )
end



----Server
addEvent('send',true)
addEventHandler('send',root,
function(gr1)
getElementPosition ( theObject )
position = Vector3 (getElementPosition (localPlayer))
theObject = createObject ( 1491, position.x , position.y +5, position.z, 0, 0, 0 )
end
)

الخطأ مخربط الاكواد + لو ابي اجيب الاوبكت من الايدي حقه من الxml استخدم getObjectModel ? Or getElementModel ?

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...