Dini don't save the player file after a kick.
#1

I script a simple admin system this week, and yesterday I noticed that when somebody is kicked, all the variables on the player's file (at scriptfiles) get all the Ints values set to zero, and the String, well, they are setted to "".

pawn Код:
else if(strcmp(cmd, "/kick", true) == 0) {
        new tmp[128], username[128], sendername[128], string[128], user;
        tmp = strtok(cmdtext, idx);
            /* Faz algumas vereficaзхes, e seta user como uma int, que representa o ID do usuбrio kickado. */
        salvarAcc(user);
        GetPlayerName(playerid, sendername, sizeof(sendername));
        GetPlayerName(user, username, sizeof(username));
        format(string, sizeof(string), "Adm.Cmd: %s foi kickado por %s. Motivo: %s", username, sendername, cmdtext[idx]);
        SendClientMessageToAll(COLOR_FIREBRICK, string);
        print(string);
        Kick(user);
        return 1;
            }
pawn Код:
public salvarAcc(playerid) {
    printf("Player ID %i se desconectando!", playerid);
    new file[100], name[128];
    GetPlayerName(playerid, name, sizeof(name));
    format(file, sizeof(file), PlayerFile, name);
    print(file);
    dini_Set(file,"IP", gPlayerInfo[playerid][PLAYER_IP]);
    dini_IntSet(file,"Reg", gPlayerInfo[playerid][PLAYER_REGGED]);
    dini_Set(file,"Password", gPlayerInfo[playerid][PLAYER_PASS]);
    dini_IntSet(file,"Level", gPlayerInfo[playerid][PLAYER_LEVEL]);
    dini_IntSet(file,"Preso", gPlayerInfo[playerid][PLAYER_PRESO]);
    dini_IntSet(file, "TempoPreso", gPlayerInfo[playerid][PLAYER_PRESO]);
    dini_IntSet(file, "Admin", gPlayerInfo[playerid][PLAYER_ADMIN]);
    dini_IntSet(file,"Dinheuri", gPlayerInfo[playerid][PLAYER_MONEY]);
    dini_IntSet(file,"Respeito", gPlayerInfo[playerid][PLAYER_RESP]);
    dini_IntSet(file, "Org", gPlayerInfo[playerid][PLAYER_ORG]);
    dini_IntSet(file, "COrg", gPlayerInfo[playerid][PLAYER_CORG]);
    dini_IntSet(file,"VIP", gPlayerInfo[playerid][PLAYER_VIP]);
    dini_IntSet(file, "Procurado", gPlayerInfo[playerid][PLAYER_PROCURADO]);
    dini_IntSet(file, "Skin", gPlayerInfo[playerid][PLAYER_SKIN]);
    gPlayerInfo[playerid][PLAYER_IP]     = 0;
    gPlayerInfo[playerid][PLAYER_REGGED] = 0;
    gPlayerInfo[playerid][PLAYER_LOGGED] = 0;
    gPlayerInfo[playerid][PLAYER_PASS]   = 0;
    gPlayerInfo[playerid][PLAYER_LEVEL]  = 0;
    gPlayerInfo[playerid][PLAYER_PRESO]  = 0;
    gPlayerInfo[playerid][PLAYER_TPRESO] = 0;
    gPlayerInfo[playerid][PLAYER_ADMIN] = 0;
    gPlayerInfo[playerid][PLAYER_MONEY] = 0;
    gPlayerInfo[playerid][PLAYER_RESP] = 0;
    gPlayerInfo[playerid][PLAYER_ORG] = 0;
    gPlayerInfo[playerid][PLAYER_CORG] = 0;
    gPlayerInfo[playerid][PLAYER_VIP] = 0;
    gPlayerInfo[playerid][PLAYER_PROCURADO] = 0;
    gPlayerInfo[playerid][PLAYER_SKIN] = 0;
    printf("Player ID %i desconectado!", playerid);
    return 1;
}
I have the salvarAcc function at my onPlayerDisconnect too.

pawn Код:
public OnPlayerDisconnect(playerid,reason)
{
    salvarAcc(playerid);
    return 1;
}
I would appreciate any help, I was trying to release something like a ALPHA version today, but with a bug like that, I don't think it is possible.
Also, sorry for my english. It is horrible, I know.

