Raised This Month: $ Target: $400
 0% 

Festival Countdown


Post New Thread Reply   
 
Thread Tools Display Modes
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 11-27-2023 , 19:43   Re: Festival Countdown
Reply With Quote #11

I added what you requested.. this was only quickly tested.

Put the below formatted festivals in amxmodx/configs/Festivals.ini
<Month> <Day> <FestivalName>
Code:
01 01 "New Years Day"
05 05 "Cinco de mayo"
07 04 "Independance Day"
12 24 "Christmas Eve"
12 25 "Christmas Day"
12 31 "New Years Eve"
PHP Code:

#include <amxmodx>
#include <amxmisc>

new const Version[] = "0.2";

const 
MaxFestivals 10;
const 
MaxFestivalNameLength 32;
const 
DaySeconds 86400;

enum _:TimePeriodParts
{
    
tpStart,
    
tpEnd,
    
tpDescription16 ]
}
new const 
TimePeriods[][ TimePeriodParts ] = 
{
    { 
"Dawn" },
    { 
"Morning" },
    { 
11 "Ante meridiem" },
    { 
12 12 "Noon" },
    { 
13 17 "Afternoon" },
    { 
18 18 "Dusk" },
    { 
19 22 "Evening" },
    { 
23 23 "Midnight" }
};
    
enum _:FestivalParts
{
    
fpMonth,
    
fpDay,
    
fpFestivalMaxFestivalNameLength  1]
}
new  
FestivalsMaxFestivals ][ FestivalParts ];

new 
g_LoadedFestivals;

public 
plugin_init() 
{
    
register_plugin"Next Holiday" Version "bugsy" );

    
g_LoadedFestivals LoadFestivals();
    
set_task1.0 "GetNextHoliday" , .flags="b" );
}

public 
GetNextHoliday()
{
    new 
szMonth] , iMonth szDay] , iDay szYear] , szHour] , iHour szMinute] , szWeekDay10 ] , iFestivalIndex = -1;
        
    
format_timeszMonth charsmaxszMonth ) , "%m" );
    
format_timeszDay charsmaxszDay ) , "%d" );
    
format_timeszYear charsmaxszYear ) , "%Y" );
    
format_timeszHour charsmaxszHour ) , "%H" );
    
format_timeszMinute charsmaxszMinute ) , "%M" );
    
format_timeszWeekDay charsmaxszWeekDay ) , "%A" );
    
    
iMonth str_to_numszMonth );
    
iDay str_to_numszDay );
    
iHour str_to_numszHour );
    
    if ( ( 
iMonth >= Festivalsg_LoadedFestivals ][ fpMonth ] ) && ( iDay Festivalsg_LoadedFestivals ][ fpDay ] ) )
    {
        
iFestivalIndex 0;
    }
    else
    {
        for ( new 
g_LoadedFestivals i++ )
        {
            if ( 
iMonth <= Festivals][ fpMonth ] )
            {
                if ( 
iMonth == Festivals][ fpMonth ] )
                {
                    while ( ( 
g_LoadedFestivals ) && ( iDay Festivals][ fpDay ] ) )
                        
i++;
                }
                
                if ( ( 
iMonth == Festivals][ fpMonth ] ) && ( iDay == Festivals][ fpDay ] ) )
                {
                    
set_hudmessage255 255 255 0.25 0.25 0.0 1.0 );
                    
show_hudmessage"Today is %s Year %s Month %s Day %s^n%s %s:%s^nToday is %s" szYear szMonth szDay szWeekDay TimePeriodsGetTimePeriodiHour ) ]  , szHour szMinute Festivals][ fpFestival ] );
                    
iFestivalIndex 9999;
                }
                else
                {
                    
iFestivalIndex i;
                }
                
                break;
            }
        }
    }
    
    if ( 
iFestivalIndex != 9999 )
    {
        
GetDaysAwayiFestivalIndex );
    }
}

