ID:264302
 
Code:
obj/Warrior/Helms
icon='Warrior Helms.dmi'
Ascalon_Helm
icon_state="Ascalon"
density=0
layer=MOB_LAYER+1
verb
Get()
set src in oview(1)
set category = "Commands"
Move(usr)
view()<<"[usr] got the [src]!"
Drop()
view()<<"[usr] dropped the [src]!"
src.loc=locate(usr.x,usr.y,usr.z)
if(usr.EHelm==1)
usr.EHelm=0
else
return
Equip()
if(usr.Warrior==1)
if(usr.EHelm==0)
usr<<"You equipped the [src]!"
suffix="E"
usr.overlays += /obj/Warrior/Helms/Ascalon_Helm
usr.EHelm=1
return
if(usr.EHelm==1)
usr<<"You have something equipped in this spot!"
return
else
usr<<"You can't use this since your not a warrior!"
Unequip()
if(usr.EHelm==1)
usr<<"You unequipped the [src]!"
suffix=""
usr.overlays -= /obj/Warrior/Helms/Ascalon_Helm
usr.EHelm=0
return
if(usr.EHelm==0)
usr<<"There is nothing equipped here."


Problem description:
When I test this in the game for ANY item I press the button to unequip the item, the Overlay of the item will stay there if I logged out with the overlay on. But if i didnt log out with the overlay on, it will remove it just fine. How would I fix this?
If you save the mob's icon in their savefile (which is a bad idea anyway because icons are huge compared to the small amount of data you actually need saved), then any overlays attached to the icon will be merged with it.

To avoid this, you need to keep track of which items the player has equipped, then un-equip those items before the save and re-equip them afterwards, and also when the savefile is loaded.

Its also good to put the "You equipped..." text message in a separate function somewhere so players don't get spammed with messages when this happens.
Don't save icons.
Use a nice overlay system to handle your overlays. Adding icons to your overlays list isn't very good, it limits what you can do with them.
In response to Foomer
Ok, i got a way now..

mob/var/list/OverlayList=list()

obj/Warrior/Helms
icon='Warrior Helms.dmi'
Ascalon_Helm
icon_state="Ascalon"
density=0
layer=MOB_LAYER+1
verb
Get()
set src in oview(1)
set category = "Commands"
Move(usr)
view()<<"[usr] got the [src]!"
Drop()
view()<<"[usr] dropped the [src]!"
src.loc=locate(usr.x,usr.y,usr.z)
if(usr.EHelm==1)
usr.EHelm=0
else
return
Equip()
if(usr.Warrior==1)
if(usr.EHelm==0)
usr<<"You equipped the [src]!"
suffix="E"
usr.overlays += /obj/Warrior/Helms/Ascalon_Helm
usr.EHelm=1
usr.OverlayList+=/obj/Warrior/Helms/Ascalon_Helm
return
if(usr.EHelm==1)
usr<<"You have something equipped in this spot!"
return
else
usr<<"You can't use this since your not a warrior!"
Unequip()
if(usr.EHelm==1)
usr<<"You unequipped the [src]!"
suffix=""
usr.overlays -= /obj/Warrior/Helms/Ascalon_Helm
usr.EHelm=0
usr.OverlayList-=/obj/Warrior/Helms/Ascalon_Helm
return
if(usr.EHelm==0)
usr<<"There is nothing equipped here."

mob
Logout()
usr.overlays-=usr.overlays
var/savefile/F = new(ckey)
Write(F)
del(src)

mob/Login()
var/savefile/F = new(ckey)
Read(F)
usr.overlays+=usr.OverlayList
return ..()


and i guess that Bad overlay demo thing helped me, gave me the idea to use a list..lol
In response to Kaiochao


<code> runtime error: Icon not found. proc name: remOverlay (/atom/proc/remOverlay) usr: Reno Kujika (/mob) src: Reno Kujika (/mob) call stack: Reno Kujika (/mob): remOverlay(, null) Reno Kujika (/mob): Sword() </code>



Yeah, that overlay code was soo good..
In response to Reno Kujika
lol i did it this way once

usr.overlays -= usr.overlays

so it take them all off so i dont worry :) cause they can put back