Registration date mysql
#1

I'm trying to save registration date of the player on the registration, i made this:

Код:
            new date[3];
			getdate(date[2], date[1], date[0]);
			new month[15];
			switch (date[1])
			{
			case 1: month = "January";
			case 2: month = "Feburary";
			case 3: month = "March";
   			case 4: month = "April";
			case 5: month = "May";
			case 6: month = "June";
			case 7: month = "July";
			case 8: month = "August";
			case 9: month = "September";
			case 10: month = "October";
			case 11: month = "November";
			case 12: month = "December";
			}
			
			new register_on[25];
			format(register_on, sizeof(register_on), "%02d %s, %d", date[0], month, date[2]);
			SQL::WriteString(handle, "p_regdate", UserInfo[playerid][p_regdate], date[0], month, date[2]);
But got errors.

Also another question, do i need to save the UserInfo[playerid][p_regdate] on player disconnect and load it on login or is not necessary? Thanks.
Reply
#2

1. What errors you got?

2. No you shouldn't save it OnPlayerDisconnect, Because as you say, It's only the registration date.
Reply
#3

Quote:
Originally Posted by oMa37
Посмотреть сообщение
1. What errors you got?

2. No you shouldn't save it OnPlayerDisconnect, Because as you say, It's only the registration date.
warning 202: number of arguments does not match definition
warning 202: number of arguments does not match definition
warning 202: number of arguments does not match definition
Reply
#4

Lines? ;-;
Reply
#5

Quote:
Originally Posted by oMa37
Посмотреть сообщение
Lines? ;-;
rip
PHP код:
OnPlayerConnect(playerid)
{
/// blab blblabalbla
            
new date[3];
            
getdate(date[2], date[1], date[0]);
            new 
month[15];
            switch (
date[1])
            {
            case 
1month "January";
            case 
2month "Feburary";
            case 
3month "March";
               case 
4month "April";
            case 
5month "May";
            case 
6month "June";
            case 
7month "July";
            case 
8month "August";
            case 
9month "September";
            case 
10month "October";
            case 
11month "November";
            case 
12month "December";
            }
            
            new 
register_on[25];
            
format(register_onsizeof(register_on), "%02d %s, %d"date[0], monthdate[2]);
            
SQL::WriteString(handle"p_regdate"register_on);
    
// BLA blablalbalbal
   
return 1;

Reply
#6

Код:
            new date[3]; 
            getdate(date[2], date[1], date[0]); 
            new const months[12][20] =
            {
                   "January",
                   "Febrary",
                   "March",
                   "April",
                   "May",
                   "June",
                   "July",
                   "August",
                   "September",
                   "October",
                   "November",
                   "December"
           };

            new register_on[25]; 
            format(register_on, sizeof(register_on), "%02d %s, %d", date[0], months[date[1]-1], date[2]); 
            SQL::WriteString(handle, "p_regdate", register_on);
Reply
#7

Quote:
Originally Posted by Yaa
Посмотреть сообщение
rip
PHP код:
OnPlayerConnect(playerid)
{
/// blab blblabalbla
            
new date[3];
            
getdate(date[2], date[1], date[0]);
            new 
month[15];
            switch (
date[1])
            {
            case 
1month "January";
            case 
2month "Feburary";
            case 
3month "March";
               case 
4month "April";
            case 
5month "May";
            case 
6month "June";
            case 
7month "July";
            case 
8month "August";
            case 
9month "September";
            case 
10month "October";
            case 
11month "November";
            case 
12month "December";
            }
            
            new 
register_on[25];
            
format(register_onsizeof(register_on), "%02d %s, %d"date[0], monthdate[2]);
            
SQL::WriteString(handle"p_regdate"register_on);
    
// BLA blablalbalbal
   
return 1;

Did you even change something smartass? All what you did that you moved the code into a callback (You didn't even public it), That guy didn't say anything about where that code is.
Reply
#8

Is at the register dialog.
Reply
#9

Which lines are these errors on? These essentially mean you have too few or too many arguments. Example:

Definition: GetPlayerMoney(playerid);
Incorrect Usage: GetPlayerMoney(playerid, Money);

Here you would have 2 arguments instead of just the one. If you point out the lines I'll point out the mistakes.
Reply
#10

Don't store time or date as a formatted string in SQL. Time and date should only ever be formatted right before they're sent to an output (i.e. client message, dialog text, textdraw, ...). You want to store data in as versatile a manner as possible; that is a Unix timestamp or an ISO string (YYYY-MM-DD HH:MM:SS). I don't know if you're using SQLite or MySQL (I really dislike those "easy" SQL includes) but both have functions to convert time and date.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)