PDA

View Full Version : Saving & Loading factions.


The__
21/12/2011, 06:03 PM
I'm using a Godfather edit, and the faction are hopping 1+ faction slot always at every restart.
That's loading & saving code, hope someone can help.

public LoadFamilies()
{
new arrCoords[35][64];
new strFromFile2[256];
new File: file = fopen("cfgs/families.cfg", io_read);
if (file) {
new idx;
while (idx < sizeof(FamilyInfo)) {
fread(file, strFromFile2);
split(strFromFile2, arrCoords, '|');
strmid(FamilyInfo[idx][FamilyName], arrCoords[0], 0, strlen(arrCoords[0]), 255);
strmid(FamilyInfo[idx][FamilyMOTD], arrCoords[1], 0, strlen(arrCoords[1]), 255);
FamilyInfo[idx][FamilySpawn][0] = floatstr(arrCoords[2]);
FamilyInfo[idx][FamilySpawn][1] = floatstr(arrCoords[3]);
FamilyInfo[idx][FamilySpawn][2] = floatstr(arrCoords[4]);
FamilyInfo[idx][FamilyExit][0] = floatstr(arrCoords[5]);
FamilyInfo[idx][FamilyExit][1] = floatstr(arrCoords[6]);
FamilyInfo[idx][FamilyExit][2] = floatstr(arrCoords[7]);
strmid(FamilyInfo[idx][FamilyRank1], arrCoords[8], 0, strlen(arrCoords[8]), 255);
strmid(FamilyInfo[idx][FamilyRank2], arrCoords[9], 0, strlen(arrCoords[9]), 255);
strmid(FamilyInfo[idx][FamilyRank3], arrCoords[10], 0, strlen(arrCoords[10]), 255);
strmid(FamilyInfo[idx][FamilyRank4], arrCoords[11], 0, strlen(arrCoords[11]), 255);
strmid(FamilyInfo[idx][FamilyRank5], arrCoords[12], 0, strlen(arrCoords[12]), 255);
strmid(FamilyInfo[idx][FamilyRank6], arrCoords[13], 0, strlen(arrCoords[13]), 255);
FamilyInfo[idx][FamilySkin1] = strval(arrCoords[14]);
FamilyInfo[idx][FamilySkin2] = strval(arrCoords[15]);
FamilyInfo[idx][FamilySkin3] = strval(arrCoords[16]);
FamilyInfo[idx][FamilySkin4] = strval(arrCoords[17]);
FamilyInfo[idx][FamilySkin5] = strval(arrCoords[18]);
FamilyInfo[idx][FamilySkin6] = strval(arrCoords[19]);
FamilyInfo[idx][FamilyInterior] = strval(arrCoords[20]);
FamilyInfo[idx][FamilyDrugs] = strval(arrCoords[21]);
FamilyInfo[idx][FamilyMats] = strval(arrCoords[22]);
FamilyInfo[idx][FamilyMoney] = strval(arrCoords[23]);
FamilyInfo[idx][FamilyLocked] = strval(arrCoords[24]);
FamilyInfo[idx][FamilyGun][0] = strval(arrCoords[25]);
FamilyInfo[idx][FamilyGun][1] = strval(arrCoords[26]);
FamilyInfo[idx][FamilyGun][2] = strval(arrCoords[27]);
FamilyInfo[idx][FamilyGun][3] = strval(arrCoords[28]);
FamilyInfo[idx][FamilyAmmo][0] = strval(arrCoords[29]);
FamilyInfo[idx][FamilyAmmo][1] = strval(arrCoords[30]);
FamilyInfo[idx][FamilyAmmo][2] = strval(arrCoords[31]);
FamilyInfo[idx][FamilyAmmo][3] = strval(arrCoords[32]);
FamilyInfo[idx][FamilyMembers] = strval(arrCoords[33]);
FamilyInfo[idx][FamilyIden] = strval(arrCoords[34]);
idx++;
}
fclose(file);
}
return 1;
}


