24 hour time to 12 hour time?
#1

Hi all, i was jsut wonderin.. how do u convert 24 hour time to 12 hour time? THX!
Reply
#2

ingame real time, or player's time
Reply
#3

um.. idk... like.. if i have a textdraw thet says the time.
Reply
#4

But textdraw that shows the hour in real life or in San Andreas??
Reply
#5

real life.
Reply
#6

wait a sec... ok.. i got this:

pawn Код:
stock UpdateTimeForPlayer(playerid)
{
    gettime(hour, minute);
    SetWorldTime(hour);
    SetPlayerTime(playerid, hour, minute);
    format(timestr,sizeof(timestr),"%d:%d",hour,minute);
    TextDrawSetString(txtTimeDisp,timestr);
}
I thought it would b 24 hour time in game but its actually 12... hmmm... because its 1:32 now and that what the textdraw says... i thought gettime returned 24 hour time... anyone can explain this?
Reply
#7

Quote:
Originally Posted by sciman001
Посмотреть сообщение
wait a sec... ok.. i got this:

pawn Код:
stock UpdateTimeForPlayer(playerid)
{
    gettime(hour, minute);
    SetWorldTime(hour);
    SetPlayerTime(playerid, hour, minute);
    format(timestr,sizeof(timestr),"%d:%d",hour,minute);
    TextDrawSetString(txtTimeDisp,timestr);
}
I thought it would b 24 hour time in game but its actually 12... hmmm... because its 1:32 now and that what the textdraw says... i thought gettime returned 24 hour time... anyone can explain this?
pawn Код:
stock UpdateTimeForPlayer(playerid)
{
    gettime(hour, minute);
    if(hour > 12) hour = hour - 12;//added by Nexotronix lol
        SetWorldTime(hour);
    SetPlayerTime(playerid, hour, minute);
    format(timestr,sizeof(timestr),"%d:%d",hour,minute);
    TextDrawSetString(txtTimeDisp,timestr);
}

cause 24 hours it's 12+12 so if our time more then 12 o'clock we need to do this:

pawn Код:
if(hour > 12) hour = hour - 12;
i think it's helpfull
Reply
#8

but it already is 12 hour... idk y tho.. look at my updated code.. u can see it in this server if u want: 24.111.46.103:7777 i am fundude and im there rit now. But, heres the code:

pawn Код:
stock UpdateTimeForPlayer(playerid)
{
    gettime(hour, minute, second);
    SetWorldTime(hour);
    SetPlayerTime(playerid, hour, minute);
    format(timestr,sizeof(timestr),"%d:%d:%d",hour,minute, second);
    TextDrawSetString(txtTimeDisp,timestr);
}
And i got things such as 1:40:33 and stuff... and that is the time here. QUESTION: Does gettime get the time it is where i live (from my pc maybe) or does it get the time of each player playing?
Reply
#9

Quote:
Originally Posted by sciman001
Посмотреть сообщение
but it already is 12 hour... idk y tho.. look at my updated code.. u can see it in this server if u want: 24.111.46.103:7777 i am fundude and im there rit now. But, heres the code:

pawn Код:
stock UpdateTimeForPlayer(playerid)
{
    gettime(hour, minute, second);
    SetWorldTime(hour);
    SetPlayerTime(playerid, hour, minute);
    format(timestr,sizeof(timestr),"%d:%d:%d",hour,minute, second);
    TextDrawSetString(txtTimeDisp,timestr);
}
And i got things such as 1:40:33 and stuff... and that is the time here. QUESTION: Does gettime get the time it is where i live (from my pc maybe) or does it get the time of each player playing?
I was asking myself the same question
I am almost 100% sure its from your computer's GMT
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)