GetDaysAwayiFestivalIndex )
{
    new 
szMonth]  , szDay]  , szYear] , iYear szHour] , iHour szMinute] , szWeekDay10 ];
    new 
szTodayDate11 ] , szFestivalDate11 ];
    new 
iTodayTS iFestivalTS;
    
    
format_timeszMonth charsmaxszMonth ) , "%m" );
    
format_timeszDay charsmaxszDay ) , "%d" );
    
format_timeszYear charsmaxszYear ) , "%Y" );
    
format_timeszHour charsmaxszHour ) , "%H" );
    
format_timeszMinute charsmaxszMinute ) , "%M" );
    
format_timeszWeekDay charsmaxszWeekDay ) , "%A" );
    
    
iYear str_to_numszYear );
    
iHour str_to_numszHour );
    
    if ( 
str_to_numszMonth ) >  FestivalsiFestivalIndex ][ fpMonth ] )
        
iYear++;
        
    
formatexszTodayDate charsmaxszTodayDate ) , "%s/%s/%s" szMonth szDay szYear );
    
formatexszFestivalDate charsmaxszFestivalDate ) , "%d/%d/%d" FestivalsiFestivalIndex ][ fpMonth ] , FestivalsiFestivalIndex ][ fpDay ] , iYear );
    
    
iTodayTS parse_timeszTodayDate "%m/%d/%Y" );
    
iFestivalTS parse_timeszFestivalDate "%m/%d/%Y" );
    
    
set_hudmessage255 ,255 255 0.25 0.25 0.0 1.0 );
    
show_hudmessage,  "Today is %s Year %s Month %s Day %s^n%s %s:%s^n%s is %d day%s away" szYear szMonth szDay szWeekDay TimePeriodsGetTimePeriodiHour ) ]  , szHour szMinute 
                                                    
FestivalsiFestivalIndex ][ fpFestival ] , ((iFestivalTS-iTodayTS) / DaySeconds) , ((iFestivalTS-iTodayTS) / DaySeconds) > "s" ""  );

    
}

GetTimePeriodiHour )
{
    new 
iTPIndex;
    
    for ( new 
sizeofTimePeriods ) ; i++ )
    {
        if ( 
TimePeriods][ tpStart ] <= iHour <= TimePeriods][ tpEnd ] )
        {
            
iTPIndex i;
            break;
        }
    }
    
    return 
iTPIndex;
}

LoadFestivals()
{
    new 
szFile64 ] , iFile szLine41 ] , iDirLen iFestivalIndex;
    new 
szMonth] , szDay] , szFestivalsizeofFestivals[][ fpFestival ] ) ];
    
    
copyszFile[ ( iDirLen get_configsdirszFile charsmaxszFile ) ) ) ] , charsmaxszFile ) - iDirLen "/Festivals.ini" ); 
    
    
iFile fopenszFile "r" );
    
    while ( !
feofiFile ) && ( iFestivalIndex sizeofFestivals ) ) )
    {
        if ( 
fgetsiFile szLine charsmaxszLine ) ) && ( szLine] != ';') )
        {
            
parseszLine szMonth charsmaxszMonth ) , szDay charsmaxszDay ) , szFestival charsmaxszFestival ) );
            
            
FestivalsiFestivalIndex ][ fpMonth ] = str_to_numszMonth );
            
FestivalsiFestivalIndex ][ fpDay ] = str_to_numszDay );
            
copy(  FestivalsiFestivalIndex ][ fpFestival ] , charsmaxFestivals[][ fpFestival ] ) , szFestival );
            
            
iFestivalIndex++;
        }
    }
    
    return 
iFestivalIndex;

__________________

Last edited by Bugsy; 11-27-2023 at 21:28.
Bugsy is offline
Old 11-27-2023, 21:05
sb123
This message has been deleted by sb123.
sb123
Senior Member
Join Date: Jan 2007
Old 11-29-2023 , 09:30   Re: Festival Countdown
Reply With Quote #12

