17.05.2012, 01:43
Hello everyone,
I was coding my own game mode. So i used this thread in the starting to do things
So everything use to work fine for me. But suddenly my password hasher stopped working and it wont use to match both the passwords. So i edited my game mode and made it like: That will save the password as a string. and it worked in the end. But now when i try to do it , it doesnt work. I even made changes in the script but nothing happens.
In case any know how to fix it. Please tell me. Im using y_ini to save/read things. Please someone help me.
If you can make this work using any kind of password hasher , if works fine ill use it. What am i doing wrong? Spent so much time on it. Please help.
Thanks
Ballu Miaa
I was coding my own game mode. So i used this thread in the starting to do things
So everything use to work fine for me. But suddenly my password hasher stopped working and it wont use to match both the passwords. So i edited my game mode and made it like: That will save the password as a string. and it worked in the end. But now when i try to do it , it doesnt work. I even made changes in the script but nothing happens.
pawn Код:
public OnPlayerConnect(playerid)
{
if(fexist(UserPath(playerid)))
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,"Login to your account.","Type your password below to login.","Login","Quit");
return 1;
}
else
{
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,"Registering your acount.","Type your password below to register a new account.","Register","Quit");
}
return 1;
}
// The Dialog Response callback
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch( dialogid )
{
case DIALOG_REGISTER:
{
if (!response) return Kick(playerid);
if(response)
{
new NKey[30];
format(NKey, sizeof(NKey), "%s",inputtext);
if(!strlen(inputtext))
{
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,"Blank Password.","Please type your password below to register a new account.","Register","Quit");
SendClientMessage(playerid, COLOR_GREEN, "[CW:WW3] Your password can not be left blank. Please input password to register your account & proceed.");
}
new INI:File = INI_Open(UserPath(playerid));
INI_WriteString(File, "Key",NKey);
INI_WriteInt(File,"Admin",0);
INI_WriteInt(File,"Banned",0);
INI_WriteInt(File,"DonateRank",0);
INI_WriteInt(File,"Warnings",0);
INI_WriteInt(File,"Jail",0);
INI_WriteInt(File,"JailTime",0);
INI_WriteInt(File,"Cash", 1000);
INI_WriteInt(File,"Kills",0);
INI_WriteInt(File,"Deaths",0);
INI_WriteInt(File,"Muted",0);
INI_WriteInt(File,"Hide",0);
INI_WriteInt(File,"Spree",0);
INI_WriteInt(File,"DuelWon",0);
INI_WriteInt(File,"DuelLost",0);
INI_WriteInt(File,"Clan",0);
INI_WriteInt(File,"ClanRank",0);
INI_Close(File);
}
}
case DIALOG_CHANGEPASS:
{
new NKey[30];
format(NKey, sizeof(NKey), "%s",inputtext);
new INI:File = INI_Open(UserPath(playerid));
INI_WriteString(File, "Key", NKey);
INI_Close(File);
new str[128];
format(str, sizeof(str), "[CW:WW3] Your password has been changed to "COL_GREEN"%s",inputtext);
SendClientMessage(playerid, COLOR_RED, str);
return 1;
}
case DIALOG_LOGIN:
{
if (!response) return Kick (playerid);
if(response)
{
new NKey[30];
format(NKey, sizeof(NKey), "%s",inputtext);
if(strcmp(PlayerInfo[playerid][pKey],NKey , true) == 0)
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
SendClientMessage(playerid, COLOR_RED, ""COL_GREEN"You have successfully logged in!");
gPlayerLogged[playerid] = 1;
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
}
return 1;
}
return 1;
}
}
}
//The callback which loads the user.
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
INI_String("Key",PlayerInfo[playerid][pKey],30);
INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
INI_Int("Banned",PlayerInfo[playerid][pBanned]);
INI_Int("DonateRank",PlayerInfo[playerid][pDonateRank]);
INI_Int("Warnings",PlayerInfo[playerid][pWarns]);
INI_Int("Jail",PlayerInfo[playerid][pJail]);
INI_Int("JailTime",PlayerInfo[playerid][pJailTime]);
INI_Int("Cash",PlayerInfo[playerid][pCash]);
INI_Int("Kills",PlayerInfo[playerid][pKills]);
INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
INI_Int("Muted",PlayerInfo[playerid][pMuted]);
INI_Int("Hide",PlayerInfo[playerid][pHide]);
INI_Int("Spree",PlayerInfo[playerid][pSpree]);
INI_Int("DuelWon",PlayerInfo[playerid][pDuelWon]);
INI_Int("DuelLost",PlayerInfo[playerid][pDuelLost]);
INI_Int("Clan",PlayerInfo[playerid][pClan]);
INI_Int("ClanRank",PlayerInfo[playerid][pClanRank]);
return 1;
}
In case any know how to fix it. Please tell me. Im using y_ini to save/read things. Please someone help me.
If you can make this work using any kind of password hasher , if works fine ill use it. What am i doing wrong? Spent so much time on it. Please help.
Thanks
Ballu Miaa