Ever wanted a heartbeat to run once per minute, or hour, or day, or perhaps multiple effects applied at different time intervals?
Now you can, with this updated version of my heartbeat system.
****Updated to show how it is possible to have multiple intervals in the same heartbeat, see updated code submission for details. -DO NOT- simply overwrite the old code provided, you must -still- download and import the update erf into your module, even if you downloaded this system before the update, and be sure to select all resources and overwrite them when importing.
(First time downloaders only need to download and import the update as it contains the modified extra scripts and the unmodified item blueprint and additional script).
It works by retrieving a Local Int from and item in any character's inventory (which they receive on log in), and based on that Int, firing an alternate command for the character, then resetting the "timer", as before, just with multiple "timers".
To install this system, you must set your module event scripts as follows.
*Or include them to your already existing module event scripts.
On Client Enter = far_modenter.
On Client Leave = far_modleave.
On Enter of the module's starting area (the first area the player enters on log in) = far_oocenter.
And then use the heartbeat script far_heartbeat where desired in the "On heartbeat" slot, (module, area, placable, etc).
The heartbeat script is posted below and commented, see for instructions on use.
***Note this system uses Local Ints set via an item, do to this being significantly faster then a database call. You -must- import the item into your module for this to work, and it will remain in the character's inventory. That being said, as with all heartbeats, be careful, even though you can change the time between intervals of the desired effect(S), resource intensive effects will still cause server drain.***
****DO NOT SIMPLY COPY AND PASTE THE POSTED SCRIPT OVER YOUR OWN HEARTBEAT ONE, IT IS POSTED AS A DESCRIPTION OF HOW TO ALTER THE SCRIPT, AND THAT ALONE.****
You need the download the erf and import it into your module. Alter the heartbeat script from -the script editor- from there. Without the other scripts, this system will not work.****
I know that many who do download systems from the vault are not script savvy, so any questions you may have about setting this all up, please post below. Thank you.
Once again, Enjoy. :)
*Thank you to FunkySwerve for your help on this one. ;)
Farchilde's Heartbeat Interval System Version 2.0 (you must import this erf if you downloaded the old system to use the extended options, be sure to select and overwrite all resources when asked while importing).
Also, with this system it is possible to add as many intervals as one wishes, to do so is not that difficult.
First make a new const int with a unique name such as "rInt" in the line directly under the other ones. And with a new numeric interval.
So this...
const int iInt = 10;//the first interval fires 1/minute----//
const int oInt = 600;//the second 1/hour-------------------//
const int aInt = 14400;//the third 1/day (24 hours)--------//
Becomes this...
const int iInt = 10;//the first interval fires 1/minute----//
const int oInt = 600;//the second 1/hour-------------------//
const int aInt = 14400;//the third 1/day (24 hours)--------//
const int rInt = 28800;//the third 1/2 days (48 hours)--------//
Then in the line directly above "oPC = GetNextPC():"
Add this code...
if (GetLocalInt(oItem, "hb_count4")== rInt)
{
//--------------------"1/2 days effect"--------------------//
SetLocalInt(oItem, "hb_count4", 0);
}
else if (GetLocalInt(oItem, "hb_count4")!= rInt)
{
int nInt;
nInt = GetLocalInt(oItem, "hb_count4");
nInt += 1;
SetLocalInt(oItem, "hb_count3", nInt);
}
And so forth, just to give you an idea of how flexible and versatile this system may be.
Enjoy. :)
Posted by Graymaster at 2008-07-08 07:16:59 Voted 10.00 on 07/08/08
Excellent piece of work and extremely well explained and documented. Thanks much for sharing.