SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Plugin Development

Reply
 
Thread Tools Display Modes
Old 25/06/2012, 07:22 PM   #1
Terminator3
Big Clucker
 
Terminator3's Avatar
 
Join Date: Oct 2009
Posts: 70
Reputation: 25
Default [REL]tfile 3.1 Best ini files system #update 16.07.12

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
  • 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

Return numbers of getting values 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

Returns true if all is correct


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

Returns true if all is correct


fDeleteData(const file[], const key[])
Deletes the data from the file
  • const file[] - file name
  • const key[] - key or list of keys separated by ,

Returns true if all is correct


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 ,

For one key returns true/false, for more returns number that represented by bits which one key exist or not


fCreate(const file[], const string[])
Creates a file and saves something to him
  • const file[] - file name
  • const string[] - text to save in file

Returns true if all is correct

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 '-'

Returns true if all is correct


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

Returns true if all is correct



*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);
and in file we find:
Quote:
Money=10000
Pass=mama
HP=100.0
sex=F
and the same to get:
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);

<i> or <d> - number
<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");
after that file looks:
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);

Download:
tfile3.inc; Mirror
tfile.dll; Mirror
tfile.so; Mirror

Source Code; Mirror
__________________
sorry for my bad English

Last edited by Terminator3; 16/07/2012 at 05:19 PM.
Terminator3 is offline   Reply With Quote
Old 25/06/2012, 07:26 PM   #2
zgintasz
Huge Clucker
 
Join Date: Oct 2011
Posts: 367
Reputation: 11
Default Re: [REL]tfile 3.0 Best file system!

Nice ! I want to see some speed test results.
EDIT: hehe, first post
zgintasz is offline   Reply With Quote
Old 25/06/2012, 07:37 PM   #3
Littlehelper
Gangsta
 
Littlehelper's Avatar
 
Join Date: Nov 2011
Location: 420
Posts: 946
Reputation: 178
Default Re: [REL]tfile 3.0 Best file system!

Looks nice, gonna test it.
Littlehelper is offline   Reply With Quote
Old 25/06/2012, 07:58 PM   #4
TheArcher
High-roller
 
TheArcher's Avatar
 
Join Date: Dec 2009
Location: Home
Posts: 2,334
Reputation: 251
Default Re: [REL]tfile 3.0 Best file system!

Looks a nice one, can you do some tests please. I'm so curious.
__________________
TheArcher is offline   Reply With Quote
Old 25/06/2012, 08:13 PM   #5
Face9000
Banned
 
Join Date: Jan 2010
Location: Pigland
Posts: 3,351
Reputation: 190
Default Re: [REL]tfile 3.0 Best file system!

Nice job.
Face9000 is offline   Reply With Quote
Old 25/06/2012, 09:12 PM   #6
Vukilore
Huge Clucker
 
Vukilore's Avatar
 
Join Date: Jan 2011
Location: http://forum.sa-mp-fr.com/index.php
Posts: 300
Reputation: 110
Default Re : [REL]tfile 3.0 Best file system!

I'm waiting for a response of ******, to be sure
__________________
http://forum.sa-mp-fr.com/index.php. << here rest the french forum, in piece.
Vukilore is offline   Reply With Quote
Old 25/06/2012, 09:29 PM   #7
Terminator3
Big Clucker
 
Terminator3's Avatar
 
Join Date: Oct 2009
Posts: 70
Reputation: 25
Default Re: Re : [REL]tfile 3.0 Best file system!

Quote:
Originally Posted by Vukilore View Post
I'm waiting for a response of ******, to be sure
Everybody loves professionals


Quote:
Originally Posted by TheArcher View Post
Looks a nice one, can you do some tests please. I'm so curious.
Tests?
__________________
sorry for my bad English
Terminator3 is offline   Reply With Quote
Old 25/06/2012, 10:06 PM   #8
rVar
Big Clucker
 
Join Date: Mar 2012
Location: Somewhere
Posts: 57
Reputation: 1
Default Re: [REL]tfile 3.0 Best file system!

Awesome! Waiting for speed results comparing this with y_ini.
rVar is offline   Reply With Quote
Old 25/06/2012, 10:25 PM   #9
Terminator3
Big Clucker
 
Terminator3's Avatar
 
Join Date: Oct 2009
Posts: 70
Reputation: 25
Default Re: [REL]tfile 3.0 Best file system!

Quote:
Originally Posted by rVar View Post
Awesome! Waiting for speed results comparing this with y_ini.
It's hard to tell, in y_ini you uses one function to set one value to file, it's easy to test the speed, you just make big loop and count the time for example 10000 runs of function, then just divide time by 10000

Here you have one function and you can write big number of arguments but more time will take loop for all arguments in function then others things, and you will never set/get so many arguments to/from file, so if you divide by numbers of arguments you get more time for checking arguments, searching then, than normally run time of function
__________________
sorry for my bad English
Terminator3 is offline   Reply With Quote
Old 25/06/2012, 10:34 PM   #10
TheArcher
High-roller
 
TheArcher's Avatar
 
Join Date: Dec 2009
Location: Home
Posts: 2,334
Reputation: 251
Default Re: Re : [REL]tfile 3.0 Best file system!

Quote:
Originally Posted by Terminator3 View Post
Tests?
Quote:
Originally Posted by rVar View Post
Waiting for speed results comparing this with y_ini.
4 char
__________________
TheArcher is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
File system? ElChapoGuzman Help Archive 7 18/03/2011 06:21 AM
File system Steve M. Help Archive 6 11/01/2011 11:22 AM
[FilterScript] [FS] File Cars - Vehicle File Storing System! lavamike Filterscripts 11 27/08/2010 11:02 PM
File System ScottCFR Help Archive 3 03/04/2010 04:36 PM


All times are GMT. The time now is 11:11 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.