#include <a_samp>
#include <YSI\y_ini>
#include <sscanf2>
#include <zcmd>
#define PATH "/Usuarios/%s.ini"
native WP_Hash(buffer[], len, const str[]);
enum pInfo
{
pPass[130],
pScore,
AdmLevel,
pDinero,
pNivel
}
new PlayerInfo[MAX_PLAYERS][pInfo];
forward loadaccount_user(playerid,name[],value[]);
public loadaccount_user(playerid,name[],value[])
{
INI_String("Contraseсa",PlayerInfo[playerid][pPass], 130);
INI_Int("Score", PlayerInfo[playerid][pScore]);
INI_Int("AdmLevel", PlayerInfo[playerid][AdmLevel]);
INI_Int("Dinero", PlayerInfo[playerid][pDinero]);
INI_Int("Nivel", PlayerInfo[playerid][pNivel]);
return 1;
}
stock UserPath(playerid)
{
new string[128],playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername,sizeof(playername));
format(string,sizeof(string),PATH,playername);
return string;
}
public OnPlayerConnect(playerid);
{
if(fexist(UserPath(playerid)))
{
INI_ParseFile(UserPath(playerid), "loadaccount_%s", .bExtra = true, .extra = playerid);
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "{00FF00}Bienvenido de vuelta!", "{FFFFFF}Escribe tu contraseсa abajo", "Aceptar", "Salir");
}
else ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "{00FF00}Bienvenido a Latin Gamers Freeroam", "{FFFFFF}Registrate poniendo tu contraseсa abajo", "Aceptar", "Salir");
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(response)
{
switch(dialogid)
{
case DIALOG_REGISTER:
{
if(!response)
{
Kick( playerid );
return 1;
}
else
if(response)
{
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "{FF0000}ERROR", "{FFFFFF}Contraseсa no valida.\n Escriba su contraseсa", "Aceptar", "Salir");
else
{
new INI:File = INI_Open(UserPath(playerid));
new Hash[129];
WP_Hash(Hash, sizeof(Hash), inputtext);
INI_SetTag(File, "Data");
INI_WriteString(File, "Contraseсa", Hash);
INI_WriteInt(File, "Dinero", 0);
INI_WriteInt(File, "Score", 0);
INI_WriteInt(File, "AdmLevel", 0);
INI_WriteInt(File, "Nivel", 0);
printf("Contrasena Hash: %s , Original: %s", Hash, inputtext); //Hice un debug para ver si estaba bien. Y al parecer si :S.
INI_Close(File);
}
}
}
case DIALOG_LOGIN:
{
if(!response)
{
Kick( playerid );
return 1;
}
else
if(response)
{
if(!strlen(inputtext))
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "{FF0000}ERROR!", "{FFFFFF}Contraseсa no valida.\n Escriba de nuevo su contraseсa", "Aceptar", "Salir");
return 1;
}
else
{
new Hash[130];
if(WP_Hash(Hash, sizeof(Hash), inputtext) == PlayerInfo[playerid][pPass])
{
INI_ParseFile(UserPath(playerid), "loadaccount_%s", .bExtra = true, .extra = playerid);
GivePlayerMoney(playerid, PlayerInfo[playerid][pDinero]);
SetPlayerScore(playerid, PlayerInfo[playerid][pScore]);
printf("Contrasena Hash: %s , Original: %s", Hash, inputtext);
return 1;
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"{FF0000}ERROR", "{FFFFFF}Contraseсa invalida. Pongala de nuevo", "Aceptar", "Salir");
return 1;
}
}
}
}
}
}
return 1;
}
[15:45:40] [join] xXmAn40100Xx has joined the server (0:192.168.1.52) [15:45:40] [Latin Gamers Log] xXmAn40100Xx se unio al servidor [15:45:43] Contrasena Hash: DD40FC699438525DDECD2DF2467A5D3709CECBC696D2F0959A218433D1EDDF08EA3B48C522FB0B8B726181FAD217616935E4D897C76A8FE663C9D1D38BF3AAB1 , Original: hola - Registro [15:45:53] [part] xXmAn40100Xx has left the server (0:1) [15:46:33] Incoming connection: 192.168.1.52:49726 [15:46:34] [join] xXmAn40100Xx has joined the server (0:192.168.1.52) [15:46:34] [Latin Gamers Log] xXmAn40100Xx se unio al servidor [15:46:39] Contrasena Hash: F4EBC060D62CAB4E271B6E020E40792FE86B55C2E75974A0D06B04C425442514AB921015F88E1E027901DF6795421A7FE7033B745E094CC45EA19815372986E7 , Original: u - Logueo [15:46:45] [part] xXmAn40100Xx has left the server (0:1)
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(response)
{
switch(dialogid)
{
case DIALOG_REGISTER:
{
if(!response)
{
Kick( playerid );
return 1;
}
else
if(response)
{
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "{FF0000}ERROR", "{FFFFFF}Contraseсa no valida.\n Escriba su contraseсa", "Aceptar", "Salir");
else
{
new INI:File = INI_Open(UserPath(playerid));
new Hash[129];
WP_Hash(Hash, sizeof(Hash), inputtext);
INI_SetTag(File, "Data");
INI_WriteString(File, "Contraseсa", Hash);
INI_WriteInt(File, "Dinero", 0);
INI_WriteInt(File, "Score", 0);
INI_WriteInt(File, "AdmLevel", 0);
INI_WriteInt(File, "Nivel", 0);
printf("Contrasena Hash: %s , Original: %s", Hash, inputtext); //Hice un debug para ver si estaba bien. Y al parecer si :S.
INI_Close(File);
}
}
}
case DIALOG_LOGIN:
{
if(!response) return Kick(playerid);
if(response)
{
if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
{
if(WP_Hash(Hash, sizeof(Hash), inputtext) == PlayerInfo[playerid][pPass])
{
INI_ParseFile(UserPath(playerid), "loadaccount_%s", .bExtra = true, .extra = playerid);
GivePlayerMoney(playerid, PlayerInfo[playerid][pDinero]);
SetPlayerScore(playerid, PlayerInfo[playerid][pScore]);
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"{FF0000}ERROR", "{FFFFFF}Contraseсa invalida. Pongala de nuevo", "Aceptar", "Salir");
}
return 1;
}
}
}
}
}
return 1;
}
PHP код:
|