io_write question
#1

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.
Reply
#2

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;
}
Reply
#3

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)