ID:1001135
 
Code:
mob/proc
FocusTrainingProc()
if(src.Training) {src<<"You are already [src.Training]";return}
if(!src.CanAct()) {src<<"You appear to be Busy...";return}
src.Training="Focus Training"
src.icon_state="powerup"
src.AddAura()
while(1)
if(src.StopFocusTraining && src.Training=="Focus Training")
src.StopFocusTraining=0
src.Training=0;break
if(src.Subscriber) src.TrainingExp+=1
src.TrainingExp+=1
sleep(10)


Problem description:How can i make it so while keep checking if user has stopped Focust traing every sec but user only gain exp every 3 to 10 sec

I have no idea what you're asking but wouldn't you be better off doing something like:

mob
verb/f_train()
training=!training
src<<"You [training ? "begin" : "stop"] training."
while(training)
src<<"lol train"
sleep(10)
var/tmp/training=0


You seem to be using unnecessary variables.
underneath the while(1) you could make a for-loop:

while(1)
for(var/inc = rand(3,10), inc, inc--)

//do stop-training check and whatever else

sleep(10)

TrainingExp += 1


The for loop will execute 3 to 10 times, waiting one second each time. Only when it is done will TrainingExp be increased, and then it goes back to the for() loop

Also, I'm pretty sure you can remove all that "src." Save you a lot of typing!
Mmmm ... src is syntactic sugar there. There's certainly arguments you could make for/against someone adding it. Personally I prefer the clarity explicitly denoting src provides.

For OP:

How does someone stop focusing? Do they ... click a verb or UI button or something? Might they also stop focusing if they get tired?
In response to Stephen001
Stephen001 wrote:
How does someone stop focusing? Do they ... click a verb or UI button or something? Might they also stop focusing if they get tired?

Unsure on the tiredness, but I assume that he has a verb which ends the procedure by setting StopFocusTraining to 1.

This seems pointless as my example does the same thing but without any unnecessary variables, if statements or extra lines of code.