dini_IntSet bugs the account and causes "incorrect password" -
Jack_Leslie - 12.12.2011
Hi guys.
So I'm having trouble with my unban command. I tried to re-do it and it still gave me troubles. There's two values that I set to a users' user file, and when they attempt to log back in, it says "incorrect password" even though it's the correct password. It's nothing to do with the login code because that works before I ban and unban someone. It's just when I ban someone and then unban someone, it does this.
Here is the unban code:
pawn Code:
CMD:unban(playerid, params[])
{
new user[126];
if(sscanf(params, "s", user)) return SendClientMessage(playerid, COLOR_GREY, "* Usuage: /unban [player name (case sensitive)]");
new string[129], string2[256];
format(string, sizeof(string), "%s.ini", user);
if(dini_Exists(string))
{
if(dini_Int(string, "Band") > 0)
{
dini_Set(string, "Band", 0);
dini_Set(string, "Warnings", 0);
string2 = dini_Get(string, "IP");
format(string, sizeof(string),"unbanip %s", string2);
SendRconCommand(string);
SendRconCommand("reloadbans");
format(string, 256, "AdmWarning: %s has unbanned account '%s' and IP '%s'.",PlayerName(playerid),user,string2);
ABroadCast(COLOR_LIGHTRED, string, 1);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_GREY, "* That user is not banned.");
string2 = dini_Get(string, "IP");
format(string, sizeof(string), "unbanip %s", string2);
SendRconCommand(string);
SendRconCommand("reloadbans");
return 1;
}
}
else
{
SendClientMessage(playerid, COLOR_LIGHTRED, "* User account not found !");
}
return 1;
}
As you can see all I do is set 2 values to the file with Dini. I'm not sure why it would do this.
Re: dini_IntSet bugs the account and causes "incorrect password" - Emmet_ - 12.12.2011
I've had a similar problem when I was testing out the SARP script, and I know how to fix it.
The problem is that you are using the raw file system, so when you use DINI, it will strip a new line after the value was set, fucking the account up in the butthole,
pawn Code:
CMD:unban(playerid, params[])
{
new user[126];
if(sscanf(params, "s", user)) return SendClientMessage(playerid, COLOR_GREY, "* Usuage: /unban [player name (case sensitive)]");
new string[129], string2[256], File:file;
format(string, sizeof(string), "%s.ini", user);
if(fexist(string))
{
file = fopen(string, io_write);
fwrite(file, "Band=0");
fwrite(file, "Warnings=0");
string2 = dini_Get(string, "IP"); // dini_Get can be used - and only that, else everything will get fucked
format(string, sizeof(string),"unbanip %s", string2);
SendRconCommand(string);
SendRconCommand("reloadbans");
format(string, 256, "AdmWarning: %s has unbanned account '%s' and IP '%s'.",PlayerName(playerid),user,string2);
ABroadCast(COLOR_LIGHTRED, string, 1);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_LIGHTRED, "* User account not found !");
}
return 1;
}
Re: dini_IntSet bugs the account and causes "incorrect password" -
Jack_Leslie - 12.12.2011
Quote:
Originally Posted by Emmet_
I've had a similar problem when I was testing out the SARP script, and I know how to fix it.
The problem is that you are using the raw file system, so when you use DINI, it will strip a new line after the value was set, fucking the account up in the butthole,
pawn Code:
CMD:unban(playerid, params[]) { new user[126]; if(sscanf(params, "s", user)) return SendClientMessage(playerid, COLOR_GREY, "* Usuage: /unban [player name (case sensitive)]"); new string[129], string2[256], File:file; format(string, sizeof(string), "%s.ini", user); if(fexist(string)) { file = fopen(string, io_write); fwrite(file, "Band=0"); fwrite(file, "Warnings=0"); string2 = dini_Get(string, "IP"); // dini_Get can be used - and only that, else everything will get fucked format(string, sizeof(string),"unbanip %s", string2); SendRconCommand(string); SendRconCommand("reloadbans"); format(string, 256, "AdmWarning: %s has unbanned account '%s' and IP '%s'.",PlayerName(playerid),user,string2); ABroadCast(COLOR_LIGHTRED, string, 1); return 1; } else { SendClientMessage(playerid, COLOR_LIGHTRED, "* User account not found !"); }
return 1; }
|
Doesn't io_write remove everything else in the file? Or does it just over-write the values you tell it too?
Re: dini_IntSet bugs the account and causes "incorrect password" - Emmet_ - 12.12.2011
Quote:
Originally Posted by Jack_Leslie
Doesn't io_write remove everything else in the file? Or does it just over-write the values you tell it too?
|
As far as I know, io_write will over-write the values (if they exist in the file already), else they will create new ones.
You should test it first, maybe I could be wrong.
Re: dini_IntSet bugs the account and causes "incorrect password" -
Jack_Leslie - 12.12.2011
Okay cheers Emmet, I'll test it now and let you know how it goes.