ID:264235
 
Code:
        coppersword
name="Copper Sword"
icon='Objects.dmi'
icon_state="coppersword"
equipped=0
equipable=1
Click()
if(src in usr)
if(!equipped)
if(!usr.rhand)
return
else
usr.overlays+=new/obj/items/sso
usr.overlays+=new/obj/items/ssb
usr.overlays+=new/obj/items/ssr
usr.overlays+=new/obj/items/ssl
usr.rhand=1
usr.attack+=4
equipped=1
Equip(src)
else
usr.overlays-=/obj/items/sso
usr.overlays-=/obj/items/ssb
usr.overlays-=/obj/items/ssr
usr.overlays-=/obj/items/ssl
usr.rhand=0
usr.attack-=4
equipped=0
Unequip(src)
else
return


Problem description:Ok, when i save my game and load it i unequip the sword, but the overlays still show on my player, why?

usr.overlays-=/obj/items/ssl
//I would do that, like this:
usr.overlays -= newlist(/obj/items/ssl)

You might also have to add it that way.
This probably isn't the best way to do it, but its the only way I know :D.
This is an old issue. Overlays are saved by default, and merged. You are going to have to write some code that clears the overlays list of the player on load (overlays.Cut(1,0)), then scans through their equipment that was equipped, and re-equips it. Better yet, just don't save overlays then scan the equipment.
In response to Ter13
thank you, could you help me with something though? i don't understand how to make it scan for the equipment. I would really appreciate if you could help. :) thank you
In response to Ralphie_leo
Funny, I had the exact same issue a little while ago!

Basically, all you need to do is overwrite your Read() and Write(). In mob.Write(), cut or null out the mob's overlays, then in mob.Read(), go through the equipment and rebuild the overlay, re-adding where necessary.

On a similar note, tracking equipped objs by a var in the obj is not the best way to handle it. Instead, I recommend using a list in the mob tracking equipped gear by location. So, maybe a sword can be equipped as a weapon so:
mob
var/list/equipment=new()
var/damage_rating
Write()
overlays=null
..()
Read()
..()
for(var/obj/O in src)
if(equipment[O.slot]==O)
overlays+=O.worn_icon
obj
var
slot
rating
worn_icon
weapon
slot="weapon"
knife
worn_icon='knife.dmi'
rating=1
sword
worn_icon='sword.dmi'
rating=3
Stormbringer
worn_icon='stormbringer.dmi'
rating=666
verb/equip()
set src in usr.contents
var/mob/M=src.loc
if(M.equipment[slot])
M << "You already wear something in that location!"
return 0
M.equipment[slot]=src
src.suffix= "([slot])"
M.overlays+=worn_icon
if(slot=="weapon") M.damage_rating+=rating
view(M) << "\The [M] wears \the [src]."
verb/remove()
set src in usr.contents
var/mob/M=src.loc
if(M.equipment[slot] != src)
M << "You are not wearing that!"
return 0
M.equipment[slot]=null
src.suffix= null
M.overlays-=worn_icon
if(slot=="weapon") M.damage_rating-=rating
view(M) << "\The [M] removes \the [src]."
In response to Jmurph
Heh, that's usr underuse there - you should really simply use usr instead of that M var in the verbs.
In response to Jmurph
wow, i would have never got that, thank you very much