How can i adjust the hour?
#1

How can i add +5 hours on this clock?

pawn Код:
public clock(){
    SyncTime();
    new
        string[256],
        year,
        month,
        day,
        hours,
        minutes,
        seconds;
    getdate(year, month, day);gettime(hours, minutes, seconds);
    format(string, sizeof string, "~b~~h~~h~~h~%d/%s%d/2012", day, ((month < 10) ? ("0") : ("")) ,month);TextDrawSetString(clock1, string);
    format(string, sizeof string, "~b~~h~~h~~h~%s%d:%s%d:%s%d", (hours < 10) ? ("0") : (""), hours, (minutes < 10) ? ("0") : (""), minutes, (seconds < 10) ? ("0") : (""), seconds);TextDrawSetString(clock2, string);
    TextDrawShowForAll(clock1);TextDrawShowForAll(clock2);}
Reply
#2

You should check out current hour, day, month, year and increase it if necessary.
Reply
#3

Thanks for the tip when i posted i didn't found the button to insert pawn codes

The problem im facing on this is one is that if i just add += 5 to the hours, the format will be incorrect, for example
Its ok if its 17:00 and i add 5, will be 22:00
But if its 22:00 and i add 5 will be 27:00 on the clock so it will be wrong because it should turn to 3:00, but it doesn't.
I dont know how to adjust it correctly
Reply
#4

Quote:
Originally Posted by sampmann
Посмотреть сообщение
Thanks for the tip when i posted i didn't found the button to insert pawn codes
I changed my first post, look at it.
Reply
#5

Quote:
Originally Posted by sampmann
Посмотреть сообщение
Thanks for the tip when i posted i didn't found the button to insert pawn codes

The problem im facing on this is one is that if i just add += 5 to the hours, the format will be incorrect, for example
Its ok if its 17:00 and i add 5, will be 22:00
But if its 22:00 and i add 5 will be 27:00 on the clock so it will be wrong because it should turn to 3:00 but it doesn't
I dont know how to adjust it correctly
If hours above 24 you should increase current date and subtract 24 from current hours.
Reply
#6

I'm new at pawn and i dont know how to do it because i've never seen something like that
(hours < 10) ? ("0") : ("")

What do the "?" means in pawn?
Reply
#7

Quote:
Originally Posted by sampmann
Посмотреть сообщение
I'm new at pawn and i dont know how to do it because i've never seen something like that
(hours < 10) ? ("0") : ("")

What does do "?" in the middle means?
It works like a check and return.

I made it myself.
pawn Код:
public clock()
{
    SyncTime();
    new string[256], year, month, day, hours, minutes, seconds;
    getdate(year, month, day), gettime(hours, minutes, seconds);
    new lhour = 19-hour;
    if(lhour) hour += 5;
    else day++, hour -= 19;
    format(string, sizeof string, "~b~~h~~h~~h~%d/%02d/%d", day, month , year);
    TextDrawSetString(clock1, string);
    format(string, sizeof string, "~b~~h~~h~~h~%02d:%02d:%02d", hours, minutes, seconds);
    TextDrawSetString(clock2, string);
    TextDrawShowForAll(clock1);TextDrawShowForAll(clock2);
}
BUT if "day" more than 28-31(End of month), the months and years are not increase.
Reply
#8

I didn't understand what you said here "if more than 30(28/31) days, the months and years are not increase"

But thanks for you help man, i'll add to your reputation, its working correctly, the only problem is that on 00:00 is marking 24:00 but i think i can fix that.
Reply
#9

Quote:
Originally Posted by sampmann
Посмотреть сообщение
I didn't understand what you said here "if more than 30(28/31) days, the months and years are not increase"

But thanks for you help man, i'll add to your reputation, its working correctly, the only problem is that on 00:00 is marking 24:00 but i think i can fix that.
Yes, i corrected the code.
Just us shared a small language barrier.
Reply
#10

Its possible to make it show 00:00 at 24h?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)