SA-MP Forums Archive
Saving??? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Saving??? (/showthread.php?tid=578035)



Saving??? - bgedition - 16.06.2015

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



Re: Saving??? - bgedition - 16.06.2015

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


AW: Saving??? - Mencent - 16.06.2015

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


Re: Saving??? - bgedition - 16.06.2015

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