Quote:
Originally Posted by Bugsy View Post
I added what you requested.. this was only quickly tested.

Put the below formatted festivals in amxmodx/configs/Festivals.ini
<Month> <Day> <FestivalName>
Code:
01 01 "New Years Day"
05 05 "Cinco de mayo"
07 04 "Independance Day"
12 24 "Christmas Eve"
12 25 "Christmas Day"
12 31 "New Years Eve"
PHP Code:

#include <amxmodx>
#include <amxmisc>

new const Version[] = "0.2";

const 
MaxFestivals 10;
const 
MaxFestivalNameLength 32;
const 
DaySeconds 86400;

enum _:TimePeriodParts
{
    
tpStart,
    
tpEnd,
    
tpDescription16 ]
}
new const 
TimePeriods[][ TimePeriodParts ] = 
{
    { 
"Dawn" },
    { 
"Morning" },
    { 
11 "Ante meridiem" },
    { 
12 12 "Noon" },
    { 
13 17 "Afternoon" },
    { 
18 18 "Dusk" },
    { 
19 22 "Evening" },
    { 
23 23 "Midnight" }
};
    
enum _:FestivalParts
{
    
fpMonth,
    
fpDay,
    
fpFestivalMaxFestivalNameLength  1]
}
new  
FestivalsMaxFestivals ][ FestivalParts ];

new 
g_LoadedFestivals;

public 
plugin_init() 
{
    
register_plugin"Next Holiday" Version "bugsy" );

    
g_LoadedFestivals LoadFestivals();
    
set_task1.0 "GetNextHoliday" , .flags="b" );
}

public 
GetNextHoliday()
{
    new 
szMonth] , iMonth szDay] , iDay szYear] , szHour] , iHour szMinute] , szWeekDay10 ] , iFestivalIndex = -1;
        
    
format_timeszMonth charsmaxszMonth ) , "%m" );
    
format_timeszDay charsmaxszDay ) , "%d" );
    
format_timeszYear charsmaxszYear ) , "%Y" );
    
format_timeszHour charsmaxszHour ) , "%H" );
    
format_timeszMinute charsmaxszMinute ) , "%M" );
    
format_timeszWeekDay charsmaxszWeekDay ) , "%A" );
    
    
iMonth str_to_numszMonth );
    
iDay str_to_numszDay );
    
iHour str_to_numszHour );
    
    if ( ( 
iMonth >= Festivalsg_LoadedFestivals ][ fpMonth ] ) && ( iDay Festivalsg_LoadedFestivals ][ fpDay ] ) )
    {
        
iFestivalIndex 0;
    }
    else
    {
        for ( new 
g_LoadedFestivals i++ )
        {
            if ( 
iMonth <= Festivals][ fpMonth ] )
            {
                if ( 
iMonth == Festivals][ fpMonth ] )
                {
                    while ( ( 
g_LoadedFestivals ) && ( iDay Festivals][ fpDay ] ) )
                        
i++;
                }
                
                if ( ( 
iMonth == Festivals][ fpMonth ] ) && ( iDay == Festivals][ fpDay ] ) )
                {
                    
set_hudmessage255 255 255 0.25 0.25 0.0 1.0 );
                    
show_hudmessage"Today is %s Year %s Month %s Day %s^n%s %s:%s^nToday is %s" szYear szMonth szDay szWeekDay TimePeriodsGetTimePeriodiHour ) ]  , szHour szMinute Festivals][ fpFestival ] );
                    
iFestivalIndex 9999;
                }
                else
                {
                    
iFestivalIndex i;
                }
                
                break;
            }
        }
    }
    
    if ( 
iFestivalIndex != 9999 )
    {
        
GetDaysAwayiFestivalIndex );
    }
}

GetDaysAwayiFestivalIndex )
{
    new 
szMonth]  , szDay]  , szYear] , iYear szHour] , iHour szMinute] , szWeekDay10 ];
    new 
szTodayDate11 ] , szFestivalDate11 ];
    new 
