#1

Hello, i'm a noob at samp scripting,
and i'm trying to make a login/register dialog using Y_INI
(IT'S NOT DONE YET)
now.. i can write to the INI file.. so register works...
Can anyone help me with these things:
- Make the login work (reading, because when i do what the Y_ini thread says, it doesn't work)
- How to hash the password?
Thanks!


Here is the code:
Code:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	new pname[128], account[128];
	GetPlayerName(playerid, pname, sizeof(pname));
	format(account, sizeof(account), "Accounts/%s.ini", pname);
	if(dialogid == DIALOG_REGISTER)
	{
	if(!response) return Kick(playerid);
        if(response)
        {
            	if(strlen(inputtext) == 0)
            	{
            	ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "SF:RP - Register", "You didn't enter a password, please enter a password!", "Register", "Leave");
				return 0;
				}
			if(!fexist(account))
			{
			new
    		INI:ini = INI_Open(account);
    		INI_WriteString(ini, "username", pname);
			INI_WriteString(ini, "password", inputtext);
			INI_Close(ini);
			GivePlayerMoney(playerid, 1000);
			
			}
		
		}

	
	}
	if(dialogid == DIALOG_LOGIN)
	{
		if(!response) return Kick(playerid);
		if(response)
			{
				if(strlen(inputtext) == 0)
					{
						ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "SF:RP - Login", "You didn't enter a password, please enter a password!", "Login", "Leave");
 						return 0;
					}
				if(fexist(account))
			 		{
						//login
			 		}
			}
	}

	return 1;
}
And if there is any one who wants to add me on msn, so who can help me when i have a question..
send me a PM
Reply
#2

Use dini in stead, much easier.
Reply
#3

https://sampforum.blast.hk/showthread.php?tid=210277
https://sampforum.blast.hk/showthread.php?tid=65290
Reply
#4

Example of reading:
pawn Code:
forward LoadMyStats( playerid, name[ ], value[ ] );
public LoadMyStats( playerid, name[ ], value[ ] )
{
    if( !strcmp( name, "Score", false ) )
        SetPlayerScore( playerid, strval( value ) );
    return true;
}
To load the score from file:
pawn Code:
INI_ParseFile( account, "LoadMyStats", false, true, playerid, true, false );
Simplest way I can think of.
Reply
#5

I use y_ini, it's simply class.
Well worth learning.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)