Gettime question?
#1

Hey guys I've been having issues with using gettime and I'm wondering that whenever gettime is used is it getting the time from the players computer or the hosting computer?
Reply
#2

From the server.
Reply
#3

Okay thank you.
Reply
#4

Sorry for double posting but I have another question. If I'm trying to get minutes out of a command this is what I have
PHP код:
CMD:connecttime(playerid)
{
    new 
string[128], totaltimeh,s,m;
    
totaltime = (gettime(h,m,s) - ConnectedTime[playerid] / 60);
    
format(stringsizeof(string), "You have been connected for: %02d minutes"totaltime);
    
SendClientMessage(playeridCOLOR_YELLOWstring);
    return 
1;

However as soon as I connect to the server the value is 1452162698

My question is: what sort of variables or difference to I need to use in order to get minutes out of gettime?
Reply
#5

With totaltime you are getting gettime value which is seconds passed since 19.. , use 'm' in send client message instead of total time.
Reply
#6

Order of operations! Division has higher precedence than subtraction. You need to use brackets so the subtraction happens before the division. Also you don't need the h, m and s variables if you are solely looking to get the timestamp. You can use the function without parameters.
Reply
#7

Or you could use:
pawn Код:
(NetStats_GetConnectedTime(playerid) / 1000)
Reply
#8

Awesome thank you! I also have another question. When saving displaying time or dates, do I have to use %02d or can I just use %d. Also what does %02d do?

Apparently GetConnectedTime doesn't work on disconnect or timeout or something like that.
Reply
#9

02d 's "0" idk "2" might be for 2 num."d" is specifier
Reply
#10

%02d will place a 0 if the value is a single digit.

7 = 07
17 = 17

%07d:

7 = 0000007
5000 = 0005000

-----------------

I'm not sure if it works under OnPlayerDisconnect, but try by debugging:

printf("%d", (NetStats_GetConnectedTime(playerid) / 1000));
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)