iTodayTS iFestivalTS;
    
    
format_timeszMonth charsmaxszMonth ) , "%m" );
    
format_timeszDay charsmaxszDay ) , "%d" );
    
format_timeszYear charsmaxszYear ) , "%Y" );
    
format_timeszHour charsmaxszHour ) , "%H" );
    
format_timeszMinute charsmaxszMinute ) , "%M" );
    
format_timeszWeekDay charsmaxszWeekDay ) , "%A" );
    
    
iYear str_to_numszYear );
    
iHour str_to_numszHour );
    
    if ( 
str_to_numszMonth ) >  FestivalsiFestivalIndex ][ fpMonth ] )
        
iYear++;
        
    
formatexszTodayDate charsmaxszTodayDate ) , "%s/%s/%s" szMonth szDay szYear );
    
formatexszFestivalDate charsmaxszFestivalDate ) , "%d/%d/%d" FestivalsiFestivalIndex ][ fpMonth ] , FestivalsiFestivalIndex ][ fpDay ] , iYear );
    
    
iTodayTS parse_timeszTodayDate "%m/%d/%Y" );
    
iFestivalTS parse_timeszFestivalDate "%m/%d/%Y" );
    
    
set_hudmessage255 ,255 255 0.25 0.25 0.0 1.0 );
    
show_hudmessage,  "Today is %s Year %s Month %s Day %s^n%s %s:%s^n%s is %d day%s away" szYear szMonth szDay szWeekDay TimePeriodsGetTimePeriodiHour ) ]  , szHour szMinute 
                                                    
FestivalsiFestivalIndex ][ fpFestival ] , ((iFestivalTS-iTodayTS) / DaySeconds) , ((iFestivalTS-iTodayTS) / DaySeconds) > "s" ""  );

    
}

GetTimePeriodiHour )
{
    new 
iTPIndex;
    
    for ( new 
sizeofTimePeriods ) ; i++ )
    {
        if ( 
TimePeriods][ tpStart ] <= iHour <= TimePeriods][ tpEnd ] )
        {
            
iTPIndex i;
            break;
        }
    }
    
    return 
iTPIndex;
}

LoadFestivals()
{
    new 
szFile64 ] , iFile szLine41 ] , iDirLen iFestivalIndex;
    new 
szMonth] , szDay] , szFestivalsizeofFestivals[][ fpFestival ] ) ];
    
    
copyszFile[ ( iDirLen get_configsdirszFile charsmaxszFile ) ) ) ] , charsmaxszFile ) - iDirLen "/Festivals.ini" ); 
    
    
iFile fopenszFile "r" );
    
    while ( !
feofiFile ) && ( iFestivalIndex sizeofFestivals ) ) )
    {
        if ( 
fgetsiFile szLine charsmaxszLine ) ) && ( szLine] != ';') )
        {
            
parseszLine szMonth charsmaxszMonth ) , szDay charsmaxszDay ) , szFestival charsmaxszFestival ) );
            
            
FestivalsiFestivalIndex ][ fpMonth ] = str_to_numszMonth );
            
FestivalsiFestivalIndex ][ fpDay ] = str_to_numszDay );
            
copy(  FestivalsiFestivalIndex ][ fpFestival ] , charsmaxFestivals[][ fpFestival ] ) , szFestival );
            
            
iFestivalIndex++;
        }
    }
    
    return 
iFestivalIndex;

Bugsy Hello! Sorry to bother you again
This plugin has a bug
The problem with the plugin now is that if all the November holidays have already been displayed, if I don't delete the November holidays from the ini, it will result in the inability to display the December holidays. Only empty holidays and 0 days will be displayed

Today is %s Year %s Month %s Day %s^n%s %s:%s^n is 0 day away

