obj/proc
itemCreation(mob/user/p , obj/item/clothe/i , var/color)
var/obj/item/clothe/z = new i.type
if(istype(i, /obj/item/clothe/shirt))
i.icon = p.gender == "male" ? 'male shirt.dmi' : 'female shirt.dmi'
z.icon = i.icon
if(i.canDye) z.icon += color
z.Move(p)
/////// this is how I equip the items
else if(istype(src, /obj/item/clothe))
if(!usr.buying)
if(!worn)
worn = 1
usr.overlays += src
src.suffix = "Equipped"
usr << "You equip: [src]----Type: [src.type]"
else
src.worn = 0
usr.overlays -= src
src.suffix = "
Problem description: My problem is that when I unequip an item, the icon stays. It's not removed from the player.
Now, if you are depending on layers then this method would not be idea at all. So, an alternative (although not really great) is to use a separate list and simply apply that.
There are several cons to using the second method I showed. First con would be by applying a list, it creates memory build, which will slow down the server(memory = lag without CPU in essence).
To help prevent memory build, use a procedure to check if the list is null or empty. If list is null when adding an object, have the procedure set the list to new/list and then add the object. If the list is empty when after an object is removed, have the game transform the list to null. Also, you really want to use world/mob=mob/whatever, this will help crop variables. BYOND basically adds X amount of memory per variable, and this depends on the type (number, string, list). So, the more variables every single base path has, the more memory is used. Therefore, if an extra variable can be avoided, it's idea to do so.
Example of the best way I can think of:
As a heads up, if you decide to go with the last mentioned method, you will want to use addOverlay with icons as well. This being, because when add/removeOverlay are ran, they will set overlay to them, making anything added to the players overlay but not in the list disappear (from overlapping them of course).