ID:2015079
 
(See the best response by Ter13.)
Code:
            proc/FlashSquare(var/mob/A)
A.overlays += icon([icon file here],[icon_state here])
sleep(30)
A.overlays -= icon([icon file here],[icon_state here])


Problem description:
I have a .dmi file. In that dmi file, I want it to play an animation. It will work when the animation loop is set to infinity but when the animation is only set to 1 time, it won't play at all. The overlay will still add but the animation will not play.
Play-once overlays don't work. You'll have to find another solution.
Do you have any alternative suggestions?
Would you prefer safe, or easy?
safe
The safest technique is to use a global image tracker. global images are /image objects that are visible to everyone. /image objects are by default only visible to the players you specify, so we'll have to keep track of a list of clients to show them to everyone when they are added to the global list, and remove them from everyone when they are removed from the global list.

var
list/global_images = list()
list/clients = list()

proc
add_global_image(image/i)
global_images |= i
clients << i

remove_global_image(image/i)
for(var/client/c in clients)
c.images -= i

add_client(client/c)
c.images |= global_images
clients |= c

remove_client(client/c)
c.images -= global_images
clients -= c

//maintain the global clients list
client
New()
add_client(src)
. = ..()
Del()
remove_client(src)
..()


Now, to use this in your specific case:

proc/FlashSquare(mob/A)
var/image/i = image([Icon file here],A,[icon_state here]) //create the image
add_global_image(i) //add it to the global images list (showing it to everyone)
sleep(30) //wait
remove_global_image(i) //remove the image from the global images list (hiding it from everyone)
i.loc = null //send the image to null, which should cause it to be garbage collected


I'm 90% sure that should work... I recall a similar case where maybe this didn't work for some reason because /image objects don't reset the appearance flags properly, but if that's the case we can try something different.
Just for reference, whats the easy way? (So I can try both ways)
Best response
proc/FlashSquare(mob/A)
var/oldappearance = appearance
overlays = list()
underlays = list(oldappearance)
icon = [Icon file here]
icon_state = [icon_state here]
sleep(30)
appearance = oldappearance


30% sure that will work, but any changes to the appearance of the mob that happen during the flash timer will not stick, so it's unsafe.
Ahh I've seen that one before, it didn't have the results I was looking for. Thanks for your help though! :)
Did the first solution work like you expected?
Not at first but I tweeked it a bit and I got it perfect. It was just adjusting the pixel x and y variables though.