How to keep all the festivals that have been counted down before without deleting them. Because if there are previous festivals in ini now, the next festival will not be displayed
Please fix this issue. Thank you
__________________
sb123 is offline
Send a message via ICQ to sb123 Send a message via MSN to sb123 Send a message via Yahoo to sb123
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 11-29-2023 , 20:35   Re: Festival Countdown
Reply With Quote #13

Quote:
Originally Posted by sb123 View Post
Bugsy Hello! Sorry to bother you again
This plugin has a bug
The problem with the plugin now is that if all the November holidays have already been displayed, if I don't delete the November holidays from the ini, it will result in the inability to display the December holidays. Only empty holidays and 0 days will be displayed

Today is %s Year %s Month %s Day %s^n%s %s:%s^n is 0 day away

How to keep all the festivals that have been counted down before without deleting them. Because if there are previous festivals in ini now, the next festival will not be displayed
Please fix this issue. Thank you
The issue is fixed and I validated many scenarios, this version should be good
PHP Code:

#include <amxmodx>
#include <amxmisc>

new const Version[] = "0.3";

const 
MaxFestivals 10;
const 
MaxFestivalNameLength 32;
const 
DaySeconds 86400;

enum _:TimePeriodParts
{
    
tpStart,
    
tpEnd,
    
tpDescription16 ]
}
new const 
TimePeriods[][ TimePeriodParts ] = 
{
    { 
"Dawn" },
    { 
"Morning" },
    { 
11 "Ante meridiem" },
    { 
12 12 "Noon" },
    {
13 17 "Afternoon" },
    { 
18 18 "Dusk" },
    { 
19 22 "Evening" },
    { 
23 23 "Midnight" }
};
    
enum _:FestivalParts
{
    
fpMonth,
    
fpDay,
    
fpFestivalMaxFestivalNameLength  1]
}
new  
FestivalsMaxFestivals ][ FestivalParts ];

new 
g_LoadedFestivals;

public 
plugin_init() 
{
    
register_plugin"Next Festival" Version "bugsy" );

    
g_LoadedFestivals LoadFestivals();
    
set_task1.0 "GetNextFestival" , .flags="b" );
}

public 
GetNextFestival()
{
    new 
szMonth] , iMonth szDay] , iDay szYear] , szHour] , iHour szMinute] , szWeekDay10 ] , iFestivalIndex = -bool:bIsToday;
        
    
format_timeszMonth charsmaxszMonth ) , "%m" );
    
format_timeszDay charsmaxszDay ) , "%d" );
    
format_timeszYear charsmaxszYear ) , "%Y" );
    
format_timeszHour charsmaxszHour ) , "%H" );
    
format_timeszMinute charsmaxszMinute ) , "%M" );
    
format_timeszWeekDay charsmaxszWeekDay ) , "%A" );
    
    
iMonth str_to_numszMonth );
    
iDay str_to_numszDay );
    
iHour str_to_numszHour );
    
    
//Check if current month/day are beyond the last festival month/day in the list, meaning the first in the list is considered next.
    
if ( ( iMonth >= Festivalsg_LoadedFestivals ][ fpMonth ] ) && ( iDay Festivalsg_LoadedFestivals ][ fpDay ]  ) )
    {
        
iFestivalIndex 0;
    }
    else
    {
        for ( new 
g_LoadedFestivals i++ )
        {
            if ( ( 
iMonth == Festivals][ fpMonth ] ) && ( iDay == Festivals][ fpDay ] ) )
            {
                
//Festival is today
                
iFestivalIndex i;
                
bIsToday true;
                break;
            }
            else if (  ( ( 
Festivals][ fpMonth ] == iMonth) && ( Festivals][ fpDay ] > iDay ) ) || (  Festivals][ fpMonth ]  > iMonth ) )
            {
                
//Festival is in current month on future day OR in future month
                
iFestivalIndex i;
                break;
            }
        }
    }

    if ( 
iFestivalIndex == -
        
set_fail_state"An unhandled exception has occurred" );
        
    if ( 
bIsToday )
    {
        
set_hudmessage255 255 255 0.25 0.25 0.0 1.0 );
        
