Jump to content

Automatic replace


Rat32

Recommended Posts

Hello. I'm trying to create script like ModLoader.

Task: adding dff and txd to folder and loading to script and replacing without adding this to meta.xml

What functions I must use?

Sorry for my bad English.

First of all you must make tables for valid models

  
validVehicles = {  
 fileName = vehID 
--fileName is the gta sa .txd, .dff file name and vehID is the veh id 
} 
  

Next you should loop thru the table and see if the fileName exists

  
for i,v in pairs (validVehicles) do  
      if fileExists(tostring(i)..".dff") and fileExists(tostring(i)..".txd") then 
            table.insert(existingFiles,tostring(i),v) 
--we save all the exising files in a table 
      end 
end 
  

Next,we must insert the existing files in meta.xml

  
local metaConnection=xmlLoadFile("meta.xml") 
for i,v in pairs (existingFiles) do 
      local newChild = xmlCreateChild(metaConnection,"file") 
      xmlNodeSetAttribute(newChild,"src",tostring(i)..".dff") 
--same with the txd file 
  

After that we must trigger a client event to load the models

Look at the evey fuction explination

Edit:Here are the funcs

CLIENT

  
engineLoadTXD 
engineLoadDFF 
engineReplaceModel 
  

SERVER

  
xmlLoadFile 
xmlCreateChild 
xmlNodeSetAttribute 
  
fileExists 
  
restartResource 
getThisResource 
  

Link to comment

Hm, okay okay - this is good, but I have another idea - i will create a automatic read files from folder, without insert him to .xml or table. I will create auto-read a folder in the script and auto replacing all files from there. Is the way to make this?

Link to comment
Hm, okay okay - this is good, but I have another idea - i will create a automatic read files from folder, without insert him to .xml or table. I will create auto-read a folder in the script and auto replacing all files from there. Is the way to make this?

I am not sure if replacing would work while the file is not in meta

Link to comment
I know, but is the way to get files inside the folder? I need function like this:
table getFilesInFolder(path)  

- i know, this function is not exist, but i need function like this.

At every file functions you have to specify the file name/path

I think the only solution is to write the files in a table

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