Black Knight's Small Cron System for AdminMod (plugin_bk_cron) |
|
|
CONTENTS
Introduction: What is a cron system?For the linux os there was a need for a system to issue commands at a certain point of time. That is, why the cron system was developed. The main aim was to execute recurring tasks without the need of a user sitting the computer at a certain point of time. The developed concept was highly flexible and easy. Of course, to understand it one has to deal with the syntax first. That may not be that easy in the beginning, but the possibility to generate a complex data flows and tasks with only a few lines makes it very powerful. Any scheduler has to match with this system.So, a cron system is able to issue preprogammed taskes at different times. It is easy to understand that it would make sense to port it to AdminMod. Of course it can be only a "light" version. Features: What is the BK Cron System able to do?
Limitations: What is the BK Cron System NOT able to do?
Purposes: What can I do with it?
Installation:
Configuration:The separator is the SPACE (double spaces, tabulators, etc. in the time area will lead to errors, but are allowed in the command area of course)Example: * * * * * 1 mp_timelimit 20 delete
In case you want to delete it, you have to write the same task again but appending a "delete". Example: 0 12 * * * 1 mp_timelimit 20 0 0 * * * 1 mp_timelimit 30 delete The first task sets the time limit to 20 minutes every day at 12 o'clock (independently from month and weekday). This persits over all mapchanges, whatever set in the server.cfg. The second task deletes the first task from the tasks.cfg and sets the time limit to 30 minutes. This value is valid until the next mapchange. Afterwards the value from the server.cfg will be vaild, as long as it is defined there. One task at different points of time: You want to execute the same task at different points of time. There are two possibilities: Example for a task issued every quarter of an hour: 0,15,30,45 * * * * 0 say quarter of an hour reached! or 60/4 * * * * 0 say quarter of an hour reached! Both examples do the same. But the second always starts at zero! Execute a adminmod command: This is easy. Just put a admin_command in front of your command. Once again, an example like shown above: 0,15,30,45 * * * * 0 admin_command quarter of an hour reached! Executing a lot of commands at one point of time: Just use the "exec" command. Of course you should have the right file on the server. Furthermore, please note that you can use the exec command as a cvar to persist the values included, but is only one exec command allowed in the tasks.cfg. Limitations:
Commands:You need to have the right 65536 to execute these!admin_cron_add <command> This command writes a new task to the first free place at the schedule.ini. "Command" must follow the structure of the examplar. admin_cron_del <line> Admin_cron_del deletes a specific entry in the schedule.ini. A line number is needed, which could be obtained by admin_cron_list. admin_cron_edit <line> <command> Changes the entry of a specific entry in the schedule.ini. Be aware that this always overwrites the whole entry. admin_cron_forcecheck This command overwrites the timer and checks if something should be executed. I used this for debuging issues. Because it does not take a lot of space, I kept it. admin_cron_forceexe <line> The command admin_cron_forceexe executes a command independently from the point of time. You have to provide the line number of course (see admin_cron_list). This command might be useful after long server outtakes, so you can execute every command which was skipped manually. admin_cron_list <line> This command shows the contents of the schedule.ini in steps by ten entries. The parameter is optional. In case you provide a 11, it shows the lines 11-20. Furthermore, you get the line number, which is needed for some of the other commands. admin_cron_refresh This should be executed, if the schedule.ini was edited manually. The schedule.ini will be reread then. You can achieve the same by doing a mapchange. admin_cron_timeleft <0/1> This command deactivates/activates (0/1) the setting of the mp_timeleft cvar. By activating the current timeleft gets written to this cvar every minute. So, the remaining time can be seen from tools like hlsw or hldm Beispiele:Sundaymapcycle:Supposing we want to do a Sunday-Custummap. Of course, it should work automatically. If you set mapcyclefile in your server.cfg, the tasks would be: 0 0 * * 7 1 mapcyclefile sunmapcycle.txt 0 0 * * 1 1 mapcyclefile mapcycle.txt delete The first task will be executed every sunday (7) at 0:00 setting mapcyclefile to sunmapcycle.txt and writing this to the tasks.cfg. The value of mapcyclefile will therefore remain in case of a mapchange. The second task will be executed every monday (1) at 0:00 setting mapcyclefile back to mapcycle.txt and deleting it from the tasks.cfg. After the next mapchange, the value in the server.cfg will be set (therefore you already set this value). If no mapcyclefile is set in the server.cfg, you can handle that a little different, although the first variant will works, too: 0 0 * * 7 0 mapcyclefile sunmapcycle.txt 0 0 * * 1 0 mapcyclefile mapcycle.txt Because no value is set in the server.cfg, it remains in case of a mapchange. It is valid until the next setting, server crash or restart. If the server crashes during the sunday it would switch back to mapcycle.txt on restart. That is, why I recommend using variant 1. Daily mapcycle: It may be that you want to change the mapcycle on a daily basis: 0 0 * * 1 1 mapcyclefile monmapcycle.txt 0 0 * * 2 1 mapcyclefile tuemapcycle.txt 0 0 * * 3 1 mapcyclefile wedmapcycle.txt 0 0 * * 4 1 mapcyclefile thumapcycle.txt 0 0 * * 5 1 mapcyclefile frimapcycle.txt 0 0 * * 6 1 mapcyclefile satmapcycle.txt 0 0 * * 7 1 mapcyclefile sunmapcycle.txt You can leave out "delete", because only one entry of each cvar can exist in the tasks.cfg and this gets overwritten. Changing mapcycle 2 times a month: 0 0 1 * * 1 mapcyclefile mapcycle1.txt 0 0 15 * * 1 mapcyclefile mapcycle2.txt The mapcycle is changed on every first and fifteenth of the month. Announcing clanwar: If you have a public server, of course you would dislike to immediately kick everybody without warning. So an announcement would be a nice thing: 40,45,50,55 19 * * * 0 admin_command admin_csay Clanwar at 8 PM! This task executes a csay every 5 minutes from 19:40 until 19:55. Instead of the asterisk you can use a real date, so in case you forgot to delete this entry, it would not display on the next day: 40,45,50,55 19 4 1 * 0 admin_command admin_csay Clanwar at 8 PM! This entry is only valid on the 4th of January. Starting the clanwar: Of course you can also load the war settings: 0 20 * * * 1 exec cw.cfg 0 23 * * * 1 exec server.cfg delete The war settings are loaded from 8-11 PM. Unfortunately, the plugin does not know about the end of the war. That is, why I recommend using the CW Creator v1.2: 0 20 * * * 0 admin_command admin_war_set [WING] [-+MfG+-] password de_dust de_dust2 esl.cfg The war can be ended anytime you use admin_war_end. You just have to delete the set-entry. Announcement of Friday the 13th: OK, it is not really a useful example, but it should give an idea, what can be done with this plugin: 0 0 13 * 5 0 admin_command admin_tsay Friday the 13th.^nGood luck! Every Friday the 13th at 12 PM, this command is issued. Known Bugs:
FAQ:
Support:
ToDo:
Thanks to:
Changelog
|