08.02.2016, 23:34
hola estoy manejando nuevamente mysql luego de aсos pero algo pasa con el registro
cuando pongo /login password pongo una contraseсa incorrecta o la original se repiten los mensajes como contraseсa incorrecta y no para hasta ke salga del server o ponga la contraseсa correcta.
parece ke tengo ke cerrar en alguna parte el codigo con 0 o el comando del mysql llamando al playerlogin es el problema, alguien sabe?
+rep saludos
cuando pongo /login password pongo una contraseсa incorrecta o la original se repiten los mensajes como contraseсa incorrecta y no para hasta ke salga del server o ponga la contraseсa correcta.
pawn Код:
funcion comprobarcuentalogin(playerid)
{
new rows,fields;
cache_get_data(rows, fields);
if(!rows) return SendClientMessage(playerid,COLOR_ROJO,"* Error: Esta cuenta no existe, usa /registrar <contraseсa> para crear una cuenta!");
else { }
}
COMMAND:login(playerid,params[]){
if(PlayerInfo[playerid][LoggedIn] == 1) return SendClientMessage(playerid,COLOR_ROJO,"* Error: Ya has accedido en tu cuenta!");
new nsa[144];
mysql_format(database, nsa, sizeof(nsa), "SELECT * FROM `accounts` WHERE `name` = '%s'",PlayerName(playerid) );
mysql_function_query(database, nsa, true, "comprobarcuentalogin","i", playerid);
if(strlen(params)==0) return SendClientMessage(playerid,COLOR_ROJO,"* Uso correcto: /login <contraseсa>");
mysql_format(database, SQUERY, sizeof(SQUERY), "SELECT * FROM `accounts` WHERE `name` = '%e' AND `password` = '%e'",PlayerName(playerid),params);
mysql_function_query(database, SQUERY, true, "PlayerLogin", "d", playerid);
return 1;
}
funcion PlayerLogin(playerid)
{
new rows,fields,maximum[36];
cache_get_data(rows, fields);
if(rows)
{
////////////////////////////////////////////////////////////////////////////////
ResetPlayerMoney(playerid);
new src2[90];
format(src2,sizeof(src2),"UPDATE `accounts` SET `loggedin` = 1 WHERE `name` = '%s'",PlayerName(playerid) );
mysql_function_query(database, src2, false, "", "");
new src4[400];
new ipv[16];
GetPlayerIp(playerid,ipv,16);
format(src4,sizeof(src4),"UPDATE `accounts` SET `ip` = '%s' WHERE `name` = '%s'", ipv, PlayerName(playerid) );
mysql_function_query(database, src4, false, "", "");
cache_get_field_content(0, "money", maximum), GivePlayerMoney(playerid, strval(maximum) );
cache_get_field_content(0, "deaths", maximum), PlayerInfo[playerid][Deaths] = strval(maximum);
cache_get_field_content(0, "kills", maximum), PlayerInfo[playerid][Kills] = strval(maximum);
cache_get_field_content(0, "level", maximum), PlayerInfo[playerid][Level] = strval(maximum);
cache_get_field_content(0, "hours",maximum), PlayerInfo[playerid][hours] = strval(maximum);
cache_get_field_content(0, "minutes",maximum), PlayerInfo[playerid][mins] = strval(maximum);
cache_get_field_content(0, "seconds",maximum), PlayerInfo[playerid][secs] = strval(maximum);
cache_get_field_content(0, "score",maximum), SetPlayerScore(playerid, strval(maximum) );
PlayerInfo[playerid][Registered] = 1;
PlayerInfo[playerid][LoggedIn] = 1;
////////////////////////////////////////////////////////////////////////////////
PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
if(PlayerInfo[playerid][Level] > 0)
{
new string[128];
format(string,sizeof(string),"* Has accedido correctamente con tu cuenta en el servidor. (AdminNivel: %d)", PlayerInfo[playerid][Level] );
return SendClientMessage(playerid,0xABE109FF,string);
}
else SendClientMessage(playerid,0xABE109FF,"* Has accedido correctamente en tu cuenta, ya puedes jugar!");
return 1;
}
else
{
PlayerInfo[playerid][FailLogin]++;
printf("* %s ha fallado en acceder a su cuenta, contraseсa incorrecta Intento (%d)", PlayerName(playerid), PlayerInfo[playerid][FailLogin] );
if(PlayerInfo[playerid][FailLogin] == 4)
{
new string[128];
format(string, sizeof(string), "* %s ha sido kickeado. (Razon: Contraseсas Incorrectas de cuenta)", PlayerName(playerid) );
SendClientMessageToAll(COLOR_ROJO, string);
print(string);
SetTimerEx( "KickPlayer", 1000, false, "i", playerid );
}
SendClientMessage(playerid,COLOR_ROJO,"* Error: Contraseсa Incorrecta!");
}
return 1;
}
+rep saludos