Jump to content

add a custom object


Hani2001

Recommended Posts

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 by Hani2001
Link to comment
     
		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 by CodyJ(L)
Link to comment
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
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 by ShayF
Link to comment
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

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 by CodyJ(L)
Link to comment
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

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