fwrite issue
#1

Hey, bascially I am making a straight write in this one area

pawn Код:
new fname[100];
        format(fname,100,"/Houses/%i.cfg",hid);
        new File:hfile = fopen(fname,io_write);
        fclose(hfile);         
        hfile = fopen(fname,io_append);
        new FileInfo[100][3];
        format(FileInfo[0],100,"Unowned \n"); fwrite(hfile,FileInfo[1]);
        format(FileInfo[1],100,"IconX=%f\r\n",hx); fwrite(hfile,FileInfo[2]);
        format(FileInfo[2],100,"IconY=%f\r\n",hy); fwrite(hfile,FileInfo[3]);
        format(FileInfo[3],100,"IconZ=%f\r\n",hz); fwrite(hfile,FileInfo[4]);
        fclose(hfile);
But it comes out in the file like this:
Quote:

wned
nX=-2521.163574
nY=-623.503662
nZ=132.772262

The word UNOWNED sort of doesn't appear fully.
Anyone know why?
Reply
#2

try this:

pawn Код:
new fname[100]; // Tip: Don't use 100, because i think a filename will never be bigger then 100 chars.
format(fname,100,"/Houses/%i.cfg",hid);
new File:hfile = fopen(fname,io_write);
fclose(hfile)
hfile = fopen(fname,io_append);
new FileInfo[3][100]; // You had this wrong, You got 100x string of 3 chars and it must be 3x string of 100 chars
format(FileInfo[0],100,"Unowned \n"); fwrite(hfile,FileInfo[0]); // Must be FileInfo[0]
format(FileInfo[1],100,"IconX=%f\r\n",hx); fwrite(hfile,FileInfo[1]); // Must be FileInfo[1]
format(FileInfo[2],100,"IconY=%f\r\n",hy); fwrite(hfile,FileInfo[2]); // Must be FileInfo[2]
format(FileInfo[3],100,"IconZ=%f\r\n",hz); fwrite(hfile,FileInfo[3]); // Must be FileInfo[3]
fclose(hfile);
Here, Comments are in the script. This script will work, i think.

Warning: Not compiled or tested
Reply
#3

How did I not see that! thank you now I feel embarrassed
Reply
#4

No Problemo :P
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)