SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 01/05/2014, 03:08 PM   #1
Affan
Huge Clucker
 
Affan's Avatar
 
Join Date: Dec 2012
Posts: 390
Reputation: 28
Default Can't load the password

pawn Code:
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
    //new strLoc[8];
    INI_Int("Password",PlayerInfo[playerid][pPass]);
    INI_Int("Cash",PlayerInfo[playerid][pCash]);
    INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
    INI_Int("Kills",PlayerInfo[playerid][pKills]);
    INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
    INI_Int("Scores",PlayerInfo[playerid][pScores]);
    INI_Int("IP",PlayerInfo[playerid][IP]);
    INI_Int( "weaponSlot0", weapons[playerid][0][0]);
    INI_Int( "weaponSlot0Ammo", weapons[playerid][0][1]);
    INI_Int( "weaponSlot1", weapons[playerid][1][0]);
    INI_Int( "weaponSlot1Ammo", weapons[playerid][1][1]);
    INI_Int( "weaponSlot2", weapons[playerid][2][0]);
    INI_Int( "weaponSlot2Ammo", weapons[playerid][2][1]);
    INI_Int( "weaponSlot3", weapons[playerid][3][0]);
    INI_Int( "weaponSlot3Ammo", weapons[playerid][3][1]);
    INI_Int( "weaponSlot4", weapons[playerid][4][0]);
    INI_Int( "weaponSlot4Ammo", weapons[playerid][4][1]);
    INI_Int( "weaponSlot5", weapons[playerid][5][0]);
    INI_Int( "weaponSlot5Ammo", weapons[playerid][5][1]);
    INI_Int( "weaponSlot6", weapons[playerid][6][0]);
    INI_Int( "weaponSlot6Ammo", weapons[playerid][6][1]);
    INI_Int( "weaponSlot7", weapons[playerid][7][0]);
    INI_Int( "weaponSlot7Ammo", weapons[playerid][7][1]);
    INI_Int( "weaponSlot8", weapons[playerid][8][0]);
    INI_Int( "weaponSlot8Ammo", weapons[playerid][8][1]);
    INI_Int( "weaponSlot9", weapons[playerid][9][0]);
    INI_Int( "weaponSlot8Ammo", weapons[playerid][9][1]);
    INI_Int( "weaponSlot10", weapons[playerid][10][0]);
    INI_Int( "weaponSlot10Ammo", weapons[playerid][10][1]);
    INI_Int( "weaponSlot11", weapons[playerid][11][0]);
    INI_Int( "weaponSlot11Ammo", weapons[playerid][11][1]);
    INI_Int( "weaponSlot12", weapons[playerid][12][0]);
    INI_Int( "weaponSlot12Ammo", weapons[playerid][12][1]);
    return 1;
}

OnPlayerConnect
pawn Code:
if(fexist(UserPath(playerid)))
    {
        INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""CLW"Login",""CLW"Type your password below to login.","Login","Quit");
    }
    else
    {
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""CLW"Registering...",""CLW"Type your password below to register a new account.","Register","Quit");
    }

