[Ayuda] Problema con logeo [mysql] -
Thewin - 27.02.2014
Me ocurre lo siguiente, al entrar al servidor me sale el dialogo de logeo, pero no reconoce mi verdadera contraseсa, es decir, con cualquier numero o letra que escriba me logea el usuario, pero al registrarme, y colocar una contraseсa incorrecta si lo detecta, no entiendo por que. les dejo el codigo abajo:
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
new string[256];
new pName[24], Query[256]; GetPlayerName(playerid, pName, 24);
switch(dialogid)
{
case LOGIN:
{
if(!response)
{
Kick(playerid);
}
if(strcmp(PlayerInfo[playerid][pPassword], inputtext, true, 128) == 0)
{
format(Query, sizeof(Query), "SELECT * FROM `usuarios` WHERE `Username` = '%s'", pName);
mysql_function_query(Conecction, Query, true, "OnQueryFinish", "ii", 1, playerid);
}
else
{
SendClientMessage(playerid, -1, "CONTRASEСA INCORRECTA");
}
}
case REGISTRO:
{
if(!response)
{
SendClientMessage(playerid, -1, "Kicked");
Kick(playerid);
}
if(response)
{
if(!strlen(inputtext))
{
Kick(playerid);
}
new string2[128];
format(string2, sizeof(string2), "%s", inputtext); format(PlayerInfo[playerid][pPassword], 144, "%s",inputtext);
format(Query, sizeof(Query), "INSERT INTO `smf_members` (member_name, passwd, real_name,avatar) VALUES ('%s', '%s','%s','http://zonalatina.com.nu/skins/%d.png')",pName, PlayerInfo[playerid][pPassword],pName,GetPlayerSkin(playerid));
mysql_function_query(Conecction, Query, true, "OnQueryFinish", "ii", 0, playerid);
format(Query, sizeof(Query), "INSERT INTO `usuarios` (username, password,posX,posY,posZ,vida,money,skin) VALUES ('%s','%s','1815.36','-1825.75','13.4141','100','50000','250')",pName, PlayerInfo[playerid][pPassword]);
mysql_function_query(Conecction, Query, true, "OnQueryFinish", "ii", 0, playerid);
format(string, sizeof(string), "Has registrado el personaje %s en nuestro servidor.\n\nAhora inicia sesiуn", pName);
ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_PASSWORD,"Iniciar sesiуn",string,"Enviar","Salir");
}
}
}
return 1;
}
Imagino que mi error es que cuando te conectas al servidor antes de logearte no se define la variable PlayerInfo[playerid][pPassword] para igualarla al inputtext pero no entiendo ya que tengo configurado los cache_get_field_content para una vez que el usuario se logee.
Gracias.
Respuesta: [Ayuda] Problema con logeo [mysql] -
Thewin - 27.02.2014
Edito: ahora encontre un codigo mal en OnQueryFinish y ahora siempre me dice contraseсa incorrecta ._.
aca el public:
Код:
public OnQueryFinish(resultid, extraid, ConnectionHandle)
{
new Rows, Field, string[256];
if(resultid != 0)
{
cache_get_data(Rows, Field);
}
switch(resultid)
{
case 1:
{
if(Rows == 1)
{
new content[20];
cache_get_field_content(0, "Baneado", content); PlayerInfo[extraid][pBan] = strval(content);
cache_get_field_content(0, "Modelo", content); PlayerInfo[extraid][vModelo] = strval(content);
cache_get_field_content(0, "X", content); PlayerInfo[extraid][vX] = strval(content);
cache_get_field_content(0, "Y", content); PlayerInfo[extraid][vY] = strval(content);
cache_get_field_content(0, "Z", content); PlayerInfo[extraid][vZ] = strval(content);
cache_get_field_content(0, "Color1", content); PlayerInfo[extraid][vColor1] = strval(content);
cache_get_field_content(0, "Color2", content); PlayerInfo[extraid][vColor2] = strval(content);
cache_get_field_content(0, "Admin", content); PlayerInfo[extraid][jAdminNvl] = strval(content);
cache_get_field_content(0, "Score", content); PlayerInfo[extraid][jNivel] = strval(content);
cache_get_field_content(0, "Sexo", content); PlayerInfo[extraid][jSexo] = strval(content);
cache_get_field_content(0, "Money", content); PlayerInfo[extraid][jBancario] = strval(content);
cache_get_field_content(0, "Faccion", content); PlayerInfo[extraid][jMiembro] = strval(content);
cache_get_field_content(0, "Skin", content); PlayerInfo[extraid][jRopa] = strval(content);
cache_get_field_content(0, "Vida", content); PlayerInfo[extraid][jVida] = floatstr(content);
cache_get_field_content(0, "Chaleco", content); PlayerInfo[extraid][jArmadura] = floatstr(content);
cache_get_field_content(0, "posX", content); PlayerInfo[extraid][jPos_x] = floatstr(content);
cache_get_field_content(0, "posY", content); PlayerInfo[extraid][jPos_y] = floatstr(content);
cache_get_field_content(0, "posZ", content); PlayerInfo[extraid][jPos_z] = floatstr(content);
if(PlayerInfo[extraid][pBan] == 1)
{
Kick(extraid);
}
else
autos[extraid] = CreateVehicle(PlayerInfo[extraid][vModelo],PlayerInfo[extraid][vX],PlayerInfo[extraid][vY],PlayerInfo[extraid][vZ],0,PlayerInfo[extraid][vColor1],PlayerInfo[extraid][vColor2],-1);
SetSpawnInfo(extraid,0,PlayerInfo[extraid][jRopa],PlayerInfo[extraid][jPos_x], PlayerInfo[extraid][jPos_y], PlayerInfo[extraid][jPos_z],0,0,0,0,0,0,0);
SetPlayerScore(extraid, PlayerInfo[extraid][jNivel]);
SetPlayerArmour(extraid, PlayerInfo[extraid][jArmadura]);
SetPlayerHealth(extraid, PlayerInfo[extraid][jVida]);
GivePlayerMoney(extraid, PlayerInfo[extraid][jBancario]);
SpawnPlayer(extraid);
}
else if(!Rows)
{
//
}
}
case 2:
{
if(Rows == 1)
{
new pName[24]; GetPlayerName(extraid, pName, 24);
new content[20];
cache_get_field_content(0, "Password", content); PlayerInfo[extraid][pPassword] = strval(content);
format(string, sizeof(string), "El personaje %s estб registrado en la base de datos. Pon los datos para iniciar sesiуn:", pName);
ShowPlayerDialog(extraid, LOGIN, DIALOG_STYLE_PASSWORD,"Login",string,"Enviar","Salir");
}
else if(!Rows)
{
new pName[24]; GetPlayerName(extraid, pName, 24);
format(string, sizeof(string), "El jugador %s no estб registrado en el servidor, pon aquн la contraseсa para registrarlo:", pName);
ShowPlayerDialog(extraid, REGISTRO, DIALOG_STYLE_PASSWORD,"Registro:",string,"Enviar","Salir");
}
}
}
return 1;
}
Re : [Ayuda] Problema con logeo [mysql] -
Thewin - 27.02.2014
Ya lo he arreglado.