Jump to content

Learning to script, need help with object replacing


HighFlyer

Recommended Posts

Hello there,

I am kinda new to MTA scripting, and I have to criticize the amount of help on the forums that is available. I've been trying to research this issue, and could not find a lot. Wiki is however very well explained, and certainly it's a good thing. Anyhow, before you take me as some jerk that just moans about the fact he can't script, you're probably right, as I'm new to LUA :lol: . I would require your help if possible please, as this thing puts me in a spot a little bit, I can't see the problem why it does not work. It's in regards to object replacement function i.e engineImportTXD and DFF. Here's my code...

    function replaceModel() 
      
      txd1 = engineLoadTXD("data/tahoma.txd", 566 ) 
      engineImportTXD(txd1, 566) 
      dff1 = engineLoadDFF("data/tahoma.dff", 566 ) 
      engineReplaceModel(dff1, 566) 
      
      txd2 = engineLoadTXD("data/linerun.txd", 403 ) 
      engineImportTXD(txd2, 403) 
      dff2 = engineLoadDFF("data/linerun.dff", 403 ) 
      engineReplaceModel(dff2, 403) 
      
    end 
    addEventHandler ( "onClientResourceStart", getResourceRootElement(getThisResource()), replaceCar) 

My folder structure is following

mygm = in folder mygm located is the file meta.xml

--> vehicles

in vehicles settings.lua and folder /data

--> data contains txd and dff files which are defined in the meta.xml like this...

  

    "HighFlyer" type="gamemode" name="HighFlyer's Test Script" description="Test GM" /> 
    

Trouble is, both of them don't work :? I'm not sure why, because I think I did all of the steps required, I fiddled around to see if the folder structure is correct, and it seems like it, any help would be appreciated.

Thanks,

HighFlyer

Link to comment

Edit:

  
    function replaceModel() 
      
      txd1 = engineLoadTXD("data/tahoma.txd", 566 ) 
      engineImportTXD(txd1, 566) 
      dff1 = engineLoadDFF("data/tahoma.dff", 566 ) 
      engineReplaceModel(dff1, 566) 
      
      txd2 = engineLoadTXD("data/linerun.txd", 403 ) 
      engineImportTXD(txd2, 403) 
      dff2 = engineLoadDFF("data/linerun.dff", 403 ) 
      engineReplaceModel(dff2, 403) 
     -- and your folders incorrect  
     --[[ you have in meta.xml file path is <file src="vehicles/data/tahoma.txd" /> 
    <file src="vehicles/data/tahoma.dff" /> 
    <file src="vehicles/data/linerun.txd" /> 
    <file src="vehicles/data/linerun.dff" /> 
    remember it .]] 
    end 
    addEventHandler ( "onClientResourceStart", getResourceRootElement(getThisResource()), replaceCar) -- you call functiom replaceCar() but you don't have this function 
  

Correct

  
    function replaceModel() 
      
      txd1 = engineLoadTXD("vehicles/data/tahoma.txd", 566 ) 
      engineImportTXD(txd1, 566) 
      dff1 = engineLoadDFF("vehicles/data/tahoma.dff", 566 ) 
      engineReplaceModel(dff1, 566) 
      
      txd2 = engineLoadTXD("vehicles/data/linerun.txd", 403 ) 
      engineImportTXD(txd2, 403) 
      dff2 = engineLoadDFF("vehicles/data/linerun.dff", 403 ) 
      engineReplaceModel(dff2, 403) 
      
    end 
    addEventHandler ( "onClientResourceStart", resourceRoot , replaceModel)  
  

and you can use variable resourceRoot instead of getResourceRootElement(getThisResource())

Link to comment
May I just ask, why resourceRoot instead of getResourceRootElement(getThisResource())?

Doesn't work sadly. I have however noticed that MTA downloads the textures, but does not replace them, any ideas?

you can write filename( script for replace cars )

and use /debugscript 3

Oh i found problem:

Try it

  
    function replaceModel() 
      
      txd1 = engineLoadTXD("vehicles/data/tahoma.txd") 
      engineImportTXD(txd1, 566) 
      dff1 = engineLoadDFF("vehicles/data/tahoma.dff", 566 ) 
      engineReplaceModel(dff1, 566) 
      
      txd2 = engineLoadTXD("vehicles/data/linerun.txd") 
      engineImportTXD(txd2, 403) 
      dff2 = engineLoadDFF("vehicles/data/linerun.dff", 403 ) 
      engineReplaceModel(dff2, 403) 
      
    end 
    addEventHandler ( "onClientResourceStart", resourceRoot , replaceModel) 
  

read wiki please : https://wiki.multitheftauto.com/wiki/EngineLoadTXD

Link to comment
addEventHandler("onClientResourceStart", resourceRoot, function() 
    txd1 = engineLoadTXD ("vehicles/data/tahoma.txd") 
    engineImportTXD (txd1, 566) 
    dff1 = engineLoadDFF ("vehicles/data/tahoma.dff", 566) 
    engineReplaceModel (dff1, 566) 
  
    txd2 = engineLoadTXD ("vehicles/data/linerun.txd") 
    engineImportTXD (txd2, 403) 
    dff2 = engineLoadDFF ("vehicles/data/linerun.dff", 403) 
    engineReplaceModel (dff2, 403) 
end) 

Link to comment
addEventHandler("onClientResourceStart", resourceRoot, function() 
    txd1 = engineLoadTXD ("vehicles/data/tahoma.txd") 
    engineImportTXD (txd1, 566) 
    dff1 = engineLoadDFF ("vehicles/data/tahoma.dff", 566) 
    engineReplaceModel (dff1, 566) 
  
    txd2 = engineLoadTXD ("vehicles/data/linerun.txd") 
    engineImportTXD (txd2, 403) 
    dff2 = engineLoadDFF ("vehicles/data/linerun.dff", 403) 
    engineReplaceModel (dff2, 403) 
end) 

lol ? this is the same ..

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