View previous topic :: View next topic |
Author |
Message |
rrc55 Voice
Joined: 11 Mar 2009 Posts: 29
|
Posted: Tue Jul 15, 2014 6:33 pm Post subject: Module Timed Think Function |
|
|
I want to write a command independent mod function that performs a task at a regular interval. How do I export it to the core? Is there a better way? Thank you. |
|
Back to top |
|
 |
rrc55 Voice
Joined: 11 Mar 2009 Posts: 29
|
Posted: Wed Jul 16, 2014 1:51 am Post subject: |
|
|
I figured it out in case anyone is interested.
Code: | void ecgn_test(void)
{
dprintf(DP_SERVER, "PRIVMSG %s :TESTING\n", "#ecgn");
}
char *ecgn_start(Function *func_table)
{
global = func_table;
module_register(MODULE_NAME, ecgn_table, 1, 2);
if (!(irc_funcs = module_depend(MODULE_NAME, "irc", 1, 3)))
return "This module requires irc 1.3 or later.";
if (!module_depend(MODULE_NAME, "eggdrop", 108, 0))
return "This module requires eggdrop1.8 or later.";
add_hook(HOOK_MINUTELY, (Function) ecgn_test);
add_builtins(H_pub, stat_cmd);
return NULL;
} |
The key here is the add_hook() function. This will call my ecgn function every minute without having to bind it to a command. This is exactly what I wanted.
Hope this helps someone. |
|
Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3740 Location: Mint Factory
|
Posted: Wed Jul 16, 2014 9:07 am Post subject: |
|
|
And why would you bother with this if there's time or cron binds? _________________ Once the game is over, the king and the pawn go back in the same box. |
|
Back to top |
|
 |
rrc55 Voice
Joined: 11 Mar 2009 Posts: 29
|
Posted: Wed Jul 16, 2014 10:31 pm Post subject: |
|
|
What are those and how do you use them? |
|
Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3740 Location: Mint Factory
|
Posted: Thu Jul 17, 2014 2:12 am Post subject: |
|
|
If you don't have TCL Commands file then grab it from here and then look at the bind cron or bind time. _________________ Once the game is over, the king and the pawn go back in the same box. |
|
Back to top |
|
 |
rrc55 Voice
Joined: 11 Mar 2009 Posts: 29
|
Posted: Thu Jul 17, 2014 10:05 am Post subject: |
|
|
Thanks. |
|
Back to top |
|
 |
|