[SOLVED] Passwords - Incorrect Saving; One letter replaced
#1

pawn Код:
new string[32];
format(string, sizeof(string), PASSWORD_FOLDER, PlayerName(playerid));
new File: hFile = fopen(string, io_write);
if (hFile)
{
   strmid(AccountInfo[playerid][Password], params, 0, strlen(params), 255);
   new str[128];
   format(str, 128, "Password=%s\n", AccountInfo[playerid][Password]);
   fwrite(hFile, str);
   fclose(hFile);

// The rest of the code - un important
It actually replaces one letter with something else, like >, <, Ђ, ^, ˇ etc and doesn't accept the password on login. What should I do? Hash them?
Reply
#2

Bump.
Reply
#3

These are my register/login commands, but you can some kind of transform them tou your scripts or i don't know. They're in latvian language, so try to translate yourself. I added comentars for easier translating. And these functions are just dini but renamed for easier use for me. Maybe they're useful for you:

Код:
if(strcmp(cmd, "/register", true) == 0)
	{
	GetPlayerName(playerid, name, sizeof(name));
	format(file, sizeof(file), "/users/%s.save", udb_encode(name));
	if(FileExist(file))
		{
		if(NumberFromFile(file,"login")==0)
			{
			SendClientMessage(playerid, COLOR_LIGHTBLUE, "SERVER: Sis lietotajs jau ir registrets, ielogojaties ar /login."); //if already is registered
			return 1;
			}
    else if(NumberFromFile(file,"login")==1)
    	{
			SendClientMessage(playerid, COLOR_LIGHTBLUE, "SERVER: Sis lietotajs jau ir registrets, un jus jau esat ielogojies."); /if already logged in
			return 1;
			}
		}
	else if(!FileExist(file))
		{
		tmp = strtok(cmdtext, idx);
		if(!strlen(tmp))
			{
			SendClientMessage(playerid, COLOR_LIGHTBLUE, "SERVER: Jus neesat ievadijis paroli."); //not written a password
			return 1;
			}
		else if(strlen(tmp))
		  {
		  new ip[16];
		  new date[128], year, month, day;
		  getdate(year, month, day);
			format(date, sizeof(date), "%d.%d.%d", day, month, year);
		  GetPlayerIp(playerid, ip, sizeof(ip));
			CreateFile(file);
			StringToFile(file, "password", tmp);
			StringToFile(file, "ip", ip);
			StringToFile(file, "regdate", date);
			StringToFile(file, "logdate", date);
			NumberToFile(file, "login", 1);
			NumberToFile(file, "admin", 0);
			NumberToFile(file, "mute", 0);
			NumberToFile(file, "ban", 0);
			NumberToFile(file, "money", 0);
			NumberToFile(file, "score", 0);
			NumberToFile(file, "kills", 0);
			NumberToFile(file, "deaths", 0);
			NumberToFile(file, "hours", 0);
			NumberToFile(file, "minutes", 0);
			NumberToFile(file, "seconds", 0);
			NumberToFile(file, "rank", 0);
			SendClientMessage(playerid, COLOR_LIGHTBLUE, "SERVER: Jus esat veiksmigi registrejies un esat automatiski ielogots."); //registered
			format(string, sizeof(string), "[user] %s registered", name);
	 		print(string);
			return 1;
			}
		}
	return 1;
	}

if(strcmp(cmd, "/login", true) == 0)
	{
	GetPlayerName(playerid, name, sizeof(name));
	format(file, sizeof(file), "/users/%s.save", udb_encode(name));
	if(!FileExist(file))
		{
		SendClientMessage(playerid, COLOR_LIGHTBLUE, "SERVER: Sis lietotajs nepastav, registrejaties ar /register."); //user does not exist use register
		return 1;
		}
	else if(FileExist(file))
 		{
 		tmp=strtok(cmdtext, idx);
		if(NumberFromFile(file,"login")==1)
			{
			SendClientMessage(playerid, COLOR_LIGHTBLUE, "SERVER: Tu jau esi ielogojies."); //already logged in
			return 1;
			}
		if(!strlen(tmp))
			{
			SendClientMessage(playerid, COLOR_LIGHTBLUE, "SERVER: Jus neesat ievadijis paroli."); //no password written
			return 1;
			}
		else if(strlen(tmp))
		  {
		  if(strcmp(StringFromFile(file,"password"),tmp))
		  	{
		  	SendClientMessage(playerid, COLOR_LIGHTBLUE, "SERVER: Jus esat ievadijis nepareizu paroli."); //wrong password
		  	return 1;
		  	}
			else if(!strcmp(StringFromFile(file,"password"),tmp))
				{
				if(NumberFromFile(file, "ban")==1)
					{
					format(string, sizeof(string), "SERVER: %s ir blokets par: blokets niks", name);
					SendClientMessage(playerid, COLOR_LIGHTBLUE, "SERVER: Sis niks ir banots.");
					SendClientMessageToAll(COLOR_LIGHTBLUE, string);
					BanEx(playerid, "Banned nick");
					return 1;
					}
			  new ip[16];
			  new date[128], year, month, day;
		  	getdate(year, month, day);
				format(date, sizeof(date), "%d.%d.%d", day, month, year);
			  GetPlayerIp(playerid, ip, sizeof(ip));
				StringToFile(file, "ip", ip);
				StringToFile(file, "lastlog", date);
				NumberToFile(file, "login", 1);
				GivePlayerMoney(playerid, NumberFromFile(file, "money"));
				SetPlayerScore(playerid, NumberFromFile(file, "score"));
				SetPlayerRank(playerid, NumberFromFile(file, "rank"));
				SendClientMessage(playerid, COLOR_LIGHTBLUE, "SERVER: Jus esat veiksmigi ielogojies."); //logged in
				format(string, sizeof(string), "[user] %s logged in", name);
	 			print(string);
				return 1;
				}
			return 1;
			}
		}
	return 1;
	}
Reply
#4

Thanks for that, but I moved from normal file functions to dini, it's a lot easier.

Now I get the "must be assigned to an array" error.
pawn Код:
AccountInfo[playerid][Password] = dini_Get(string, "Password");
Reply
#5

Maybe something is wrong in new or enums. These are from ladmin(Made by LethaL) :
Код:
enum PlayerData
{
	Registered,
	LoggedIn,
	Level,
	Score,
	Muted,
	Caps,
	Jailed,
	JailTime,
	Frozen,
	FreezeTime,
	Kills,
	Deaths,
	hours,
	mins,
	secs,
	TotalTime,
	ConnectTime,
 	MuteWarnings,
	Warnings,
	Spawned,
	TimesSpawned,
	God,
	GodCar,
	DoorsLocked,
	SpamCount,
	SpamTime,
	PingCount,
	PingTime,
	BotPing,
	pPing[PING_MAX_EXCEEDS],
	blip,
	blipS,
	pColour,
	pCar,
	SpecID,
	SpecType,
	bool:AllowedIn,
	FailLogin,
};
new PlayerInfo[MAX_PLAYERS][PlayerData];
This:
Код:
new PlayerInfo[MAX_PLAYERS][PlayerData];
Is like your new AccountInfo, but maybe something is wrong in your script.
Reply
#6

Never mind, I fixed it. I had chosen DUDB.
I used udb_Create, then checked the login with udb_CheckLogin.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)