Hani2001 Posted December 18, 2017 Share Posted December 18, 2017 (edited) Please How To Add a custom object id on mtasa ex: id:18633 is this function work ? addEventHandler("onClientResourceStart", resourceRoot, function() dff = engineLoadDFF ( "object.dff", 18633) engineReplaceModel ( dff, 18633) col = engineLoadCOL( "object.col" ) engineReplaceCOL( col, 18633 ) txd = engineLoadTXD( "object.txd" ) engineImportTXD( col, 18633 ) end ) Edited December 18, 2017 by Hani2001 Link to comment
kieran Posted December 19, 2017 Share Posted December 19, 2017 (edited) Here's a link to the MTA channel on YouTube, it explains how you make, export, and load a custom object into your server, it's also pretty funny Custom Map Models Tutorial Time that the script is made for importing the custom object Edited December 19, 2017 by kieran Link to comment
Captain Cody Posted December 20, 2017 Share Posted December 20, 2017 (edited) local DFFdictonary = '' -- example content/models/ local COLdictonary = '' local TXDdictonary = '' txdTable = {} function loadTXD(TXD) txdTable[TXD] = txdTable[TXD] or engineLoadTXD(TXD..TXDdictonary..'.txd') return txdTable[TXD] end models = { {'object','object','object',18633}, } -- Dff, Col, Txd, ID for i=1,#models do dff = engineLoadDFF ( DFFdictonary..models[i][1]..'.dff', models[i][4]) engineReplaceModel ( dff, models[i][4]) col = engineLoadCOL( COLdictonary..models[i][2]..'.col' ) engineReplaceCOL( col, models[i][4] ) txd = loadTXD[models[i][3]] engineImportTXD( col, models[i][4] ) end Loads your models and ensures that if something shares a TXD that is only loaded once to save memory. Edited December 20, 2017 by CodyJ(L) Link to comment
Hani2001 Posted December 23, 2017 Author Share Posted December 23, 2017 On 20/12/2017 at 12:19, CodyJ(L) said: local DFFdictonary = '' -- example content/models/ local COLdictonary = '' local TXDdictonary = '' txdTable = {} function loadTXD(TXD) txdTable[TXD] = txdTable[TXD] or engineLoadTXD(TXD..TXDdictonary..'.txd') return txdTable[TXD] end models = { {'object','object','object',18633}, } -- Dff, Col, Txd, ID for i=1,#models do dff = engineLoadDFF ( DFFdictonary..models[i][1]..'.dff', models[i][4]) engineReplaceModel ( dff, models[i][4]) col = engineLoadCOL( COLdictonary..models[i][2]..'.col' ) engineReplaceCOL( col, models[i][4] ) txd = loadTXD[models[i][3]] engineImportTXD( col, models[i][4] ) end Loads your models and ensures that if something shares a TXD that is only loaded once to save memory. i change it to this and not work local DFFdictonary = 'dff' -- example content/models/ local COLdictonary = 'col' local TXDdictonary = 'txd' txdTable = {} function loadTXD(TXD) txdTable[TXD] = txdTable[TXD] or engineLoadTXD(TXD..TXDdictonary..'.txd') return txdTable[TXD] end models = { {'WSRocky1','WSRocky1','WSSections',19073}, } -- Dff, Col, Txd, ID for i=1,#models do txd = loadTXD[models[i][3]] engineImportTXD( txd, models[i][4] ) col = engineLoadCOL( COLdictonary..models[i][2]..'.col' ) engineReplaceCOL( col, models[i][4] ) dff = engineLoadDFF ( DFFdictonary..models[i][1]..'.dff', models[i][4]) engineReplaceModel ( dff, models[i][4]) end Link to comment
Captain Cody Posted December 23, 2017 Share Posted December 23, 2017 You did something wrong with your model then. Link to comment
ShayF2 Posted December 23, 2017 Share Posted December 23, 2017 (edited) On 12/20/2017 at 05:19, CodyJ(L) said: local DFFdictonary = '' -- example content/models/ local COLdictonary = '' local TXDdictonary = '' txdTable = {} function loadTXD(TXD) txdTable[TXD] = txdTable[TXD] or engineLoadTXD(TXD..TXDdictonary..'.txd') return txdTable[TXD] end models = { {'object','object','object',18633}, } -- Dff, Col, Txd, ID for i=1,#models do dff = engineLoadDFF ( DFFdictonary..models[i][1]..'.dff', models[i][4]) engineReplaceModel ( dff, models[i][4]) col = engineLoadCOL( COLdictonary..models[i][2]..'.col' ) engineReplaceCOL( col, models[i][4] ) txd = loadTXD[models[i][3]] engineImportTXD( col, models[i][4] ) end Loads your models and ensures that if something shares a TXD that is only loaded once to save memory. models = { {'object.dff','object.col','object.txd',18633}, } addEventHandler('onClientResourceStart',resourceRoot,function() for i=1,#models do local dff = engineLoadDFF(models[i][1],models[i][4]) engineReplaceModel(dff,models[i][4]) local col = engineLoadCOL(models[i][2]) engineReplaceCOL(col,models[i][4]) local txd = engineLoadTXD[models[i][3]] engineImportTXD(txd,models[i][4]) end end) Formatted code. Same result. If this does not work, it is either your model or the element id is not valid, have a nice day. Edited December 23, 2017 by ShayF Link to comment
Captain Cody Posted December 23, 2017 Share Posted December 23, 2017 Well if you even bothered to read mine it's setup for more customization. Plus you're missing the loadTXD function. Link to comment
ShayF2 Posted December 23, 2017 Share Posted December 23, 2017 14 minutes ago, CodyJ(L) said: Well if you even bothered to read mine it's setup for more customization. Plus you're missing the loadTXD function. onClientResourceStart runs 1 time, all the code is unloaded when the script stops, so it runs a loop through the table 1 time. meaning it uses the information 1 time. And so on, simply put the whole thing runs once and only once. All you need for customization is the table above. It includes dff name, txd name, and col name, as well as the element id you want to replace. I'm not quite sure what other customization you're including. What i posted is customizable, clean, and functional. You've made cool :~ Cody, I wont deny your skill, you've got a lot more potential than I do. However your code is not 'clean', it becomes hard to understand. I ask that you don't contradict me because I find it insulting. Link to comment
Captain Cody Posted December 23, 2017 Share Posted December 23, 2017 (edited) There's literally no reason to put on client resource start just slapping it in the client script works the same, also mine has ability to set object location. Other then removing that you've basically done nothing else to the code besides remove an important function. And I will respond back because I've been doing this type of stuff for a while now, I know exactly what I'm doing. Edited December 23, 2017 by CodyJ(L) Link to comment
ShayF2 Posted December 23, 2017 Share Posted December 23, 2017 2 hours ago, CodyJ(L) said: There's literally no reason to put on client resource start just slapping it in the client script works the same, also mine has ability to set object location. Other then removing that you've basically done nothing else to the code besides remove an important function. And I will respond back because I've been doing this type of stuff for a while now, I know exactly what I'm doing. I'm not trying to change what the code does Cody. I'm just making the code simpler and cleaner than it was. 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