Save problem
#1

whats wrong with this "SaveFamilie"? inside scriptfiles i have a folder called "Families" and inside that i have 3 .ini files called Familie_1, Familie_2 and Familie_3.
And when i try to save the familie with
Код:
SaveFamilie( Player[playerid][Familie]);
it just prints:
Код:
Could not execute SaveFamilie(number).
What could be the problem?

Stock savefamilie:
pawn Код:
stock SaveFamilie( i )
{
    new FileName[ 21 ];
    format(FileName, sizeof(FileName), "Families/Familie_%d.ini", i);
    if(fexist(FileName) )
    {
        dini_IntSet(FileName, "Test1", Families[i][Test1]); // This is just a test it should work.
        dini_IntSet(FileName, "Test2", Families[i][Test2]); // This is just a test it should work.
        dini_IntSet(FileName, "Test3", Families[i][Test3]); // This is just a test it should work.

        printf( "[system] Familie %d saved.", i);
    }
    else
    {
        printf( "Could not execute SaveFamilie(%d).", i);
    }
}
Reply
#2

Are you sure you have the file? ("Families/Familie_%d.ini")
Reply
#3

Quote:
Originally Posted by varthshenon
Посмотреть сообщение
Are you sure you have the file? ("Families/Familie_%d.ini")
Yes i have it like this: scriptfiles/Families/And in here i have Familie_1, Familie_2, Familie_3.
I have no idea what could be wrong.
Reply
#4

Quote:
Originally Posted by [HLF]Southclaw
Посмотреть сообщение
The line
[pawn if(fexist(FileName) )[/pawn]
isn't returning because the file doesn't exist.

Check case and do some data prints [printf] to check if the variables are all right
Also make sure you have the extension right aswell [.ini]
Im gonna check up on everything.

Quote:
Originally Posted by [HLF]Southclaw
Посмотреть сообщение
And also the singular of families isn't familie, it's family.
Okaaay? i don't think thats my problem. But thanks anyway for pointing that out .
Reply
#5

Okay i changed this
pawn Код:
new FileName[ 21 ];
To this
pawn Код:
new FileName[ 31 ];
and now it saves, i guess i don't really understand that 100% then....
Reply
#6

That's the length of your string.
Reply
#7

Quote:
Originally Posted by [HLF]Southclaw
Посмотреть сообщение
Because your string length was too short, the file location didn't fit into the string, you probably ended up with something like

"Families/Familie_1.i" 21 chars, misses out the rest of the file extension

Understand now?
Oh yes thank you. That explains it all thank you .
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)