Raised This Month: $ Target: $400
 0% 

Scripting help. How to check eg. February 14.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Evaldas.Grigas
Senior Member
Join Date: Sep 2011
Location: Lithuania
Old 11-16-2011 , 09:29   Scripting help. How to check eg. February 14.
Reply With Quote #1

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.
__________________
Please enter this website everyday: http://forums.alliedmods.net/showthread.php?t=169067
Evaldas.Grigas is offline
Send a message via Skype™ to Evaldas.Grigas
kramesa
Veteran Member
Join Date: Feb 2011
Location: Brazil
Old 11-16-2011 , 09:34   Re: Scripting help. How to check eg. February 14.
Reply With Quote #2

PHP Code:
get_time 
http://www.amxmodx.org/funcwiki.php?go=func&id=249
__________________
kramesa is offline
Old 11-16-2011, 09:36
mrhellish
This message has been deleted by mrhellish.
Evaldas.Grigas
Senior Member
Join Date: Sep 2011
Location: Lithuania
Old 11-16-2011 , 13:07   Re: Scripting help. How to check eg. February 14.
Reply With Quote #3

For example?
PHP Code:
if (get_time == December
Or how?
__________________
Please enter this website everyday: http://forums.alliedmods.net/showthread.php?t=169067
Evaldas.Grigas is offline
Send a message via Skype™ to Evaldas.Grigas
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 11-16-2011 , 13:49   Re: Scripting help. How to check eg. February 14.
Reply With Quote #4

Did you even read the link he posted ?
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
Evaldas.Grigas
Senior Member
Join Date: Sep 2011
Location: Lithuania
Old 11-16-2011 , 13:50   Re: Scripting help. How to check eg. February 14.
Reply With Quote #5

Yes, I have no idea how to make it work with "if"
__________________
Please enter this website everyday: http://forums.alliedmods.net/showthread.php?t=169067

Last edited by Evaldas.Grigas; 11-16-2011 at 13:50.
Evaldas.Grigas is offline
Send a message via Skype™ to Evaldas.Grigas
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 11-16-2011 , 13:56   Re: Scripting help. How to check eg. February 14.
Reply With Quote #6

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.
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
The Inhabitant Of Heavens
Member
Join Date: Aug 2011
Old 11-16-2011 , 13:57   Re: Scripting help. How to check eg. February 14.
Reply With Quote #7

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)));
}

Last edited by The Inhabitant Of Heavens; 11-16-2011 at 13:58.
The Inhabitant Of Heavens is offline
joshknifer
Veteran Member
Join Date: Jun 2011
Location: Denver, CO
Old 11-16-2011 , 14:08   Re: Scripting help. How to check eg. February 14.
Reply With Quote #8

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 
__________________
joshknifer is offline
Send a message via Skype™ to joshknifer
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 11-16-2011 , 14:10   Re: Scripting help. How to check eg. February 14.
Reply With Quote #9

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.
__________________
Impossible is Nothing

Last edited by Sylwester; 11-16-2011 at 14:12.
Sylwester is offline
joshknifer
Veteran Member
Join Date: Jun 2011
Location: Denver, CO
Old 11-16-2011 , 14:15   Re: Scripting help. How to check eg. February 14.
Reply With Quote #10

Quote:
Originally Posted by Sylwester View Post
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
__________________
joshknifer is offline
Send a message via Skype™ to joshknifer
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 08:24.


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