[Help] Created Object Not... Spawning?

I’m experiencing some issues with CreateObject and CreateObjectNoOffset. My map loader parses an .xml file saved by the MapEditor mod. I have verified over and over that tables are populated correctly and with the correct values. I double check them when they’re transferred to the client.

Using either Trace (trace for whatever reasons ouputs twice to the console, am I misusing it or is this a bug?). I confirm that I get the right amount of entities - in this case, 7 props and 24 vehicles. I’ve also compared their hash, position, rotation and quaternion to the XML file several times.

Also, for some reason there is always 1 object that will remain if I stop the resource. Here’s a video of what is going on;
https://streamable.com/gqnfx

And here’s a screenshot of what it should look like;

This is the code I use to create the objects (I have tried both with and without using an asynchronous thread);

for i=1, #propList do
		--[[ {Hash, {PosX, PosY, PosZ}, {RotX, RotY, RotZ}, {QuatX, QuatY, QuatZ, QuatW}, Dynamic} ]]
		--[[ {Hash, {PosX, PosY, PosZ}, {RotX, RotY, RotZ}, Dynamic} ]]
		-- If index 4 is a table, that means it has a quaternion shitty headache thing
		if(type(propList[i][4]) == "table") then
			local theObject = CreateObjectNoOffset(propList[i][1], propList[i][2][1], propList[i][2][2], propList[i][2][3], false, false, false)
			if(theObject) then
				SetEntityCoords(theObject, propList[i][2][1], propList[i][2][2], propList[i][2][3])
				SetEntityRotation(theObject, propList[i][3][1], propList[i][3][2], propList[i][3][3], 2, true)
				SetEntityQuaternion(theObject, propList[i][4][1], propList[i][4][2], propList[i][4][3], propList[i][4][4])
				FreezeEntityPosition(theObject, true)
				table.insert(spawnedProps, theObject)
			end
		elseif(propList[i][4] == "true" or propList[i][4] == "false") then
			local theObject = CreateObjectNoOffset(propList[i][1], propList[i][2][1], propList[i][2][2], propList[i][2][3], false, false, false)
			if(theObject) then
				SetEntityCoords(theObject, propList[i][2][1], propList[i][2][2], propList[i][2][3])
				SetEntityRotation(theObject, propList[i][3][1], propList[i][3][2], propList[i][3][3], 2, true)
				FreezeEntityPosition(theObject, true)
				table.insert(spawnedProps, theObject)
			end
		end
	end

At this point I’m all out of ideas, I’ve fiddled with collisions, the last 2 parameters in SetEntityRotation. I’ve tried ignoring quaternions completely. I’ve tried changing the values in the XML file to be floats (for pos, rot and quat).

My hair has now turned all grey and is starting to fall off, so I’m gonna hit the bed. If anyone has any suggestions or advice, please let me know. :cry:

Why did you not use ObjectLoader release together with MapEditor for GTA V ?

It would make your life so much easier.

What, where, how, when and why?

I just now managed to fix this, however. The issue is that I need to use vector3(). If I do not use vector3() for SetEntityRotation one or more objects would always have incorrect rotation applies - if at all. So just in case I did it for position as well.

Whether or not this is a bug or me being a dum-dum, I don’t know. But if you want to review the code to see whether or not it is, just throw me a message.

I did look at and was previously using this;

But I’m the kind of man that prefer making my own stuff instead of trying to learn how other people’s stuff work most of the time. That way when and if I need to make changes I’ll know right away what needs to be done. :slight_smile:

Were your values by any chance integers (0, 180, 0) and not floats (0, 180.0, 0)?

In the .txt file some are integers, yes, but those are all converted into floats as the map is parsed (except the hash, obviously).

At first I thought it might have been because some values were for example -90, rather than 270 - so I tried manually changing those but the results were the same.

If you want the source to take a look that’s no problem, just throw me a message. It’s very lightweight and already has some debug prints/traces in place. :slight_smile: