Jump to content

XML file function


Piorun

Recommended Posts

Hi

My code

  
function deleteVeh(source) 
   if isPedInVehicle(source) then 
      local veh = getPedOccupiedVehicle(source) 
      local data = getElementData(veh, "datanum") 
      if data then 
         local xmlfile = xmlLoadFile("veh.xml") 
         for i, node in ipairs(xmlNodeGetChildren(xmlfile)) do 
            local datanode = xmlNodeGetAttribute(node, "datanum") 
            if data == datanode then 
               local result = xmlDestroyNode(node) 
               xmlSaveFile(xmlfile) 
               destroyElement(veh) 
            end 
         end             
      end 
   end     
end 
addCommandHandler("usunauto", deleteVeh) 
  

Is working when i restart resource. In other functions i've got creating a vehicle and saveing few info into xml file. When i create a veh and enter to it this function doesn't work, but when i restart resource and enter again - it's working. Why?

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