Register date
#1

So, i'm using mysql for my saving system. I save the register date of the player without problems.

I have problems showing it in /stats.

I get: "Register Date: " only.

Code from /stats:

pawn Код:
format(temp, sizeof(temp), ""WHITE"Register Date: "GREEN"%s\n\n",Player[playerid][RegisterDate]);
    strcat(info, temp);
This it how i save it (without problems, correct register date shows in mysql table):

pawn Код:
new query[128];
    format(query, sizeof(query), "UPDATE `playertable` SET `RegisterDate` = '%s' WHERE `username` = '%s'", ReturnDate(), Player[playerid][Name]);
    mysql_tquery(g_SQL, query);
Whats wrong?
Reply
#2

Chances are;
a) Your RegisterDate isn't a string variable.
b) Your register/login can't properly load RegisterDate variable.

Check if RegisterDate is indeed a string variable and if it is, the issue has to be b. If it's a, just change the size of RegisterDate variable to suit your needs and if it's b, show us your player data loading code.
Reply
#3

Why would you save the register date with an UPDATE query when INSERT query can do that for you?
Why would you save the register date as string and not as TIMESTAMP or DATETIME data type? You can then manipulate date and time data using in-built functions and also retrieve date with any format you want.

Do you load the register date and assign to Player[playerid][RegisterDate]? Otherwise it is null.
Reply
#4

Just checked now, i wasn't loading the registerdate when players loggin in..
How i can do it?

pawn Код:
cache_get_value_int(0, "RegisterDate", Player[playerid][RegisterDate]);
Doesn't work.
Reply
#5

Since you save it as string, you should use:
Код:
cache_get_value(0, "RegisterDate", Player[playerid][RegisterDate], size_of_RegisterDate);
Reply
#6

Ok thanks, about the INSERT query, currently im using this on register:

pawn Код:
new query[128];
    format(query, sizeof(query), "UPDATE `players` SET `RegisterDate` = '%s' WHERE `username` = '%s'", ReturnDate(), Player[playerid][Name]);
    mysql_tquery(g_SQL, query);
How i can edit it with INSERT instead of UPDATE?
Reply
#7

Just add the column to the list and a value for it:
pawn Код:
"INSERT INTO players (..., RegisterDate) VALUES (..., '%s')"
If you had used TIMESTAMP datatype, you could set a default value as CURRENT_TIMESTAMP and it would set the register date itself.
Reply
#8

Thank you.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)