25.06.2012, 19:22
(
Last edited by Terminator3; 16/07/2012 at 05:19 PM.
)
I present you, my new plugin named tfile 3.0, is based on C++ fstream and it's better than standard file.inc (more characters available)
Why it is better then others file systems?
Almost all to set one value to file must use one function, in my plugin you use one function to save or get unlimited number of data
Functions:
fGetData(const file[], const format[], {Float,_}:...)
Get the data from the file
fSaveData(const file[], const format[], {Float,_}:...)
Saves data to the file
fAddData(const file[], const string[], bool:exist = false)
Add data to the file
fDeleteData(const file[], const key[])
Deletes the data from the file
fKeyExist(const file[], const key[])
Check if key or keys (max 32) exist in file
fCreate(const file[], const string[])
Creates a file and saves something to him
Additional functions
fConvertTags(const file[], oldtag, newtag)
Convert diverting char
fChangeConfig(keytab = '=', nicelook = false, ignorekeycase = false, keysize = 30, linesize = 256)
*What is the format? i explain the example
and in file we find:
and the same to get:
<i> or <d> - number
<s> - string, text
<f> - float value
<c> - one char
after that file looks:
Download:
tfile3.inc; Mirror
tfile.dll; Mirror
tfile.so; Mirror
Source Code; Mirror
Why it is better then others file systems?
Almost all to set one value to file must use one function, in my plugin you use one function to save or get unlimited number of data
Functions:
fGetData(const file[], const format[], {Float,_}:...)
Get the data from the file
- const file[] - name of a file
- const format[] - list of keys and value types to get from file, see below*
- {Float,_}:... - arguments to save data from file
fSaveData(const file[], const format[], {Float,_}:...)
Saves data to the file
- const file[] - name of a file
- const format[] - the same as fGetData*
- {Float,_}:... - arguments (values) to save in the file
fAddData(const file[], const string[], bool:exist = false)
Add data to the file
- const file[] - name of a file
- const string[] - text to save in file
- bool:exist = false - file must exist, default no
fDeleteData(const file[], const key[])
Deletes the data from the file
- const file[] - file name
- const key[] - key or list of keys separated by ,
fKeyExist(const file[], const key[])
Check if key or keys (max 32) exist in file
- const file[] - file name
- const key[] - key or list of keys separated by ,
fCreate(const file[], const string[])
Creates a file and saves something to him
- const file[] - file name
- const string[] - text to save in file
Additional functions
fConvertTags(const file[], oldtag, newtag)
Convert diverting char
- const file[] - file name
- oldtag - old diverting char, for example '='
- newtag - new diverting char, for example '-'
fChangeConfig(keytab = '=', nicelook = false, ignorekeycase = false, keysize = 30, linesize = 256)
- keytab = '=' - diverting char
- nicelook = false - if true file looks "key = value" is false "key=value"
- ignorekeycase = false - whether to ignore case when searching for a key in a file
- keysize = 30 - max length of key name
- linesize = 256 - max size of one line in file
*What is the format? i explain the example
pawn Code:
new pass[24], Float:hp, sex = 'F';
GetPlayerHealth(playerid, hp);
fSaveData("test.txt", "Money<d>Pass<s>HP<f>sex<c>", GetPlayerMoney(playerid), pass, hp, sex);
Quote:
Money=10000 Pass=mama HP=100.0 sex=F |
pawn Code:
new money, pass[24], Float:hp, sex;
fGetData("test.txt", "Money<d>Pass<s>HP<f>sex<c>", money, pass, hp, sex);
SetPlayerMoney(playerid, money);
SetPlayerHealth(playerid, hp);
<s> - string, text
<f> - float value
<c> - one char
pawn Code:
new x = fKeyExist("test.txt", "Money,Score,sex,Money");
if(x & 1) // if Money exist
print("Money exist");
if(x & 2) // if Score exist
print("Score exist");
if(x & 4) // if sex exist
print("sex exist");
if(x & 8) // if Money exist
print("Money exist");
pawn Code:
fDeleteData("test.txt", "Money,sex");
Quote:
Pass=mama HP=100.0 |
pawn Code:
new str[64];
format(str, sizeof str, "Money=%d\nScore=%d\nVIP=1\n", GetPlayerMoney(playerid), GetPlayerScore(playerid));
fAddData("test.txt", str);
tfile3.inc; Mirror
tfile.dll; Mirror
tfile.so; Mirror
Source Code; Mirror