SA-MP Forums Archive
saving register date - 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: saving register date (/showthread.php?tid=540104)



saving register date - Ghazal - 02.10.2014

Hi,

I'd like to know how can I save the date when the player registered so I can show it in /stats for example:

Registered Date: dd/mm/yyyy (2/10/2014)

Note: I'm using MySQL

Thanks!


Re: saving register date - Pottus - 02.10.2014

Use gettime() and save that value then format later.


Re: saving register date - mant - 02.10.2014

Eh ya Maro 3aml eh
Kol Sana We Anta Tayeb


Re: saving register date - Ghazal - 02.10.2014

Quote:
Originally Posted by Pottus
Посмотреть сообщение
Use gettime() and save that value then format later.
Thanks,

I used getdate instead and it worked like a charm!


Re: saving register date - Ghazal - 02.10.2014

Oh, It is not working, sorry.

It is showing

What I did:

I added RegDate[16] in the enum of Player data, And in registering I added:
pawn Код:
new Date[16], year, month, day;
            getdate(year, month, day);
            format(Date, sizeof(Date), "%d/%d/%d", day, month, year);
And, I Inserted it when registering with the '%s' and at the end of the format, I wrote pInfo[playerid][RegDate] And after inserting I added
pawn Код:
pInfo[playerid][RegDate] = Date;
I did the same in loading the accounts ..

I thought it is working since I added a testing command
pawn Код:
CMD:regdate( playerid, params [] )
{
    format(mstring, sizeof(mstring), "Register date: %s", pInfo[playerid][RegDate] );
    SendClientMessage( playerid, -1, mstring);
    return 1;
}
And, It was sending me a message:
Register date: 02/10/2014


Re: saving register date - Pottus - 02.10.2014

Use getttime() it will return a unix timestamp which is easy to work with in any way you could possibly use it!


Re: saving register date - Ghazal - 02.10.2014

Quote:
Originally Posted by Pottus
Посмотреть сообщение
Use gettime() and save that value then format later.
Quote:
Originally Posted by Pottus
Посмотреть сообщение
Use getttime() it will return a unix timestamp which is easy to work with in any way you could possibly use it!
What I understood from the wiki of gettime that its used in hours, minutes, seconds, I need to use it in date, thats why I used getdate


Re: saving register date - Shady - 02.10.2014

Well

I'm not good with MySQL but open the table and make the type (Date, Datetime or Timestamp)

P.s: Pm me


Re: saving register date - Ghazal - 02.10.2014

Quote:
Originally Posted by ShadyX
Посмотреть сообщение
Well

I'm not good with MySQL but open the table and make the type (Date, Datetime or Timestamp)

P.s: Pm me
Lol, The screenshoot already shows that I setted the type to "date"

I am not PMing you, If you would like to help, help here so all of the members know how.


Re: saving register date - Vince - 02.10.2014

No, it should be an integer if using Unix timestamps. A timestamp saves the number of seconds passed since 1/1/1970. Something like 1.4 billion currently. That value can be converted back into a date and time. Most easily done with the FROM_UNIXTIME MySQL function, but there are Pawn implementations as well (although slower).

PHP код:
SELECT FROM_UNIXTIME(1412285145'%M %D %Y, at %H:%i'
Код:
October 2nd 2014, at 23:25