SA-MP Forums Archive
Help with account saving - 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: Help with account saving (/showthread.php?tid=658673)



Help with account saving - TaligaroW - 09.09.2018

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.


Re: Help with account saving - Undef1ned - 09.09.2018

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.


Re: Help with account saving - TaligaroW - 09.09.2018

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;




Re: Help with account saving - Undef1ned - 09.09.2018

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); 



Re: Help with account saving - TaligaroW - 09.09.2018

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!!!! :*