Strange for cikle - 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: Strange for cikle (
/showthread.php?tid=624356)
Strange for cikle -
MerryDeer - 15.12.2016
Hi,
Код:
stock TimestampToDate(Timestamp, &year, &month, &day, &hour, &minute, &second, HourGMT, MinuteGMT = 0)
{
new tmp = 2;
year = 1970;
month = 1;
Timestamp -= 172800; // Delete two days from the current timestamp. This is necessary, because the timestamp retrieved using gettime() includes two too many days.
for(;;)
{
if(Timestamp >= 31536000)
{
year ++;
Timestamp -= 31536000;
tmp ++;
if(tmp == 4)
{
if(Timestamp >= 31622400)
{
tmp = 0;
year ++;
Timestamp -= 31622400;
}
else break;
}
}
else break;
}
for(new i = 0; i < 12; i ++)
{
if(Timestamp >= MonthTimes[i][2 + IsLeapYear(year)])
{
month ++;
Timestamp -= MonthTimes[i][2 + IsLeapYear(year)];
}
else break;
}
day = 1 + (Timestamp / 86400);
Timestamp %= 86400;
hour = HourGMT + (Timestamp / 3600);
Timestamp %= 3600;
minute = MinuteGMT + (Timestamp / 60);
second = (Timestamp % 60);
if(minute > 59)
{
minute = 0;
hour ++;
}
if(hour > 23)
{
hour -= 24;
day ++;
}
if(day > MonthTimes[month][IsLeapYear(year)])
{
day = 1;
month ++;
}
if(month > 12)
{
month = 1;
year ++;
}
return 1;
}
for(;

what does it mean?
Re: Strange for cikle -
AroseKhanNiazi - 15.12.2016
This converts a timestamp to date
Re: Strange for cikle -
Vince - 15.12.2016
It's called a
loop in English. I think I've told you that before. A for-
loop with no initializers, no condition and no increment runs forever. It's equivalent to while(true). Although Pawn does not support that one.
Re: Strange for cikle -
MerryDeer - 15.12.2016
if(day > MonthTimes[month][IsLeapYear(year)])
{
day = 1;
month ++;
}
Crash detect warning me array error where is month, because now is 12 month, and array MonthTimes contains MonthTimes[ 12 ], so i need to month-1 ?
Re: Strange for cikle -
OneDay - 15.12.2016
No if January is 0 now is 11.
Re: Strange for cikle -
MerryDeer - 15.12.2016
So why crash detect print my error?