ID:178173
 
Okay, I have one map. X:10, Y:10, Z:1000, and it has one item in it. How do you make it so when you login you go to one of the z levels that isnt occupied. The one I tried worked, but other players didnt get the item!
FireEmblem wrote:
Okay, I have one map. X:10, Y:10, Z:1000, and it has one item in it. How do you make it so when you login you go to one of the z levels that isnt occupied. The one I tried worked, but other players didnt get the item!

If they're on other Z levels, then of course they won't get to the item. If you put the same item on every Z level, though, they can.

To find a level that's unoccupied, you'd basically have to cycle through all mobs in the world, take note of their Z levels, and send the new player to the first such level that isn't on the list.

Lummox JR
In response to Lummox JR
How do you give the item to each z level?
Or can ya make it so everyone is on the same map but ONLY U can see your pet? And anyone else can walk over it?
In response to FireEmblem
Probably the easiest way is to set up a loop something like...
var/global/ZLEVEL = 0

world
New()
while(ZLEVEL < 1000)
ZLEVEL += 1
var/obj/(OBJECT)/O = new(4,4,ZLEVEL)

//Then, to give each person their own Z level...

mob
Player
var/global/USEDZ = 1
Login()
src.loc = locate(1,1,USEDZ)
USEDZ += 1

Or, even better...
mob
Player
var/global/USEDZ = 1
Login()
src.loc = locate(1,1,USEDZ)
USEDZ += 1
var/obj/(OBJECT)/O = new(4,4,USEDZ)

That would create the new object on each Z level once someone logs in. This is very basic, of course. Once someone leaves that Z level would go unused.

[edit]
If you want to reuse the Z levels, there is a somewhat easy way to do it. Although it uses a LOT of computing power, especially for large maps...
mob
Player
Logout()
USEDZ -= 1
for(var/obj/O in world)
if(O.z > src.z)
O.z -= 1
else if(O.z == src.z)
del(O)
for(var/mob/M in world)
if(M.z > src.z)
O.z -= 1
else if(M.z == src.z && M != src)
del(M)
del(src)

That would reduce the Z level by 1 for everyone that's above their Z level. Of course, searching every single object in the world is hard to do, and it will slow down your game if you have too many objects. Also, it will delete everything on the player's Z level. Notice that I do a check to see if the mob ISN'T them, that's so that the Logout() proc isn't stopped suddenly because they're deleted. Once they've all been checked, THEN you can delete them.