fwrite and fread problems -
Johanson24 - 08.05.2013
Alright so the basic code is something like this-..
Код:
if(!fexist("houses.cfg")) return 1;
new
szFileStr[1024],
sscanf(szFileStr, "p<|>iiis[24]ffffffffiiiiiiiiiiiiiiiiiffi",
HouseInfo[iIndex][hOwned],
HouseInfo[iIndex][hLevel],
HouseInfo[iIndex][hHInteriorWorld],
HouseInfo[iIndex][hOwner],
HouseInfo[iIndex][hExteriorX],
HouseInfo[iIndex][hExteriorY],
HouseInfo[iIndex][hExteriorZ],
HouseInfo[iIndex][hExteriorR],
HouseInfo[iIndex][hInteriorX],
HouseInfo[iIndex][hInteriorY],
HouseInfo[iIndex][hInteriorZ],
HouseInfo[iIndex][hInteriorR],
HouseInfo[iIndex][hLock],
HouseInfo[iIndex][hRentable],
HouseInfo[iIndex][hRentFee],
HouseInfo[iIndex][hValue],
HouseInfo[iIndex][hSafeMoney],
HouseInfo[iIndex][hPot],
HouseInfo[iIndex][hCrack],
HouseInfo[iIndex][hMaterials],
HouseInfo[iIndex][hWeapons][0],
HouseInfo[iIndex][hWeapons][1],
HouseInfo[iIndex][hWeapons][2],
HouseInfo[iIndex][hWeapons][3],
HouseInfo[iIndex][hWeapons][4],
HouseInfo[iIndex][hGLUpgrade],
HouseInfo[iIndex][hPickupID],
HouseInfo[iIndex][hCustomInterior],
HouseInfo[iIndex][hCustomExterior],
HouseInfo[iIndex][hExteriorA],
HouseInfo[iIndex][hInteriorA]
The load is something like this..
Код:
stock SaveHouses()
{
new
szFileStr[1024],
What exactly does the szFileStr mean now I know that it means the amount of things it writes and loads but my question is how do I find how much it loads. For example, is it the amount of characters on one line like %d or is it the %d and the "|" sign. Thanks!
Re: fwrite and fread problems -
Bakr - 08.05.2013
With the code you posted alone, it has no actual use. I'd assume in action it would simply be the buffer that stores the information read from the file, which is then parsed by sscanf.
Re: fwrite and fread problems -
IceCube! - 08.05.2013
Example...
%s | %i | %s (HouseName, Price, Owner)
Max Housename size - logical 50 - 100 characters.
Price - 9 Characters.
Owner - 24 characters
100 + 9 + 24 = 133, just use this method most are predefined if your script is made clearly.. I often use my #defies and let the script do the maths...
new string[MAX_PLAYER_NAME * 2 + 8];
EDIT: I forgot to add 3 for each pace as spaces and | count, therefore the number for the example is 139.
Re: fwrite and fread problems -
Johanson24 - 08.05.2013
Alright so say I was to add another |%d a basic [hLockLevel] which ranges from 0 to 3. How much should I increase the characters to? I tried doing 1025 and 1026 and it just fucks up the saving.
I can provide the code if you like.
Re: fwrite and fread problems -
Johanson24 - 08.05.2013
Nah it does, it's a dynamic house system that can make houses and edit them IN-GAME and whatnot. The question is why when I up the string to 1025 it fucks up the file that it is saved in.
Re: fwrite and fread problems -
IceCube! - 08.05.2013
A string cannot be bigger than 1024... Look for the function strcat on SAMP Wiki...
https://sampwiki.blast.hk/wiki/Strcat
HOwever this is why people use more modern systems such as Y_INI so each data line is one thing yet is still reasonably quick.
Re: fwrite and fread problems -
Bakr - 08.05.2013
Quote:
Originally Posted by IceCube!
A string cannot be bigger than 1024
|
How did you come about that?
Re: fwrite and fread problems -
IceCube! - 08.05.2013
Quote:
Originally Posted by Bakr
How did you come about that?
|
A birdie told me when I started scripting, therefore I have always followed that rule and if its wrong I now have ALOT of work to do fixing this in my modes...
By this I ment one format could only convert 1024 then you needed to do an strcat to join the two 1024s together if they were the same length to bond into a [2048]
EDIT: Convert = Cover...
Re: fwrite and fread problems -
Johanson24 - 08.05.2013
Quote:
Originally Posted by IceCube!
A birdie told me when I started scripting, therefore I have always followed that rule and if its wrong I now have ALOT of work to do fixing this in my modes...
By this I ment one format could only convert 1024 then you needed to do an strcat to join the two 1024s together if they were the same length to bond into a [2048]
|
Can someone confirm this? That would make sense to be honest.
Re: fwrite and fread problems -
Bakr - 08.05.2013
Ah, for format(), yeah, the max characters seem to be 1024.