SA-MP Forums Archive
io_write question - 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: io_write question (/showthread.php?tid=156871)



io_write question - Headshot1108 - 24.06.2010

hi,
well in my server i use dini and io_write.
I would like to know how i can do that the password_hash will be saved correctly.

this one works, but will this works for all players and will not bug ?

pawn Код:
if(LoggedIn[playerid] == 1)
    {
        new tmpHASH;
      new filestr[128];
      format(filestr,sizeof(filestr),"Oyuncu/%s.ini",PlayerName(playerid));
        tmpHASH = dini_Int(filestr,"password_hash");
        new File: file = fopen(filestr, io_write);
        if (file)
        {
          dini_IntSet(filestr,"password_hash",tmpHASH);
          dini_IntSet(filestr,"Money",GetPlayerMoney(playerid));
          dini_IntSet(filestr,"Score",GetPlayerScore(playerid));
          dini_IntSet(filestr,"Kills",Kills[playerid]);
          dini_IntSet(filestr,"Deaths",Deaths[playerid]);
          dini_IntSet(filestr,"Level",PlayerInfo[playerid][pAdmin]);
        }
        fclose(file);
    }
i used io_write that the file deletes all old things (example when i add or remove some variables) and saves the new variables which i created in the script.


Re: io_write question - MadeMan - 24.06.2010

Better use this to hash players passwords so you don't have to load them from file?

pawn Код:
stock udb_hash(buf[])
{
    new length=strlen(buf);
    new s1 = 1;
    new s2 = 0;
    new n;
    for (n=0; n<length; n++)
    {
        s1 = (s1 + buf[n]) % 65521;
        s2 = (s2 + s1)   % 65521;
    }
    return (s2 << 16) + s1;
}



Re: io_write question - Headshot1108 - 24.06.2010

yes, this would be better but in the io_write bracket all old variables (from the file) will be deleted so I cant get them, that means i must get the hash before the bracket. Or i understood you wrong ? :P