ID:2038896
 
Problem description: well as far as i'm concerned everything works in my code, but i want it to pick a random target that's in the list and remove one and add a new one in it's place, also remove the target image from the mob that was removed from the list but it is not calling Remove(pick(src.targets)) line at all it seem's when the target.len max is reached.

Code:
/player
var list/targets[] = list()
var max_targets = 3
proc
set_target()
rem_target()
set_target(var/player/o)
if(o in targets)//if the target is already i the list.
return

var/image/target_icon = image('target.dmi', o)
if(o.client && o) if(targets.len == max_targets)
src.targets.Remove(pick(src.targets))

src.targets.Add(o)
o.overlays.Add(target_icon)
src << target_icon

rem_target(var/player/o, var/image/target_icon)
if(o in targets) for(target_icon in src.overlays)
src.overlays.Remove(target_icon)
src.targets.Remove(o)

What you should be doing is keeping every player's target image in a variable, and adding/removing that image from client.images of the user when targeting/untargeting, respectively.

var/image/target_icon
for(target_icon in src.overlays)
del target_icon


What you are doing there is wrong since src.overlays doesn't contain image objects. But I'm sure what you were trying to do was specifically remove the target_icon image created in set_target(), which isn't the right way to go about it (see beginning of post).
ive been alil off now adays idk where my head's been at making common mistakes like that, makes sense thank you ill repost if any problems persist