error 035: argument type mismatch (argument 1)
#1

EDIT: Important addition in post #3.

The error:
PHP код:
error 035argument type mismatch (argument 1
The function(emphasised error line)
PHP код:
        case 2// Login
        
{
            new 
name[MAX_PLAYER_NAME+1];
            
GetPlayerName(playeridnamesizeof(name));
            if(
CheckPassword(nameinputtext) >= 1// Error line
            
{
                
SendClientMessage(playeridCOLOR_WHITE"[SUCCESS] You have successfully logged in!");
                
GetStats(playerid);
            }
            else
            {
                
SendClientMessage(playeridCOLOR_RED"[Error] Wrong password!");
                
ShowPlayerDialog(playerid2DIALOG_STYLE_INPUT"Login""Wrong password, enter the correct one!""Submit""Cancel");
            }
        } 
CheckPassword:
PHP код:
CheckPassword(nameinputtext)
{
    new 
rowsfieldsstring[128];
    
format(stringsizeof(string), "SELECT * FROM users WHERE username = '%s' AND password = '%s'"nameinputtext);
    
mysql_function_query(dbHandlestringfalse"""""");
    
cache_get_data(rowsfieldsdbHandle);
    if(
rows >= 1) return 1;
    else return 
0;

Reply
#2

In your check password function change
pawn Код:
CheckPassword(name, inputtext)
to
pawn Код:
CheckPassword(name[], inputtext[])
Also your function will not work, because it's not how caching queries works - reread the tutorial - https://sampforum.blast.hk/showthread.php?tid=337810
Reply
#3

Alright so I managed to fix the error thanks to you.
And regardless of the error I changed the functions a little bit.
Now I don't get any errors, but I have encountered an issue in the script:

I type in the correct password, then it shows me the dialog where it says that the password I entered is incorrect, but then I can type in anything I want and it'll let me in. Of course only if I wrote the CORRECT password at first.

Example to make it easier:
Let's say that the real password is 74.
So I log in, type in "74" it says "Wrong password, please try again blah blah.." and then when I type again, I can type anything, like literally type in "wsuphomies" and it'll log me in.
The good thing is that at least, you have to type in the correct password at first, and only then you can type in whatever you want to log in.
But how can I fix it?

The current function:
PHP код:
        case 2// Login
        
{
            new 
name[MAX_PLAYER_NAME+1];
            
GetPlayerName(playeridnamesizeof(name));
            if(
CheckPassword(nameinputtext) >= 1)
            {
                
SendClientMessage(playeridCOLOR_WHITE"[SUCCESS] You have successfully logged in!");
                new 
string[128];
                
format(stringsizeof(string), "SELECT * FROM users WHERE username = '%s'"name);
                
mysql_function_query(dbHandlestringtrue"GetStats""d"playerid);
            }
            else
            {
                
SendClientMessage(playeridCOLOR_RED"[Error] Wrong password!");
                
ShowPlayerDialog(playerid2DIALOG_STYLE_INPUT"Login""Wrong password, enter the correct one!""Submit""Cancel");
            }
        } 
CheckPassword:
PHP код:
CheckPassword(name[], inputtext[])
{
    new 
rowsfieldsstring[128];
    
format(stringsizeof(string), "SELECT * FROM users WHERE username = '%s' AND password = '%s'"nameinputtext);
    
mysql_function_query(dbHandlestringtrue"""""");
    
cache_get_data(rowsfieldsdbHandle);
    if(
rows >= 1) return 1;
    else return 
0;

Reply
#4

Create a new function when checking if the account exists

Код:
CheckPassword(name[], inputtext[]) 
{ 
    new rows, fields, string[128]; 
    format(string, sizeof(string), "SELECT * FROM users WHERE username = '%s' AND password = '%s'", name, inputtext); 
    return mysql_function_query(dbHandle, string, true, "AccountCheck", "i", playerid); 
}  

forward public AccountCheck(playerid);
public AccountCheck(playerid)
{
    new rows, fields;
    cache_get_data(rows, fields, dbHandle); 
    
    if(rows)
    {
        //show login dialog
    }
    else
    {
       //show register dialog
    }
    
    return 1;
}
Reply
#5

I already have a function to check if the account exists... I call it OnPlayerConnect.
PHP код:
CheckAccountExists1(playeridaccount[])
{
    new 
string[128];
    
format(stringsizeof(string), "SELECT * FROM users WHERE username = '%s'"account);
    
mysql_function_query(dbHandlestringtrue"OnAccountCheck""d"playerid);
    
//mysql_store_result();
    //new value = mysql_num_rows();
    //mysql_free_result();
    //return value;
    
return 1;

PHP код:
forward OnAccountCheck(playerid);
public 
OnAccountCheck(playerid)
{
    new 
rowsfields;
    
cache_get_data(rowsfieldsdbHandle);
    if(
rows) {
            
ShowPlayerDialog(playerid2DIALOG_STYLE_INPUT"Login""This account is registered, please enter the password.""Submit""Cancel");
    }
    else {
            
ShowPlayerDialog(playerid1DIALOG_STYLE_INPUT"Register""Please enter the password for your new account.""Submit""Cancel");
    }
    return 
1;

Reply
#6

Well?
Reply
#7

You were given answer - create new function. You can reuse this one, like
pawn Код:
CheckPassword(name[], inputtext[])
{
    new rows, fields, string[128];
    format(string, sizeof(string), "SELECT * FROM users WHERE username = '%s' AND password = '%s'", name, inputtext);
    mysql_function_query(dbHandle, string, true, "OnAccountCheck", "i", somehowgetplayeridhere);
  return 0;
}
I'd recommend you using y_playervars (I think) - it doesn't query database on every login attempt...
Reply
#8

What about this? I tested it briefly and it seems to work pretty fine, I'd still like to hear others' opinions.
PHP код:
        case 2// Login
        
{
            new 
name[MAX_PLAYER_NAME+1], string[128];
            
GetPlayerName(playeridnamesizeof(name));
            
//if(CheckPassword(name, inputtext) >= 1)
            
format(stringsizeof(string), "SELECT * FROM users WHERE username = '%s' AND password = '%s'"nameinputtext);
            
mysql_function_query(dbHandlestringtrue"CheckPassword""is"playeridname);

PHP код:
forward CheckPassword(playeridname[]);
public 
CheckPassword(playeridname[])
{
    new 
rowsfieldsstring[128];
    
cache_get_data(rowsfieldsdbHandle);
    if(
rows >= 1)
    {
        
SendClientMessage(playeridCOLOR_WHITE"[SUCCESS] You have successfully logged in!");
        
format(stringsizeof(string), "SELECT * FROM users WHERE username = '%s'"name);
        
mysql_function_query(dbHandlestringtrue"GetStats""d"playerid);
    }
    else
    {
        
SendClientMessage(playeridCOLOR_RED"[Error] Wrong password!");
        
ShowPlayerDialog(playerid2DIALOG_STYLE_INPUT"Login""Wrong password, enter the correct one!""Submit""Cancel");
    }
    return 
1;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)