Need Function | Day - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Need Function | Day (
/showthread.php?tid=395883)
Need Function | Day -
dr.lozer - 28.11.2012
i need a function that returns the name of day.. like Monday or sunday etc
Please I need it for my server :P
Re: Need Function | Day -
dino_d_carter - 28.11.2012
Well here is a good answer to you.
Click Here.
It's day/time "system"
Re: Need Function | Day -
Konstantinos - 28.11.2012
Or you can use a custom function, although I am not sure if it still works.
pawn Код:
GetWeekDay(day=0, month=0, year=0) // By Weirdosport (I think)
{
if (!day) getdate(year, month, day);
new weekday_str[10], j, e;
if (month <= 2)
{
month += 12;
--year;
}
j = year % 100;
e = year / 100;
switch ((day + (month+1)*26/10 + j + j/4 + e/4 - 2*e) % 7)
{
case 0: weekday_str = "Saturday";
case 1: weekday_str = "Sunday";
case 2: weekday_str = "Monday";
case 3: weekday_str = "Tuesday";
case 4: weekday_str = "Wednesday";
case 5: weekday_str = "Thursday";
case 6: weekday_str = "Friday";
}
return weekday_str;
}
Re: Need Function | Day -
dr.lozer - 28.11.2012
Quote:
Originally Posted by Dwane
Or you can use a custom function, although I am not sure if it still works.
pawn Код:
GetWeekDay(day=0, month=0, year=0);
|
Thank you !!!!!
Re: Need Function | Day -
Konstantinos - 29.11.2012
Quote:
Originally Posted by dr.lozer
Thank you !!!!!
|
You're welcome. Although, I have tested and it gets the name of the day, but +2.
You need to change the switch with the following one;
pawn Код:
// --
switch( ( day + ( month + 1 ) * 26 / 10 + j + j / 4 + e / 4 - 2 * e ) % 7 )
{
case 0: weekday_str = "Thursday";
case 1: weekday_str = "Friday";
case 2: weekday_str = "Saturday";
case 3: weekday_str = "Sunday";
case 4: weekday_str = "Monday";
case 5: weekday_str = "Tuesday";
case 6: weekday_str = "Wednesday";
}