y-ini loading help
#1

Hello everyone i am trying to make a group system everything works fine group saves in a file butt he problem is its not loading

here is my code:

PHP код:

stock SaveGroups
(id)
{
    new 
file[64];
    
format(filesizeof(file), "Groups/%d.ini"id);
    new 
INI:fHandle INI_Open(file);
    if(
fHandle != INI_NO_FILE)
    {
           
INI_SetTag(fHandle"GroupsData");
        
INI_WriteString(fHandle"GroupName"GroupInfo[id][gName]);
        
INI_WriteString(fHandle"LeaderName"GroupInfo[id][gLeaderName]);
        
INI_WriteInt(fHandle,"Active"GroupInfo[id][gActive]);
        
INI_Close(fHandle);
    }
    return 
1;
}
forward LoadGroups(idname[], value[]);
public 
LoadGroups(idname[], value[])
{
    
INI_String("GroupName"GroupInfo[id][gName],75);
    
INI_String("LeaderName"GroupInfo[id][gLeaderName], MAX_PLAYER_NAME);
    
INI_Int("Active"GroupInfo[id][gActive]);
    return 
1;
}
// loading code in GameModeInit
    
new gfile[64];
    for(new 
iMAX_GROUPSi++)
    {
        
format(gfilesizeof(gfile), "Groups/%d.ini"i);
        if(
fexist(gfile))
        {
            
INI_ParseFile(file"LoadGroups", .bExtra true, .extra i);
        }
    } 
this is group ini save file
PHP код:
[GroupsData]
GroupName the test
LeaderName 
salman97
Active 

i have one more question its not related with problem:

this is my saving code i call it in gamemode exit:
PHP код:
    for(new iMAX_GROUPSi++)
    {
        if(
GroupInfo[i][gActive] == 1){SaveGroups(i);}
    } 
my question is: should i put it in onplayerdisconnect or its not needed?
Reply
#2

You are saving with "GroupsData" tag, but you don't load it. Try
pawn Код:
public LoadGroups_GroupsData(id, name[], value[])
//(...) and
INI_ParseFile(file, "LoadGroups_%s", .bExtra = true, .extra = i);
Reply
#3

Quote:
Originally Posted by Misiur
Посмотреть сообщение
You are saving with "GroupsData" tag, but you don't load it. Try
pawn Код:
public LoadGroups_GroupsData(id, name[], value[])
//(...) and
INI_ParseFile(file, "LoadGroups_%s", .bExtra = true, .extra = i);
did what u said still the same:

PHP код:
    new gfile[64];
    for(new 
iMAX_GROUPSi++)
    {
        
format(gfilesizeof(gfile), "Groups/%d.ini"i);
        if(
fexist(gfile))
        {
            
INI_ParseFile(file"LoadGroups_%s", .bExtra true, .extra i);
        }
    }
forward LoadGroups_GroupsData(idname[], value[]);
public 
LoadGroups_GroupsData(idname[], value[])
{
    
INI_String("GroupName"GroupInfo[id][gName],75);
    
INI_String("LeaderName"GroupInfo[id][gLeaderName], MAX_PLAYER_NAME);
    
INI_Int("Active"GroupInfo[id][gActive]);
    return 
1;

and this is how i check for groups

PHP код:
COMMAND:groups(playeridparams[])
{
    
ListGroups(playerid);
    return 
1;
}
stock ListGroups(playerid)
{
    new 
countstring[512];
    for (new 
0MAX_GROUPSi++)  
    {
        if(
GroupInfo[i][gActive] == 1)
        {
            
count++;
            
format(stringsizeof (string), "%s %s\n"stringGroupInfo[i][gName]);
        }
     }
    if (!
countSendClientMessage(playerid, -1"no groups");
    else 
ShowPlayerDialog(playerid286DIALOG_STYLE_MSGBOX"Groups"string"Close""");
    return 
1;

Reply
#4

Not sure if it has any impact but you could use Misiur's method and beside that you could try changing
pawn Код:
%d
to
pawn Код:
%i
Here's my method of loading groups:
pawn Код:
for(new idy = 1; idy < sizeof(GroupInfo); idy++)
    {
        new gname[250];
        format(str, sizeof(str), GPATH, idy);
        INI_ParseFile(str, "loadgroup_%s", .bExtra = true, .extra = idy);
        GroupInfo[idy][gOutsideIcon] = CreateDynamicPickup(1239, 1, GroupInfo[idy][gHqX], GroupInfo[idy][gHqY], GroupInfo[idy][gHqZ], 0);
        format(gname, sizeof(gname), "%s's HQ\n\nOnly members are allowed.\n\nPress \"Enter\" to access.", GroupInfo[idy][gName]);
        Create3DTextLabel(gname, -1, GroupInfo[idy][gHqX], GroupInfo[idy][gHqY], GroupInfo[idy][gHqZ], 20, 0);
        GroupInfo[idy][gInsideIcon] =  CreateDynamicPickup(1239, 1, GroupInfo[idy][gInsideX], GroupInfo[idy][gInsideY], GroupInfo[idy][gInsideZ], GroupInfo[idy][gInterior]);
    }
Reply
#5

thanks for taking time and trying to help but still not loading

any other help please?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)