SA-MP Forums

SA-MP Forums (https://forum.sa-mp.com/index.php)
-   Help Archive (https://forum.sa-mp.com/forumdisplay.php?f=89)
-   -   Y_Ini - Let's do it! (https://forum.sa-mp.com/showthread.php?t=237420)

Riddick94 09/03/2011 05:48 PM

Y_Ini - Let's do it!
 
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 : )

Mean 09/03/2011 06:08 PM

Re: Y_Ini - Let's do it!
 
To get the pass from file:
pawn Code:
new PasswordVar[ MAX_PLAYERS ];
forward GetPassword( playerid, name[ ], value[ ] );
public GetPassword( playerid, name[ ], value[ ] )
{
    if( !strcmp( name, "Password" ) )
        PasswordVar[ playerid ] = value;
    return 1;
}

pawn Code:
// To load the password
new file[ 128 ], name[ 24 ]; GetPlayerName( playerid, name, 24 );
format( file, sizeof file, "%s.ini", name );
INI_ParseFile( file, "GetPassword", false, true, playerid, true, false );
new string[ 128 ]; format( string, sizeof string, "Your password is %s", PasswordVar[ playerid ] );
SendClientMessage( playerid, 0xAAAAAA, string );
Should work.

Riddick94 09/03/2011 06:14 PM

Re: Y_Ini - Let's do it!
 
GetPassword:
Code:

error 006: must be assigned to an array
-cut-

Riddick94 09/03/2011 06:21 PM

Re: Y_Ini - Let's do it!
 
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 (c) 1997-2006, ITB CompuPhase


1 Error.

Why? : )

Mean 09/03/2011 06:23 PM

Re: Y_Ini - Let's do it!
 
Try:
pawn Code:
if ( !strcmp( name, "Password" ) )
        SetPVarString( playerid, "pPass", value );
pawn Code:
new file[ 128 ], name[ 24 ]; GetPlayerName( playerid, name, 24 );
format( file, sizeof file, "%s.ini", name );
new pass[ 256 ];
GetPVarString( playerid, "pPass", pass, sizeof pass );
INI_ParseFile( file, "GetPassword", false, true, playerid, true, false );
new string[ 128 ]; format( string, sizeof string, "Your password is %s", pass );
SendClientMessage( playerid, 0xAAAAAA, string );
And delete the
pawn Code:
new PasswordVar[ MAX_PLAYERS ];
Hope it works.

Fj0rtizFredde 09/03/2011 06:25 PM

Re: Y_Ini - Let's do it!
 
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);

Riddick94 09/03/2011 06:34 PM

Re: Y_Ini - Let's do it!
 
Quote:

Originally Posted by Fj0rtizFredde (Post 1110100)
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);

http://img814.imageshack.us/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?

Riddick94 09/03/2011 06:58 PM

Re: Y_Ini - Let's do it!
 
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?

Zh3r0 09/03/2011 07:01 PM

Re: Y_Ini - Let's do it!
 
Quote:

Originally Posted by Mean (Post 1110075)
To get the pass from file:
pawn Code:
new PasswordVar[ MAX_PLAYERS ];
forward GetPassword( playerid, name[ ], value[ ] );
public GetPassword( playerid, name[ ], value[ ] )
{
    if( !strcmp( name, "Password" ) )
        PasswordVar[ playerid ] = value;
    return 1;
}

pawn Code:
// To load the password
new file[ 128 ], name[ 24 ]; GetPlayerName( playerid, name, 24 );
format( file, sizeof file, "%s.ini", name );
INI_ParseFile( file, "GetPassword", false, true, playerid, true, false );
new string[ 128 ]; format( string, sizeof string, "Your password is %s", PasswordVar[ playerid ] );
SendClientMessage( playerid, 0xAAAAAA, string );
Should work.

You are wrong! It must be a string, password aren't made just out of a large number( Depends if you want or not ).

Riddick94 09/03/2011 07:02 PM

Re: Y_Ini - Let's do it!
 
If he was wrong you can help me?


All times are GMT. The time now is 05:48 PM.

Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.