Creating an empty file

Well I don't really know how to explain this, but I was making a new gamemode.
I started off with making a registration system, but I found a bug.

If I click on "Quit" before registering, for some reason it's creating the .ini file, but empty.
And that would stop me from registering, and will ask me to login.

pawn Код:
        return Kick(playerid);

        if(strlen(inputtext) < 3 || strlen(inputtext) > 32)
            return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Registering...", "Welcome to the server!\nPlease enter a password to register.\n\n{FF0000}The password must be between 3 and 32 characters.", "Register", "Quit");

        new hashedpass[129];
        WP_Hash(hashedpass, sizeof (hashedpass), inputtext);
        new INI:file = INI_Open(UserPath(playerid));
        INI_WriteString(file, "Password", hashedpass);
        INI_WriteInt(file, "Admin", 0);
        INI_WriteInt(file, "Money", 0);
        INI_WriteInt(file, "Score", 0);
        INI_WriteInt(file, "Kills", 0);
        INI_WriteInt(file, "Deaths", 0);
        // Rest of the code

Use "fexist" function to check if there's a file existing with the player name. AFAIK, fexist only checks if a file exists or not, it doesn't create a new one.

Well what do you exactly mean?
Even if I check it would still create the file.

It would be very helpful if you explain more.

EDIT: I checked some admin filterscripts / gamemodes which use Y_INI but I couldn't get anything.
A lot of them actually have this.

24 hour bump.
It would be good if someone helps.

The problem isn't in the code. It's either an outdated plugin or include. We can't fix it for you.

Include's up to date.
Like I said I was starting a new gamemode so I don;t have any plugins.

Oops, did I say plugin? My bad.

The problem could also reside in the file permissions that your hosting provider has set. Contact them to make sure you have the correct permissions.

The problem is in the OnPlayerDisconnect callback, you are saving the user data when a player disconnect so it saves the unregistered player's data. So make a variable to check if the player is registered or not to save his data.

Why didn't I think of that..
Thanks, Juvanii.

So the file wasn't empty... it was just the wrong values...
Thanks for clearing that up Stinged, you could have saved a lot of time.

Forum Jump:

Users browsing this thread: