Dini problem
#1

Aight, I've got a problem with Dini. It's just simply not saving things at all...
I tried using many things bellow OnPlayerDissconect but aint helping.. Please gimme some help here...

Code for the reg and log
PHP код:
    if(strcmp(cmd"/register"true) == 0)
    {
         new 
name[MAX_PLAYER_NAME];
        
tmp strtok(cmdtextidx);
         
GetPlayerName(playeridnamesizeof(name));
        if(
strlen(tmp) == 0) return SendClientMessage(playerid0xFFFFFFFF"USAGE: /register [password]");
         
format(file,sizeof(file),"%s.ini",name);
          if(!
fexist(file))
        {
              
dini_Create(file);
              
dini_IntSet(file"Password"udb_hash(tmp));
              
dini_IntSet(file,"AdminLevel"0);
              
dini_IntSet(file,"Cash"0);
              
dini_IntSet(file,"Score"0);
              
SendClientMessage(playeridCOLOR_WHITE"[System]: Account Created!");
              
PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
              
GetPlayerName(playeridnamesizeof(name));
              
printf("%s has registered a account!"name);
            }
            else
            {
                  
SendClientMessage(playeridCOLOR_RED" Account Already Found In Database");
                
PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
            }
            
    }
    if(
strcmp(cmd"/login"true) == 0)
    {
          new 
PlayerName[24];
          
tmp strtok(cmdtextidx);
          if(
strlen(tmp) == 0) return SendClientMessage(playerid0xFFFFFFFF"USAGE: /login [password]");
        new 
name[MAX_PLAYER_NAME];
        if(
IsLogged[playerid] == 1)
        {
            
SendClientMessage(playeridCOLOR_RED"You already are logged in!");
            return 
1;
        }
        else
        {
            
GetPlayerName(playeridnamesizeof(name));
            
format(file,sizeof(file),"%s.ini",name);
            if(
fexist(file))
            {
                  
tmp2 dini_Get(file"Password");
                 if(
udb_hash(tmp) != strval(tmp2))
                {
                  
SendClientMessage(playeridCOLOR_RED"Login Failed!");
                   
GetPlayerName(playeridPlayerNamesizeof(PlayerName));
                   
printf("%s has failed to login"name);
                }
                else
                {
                     
IsLogged[playerid] = 1;
                     
SetPlayerMoney(playeriddini_Int(file"Cash"));
                     
SetPlayerScore(playeriddini_Int(file"Score"));
                    
PlayerInfo[playerid][AdminLevel] = dini_Int(file"AdminLevel");
                    
SendClientMessage(playeridCOLOR_WHITE"[System]: Account Logged into!");
                }
            }
        }
        return 
1;
    } 
Reply
#2

Try to set a timer for when someone's logged in.

Say:

pawn Код:
forward SaveTimer(playerid);

SetTimerEx("SaveTimer", 1000, 1, "i", playerid);  // Under /login command

public SaveTimer(playerid)
{
    //Your dini stuff here.
    return 1;
}
Just a suggestion.
Reply
#3

Tried with that stuff to. Well the thing is happening is that it's sometimes saving it when I make it just it's creating new folders... It's not saving in the current ones.
Reply
#4

Hmmm. Have you checked the whole code?
Reply
#5

Yeah. The thing is, when player registers it makes his file. Then when he goes off it makes an empty folder called "Score".
Reply
#6

This is my dissconect code.
PHP код:
new string[128], PlayerName[MAX_PLAYER_NAME];
    
GetPlayerName(playeridPlayerNamesizeof(PlayerName)); 
    
format(stringsizeof(string), "Scores/%s.ini"PlayerName);
    if(
fexist(string))
    {
    
dini_IntSet(string"Score"GetPlayerScore(playerid));
    }
    else
    {
    
dini_Create(string); 
    
dini_IntSet(string"Score"GetPlayerScore(playerid)); 
    } 
Reply
#7

dudeu, why Scores/%s.ini?

The other file is just %s.ini
Reply
#8

i use a public in OnPlayerDisconnect for Save, look:
pawn Код:
public OnPlayerStatsUpdate(playerid)
{
    if(IsPlayerConnected(playerid))
    {
        if(gPlayerLogged[playerid])
        {
            new conta[128];
            conta = UserPath(playerid); // tenta
            if(dini_Exists(conta))
            {
                dini_Create(conta);
                dini_IntSet(conta,"Level",PInfo[playerid][Level]);
                dini_IntSet(conta,"Admin",PInfo[playerid][Admin]);
                dini_IntSet(conta,"Idade",PInfo[playerid][Age]);
                dini_IntSet(conta,"Sexo",PInfo[playerid][Sexo]);
                dini_IntSet(conta,"FactionL",PInfo[playerid][FactionL]);
                dini_IntSet(conta,"FactionM",PInfo[playerid][FactionM]);
                dini_IntSet(conta,"Telemovel",PInfo[playerid][Telemovel]);
                dini_IntSet(conta,"TelNR",PInfo[playerid][TelNR]);
                dini_IntSet(conta,"TipoCard",PInfo[playerid][TipoCard]);
                dini_IntSet(conta,"Rank",PInfo[playerid][Rank]);
                dini_IntSet(conta,"Job",PInfo[playerid][Job]);
                dini_IntSet(conta,"WLevel",PInfo[playerid][WantedLevel]);
                dini_IntSet(conta,"Jail",PInfo[playerid][Jail]);
                dini_IntSet(conta,"JailID",PInfo[playerid][JailID]);
                dini_IntSet(conta,"JailTime",PInfo[playerid][JailTime]);
                PInfo[playerid][Cash] = PlayerGetMoney(playerid);
                dini_IntSet(conta,"Cash",PInfo[playerid][Cash]);
                dini_IntSet(conta,"Bank",PInfo[playerid][Bank]);
                dini_IntSet(conta,"ChaveCasa",PInfo[playerid][ChaveCasa]);
                dini_IntSet(conta,"Registed",PInfo[playerid][Reg]);
                dini_IntSet(conta,"Skin",PInfo[playerid][Skin]);
                dini_IntSet(conta,"Kills",PInfo[playerid][Kills]);
                dini_IntSet(conta,"Deaths",PInfo[playerid][Deaths]);
                dini_IntSet(conta,"LSpawn",PInfo[playerid][LSpawn]);
                dini_IntSet(conta,"Tempo",PInfo[playerid][Tempo]);
                dini_IntSet(conta,"CarroL",PInfo[playerid][CarroL]);
                dini_IntSet(conta,"MotaL",PInfo[playerid][MotaL]);
                dini_IntSet(conta,"VehPID",PInfo[playerid][VehPID]);
                dini_IntSet(conta,"Tutorial",PInfo[playerid][Tutorial]);
                dini_IntSet(conta,"Limite",PInfo[playerid][Limite]);
                if ((PInfo[playerid][pPos_x]==0.0 && PInfo[playerid][pPos_y]==0.0 && PInfo[playerid][pPos_z]==0.0))
                {
                    PInfo[playerid][pPos_x] = 1684.9;
                    PInfo[playerid][pPos_y] = -2244.5;
                    PInfo[playerid][pPos_z] = 13.5;
                }
                dini_FloatSet(conta,"Pos_x",PInfo[playerid][pPos_x]);
                dini_FloatSet(conta,"Pos_y",PInfo[playerid][pPos_y]);
                dini_FloatSet(conta,"Pos_z",PInfo[playerid][pPos_z]);
            }
        }
    }
}
Reply
#9

Still dont get it how to make it
Reply
#10

I believe it is just dini_int. Not dini_intset
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)