Bueno aqui dejo paso a paso lo que hice para agregar dicho sistema. Tambien intente poner el sistema de puertas/salidas dinбmicas, como dije todo perfecto compila pero a la hora de cerrar el server no se guarda nada. Bueno aqui dejo lo que hice.
Defino los skins de las familias:
Код:
// Family skins
new pskin[MAX_PLAYERS], fskin[MAX_PLAYERS];
new Fam[MAX_VEHICLES];
new Family[MAX_PLAYERS];
El enum de las familias:
Код:
enum famInfo
{
fTaken,
fName[32],
fMOTD[64],
fColor,
fLeader[MAX_PLAYER_NAME],
fMembers,
Float:fSafeX,
Float:fSafeY,
Float:fSafeZ,
fMoney,
fMats,
fWeed,
fCrack,
fRank1[32],
fRank2[32],
fRank3[32],
fRank4[32],
fRank5[32],
fRank6[32],
fSkins[7],
fStrikes,
Text3D:fText,
fPickup,
fVeh[5],
fVehType[5],
Float:fVehCoX[5],
Float:fVehCoY[5],
Float:fVehCoZ[5],
fVehCol1[5],
fVehCol2[5],
Float:fVehRot[5]
}
new FamInfo[MAX_FAMILIES][famInfo];
Los stock que Guardas las familias:
Код:
"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.");
}
Stock que carga la familia:
Код:
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;
}
En gamemode Init coloco para que Carguen las familias:
En gamemode Exit coloco la funciуn que guarda las familias al cerrar el server:
[code]SaveFamilies();[/CODE
Un stock que crear el guardado de las familias:
Код:
stock fcreate(filename[])
{
if (fexist(filename)) return false;
new File:fhnd;
fhnd=fopen(filename,io_write);
if (fhnd) {
fclose(fhnd);
return true;
}
return false;
}
Por ъltimo el comando para crear las familias:
Код:
CMD:fcreate(playerid, params[])
{
new string[128], playerb, idx;
if(JugadorInfo[playerid][jAdmin] < 4 && !JugadorInfo[playerid][jGangMod]) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
if(sscanf(params, "ui", playerb, idx)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /fcreate [playerid] [slot]");
if(idx < 1 || idx > 10) return SendClientMessage(playerid, COLOR_GREY, "Families are between 1 and 10.");
if(FamInfo[idx][fTaken]) return SendClientMessage(playerid, COLOR_GREY, "Family slot is already in use.");
FamInfo[idx][fTaken] = 1;
FamInfo[idx][fMembers] ++;
JugadorInfo[playerb][jFam] = idx;
JugadorInfo[playerb][jFamRank] = 6;
FamInfo[idx][fStrikes] = 0;
format(FamInfo[idx][fLeader], MAX_PLAYER_NAME, "%s", RPN(playerb));
format(string, sizeof(string), "AdmWarn: %s has given %s family slot %d.", RPN(playerid), RPN(playerb), idx);
SendAdminMessage(COLOR_DARKRED, 1, string);
Log("logs/families.log", string);
format(string, sizeof(string), " %s has given you family slot {33AA33}%d {33CCFF}ownership.", RPN(playerid), idx);
SendClientMessage(playerb, COLOR_LIGHTBLUE, string);
return 1;
}
Bueno como dije al compilar no me tira ningъn error, No se si influye las lineas en forma que defini algo, Me ayudarнa mucho si alguien me podrнa despejar mi duda e.e