Y_INI saving problem
#1

I'm trying to save player's info. Well, The code isn't working. I join the game, And since my user file doesn't exists, It is supposed to create a new file. And it doesn't look like it saves. Here's my code:

PHP код:
#define MAX_OWNABLE_VEHICLES 5
#define USERS_PATH "/EVO/users/%s.ini"
enum pInfo {
    
bool:pAllowed,
    
pTotalVehs,
    
pVSlot[MAX_OWNABLE_VEHICLES-1]
}
stock UserPath(playerid) {
    new 
path[64], name[MAX_PLAYER_NAME];
    
GetPlayerName(playeridnamesizeof(name));
    
format(pathsizeof(path), USERS_PATHname);
    return 
name;
}
public 
LoadUser_data(playerid,name[],value[])
{
    
printf("Read %s: %s"namevalue);
    
    
INI_Bool("allowed"PlayerInfo[playerid][pAllowed]);
    
INI_Int("totalvehs"PlayerInfo[playerid][pTotalVehs]);
    for(new 
0MAX_OWNABLE_VEHICLESi++) {
        new 
vslot[10];
        
format(vslotsizeof(vslot), "slot%d"i);
        
INI_Int(vslotPlayerInfo[playerid][pVSlot][i]);
    }
     return 
1;
}
public 
OnPlayerConnect(playerid)
{
    if(
fexist(UserPath(playerid)))
    {
        
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra true, .extra playerid);
    }
    else
    {
         new 
INI:File INI_Open(UserPath(playerid));
         
INI_SetTag(File,"data");
        
INI_WriteBool(File"allowed"PlayerInfo[playerid][pAllowed]);
        
INI_WriteInt(File"totalvehs"PlayerInfo[playerid][pTotalVehs]);
        for(new 
0MAX_OWNABLE_VEHICLESi++) {
            new 
vslot[10];
            
format(vslotsizeof(vslot), "slot%d"i);
            
INI_WriteInt(FilevslotPlayerInfo[playerid][pVSlot][i]);
        }    
        
INI_Close(File);
    }
    return 
1;
}
public 
OnPlayerDisconnect(playeridreason)
{
    new 
INI:File INI_Open(UserPath(playerid));
    
INI_SetTag(File,"data");
    
INI_WriteBool(File"allowed"PlayerInfo[playerid][pAllowed]);
    
INI_WriteInt(File"totalvehs"PlayerInfo[playerid][pTotalVehs]);
    for(new 
0MAX_OWNABLE_VEHICLESi++) {
        new 
vslot[10];
        
format(vslotsizeof(vslot), "slot%d"i);
        
INI_WriteInt(FilevslotPlayerInfo[playerid][pVSlot][i]);
    }    
    
INI_Close(File);
    return 
1;

EDIT: Okay, I've just seen something. It saves but it saves it directly to my scriptfiles folder. And it doesn't have the .ini extension, nor does it have any data. I'm sure that I have all the necessary folder created for the path.

Reply


Messages In This Thread
Y_INI saving problem[FIXED] - by DarkSkull - 26.07.2016, 17:11
Re: Y_INI saving problem - by DarkSkull - 27.07.2016, 14:51
Re: Y_INI saving problem - by AndySedeyn - 27.07.2016, 15:57
Re: Y_INI saving problem - by DarkSkull - 27.07.2016, 16:42
Re: Y_INI saving problem - by ThePhenix - 27.07.2016, 16:47
Re: Y_INI saving problem - by DarkSkull - 27.07.2016, 17:54
Re: Y_INI saving problem - by ThePhenix - 27.07.2016, 17:59
Re: Y_INI saving problem - by DarkSkull - 27.07.2016, 18:10
Re: Y_INI saving problem - by ThePhenix - 27.07.2016, 18:14
Re: Y_INI saving problem - by DarkSkull - 27.07.2016, 18:22

Forum Jump:


Users browsing this thread: 1 Guest(s)