OnDialog
pawn Code:
switch( dialogid )
    {
        case DIALOG_REGISTER:
        {
            if (!response) return Kick(playerid);
            if(response)
            {
                new ip;
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""CLW"Registering...",""CLR"You have entered an invalid password.\n"CLW"Type your password below to register a new account.","Register","Quit");
                ip = GetPlayerIp(playerid, PlayerInfo[playerid][IP], 16);
                new INI:File = INI_Open(UserPath(playerid));
                INI_SetTag(File,"PlayerData");
                INI_WriteInt(File,"Password",udb_hash(inputtext));
                INI_WriteInt(File,"Cash",0);
                INI_WriteInt(File,"Admin",0);
                INI_WriteInt(File,"Kills",0);
                INI_WriteInt(File,"Deaths",0);
                INI_WriteInt(File,"Scores",0);
                INI_WriteInt(File,"IP",ip);
                INI_WriteInt(File, "weaponSlot0", weapons[playerid][0][0]);
                INI_WriteInt(File, "weaponSlot0Ammo", weapons[playerid][0][1]);
                INI_WriteInt(File, "weaponSlot1", weapons[playerid][1][0]);
                INI_WriteInt(File, "weaponSlot1Ammo", weapons[playerid][1][1]);
                INI_WriteInt(File, "weaponSlot2", weapons[playerid][2][0]);
                INI_WriteInt(File, "weaponSlot2Ammo", weapons[playerid][2][1]);
                INI_WriteInt(File, "weaponSlot3", weapons[playerid][3][0]);
                INI_WriteInt(File, "weaponSlot3Ammo", weapons[playerid][3][1]);
                INI_WriteInt(File, "weaponSlot4", weapons[playerid][4][0]);
                INI_WriteInt(File, "weaponSlot4Ammo", weapons[playerid][4][1]);
                INI_WriteInt(File, "weaponSlot5", weapons[playerid][5][0]);
                INI_WriteInt(File, "weaponSlot5Ammo", weapons[playerid][5][1]);
                INI_WriteInt(File, "weaponSlot6", weapons[playerid][6][0]);
                INI_WriteInt(File, "weaponSlot6Ammo", weapons[playerid][6][1]);
                INI_WriteInt(File, "weaponSlot7", weapons[playerid][7][0]);
                INI_WriteInt(File, "weaponSlot7Ammo", weapons[playerid][7][1]);
                INI_WriteInt(File, "weaponSlot8", weapons[playerid][8][0]);
                INI_WriteInt(File, "weaponSlot8Ammo", weapons[playerid][8][1]);
                INI_WriteInt(File, "weaponSlot9", weapons[playerid][9][0]);
                INI_WriteInt(File, "weaponSlot8Ammo", weapons[playerid][9][1]);
                INI_WriteInt(File, "weaponSlot10", weapons[playerid][10][0]);
                INI_WriteInt(File, "weaponSlot10Ammo", weapons[playerid][10][1]);
                INI_WriteInt(File, "weaponSlot11", weapons[playerid][11][0]);
                INI_WriteInt(File, "weaponSlot11Ammo", weapons[playerid][11][1]);
                INI_WriteInt(File, "weaponSlot12", weapons[playerid][12][0]);
                INI_WriteInt(File, "weaponSlot12Ammo", weapons[playerid][12][1]);
                INI_Close(File);
                SpawnPlayer(playerid);
            }
        }

        case DIALOG_LOGIN:
        {
            if ( !response ) return Kick ( playerid );
            if( response )
            {
                if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
                {
                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                    GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
                    ShowPlayerDialog(playerid, DIALOG_SUCCESS, DIALOG_STYLE_MSGBOX,""CLW"Success!",""CLG"You have successfully logged in!","Ok","");
                }
                else
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""CLW"Login",""CLR"You have entered an incorrect password.\n"CLW"Type your password below to login.","Login","Quit");
                }
                return 1;
            }
        }

