Issue creating file
#1

I'm making a multisectional log and I've hit a snag with writing a file.

right now it's in 2 parts, general log and kills-deaths log. General Log works just fine, but in the same exact directory, Kills-Deaths causes a server crash, I can write the same thing in it, I can shorten the name, but it still crashes when I try to create the file in the same directory.

pawn Code:
new FileName[150];
      new month[3],day,year;
      GetMonthName(month);
      getdate(year,day,day);
      format(FileName,sizeof(FileName),"User Files/%s/%s-%d-%d/General.ini",PlayerName,month,day,year);
      new File:file = fopen(FileName,io_append);
     
        new string[300];
        new hour,minute,second;
        gettime(hour,minute,second);
        format(string,sizeof(string),"[%02d:%02d:%02d] %s kills %s with %s\n",hour,minute,second,SenderName,PlayerName,text);
        fwrite(file,string);
        fclose(file);
that works
pawn Code:
new DeathFile[150];
        format(DeathFile,sizeof(DeathFile),"User Files/%s/%s-%d-%d/Kills-Deaths.ini",PlayerName,month,day,year);
      new File:file1 =fopen(DeathFile,io_append);
        new weaponname[20];
        new Float:tmp,Float:tmp2,Float:tmp3,Float:tmp4;
        gettime(hour,minute,second);
        format(string,sizeof(string),"-----[%02d:%02d:%02d]-----\n",hour,minute,second);
        fwrite(file1,string);
that doesn't...

why?

EDIT** If I remove the first one, the second works fine... What the forizzle??
Reply
#2

Hmm, I split up the files by putting the second into a separate public function and it works now.

Does that count as a pawn bug?
Reply
#3

Quote:
Originally Posted by SilentHuntR
Hmm, I split up the files by putting the second into a separate public function and it works now.

Does that count as a pawn bug?
No it counts as incorrect scripting
Reply
#4

Want to elaborate on that?

I hadn't done anything wrong, I could run but not the other, no matter which one. They both had variables to run off of they just could not run consecutively.

EDIT** It may be the fact I'm running the server on my laptop for testing, but I assure you it is not my scripting. I've re-enacted the bug 3 more times in different situations.
Reply
#5

Hi there,

SA-MP is not able to create new directories. So you can't use special things such as dates in a folder, you can in the file name, but not in the folder name as it would be dynamic and you would need to create the folder yourself each time you start the server.

Have fun scripting.

Kind regards,

Francis Morissette
SA-MP Scripter
http://sa-mp.com
Reply
#6

Yeah I use YSF's plugin which has directory creating functions

Have fun scripting.
Reply
#7

Quote:
Originally Posted by SilentHuntR
Have fun scripting.
Hi there,

Hehe. ^^

Have fun scripting.

Kind regards,

Francis Morissette
SA-MP Scripter
http://sa-mp.com
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)