Help with account saving
#1

Can anybody help me...
My problem is that i am using gamemode which saves user data into user.db file.
I checked the .db file with DB Browser and everything is there(The users,bans and everything),but when user relogs,he needs to register again,and he does not have vip/admin/premium.
Reply
#2

First you must check from the database if the player is registered or not.

PHP код:
new DBResult:ResultQuery[1200];
format(Querysizeof(Query),"SELECT PASS FROM USERS WHERE NAME = '%s'"Player[playerid][Name]); //Change by the variables of your database and game mode.
Result db_query(databaseQuery);
if(
db_num_rows(Result))
{
    
Player[playerid][Pass] = db_get_field_int(Result0);
    
Player[playerid][Registered] = true;
    
//show dialog to login
}    
else 
//If the player is not registered.
{
}
db_free_result(Result); 
It's just an example for you to understand better. You must change everything for your variables.
Reply
#3

Quote:
Originally Posted by Undef1ned
Посмотреть сообщение
First you must check from the database if the player is registered or not.

PHP код:
new DBResult:ResultQuery[1200];
format(Querysizeof(Query),"SELECT PASS FROM USERS WHERE NAME = '%s'"Player[playerid][Name]); //Change by the variables of your database and game mode.
Result db_query(databaseQuery);
if((
Result))
{
    
Player[playerid][Pass] = db_get_field_int(Result0);
    
Player[playerid][Registered] = true;
    
//show dialog to login
}    
else 
//If the player is not registered.
{
}
db_free_result(Result); 
It's just an example for you to understand better. You must change everything for your variables.
Helpp .. I don't know what to do... I've never used db saving in my whole scripting life
Here's mine code
PHP код:
    new
        
Query[600],
        
DBResultResult,
        
storedip[71],
        
ip[20]
    ;
    
GetPlayerIp(playeridip20);
    
format(Querysizeof(Query), "Choose `password`, `IP` from `users` where `username` = '%s'"DB_Escape(User[playerid][accountName]));
    
Result db_query(DatabaseQuery);
    if(
db_num_rows(Result))
    {
        
db_get_field_assoc(Result"IP"storedip20);
        
db_get_field_assoc(Result"password"User[playerid][accountPassword], 129);
        if((!
strcmp(ipstorediptrue)))
        {
            
LoginPlayer(playerid);
            
LoginPremium(playerid);
        }
        else
        {
            
ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_STYLE_PASSWORD"Login"""grey"Welcome to Express FreeRoam 2.1.\nYour account is registered in our database, Type your password below to log in.\n\nTIP: IF you are not the owner of this account,please type /q and choose another nickname.""Login""Cancel");
        }
    }
    else
    {
        
ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_STYLE_PASSWORD"Register"""grey"Welcome to our updated Express FreeRoam 2.1.\nThis account is not registered in our database,please enter a password to continue.\n\nСЪВЕТ: Make a strong password,so your account will be more secured.""Register""Quit");
    }
    
db_free_result(Result);
    return 
1;

Reply
#4

PHP код:
 new 
        
Query[600], 
        
DBResult:Result
        
storedip[16], 
        
ip[16
    ;
    
GetPlayerIp(playeridip16); 
    
format(Querysizeof(Query), "SELECT `password`, `IP` FROM `users` WHERE `username` = '%q'"User[playerid][accountName]); 
    
Result db_query(DatabaseQuery); 
    if(
db_num_rows(Result)) 
    { 
        
db_get_field_assoc(Result"IP"storedip16);
        
db_get_field_assoc(Result"password"User[playerid][accountPassword], 129); 
       
        if(
strcmp(ipstoredipfalse))
        {
            
LoginPlayer(playerid); 
            
LoginPremium(playerid);
            return 
1;
        }
       
        
ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_STYLE_PASSWORD"Login"""grey"Welcome to Express FreeRoam 2.1.\nYour account is registered in our database, Type your password below to log in.\n\nTIP: IF you are not the owner of this account,please type /q and choose another nickname.""Login""Cancel"); 
    } 
    else 
    { 
        
ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_STYLE_PASSWORD"Register"""grey"Welcome to our updated Express FreeRoam 2.1.\nThis account is not registered in our database,please enter a password to continue.\n\nСЪВЕТ: Make a strong password,so your account will be more secured.""Register""Quit"); 
    } 
    
db_free_result(Result); 
Reply
#5

Quote:
Originally Posted by Undef1ned
Посмотреть сообщение
PHP код:
 new 
        
Query[600], 
        
DBResult:Result
        
storedip[16], 
        
ip[16
    ;
    
GetPlayerIp(playeridip16); 
    
format(Querysizeof(Query), "SELECT `password`, `IP` FROM `users` WHERE `username` = '%q'"User[playerid][accountName]); 
    
Result db_query(DatabaseQuery); 
    if(
db_num_rows(Result)) 
    { 
        
db_get_field_assoc(Result"IP"storedip16);
        
db_get_field_assoc(Result"password"User[playerid][accountPassword], 129); 
       
        if(
strcmp(ipstoredipfalse))
        {
            
LoginPlayer(playerid); 
            
LoginPremium(playerid);
            return 
1;
        }
       
        
ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_STYLE_PASSWORD"Login"""grey"Welcome to Express FreeRoam 2.1.\nYour account is registered in our database, Type your password below to log in.\n\nTIP: IF you are not the owner of this account,please type /q and choose another nickname.""Login""Cancel"); 
    } 
    else 
    { 
        
ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_STYLE_PASSWORD"Register"""grey"Welcome to our updated Express FreeRoam 2.1.\nThis account is not registered in our database,please enter a password to continue.\n\nСЪВЕТ: Make a strong password,so your account will be more secured.""Register""Quit"); 
    } 
    
db_free_result(Result); 
THANK YOU MAN!!!!
THANKSSSS!!!!!
P.S ACCEPT MY FRIEND REQUEST!!!! :*
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)