[Y_INI Registration] Creating empty files -
Stinged - 22.06.2014
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 Код:
case DIALOG_REGISTER:
{
if(!response)
return Kick(playerid);
if(response)
{
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);
INI_Close(file);
// Rest of the code
}
}
Re: Creating an empty file -
Lordzy - 22.06.2014
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.
Re: Creating an empty file -
Stinged - 22.06.2014
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.
Re: Creating an empty file -
Stinged - 23.06.2014
24 hour bump.
It would be good if someone helps.
Re: Creating an empty file -
Threshold - 23.06.2014
The problem isn't in the code. It's either an outdated plugin or include. We can't fix it for you.
Re: Creating an empty file -
Stinged - 23.06.2014
Include's up to date.
Like I said I was starting a new gamemode so I don;t have any plugins.
Re: Creating an empty file -
Threshold - 23.06.2014
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.
Re: Creating an empty file -
Juvanii - 23.06.2014
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.
Re: Creating an empty file -
Stinged - 23.06.2014
Why didn't I think of that..
Thanks, Juvanii.
Re: Creating an empty file -
Threshold - 23.06.2014
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.