ID:270043
 
i treide making a cool down time for this, but it didnt work right.

Mining_Rock
icon_state = "Mining Rock"
density = 1
verb/Mine()
set src in view(1)
if(!(locate(/obj/item/Skills_Item/Mining_Hammer) in usr.contents))
usr << "You must have a Mining Hammer."
else
if(usr.key == "Pyro_dragons")
flick('Yuan.dmi',usr)
flick("Mining",usr)
sleep(12)
icon_state = "Broken Mining Rock"
MA = 0
if(usr.M < 20)
if(prob(7.5))
var/obj/item/Ore/Iron_Ore/IO = new (loc)
IO.loc = usr
usr << "You get an Iron Ore!"
if(usr.M > 20 && usr.M < 50)
if(prob(20))
var/obj/item/Ore/Iron_Ore/IO = new (loc)
IO.loc = usr
usr << "You get an Iron Ore!"
if(usr.M > 50 && usr.M < 80)
if(prob(40))
var/obj/item/Ore/Iron_Ore/IO = new (loc)
IO.loc = usr
usr << "You get an Iron Ore!"
if(usr.M > 80)
if(prob(60))
var/obj/item/Ore/Iron_Ore/IO = new (loc)
IO.loc = usr
usr << "You get an Iron Ore!"
density = 0
usr.MiningEXP += 25
if(usr.MiningEXP >= usr.maxMiningEXP)
usr.MiningEXP = 0
if(usr.M == maxM)
usr << "You cannot level anymore in Mining"
usr.M += 0
else
usr.M += 1
usr << "Your Mining Level is now [usr.M]!"
usr.maxMiningEXP = usr.maxMiningEXP * 1.20
sleep(200)
icon_state = "Mining Rock"
density = 1
else
icon_state = "Broken Mining Rock"
if(usr.M < 20)
if(prob(20))
var/obj/item/Ore/Iron_Ore/IO = new (loc)
IO.loc = usr
usr << "You get an Iron Ore!"
density = 0
usr.MiningEXP += 25
if(usr.MiningEXP >= usr.maxMiningEXP)
usr.MiningEXP = 0
if(usr.M == maxM)
usr << "You cannot level anymore in Mining"
usr.M += 0
else
usr.M += 1
usr << "Your Mining Level is now [usr.M]!"
usr.maxMiningEXP = usr.maxMiningEXP * 1.20
sleep(200)
icon_state = "Mining Rock"
density = 1

i want to make it so that they ahve to wait for it to respawn before they can use it again. i tried it, but it made them wait for one to respawn and they could not hit any others. thx much guys.
can i have a little help plz?
In response to Pyro_dragons
Heh, 2 days and still no reply. Well, just read the above post please. Thank you.
Could you elaborate slightly on your problem? Looking through someone else's uncommented code is enough of a pain in the ass, even without having to search through 20 lines or so to get even any idea of A) what you're trying to do, B) what is actually happening, and C) what your problem is.

In the future, it would be appreciated if you took a little more time posting your problem; try and explain what your code is supposed to do, and in detail what is actually happening. You should know what you're trying to accomplish with your own code (if you don't, why did you write it?), and finding out what is actually happening can frequently lead you to your answer.

From what I can tell, your problem is that there is no cooldown time. It looks like you misunderstand what the sleep() proc does. sleep() just puts a delay in a proc; all thats happening with your particular use of it is that there is a 20 second delay before the Mining_Rock's density and icon_state change again.

If you want to prevent the rock from being used again, you could check to see if the icon_state of the Mining_Rock is set to "Mining Rock", and if its not, don't like anything happen. IE, you could put this near the top of your verb
if(icon_state!="Mining Rock") return

If you need more help, please see to the problems I noted in your post.
In response to Gathin
Ok, first of all, I know what sleep does and how it works. Second, the code is not that complicated it just looks that way. Third, I think topic itself explains what i was trying to do and I think you misunderstood what I meant by I've tried and failed. I meant that i tried to do it and it didn't work, so I took it out.

Anyway, it works now, so thank you. Please don't criticize how I posted that because i explained what I need to do. You just misunderstood it a bit.