Jump to content

Cum verific ce zi din saptamana este ?


Danielowski

Recommended Posts

Salut. Vin cu o noua problema. Cum verific daca este luni / marti / miercuri etc...

 

Am gasit ceva care, din cate am inteles, a dat roade pentru persoana respectiva, insa eu nu stiu cum sa ma folosesc de acest script.

 

Code:
GetWeekDay(day=0, month=0, year=0)
{
  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;
}


Usage

Code:
GetWeekDay(); //should return the weekday of today
GetWeekDay(13, 3, 2009); //should return "Friday"
Link to comment
Share on other sites

6 hours ago, Danielowski said:

Nu stiu unde in gamemode trebuie implementat si cum fac o comanda pe baza acestuia, gen /date si sa apara "Ziua: X"

Btw, eu doresc sa aflu aceasta chestie fiindca vreau sa fac un event automatizat ca in fiecare zi de vineri la ora X sa inceapa un anumit event.

Acest stock îl pui la sfârșitul gm.ului sau depi de cum ai tu aranjamentul, iar apoi la comanda /date, te folosești de getdate

New zi, lună, an;

Getdate(zi,luna,an);

Si apoi GetWeekDay(zi,luna,an);

Spor.

**********************************

Servicii Scripting de calitate:

*********************************

Future Project: ExpertGame

*********************************

Link to comment
Share on other sites

Just now, Danielowski said:

Incerc si revin cu un edit.

A functionat perfect. Multumesc frumos.

Daca vreau sa verific daca este duminica, trebuie sa folosesc strcmp, corect ?

da

 

Rezolvat, T/C

**********************************

Servicii Scripting de calitate:

*********************************

Future Project: ExpertGame

*********************************

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.