ID:176399
 
Well I need help with overlays. I know how to use them but the problem is this. When a player equips the sword then logs out of the game then logs back into the game and unequips the weapon the overlay is not removed. I can't get the overlay to remove and I've tried several ways.
This is the code I'm using for equiping and unequping a weapon.
verb/Equip()
set src in usr
if (usr.Weapon == "None")
usr.Weapon = "Iron Long Sword"
usr.Strength += 7
usr << "You equip the [src]."
src.suffix = "(Equiped)"
usr.overlays += /obj/overlays/swords/weak
else usr << "You all ready have a weapon equiped."
verb/Upequip()
set src in usr
if (usr.Weapon == "Iron Long Sword")
usr.Weapon = "None"
usr.Strength -= 7
usr << "You remove the [src]."
src.suffix = ""
usr.overlays -= /obj/overlays/swords/weak
else usr << "You don't have that weapon equiped."

It all works fine apart from removing the overlays (when a player logs out and logs back in with a weapon equipped).
lol sorry i cant help you. I was about to post a thread on the same thing,except my problem is with clothes, but I saw your thread :) Hopefully it gets answered.
Maybe you can set the overlays to null at login()>
mob
Login()
src.overlays = null
..()

I think that should work
In response to Weedman
Actually I think the problem lies in saving the mob's icon. When the icon gets saved it simply saves the whole thing, overlays and all. Then, when the icon is reloaded, the overlays are now a part of the new icon.
In response to Jotdaniel
So you could do
mob/var/overlaysave
mob/Logout()
for(var/obj/overlays/a in overlays)
overlaysave += a
overlays -= a
mob/Login()
for(var/a in overlaysave)
overlays += a
overlaysave -= a

That might work.