pawn Code:
forward SavePlayer(playerid);
public SavePlayer(playerid)
{
    //new strLoc[8];
    new INI:File = INI_Open(UserPath(playerid));
    for (new i = 0; i < 13; i++) GetPlayerWeaponData(playerid, i, weapons[playerid][i][0], weapons[playerid][i][1]);
    INI_SetTag(File,"PlayerData");
    INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
    INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
    INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
    INI_WriteString(File,"IP", PlayerInfo[playerid][IP]);
    INI_WriteInt(File,"Scores",PlayerInfo[playerid][pScores]);
    INI_WriteInt(File, "weaponSlot0", weapons[playerid][0][0]);
    INI_WriteInt(File, "weaponSlot0Ammo", weapons[playerid][0][1]);
    INI_WriteInt(File, "weaponSlot1", weapons[playerid][1][0]);
    INI_WriteInt(File, "weaponSlot1Ammo", weapons[playerid][1][1]);
    INI_WriteInt(File, "weaponSlot2", weapons[playerid][2][0]);
    INI_WriteInt(File, "weaponSlot2Ammo", weapons[playerid][2][1]);
    INI_WriteInt(File, "weaponSlot3", weapons[playerid][3][0]);
    INI_WriteInt(File, "weaponSlot3Ammo", weapons[playerid][3][1]);
    INI_WriteInt(File, "weaponSlot4", weapons[playerid][4][0]);
    INI_WriteInt(File, "weaponSlot4Ammo", weapons[playerid][4][1]);
    INI_WriteInt(File, "weaponSlot5", weapons[playerid][5][0]);
    INI_WriteInt(File, "weaponSlot5Ammo", weapons[playerid][5][1]);
    INI_WriteInt(File, "weaponSlot6", weapons[playerid][6][0]);
    INI_WriteInt(File, "weaponSlot6Ammo", weapons[playerid][6][1]);
    INI_WriteInt(File, "weaponSlot7", weapons[playerid][7][0]);
    INI_WriteInt(File, "weaponSlot7Ammo", weapons[playerid][7][1]);
    INI_WriteInt(File, "weaponSlot8", weapons[playerid][8][0]);
    INI_WriteInt(File, "weaponSlot8Ammo", weapons[playerid][8][1]);
    INI_WriteInt(File, "weaponSlot9", weapons[playerid][9][0]);
    INI_WriteInt(File, "weaponSlot8Ammo", weapons[playerid][9][1]);
    INI_WriteInt(File, "weaponSlot10", weapons[playerid][10][0]);
    INI_WriteInt(File, "weaponSlot10Ammo", weapons[playerid][10][1]);
    INI_WriteInt(File, "weaponSlot11", weapons[playerid][11][0]);
    INI_WriteInt(File, "weaponSlot11Ammo", weapons[playerid][11][1]);
    INI_WriteInt(File, "weaponSlot12", weapons[playerid][12][0]);
    INI_WriteInt(File, "weaponSlot12Ammo", weapons[playerid][12][1]);
    INI_Close(File);
}

OnPlayerDisconnect
pawn Code:
SavePlayer(playerid);

When I register a new account then logout, and when i login back, it says wrong password, any fix? I'm using Y_INI.
Would be nice if someone could tell me how to change udb_hash to whirlpool
Affan is offline   Reply With Quote
Old 02/05/2014, 10:49 AM   #2
biker122
Gangsta
 
Join Date: Feb 2014
Posts: 766
Reputation: 59
Default Re: Can't load the password

Put this under your includes - Above public OnGameModeInit or OnFilterScriptInit
pawn Code:
native WP_Hash(buffer[], len, const str[]);

Edit your enum pInfo
pawn Code:
pPass[129]

public LoadUserdata:
pawn Code:
INI_String("Password",PlayerInfo[playerid][pPass],129);