Thanks a Lot.
Reply
#2

Hmm...

pawn Код:
stock SaveKick( playerid )
{
    salvarAcc( playerid );

    Kick( playerid );
}
Add a check, if the player is logged in or not

pawn Код:
public salvarAcc(playerid) {
    if ( gPlayerInfo[ playerid ][ PLAYER_LOGGED ] ) {
    printf("Player ID %i se desconectando!", playerid);
    new file[100], name[128];
    GetPlayerName(playerid, name, sizeof(name));
    format(file, sizeof(file), PlayerFile, name);
    print(file);
    dini_Set(file,"IP", gPlayerInfo[playerid][PLAYER_IP]);
    dini_IntSet(file,"Reg", gPlayerInfo[playerid][PLAYER_REGGED]);
    dini_Set(file,"Password", gPlayerInfo[playerid][PLAYER_PASS]);
    dini_IntSet(file,"Level", gPlayerInfo[playerid][PLAYER_LEVEL]);
    dini_IntSet(file,"Preso", gPlayerInfo[playerid][PLAYER_PRESO]);
    dini_IntSet(file, "TempoPreso", gPlayerInfo[playerid][PLAYER_PRESO]);
    dini_IntSet(file, "Admin", gPlayerInfo[playerid][PLAYER_ADMIN]);
    dini_IntSet(file,"Dinheuri", gPlayerInfo[playerid][PLAYER_MONEY]);
    dini_IntSet(file,"Respeito", gPlayerInfo[playerid][PLAYER_RESP]);
    dini_IntSet(file, "Org", gPlayerInfo[playerid][PLAYER_ORG]);
    dini_IntSet(file, "COrg", gPlayerInfo[playerid][PLAYER_CORG]);
    dini_IntSet(file,"VIP", gPlayerInfo[playerid][PLAYER_VIP]);
    dini_IntSet(file, "Procurado", gPlayerInfo[playerid][PLAYER_PROCURADO]);
    dini_IntSet(file, "Skin", gPlayerInfo[playerid][PLAYER_SKIN]);
    gPlayerInfo[playerid][PLAYER_IP]     = 0;
    gPlayerInfo[playerid][PLAYER_REGGED] = 0;
    gPlayerInfo[playerid][PLAYER_LOGGED] = 0;
    gPlayerInfo[playerid][PLAYER_PASS]   = 0;
    gPlayerInfo[playerid][PLAYER_LEVEL]  = 0;
    gPlayerInfo[playerid][PLAYER_PRESO]  = 0;
    gPlayerInfo[playerid][PLAYER_TPRESO] = 0;
    gPlayerInfo[playerid][PLAYER_ADMIN] = 0;
    gPlayerInfo[playerid][PLAYER_MONEY] = 0;
    gPlayerInfo[playerid][PLAYER_RESP] = 0;
    gPlayerInfo[playerid][PLAYER_ORG] = 0;
    gPlayerInfo[playerid][PLAYER_CORG] = 0;
    gPlayerInfo[playerid][PLAYER_VIP] = 0;
    gPlayerInfo[playerid][PLAYER_PROCURADO] = 0;
    gPlayerInfo[playerid][PLAYER_SKIN] = 0;
    printf("Player ID %i desconectado!", playerid);
    return 1; }
}
pawn Код:
else if(strcmp(cmd, "/kick", true) == 0) {
        new tmp[128], username[128], sendername[128], string[128], user;
        tmp = strtok(cmdtext, idx);
            /* Faz algumas vereficaзхes, e seta user como uma int, que representa o ID do usuбrio kickado. */
        //salvarAcc(user);
        GetPlayerName(playerid, sendername, sizeof(sendername));
        GetPlayerName(user, username, sizeof(username));
        format(string, sizeof(string), "Adm.Cmd: %s foi kickado por %s. Motivo: %s", username, sendername, cmdtext[idx]);
        SendClientMessageToAll(COLOR_FIREBRICK, string);
        print(string);
        SaveKick(user);
        return 1;
            }
Reply
#3

OMFG. Worked. Thanks, thanks, thanks. I love you. *-*
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)