Rat32 Posted August 19, 2016 Share Posted August 19, 2016 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. Link to comment
Simple0x47 Posted August 20, 2016 Share Posted August 20, 2016 You've got to get the mod files and add them automaticaly to the meta.xml Link to comment
G-Stefan Posted August 20, 2016 Share Posted August 20, 2016 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
Rat32 Posted August 20, 2016 Author Share Posted August 20, 2016 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
G-Stefan Posted August 20, 2016 Share Posted August 20, 2016 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
Rat32 Posted August 20, 2016 Author Share Posted August 20, 2016 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. Link to comment
G-Stefan Posted August 20, 2016 Share Posted August 20, 2016 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
Rat32 Posted August 20, 2016 Author Share Posted August 20, 2016 Ok, but how to get all this files without manual checking in script? Link to comment
Rat32 Posted August 20, 2016 Author Share Posted August 20, 2016 Is on community ModLoader script - it's working like that. Link to comment
G-Stefan Posted August 20, 2016 Share Posted August 20, 2016 Is on community ModLoader script - it's working like that. Modloader has the file names in tables Just look at data.lua and you'll see Format fileName=modelID It checks if the fileName.extension exist and if it exists he saves the file in meta Link to comment
Rat32 Posted August 20, 2016 Author Share Posted August 20, 2016 Ah, exatly. OK - thank you very much! Link to comment
G-Stefan Posted August 20, 2016 Share Posted August 20, 2016 Ah, exatly. OK - thank you very much! It was my pleasure 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