world
mob = /mob/player
mob/player
var
list/selected = list()
Stat()
statpanel("Selected Units:")
for(var/x in selected)
stat(x)
mob/units
var
faction = "h"
Click()
var/mob/player/p = usr
var/image/I = image('Select.dmi',src,faction,layer=MOB_LAYER+1)
if(src in p.selected)
// overlays -= I
p.selected -= src
p.client.images -= I
return 1
if(!(src in p.selected))
// overlays += I
p.selected += src
p << I
return 1
Problem description:
When a client logs in, he is automatically changed to a /mob/player (line 2). When I click on a /mob/unit, the overlay is added and the unit is added to my select list, when I click on it again, it is removed from my select list, but the [image] overlay remains there.
Why isnt the [image] overlay removed and how would I remove it?
Note: If I replace the "p << I" and "p.client.images -= I" with OVERLAYS (commented lines), it works fine.
Thanks!
Also, use else instead of the same if() twice with a ! operator in one.
And your problem lies in the fact that you're removing a new image, not the old one, by the way. Keep some form of reference to the old image, and then delete it rather than making a new one and deleting it.
Remember, images aren't overlays unless you add them to the overlays list; they are like objs and mobs.