Register Bug
#1

When a player enters the server, even if he doesn't type a password and type register it still saves him a INI_FILE

Im using Y_INI
Reply
#2

Quote:
Originally Posted by X|Dragon|X
Посмотреть сообщение
When a player enters the server, even if he doesn't type a password and type register it still saves him a INI_FILE

Im using Y_INI
Why couldn't you show the code along?
Reply
#3

Wrong position of yini save
Reply
#4

pawn Код:
if(dialogid == DIALOG_REGISTER_1) //If dialog id is a register dialog
    {//then
        if(!response) return Kick(playerid); //If they clicked the second button "Quit", we will kick them.
        if(response) //if they clicked the first button "Register"
        {//then
            if(!strlen(inputtext)) //If they didn't enter any password
            {// then we will tell to them to enter the password to register
                ShowPlayerDialog(playerid,DIALOG_REGISTER_1,DIALOG_STYLE_INPUT,"Register","Welcome! This account is not registered.\nEnter your own password to create a new account.\nPlease enter the password!","Register","Quit");
                return 1;
            }
            //If they have entered a correct password for his/her account...
            new hashpass[129]; //Now we will create a new variable to hash his/her password
            WP_Hash(hashpass,sizeof(hashpass),inputtext);//We will use whirlpool to hash their inputted text
            new INI:file = INI_Open(Path(playerid)); // we will open a new file for them to save their account inside of Scriptfiles/Users folder
            INI_SetTag(file,"Player's Data");//We will set a tag inside of user's account called "Player's Data"
            INI_WriteString(file,"Password",hashpass);//This will write a hashed password into user's account
            INI_WriteInt(file,"Admin",0); //Write an integer inside of user's account called "AdminLevel". We will set his level to 0 after he registered.
            INI_WriteInt(file,"Money",5000);//Write an integer inside of user's account called "Money". We will set their money to 0 after he registered
            INI_WriteInt(file,"Level",1);
            INI_WriteInt(file,"LastX",0); // It doesn't matter they are Int here because we change them to Float later.
            INI_WriteInt(file,"LastY",0);// It doesn't matter they are Int here because we change them to Float later.
            INI_WriteInt(file,"LastZ",0);
            INI_WriteInt(file,"LastA",0);
            INI_WriteInt(file,"LastInt",0);
            INI_WriteInt(file,"LastVW",0);
            INI_WriteInt(file,"NewReg",0);
            INI_WriteInt(file,"LastSkin",0);
            INI_Close(file);//Now after we've done saving their data, we now need to close the file
            PlayerInfo[playerid][NewReg] = 1;
            SendClientMessage(playerid,-1,"You have been successfully registered");//Tell to them that they have successfully registered a new account
            return 1;
        }
    }
    if(dialogid == DIALOG_LOGIN) //If dialog id is a login dialog
    {//then
        if(!response) return Kick(playerid); //If they clicked the second button "Quit", we will kick them.
        if(response) //if they clicked the first button "Register"
        {//then
            new hashpass[129]; //Will create a new variable to hash his/her password
            WP_Hash(hashpass,sizeof(hashpass),inputtext); //Will hash inputted password
            if(!strcmp(hashpass, PlayerInfo[playerid][pPassword], false)) //If they have insert their correct password
            {//then
                INI_ParseFile(Path(playerid),"loadaccount_%s",.bExtra = true, .extra = playerid);//We will load his account's data from user's path
                SetPlayerScore(playerid,PlayerInfo[playerid][pLevel]);//We will get their score inside of his user's account and we will set it here
                GivePlayerMoney(playerid,PlayerInfo[playerid][pMoney]);//As explained above
                SendClientMessage(playerid,-1,"Welcome back! You have successfully logged in");//Tell them that they've successfully logged in
                SetSpawnInfo(playerid, 0, 0, 1532.3077, -1670.3546, 13.3828 , 0, 0, 0, 0, 0, 0, 0);
                SpawnPlayer(playerid);
                SetCameraBehindPlayer(playerid);
                TogglePlayerSpectating(playerid,false);
                SetPlayerInterior(playerid, 0);
                SetPlayerVirtualWorld(playerid, playerid+0);
            }
            else //If they've entered an incorrect password
            {//then
                ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Login",""COLOR_RED"Welcome back. "COLOR_WHITE"This account is registered. \nInsert your password to login to your account.\n"COLOR_RED"Incorrect password!","Login","Quit");//We will tell to them that they've entered an incorrect password
                return 1;
            }
        }
    return 1;
}
pawn Код:
new Float:Xlog, Float:Ylog, Float:Zlog;
    GetPlayerPos(playerid, Xlog, Ylog, Zlog); // Getting the player position on disconnect.
    PlayerInfo[playerid][LastX] = Xlog;
    PlayerInfo[playerid][LastY] = Ylog;
    PlayerInfo[playerid][LastZ] = Zlog;
    new playerskin = GetPlayerSkin(playerid);
    new INI:file = INI_Open(Path(playerid)); //will open their file
    INI_SetTag(file,"Player's Data");//We will set a tag inside of user's account called "Player's Data"
    INI_WriteInt(file,"Admin",PlayerInfo[playerid][pAdmin]); //If you've set his/her admin level, then his/her admin level will be saved inside of his/her account
    INI_WriteInt(file,"Gender",PlayerInfo[playerid][pGender]);//As explained above
    INI_WriteInt(file,"Money",GetPlayerMoney(playerid));//We will save his money inside of his account
    INI_WriteInt(file,"Level",GetPlayerScore(playerid));//We will save his score inside of his account
    INI_WriteInt(file,"Age",PlayerInfo[playerid][pAge]);//Asplained above
    INI_WriteInt(file,"Ban",PlayerInfo[playerid][pBan]);
    INI_WriteInt(file,"LastSkin",playerskin);
    INI_WriteFloat(file,"LastX",PlayerInfo[playerid][LastX]); // Making sure we save it as a FLOAT
    INI_WriteFloat(file,"LastY",PlayerInfo[playerid][LastY]); // Making sure we save it as a FLOAT
    INI_WriteFloat(file,"LastZ",PlayerInfo[playerid][LastZ]); // Making sure we save it as a FLOAT
    INI_WriteInt(file,"NewReg",0); //
   
    INI_Close(file);//Now after we've done saving their data, we now need to close the file
    TextDrawDestroy(SpeedoText[playerid]);
Reply
#5

Are you using a command for the DIALOG_REGISTER_1 to pop up? for eg: just typing the cmd "register" and the dialog box appears.
Reply
#6

Is the player ini empty if player doesn't registered ?
Reply
#7

Quote:
Originally Posted by Ironboy
Посмотреть сообщение
Are you using a command for the DIALOG_REGISTER_1 to pop up? for eg: just typing the cmd "register" and the dialog box appears.
No, it's an auto dialog onconnect
Reply
#8

Quote:
Originally Posted by bigboy81
Посмотреть сообщение
Is the player ini empty if player doesn't registered ?
No it has everything except the password line
Reply
#9

How do i make so if that the dialog inputtext is null, then don't save an ini file?
Reply
#10

make something like this
if(strlen(inputtext) < 3) return 1;
that will block if player not type password under 3 characters
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)