User File Problem
#1

When i use a command that will change user file info then all gets delete from the user like:
I type /makeadmin and it succefly makes it and i /q.
but when i check the scripting files I find a black userfile.. It is full before the cmd.
i putted onplayerupdate after onplayerdisconnect:

Код:
public OnPlayerUpdate(playerid)
{
    if(IsPlayerConnected(playerid))
    {
        if(AccountInfo[playerid][aLogged] == 1)
        {
            new string3[128];
            new playername3[MAX_PLAYER_NAME];
            GetPlayerName(playerid, playername3, sizeof(playername3));
            format(string3, sizeof(string3), ACCOUNTS_FOLDER, playername3);
            new ip[20];
            GetPlayerIp(playerid,ip,sizeof(ip));
            new File: hFile = fopen(string3, io_write);
            if (hFile)
            {
            	new var[128];
             	format(var, 128, "Password=%s\n", AccountInfo[playerid][aPassword]);fwrite(hFile, var);
             	format(var, 128, "IP=%s\n",ip);fwrite(hFile, var);
        				format(var, 128, "EE=%d\n", AccountInfo[playerid][aEE]);fwrite(hFile, var);
        				format(var, 128, "Admin=%d\n", AccountInfo[playerid][aAdmin]);fwrite(hFile, var);
        				format(var, 128, "Tut=%d\n", AccountInfo[playerid][aTut]);fwrite(hFile, var);
        				format(var, 128, "Faction=%d\n", AccountInfo[playerid][aFaction]);fwrite(hFile, var);
            }
        }
    }
    return 1;
}
this aint GF or any other gm
Reply
#2

shouldn't you close the files after you write something on them?
Reply
#3

ohhhhhhhhhhhhhh gonna try that THX

edit:
works xD nice thx buddy
Reply
#4

This is a VERY bad way to do. You shouldn't save files at the OnPlayerUpdate-callback.
Reply
#5

how to do it in good way then xd correlli pomoziiiiiiiiiiiiiii
Reply
#6

Yeh I though that too lol.

Maybe the problem is in the /makeadmin command.
Reply
#7

Put the code to other self-made function.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)