ID:146609
 
Code:
mob
verb
attack()
for(src in get_step(usr,usr.dir))
if(src.client) //was src.key
yes = 1
damage = src.defense / (src.defense / 2) * usr.strength + rand(1,usr.strength)
src.health -= damage
src << "[usr] starts a battle with you!"
src << "[usr] does [damage] damage to you!"
usr << "You do [damage] to [src]!"

if(src.health <= 0)
src.loc = locate(lastx,lasty,lastz)
src.health = src.maxHealth
usr << "You killed [src]."

if(!src.client) //was !src.key or try typesof
yes = 1
attacking = 1
damage = src.defense / (src.defense / 2) * usr.strength + rand(1,usr.strength)
src.health -= damage
src << "[usr] starts a battle with you!"
oview(1) << "[usr] begins to battle with [src]!"
src << "[usr] does [damage] damage to you!"
usr << "You do [damage] to [src]!"
Retaliate()
if(src.health <= 0)
src.health = src.maxHealth
attacking = 0
usr << "You killed [src]."
gain_Level()
del src


Problem description:What I need is everytime the person attacks, it has a delay to the attacking, so the person can not just spam kill and spam attack. The sleep has obviously failed.

DragonMasterGod wrote:
Problem description:What I need is everytime the person attacks, it has a delay to the attacking, so the person can not just spam kill and spam attack. The sleep has obviously failed.

What sleep? I did not see one there. If you had one, and only executed the main part of the function when !attacking, it should work fine.
First of all, changing the value of src doesn't really make sense when you can define your own variable instead.

Second, "yes" is a really bad variable name. The name of a variable should be a comment in itself.

Finally, when you have a line like this:

my_proc()


and when you have a line like this:

my_var = 0


You're really saying this:

src.my_proc()


and you're saying:

src.my_var = 0


You may not want to use src for some of these, considering you changed its value. Of course, this will be a moot point when you follow the first piece of advice.
mob/var/tmp/AttackWait = 0 //make it reset every time the user plays...

mob/verb/Attack(mob/M in oview(1))
if(src.AttackWait > world.time) return //If it hasn't waited long enough?
var/DelayTime = 10 // delaytime (one second)
src.AttackWait = world.time+DelayTime //Set the time to wait
//Attack Crap


I believe this is what you wanted?

P.S.: Use if and else. And also, do what Wizkidd0123 said in his post.

-Ryan
In response to Ryne Rekab
This isn't working. Wth I'm messing with it left and right and it still refuses to work.
In response to DragonMasterGod
Sorry, I thought that it works. I don't know what I did wrong. Sorry.

-Ryan
DragonMasterGod wrote:
Problem description:What I need is everytime the person attacks, it has a delay to the attacking, so the person can not just spam kill and spam attack. The sleep has obviously failed.

A thread with this same delay question is posted at least once a week -- try using the forum search to find existing threads regarding attack delays. Here's a link to my library:

Action Control


~Polatrite~
In response to Polatrite
If everyone did this, then the forums would be boring. You're boring.

-Ryan