Your dialogs
pawn Code:
case DIALOG_REGISTER:
        {
            if (!response) return Kick(playerid);
            if(response)
            {
                new ip,hashpass[129]
                WP_Hash(hashpass,sizeof(hashpass),inputtext);;
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""CLW"Registering...",""CLR"You have entered an invalid password.\n"CLW"Type your password below to register a new account.","Register","Quit");
                ip = GetPlayerIp(playerid, PlayerInfo[playerid][IP], 16);
                new INI:File = INI_Open(UserPath(playerid));
                INI_SetTag(File,"PlayerData");
                INI_WriteString(File,"Password",hashpass);
                INI_WriteInt(File,"Cash",0);
                INI_WriteInt(File,"Admin",0);
                INI_WriteInt(File,"Kills",0);
                INI_WriteInt(File,"Deaths",0);
                INI_WriteInt(File,"Scores",0);
                INI_WriteInt(File,"IP",ip);
                INI_WriteInt(File, "weaponSlot0", weapons[playerid][0][0]);
                INI_WriteInt(File, "weaponSlot0Ammo", weapons[playerid][0][1]);
                INI_WriteInt(File, "weaponSlot1", weapons[playerid][1][0]);
                INI_WriteInt(File, "weaponSlot1Ammo", weapons[playerid][1][1]);
                INI_WriteInt(File, "weaponSlot2", weapons[playerid][2][0]);
                INI_WriteInt(File, "weaponSlot2Ammo", weapons[playerid][2][1]);
                INI_WriteInt(File, "weaponSlot3", weapons[playerid][3][0]);
                INI_WriteInt(File, "weaponSlot3Ammo", weapons[playerid][3][1]);
                INI_WriteInt(File, "weaponSlot4", weapons[playerid][4][0]);
                INI_WriteInt(File, "weaponSlot4Ammo", weapons[playerid][4][1]);
                INI_WriteInt(File, "weaponSlot5", weapons[playerid][5][0]);
                INI_WriteInt(File, "weaponSlot5Ammo", weapons[playerid][5][1]);
                INI_WriteInt(File, "weaponSlot6", weapons[playerid][6][0]);
                INI_WriteInt(File, "weaponSlot6Ammo", weapons[playerid][6][1]);
                INI_WriteInt(File, "weaponSlot7", weapons[playerid][7][0]);
                INI_WriteInt(File, "weaponSlot7Ammo", weapons[playerid][7][1]);
                INI_WriteInt(File, "weaponSlot8", weapons[playerid][8][0]);
                INI_WriteInt(File, "weaponSlot8Ammo", weapons[playerid][8][1]);
                INI_WriteInt(File, "weaponSlot9", weapons[playerid][9][0]);
                INI_WriteInt(File, "weaponSlot8Ammo", weapons[playerid][9][1]);
                INI_WriteInt(File, "weaponSlot10", weapons[playerid][10][0]);
                INI_WriteInt(File, "weaponSlot10Ammo", weapons[playerid][10][1]);
                INI_WriteInt(File, "weaponSlot11", weapons[playerid][11][0]);
                INI_WriteInt(File, "weaponSlot11Ammo", weapons[playerid][11][1]);
                INI_WriteInt(File, "weaponSlot12", weapons[playerid][12][0]);
                INI_WriteInt(File, "weaponSlot12Ammo", weapons[playerid][12][1]);
                INI_Close(File);
                SpawnPlayer(playerid);
            }
        }

        case DIALOG_LOGIN:
        {
            if ( !response ) return Kick ( playerid );
            if( response )
            {
        new hashpass[129];
            WP_Hash(hashpass,sizeof(hashpass),inputtext);
                if(!strcmp(hashpass, PlayerInfo[playerid][pPass], false))
                {
                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                    GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
                    ShowPlayerDialog(playerid, DIALOG_SUCCESS, DIALOG_STYLE_MSGBOX,""CLW"Success!",""CLG"You have successfully logged in!","Ok","");
                }
                else
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""CLW"Login",""CLR"You have entered an incorrect password.\n"CLW"Type your password below to login.","Login","Quit");
                }
                return 1;
            }
        }
When running the server, Include Whirlpool plugin in your server.cfg, otherwise it won't work.
Hope it works,
Good luck!
__________________
k
biker122 is offline   Reply With Quote
Old 02/05/2014, 11:04 AM   #3
XK
Huge Clucker
 
XK's Avatar
 
Join Date: Mar 2014
Location: A Rare Place
Posts: 242
Reputation: 30
Default Re: Can't load the password

Edit: biker answered before me,by the way mine was better.. if you need help tell me
__________________
By XK:
And are we meant to guess your Request?

XK is offline   Reply With Quote
Reply

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
Password! help Jermi Scripting Help 6 22/01/2013 07:23 PM
y_ini. Cannot load Password. Konstantinos Scripting Help 2 16/01/2012 02:52 PM
Can't play it says that i need to put a password but i don't know any password ? Lol man Client Support 1 03/06/2010 02:04 PM
Load playerid to load for all ArTisT Help Archive 0 26/05/2010 08:45 PM
Error: Your password must be changed from the default password, please change it Zurrek Server Support 4 03/05/2009 06:44 AM


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


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