[HELP]Whirlpool&Y_ini!!!
#4

First of all use enums for this.
Replace these
pawn Код:
new
   Score[MAX_PLAYERS],
   Money[MAX_PLAYERS],
   Admin[MAX_PLAYERS],
   hPass[129];
To
pawn Код:
enum uData
{
   Score,
   Money,
   Admin,
   hPass[ 129 ]
}
new
    UserData[ MAX_PLAYERS ][ uData ];
Also, replace
pawn Код:
stock LoadPlayerAccount_data(playerid,name[],value[])
{
     INI_String("Password",hPass,129);
     INI_Int("Money",Money[playerid]);
     INI_Int("Score",Score[playerid]);
     INI_Int("Adminlevel",Admin[playerid]);
     return 1;
}
To
pawn Код:
forward LoadPlayerAccount_data( playerid, name[ ], value[ ] );
public LoadPlayerAccount_data( playerid, name[ ], value[ ] )
{
     INI_String( "Password", UserData[ playerid ][ hPass ], 129 ) ;
     INI_Int( "Money", UserData[ playerid ][ Money ] );
     INI_Int( "Score", UserData[ playerid ][ Score ] );
     INI_Int( "Adminlevel", UserData[ playerid ][ Admin ] );
     return 1;
}
And this
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid==1) {
        if(response==1) {
            if(!strlen(inputtext)) {
                PlayerPlaySound(playerid,1055,0,0,0);
                SendClientMessage(playerid,COLOR_RED,"Invalid password,please try again");
                ShowPlayerDialog(playerid,DIALOG_STYLE_INPUT,1,"Register","Please type in a password to register: ","Register","Cancel");
            }
            else {
                new pName[24];
                GetPlayerName(playerid,pName,sizeof(pName));
                LoadRegisteredAccount(playerid);
                SendClientMessage(playerid,COLOR_GREEN,"Succesfully registered!!!");
                PlayerPlaySound(playerid,1057,0,0,0);
                SendClientMessage(playerid,COLOR_PURPLE,"This is San Fierro RolePlay");
                SendClientMessage(playerid,COLOR_YELLOW,"Type /new for more infos about the server");
                SendClientMessage(playerid,COLOR_YELLOW,"Type /rules for server rules");
                LoadRegisteredAccount(playerid);
                new INI:PFile = INI_Open(Accounts(playerid));
                INI_SetTag(PFile,"PlayerInfo");
                WP_Hash(hPass,129,inputtext);
                INI_WriteString(PFile,"Password",hPass);
                INI_WriteInt(PFile,"Score",GetPlayerScore(playerid));
                INI_WriteInt(PFile,"Money",GetPlayerMoney(playerid));
                INI_WriteInt(PFile,"Adminlevel",0);
                INI_Close(PFile);
            }
        }
        if(response==0) {
            SendClientMessage(playerid,COLOR_GREEN,"I hope you will be back soon");
            Kick(playerid);
        }
    }
    // Rest
To
pawn Код:
public OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] )
{
    if( dialogid == 1 ) {
        if( response == 1 ) {
            if( !strlen( inputtext ) ) {
                PlayerPlaySound (playerid, 1055, 0, 0, 0 );
                SendClientMessage( playerid, COLOR_RED, "Invalid password,please try again" );
                ShowPlayerDialog( playerid, DIALOG_STYLE_INPUT, 1, "Register", "Please type in a password to register: ", "Register", "Cancel" );
            }
            else {
                new
                    hashed_password[ 129 ], pName[ 24 ];

                WP_Hash( hashed_password, sizeof( hashed_password ), inputtext );
                GetPlayerName( playerid, pName, sizeof( pName ) );
                LoadRegisteredAccount( playerid );
                SendClientMessage( playerid, COLOR_GREEN, "Succesfully registered!!!" );
                PlayerPlaySound( playerid, 1057, 0, 0, 0 );
                SendClientMessage( playerid, COLOR_PURPLE, "This is San Fierro RolePlay" );
                SendClientMessage( playerid, COLOR_YELLOW, "Type /new for more infos about the server" );
                SendClientMessage( playerid, COLOR_YELLOW, "Type /rules for server rules" );
                LoadRegisteredAccount( playerid );
                new INI:PFile = INI_Open( Accounts( playerid ) );
                INI_SetTag( PFile, "PlayerInfo" );
                INI_WriteString( PFile, "Password", hashed_password );
                INI_WriteInt( PFile, "Score", GetPlayerScore( playerid ) );
                INI_WriteInt( PFile, "Money", GetPlayerMoney( playerid ) );
                INI_WriteInt( PFile, "Adminlevel", 0 );
                INI_Close( PFile );
            }
        }
        if( response == 0 ) {
            SendClientMessage( playerid, COLOR_GREEN, "I hope you will be back soon" );
            Kick( playerid );
        }
    }
    // Rest
Last,
pawn Код:
// On Login
new
    hashed_password[ 129 ];

WP_Hash( hashed_password, sizeof( hashed_password ), inputtext );
if( !strcmp( hashed_password, UserData[ playerid ][ hPass ] ) )
{
    INI_ParseFile( Accounts( playerid ), "LoadPlayerAccount_%s", .bExtra = true, .extra = playerid );
    // Rest of settings.
else
{
    // Kick...
}
In conclusion, if you are using the last version of whirlpool, you should have this at the top
pawn Код:
#include < a_samp >

#define MAX_INI_ENTRY_TEXT 130
#include < YSI\y_ini >
// Rest
Reply


Messages In This Thread
[HELP]Whirlpool&Y_ini!!! - by Cjgogo - 03.02.2012, 12:57
Re: [HELP]Whirlpool&Y_ini!!! - by Konstantinos - 03.02.2012, 13:00
Re: [HELP]Whirlpool&Y_ini!!! - by Cjgogo - 03.02.2012, 14:37
Re: [HELP]Whirlpool&Y_ini!!! - by Konstantinos - 03.02.2012, 15:01
Re: [HELP]Whirlpool&Y_ini!!! - by Cjgogo - 04.02.2012, 12:58
Re: [HELP]Whirlpool&Y_ini!!! - by Cjgogo - 04.02.2012, 15:49
Re: [HELP]Whirlpool&Y_ini!!! - by Konstantinos - 04.02.2012, 15:56
Re: [HELP]Whirlpool&Y_ini!!! - by Cjgogo - 04.02.2012, 16:10
Re: [HELP]Whirlpool&Y_ini!!! - by Konstantinos - 04.02.2012, 16:16

Forum Jump:


Users browsing this thread: 1 Guest(s)