Ryosuke

Simplified object script - help

Recommended Posts

 

 

I need help to create this script that replaces objects across a table, thus getting more practical and quick to convert objects


Garage_OBJ_DFF = {
    {"garage_1.dff",1455},
    {"garage_2.dff",1455},
}
Garage_OBJ_TXD = {
    {"garage_1.txd",1455},
    {"garage_1.txd",1484},
}
Garage_OBJ_COL = {
    {"garage_1.col",1484},
    {"garage_2.col",1484},
}


function replacemodels(player)
for i,object1,object2 in ipairs(Garage_OBJ_DFF) do
table.insert(object1[1],object2[2])    
object1 = engineLoadDFF
object2 = engineReplaceModel
end
for i,object1,object2 in ipairs(Garage_OBJ_TXD) do
table.insert(object1[1],object2[2])    
object1 = engineLoadTXD
object2 = engineImportTXD
end
for i,object1,object2 in ipairs(Garage_OBJ_COL) do
table.insert(object1[1],object2[2])    
object1 = engineLoadCOL
object2 = engineReplaceCOL
end
end
 addEventHandler("onClientRender",root,replacemodels)

Share this post


Link to post

I don't see the point of using a table for this, replacing objects is client sided anyhow and loads depending on how good the players PC is.
Also OnClientRender is dynamic, meaning it's gonna keep loading your objects 24/7 (every time your screen renders a new frame).
Probably should use OnClientResourceStart instead.
Try learning to use the MTA Wiki as well.
Unfortunately your code is so confusing that I just gave you an example of what you're looking for Cx

function replaceModels()
	txd1 = engineLoadTXD("garage1.txd", 1455)
	txd2 = engineLoadTXD("garage1.txd", 1484)
	engineImportTXD(txd1, 1455)
	engineImportTXD(txd2, 1484)
	dff1 = engineLoadDFF("garage1.dff", 1455)
	engineReplaceModel(dff1, 1455)
	col1 = engineLoadCOL("garage1.col", 1484)
	engineReplaceCOL(col1, 1484)
end
addEventHandler("onClientResourceStart", resourceRoot, replaceModels)

onClientRender

Clientside event

"This event is triggered every time GTA renders a new frame. It is required for the DirectX drawing functions, and also useful for other clientside operations that have to be applied repeatedly with very short time differences between them."

OnClientRender
OnClientResourceStart
MTA Wiki

Edited by JustinMTA
  • Like 1

Share this post


Link to post
1 hour ago, JustinMTA said:

I don't see the point of using a table for this, replacing objects is client sided anyhow and loads depending on how good the players PC is.
Also OnClientRender is dynamic, meaning it's gonna keep loading your objects 24/7 (every time your screen renders a new frame).
Probably should use OnClientResourceStart instead.
Try learning to use the MTA Wiki as well.
Unfortunately your code is so confusing that I just gave you an example of what you're looking for Cx


function replaceModels()
	txd1 = engineLoadTXD("garage1.txd", 1455)
	txd2 = engineLoadTXD("garage1.txd", 1484)
	engineImportTXD(txd1, 1455)
	engineImportTXD(txd2, 1484)
	dff1 = engineLoadDFF("garage1.dff", 1455)
	engineReplaceModel(dff1, 1455)
	col1 = engineLoadCOL("garage1.col", 1484)
	engineReplaceCOL(col1, 1484)
end
addEventHandler("onClientResourceStart", resourceRoot, replaceModels)

onClientRender

Clientside event

"This event is triggered every time GTA renders a new frame. It is required for the DirectX drawing functions, and also useful for other clientside operations that have to be applied repeatedly with very short time differences between them."

OnClientRender
OnClientResourceStart
MTA Wiki

thanks for help me 

Share this post


Link to post
2 hours ago, Elvis Willian said:

thanks for help me 

4 hours ago, JustinMTA said:

I don't see the point of using a table for this, replacing objects is client sided anyhow and loads depending on how good the players PC is.
Also OnClientRender is dynamic, meaning it's gonna keep loading your objects 24/7 (every time your screen renders a new frame).
Probably should use OnClientResourceStart instead.
Try learning to use the MTA Wiki as well.
Unfortunately your code is so confusing that I just gave you an example of what you're looking for Cx


function replaceModels()
	txd1 = engineLoadTXD("garage1.txd", 1455)
	txd2 = engineLoadTXD("garage1.txd", 1484)
	engineImportTXD(txd1, 1455)
	engineImportTXD(txd2, 1484)
	dff1 = engineLoadDFF("garage1.dff", 1455)
	engineReplaceModel(dff1, 1455)
	col1 = engineLoadCOL("garage1.col", 1484)
	engineReplaceCOL(col1, 1484)
end
addEventHandler("onClientResourceStart", resourceRoot, replaceModels)

onClientRender

Clientside event

"This event is triggered every time GTA renders a new frame. It is required for the DirectX drawing functions, and also useful for other clientside operations that have to be applied repeatedly with very short time differences between them."

OnClientRender
OnClientResourceStart
MTA Wiki

 

to work I just need to make it check the name and ID and give the function, just do not know why it does not work

function replacemodels(player)
for i,OBJ in ipairs(Garage_OBJ_COL) do
table.insert (engineLoadCOL,{OBJ[1]})
table.insert (engineReplaceCOL,{OBJ[2]})
end
end
 addEventHandler("onResourceStart",root,replacemodels)

Share this post


Link to post
function replacemodels(player)
  for i,OBJ in ipairs(Garage_OBJ_COL) do
    -- OBJ[1] is the file name
    -- OBJ[2] is the model id
    local col = engineLoadCOL(OBJ[1], OBJ[2])
    engineReplaceCOL(col, OBJ[2])
  end
end
addEventHandler("onResourceStart",root,replacemodels)

 

Edited by MrTasty

Share this post


Link to post
35 minutes ago, MrTasty said:

function replacemodels(player)
  for i,OBJ in ipairs(Garage_OBJ_COL) do
    -- OBJ[1] is the file name
    -- OBJ[2] is the model id
    local col = engineLoadCOL(OBJ[1], OBJ[2])
    engineReplaceCOL(col, OBJ[2])
  end
end
addEventHandler("onResourceStart",root,replacemodels)

 

 

that's right I needed, thank you just finished saving me worked perfectly

Share this post


Link to post

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.