ID:1954081
 
Code:
    var/origin
New()
origin=loc
..()
proc
respawn()
var/oldloc = origin
spawn(respawnTime)
var/obj/clone = new type
clone.loc = oldloc


Problem description:

When a player takes an object it is supposed to respawn but there are strange happenings. Objects will duplicate in the inventory or not respawn at all
You need to create atoms with an initial location as part of the 'new' statement.
respawn()
spawn(respawnTime)
new type (origin)

This is because, for the clone, origin is being set to null because New() occurs before the line "clone.loc = oldloc" and you're creating the "new type" without an initial location.
Objects are still duplicating on the ground? I don't know if my respawn code is just running multiple times or something else.
In response to Enakro
Where are you actually calling respawn()?
        Cross(mob/M)
if(usr.carryweight+src.weight<=usr.mcarryweight)
src.respawn()
usr.carryweight+=src.weight
usr.contents+=src
usr<<'audio/216629__wiesenwiesel__picking-up-small-box-with-items-inside.wav'
usr<<"Got [src] ([src.weight]lbs)!"
else
return 1


and whenever it respawns there is an extra item, it accumulates each time. First there are 2, then 3, and so on.