HighFlyer Posted October 16, 2011 Share Posted October 16, 2011 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 . 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
Kenix Posted October 16, 2011 Share Posted October 16, 2011 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
HighFlyer Posted October 16, 2011 Author Share Posted October 16, 2011 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? Link to comment
Castillo Posted October 17, 2011 Share Posted October 17, 2011 resourceRoot is the same as getResourceRootElement(getThisResource()), just a "shortcut" Link to comment
Kenix Posted October 17, 2011 Share Posted October 17, 2011 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
TAPL Posted October 17, 2011 Share Posted October 17, 2011 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
Kenix Posted October 17, 2011 Share Posted October 17, 2011 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
TAPL Posted October 17, 2011 Share Posted October 17, 2011 not same your code size = 517 Bytes my code size = 443 Bytes is same? Link to comment
qaisjp Posted October 18, 2011 Share Posted October 18, 2011 indeed more cleaner, but unneeded post. have you got it working now? Link to comment
HighFlyer Posted October 18, 2011 Author Share Posted October 18, 2011 Sorry for a late reply, and I did yes, thanks a lot. It was my folder structure by the looks... The script didn't like vehicles/data/filename.txd(and/or dff) inside meta.xml. vehicles/filename.extension suits it better. Thank you 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