ID:1663962
 
Health regen is triggered every time the player gets damaged or logs in. I made the regen tick every 5 seconds but it feels sluggish. I did this because I thought it would put less stress on the server than having it tick every second. Would it really matter?
A simple incremental for just players really wouldn't be much to handle. When you've got more things going on is when you'll want to conceder increasing the delay on what you can. (Say creating a couple of hundred objects while trying to keep the game playable - and things like that).
    SMR(mob/M)
if(M.Sregening == TRUE)
return
else
M.Sregening = TRUE
spawn()
while(M.stam <= M.maxstam)
if(rest == 1)
M.stamregen = 10
else
M.stamregen = 5

M.stam+=M.stamregen
sleep(50)
M.stam = M.maxstam
M.Sregening = FALSE


Thats for stam regen. There are also two other stats that can regen - HP and MP. They're similar to stamina regen just with different variables. If there were 50 players and all three procs were running per player (so 150 procs in all running concurrently) would there be any noticeable lag?
I rewrote your code because I was bored and I saw a couple small things that urked me slightly.

mob
proc
SMR() // I don't like doing mob procs the way you did with the mob as an argument. so bleh.
/*
I just did a rewrite because reasons.
--
You can simplify your code quite a bit, although you're over-stressing the cpu-load(especially since it only updates every 5 seconds).
*/

if(!Sregening)
// You don't have to check if the Sregening var is true if you're just trying to make sure it isn't.
// instead you can just check if it's false right off the bat.
Sregening = TRUE
spawn
while(stam < maxstam) // <-- this part.
/*
You did have a little hiccup on this part of your code.
You used <= which would continue to regenerate stamina even when stam was full (<= translates to less than OR equal to).
*/

stam += 5 // Why set a variable for stamregen when you can just outright update it with 5?
if(rest)
stam += 5 // Then add a bonus 5 if they're resting. This will shave a liitle more. (:
if(stam > maxstam) stam = maxstam // throw this here before the five second sleep so there's never an awkwardly brief surplus.
sleep 50

Sregening = FALSE


To answer your question, you shouldn't be so concerned with lag on a simple loop like this. You should definitely be able to shorten your sleep to to at least world.tick_lag*2 (tick_lag pending, ofc.)
Further cleanup. Slightly more efficient, slightly cleaner:

Notably, I removed the unnecessary spawn(), which makes this function impossible to profile accurately. Instead, I replaced it with setting waitfor to 0, which effectively does the same thing as a spawn, but without the added consequence of the code not showing up properly in the profiler.

mob/proc
SMR()
set waitfor = 0
if(Sregening)
return
Sregening = TRUE
while(stam < maxstam)
if(rest)
stam = min(maxstam,stam+10)
else
stam = min(maxstam,stam+5)
sleep(50)
Sregening = FALSE


There's no real reason to worry about something this simple, though. You can have this happen thousands upon thousands of times per second with no real impact.