show_hudmessage"Today is %s Year %s Month %s Day %s^n%s %s:%s^nToday is %s" szYear szMonth szDay szWeekDay TimePeriodsGetTimePeriodiHour ) ]  , szHour szMinute FestivalsiFestivalIndex ][ fpFestival ] );
    }
    else
    {
        
PrintDaysAwayiFestivalIndex );
    }
}

PrintDaysAwayiFestivalIndex )
{
    new 
szMonth]  , szDay]  , szYear] , iYear szHour] , iHour szMinute] , szWeekDay10 ];
    new 
szTodayDate11 ] , szFestivalDate11 ];
    new 
iTodayTS iFestivalTS;
    
    
format_timeszMonth charsmaxszMonth ) , "%m" );
    
format_timeszDay charsmaxszDay ) , "%d" );
    
format_timeszYear charsmaxszYear ) , "%Y" );
    
format_timeszHour charsmaxszHour ) , "%H" );
    
format_timeszMinute charsmaxszMinute ) , "%M" );
    
format_timeszWeekDay charsmaxszWeekDay ) , "%A" );
    
    
iYear str_to_numszYear );
    
iHour str_to_numszHour );
    
    if ( 
str_to_numszMonth ) >  FestivalsiFestivalIndex ][ fpMonth ] )
        
iYear++;
        
    
formatexszTodayDate charsmaxszTodayDate ) , "%s/%s/%s" szMonth szDay szYear );
    
formatexszFestivalDate charsmaxszFestivalDate ) , "%d/%d/%d" FestivalsiFestivalIndex ][ fpMonth ] , FestivalsiFestivalIndex ][ fpDay ] , iYear );
    
    
iTodayTS parse_timeszTodayDate "%m/%d/%Y" );
    
iFestivalTS parse_timeszFestivalDate "%m/%d/%Y" );
    
    
set_hudmessage255 ,255 255 0.25 0.25 0.0 1.0 );
    
show_hudmessage,  "Today is %s Year %s Month %s Day %s^n%s %s:%s^n%s is %d day%s away" szYear szMonth szDay szWeekDay TimePeriodsGetTimePeriodiHour ) ]  , szHour szMinute 
                                                    
FestivalsiFestivalIndex ][ fpFestival ] , ((iFestivalTS-iTodayTS) / DaySeconds) , ((iFestivalTS-iTodayTS) / DaySeconds) > "s" ""  );    
}

GetTimePeriodiHour )
{
    new 
iTPIndex;
    
    for ( new 
sizeofTimePeriods ) ; i++ )
    {
        if ( 
TimePeriods][ tpStart ] <= iHour <= TimePeriods][ tpEnd ] )
        {
            
iTPIndex i;
            break;
        }
    }
    
    return 
iTPIndex;
}

LoadFestivals()
{
    new 
szFile64 ] , iFile szLine41 ] , iDirLen iFestivalIndex;
    new 
szMonth] , szDay] , szFestivalsizeofFestivals[][ fpFestival ] ) ];
    
    
copyszFile[ ( iDirLen get_configsdirszFile charsmaxszFile ) ) ) ] , charsmaxszFile ) - iDirLen "/Festivals.ini" ); 
    
    
iFile fopenszFile "r" );
    
    while ( !
feofiFile ) && ( iFestivalIndex sizeofFestivals ) ) )
    {
        if ( 
fgetsiFile szLine charsmaxszLine ) ) && ( szLine] != ';') )
        {
            
parseszLine szMonth charsmaxszMonth ) , szDay charsmaxszDay ) , szFestival charsmaxszFestival ) );
            
            
FestivalsiFestivalIndex ][ fpMonth ] = str_to_numszMonth );
            
FestivalsiFestivalIndex ][ fpDay ] = str_to_numszDay );
            
copy(  FestivalsiFestivalIndex ][ fpFestival ] , charsmaxFestivals[][ fpFestival ] ) , szFestival );
            
            
iFestivalIndex++;
        }
    }
    
    return 
