ID:1615287
 
(See the best response by Lugia319.)
Code:
obj
Food
Speed_Pills
icon='Items.dmi'
icon_state="Speed"
density=0
name="Speed Pills"
verb

Interact()
set src in oview(1)
usr << "You get the [src]!"
Move(usr)

verb
Eat()
if(usr.SpeedPill==0)
usr <<"You eat the [src]. You feel strange."
usr.HP-=15
sleep(5)
usr <<"You lose some health, but you feel great."
usr.damage+=15
usr.SpeedPill=1
del src
sleep(500)
usr.SpeedPill=0
usr.damage-=15
else
if(usr.SpeedPill==1)
usr<<"I wouldn't take anymore [src] if I were you."


Problem description: I have this item in my game called "Speed Pills". Basically, the user sacrifices a little bit of health to increase their attack for a set amount of time.

However, I think the timer stops when the player logs out. How could I go about making it that even if they log out it'll continue to countdown when they log back in?

Or, should I just set it to stop completely if someone logs out. IE, when they log back in they no longer have that buff.

Best response
The sleep(500) isn't executed because the source has been deleted.

You'd need to save existing buff timers and reapply them if you wanted buffs to persist through logout.
In response to Lugia319
Lugia319 wrote:
The sleep(500) isn't executed because the source has been deleted.

You'd need to save existing buff timers and reapply them if you wanted buffs to persist through logout.

I've never messed with timers and what-not. Especially aspects involving world.time

Any tips?

Maybe check for existing buffs on the player upon logout, save those with the player in an associative list, and then when you load the player extract the necessary information to recreate the buff and the timer.