Jump to content

Help with CreateObject


Nicolas3D

Recommended Posts

Hello I'm editing the map and I can't use the create object function, is there any special function when the object is modified?

What is better to use for the .map or .lua player?

what is the difference between server and client?

function loadMapObjects()
    createObject ( 3724, 2838.0313, -2371.9531, 7.29688, 0, 0, 270 )
end
addEventHandler("onResourceStart", resourceRoot, loadMapObjects)


        txd = engineLoadTXD("TXD/3724.txd")
	engineImportTXD (txd, 3724)
        
	dff = engineLoadDFF("DFF/3724.dff")
	engineReplaceModel (dff, 3724)
        
	col = engineLoadCOL("COL/3724.col")
	engineReplaceCOL (col, 3724)

<meta>
	<info author="Nicolas3D" version="1.3" name="LS" type="mapa" />

	<script src="objetos.lua" type="client" />
	<script src="posicao.lua" type="server" />
        <file src="DFF/3724.dff" />
        <file src="COL/3724.col" />

</meta>

 

Link to comment
  • Moderators
  On 10/03/2021 at 09:28, Nicolas3D said:

Hello I'm editing the map and I can't use the create object function

Expand  

onResourceStart = serverside < reason why your code does not run.

onClientResourceStart = clientside

 

 

  On 10/03/2021 at 09:28, Nicolas3D said:

What is better to use for the .map or .lua player?

Expand  

Depending on the quantity, if it is just 2 objects, it doesn't really matter. But if it is 1000 objects, .map will be faster.

 

 

  On 10/03/2021 at 09:28, Nicolas3D said:

what is the difference between server and client?

Expand  

Server

  • Server(side) is code running on the server. There is only 1 serverside.

Client

  • Players are clients. This code is running inside of the game. Each player is running a copy of this code.

 

Link to comment

 

  On 10/03/2021 at 09:41, IIYAMA said:

onResourceStart = serverside < reason why your code does not run.

onClientResourceStart = clientside

 

 

Depending on the quantity, if it is just 2 objects, it doesn't really matter. But if it is 1000 objects, .map will be faster.

 

 

Server

  • Server(side) is code running on the server. There is only 1 serverside.

Client

  • Players are clients. This code is running inside of the game. Each player is running a copy of this code.

 

Expand  

Tks, I will have to use the .map, so the script will not be necessary, but I was in doubt how to put the lod in the .map in case I created a lod, how do I load it

Link to comment
  On 10/03/2021 at 10:03, IIYAMA said:

For lowLOD's you need scripting as well afaik.

https://wiki.multitheftauto.com/wiki/SetLowLODElement

Expand  

I had used this code for the lods but I believe it doesn’t fit or I did it wrong

https://wiki.multitheftauto.com/wiki/EngineReplaceModel_notes

 

        txdLOD = engineLoadTXD( "garageLOD.txd" )
        engineImportTXD( txdLOD, modelIdLOD )

        dffLOD = engineLoadDFF( "LODDFF/5164.dff", 0 )
        engineReplaceModel( dffLOD, 5164 )

        objLOD = createObject( 5164, 2839.0313,-2371,9531,7.29688, 0, 0, 270, true )
        setLowLODElement(3724, 5164)
        
        engineSetModelLODDistance (5164,5000)

 

Link to comment
  • Moderators
  On 10/03/2021 at 11:10, Nicolas3D said:

I had used this code for the lods but I believe it doesn’t fit or I did it wrong

https://wiki.multitheftauto.com/wiki/EngineReplaceModel_notes

 

        txdLOD = engineLoadTXD( "garageLOD.txd" )
        engineImportTXD( txdLOD, modelIdLOD )

        dffLOD = engineLoadDFF( "LODDFF/5164.dff", 0 )
        engineReplaceModel( dffLOD, 5164 )

        objLOD = createObject( 5164, 2839.0313,-2371,9531,7.29688, 0, 0, 270, true )
        setLowLODElement(3724, 5164)
        
        engineSetModelLODDistance (5164,5000)

 

Expand  

 

The syntax for the setLowLODElement function:

bool setLowLODElement ( element theElement, element lowLODElement )

https://wiki.multitheftauto.com/wiki/SetLowLODElement

 

You need to fill in the elements, not the model number. Afaik you are seeing warnings/errors appear in your debug console because of this.

This function is used for swapping between default objects and lowLOD objects, depending if the object is streamed-in or not.

 

 

Link to comment
  On 10/03/2021 at 11:17, IIYAMA said:

 

The syntax for the setLowLODElement function:

bool setLowLODElement ( element theElement, element lowLODElement )

https://wiki.multitheftauto.com/wiki/SetLowLODElement

 

You need to fill in the elements, not the model number. Afaik you are seeing warnings/errors appear in your debug console because of this.

This function is used for swapping between default objects and lowLOD objects, depending if the object is streamed-in or not.

 

 

Expand  

I didn’t understand, I could show you an example I don’t know much about scripta

Link to comment
  • Moderators
  On 10/03/2021 at 11:26, Nicolas3D said:

I didn’t understand, I could show you an example I don’t know much about scripta

Expand  

Or you learn to script first, so that your topic doesn't become a scripting request. ?

I only give examples when you can learn enough from them, which is not the case when your question goes beyond the basics (those that you are missing at the moment).

Link to comment
  On 10/03/2021 at 12:06, IIYAMA said:

Or you learn to script first, so that your topic doesn't become a scripting request. ?

I only give examples when you can learn enough from them, which is not the case when your question goes beyond the basics (those that you are missing at the moment).

Expand  

the basics I can understand ? but it's starting to complicate in some parts my area is 3D but I want to evolve to script

Link to comment
  • Moderators
  On 10/03/2021 at 12:28, Nicolas3D said:

the basics I can understand ? but it's starting to complicate in some parts my area is 3D but I want to evolve to script

Expand  

Oh perfect.

 

In that case, create 2 objects at the same place and link them together:

-- non lowLOD
obj = createObject( 5164, 2839.0313,-2371,9531,7.29688, 0, 0, 270, false )

-- lowLOD
objLOD = createObject( 5164, 2839.0313,-2371,9531,7.29688, 0, 0, 270, true )

setLowLODElement(obj, objLOD)

When the non lowLOD variant streams out, the lowLOD variant will kick-in.

 

Link to comment
  On 10/03/2021 at 12:48, IIYAMA said:

Oh perfect.

 

In that case, create 2 objects at the same place and link them together:

-- non lowLOD
obj = createObject( 5164, 2839.0313,-2371,9531,7.29688, 0, 0, 270, false )

-- lowLOD
objLOD = createObject( 5164, 2839.0313,-2371,9531,7.29688, 0, 0, 270, true )

setLowLODElement(obj, objLOD)

When the non lowLOD variant streams out, the lowLOD variant will kick-in.

 

Expand  

 ERROR: test.lua:2: attempt to call global 'engineLoadDFF' (a nil value

There was even a lod but it is original to the game, and even if it moves me away, it does not disappear

Link to comment
  On 10/03/2021 at 14:40, IIYAMA said:

That function is only available on clientside.

See docs: https://wiki.multitheftauto.com/wiki/EngineLoadDFF

Expand  

thank you very much for your explanation helped me to understand and learn a little ❤️ 

  On 10/03/2021 at 14:40, IIYAMA said:

That function is only available on clientside.

See docs: https://wiki.multitheftauto.com/wiki/EngineLoadDFF

Expand  

thank you very much for your explanation helped me to understand and learn a little ❤️ 3

There would be no way to change the 3D switching time with the lod

  • Like 1
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...