30.03.2015, 19:25
can give me code please help please
I dont save Turf Owner and Turf Color help me guys
PHP код:
forward LoadTurfs();
public LoadTurfs()
{
new arrCoords[14][256];
new strFromFile2[256];
new File: file = fopen("Factions/Turfs.ini", io_read);
if (file)
{
new playerid;
while (playerid < sizeof(turfs))
{
fread(file, strFromFile2);
split(strFromFile2, arrCoords, '|');
turfs[playerid][turfID] = strval(arrCoords[0]);
strmid(turfs[playerid][turfName], arrCoords[1], 0, strlen(arrCoords[0]), 255);
strmid(turfs[playerid][cityName], arrCoords[2], 0, strlen(arrCoords[0]), 255);
turfs[playerid][zMinX] = strval(arrCoords[3]);
turfs[playerid][zMinY] = strval(arrCoords[4]);
turfs[playerid][zMaxX] = strval(arrCoords[5]);
turfs[playerid][zMaxY] = strval(arrCoords[6]);
strmid(turfs[playerid][TurfColor], arrCoords[7], 0, strlen(arrCoords[0]), 255);
strmid(turfs[playerid][TurfOwner], arrCoords[8], 0, strlen(arrCoords[0]), 255);
turfs[playerid][TurfAttacker] = strval(arrCoords[9]);
turfs[playerid][TurfKills] = strval(arrCoords[10]);
turfs[playerid][TurfAttackKills] = strval(arrCoords[11]);
turfs[playerid][TurfWarStarted] = strval(arrCoords[12]);
turfs[playerid][MIT] = strval(arrCoords[13]);
playerid++;
}
fclose(file);
}
return 1;
}
PHP код:
forward SaveTurfs();
public SaveTurfs()
{
new idx;
new File: file2;
while (idx < sizeof(turfs))
{
new coordsstring[512];
format(coordsstring, sizeof(coordsstring), "%d|%s|%s|%d|%d|%d|%d|||%d|%d|%d|%d|%d___________________\n",
turfs[idx][turfID],
turfs[idx][turfName],
turfs[idx][cityName],
turfs[idx][zMinX],
turfs[idx][zMinY],
turfs[idx][zMaxX],
turfs[idx][zMaxY],
turfs[idx][TurfColor],
turfs[idx][TurfOwner],
turfs[idx][TurfAttacker],
turfs[idx][TurfKills],
turfs[idx][TurfAttackKills],
turfs[idx][TurfWarStarted],
turfs[idx][MIT]);
if(idx == 0)
{
file2 = fopen("Factions/Turfs.ini", io_write);
}
else
{
file2 = fopen("Factions/Turfs.ini", io_append);
}
fwrite(file2, coordsstring);
idx++;
fclose(file2);
}
return 1;
}