ID:143365
 
Code:
obj/button/attack
icon = 'HUD.dmi'
icon_state = "attack"
layer = MOB_LAYER+10
New(client/C)
C.screen += src
..()
Click(usr)
usr:Attack()


Problem description:
This is a button on the hud I want it to use the verb attack for the player. But it seems to think the button wants to use attack not the usr. please help
Click()
usr.Attack()


Please look up what each parameter for the procedure is next time.

Also, avoid using : unless you want runtime errors (such as when you remove a variable later on and forgot to delete all references to it)
In response to GhostAnime (#1)
No I still get the problem
mob
verb
Attack(mob/M in get_step(src,src.dir))
if(usr.made==0)
usr << "<font color=green>Please make a character first.</font>"
return
if(usr.pvp == "Yes")
var/damage = src.strength - M.defense
if(M.defense >= src.strength)
damage = 0
if(M.client)
M.hp -= damage
src <<"You attack [M] for [damage]!"
src << sound('sound/bash.wav',,,3,100)
M <<"<font color=red>You are being attacked by</font> [src]!"
src.level_up()
updateHealth()
M.death_check(src)
else
M.hp -= damage
src <<"You attack [M] for [damage]!"
src << sound('sound/bash.wav',,,2,100)
M <<"You are being attacked by [src]!"
src.exp += M.giveexp
src.level_up()
updateHealth()
M.death_check(src)
else
if(usr.pvp == "No")
if(usr.team == "Good"&&M.team == "Good")
usr << "Can not hurt your friends."
return
else
var/damage = src.strength - M.defense
if(M.defense >= src.strength)
damage = 0
if(M.client)
M.hp -= damage
src <<"You attack [M] for [damage]!"
src << sound('sound/bash.wav',,,2,100)
M <<"You are being attacked by [src]!"
src.level_up()
updateHealth()
M.death_check(src)
else
M.hp -= damage
src <<"You attack [M] for [damage]!"
src << sound('sound/bash.wav',,,2,100)
M <<"You are being attacked by [src]!"
src.exp += M.giveexp
src.level_up()
updateHealth()
M.death_check(src)

^
|
Heres my attack verb
obj/button/attack
icon = 'HUD.dmi'
icon_state = "attack"
layer = MOB_LAYER+10
Click()
// usr.Attack()
New(client/C)
C.screen += src
..()

^
|
Heres my attack button
------------------------------------------------------------
and it does nothing at all... when I had it at usr:attack it thought the button was using the attack! not the mob...
In response to Hellonagol (#2)
That's because no arguments were being sent over (hint: You may want to read up on arguments in the DM Ref.)

A suggested alternative for Attack() is not to get a mob reference by means of an argument but defining it in the verb itself.<font color="black">.</font>. though I suggest it would be easier to locate() a /mob using get_step().

That may sound a bit complex and fancy, but all you have to do is read it carefully instead of skimming through. If you're lucky enough to use that noggin' when replying to me, you'll probably get a treat to the answer I was mentioning :P
In response to GhostAnime (#3)
or I can make a button on the skin...
In response to Hellonagol (#4)
You did not understand a word I said, neh?

When you do "usr.Attack()", the argument is null. Meaning in the verb, M is defined as nothing. Place the definition of who M is in the body of the verb, not in the argument.

Hint: There's a (hidden) link posted to a helpful solution of a similar problem in my last post. Either find that link or use forum search ;/