21.07.2014, 00:08
Hi..I'm having a little problem here i couldn't figure out.. maybe someone could help me out of this mess?
After I created family vehicles & saved them i tried to reload the gamemode.. and the vehicles are spawning 10 times on the same location.. means 10x10 just lots of vehicles spawn instead of just 5 that i created in the /fedit command.. Therefore to debug the situation i tried to save the families.cfg and then close the server & afterwards just load the file without saving new stuff. and the vehicles spawn only twice on the same location. Couldn't figure which does the problem the save or the load.![Confused](images/smilies/confused.png)
I'm having SaveFamilies(); "OnGameModeExit" & LoadFamilies(); "OnGameModeInit".
Here is saving families:
Here is the loading families:
Why this is happening any clue?
After I created family vehicles & saved them i tried to reload the gamemode.. and the vehicles are spawning 10 times on the same location.. means 10x10 just lots of vehicles spawn instead of just 5 that i created in the /fedit command.. Therefore to debug the situation i tried to save the families.cfg and then close the server & afterwards just load the file without saving new stuff. and the vehicles spawn only twice on the same location. Couldn't figure which does the problem the save or the load.
![Confused](images/smilies/confused.png)
I'm having SaveFamilies(); "OnGameModeExit" & LoadFamilies(); "OnGameModeInit".
Here is saving families:
pawn Код:
stock SaveFamilies()
{
new idx = 1, File:file;
new string[1300];
while(idx < MAX_FAMILIES)
{
format(string, sizeof(string), "%d|%s|%s|%d|%s|%d|%f|%f|%f|%d|%d|%d|%d|%s|%s|%s|%s|%s|%s|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%f|%f|%f|%f|%f|%f|%f|%f|%f|%f|%f|%f|%f|%f|%f|%f|%f|%f|%f|%f|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d\r\n",
FamInfo[idx][fTaken],
FamInfo[idx][fName],
FamInfo[idx][fMOTD],
FamInfo[idx][fColor],
FamInfo[idx][fLeader],
FamInfo[idx][fMembers],
FamInfo[idx][fSafeX],
FamInfo[idx][fSafeY],
FamInfo[idx][fSafeZ],
FamInfo[idx][fMoney],
FamInfo[idx][fMats],
FamInfo[idx][fWeed],
FamInfo[idx][fCrack],
FamInfo[idx][fRank1],
FamInfo[idx][fRank2],
FamInfo[idx][fRank3],
FamInfo[idx][fRank4],
FamInfo[idx][fRank5],
FamInfo[idx][fRank6],
FamInfo[idx][fSkins][0],
FamInfo[idx][fSkins][1],
FamInfo[idx][fSkins][2],
FamInfo[idx][fSkins][3],
FamInfo[idx][fSkins][4],
FamInfo[idx][fSkins][5],
FamInfo[idx][fSkins][6],
FamInfo[idx][fStrikes],
FamInfo[idx][fVehType][0], // Veh 1
FamInfo[idx][fVehType][1], // Veh 2
FamInfo[idx][fVehType][2], // Veh 3
FamInfo[idx][fVehType][3], // Veh 4
FamInfo[idx][fVehType][4], // Veh 5
FamInfo[idx][fVehCoX][0], // Veh 1 Coords
FamInfo[idx][fVehCoY][0],
FamInfo[idx][fVehCoZ][0],
FamInfo[idx][fVehCoX][1], // Veh 2 Coords
FamInfo[idx][fVehCoY][1],
FamInfo[idx][fVehCoZ][1],
FamInfo[idx][fVehCoX][2], // Veh 3 Coords
FamInfo[idx][fVehCoY][2],
FamInfo[idx][fVehCoZ][2],
FamInfo[idx][fVehCoX][3], // Veh 4 Coords
FamInfo[idx][fVehCoY][3],
FamInfo[idx][fVehCoZ][3],
FamInfo[idx][fVehCoX][4], // Veh 5 Coords
FamInfo[idx][fVehCoY][4],
FamInfo[idx][fVehCoZ][4],
FamInfo[idx][fVehRot][0],
FamInfo[idx][fVehRot][1],
FamInfo[idx][fVehRot][2],
FamInfo[idx][fVehRot][3],
FamInfo[idx][fVehRot][4],
FamInfo[idx][fVehCol1][0],
FamInfo[idx][fVehCol1][1],
FamInfo[idx][fVehCol1][2],
FamInfo[idx][fVehCol1][3],
FamInfo[idx][fVehCol1][4],
FamInfo[idx][fVehCol2][0],
FamInfo[idx][fVehCol2][1],
FamInfo[idx][fVehCol2][2],
FamInfo[idx][fVehCol2][3],
FamInfo[idx][fVehCol2][4]);
if(idx == 1)
{
file = fopen("families.cfg", io_write);
}
else
{
file = fopen("families.cfg", io_append);
}
fwrite(file, string);
fclose(file);
idx++;
}
print("Families saved successfully.");
}
pawn Код:
stock LoadFamilies()
{
new finfo[62][48];
new string[512];
new File:file = fopen("families.cfg", io_read);
if(file)
{
new idx = 1;
while(idx < MAX_FAMILIES)
{
fread(file, string);
split(string, finfo, '|');
FamInfo[idx][fTaken] = strval(finfo[0]);
format(FamInfo[idx][fName], 32, "%s", finfo[1]);
format(FamInfo[idx][fMOTD], 64, "%s", finfo[2]);
FamInfo[idx][fColor] = strval(finfo[3]);
format(FamInfo[idx][fLeader], MAX_PLAYER_NAME, "%s", finfo[4]);
FamInfo[idx][fMembers] = strval(finfo[5]);
FamInfo[idx][fSafeX] = floatstr(finfo[6]);
FamInfo[idx][fSafeY] = floatstr(finfo[7]);
FamInfo[idx][fSafeZ] = floatstr(finfo[8]);
FamInfo[idx][fMoney] = strval(finfo[9]);
FamInfo[idx][fMats] = strval(finfo[10]);
FamInfo[idx][fWeed] = strval(finfo[11]);
FamInfo[idx][fCrack] = strval(finfo[12]);
format(FamInfo[idx][fRank1], 32, "%s", finfo[13]);
format(FamInfo[idx][fRank2], 32, "%s", finfo[14]);
format(FamInfo[idx][fRank3], 32, "%s", finfo[15]);
format(FamInfo[idx][fRank4], 32, "%s", finfo[16]);
format(FamInfo[idx][fRank5], 32, "%s", finfo[17]);
format(FamInfo[idx][fRank6], 32, "%s", finfo[18]);
FamInfo[idx][fSkins][0] = strval(finfo[19]);
FamInfo[idx][fSkins][1] = strval(finfo[20]);
FamInfo[idx][fSkins][2] = strval(finfo[21]);
FamInfo[idx][fSkins][3] = strval(finfo[22]);
FamInfo[idx][fSkins][4] = strval(finfo[23]);
FamInfo[idx][fSkins][5] = strval(finfo[24]);
FamInfo[idx][fSkins][6] = strval(finfo[25]);
FamInfo[idx][fStrikes] = strval(finfo[26]);
FamInfo[idx][fVehType][0] = strval(finfo[27]);
FamInfo[idx][fVehType][1] = strval(finfo[28]);
FamInfo[idx][fVehType][2] = strval(finfo[29]);
FamInfo[idx][fVehType][3] = strval(finfo[30]);
FamInfo[idx][fVehType][4] = strval(finfo[31]);
FamInfo[idx][fVehCoX][0] = floatstr(finfo[32]);
FamInfo[idx][fVehCoY][0] = floatstr(finfo[33]);
FamInfo[idx][fVehCoZ][0] = floatstr(finfo[34]);
FamInfo[idx][fVehCoX][1] = floatstr(finfo[35]);
FamInfo[idx][fVehCoY][1] = floatstr(finfo[36]);
FamInfo[idx][fVehCoZ][1] = floatstr(finfo[37]);
FamInfo[idx][fVehCoX][2] = floatstr(finfo[38]);
FamInfo[idx][fVehCoY][2] = floatstr(finfo[39]);
FamInfo[idx][fVehCoZ][2] = floatstr(finfo[40]);
FamInfo[idx][fVehCoX][3] = floatstr(finfo[41]);
FamInfo[idx][fVehCoY][3] = floatstr(finfo[42]);
FamInfo[idx][fVehCoZ][3] = floatstr(finfo[43]);
FamInfo[idx][fVehCoX][4] = floatstr(finfo[44]);
FamInfo[idx][fVehCoY][4] = floatstr(finfo[45]);
FamInfo[idx][fVehCoZ][4] = floatstr(finfo[46]);
FamInfo[idx][fVehRot][0] = strval(finfo[47]); // Rot
FamInfo[idx][fVehRot][1] = strval(finfo[48]);
FamInfo[idx][fVehRot][2] = strval(finfo[49]);
FamInfo[idx][fVehRot][3] = strval(finfo[50]);
FamInfo[idx][fVehRot][4] = strval(finfo[51]);
FamInfo[idx][fVehCol1][0] = strval(finfo[52]); // Colors
FamInfo[idx][fVehCol1][1] = strval(finfo[53]);
FamInfo[idx][fVehCol1][2] = strval(finfo[54]);
FamInfo[idx][fVehCol1][3] = strval(finfo[55]);
FamInfo[idx][fVehCol1][4] = strval(finfo[56]);
FamInfo[idx][fVehCol2][0] = strval(finfo[57]);
FamInfo[idx][fVehCol2][1] = strval(finfo[58]);
FamInfo[idx][fVehCol2][2] = strval(finfo[59]);
FamInfo[idx][fVehCol2][3] = strval(finfo[60]);
FamInfo[idx][fVehCol2][4] = strval(finfo[61]);
if(FamInfo[idx][fSafeX] != 0 && FamInfo[idx][fSafeY] != 0 && FamInfo[idx][fSafeZ] != 0)
{
FamInfo[idx][fPickup] = CreateDynamicPickup(1239, 1, FamInfo[idx][fSafeX], FamInfo[idx][fSafeY], FamInfo[idx][fSafeZ], -1);
format(string, sizeof(string), "%s's Safe", FamInfo[idx][fName]);
FamInfo[idx][fText] = CreateDynamic3DTextLabel(string, COLOR_WHITE, FamInfo[idx][fSafeX], FamInfo[idx][fSafeY], FamInfo[idx][fSafeZ]+0.3, 15);
}
for(new i=0; i<5; i++)
{
if(FamInfo[idx][fVehType][i])
{
FamInfo[idx][fVeh][i] = CreateVehicle(FamInfo[idx][fVehType][i], FamInfo[idx][fVehCoX][i], FamInfo[idx][fVehCoY][i], FamInfo[idx][fVehCoZ][i], FamInfo[idx][fVehRot][i], FamInfo[idx][fVehCol1][i], FamInfo[idx][fVehCol2][i], 1200);
ChangeVehicleColor(FamInfo[idx][fVeh][i], FamInfo[idx][fVehCol1][i], FamInfo[idx][fVehCol2][i]);
Fam[FamInfo[idx][fVeh][i]] = idx;
}
}
idx++;
}
}
print("Families loaded successfully.");
return 1;
}