iFestivalIndex;

__________________

Last edited by Bugsy; 11-29-2023 at 20:37.
Bugsy is offline
sb123
Senior Member
Join Date: Jan 2007
Old 11-29-2023 , 21:43   Re: Festival Countdown
Reply With Quote #14

Quote:
Originally Posted by Bugsy View Post
The issue is fixed and I validated many scenarios, this version should be good
PHP Code:

#include <amxmodx>
#include <amxmisc>

new const Version[] = "0.3";

const 
MaxFestivals 10;
const 
MaxFestivalNameLength 32;
const 
DaySeconds 86400;

enum _:TimePeriodParts
{
    
tpStart,
    
tpEnd,
    
tpDescription16 ]
}
new const 
TimePeriods[][ TimePeriodParts ] = 
{
    { 
"Dawn" },
    { 
"Morning" },
    { 
11 "Ante meridiem" },
    { 
12 12 "Noon" },
    {
13 17 "Afternoon" },
    { 
18 18 "Dusk" },
    { 
19 22 "Evening" },
    { 
23 23 "Midnight" }
};
    
enum _:FestivalParts
{
    
fpMonth,
    
fpDay,
    
fpFestivalMaxFestivalNameLength  1]
}
new  
FestivalsMaxFestivals ][ FestivalParts ];

new 
g_LoadedFestivals;

public 
plugin_init() 
{
    
register_plugin"Next Festival" Version "bugsy" );

    
g_LoadedFestivals LoadFestivals();
    
set_task1.0 "GetNextFestival" , .flags="b" );
}

public 
GetNextFestival()
{
    new 
szMonth] , iMonth szDay] , iDay szYear] , szHour] , iHour szMinute] , szWeekDay10 ] , iFestivalIndex = -bool:bIsToday;
        
    
format_timeszMonth charsmaxszMonth ) , "%m" );
    
format_timeszDay charsmaxszDay ) , "%d" );
    
format_timeszYear charsmaxszYear ) , "%Y" );
    
format_timeszHour charsmaxszHour ) , "%H" );
    
format_timeszMinute charsmaxszMinute ) , "%M" );
    
format_timeszWeekDay charsmaxszWeekDay ) , "%A" );
    
    
iMonth str_to_numszMonth );
    
iDay str_to_numszDay );
    
iHour str_to_numszHour );
    
    
//Check if current month/day are beyond the last festival month/day in the list, meaning the first in the list is considered next.
    
if ( ( iMonth >= Festivalsg_LoadedFestivals ][ fpMonth ] ) && ( iDay Festivalsg_LoadedFestivals ][ fpDay ]  ) )
    {
        
iFestivalIndex 0;
    }
    else
    {
        for ( new 
g_LoadedFestivals i++ )
        {
            if ( ( 
iMonth == Festivals][ fpMonth ] ) && ( iDay == Festivals][ fpDay ] ) )
            {
                
//Festival is today
                
iFestivalIndex i;
                
bIsToday true;
                break;
            }
            else if (  ( ( 
Festivals][ fpMonth ] == iMonth) && ( Festivals][ fpDay ] > iDay ) ) || (  Festivals][ fpMonth ]  > iMonth ) )
            {
                
//Festival is in current month on future day OR in future month
                
iFestivalIndex i;
                break;
            }
        }
    }

    if ( 
iFestivalIndex == -
        
set_fail_state"An unhandled exception has occurred" );
        
    if ( 
bIsToday )
    {
        
set_hudmessage255 255 255 0.25 0.25 0.0 1.0 );
        
show_hudmessage"Today is %s Year %s Month %s Day %s^n%s %s:%s^nToday is %s" szYear szMonth szDay szWeekDay TimePeriodsGetTimePeriodiHour ) ]  , szHour szMinute FestivalsiFestivalIndex ][ fpFestival ] );
    }
    else
    {
        
PrintDaysAwayiFestivalIndex );
    }
}

