Auto login
#1

Hey guys i started my new mysql admin system from MySQL 3-9 by Jeason and i have a problem that auto login is not working

PHP код:
public OnAccountCheck(playerid)
{
    new 
rowsfields//a variable that will be used to retrieve rows and fields in the database.
    
cache_get_data(rowsfieldsmysql);//let's get the rows and fields from the database.
    
if(rows//if there is row
    
{
        
cache_get_field_content(0"IP"IP[playerid], mysql16);
        new 
newIP[16];
        
GetPlayerIp(playeridnewIP16);
        
IsPlayerRegisterd[playerid] = 1;
        if(
strlen(IP[playerid]) != && !strcmp(IP[playerid], newIPtrue)) //Checks that the MySQL IP has a value and that they are the same.
        
{
            
GameTextForPlayer(playerid"Loading Account"30003);
            new 
query[100];
            
mysql_tquery(mysqlquery"OnAccountLoad""i"playerid);
        }
        else
        {
            (!
strlen(IP[playerid]) || strcmp(IP[playerid], newIPtrue));
            
//then
            
cache_get_field_content(0"Password"pData[playerid][Password], mysql129);
            
//we will load player's password into pData[playerid][Password] to be used in logging in
            
pData[playerid][ID] = cache_get_field_content_int(0"ID"); //now let's load player's ID into pData[playerid][ID] so we can use it later
            
printf("%s"pData[playerid][Password]); //OPTIONAL: Just for debugging. If it didn't show your password, then there must be something wrong while getting player's password
            
new st4[2016+1000];
            
ShowPlayerDialog(playeriddLOGINDIALOG_STYLE_INPUT"Login""In order to play, you need to login""Login""Quit"); //And since we found a result from the database, which means, there is an account; we will show a login dialog
        
}
    }
    else 
//if we didn't find any rows from the database, that means, no accounts were found
    
{
        
ShowPlayerDialog(playeriddREGISTERDIALOG_STYLE_INPUT"Register""In order to play, you need to register.""Register""Quit");
        
//So we show them a dialog register
    
}
    return 
1;

On account load

PHP код:
public OnAccountLoad(playerid)
{
    new 
score;
     
pData[playerid][Admin] = cache_get_field_content_int(0"Admin"); //we're getting a field 4 from row 0. And since it's an integer, we use cache_get_row_int
     
pData[playerid][VIP] = cache_get_field_content_int(0"VIP"); //Above
     
pData[playerid][Money] = cache_get_field_content_int(0"Money");//Above
     
pData[playerid][Kills] = cache_get_field_content_int(0,"Kills");
     
pData[playerid][Deaths] = cache_get_field_content_int(0"Deaths");
     
score cache_get_field_content_int(0"Score");
     
SetPlayerScore(playeridscore);
     
GivePlayerMoney(playeridpData[playerid][Money]);//Let's set their money
     //For player's position, set it once they spawn(OnPlayerSpawn)
    
SendClientMessage(playerid0xFF0000F"Successfully logged in"); //tell them that they have successfully logged in
    
return 1;

Reply
#2

Whats the problem?Do you want us to guess or?
Reply
#3

i said "i have a problem that auto login is not working"

it doesn't load the player data
Reply
#4

Код:
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,MAX_PLAYER_NAME):
new query[100];
format(query,sizeof(query),"SELECT * FROM `accounts` WHERE Name = '%s'",name);
mysql_tquery(mysql, query, "OnAccountLoad", "i", playerid);
Reply
#5

Where
Reply
#6

Do you see "GameTextForPlayer(playerid, "Loading Account", 3000, 3); " in game? Or it doesn't show?
Reply
#7

I dont
Reply
#8

Quote:
Originally Posted by Loinal
Посмотреть сообщение
I dont
So the problem it's before.

Try to add this printf before the strcmp check:

PHP код:
printf("IP: %s, %s"newIPIP[playerid]); 
So when you'll execute the function you'll know exactly where is the problem
Reply
#9

Not working
Reply
#10

Quote:
Originally Posted by Loinal
Посмотреть сообщение
Not working
What do you mean with not working? Did you understand my message and what is the aim of that?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)