hobo crontab, possible problem?
here is my hobo_crontab.ini...
Code:
* * * 00 | say "ES Clan is looking for donors! say !donate to read more in depth!"
* * * 05 | say "ES Clan is looking for donors! say !donate to read more in depth!"
* * * 10 | say "ES Clan is looking for donors! say !donate to read more in depth!"
* * * 15 | say "ES Clan is looking for donors! say !donate to read more in depth!"
* * * 20 | say "ES Clan is looking for donors! say !donate to read more in depth!"
* * * 25 | say "ES Clan is looking for donors! say !donate to read more in depth!"
* * * 30 | say "ES Clan is looking for donors! say !donate to read more in depth!"
* * * 35 | say "ES Clan is looking for donors! say !donate to read more in depth!"
* * * 40 | say "ES Clan is looking for donors! say !donate to read more in depth!"
* * * 45 | say "ES Clan is looking for donors! say !donate to read more in depth!"
* * * 50 | say "ES Clan is looking for donors! say !donate to read more in depth!"
* * * 55 | say "ES Clan is looking for donors! say !donate to read more in depth!"
it IS enabled in plugins.ini, no errors in the error log..
I did post in http://forums.alliedmods.net/showthr...715#post852715
it cuts off at the 'don' part of donors!
can someone help me out here?
the source:
PHP Code:
/* ******************************************************************************** * AMX Mod X script. * * Hobo Crontab (hobo_crontab.sma) * Copyright (C) 2008-2009 hoboman * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * when you downloaded AMX Mod X; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * In addition, as a special exception, the author gives permission to * link the code of this program with the Half-Life Game Engine ("HL * Engine") and Modified Game Libraries ("MODs") developed by Valve, * L.L.C ("Valve"). You must obey the GNU General Public License in all * respects for all of the code used other than the HL Engine and MODs * from Valve. If you modify this file, you may extend this exception * to your version of the file, but you are not obligated to do so. If * you do not wish to do so, delete this exception statement from your * version. * ********************************************************************************* */
/* * For a full plugin description read: http://forums.alliedmods.net/showthread.php?t=69068 */
#include <amxmodx> #include <amxmisc> #include <fakemeta>
#define PLUGIN "Hobo Crontab" #define AUTHOR "hoboman313" #define VERSION "1.1"
#define MAX_CRON_ENTRIES 32 #define MAX_CMDS_PER_ENTRY 8
//the dates and the commands from a crontab entry are stored in these new fileDate[MAX_CRON_ENTRIES][4], fileCmd[MAX_CRON_ENTRIES][MAX_CMDS_PER_ENTRY][32] new entryCount, fileCmdCount[MAX_CRON_ENTRIES], secondsStart public plugin_init() { register_plugin(PLUGIN, VERSION, AUTHOR) register_forward( FM_ServerDeactivate, "change_level") register_concmd("hobo_crontab_reload","reload_file", ADMIN_RCON, " - reloads the crontab entries") register_concmd("hobo_show_time","show_server_time", _, " - shows the server's time") //let's not fudge up the server while it is loading a new map set_task( 10.0, "check_cron_entries", 0 ) set_task( 60.0, "check_schedule", 1, _, _, "b" ) new secondsString[3] get_time( "%S", secondsString, 2 ) secondsStart = str_to_num(secondsString) }
//the server is about to change map public change_level() { new secondsString[3], secondsFinish get_time( "%S", secondsString, 2 ) secondsFinish = str_to_num(secondsString) //if this is true then we run the chance of missing an entry that was supposed to be run //on the same minute as the map change happened if( secondsFinish < secondsStart ) check_schedule() }
//read and record all the crontab entries from the crontab.ini file public check_cron_entries() { static cronFile[64], line[128] new fileDisc get_configsdir( cronFile, 50 ) format( cronFile, 63, "%s/hobo_crontab.ini", cronFile ) //if the crontab.ini file doesn't exist, create it and stop the plugin if(!file_exists(cronFile)) { write_file(cronFile,"* * * 30 | say hobo_crontab is not set up") return PLUGIN_HANDLED } fileDisc = fopen(cronFile,"rt") //set everything to default for ( new i=0; i<MAX_CRON_ENTRIES; i++) { for ( new j=0; j<MAX_CMDS_PER_ENTRY;j++) { fileCmd[i][j][0]='^0' } } entryCount = 0 //read from the crontab.ini file one line at a time for( new i=0; fgets( fileDisc, line, sizeof(line)-1 ); i++ ) { trim ( line ) if( strlen(line) < 10 ) { i-- continue } get_args( line, i )
entryCount++ } fclose(fileDisc) return PLUGIN_HANDLED }
//from one line of the crontab file entry, distribute the dates into the fileDate and fileCmd arrays public get_args( line[], i ) { new stringHolder[4][3], fileCmdLen = sizeof( fileCmd[][] ) new cmdCount, vertLineSymb, lenLine = strlen(line) parse( line, stringHolder[0], 2, stringHolder[1], 2, stringHolder[2], 2, stringHolder[3], 2 ) for ( new j = 0; j<4; j++ ) { if( is_str_num( stringHolder[j] ) ) fileDate[i][j] = str_to_num( stringHolder[j] ) else fileDate[i][j]= -1 } vertLineSymb = contain( line, "|" ) format( line, strlen(line)-1, "%s", line[vertLineSymb+1] ) //now all the dates from an entry are in the fileDate, but the commands from the entry are still in line lenLine = strlen( line )
for( cmdCount=0; strlen(line) > 2; cmdCount++ ) { trim( line )
strtok( line, fileCmd[i][cmdCount], fileCmdLen, line, lenLine, ',' ) } fileCmdCount[i] = cmdCount }
//check the cron entry date with the server date then start the task to run the entry cmds public check_schedule() { static strServerDateString[16], strServerDate[4][3], serverDate[4] //get the current minute, hour, day of week from server get_time("%d %w %H %M", strServerDateString, 15) parse( strServerDateString, strServerDate[0], 2, strServerDate[1], 2, strServerDate[2], 2, strServerDate[3], 2 ) for( new i=0; i<4; i++ ) { serverDate[i]=str_to_num(strServerDate[i]) } for( new i=0; i < entryCount; i++ ) { //check if right now is meets the date requirement of the entry //a fileDate will be -1 if it is not a number meaning the entry should be run every day of month, day of week, hour or minute if( ( serverDate[0]==fileDate[i][0] || fileDate[i][0]==-1 ) && ( serverDate[1]==fileDate[i][1] || fileDate[i][1]==-1 ) && ( serverDate[2]==fileDate[i][2] || fileDate[i][2]==-1 ) && ( serverDate[3]==fileDate[i][3] || fileDate[i][3]==-1 ) ) { execute_entry(i) } } }
//run the cmds from the cron entry public execute_entry(i) { new cmdCount = fileCmdCount[i] static pluginsFile[64], line[64], pluginName[32] new lineNumb=0, bool:writeAble, file get_configsdir( pluginsFile, sizeof(pluginsFile)-1 ) format( pluginsFile, 63, "%s/plugins.ini", pluginsFile ) for ( new j=0; j<cmdCount; j++) { trim( fileCmd[i][j] ) //if the command wants to uncomment a plugin if( equal( fileCmd[i][j], "@", 1 ) ) { file=fopen( pluginsFile,"r+t" ) writeAble=false format( pluginName, sizeof(pluginName)-1, ";%s", fileCmd[i][j][1] ) for( lineNumb=0; !feof(file); lineNumb++ ) { fgets( file, line, sizeof(line)-1 ) trim( line ) if( equal( pluginName, line, strlen(pluginName) ) ) { writeAble=true break } } if( writeAble ) { format( pluginName, sizeof(pluginName)-1, "%s", fileCmd[i][j][1] ) write_file( pluginsFile, pluginName, lineNumb ) } fclose( file ) } //if the command wants to comment a plugin else if( equal(fileCmd[i][j], "$", 1) ) { file = fopen(pluginsFile,"r+t") writeAble=false format( pluginName, sizeof(pluginName)-1, "%s", fileCmd[i][j][1] ) for( lineNumb=0; !feof(file); lineNumb++ ) { fgets( file, line, sizeof(line)-1 ) trim( line ) if( equal( pluginName, line, strlen(pluginName) ) ) { writeAble=true break } } if( writeAble ) { format( pluginName, sizeof(pluginName)-1, ";%s", pluginName )
write_file( pluginsFile, pluginName, lineNumb ) } fclose(file) } //if the command is just a regular server command then just excecute it now else { server_cmd( fileCmd[i][j] ) server_exec() } } }
//if admin uses the amx_crontab_reload command public reload_file(id,level,cid) { if(!cmd_access(id,level,cid,1)) return PLUGIN_HANDLED client_print( id, print_chat, "Reloading the crontab entries." ) check_cron_entries() return PLUGIN_HANDLED }
public show_server_time(id,level,cid) { new strServerDateString[16], strServerDate[4][3] get_time("%d %w %H %M", strServerDateString, 15) parse( strServerDateString, strServerDate[0], 2, strServerDate[1], 2, strServerDate[2], 2, strServerDate[3], 2 )
client_print( id, print_chat, "Current Server Time: Day of Month is %s, Day of Week is %s, Hour is %s, Minute is %s", strServerDate[0], strServerDate[1], strServerDate[2], strServerDate[3] ) }
the game im installing this on is TFC (if that matters)
|