AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   hobo crontab, possible problem? (https://forums.alliedmods.net/showthread.php?t=95279)

HLM 06-22-2009 01:13

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 
entryCountfileCmdCount[MAX_CRON_ENTRIES], secondsStart
    
public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_forwardFM_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_task10.0"check_cron_entries")
    
    
set_task60.0"check_schedule"1__"b" )
    
    new 
secondsString[3]
    
get_time"%S"secondsString)
    
secondsStart str_to_num(secondsString)
}

//the server is about to change map
public change_level()
{
    new 
secondsString[3], secondsFinish
    get_time
"%S"secondsString)
    
    
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
cronFile50 )
    
formatcronFile63"%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=0i<MAX_CRON_ENTRIESi++)
    {
        for ( new 
j=0j<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=0fgetsfileDisclinesizeof(line)-); i++ )
    {        
        
trim line )
        
        if( 
strlen(line) < 10 )
        {
            
i--
            continue
        }
        
        
get_argsline)

        
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_argsline[], )
{
    new 
stringHolder[4][3], fileCmdLen sizeoffileCmd[][] )
    new 
cmdCountvertLineSymblenLine strlen(line)
    
    
parselinestringHolder[0], 2stringHolder[1], 2stringHolder[2], 2stringHolder[3], )
    
    for ( new 
0j<4j++ )
    {
        if( 
is_str_numstringHolder[j] ) )
            
fileDate[i][j] = str_to_numstringHolder[j] )
        else
            
fileDate[i][j]= -1
    
}
    
    
vertLineSymb containline"|" )
    
formatlinestrlen(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 strlenline )

    for( 
cmdCount=0strlen(line) > 2cmdCount++ )
    {
        
trimline )

        
strtoklinefileCmd[i][cmdCount], fileCmdLenlinelenLine',' )
    }
    
    
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"strServerDateString15)
    
    
parsestrServerDateStringstrServerDate[0], 2strServerDate[1], 2strServerDate[2], 2strServerDate[3], )
    
    for( new 
i=0i<4i++ )
    {
        
serverDate[i]=str_to_num(strServerDate[i])
    }
    
    
    for( new 
i=0entryCounti++ )
    {
        
//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]==-) && ( serverDate[1]==fileDate[i][1] || fileDate[i][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=0bool:writeAblefile
    
    get_configsdir
pluginsFilesizeof(pluginsFile)-)
    
formatpluginsFile63"%s/plugins.ini"pluginsFile )
    
    for ( new 
j=0j<cmdCountj++)
    {
        
trimfileCmd[i][j] )
        
        
//if the command wants to uncomment a plugin
        
if( equalfileCmd[i][j], "@") )
        {
            
file=fopenpluginsFile,"r+t" )
            
            
writeAble=false
            format
pluginNamesizeof(pluginName)-1";%s"fileCmd[i][j][1] )
            
            for( 
lineNumb=0; !feof(file); lineNumb++ )
            {
                
fgetsfilelinesizeof(line)-)
                
trimline )
                
                if(    
equalpluginNamelinestrlen(pluginName) ) )
                {
                    
writeAble=true
                    
break
                }
            }
            
            if( 
writeAble )
                {
                    
formatpluginNamesizeof(pluginName)-1"%s"fileCmd[i][j][1] )
                    
write_filepluginsFilepluginNamelineNumb )
                }
                        
            
fclosefile )
        }        
            
        
//if the command wants to comment a plugin
        
else if( equal(fileCmd[i][j], "$"1) )
        {            
            
file fopen(pluginsFile,"r+t")
            
            
writeAble=false
            format
pluginNamesizeof(pluginName)-1"%s"fileCmd[i][j][1] )
                
            for( 
lineNumb=0; !feof(file); lineNumb++ )
            {
                
fgetsfilelinesizeof(line)-)
                
trimline )
                
                if(    
equalpluginNamelinestrlen(pluginName) ) )
                {
                    
writeAble=true
                    
break
                }
            }
                
            if( 
writeAble )
            {
                
formatpluginNamesizeof(pluginName)-1";%s"pluginName )

                
write_filepluginsFilepluginNamelineNumb )
            }
            
            
fclose(file)
        }
            
        
//if the command is just a regular server command then just excecute it now
        
else
        {
            
server_cmdfileCmd[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
idprint_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"strServerDateString15)
    
    
parsestrServerDateStringstrServerDate[0], 2strServerDate[1], 2strServerDate[2], 2strServerDate[3], )

    
client_printidprint_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)


All times are GMT -4. The time now is 15:33.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.