07.01.2010, 20:34
Hello again.
I have a problem while using WP_Hash, I thought I could simply get it to work, but I require a little more help.
When the player types for instance: /register askme123, the WP_Hash generates this
>> Password: 7EBEFEBAC5ACCF4E3B459A0B59D7B50FA4422F7304FB0811B9 D6A0692D48ADCB1C713AE7450BBFFC1EF3DE9A92F5D2F10C65 97AFC0DB5CE84BC13
Which is what I feel it should generate. But my problem is this, when the player goes to type '/login askme123', they get the message 'Incorrect password.' I don't know if I am missing an if statement or not, which is why I need the help, so this is the code that I use. (It has been taken from seifadmin's script, that uses MD5, I just changed it to WP_Hash a while ago)
OnPlayerLogin : This is called when the player types '/login password'
The login command.
Any help would be appreciated.
I have a problem while using WP_Hash, I thought I could simply get it to work, but I require a little more help.
When the player types for instance: /register askme123, the WP_Hash generates this
>> Password: 7EBEFEBAC5ACCF4E3B459A0B59D7B50FA4422F7304FB0811B9 D6A0692D48ADCB1C713AE7450BBFFC1EF3DE9A92F5D2F10C65 97AFC0DB5CE84BC13
Which is what I feel it should generate. But my problem is this, when the player goes to type '/login askme123', they get the message 'Incorrect password.' I don't know if I am missing an if statement or not, which is why I need the help, so this is the code that I use. (It has been taken from seifadmin's script, that uses MD5, I just changed it to WP_Hash a while ago)
OnPlayerLogin : This is called when the player types '/login password'
pawn Код:
forward OnPlayerLogin(playerid,password[]);
public OnPlayerLogin(playerid,password[])
{
new name[24], str[128], buf[145];
GetPlayerName(playerid, name, sizeof name);
format(str, sizeof str, "/Accounts/%s.playeraccount", name);
new File:account = fopen(str, io_read);
if (account)
{
new pass[256];
new passres[128], value[128];
fread(account, pass, sizeof pass);
passres = GetFileString(pass);
if (!strcmp("Password", passres))
{
value = GetFileValue(pass);
strmid(AccountInfo[playerid][Password], value, 0, strlen(value)-1, 128);
}
if (!strcmp(AccountInfo[playerid][Password], password, true))
{
while (fread(account, pass, 256))
{
passres = GetFileString(pass);
if (strfind(passres, "AdminLevel") != -1)
{
value = GetFileValue(pass);
AccountInfo[playerid][AdminLevel] = strval(value);
}
if (strfind(passres, "Cash") != -1)
{
value = GetFileValue(pass);
AccountInfo[playerid][Cash] = strval(value);
}
}
fclose(account);
AccountInfo[playerid][Logged] = 1;
}
else
{
SendClientMessage(playerid, RED, "Incorrect Password.");
fclose(account);
return 1;
}
GivePlayerMoney(playerid, AccountInfo[playerid][Cash]);
format(str, sizeof str, "|- You have successfully logged in as %s -|", name);
SendClientMessage(playerid, GREEN, str);
printf("%s has logged in", name);
if (AccountInfo[playerid][AdminLevel] > 0)
{
format(str, sizeof str, "|» You are now logged in as a level %d admin «|", AccountInfo[playerid][AdminLevel]);
SendClientMessage(playerid, LIGHTGREEN, str);
}
}
return 1;
}
pawn Код:
dcmd_login(playerid, params[])
{
new
tmppass[145],
plname[24],
string[128];
if(AccountInfo[playerid][Logged] == 1) return SendClientMessage(playerid, RED, "You are already logged in.");
if(!sscanf(params, "i", tmppass))
{
SendClientMessage(playerid, ORANGE, "Error! Use /login password!");
}
else
{
GetPlayerName(playerid, plname, sizeof(plname));
format(string, sizeof(string), "/Accounts/%s.playerAccount", plname);
if(!fexist(string)) return SendClientMessage(playerid, RED, "That account isn't registered! Please register: /register [password]");
strmid(tmppass, params, 0, strlen(params), 255);
WP_Hash(tmppass, sizeof(tmppass), params);
OnPlayerLogin(playerid, tmppass);
return true;
}
return true;
}