MySQL - Floats + AccountID
#8

Quote:
Originally Posted by Ironboy
Посмотреть сообщение
The above code doesn't have any problems, show your register dialog.
Here we go

PHP код:
public OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    switch(
dialogid)
    {
        case 
DIALOG_LOGIN//login dialog
        
{
            if(!
responseKick(playerid); //if they clicked Quit, we will kick them
            
new hpass[129]; //for password hashing
              
new query[1024]; // for formatting our query.
            
WP_Hash(hpass129inputtext); //hashing inputtext
            
if(!strcmp(hpasspInfo[playerid][Password])) //remember we have loaded player's password into this variable, pInfo[playerid][Password] earlier. Now let's use it to compare the hashed password with password that we load
            
//if the hashed password matches with the loaded password from database
                
mysql_format(mysqlquerysizeof(query), "SELECT * FROM `accounts` WHERE `Name` = '%e' LIMIT 1"Name[playerid]);
                
//let's format our query
                //We select all rows in the table that has your name and limit the result to 1
                
mysql_tquery(mysqlquery"OnAccountLoad""i"playerid);
                
//lets execute the formatted query and when the execution is done, a callback OnAccountLoad will be called
                //You can name the callback however you like
            
}
            else 
//if the hashed password didn't match with the loaded password(pInfo[playerid][Password])
            
{
                
//we tell them that they have inserted a wrong password
                
ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_STYLE_PASSWORD"Login""In order to play, you need to login\nWrong password!""Login""Quit");
            }
        }
        case 
DIALOG_REGISTER//register dialog
        
{
            if(!
response) return Kick(playerid); //if they clicked Quit, we will kick them
            
if(strlen(inputtext) < 6) return ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_STYLE_PASSWORD"Register""In order to play, you need to register.\nYour password must be at least 6 characters long!""Register""Quit");
            
//strlen checks a lenght of a string. so if player types their password that is lower than 6, we tell them; Your password must be at least 6 characters long!
            
new query[1024];
            
WP_Hash(pInfo[playerid][Password], 129inputtext); //hashing inputtext
            
mysql_format(mysqlquerysizeof(query), "INSERT INTO `accounts` (`Name`, `Password`, `PosX`, `PosY`, `PosZ`, `FacingAngel`) VALUES ('%e', '%s', 701.8041,-519.4351,16.3318,261.1537)"Name[playerid], pInfo[playerid][Password]);
            
//Now let's create a new row and insert player's information in it
            
mysql_tquery(mysqlquery"OnAccountRegister""i"playerid);
            
//let's execute the query
        
}
    }
    return 
1;

Reply


Messages In This Thread
MySQL - Floats + AccountID - by Saize - 25.01.2015, 08:12
Re: MySQL - Floats + AccountID - by Ironboy - 25.01.2015, 09:35
AW: Re: MySQL - Floats + AccountID - by Saize - 25.01.2015, 09:53
Re: MySQL - Floats + AccountID - by Vince - 25.01.2015, 11:50
AW: Re: MySQL - Floats + AccountID - by Saize - 25.01.2015, 12:00
AW: Re: MySQL - Floats + AccountID - by Saize - 25.01.2015, 16:26
Re: MySQL - Floats + AccountID - by Ironboy - 25.01.2015, 16:30
AW: Re: MySQL - Floats + AccountID - by Saize - 26.01.2015, 18:55
AW: MySQL - Floats + AccountID - by Saize - 26.01.2015, 21:48
AW: Re: MySQL - Floats + AccountID - by Saize - 31.01.2015, 00:15

Forum Jump:


Users browsing this thread: 1 Guest(s)