stock SaveGroups(id)
{
new file[64];
format(file, sizeof(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(id, name[], value[]);
public LoadGroups(id, name[], 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 i; i < MAX_GROUPS; i++)
{
format(gfile, sizeof(gfile), "Groups/%d.ini", i);
if(fexist(gfile))
{
INI_ParseFile(file, "LoadGroups", .bExtra = true, .extra = i);
}
}
[GroupsData]
GroupName = the test
LeaderName = salman97
Active = 1
for(new i; i < MAX_GROUPS; i++)
{
if(GroupInfo[i][gActive] == 1){SaveGroups(i);}
}
public LoadGroups_GroupsData(id, name[], value[])
//(...) and
INI_ParseFile(file, "LoadGroups_%s", .bExtra = true, .extra = i);
You are saving with "GroupsData" tag, but you don't load it. Try
pawn Код:
|
new gfile[64];
for(new i; i < MAX_GROUPS; i++)
{
format(gfile, sizeof(gfile), "Groups/%d.ini", i);
if(fexist(gfile))
{
INI_ParseFile(file, "LoadGroups_%s", .bExtra = true, .extra = i);
}
}
forward LoadGroups_GroupsData(id, name[], value[]);
public LoadGroups_GroupsData(id, name[], 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;
}
COMMAND:groups(playerid, params[])
{
ListGroups(playerid);
return 1;
}
stock ListGroups(playerid)
{
new count, string[512];
for (new i = 0; i < MAX_GROUPS; i++)
{
if(GroupInfo[i][gActive] == 1)
{
count++;
format(string, sizeof (string), "%s %s\n", string, GroupInfo[i][gName]);
}
}
if (!count) SendClientMessage(playerid, -1, "no groups");
else ShowPlayerDialog(playerid, 286, DIALOG_STYLE_MSGBOX, "Groups", string, "Close", "");
return 1;
}
%d
%i
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]);
}