SA-MP Forums Archive
fopen returns NULL - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: fopen returns NULL (/showthread.php?tid=263970)



fopen returns NULL - Roko_foko - 24.06.2011

I've got a problem:

The program doesn't want to create a new file. the part of the colde looks like:
pawn Код:
if(!fexist(SettingFile))
{
    dini_Create(SettingFile);
    dini_IntSet(SettingFile, "PocketMoney", 1000);
    dini_IntSet(SettingFile, "AnnounceSeconds", 3);
    dini_IntSet(SettingFile, "PassMin", 3);
    dini_IntSet(SettingFile, "PassMax", 15);
}
I am sure that file doesn't exist.
I have tried to figure out the problem and I realised the problem comes here(in dini_Create):
pawn Код:
stock dini_Create(filename[]) {
    if (fexist(filename))
    {
        return false;
    }
    new File:fhnd;
    fhnd=fopen(filename,io_write);
    if (fhnd) // IT DOESN'T ENTER THIS if clause <-----
    {
        fclose(fhnd);
        return true;
    }
    return false;
}
So fopen returns NULL.
I don't know how to fix that.
Btw. I have reinstalled my computer and now it doesn't work(but before it worked perfectly)
I have aloso some dini_Create which work perfectly.
I would be very greatful if you can help me.

PS: Sorry for that codes, I dunno how to put "pawn code console"


Re: fopen returns NULL - Wesley221 - 24.06.2011

Код:
[ pawn ]code between this, do NOT use the spaces between it ofcourse[ / pawn ]
Did you format the SettingFile? If so: show us the format


Re: fopen returns NULL - Roko_foko - 24.06.2011

#define SettingFile "AdminScript/Settings/MainSettings.ini"
It doesn't need format(), I thinik.
Aswell, I've seen if the problem appears in dev c++ you can easily find the reason with perror();


Re: fopen returns NULL - Wesley221 - 24.06.2011

Yeah sorry, forgot it didnt need a name in it
Did you made the folders "AdminScript/Settings" in your scriptfils?


Re: fopen returns NULL - Roko_foko - 24.06.2011

Yea, otherwise server would chrash, I think. It didn't crash. Now I checked if I spelled it right.


Re: fopen returns NULL - Roko_foko - 24.06.2011

Yes you were right, my Folder was called MainSettings, not Settings. Thank you very much!!!