09.01.2011, 03:12
Hey guys, i am the man with the most problems, lol.
Anyways this time, my problem is with login, ofc i fix register then login decides to fuck up -.-.
My original login code was:
Yes, i noticed is says insert, so i asked a bud and he told me it was wrong, then i noticed i use insert instead of select, so he gave me this edit:
Yesh, it solved one of my problems, but now my problem is, if you use wrong password, you still can login, if you put no password, you can still login. Help me please .
Thanks in advance,
-Anthony
Anyways this time, my problem is with login, ofc i fix register then login decides to fuck up -.-.
My original login code was:
pawn Код:
if (dialogid == 2)
{
new string[128], escpass[100], escname[MAX_PLAYER_NAME];
//GetPlayerName(playerid, Name, sizeof(Name));
mysql_real_escape_string(inputtext, escpass);
mysql_real_escape_string(UserStats[playerid][Name], escname);
GetPlayerName(playerid, escname, MAX_PLAYER_NAME);
format(string,sizeof(string),"INSERT INTO `Users` (`Name`, `Password`) VALUES ('%s', '%s')",escname, escpass);
mysql_query(string);
if(!mysql_num_rows())
return SendClientMessage(playerid, COLOR_RED, "[ACCOUNT] Incorrect password!");
new row[128];
new field[7][32]; // [4] = Amount of fields, [24] = Max length of the bigest field.
mysql_fetch_row_format(row, "|");
explode(row, field, "|");
mysql_free_result();
// The field starts here with 1, because the field 'Name' = 0, and we already have the name in a variable.
format(UserStats[playerid][Password], 32, "%s", field[1]);
UserStats[playerid][Admin] = strval(field[2]);
UserStats[playerid][Money] = strval(field[3]);
UserStats[playerid][ppos_x] = strval(field[4]);
UserStats[playerid][ppos_y] = strval(field[5]);
UserStats[playerid][ppos_z] = strval(field[6]);
GivePlayerCash(playerid, UserStats[playerid][Money]);
SetPlayerPos(playerid, UserStats[playerid][ppos_x], UserStats[playerid][ppos_y], UserStats[playerid][ppos_z]);
}
pawn Код:
if (dialogid == 2)
{
new string[128], escpass[100], escname[MAX_PLAYER_NAME];
//GetPlayerName(playerid, Name, sizeof(Name));
mysql_real_escape_string(inputtext, escpass);
mysql_real_escape_string(UserStats[playerid][Name], escname);
GetPlayerName(playerid, escname, MAX_PLAYER_NAME);
//format(string,sizeof(string),"INSERT INTO `Users` (`Name`, `Password`) VALUES ('%s', '%s')",escname, escpass);
//mysql_query(string);
//if(!mysql_num_rows())
// return SendClientMessage(playerid, COLOR_RED, "[ACCOUNT] Incorrect password!");
new row[128];
new field[7][32]; // [4] = Amount of fields, [24] = Max length of the bigest field.
mysql_fetch_row_format(row, "|");
explode(row, field, "|");
mysql_free_result();
if(strcmp(inputtext,field[1], true) == 0)
{
// The field starts here with 1, because the field 'Name' = 0, and we already have the name in a variable.
format(UserStats[playerid][Password], 32, "%s", field[1]);
UserStats[playerid][Admin] = strval(field[2]);
UserStats[playerid][Money] = strval(field[3]);
UserStats[playerid][ppos_x] = strval(field[4]);
UserStats[playerid][ppos_y] = strval(field[5]);
UserStats[playerid][ppos_z] = strval(field[6]);
GivePlayerCash(playerid, UserStats[playerid][Money]);
SetPlayerPos(playerid, UserStats[playerid][ppos_x], UserStats[playerid][ppos_y], UserStats[playerid][ppos_z]);
}
}
Thanks in advance,
-Anthony