public SaveFamilies()
{
new idx;
new File: file2;
while (idx < sizeof(FamilyInfo)) {
new coordsstring[256];
format(coordsstring, sizeof(coordsstring), "%d,%s|%s|%f|%f|%f|%f|%f|%f|%s|%s|%s|%s|%s|%s|%d|%d |%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|% d|%d|%d\r\n",
idx,
FamilyInfo[idx][FamilyName],
FamilyInfo[idx][FamilyMOTD],
FamilyInfo[idx][FamilySpawn][0],
FamilyInfo[idx][FamilySpawn][1],
FamilyInfo[idx][FamilySpawn][2],
FamilyInfo[idx][FamilyExit][0],
FamilyInfo[idx][FamilyExit][1],
FamilyInfo[idx][FamilyExit][2],
FamilyInfo[idx][FamilyRank1],
FamilyInfo[idx][FamilyRank2],
FamilyInfo[idx][FamilyRank3],
FamilyInfo[idx][FamilyRank4],
FamilyInfo[idx][FamilyRank5],
FamilyInfo[idx][FamilyRank6],
FamilyInfo[idx][FamilySkin1],
FamilyInfo[idx][FamilySkin2],
FamilyInfo[idx][FamilySkin3],
FamilyInfo[idx][FamilySkin4],
FamilyInfo[idx][FamilySkin5],
FamilyInfo[idx][FamilySkin6],
FamilyInfo[idx][FamilyInterior],
FamilyInfo[idx][FamilyDrugs],
FamilyInfo[idx][FamilyMats],
FamilyInfo[idx][FamilyMoney],
FamilyInfo[idx][FamilyLocked],
FamilyInfo[idx][FamilyGun][0],
FamilyInfo[idx][FamilyGun][1],
FamilyInfo[idx][FamilyGun][2],
FamilyInfo[idx][FamilyGun][3],
FamilyInfo[idx][FamilyAmmo][0],
FamilyInfo[idx][FamilyAmmo][1],
FamilyInfo[idx][FamilyAmmo][2],
FamilyInfo[idx][FamilyAmmo][3],
FamilyInfo[idx][FamilyMembers],
FamilyInfo[idx][FamilyIden]);
if(idx == 0) {
file2 = fopen("cfgs/families.cfg", io_write);
}
else {
file2 = fopen("cfgs/families.cfg", io_append);
}
fwrite(file2, coordsstring);
idx++;
fclose(file2);
}
return 1;
}

DiiP
21/12/2011, 06:04 PM
I have exactly the same problem, can someone help?

demonarn
21/12/2011, 06:06 PM
look at this post http://forum.sa-mp.com/showthread.php?t=45235
And you will find this ANYTHING Godfather related http://forum.sa-mp.com/showthread.php?t=7797

The__
21/12/2011, 06:08 PM
What ? please, quit spamming, I'm asking for help.

Tee
21/12/2011, 06:17 PM
What exactly is happening?

The__
21/12/2011, 06:33 PM
Every time I GMX, the faction slot is hopping by one.
For Ex. : I'll change the name of faction number 13, then I GMX, and the name jumps to faction number 14.

The__
22/12/2011, 05:40 AM
Bump, 24 hours.

Steven82
22/12/2011, 05:48 AM
21/12/2011, 11:33 AM
21/12/2011, 10:40 PM
Doesn't seem to look like 24 hours(my timezone).


On Topic:

When your GMX are you using this function?
SaveFamilies();

The__
22/12/2011, 06:58 AM
21/12/2011, 11:33 AM
21/12/2011, 10:40 PM
Doesn't seem to look like 24 hours(my timezone).


On Topic:

When your GMX are you using this function?
SaveFamilies();
I'll try this function :

forward Restarting();
public Restarting()
{
new string[128];
new Restart = 20;
foreach (Player, i) {
if(Restart >= 1) {
Restart --;
PlayerPlaySound(i, 1138, 0.0, 0.0, 0.0);
format(string, sizeof(string), "Restarting in...~n~~r~%d",Restart);
GameTextForAll(string, 5000, 3);
}
else if(Restart == 0) {
OnPlayerDataSave(i);
SaveCars();
SaveTrunk();
SaveSafe();
SaveFamilies();
SaveBans();
OnPropUpdate();
DOF2_Exit();
SendRconCommand("gmx");
}
}
return 1;
}

The__
22/12/2011, 01:43 PM
Doesn't work...sorry for bumping.