//So the problem is everytime I try to log in, I enter the correct password the player won't log.
//When I enter my password the dialog dissappears and nothing happens, after a while I crash.
//Registering and all other stuff are working great but I just end up with this, any help is appreciated
if(dialogid == DIALOG_LOGIN)
{
if(!response) return Kick (playerid);
if(response)
{
new query[256], EncryptedPass[130];
WP_Hash(EncryptedPass, sizeof(EncryptedPass), inputtext);
format(query, sizeof(query), "SELECT * FROM accounts WHERE name = '%s' AND password = '%s'", GPN(playerid), EncryptedPass);
mysql_query(query);
mysql_store_result();
if(mysql_num_rows() != 0)
{
LoadPlayer(playerid);
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,"{FF8000}Login","{FFFFFF}Wrong password.\nLogin below with the password you registered with.","Login","Quit");
}
}
}
//LoadPlayer
stock LoadPlayer(playerid)
{
new query[128];
format(query, sizeof(query), "SELECT * FROM accounts WHERE Name = '%s'", GPN(playerid));
mysql_query(query);
mysql_store_result();
while(mysql_fetch_row_format(query,"|"))
{
mysql_fetch_field_row(query, "ID"); PlayerInfo[playerid][pID] = strval(query);
mysql_fetch_field_row(PlayerInfo[playerid][pName], "Name");
mysql_fetch_field_row(PlayerInfo[playerid][pPass], "Password");
}
SendClientMessage(playerid,COLOR_WHITE,"WB");
SetSpawnInfo(playerid,0,0,0,0,0,0,0,0,0,0,0,0);
SpawnPlayer(playerid);
TogglePlayerSpectating(playerid, 0);
SetCameraBehindPlayer(playerid);
//SetPlayerPos(playerid,PlayerInfo[playerid][pPosX],PlayerInfo[playerid][pPosY],PlayerInfo[playerid][pPosZ]);
if(PlayerInfo[playerid][pVModel] > 0)
{
PlayerInfo[playerid][pVehicle] = CreateVehicle(PlayerInfo[playerid][pVModel],PlayerInfo[playerid][pVX],PlayerInfo[playerid][pVY],PlayerInfo[playerid][pVZ],PlayerInfo[playerid][pVA],PlayerInfo[playerid][pVColor1],PlayerInfo[playerid][pVColor2],-1);
Fuel[PlayerInfo[playerid][pVehicle]] = PlayerInfo[playerid][pVFuel];
for(new i = 0; i < MAX_MODS; i++)
{
AddVehicleComponent(PlayerInfo[playerid][pVehicle], PlayerInfo[playerid][pVMods][i]);
}
}
return 1;
}
I'm not good in MySQL, in fact I don't know shit about it but you should post your server log so other people can easily help you.
|
And yet you start with obsolete methods? If you're a starter it's easier to learn the newer methods now, rather than to have to upgrade later, with all foreseeable problems at that.
|
format(query, sizeof(query), "SELECT * FROM accounts WHERE name = '%s' AND password = '%s'", GPN(playerid), EncryptedPass);
mysql_query(query);
format(query, sizeof(query), "SELECT * FROM `accounts` WHERE `name` = '%s' AND `password` = '%s'", GPN(playerid), EncryptedPass);
mysql_query(query);
if(dialogid == DIALOG_LOGIN)
{
if(!response) return Kick (playerid);
if(response)
{
new query[256], EncryptedPass[130];
WP_Hash(EncryptedPass, sizeof(EncryptedPass), inputtext);
format(query, sizeof(query), "SELECT * FROM `accounts` WHERE `name` = '%s' AND `password` = '%s'", GPN(playerid), EncryptedPass);
mysql_query(query);
mysql_store_result();
if(mysql_num_rows() != 0)
{
LoadPlayer(playerid);
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,"{FF8000}Login","{FFFFFF}Wrong password.\nLogin below with the password you registered with.","Login","Quit");
}
}
}
if(dialogid == DIALOG_REGISTER) // This works perfectly fine, no trouble with this
{
if(!response) return Kick(playerid);
if(response)
{
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "{FF8000}Register","Incorrect password.\nInsert a valid password below.","Register","Quit");
RegisterPlayer(playerid, inputtext);
}
}
stock LoadPlayer(playerid)
{
new query[128];
format(query, sizeof(query), "SELECT * FROM accounts WHERE Name = '%s'", GPN(playerid));
mysql_query(query);
mysql_store_result();
while(mysql_fetch_row_format(query,"|"))
{
mysql_fetch_field_row(query, "ID"); PlayerInfo[playerid][pID] = strval(query);
mysql_fetch_field_row(PlayerInfo[playerid][pName], "Name");
mysql_fetch_field_row(PlayerInfo[playerid][pPass], "Password");
}
SendClientMessage(playerid,COLOR_WHITE,"WB");
SetSpawnInfo(playerid,0,0,0,0,0,0,0,0,0,0,0,0);
SpawnPlayer(playerid);
TogglePlayerSpectating(playerid, 0);
SetCameraBehindPlayer(playerid);
//SetPlayerPos(playerid,PlayerInfo[playerid][pPosX],PlayerInfo[playerid][pPosY],PlayerInfo[playerid][pPosZ]);
if(PlayerInfo[playerid][pVModel] > 0)
{
PlayerInfo[playerid][pVehicle] = CreateVehicle(PlayerInfo[playerid][pVModel],PlayerInfo[playerid][pVX],PlayerInfo[playerid][pVY],PlayerInfo[playerid][pVZ],PlayerInfo[playerid][pVA],PlayerInfo[playerid][pVColor1],PlayerInfo[playerid][pVColor2],-1);
Fuel[PlayerInfo[playerid][pVehicle]] = PlayerInfo[playerid][pVFuel];
for(new i = 0; i < MAX_MODS; i++)
{
AddVehicleComponent(PlayerInfo[playerid][pVehicle], PlayerInfo[playerid][pVMods][i]);
}
}
return 1;
}
stock RegisterPlayer(playerid, regpass[])
{
new query[256], EncryptedPass[130];
WP_Hash(EncryptedPass, sizeof(EncryptedPass), regpass);
format(query, sizeof(query), "INSERT INTO accounts (Name, Password) VALUES ('%s', '%s')", GPN(playerid), EncryptedPass);
mysql_query(query);
PlayerInfo[playerid][pLevel] = 1;
SetPlayerScore(playerid, 1);
Registration[playerid] = 1;
PlayerInfo[playerid][pHealth] = 100;
if(Registration[playerid] == 1)
{
ShowPlayerDialog(playerid,DIALOG_GENDER,DIALOG_STYLE_MSGBOX,"{FF8000}Gender","{FFFFFF}What is your characters gender?","Male","Female");
return 1;
}
return 1;
}
stock RegisterPlayer(playerid, regpass[])
{
new query[256], EncryptedPass[130];
WP_Hash(EncryptedPass, sizeof(EncryptedPass), regpass);
format(query, sizeof(query), "INSERT INTO `accounts` (`Name`, `Password`) VALUES ('%s', '%s')", GPN(playerid), EncryptedPass);
mysql_query(query);
PlayerInfo[playerid][pLevel] = 1;
SetPlayerScore(playerid, 1);
Registration[playerid] = 1;
PlayerInfo[playerid][pHealth] = 100;
if(Registration[playerid] == 1)
{
ShowPlayerDialog(playerid,DIALOG_GENDER,DIALOG_STYLE_MSGBOX,"{FF8000}Gender","{FFFFFF}What is your characters gender?","Male","Female");
return 1;
}
return 1;
}
stock LoadPlayer(playerid)
{
new query[128];
format(query, sizeof(query), "SELECT * FROM `accounts` WHERE `Name` = '%s'", GPN(playerid));
mysql_query(query);
mysql_store_result();
while(mysql_fetch_row_format(query,"|"))
{
mysql_fetch_field_row(query, "ID"); PlayerInfo[playerid][pID] = strval(query);
mysql_fetch_field_row(PlayerInfo[playerid][pName], "Name");
mysql_fetch_field_row(PlayerInfo[playerid][pPass], "Password");
}
SendClientMessage(playerid,COLOR_WHITE,"WB");
SetSpawnInfo(playerid,0,0,0,0,0,0,0,0,0,0,0,0);
SpawnPlayer(playerid);
TogglePlayerSpectating(playerid, 0);
SetCameraBehindPlayer(playerid);
//SetPlayerPos(playerid,PlayerInfo[playerid][pPosX],PlayerInfo[playerid][pPosY],PlayerInfo[playerid][pPosZ]);
if(PlayerInfo[playerid][pVModel] > 0)
{
PlayerInfo[playerid][pVehicle] = CreateVehicle(PlayerInfo[playerid][pVModel],PlayerInfo[playerid][pVX],PlayerInfo[playerid][pVY],PlayerInfo[playerid][pVZ],PlayerInfo[playerid][pVA],PlayerInfo[playerid][pVColor1],PlayerInfo[playerid][pVColor2],-1);
Fuel[PlayerInfo[playerid][pVehicle]] = PlayerInfo[playerid][pVFuel];
for(new i = 0; i < MAX_MODS; i++)
{
AddVehicleComponent(PlayerInfo[playerid][pVehicle], PlayerInfo[playerid][pVMods][i]);
}
}
return 1;
}