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;
}
usa un print para saber como es la consulta que se hace en
mysql_format(database, SQUERY, sizeof(SQUERY), "SELECT * FROM `accounts` WHERE `name` = '%e' AND `password` = '%e'",PlayerName(playerid),params); Luego, con la consulta que obtuviste en el print vas a phpmyadmin y verificas si te salen datos. |
COMMAND:login(playerid,params[]){ if(PlayerInfo[playerid][LoggedIn] == 1) return SendClientMessage(playerid,COLOR_ROJO,"* Error: Ya has accedido en tu cuenta!"); if(strlen(params)==0) return SendClientMessage(playerid,COLOR_ROJO,"* Uso correcto: /login <contraseсa>"); new nsa[144]; mysql_format(database, nsa, sizeof(nsa), "SELECT * FROM `accounts` WHERE `name` = '%s'",PlayerName(playerid)); mysql_function_query(database, nsa, true, "comprobarcuentalogin","is", playerid, params); return 1; } funcion comprobarcuentalogin(playerid, password[]) { new rows,fields; cache_get_data(rows, fields); if(rows) { mysql_format(database, SQUERY, sizeof(SQUERY), "SELECT * FROM `accounts` WHERE `name` = '%e' AND `password` = '%e'",PlayerName(playerid),password); mysql_function_query(database, SQUERY, true, "PlayerLogin", "d", playerid); } else { SendClientMessage(playerid,COLOR_ROJO,"* Error: Esta cuenta no existe, usa /registrar <contraseсa> para crear una cuenta!"); } return 1; } funcion PlayerLogin(playerid) { new rows,fields,maximum[36]; cache_get_data(rows, fields); if(rows) { //////////////////////////////////////////////////////////////////////////////// ResetPlayerMoney(playerid); new src2[90], ipv[16]; GetPlayerIp(playerid,ipv,16); format(src2,sizeof(src2),"UPDATE `accounts` SET `loggedin` = 1, `ip` = '%s' WHERE `name` = '%s'", ipv, PlayerName(playerid)); mysql_function_query(database, src2, false, "", ""); GivePlayerMoney(playerid, cache_get_field_content_int(0, "money")); PlayerInfo[playerid][Deaths] = cache_get_field_content_int(0, "deaths"); PlayerInfo[playerid][Kills] = cache_get_field_content_int(0, "kills"); PlayerInfo[playerid][Level] = cache_get_field_content_int(0, "level"); PlayerInfo[playerid][hours] = cache_get_field_content_int(0, "hours"); PlayerInfo[playerid][mins] = cache_get_field_content_int(0, "minutes"); PlayerInfo[playerid][secs] = cache_get_field_content_int(0, "seconds"); SetPlayerScore(playerid, cache_get_field_content_int(0, "score")); 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] ); SendClientMessage(playerid,0xABE109FF,string); } SendClientMessage(playerid,0xABE109FF,"* Has accedido correctamente en tu cuenta, ya puedes jugar!"); } 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; }
podrias probar asi
Код:
COMMAND:login(playerid,params[]){ if(PlayerInfo[playerid][LoggedIn] == 1) return SendClientMessage(playerid,COLOR_ROJO,"* Error: Ya has accedido en tu cuenta!"); if(strlen(params)==0) return SendClientMessage(playerid,COLOR_ROJO,"* Uso correcto: /login <contraseсa>"); new nsa[144]; mysql_format(database, nsa, sizeof(nsa), "SELECT * FROM `accounts` WHERE `name` = '%s'",PlayerName(playerid)); mysql_function_query(database, nsa, true, "comprobarcuentalogin","is", playerid, params); return 1; } funcion comprobarcuentalogin(playerid, password[]) { new rows,fields; cache_get_data(rows, fields); if(rows) { mysql_format(database, SQUERY, sizeof(SQUERY), "SELECT * FROM `accounts` WHERE `name` = '%e' AND `password` = '%e'",PlayerName(playerid),password); mysql_function_query(database, SQUERY, true, "PlayerLogin", "d", playerid); } else { SendClientMessage(playerid,COLOR_ROJO,"* Error: Esta cuenta no existe, usa /registrar <contraseсa> para crear una cuenta!"); } return 1; } funcion PlayerLogin(playerid) { new rows,fields,maximum[36]; cache_get_data(rows, fields); if(rows) { //////////////////////////////////////////////////////////////////////////////// ResetPlayerMoney(playerid); new src2[90], ipv[16]; GetPlayerIp(playerid,ipv,16); format(src2,sizeof(src2),"UPDATE `accounts` SET `loggedin` = 1, `ip` = '%s' WHERE `name` = '%s'", ipv, PlayerName(playerid)); mysql_function_query(database, src2, false, "", ""); GivePlayerMoney(playerid, cache_get_field_content_int(0, "money")); PlayerInfo[playerid][Deaths] = cache_get_field_content_int(0, "deaths"); PlayerInfo[playerid][Kills] = cache_get_field_content_int(0, "kills"); PlayerInfo[playerid][Level] = cache_get_field_content_int(0, "level"); PlayerInfo[playerid][hours] = cache_get_field_content_int(0, "hours"); PlayerInfo[playerid][mins] = cache_get_field_content_int(0, "minutes"); PlayerInfo[playerid][secs] = cache_get_field_content_int(0, "seconds"); SetPlayerScore(playerid, cache_get_field_content_int(0, "score")); 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] ); SendClientMessage(playerid,0xABE109FF,string); } SendClientMessage(playerid,0xABE109FF,"* Has accedido correctamente en tu cuenta, ya puedes jugar!"); } 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; } |