[Include] rFile - Faster than y_ini
#1

Author: RPS (aka Diler)
Version: 1.0 R2
Last Update: 06.11.2010

It is a fast and simple system file operations


Functions:

Код:
Read(playerid) - function read a player file (use in OnPlayerConnect/Spawn)
Save(playerid) - function saves the data players (use in OnPlayerDisconnect)
Delete(playerid) - function removes the file player (use after Save)
DeleteOption(playerid, option[]) - function removes option in player file

ReadFile(const filename[], const ID) - function read a file
SaveFile(const filename[], const ID) - function save a file
DeleteFile(filename[]) - function removes the file
DeleteFileOption(const ID, option[]) - function removes option in file

rSetStr(playerid, option[], definition[]) - function save string to file
rSetInt(playerid, option[], definition) - functtion save integer to file
rSetFloat(playerid, option[], Float:definition) - function save float to file

rGetStr(playerid, option[]) - function returns the definitions of the options
rGetInt(playerid, option[]) - function returns the definitions of the options
rGetFloat(playerid, option[]) - function returns the definitions of the options
IsSet(playerid, option[]) - function returns when it finds an option, 0 if not
How to use ?
Simple code:
Код:
#include <a_samp>
#include <rFile>

public OnFilterScriptInit()
{
    #define ID 51
    ReadFile("rFile.ini", ID);
    rSetStr(ID, "Str", "test");
    rSetInt(ID, "Int", 1);
    rSetFloat(ID, "Float", 1.234);
    printf("%s | %d | %f", rGetStr(ID, "Str"), rGetInt(ID, "Int"), rGetFloat(ID, "Float"));
    DeleteFileOption(ID, "Str");
    SaveFile("rFile.ini", ID);
    return 1;
}
and...
Код:
public OnPlayerConnect(playerid)
{
    Read(playerid);
    rSetInt(playerid, "CountConnect", rGetInt(playerid, "CountConnect")+1);
    return 1;
}

public OnPlayerDisconnect(playerid)
{
    Save(playerid);
    return 1;
}
Comparison
Код:
#include <a_samp> 
#include <YSI\y_ini> 
#include <rFile> 

#define MAX 1000 
public OnFilterScriptInit() 
{ 
    new 
        str[128], 
        s = GetTickCount(); 

    new INI:tt = INI_Open("y_ini.ini"); 
    for(new i; i < MAX; i++) 
    { 
       format(str, sizeof str, "test%d", i); 
       INI_WriteString(tt, str, "test"); 
    } 
    INI_Close(tt); 
    printf("[Y_INI]: %d", GetTickCount()-s); 

    s = GetTickCount(); 
    ReadFile("rFile.ini", 50); 
    for(new i; i < MAX; i++) 
    { 
       format(str, sizeof str, "test%d", i); 
       rSetStr(50, str, "test"); 
    } 
    SaveFile("rFile.ini", 50); 
    printf("[R_FILE]: %d", GetTickCount()-s); 
    return 1; 
}
Result:
The first time - 458 (y_ini) vs 204 (rFile) [ms]
The second time - 718 (y_ini) vs 87 (rFile) [ms]

Download
Pastebin -> http://pastebin.com/4DmWp8Bk


Код:
#define MAX_PLAYERSS 50
Replace number to server slots !!

Thank you for your time and sorry for my bad english
Reply


Messages In This Thread
rFile - Faster than y_ini - by Diler - 10.12.2010, 15:31
Re: rFile - Faster than y_ini - by Wennicke - 10.12.2010, 15:34
Re: rFile - Faster than y_ini - by Diler - 10.12.2010, 15:36
Re: rFile - Faster than y_ini - by GaGlets(R) - 10.12.2010, 15:39
Re: rFile - Faster than y_ini - by Gavibro - 10.12.2010, 15:44
Re: rFile - Faster than y_ini - by Grim_ - 10.12.2010, 15:45
Re: rFile - Faster than y_ini - by RyDeR` - 10.12.2010, 15:54
Re: rFile - Faster than y_ini - by Diler - 10.12.2010, 15:57
Re: rFile - Faster than y_ini - by Kwarde - 10.12.2010, 16:11
Re: rFile - Faster than y_ini - by RyDeR` - 10.12.2010, 16:14

Forum Jump:


Users browsing this thread: 2 Guest(s)