Reading data from file
#1

Quote:

format(var, 128, "Passwort=%s\n",Stat[playerid][password]);fwrite(hFile, var);
format(var, 128, "Level=%d\n",Stat[playerid][level]);fwrite(hFile, var);

Thats how I write some stuff in a userfile...

Now I want to read all this stuff from this file..

Quote:

new File: UserFile = fopen(string, io_read);
if ( UserFile )
{

new keytmp[256], valtmp[2][256];
while(fread( UserFile , keytmp , sizeof( keytmp )))
{

split(keytmp, valtmp, '=');
if(strcmp(valtmp[0], "Passwort", true) == 0)
{
strmid(Stat[playerid][password], valtmp[1], 0, strlen(valtmp[1]), 255);
}


}
if(!(strcmp(Stat[playerid][password], tmppass, true) == 0))
{
SendUserMessage(playerid, COLOR_GREY, "Wrong password !", "Falsches Passwort!");
Kick(playerid);
return 1;
}

And at this point, I always get the message Wrong password...
What did I do wrong? (I typed in the correct password :d )
Reply
#2

maybe you forgot to hash it somewhere that would cause it to think the passwords are diffrent. or you didn't hash and save then tried to login and hash it. I mean the script hash OnPlayerLogin or wherver. check that
Reply
#3

No, I didn't hash it anywhere...
And when I open the file with an editor it looks like:

Passwort=123456
Level=0
...
...

Reply
#4

I tried it now with printing into the server log...

The password he read from the file is exactly the same as the one I tipe in at /login (tmppass).

Is it possible that he doesn't like the different string lenghts?
Reply
#5

Quote:
Originally Posted by RDragon
if(strcmp(valtmp[0], "Passwort", true) == 0)
{
strmid(Stat[playerid][password], valtmp[1], 0, strlen(valtmp[1])-1, 255);
}
Sorry, my mistake
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)