SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 09/03/2011, 05:48 PM   #1
Riddick94
Banned
 
Join Date: Mar 2010
Location: Poland
Posts: 1,767
Reputation: 223
Default 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 : )
Riddick94 is offline  
Old 09/03/2011, 06:08 PM   #2
Mean
High-roller
 
Join Date: Jul 2010
Location: 14th annual lemon party
Posts: 2,727
Reputation: 229
Default 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.
__________________
I'm pretty much the creator of the PUB: macro used in many scripts today, therefore I'm a legitimate genius.

Ground breaking stuff
Quote:
Originally Posted by ******
I've met Mean on a few occasions in real life, a true genius and a 400 pound all-muscle gorilla alpha male. He has had a great influence on my life.
Quote:
Originally Posted by Kalcor
I don't know where I'd be today without Mean. He has helped me through some tough times in my life. He always brings a smile to my face. Such a positive lad!
Mean is offline  
Old 09/03/2011, 07:01 PM   #3
Zh3r0
High-roller
 
Join Date: Mar 2008
Posts: 4,513
Reputation: 398
Default Re: Y_Ini - Let's do it!

Quote:
Originally Posted by Mean View Post
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 ).
__________________
Zh3r0 is offline  
Old 09/03/2011, 06:14 PM   #4
Riddick94
Banned
 
Join Date: Mar 2010
Location: Poland
Posts: 1,767
Reputation: 223
Default Re: Y_Ini - Let's do it!

GetPassword:
Code:
error 006: must be assigned to an array
-cut-
Riddick94 is offline  
Old 09/03/2011, 06:21 PM   #5
Riddick94
Banned
 
Join Date: Mar 2010
Location: Poland
Posts: 1,767
Reputation: 223
Default 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? : )
Riddick94 is offline  
Old 09/03/2011, 06:23 PM   #6
Mean
High-roller
 
Join Date: Jul 2010
Location: 14th annual lemon party
Posts: 2,727
Reputation: 229
Default 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.
__________________
I'm pretty much the creator of the PUB: macro used in many scripts today, therefore I'm a legitimate genius.

Ground breaking stuff
Quote:
Originally Posted by ******
I've met Mean on a few occasions in real life, a true genius and a 400 pound all-muscle gorilla alpha male. He has had a great influence on my life.
Quote:
Originally Posted by Kalcor
I don't know where I'd be today without Mean. He has helped me through some tough times in my life. He always brings a smile to my face. Such a positive lad!
Mean is offline  
Old 09/03/2011, 06:25 PM   #7
Fj0rtizFredde
Gangsta
 
Fj0rtizFredde's Avatar
 
Join Date: Jun 2008
Location: Sweden
Posts: 888
Reputation: 120
Default 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);
__________________
Latest crap I've made:
[Include]CleverBot - Never Be Alone Again!
Fj0rtizFredde is offline  
Old 09/03/2011, 06:34 PM   #8
Riddick94
Banned
 
Join Date: Mar 2010
Location: Poland
Posts: 1,767
Reputation: 223
Default Re: Y_Ini - Let's do it!

Quote:
Originally Posted by Fj0rtizFredde View Post
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 is offline  
Old 09/03/2011, 06:58 PM   #9
Riddick94
Banned
 
Join Date: Mar 2010
Location: Poland
Posts: 1,767
Reputation: 223
Default 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?
Riddick94 is offline  
Old 09/03/2011, 07:02 PM   #10
Riddick94
Banned
 
Join Date: Mar 2010
Location: Poland
Posts: 1,767
Reputation: 223
Default Re: Y_Ini - Let's do it!

If he was wrong you can help me?
Riddick94 is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Y_ini Stefans94 Help Archive 4 07/03/2011 07:57 PM
y_ini Help Linus- Help Archive 6 22/01/2011 01:09 PM
Y_INI [HELP] park4bmx Help Archive 14 15/01/2011 03:18 PM
Y_ini help. Haydz Help Archive 0 12/01/2011 11:35 AM


All times are GMT. The time now is 02:15 PM.


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