Jump to content

Load dff, txd, col


Reda_Iq

Recommended Posts

local txd = {}
local dff = {}
local col = {}

txd[1] = engineLoadTXD ( "mod1.txd" )
engineImportTXD ( txd[1], 3356 )
dff[1]= engineLoadDFF ( "mod1.dff" )
engineReplaceModel ( dff[1], 3356 )
col[1] = engineLoadCOL( "mod1.col" )
engineReplaceCOL( col[1], 3356 )

txd[2] = engineLoadTXD ( "mod2.txd" )
engineImportTXD ( txd[2], 3357 )
dff[2] = engineLoadDFF ( "mod2.dff" )
engineReplaceModel ( dff[2], 3357 )
col[2] = engineLoadCOL( "mod2.col" )
engineReplaceCOL( col[2], 3357 )

just an example

Is not required to put local txd = {}, you can put txd1, txd2 etc.. but it's more easy to do like the example above.

  • Like 1
Link to comment

Hello,

I think the interest to use table is to loop them so I wonder if it's more optimized to do for example that way :

Hydra answer is totally fine, I just wanted to contribute. :)

I did not test the script, hope I did not make any mistakes.

local models = {
	[3356] = "mod1",
	[3357] = "mod2",
	[3358] = "mod3"
  	-- [model id] = "name of files" (In this example, txd, col and dff need to have the same name !)
  	-- you just need to add lines here to change models
}

-- when client resource is starting
addEventHandler("onClientResourceStart", resourceRoot, function()
	for id, name in ipairs(models) do
		local txd = engineLoadTXD(name..".txd")
		engineImportTXD(txd, id)
		
		local dff = engineLoadDFF(name..".dff")
		engineReplaceModel(dff, id)
		
		local col = engineLoadCOL(name..".col")
		engineReplaceCOL(col, id)
	end
end
)

-- to restore default models when client resource is stopping
addEventHandler("onClientResourceStop", resourceRoot, function()
	for id, _ in ipairs(models) do
		engineRestoreModel(id)
		engineRestoreCOL(id)
	end
end
)

 

Edited by Mkl
Link to comment
On 11/07/2021 at 21:05, Mkl said:

Hello,

I think the interest to use table is to loop them so I wonder if it's more optimized to do for example that way :

Hydra answer is totally fine, I just wanted to contribute. :)

I did not test the script, hope I did not make any mistakes.


local models = {
	[3356] = "mod1",
	[3357] = "mod2",
	[3358] = "mod3"
  	-- [model id] = "name of files" (In this example, txd, col and dff need to have the same name !)
  	-- you just need to add lines here to change models
}

-- when client resource is starting
addEventHandler("onClientResourceStart", resourceRoot, function()
	for id, name in ipairs(models) do
		local txd = engineLoadTXD(name..".txd")
		engineImportTXD(txd, id)
		
		local dff = engineLoadDFF(name..".dff")
		engineReplaceModel(dff, id)
		
		local col = engineLoadCOL(name..".col")
		engineReplaceCOL(col, id)
	end
end
)

-- to restore default models when client resource is stopping
addEventHandler("onClientResourceStop", resourceRoot, function()
	for id, _ in ipairs(models) do
		engineRestoreModel(id)
		engineRestoreCOL(id)
	end
end
)

 

Thank you a lot , it wasn't working , now it working

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