login script
#1

This is a part of an include I made
pawn Код:
new PlayerName[MAX_PLAYER_NAME], Password[MAX_PASSWORD];

INI:playerlist[](playerid, name[], value[])
{
    INI_String(PlayerName, Password, sizeof(Password));
    return 1;
}

stock CheckPlayer(playerid){
    GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
    INI_Load("playerlist.ini", true, playerid);     // if set to true, playerid will be passed over to INI:playerlist[...
    if(strlen(Password) == 0){
        ShowPlayerDialog(playerid, 30, 1, "Register", "To register you must first give in the first name of your character.", "OK", "");
        return 1;
    }
    else{
        ShowPlayerDialog(playerid, 33, 1, "Login", "Please give in your password.", "OK", "");
        return 1;
    }
}
So when one decides to register, this playlerist.ini might appear
pawn Код:
Har_Levis = mypass
however, when you try to log in with sa-mp username Har_Levis the script again asks you to register. But then, when I restart the server you are able to log in with EVERY sa-mp username using mypass :S

I just want to make a login script you know, in which you can register and login with your own username and password.
Reply
#2

try to use my MubAdmin login.. ( It has fixed with failed entering password and the dialog show to login again )

pawn Код:
public LoginParseP ( playerid , name [ ] , value [ ] ) {
    if ( !strcmp ( name , "Password" ) )    SetPVarString ( playerid , "Password" , value ) ;
    return 1 ;
}

public OnDialogResponse ( playerid , dialogid , response , listitem , inputtext [ ] ) {
    if ( dialogid == iMenu2 ) { //change this
        if ( response ) {
       
            new
                iPath [ MAX_STRINGS ] ;
            format ( iPath , sizeof ( iPath ) , "MubAdmin/Users/%s.sav" , iName ( playerid ) ) ; // change this

            new
                iPass [ 20 + 1 ] ;
               
            INI_ParseFile ( iPath , "LoginParseP" , false , true , playerid ) ;
            GetPVarString ( playerid , "Password" , iPass , sizeof ( iPass ) ) ;
           
            if ( !strcmp ( inputtext , iPass , false ) ) {
           
                format ( iPath , sizeof ( iPath ) , "MubAdmin/Users/%s.sav" , iName ( playerid ) ) ; // this too
                INI_ParseFile ( iPath , "LoginParseF" , false , true , playerid , true , false ) ;

                GivePlayerMoney ( playerid , Account [ playerid ] [ Money ] ) ;
                SetPlayerScore ( playerid , Account [ playerid ] [ Score ] ) ;
               
                if ( Account [ playerid ] [ Level ] == 0 ) {
                    new
                        str [ MAX_STRINGS ] ;
                    format ( str , sizeof ( str ) , "Welcome back, you have logged as 'Normal Player', %s" , iName ( playerid ) ) ;
                    SendClientMessage ( playerid , COLOR_LIGHTGREEN , str ) ;
                }
                else if ( Account [ playerid ] [ Level ] == 1 ) {
                    new
                        str [ MAX_STRINGS ] ;
                    format ( str , sizeof ( str ) , "Welcome back, you have logged as 'Moderator', %s" , iName ( playerid ) ) ;
                    SendClientMessage ( playerid , COLOR_LIGHTGREEN , str ) ;
                }
                else if ( Account [ playerid ] [ Level ] == 2 ) {
                    new
                        str [ MAX_STRINGS ] ;
                    format ( str , sizeof ( str ) , "Welcome back, you have logged as 'Administrator', %s" , iName ( playerid ) ) ;
                    SendClientMessage ( playerid , COLOR_LIGHTGREEN , str ) ;
                }
                else if ( Account [ playerid ] [ Level ] == 3 ) {
                    new
                        str [ MAX_STRINGS ] ;
                    format ( str , sizeof ( str ) , "Welcome back, you have logged as 'Owner', %s" , iName ( playerid ) ) ;
                    SendClientMessage ( playerid , COLOR_LIGHTGREEN , str ) ;
                }
               
                PlayerPlaySound( playerid, 1057, 0.0, 0.0, 0.0 ) ;
               
                Account [ playerid ] [ Regged ] = 1 ;
                Account [ playerid ] [ Logged ] = 1 ;
            }
            else {
                ShowPlayerDialog ( playerid , iMenu2 , DIALOG_STYLE_INPUT , ""#YELLOW"Login Menu" , ""#RED"ERROR: "#LIGHTBLUE"Wrong password" , "Submit" , "Exit" ) ;
            }
        }
        else {
            Kick ( playerid ) ;
        }
    }
    return 1 ;
}
EDIT: maybe i post off - topic lol
Reply
#3

That would be an option but I want to know what is causing the problem in my script.

But thanks anyaway
Reply
#4

refresh
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)