Saving???
#1

Hey all,
I have an issue with saving my zone's info. I think it is very simple issue. But I can't find it. Help, please.

Код:
stock SaveGangZones() {
    new File:fHandle, fPATH[45], fLine[256], ZoneIDs;
    format(fPATH, sizeof(fPATH), "%s%s.txt", GANG_ZONE_PATH, GANG_ZONE_FILE);
    fHandle = fopen(fPATH, io_write);
    if(fexist(fPATH)) {
        if(fHandle) {
            for(new ZoneID; ZoneID < MAX_GANG_ZONES; ZoneID ++) {
                format(fLine, sizeof(fLine), "%d, %s, %d, %s, %s, %.4f, %.4f, %.4f, %.4f\r\n",
                ZoneInfo[ZoneID][ZONE_ID], ZoneInfo[ZoneID][ZONE_NAME], ZoneInfo[ZoneID][ZONE_OWNER_ID], ZoneInfo[ZoneID][ZONE_OWNER],
                ZoneInfo[ZoneID][ZONE_COLOR], ZoneInfo[ZoneID][ZONE_POS][MinX], ZoneInfo[ZoneID][ZONE_POS][MinY], ZoneInfo[ZoneID][ZONE_POS][MaxX],
                ZoneInfo[ZoneID][ZONE_POS][MaxY]);
                fwrite(fHandle, fLine);
                ZoneIDs += 1;
            }
            fclose(fHandle);
            printf("Number of gang zones saved: %d", ZoneIDs);
        }
    }
    return 1;
}
The problem is when it is saving it's saving 150 new lines with zero parameters. And is there any way to make the save with sscanf? Because I am using sscanf for the load part. Help again, please.

BGEdition
Reply
#2

Hey again, can someone help me, please? Sorry for the bumping I need this!
Reply
#3

Hello!

Can you try this version?
PHP код:
stock SaveGangZones()
{
    new 
File:fHandle,fPATH[45],fLine[256],ZoneIDs;
    
format(fPATH,sizeof fPATH,"%s%s.txt",GANG_ZONE_PATH,GANG_ZONE_FILE);
    
fHandle fopen(fPATH,io_write);
    if(
fexist(fPATH))
    {
        if(
fHandle)
        {
            for(new 
ZoneID;ZoneID MAX_GANG_ZONES;ZoneID ++)
            {
                if(!
strlen(ZoneInfo[ZoneID][ZONE_NAME]))continue;
                
format(fLine,sizeof fLine,"%d,%s,%d,%s,%s,%0.4f,%0.4f,%0.4f,%0.4f\r\n",
                
ZoneInfo[ZoneID][ZONE_ID],ZoneInfo[ZoneID][ZONE_NAME],ZoneInfo[ZoneID][ZONE_OWNER_ID],ZoneInfo[ZoneID][ZONE_OWNER],
                
ZoneInfo[ZoneID][ZONE_COLOR],ZoneInfo[ZoneID][ZONE_POS][MinX],ZoneInfo[ZoneID][ZONE_POS][MinY],ZoneInfo[ZoneID][ZONE_POS][MaxX],
                
ZoneInfo[ZoneID][ZONE_POS][MaxY]);
                
fwrite(fHandle,fLine);
                
ZoneIDs += 1;
            }
            
fclose(fHandle);
            
printf("Number ob gang zones saved: %i",ZoneIDs);
        }
    }
    return 
1;

- Mencent
Reply
#4

Just tried it and now the file is empty, its not saving anything
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)