CreateObject does not spawn props properly

Hello

i try to spawn a prop in the player’s location using a command.
in some places in the map it work fine, other places does spawn above player Y position and sometimes it’s spawned but not visible, i know that is spawned because i got its id.

here is my code maybe someone can tells me whay’s going wrong

int spawnModel = GetHashKey(“model1”);
RequestModel((uint)spawnModel);

// check is useless since check is always false don’t know why and my model is well loaded
//while (!HasModelLoaded((uint)spawnModel))
//{
// RequestModel((uint)spawnModel);
// Wait(500);
//}

int ped = PlayerPedId();
Vector3 coors = GetEntityCoords(ped, true);

int myProp = CreateObject(spawnModel, coors.X, coors.Y, coors.Y, true, true, true);

FreezeEntityPosition(myProp , true);
SetEntityCanBeDamaged(myProp , true);

Debug.WriteLine("entity invoked with id " + myProp );

Hi there!

I’m not quite sure what you’re trying to achieve, but I suppose the following native might help you out.

i just want to have ability to spawn object using a command where i want in the game.
the issue is that it work in some places, and other places does not show up.

to be able to spawn it as an external object i should already spawn it as fixed somewhere in the map using a resource
and mark it as this_is_a_map ‘yes’ even i don’t really need it to be spawned by default but i think it’s the only way to add an external prop i guess so correct me if i am wrong.

but what i have realise is that away of a certain range of this original spawn it does not show up, and when i just enter to this invisible range it work.

i tryed another function CreateProp and it’s same, beyond a range the prop is not showing and i think it’s a game issue since i find this comment of the function

why there is a way that it return null ? indeed that’s what happen object can’t be spawned but close to the fixed one “as a map object using CodeWalker” it does spawn.

is there some conditions for that behavior ?