Reading data from file - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Reading data from file (
/showthread.php?tid=83786)
Reading data from file -
RDragon - 27.06.2009
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 )
Re: Reading data from file -
Ignas1337 - 27.06.2009
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
Re: Reading data from file -
RDragon - 27.06.2009
No, I didn't hash it anywhere...
And when I open the file with an editor it looks like:
Passwort=123456
Level=0
...
...
Re: Reading data from file -
RDragon - 27.06.2009
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?
Re: Reading data from file -
RDragon - 27.06.2009
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