Hello everyone.
I'm trying to spawn an item at a very specific location in the world (x: 5548, y: 12469, z: 0) when the game starts, but strangely, I'm unable to.
I saw a lot of posts in this forum, and only found two "solutions". This one:
Which makes use of getOrCreateGridSquare() which sounds great but doesn't work.
With this solution, I tried a lot of hooks from this list:
https://pzwiki.net/wiki/Category:Lua_Events
But the problem is, it only works for grid squares that are near the player (I'm assuming the system only loads the grid squares as needed, which makes sense. But then again, getOrCreateGridSquare() should work anyways, because I'm forcing the creation of the grid square, right?).
I also tried this solution:
Which seems to check coordinates every time a grid square is spawned, which is honestly crazy and very bad for performance.
How do you usually do something like this? Shouldn't it be very simple? What am I getting wrong?
Sorry for not posting my code. That is because I tried a lot of different solutions. But in case you really need something, here's a simplified version of one fo my attempts:
CVM.spawn = function()
local x, y, z = 5548, 12469, 0;
local sq = getCell():getOrCreateGridSquare(x, y, z);
sq:AddWorldInventoryItem("Base.Axe", 0, 0, 0);
end
Events.OnCGlobalObjectSystemInit.Add(CVM.spawn)
Thank you for your help.