20.11.2015, 23:45
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:
this is group ini save file
i have one more question its not related with problem:
this is my saving code i call it in gamemode exit:
my question is: should i put it in onplayerdisconnect or its not needed?
here is my code:
PHP код:
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);
}
}
PHP код:
[GroupsData]
GroupName = the test
LeaderName = salman97
Active = 1
this is my saving code i call it in gamemode exit:
PHP код:
for(new i; i < MAX_GROUPS; i++)
{
if(GroupInfo[i][gActive] == 1){SaveGroups(i);}
}