AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Scripting help. How to check eg. February 14. (https://forums.alliedmods.net/showthread.php?t=172150)

Evaldas.Grigas 11-16-2011 09:29

Scripting help. How to check eg. February 14.
 
How to check any date on Counter Strike? I am going to do an easy plugin in my server. It's called hollyday VIPs. Every one will have VIP status on my server.

kramesa 11-16-2011 09:34

Re: Scripting help. How to check eg. February 14.
 
PHP Code:

get_time 

http://www.amxmodx.org/funcwiki.php?go=func&id=249

Evaldas.Grigas 11-16-2011 13:07

Re: Scripting help. How to check eg. February 14.
 
For example?
PHP Code:

if (get_time == December

Or how?

drekes 11-16-2011 13:49

Re: Scripting help. How to check eg. February 14.
 
Did you even read the link he posted ?

Evaldas.Grigas 11-16-2011 13:50

Re: Scripting help. How to check eg. February 14.
 
Yes, I have no idea how to make it work with "if"

drekes 11-16-2011 13:56

Re: Scripting help. How to check eg. February 14.
 
get_time() puts the data you want in a string, so you need to str_to_num() or equal[i]() to compare the data in an if statement.

You could check the "say /thetime" function from the default amxx package.
I'm not sure which plugin has that though, you'll need to look into that yourself.

The Inhabitant Of Heavens 11-16-2011 13:57

Re: Scripting help. How to check eg. February 14.
 
Code:

#include <amxmodx>

public plugin_init()
        time()

time()
{
        new timestamp = TimeToUnix(2011, 12, 31, 11, 59, 0)
       
        if(get_systime() > timestamp)
                client_print ( 0 , print_chat, ".......")
}


stock const YearSeconds[2] =
{
        31536000,        //Normal year
        31622400        //Leap year
};

stock const MonthSeconds[12] =
{
        2678400, //January        31
        2419200, //February        28
        2678400, //March        31
        2592000, //April        30
        2678400, //May                31
        2592000, //June                30
        2678400, //July                31
        2678400, //August        31
        2592000, //September        30
        2678400, //October        31
        2592000, //November        30
        2678400  //December        31
};

stock const DaySeconds = 86400;
stock const HourSeconds = 3600;
stock const MinuteSeconds = 60;

stock UnixToTime(iTimeStamp , &iYear , &iMonth , &iDay , &iHour , &iMinute , &iSecond)
{
        new iTemp;
       
        iYear = 1970;
        iMonth = 1;
        iDay = 1;
        iHour = 0;

        while (iTimeStamp > 0)
        {
                iTemp = IsLeapYear(iYear);

                if ((iTimeStamp - YearSeconds[iTemp]) >= 0)
                {
                        iTimeStamp -= YearSeconds[iTemp];
                        iYear++;
                }
                else
                {
                        break;
                }
        }

        while (iTimeStamp > 0)
        {
                iTemp = SecondsInMonth(iYear , iMonth);

                if ((iTimeStamp - iTemp) >= 0)
                {
                        iTimeStamp -= iTemp;
                        iMonth++;
                }
                else
                {
                        break;
                }
        }

        while (iTimeStamp > 0)
        {
                if ((iTimeStamp - DaySeconds) >= 0)
                {
                        iTimeStamp -= DaySeconds;
                        iDay++;
                }
                else
                {
                        break;
                }
        }
       
        while (iTimeStamp > 0)
        {
                if ((iTimeStamp - HourSeconds) >= 0)
                {
                        iTimeStamp -= HourSeconds;
                        iHour++;
                }
                else
                {
                        break;
                }
        }
       
        iMinute = (iTimeStamp / 60);
        iSecond = (iTimeStamp % 60);
}

stock TimeToUnix(const iYear , const iMonth , const iDay , const iHour , const iMinute , const iSecond)
{
        new i;
        new iTimeStamp;

        for (i = 1970 ; i < iYear ; i++)
                iTimeStamp += YearSeconds[IsLeapYear(i)];

        for (i = 1 ; i < iMonth ; i++)
                iTimeStamp += SecondsInMonth(iYear , i);

        iTimeStamp += ((iDay - 1) * DaySeconds);
        iTimeStamp += (iHour * HourSeconds);
        iTimeStamp += (iMinute * MinuteSeconds);
        iTimeStamp += iSecond;

        return iTimeStamp;
}

stock SecondsInMonth(const iYear , const iMonth)
{
        return ((IsLeapYear(iYear) && (iMonth == 2)) ? (MonthSeconds[iMonth - 1] + DaySeconds) : MonthSeconds[iMonth - 1]);
}

stock IsLeapYear(const iYear)
{
        return (((iYear % 4) == 0) && (((iYear % 100) != 0) || ((iYear % 400) == 0)));
}


joshknifer 11-16-2011 14:08

Re: Scripting help. How to check eg. February 14.
 
Seems like this should be simpler. In looking at the example on the wiki would something like this work?
PHP Code:

new CurrentTime[9]
get_time ("%m/%d",CurrentTime,"")
    if (
CurrentTime == "2/14" // your code works 


Sylwester 11-16-2011 14:10

Re: Scripting help. How to check eg. February 14.
 
It's pointless to add so much stuff for such a simple thing.
PHP Code:

new temp[10]
get_time("%m %d"tempsizeof(temp)-1)
if(
equali(temp"02 14")){
     
//...


EDIT:
@joshknifer: Your code is wrong.

joshknifer 11-16-2011 14:15

Re: Scripting help. How to check eg. February 14.
 
Quote:

Originally Posted by Sylwester (Post 1597639)
It's pointless to add so much stuff for such a simple thing.
PHP Code:

new temp[10]
get_time("%m %d"tempsizeof(temp)-1)
if(
equali(temp"02 14")){
     
//...


EDIT:
@joshknifer: Your code is wrong.

Thanks, still learning. i appreciate the help :)


All times are GMT -4. The time now is 08:24.

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