-
Notifications
You must be signed in to change notification settings - Fork 102
Timers
Tomm edited this page Apr 7, 2019
·
3 revisions
Timers are a way to execute logic at specific intervals for players or npcs.
Timers are an efficient way to handle logic that should occur for a player or npc after a specific amount of game cycles.
Timers are made up of two parts:
TimerKey
TimerMap
TimerKey
s are defined in your plugin file and the TimerMap
is stored for each player and can be accessed via player.timers
.
package gg.rsmod.plugins.content.mechanics.poison
// If we want the timer to save on log-out, we specify a name
// inside the TimerKey.
val NEXT_POISON_DMG = TimerKey()
// To test, we can create a short command to poison ourselves.
on_command("poisonme") {
player.timers[NEXT_POISON_DMG] = 4 // Queue the timer to be invoked in 4 game cycles
}
on_timer(NEXT_POISON_DMG) {
val damage = 4
player.hit(damage)
player.timers[NEXT_POISON_DMG] = 4 // Queue the timer to be invoked in 4 game cycles
}
Join the Discord if you have any questions or want to chat with the community
- User Guide