ID:140324
 
Code:
client/New()//When a client connects to a mob
..()
new/obj/hud/button1(src)


obj
hud
var
clicked

clicked = 0

button1
layer = MOB_LAYER + 2
icon = 'button1.dmi'
icon_state = "1"
New(client/C)
screen_loc = "1,1"
C.screen+=src
DblClick()
if(src.clicked == 0)
src.icon_state = "2"
src.clicked = 1
if(src.clicked == 1)
src.icon_state = "1"
src.clicked = 0


Problem description:
dont work

Edit
        button1
layer = MOB_LAYER + 2
icon = 'button1.dmi'
icon_state = "1"
New(client/C)
screen_loc = "1,1"
C.screen+=src
DblClick()
if(src.clicked == 0)
src.icon_state = "2"
src.clicked = 1
return
if(src.clicked == 1)
src.icon_state = "1"
src.clicked = 0
return
            DblClick()
if(src.clicked == 0)
src.icon_state = "2"
src.clicked = 1
if(src.clicked == 1)
src.icon_state = "1"
src.clicked = 0


Replace src with usr.

To add as a learning experience, you CAN use usr in Click() if that's what you were thinking.
In response to Gr1m d4 r34p3r
Euhh. Nooooo.
In response to Gr1m d4 r34p3r
No, don't, src is the object being clicked, usr the the object clicking.
In response to Ulterior Motives
He wants the usr to change, right?
In response to Gr1m d4 r34p3r
He is changing a variable named clicked that belongs to the object being clicked. So I would assume not. Since he doesn't state what doesn't work that makes it a little harder to find out what he is trying to do.
In response to Gr1m d4 r34p3r
nvm i found out the problem, add return after src.clicked = 0 and src.clicked = 1
In response to Ulterior Motives
the problem was that it set the "clicked" to 1 then went to the next command which turned "clicked" to 0. kinda confusing since this never happened before to me.
In response to XnathanielX
            DblClick()
if(!src.clicked)
src.icon_state = "2"
src.clicked = TRUE
else if(src.clicked)
src.icon_state = "1"
src.clicked = FALSE

Since you are using two if() statements like that it is checking if clicked is 0. Then changing it to 1 and continuing on to the next if() statement. Using an else or else if() statement should solve that.
In response to Ulterior Motives
ah never knew you could put else and if together.
In response to Ulterior Motives
Or, you could shorten all the useless if-else evaluation and simply operate on what you need ;)

DblClick()
clicked = !clicked
icon_state = "[clicked]"


Granted, you'd have to rename the icon states from 1/2, to 0/1, but, well... if you really like them as 1/2, just replace "[clicked]" by "[clicked + 1]".
In response to XnathanielX
"else if" is just shorthand. These two are equivalent:
if(A)
//A
else
if(B)
//B
else
if(C)
//C
else
//D


if(A)
//A
else if(B)
//B
else if(C)
//C
else
//D
In response to Schnitzelnagler
Never thought of doing that. When I first looked at it, it seemed it should make clicked = 0. After I thought about it though, it made sense because of the ! operator. The more you know.