Problem with save gang zone
#1

PHP код:
forward SaveTurfs();
public 
SaveTurfs()
{
    new 
idx;
    new 
Filefile3;
    while (
idx sizeof(turfs))
    {
        new 
coordsstring[512];
        
format(coordsstringsizeof(coordsstring), "%d|%s|%s|%d|%d|%d|%d|[%s|%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)
        {
            
file3 fopen("Factions/Turfs.ini"io_write);
        }
        else
        {
            
file3 fopen("Factions/Turfs.ini"io_append);
        }
        
fwrite(file3coordsstring);
        
idx++;
        
fclose(file3);
    }
    return 
1
}
Problem is save team own zone TEAM_GROVE and colors. I use %s %d and dont work. Help me please
Reply
#2

Ouch, you are reopening a file for each turf? Open the file just once, then work on it.

pawn Код:
forward SaveTurfs();
public SaveTurfs()
{
    new
        File:file = fopen("Factions/Turfs.ini", io_write)
    ;

    //Failed to open file
    if (!file) return 0;

    for(new idx = 0; idx != sizeof(turfs); ++idx)
    {
        new coordsstring[512];
        format(coordsstring, sizeof(coordsstring), "%d|%s|%s|%d|%d|%d|%d|%s|%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]);
        fwrite(file, coordsstring);
    }

    fclose(file);

    return 1;  
}
Could you show what is in your file after running this?
Reply
#3

How to save
TEAM_GROVE and
COLOR_GREEN
|%s|%d| dont work
Reply
#4

I asked about file contents. Also, what does your TEAM_GROVE (define I guess) contains? A number, or a string?
Reply
#5

my turf system,
{ 0, "Grove Street", "LS", 2440.60, -1629.70, 2540.90, -1723.70, COLOR_GREEN, TEAM_GROVE, -1, 0, 0, 0, 0},
Color green and team_grove dont save
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)