Jump to content

TXD animation with a timer fail


Faw[Ful]

Recommended Posts

I want to animate my TXD (gta sa texture library) by using a timer and many TXD so there is a texture with the same name in each TXD. With a timer I want to load the TXD 1 for example and after the TXD 2 and after the TXD 3 so at the end I will create an animation.

But

This work :

addEventHandler('onClientResourceStart', resourceRoot,  
function()   
  
txd_anim1 = engineLoadTXD('files/anim1.txd') 
engineImportTXD(txd_anim1, 2396) 
  
local col = engineLoadCOL('files/21.col')  
    engineReplaceCOL(col, 2396) 
  
local dff = engineLoadDFF('files/21.dff', 0)  
    engineReplaceModel(dff, 2396) 
  
engineSetModelLODDistance(2396, 500) 
  
end  
) 

and this dont work :( :

function animate()   
  
txd_anim1 = engineLoadTXD('files/anim1.txd') 
engineImportTXD(txd_anim1, 2396) 
  
local col = engineLoadCOL('files/21.col')  
    engineReplaceCOL(col, 2396) 
  
local dff = engineLoadDFF('files/21.dff', 0)  
    engineReplaceModel(dff, 2396) 
  
engineSetModelLODDistance(2396, 500) 
  
end  
setTimer ( animate, 1000, 0 ) 

But I cant add a timer in the first script , because my function need a name and if I add a name the script dont work.

Link to comment

You're doing that in a wrong way. First, you load custom models and textures every second and don't unload them. Because of that, you may run out of RAM pretty fast. In your place, I would use a model ID for every animation frame. I would load the same DFF and COL on all of them and different TXDs on every model ID. Then I would create as many objects as there are frames, in the same position, and would show them one after another with setElementAlpha. I would also disable collisions for all but one model (but I would still replace COLs as they're used to detect whether the object is on the screen and should be rendered).

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