PrintDaysAwayiFestivalIndex )
{
    new 
szMonth]  , szDay]  , szYear] , iYear szHour] , iHour szMinute] , szWeekDay10 ];
    new 
szTodayDate11 ] , szFestivalDate11 ];
    new 
iTodayTS iFestivalTS;
    
    
format_timeszMonth charsmaxszMonth ) , "%m" );
    
format_timeszDay charsmaxszDay ) , "%d" );
    
format_timeszYear charsmaxszYear ) , "%Y" );
    
format_timeszHour charsmaxszHour ) , "%H" );
    
format_timeszMinute charsmaxszMinute ) , "%M" );
    
format_timeszWeekDay charsmaxszWeekDay ) , "%A" );
    
    
iYear str_to_numszYear );
    
iHour str_to_numszHour );
    
    if ( 
str_to_numszMonth ) >  FestivalsiFestivalIndex ][ fpMonth ] )
        
iYear++;
        
    
formatexszTodayDate charsmaxszTodayDate ) , "%s/%s/%s" szMonth szDay szYear );
    
formatexszFestivalDate charsmaxszFestivalDate ) , "%d/%d/%d" FestivalsiFestivalIndex ][ fpMonth ] , FestivalsiFestivalIndex ][ fpDay ] , iYear );
    
    
iTodayTS parse_timeszTodayDate "%m/%d/%Y" );
    
iFestivalTS parse_timeszFestivalDate "%m/%d/%Y" );
    
    
set_hudmessage255 ,255 255 0.25 0.25 0.0 1.0 );
    
show_hudmessage,  "Today is %s Year %s Month %s Day %s^n%s %s:%s^n%s is %d day%s away" szYear szMonth szDay szWeekDay TimePeriodsGetTimePeriodiHour ) ]  , szHour szMinute 
                                                    
FestivalsiFestivalIndex ][ fpFestival ] , ((iFestivalTS-iTodayTS) / DaySeconds) , ((iFestivalTS-iTodayTS) / DaySeconds) > "s" ""  );    
}

GetTimePeriodiHour )
{
    new 
iTPIndex;
    
    for ( new 
sizeofTimePeriods ) ; i++ )
    {
        if ( 
TimePeriods][ tpStart ] <= iHour <= TimePeriods][ tpEnd ] )
        {
            
iTPIndex i;
            break;
        }
    }
    
    return 
iTPIndex;
}

LoadFestivals()
{
    new 
szFile64 ] , iFile szLine41 ] , iDirLen iFestivalIndex;
    new 
szMonth] , szDay] , szFestivalsizeofFestivals[][ fpFestival ] ) ];
    
    
copyszFile[ ( iDirLen get_configsdirszFile charsmaxszFile ) ) ) ] , charsmaxszFile ) - iDirLen "/Festivals.ini" ); 
    
    
iFile fopenszFile "r" );
    
    while ( !
feofiFile ) && ( iFestivalIndex sizeofFestivals ) ) )
    {
        if ( 
fgetsiFile szLine charsmaxszLine ) ) && ( szLine] != ';') )
        {
            
parseszLine szMonth charsmaxszMonth ) , szDay charsmaxszDay ) , szFestival charsmaxszFestival ) );
            
            
FestivalsiFestivalIndex ][ fpMonth ] = str_to_numszMonth );
            
FestivalsiFestivalIndex ][ fpDay ] = str_to_numszDay );
            
copy(  FestivalsiFestivalIndex ][ fpFestival ] , charsmaxFestivals[][ fpFestival ] ) , szFestival );
            
            
iFestivalIndex++;
        }
    }
    
    return 
iFestivalIndex;

After multiple tests, no other issues have been found temporarily. Thank you very much for fixing the code. Thank you
__________________
sb123 is offline
Send a message via ICQ to sb123 Send a message via MSN to sb123 Send a message via Yahoo to sb123
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 03:23.


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