Gettime question? - 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 question? (
/showthread.php?tid=619470)
Gettime question? -
Tass007 - 18.10.2016
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?
Re: Gettime question? -
SickAttack - 18.10.2016
From the server.
Re: Gettime question? -
Tass007 - 18.10.2016
Okay thank you.
Re: Gettime question? -
Tass007 - 18.10.2016
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], totaltime, h,s,m;
totaltime = (gettime(h,m,s) - ConnectedTime[playerid] / 60);
format(string, sizeof(string), "You have been connected for: %02d minutes", totaltime);
SendClientMessage(playerid, COLOR_YELLOW, string);
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?
Re: Gettime question? - iLearner - 18.10.2016
With totaltime you are getting gettime value which is seconds passed since 19.. , use 'm' in send client message instead of total time.
Re: Gettime question? -
Vince - 18.10.2016
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.
Re: Gettime question? -
SickAttack - 18.10.2016
Or you could use:
pawn Код:
(NetStats_GetConnectedTime(playerid) / 1000)
Re: Gettime question? -
Tass007 - 18.10.2016
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.
Re: Gettime question? -
Gotham - 18.10.2016
02d 's "0" idk "2" might be for 2 num."d" is specifier
Re: Gettime question? -
SickAttack - 18.10.2016
%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));