ID:269933
 
SO in my game, you click units to select them. Then it makes this little box around them. Here's the code I have.
client/Click(atom/A)
var/image/I
var/mob/player/P=usr
if(istype(A,/mob/units/))
if(P.selected==A)
P.selected=null
else
I=image('select.dmi',A,"blue")
P<<I
P.selected=A


I want to know how to remove the image overlay. I'm probably approaching this the wrong way.

NOTE: I don't want other players to see which units are selected.
del() it.
In response to Kalzar
I actually have that. I didn't put it in the code...because then i figured I'm more asking what's wrong with the code than how to do it.

client/Click(atom/A)
var/image/I
var/mob/player/P=usr
if(istype(A,/mob/units/))
if(P.selected==A)
del(I)
P.selected=null
else
I=image('select.dmi',A,"blue")
P<<I
P.selected=A

Yet it doesn't work.
In response to Dark Weasel
The problem is that you're deleting nothing. I isn't going to be the last person you selected because you never told the compiler to do that. The best thing to do is to define a list with the reference to what you clicked.

client
var/list/selec_list = list()
Click(atom/A)
var/image/I
var/mob/player/P = src.mob
if(P.selected == A)
I = selec_list[A]
del(I)
else
I = image('select.dmi', A, "blue")
P << I
selec_list[A] = I // use an associative list to hold the reference and image for later deletion
P.selected = A


~~> Unknown Person
In response to Unknown Person
Thanks that worked.