Login Help
#1

Hello!

I have a problem with my server's accounts.

Whenever a player connects to the server, even if his account is already registered, he gets the registration dialog.

If he attempts to use the registration dialog, the login dialog appears (after I edited it) as it sends him the message that the account is already registered.

I want to get rid of the registering dialog when you are already registered.

Here are the codes:

OnPlayerConnect:

PHP код:
    new pname[MAX_PLAYER_NAME], path[200];
    
GetPlayerName(playeridpnamesizeof(pname));
    
format(pathsizeof(path), "Users/%s.ini"pname);
    if(!
dini_Exists(path))
    {
        
gPlayerAccount[playerid] = 1;
        
DisplayDialogForPlayer(playerid1);
        
SendClientMessage(playerid, -1"This server may use explicit content. By playing here you agree with our COPPA Compliance.");
        return 
1;
    }
    else
    {
        
gPlayerAccount[playerid] = 0;
        
DisplayDialogForPlayer(playerid2);
        
SendClientMessage(playerid, -1"This server may use explicit content. By playing here you agree with our COPPA Compliance.");
        return 
1;
    } 
OnDialogResponse:

Logging in:

PHP код:
    if(dialogid == 1//LOGIN
    
{
        if(
gPlayerLogged[playerid] == 1)
        {
            
SendClientMessage(playeridCOLOR_WHITE"Error: You are already logged in.");
            return 
1;
        }
        if(
response)
        {
            if(!
strlen(inputtext))
            {
                
ClearChatbox(playerid100);
                
DisplayDialogForPlayer(playerid1); //login
                
SendClientMessage(playeridCOLOR_WHITE"Error: You must enter a password.");
                return 
1;
            }
            if(
strlen(inputtext) >= 50)
            {
                
ClearChatbox(playerid100);
                
DisplayDialogForPlayer(playerid1); //login
                
SendClientMessage(playeridCOLOR_WHITE"Error: Password is too long.");
                return 
0;
            }
            new 
tmppass[64];
            
//Store Player ID & TMP pass in echo to find string used to crash server
            
new playername[MAX_PLAYER_NAME];
            
strmid(tmppassinputtext0strlen(inputtext), 255);
            
GetPlayerName(playeridplayernamesizeof(playername));
            
//FadeColorForPlayer(playerid,0,0,0,0,0,0,0,255,15,0);
            
if(strlen(playername) == 3)
            {
                    
SendClientMessage(playeridCOLOR_LIGHTRED"Sorry, that name is too short, please change it.");
                    
SetTimerEx("GettingKicked"2000false"i"playerid);
                    return 
1;
            }
            
Encrypt(tmppass);
            
OnPlayerLogin(playerid,tmppass);
        }
        else
        {
            
DisplayDialogForPlayer(playerid1); //login
        
}
    } 
Registration:

PHP код:
    if(dialogid == 2//REGISTER
    
{
        if(
gPlayerLogged[playerid] == 1)
        {
            
ClearChatbox(playerid100);
            
SendClientMessage(playeridCOLOR_WHITE"SERVER: You are already logged in.");
            return 
1;
        }
        if(
response)
        {
            if(
strlen(inputtext) >= 50)
            {
                
DisplayDialogForPlayer(playerid2); //register
                
ClearChatbox(playerid100);
                
SendClientMessage(playeridCOLOR_WHITE"SERVER: Password is too long.");
                return 
0;
            }
            new 
sendername[MAX_PLAYER_NAME];
            
GetPlayerName(playeridsendernamesizeof(sendername));
            new 
namestring strfind(sendername"_"true);
            if(
namestring == -1)
            {
                
SendClientMessage(playeridCOLOR_YELLOW"Your name must be in the Firstname_Lastname format. Please relog with a name such as John_Doe.");
                
SetTimerEx("GettingKicked"2000false"i"playerid);
                return 
1;
            }
            if(
strlen(sendername) == 6)
            {
                    
SendClientMessage(playeridCOLOR_LIGHTRED"Sorry, that name is too short, please change it.");
                    
SetTimerEx("GettingKicked"2000false"i"playerid);
                    return 
1;
            }
            else
            {
                if(!
strlen(inputtext))
                {
                    
DisplayDialogForPlayer(playerid2); //register
                    
SendClientMessage(playeridCOLOR_WHITE"SERVER: You must enter a password.");
                    return 
1;
                }
                
format(stringsizeof(string), "Users/%s.ini"sendername);
                if(
dini_Exists(string))
                   
//if(fexist(string))
                
{
                    
DisplayDialogForPlayer(playerid1); //login
                       
SendClientMessage(playeridCOLOR_LIGHTRED"This name is already taken. Please proceed to login.");
                    return 
0;
                }
                new 
tmppass[64];
                
strmid(tmppassinputtext0strlen(inputtext), 255);
                
Encrypt(tmppass);
                
PlayAudioStreamForPlayer(playerid,"hidden");
                
ClearChatbox(playerid100);
                
//FadeColorForPlayer(playerid,0,0,0,255,0,0,0,0,15,0);
                
OnPlayerRegister(playerid,tmppass);
                
OnPlayerLogin(playerid,tmppass);
                
//SendClientMessage(playerid, COLOR_YELLOW, "Account registered, you have been logged in automatically.");
            
}
        }
        else
        {
            
DisplayDialogForPlayer(playerid2); //register
        
}
    } 
After reviewing the codes, I couldn't fix the problem. The registering dialog still appears before the login dialog.
Reply
#2

pawn Код:
OnPlayerRegister(playerid,tmppass);
                OnPlayerLogin(playerid,tmppass);
show us these 2 functions please.
Reply
#3

They were posted in the codes I provided.

Logging:
PHP код:
            new tmppass[64]; 
            
//Store Player ID & TMP pass in echo to find string used to crash server 
            
new playername[MAX_PLAYER_NAME]; 
            
strmid(tmppassinputtext0strlen(inputtext), 255); 
            
GetPlayerName(playeridplayernamesizeof(playername)); 
            
//FadeColorForPlayer(playerid,0,0,0,0,0,0,0,255,15,0); 
            
if(strlen(playername) == 3
            { 
                    
SendClientMessage(playeridCOLOR_LIGHTRED"Sorry, that name is too short, please change it."); 
                    
SetTimerEx("GettingKicked"2000false"i"playerid); 
                    return 
1
            } 
            
Encrypt(tmppass); 
            
OnPlayerLogin(playerid,tmppass); 
        } 
Registration:
PHP код:
                new tmppass[64]; 
                
strmid(tmppassinputtext0strlen(inputtext), 255); 
                
Encrypt(tmppass); 
                
PlayAudioStreamForPlayer(playerid,"hidden"); 
                
ClearChatbox(playerid100); 
                
//FadeColorForPlayer(playerid,0,0,0,255,0,0,0,0,15,0); 
                
OnPlayerRegister(playerid,tmppass); 
                
OnPlayerLogin(playerid,tmppass); 
                
//SendClientMessage(playerid, COLOR_YELLOW, "Account registered, you have been logged in automatically."); 
            

Reply
#4

Quote:
Originally Posted by Michael B
Посмотреть сообщение
They were posted in the codes I provided.

Logging:
PHP код:
            new tmppass[64]; 
            
//Store Player ID & TMP pass in echo to find string used to crash server 
            
new playername[MAX_PLAYER_NAME]; 
            
strmid(tmppassinputtext0strlen(inputtext), 255); 
            
GetPlayerName(playeridplayernamesizeof(playername)); 
            
//FadeColorForPlayer(playerid,0,0,0,0,0,0,0,255,15,0); 
            
if(strlen(playername) == 3
            { 
                    
SendClientMessage(playeridCOLOR_LIGHTRED"Sorry, that name is too short, please change it."); 
                    
SetTimerEx("GettingKicked"2000false"i"playerid); 
                    return 
1
            } 
            
Encrypt(tmppass); 
            
OnPlayerLogin(playerid,tmppass); 
        } 
Registration:
PHP код:
                new tmppass[64]; 
                
strmid(tmppassinputtext0strlen(inputtext), 255); 
                
Encrypt(tmppass); 
                
PlayAudioStreamForPlayer(playerid,"hidden"); 
                
ClearChatbox(playerid100); 
                
//FadeColorForPlayer(playerid,0,0,0,255,0,0,0,0,15,0); 
                
OnPlayerRegister(playerid,tmppass); 
                
OnPlayerLogin(playerid,tmppass); 
                
//SendClientMessage(playerid, COLOR_YELLOW, "Account registered, you have been logged in automatically."); 
            

Those are the dialogs, inside your OnDialogResponse I see this callback
PHP код:
OnPlayerLogin(playerid,tmppass); 
I can't find that function anywhere in the code you've provided.
Reply
#5

pawn Код:
if(!dini_Exists(path)) // if account doesn't exist
    {
        gPlayerAccount[playerid] = 1;
        DisplayDialogForPlayer(playerid, 1); // you show login dialog ? wth
        SendClientMessage(playerid, -1, "This server may use explicit content. By playing here you agree with our COPPA Compliance.");
        return 1;
    }
    else // account exists
    {
        gPlayerAccount[playerid] = 0;
        DisplayDialogForPlayer(playerid, 2); // you show register dialog ? wth
        SendClientMessage(playerid, -1, "This server may use explicit content. By playing here you agree with our COPPA Compliance.");
        return 1;
    }
Reply
#6

Quote:
Originally Posted by Jefff
Посмотреть сообщение
pawn Код:
if(!dini_Exists(path)) // if account doesn't exist
    {
        gPlayerAccount[playerid] = 1;
        DisplayDialogForPlayer(playerid, 1); // you show login dialog ? wth
        SendClientMessage(playerid, -1, "This server may use explicit content. By playing here you agree with our COPPA Compliance.");
        return 1;
    }
    else // account exists
    {
        gPlayerAccount[playerid] = 0;
        DisplayDialogForPlayer(playerid, 2); // you show register dialog ? wth
        SendClientMessage(playerid, -1, "This server may use explicit content. By playing here you agree with our COPPA Compliance.");
        return 1;
    }
@Jeff: "gPlayerAccount[playerid] = 0;" is the case for the players who do not have an account.

@Smileys: The "tmppass" is defined above.
Reply
#7

Jefff pointed out the mistake but you didn't understand him.

If the file doesn't exist (player is not registered), you set that the player has an account and you show them the dialog with ID 1 which is the login one. Those HAVE to be on the login part (if the file exists).

Just swap them.
Reply
#8

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Jefff pointed out the mistake but you didn't understand him.

If the file doesn't exist (player is not registered), you set that the player has an account and you show them the dialog with ID 1 which is the login one. Those HAVE to be on the login part (if the file exists).

Just swap them.
Exactly what I wanted to say.
Reply
#9

Quote:
Originally Posted by Jefff
Посмотреть сообщение
pawn Код:
if(!dini_Exists(path)) // if account doesn't exist
    {
        gPlayerAccount[playerid] = 1;
        DisplayDialogForPlayer(playerid, 1); // you show login dialog ? wth
        SendClientMessage(playerid, -1, "This server may use explicit content. By playing here you agree with our COPPA Compliance.");
        return 1;
    }
    else // account exists
    {
        gPlayerAccount[playerid] = 0;
        DisplayDialogForPlayer(playerid, 2); // you show register dialog ? wth
        SendClientMessage(playerid, -1, "This server may use explicit content. By playing here you agree with our COPPA Compliance.");
        return 1;
    }
Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Jefff pointed out the mistake but you didn't understand him.

If the file doesn't exist (player is not registered), you set that the player has an account and you show them the dialog with ID 1 which is the login one. Those HAVE to be on the login part (if the file exists).

Just swap them.
My bad then, I'll try it out.
Edit: Applied the changes, nothing has changed. It seems the error comes from another source.
Reply
#10

Bro, the UG-RP script is full of bugs, if you start from scratch and read/fix every bug you find, like I did, you will not have anymore problems. Right now I have no problems. Try deleteing all the accounts and I don't think it'll harm you as your community is not even launched.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)