Posts: 1,767
Threads: 124
Joined: Mar 2010
Hi.. i'm starting for the first time with Y_ini.. i was readed fully topic ****** and i've a problem : )
Code:
new INI:Account, buf[129];
Account = INI_Open(PlayerName(playerid));
INI_WriteInt(Account, "Password", WP_Hash(password, sizeof(buf), buf));
INI_Close(Account);
How i can hash player password (this giving me "Password = 0' in user file)
2.. how i can get password from player file. It's too complicated for me. (Better for me is dini_Get xD - but in need to learn something stronger.)
So.. i'm waiting for the help : )
Posts: 1,767
Threads: 124
Joined: Mar 2010
GetPassword:
Code:
error 006: must be assigned to an array
-cut-
Posts: 1,767
Threads: 124
Joined: Mar 2010
Okey.. i changed it:
Code:
GetPassword(playerid, nickname[], value)
value[] on value.
edit://
I think @UP is must be value[]. But don't know how to fix.
pawn Code:
stock OnPlayerLogin(playerid, password[])
{
if(GetPassword(playerid, PlayerName(playerid), password))
{
Code:
C:\Documents and Settings\Kakarotto\Pulpit\Sa-Mp Serwer 0.3c Y_INI\gamemodes\pes.pwn(2137) : error 035: argument type mismatch (argument 3)
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
1 Error.
Why? : )
Posts: 1,767
Threads: 124
Joined: Mar 2010
Quote:
Originally Posted by Fj0rtizFredde
For your first question. The password is a string and not an int
pawn Code:
new INI:Account, buf[129]; Account = INI_Open(PlayerName(playerid)); WP_Hash(password, sizeof(buf), buf); INI_WriteString(Account, "Password", buf); INI_Close(Account);
|
/imageshack/img814/8625/beztytuudvf.png
Saved to file:
Password = (nothing here)
But maybe it's my problem.
pawn Code:
stock INI_Exist(nickname[])
{
new string[64];
format(string, sizeof(string),"%s\%s.ini", UserFile, nickname);
return fexist(string);
}
pawn Code:
#define UserFile "/Polski eXtra Serwer/Users/"
How to create player file in a folder?
Posts: 1,767
Threads: 124
Joined: Mar 2010
Account created in a folder:
pawn Code:
stock PlayerFile(playerid)
{
new string[64];
format(string, sizeof(string), "%s\%s.ini", UserFile, PlayerName(playerid));
return string;
}
Now need help with that password.
pawn Code:
stock OnPlayerRegister(playerid, password[])
{
new INI:Account, buf[129];
Account = INI_Open(PlayerFile(playerid));
WP_Hash(password, sizeof(buf), buf);
INI_WriteString(Account, "Password", buf);
INI_Close(Account);
return true;
}
pawn Code:
stock OnPlayerLogin(playerid, password[])
{
if(GetPassword(playerid, PlayerFile(playerid), password))
{
SendClientMessage
}else{
SendErrorMessage
}
return true;
}
Is all okey now?
Posts: 1,767
Threads: 124
Joined: Mar 2010
If he was wrong you can help me?
Posts: 15,941
Threads: 0
Joined: Jun 2008
Quote:
Originally Posted by Riddick94
edit://
I don't understand it:
pawn Code:
INI_ParseFile( "PlayerFile.ini", "ParsePass", .bExtra = true, .extra = playerid ); new Str[ 129 ], PlayerPass[ 129 ]; GetPVarString( playerid, "pPass", PlayerPass, 129 ); foprmat( Str, 129, "%s", PlayerPass ); SendClientMessage( playerid, -1, Str );
I need to use this in OnPlayerLogin? if yes.. how?
|
Where is this in your new code? This is loading code, not what you just posted - that only opens the file and closes it again instantly.
Posts: 1,767
Threads: 124
Joined: Mar 2010
Can you tell me where i need to put it? in OnDialogResponse when player have a dialog login?
pawn Code:
case DIALOG_LOGOWANIE:
{
if(!response)Kick(playerid);
if(response)
{
INI_ParseFile(PlayerFile(playerid), "GetPlayerPassword");
new PlayerPass[129];
GetPVarString(playerid, "pPass", PlayerPass, 129);
if(!inputtext[0])
{
SendClientMessage(playerid, COLOR_RED, "* You need to insert your password here.");
}else{
OnPlayerLogin(playerid, inputtext);
}
Posts: 1,767
Threads: 124
Joined: Mar 2010
Posts: 15,941
Threads: 0
Joined: Jun 2008
I would place it in OnPlayerLogin where you are checking that the password is correct (actually slightly before there).
Posts: 1,767
Threads: 124
Joined: Mar 2010
So like that, yes?
pawn Code:
stock OnPlayerLogin(playerid, password[])
{
INI_ParseFile(PlayerFile(playerid), "GetPlayerPassword");
new PlayerPass[129];
GetPVarString(playerid, "pPass", PlayerPass, 129);
if(GetPlayerPassword(playerid, PlayerFile(playerid), password))
{
new INI:Account;
Account = INI_Open(PlayerFile(playerid));
INI_Close(Account);
PlayerInfo[playerid][pLogged] = true;
TogglePlayerClock(playerid, true);
SendDeathMessage(INVALID_PLAYER_ID, playerid, ICON_CONNECT);
SendFormattedMessageToAll(COLOR_WHITE, "*** %s [{FF003F}ID{FFFFFF}: {FF003F}%d{FFFFFF}] dołączył do serwera.", PlayerName(playerid), playerid);
SendFormattedMessage(playerid, COLOR_LIMON, "{1BE03F}* Zalogowany jako {EDBC6D}%s {FFFFFF}[{FF003F}ID{FFFFFF}: {FF003F}%d{FFFFFF}]{1BE03F}. Witamy spowrotem na Polskim eXtra Serwerze!", PlayerName(playerid), playerid);
}else{
new string[128];
format(string,sizeof(string),"{9EB8E8}Witamy ponownie {F2EE0C}%s{9EB8E8}. Proszę wpisać poniżej swoje hasło, aby zalogować się i grać:", PlayerName(playerid));
ShowPlayerDialog(playerid, DIALOG_LOGOWANIE, DIALOG_STYLE_INPUT, "Logowanie", string, "Zaloguj", "Wyjdź");
GameTextForPlayer(playerid, " ~n~ ~n~ ~n~ ~n~ ~n~ ~r~Nieprawidlowe haslo!", SECONDS(3), 3);
}
return true;
}
pawn Code:
function GetPlayerPassword(playerid, name[], value[])
{
if(!strcmp(name, "Password"))SetPVarString(playerid, "pPass", value);
return true;
}
pawn Code:
stock PlayerFile(playerid)
{
new string[128];
format(string, sizeof(string),"%s\%s.ini", UserFile, PlayerName(playerid));
return string;
}
Posts: 15,941
Threads: 0
Joined: Jun 2008
Change:
pawn Code:
if(GetPlayerPassword(playerid, PlayerFile(playerid), password))
To:
pawn Code:
if (!strcmp(PlayerPass, password))
Although, where are you hashing the password?
Posts: 1,767
Threads: 124
Joined: Mar 2010
You mean where i'm hashing password?
pawn Code:
stock OnPlayerRegister(playerid, password[])
{
new INI:Account, buf[129];
Account = INI_Open(PlayerFile(playerid));
WP_Hash(buf, sizeof(buf), password);
INI_WriteString(Account, "Password", buf);
INI_WriteInt(Account, "Kasa", 10000);
INI_WriteInt(Account, "FightStyle", FIGHT_STYLE_GRABKICK);
INI_Close(Account);
PlayerInfo[playerid][pLogged] = true;
TogglePlayerClock(playerid, true);
SendDeathMessage(INVALID_PLAYER_ID, playerid, ICON_CONNECT);
SendFormattedMessageToAll(COLOR_WHITE, "*** %s [{FF003F}ID{FFFFFF}: {FF003F}%d{FFFFFF}] dołączył do serwera.", PlayerName(playerid), playerid);
SendClientMessage(playerid, COLOR_LIMON, "* Twoje konto zostało utworzone. Zostałeś automatycznie zalogowany. Witamy na Polskim eXtra Serwerze!");
SendFormattedMessage(playerid, COLOR_LIGHTRED, "* Zapamiętaj swoje hasło: {EDBC6D}-> '%s' <-", password);
return true;
}
edit://
Not working.. need to read hashed password, yes? but how to read hashed? i know only how to write.. : d
Posts: 15,941
Threads: 0
Joined: Jun 2008
When you read the value you get the hashed password. You then need to also hash the text the user types when they log in and compare the two hashed versions.
Posts: 1,767
Threads: 124
Joined: Mar 2010
Okey, how to do that? sorry i don't know really how to make that. Can you show the code and describe it? please..