SA-MP Forums Archive
gettime function - 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: gettime function (/showthread.php?tid=535952)



gettime function - Jacapo - 06.09.2014

Hello,

I have a litte question about gettime function.

Код:
new hour, minute, second;
gettime(hour, minute, second);
if(hour >= 03)
{
//some code
}
So simply i want: hour 03 AM (morning), but in script it is wrong


Re: gettime function - Jacapo - 06.09.2014

----up


Re: gettime function - CutX - 06.09.2014

Quote:
Originally Posted by Jacapo
Посмотреть сообщение
Hello,

I have a litte question about gettime function.

Код:
new hour, minute, second;
gettime(hour, minute, second);
if(hour >= 03)
{
//some code
}
So simply i want: hour 03 AM (morning), but in script it is wrong
//EDIT:misunderstood something.

so, where's your problem?
you have what you want, if hours equals 3 (or greater than 3), it's 3am in the morning.
you can just do your stuff in that control structure.

btw. if you were to put some code generating some message like "hello! it's 3 am!"
with the current condition in that control structure, it would still say that it's3 am in the morning even if it's 9 pm :P
something like
Код:
if(hour == 3)
would be better for things like that.
ah, well, you could also do a nice switch, if you want multiple messages displaying at certain times of the day


Re: gettime function - SickAttack - 06.09.2014

Quote:
Originally Posted by Jacapo
Посмотреть сообщение
Hello,

I have a litte question about gettime function.

Код:
new hour, minute, second;
gettime(hour, minute, second);
if(hour >= 03)
{
//some code
}
So simply i want: hour 03 AM (morning), but in script it is wrong
You said that you have a question but I don't see any questions in your post..


Re: gettime function - Jacapo - 06.09.2014

thanks for your reply, but i got it working... it must be:

Код:
new hour, minute, second;
gettime(hour, minute, second);
if(hour >= 03 && hour <= 05) //This is the fix.. so its only between 3-5 AM, if it was only the 3AM it will be persist till next day 3AM
{
//some code
}



Re: gettime function - SickAttack - 06.09.2014

Quote:
Originally Posted by Jacapo
Посмотреть сообщение
thanks for your reply, but i got it working... it must be:

Код:
new hour, minute, second;
gettime(hour, minute, second);
if(hour >= 03 && hour <= 05) //This is the fix.. so its only between 3-5 AM, if it was only the 3AM it will be persist till next day 3AM
{
//some code
}
Use your head before posting next time.


Re: gettime function - Jacapo - 06.09.2014

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
Use your head before posting next time.
As you say.