error 035: argument type mismatch (argument 1) -
Tomer!.$ - 06.09.2013
EDIT: Important addition in post #3.
The error:
PHP код:
error 035: argument type mismatch (argument 1)
The function(emphasised error line)
PHP код:
case 2: // Login
{
new name[MAX_PLAYER_NAME+1];
GetPlayerName(playerid, name, sizeof(name));
if(CheckPassword(name, inputtext) >= 1) // Error line
{
SendClientMessage(playerid, COLOR_WHITE, "[SUCCESS] You have successfully logged in!");
GetStats(playerid);
}
else
{
SendClientMessage(playerid, COLOR_RED, "[Error] Wrong password!");
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Login", "Wrong password, enter the correct one!", "Submit", "Cancel");
}
}
CheckPassword:
PHP код:
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, false, "", "", "");
cache_get_data(rows, fields, dbHandle);
if(rows >= 1) return 1;
else return 0;
}
Re: error 035: argument type mismatch (argument 1) -
Misiur - 06.09.2013
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
Re: error 035: argument type mismatch (argument 1) -
Tomer!.$ - 06.09.2013
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(playerid, name, sizeof(name));
if(CheckPassword(name, inputtext) >= 1)
{
SendClientMessage(playerid, COLOR_WHITE, "[SUCCESS] You have successfully logged in!");
new string[128];
format(string, sizeof(string), "SELECT * FROM users WHERE username = '%s'", name);
mysql_function_query(dbHandle, string, true, "GetStats", "d", playerid);
}
else
{
SendClientMessage(playerid, COLOR_RED, "[Error] Wrong password!");
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Login", "Wrong password, enter the correct one!", "Submit", "Cancel");
}
}
CheckPassword:
PHP код:
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, "", "", "");
cache_get_data(rows, fields, dbHandle);
if(rows >= 1) return 1;
else return 0;
}
Re: error 035: argument type mismatch (argument 1) -
AaronKillz - 06.09.2013
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;
}
Re: error 035: argument type mismatch (argument 1) -
Tomer!.$ - 06.09.2013
I already have a function to check if the account exists... I call it OnPlayerConnect.
PHP код:
CheckAccountExists1(playerid, account[])
{
new string[128];
format(string, sizeof(string), "SELECT * FROM users WHERE username = '%s'", account);
mysql_function_query(dbHandle, string, true, "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 rows, fields;
cache_get_data(rows, fields, dbHandle);
if(rows) {
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Login", "This account is registered, please enter the password.", "Submit", "Cancel");
}
else {
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Register", "Please enter the password for your new account.", "Submit", "Cancel");
}
return 1;
}
Re: error 035: argument type mismatch (argument 1) -
Tomer!.$ - 06.09.2013
Well?
Re: error 035: argument type mismatch (argument 1) -
Misiur - 06.09.2013
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...
Re: error 035: argument type mismatch (argument 1) -
Tomer!.$ - 06.09.2013
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(playerid, name, sizeof(name));
//if(CheckPassword(name, inputtext) >= 1)
format(string, sizeof(string), "SELECT * FROM users WHERE username = '%s' AND password = '%s'", name, inputtext);
mysql_function_query(dbHandle, string, true, "CheckPassword", "is", playerid, name);
}
PHP код:
forward CheckPassword(playerid, name[]);
public CheckPassword(playerid, name[])
{
new rows, fields, string[128];
cache_get_data(rows, fields, dbHandle);
if(rows >= 1)
{
SendClientMessage(playerid, COLOR_WHITE, "[SUCCESS] You have successfully logged in!");
format(string, sizeof(string), "SELECT * FROM users WHERE username = '%s'", name);
mysql_function_query(dbHandle, string, true, "GetStats", "d", playerid);
}
else
{
SendClientMessage(playerid, COLOR_RED, "[Error] Wrong password!");
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Login", "Wrong password, enter the correct one!", "Submit", "Cancel");
}
return 1;
}