10.12.2010, 15:31
(
Последний раз редактировалось Diler; 13.12.2010 в 15:21.
Причина: Added comparison
)
Author: RPS (aka Diler)
Version: 1.0 R2
Last Update: 06.11.2010
Functions:
How to use ?
Simple code:
and...
Comparison
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
Replace number to server slots !!
Thank you for your time and sorry for my bad english
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
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; }
Код:
public OnPlayerConnect(playerid) { Read(playerid); rSetInt(playerid, "CountConnect", rGetInt(playerid, "CountConnect")+1); return 1; } public OnPlayerDisconnect(playerid) { Save(playerid); return 1; }
Код:
#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; }
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
Thank you for your time and sorry for my bad english