PHP код:
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;
}