26.01.2011, 03:58
(
Последний раз редактировалось cessil; 18.12.2011 в 02:38.
)
Version 2.0
Back story:
So I was talking to Grim_ right and he's all like y u use dini when it sooo slow (but not in those words) and I was all like idk LOL so then he's like y u not use default funktons? and i was like LOL ok ill stocks that uses them and call it cini, so then I like scripted this.
How it works:
It gets the data you send to it and formats it into a string and then writes to the file.
when it reads data it gets each line individually and then checks if the line is the line you want and strips the data you want from it.
Encode Passwords:
I left the option to encode passwords up to the scripter, seeing as there's a few out there.
To encode passwords you should do the encoding before you use cini.
password = Encode(params);
cini_Register(playerid,password);
if you're doing this then you should review the defines such as cini_max_password_length
Defines:
cini_max_filename //max size of /folder/name.ini
cini_max_string //this should cover the string size of the contents of a user file
cini_max_password_length //maximum password length, use longer if you're encrypting especially whirlpool
cini_string //this should cover the longest length of a line in the user file. if you're saving 126 sized strings then you should use a bigger number
cini_file_location //folder to save accounts to
cini
pawn Код:
/*
| cessil's ini system (cini)
| version: 2.0
| date: 26/1/2010
| stocks:
| cini_Register(playerid,pass[]); creates a user file with a password
| cini_CheckAccount(playerid,pass[]); checks if an account exists
| cini_Save(playerid,typedefs[],{Float,_}:...); clears an account file and writes specified stats
| cini_Add(playerid,typedefs[],{Float,_}:...); similar to cini_Save but it adds to an existing file and doesn't clear it
| cini_Load(playerid,typedefs[],{Float,_}:...); returns data from a user file
| cini_Update(playerid,typedefs[],{Float,_}:...); replaces key values with new ones
| cini_DelKey(playerid,typedefs[],{Float,_}:...); deletes a key from a user file
| cini_DeleteAccount(playerid) deletes a user file
| cini_EscapeString(text[]); cancels out \n and \r, it's not needed if you don't save then load after registration
| cini_Create(filen[],typedefs[],{Float,_}:...); creates an empty file
| cini_FSave(filen[],typedefs[],{Float,_}:...); similar to cini_Save but first arg requires a filename not playerid and does not check if file exists first
| cini_FAdd(filen[],typedefs[],{Float,_}:...); similar to cini_Add but first arg requires a filename not playerid
| cini_FLoad(filen[],typedefs[],{Float,_}:...); similar to cini_Load but first arg requires a filename not playerid
| cini_FUpdate(filen[],typedefs[],{Float,_}:...); similar to cini_Update but first arg requires a filename not playerid
| cini_FDelKey(filen[],typedefs[],{Float,_}:...); similar to cini_DelKey but first arg requires a filename not playerid
| cini_FDelete(filen[]); deletes a file
|
| Version: 2.0
| speed improved
| escapes all saved strings
| doesn't stop on undefined typedefs
| changed cini_Delete to cini_DeleteAccount
| added cini_FDelete(filen[])
*/
#include <a_samp>
#define cini_max_filename 40 //max size of /folder/name.ini
#define cini_max_string 256 //max string for saving total data
#define cini_max_password_length 20 //maximum password length, use longer if you're encrypting especially whirlpool
#define cini_string 48 //this is like "Password=security" strings
#define cini_file_location "/accounts/" //folder to save accounts to
#define getstrarg(%1,%2) for(new x = 0; getarg(%1,x) != '\0'; x++) %2[x] = getarg(%1,x)
#define setstrarg(%1,%2) for(new x = 0; %2[x] != '\0'; x++) setarg(%1,x,%2[x])
#define cini_ES cini_EscapeString
/*==================/
/ for user accounts /
/==================*/
stock cini_GetFileName(playerid,filename[])
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
strcat(filename,cini_file_location,cini_max_filename);
strcat(filename,name,cini_max_filename);
strcat(filename,".ini",cini_max_filename);
}
stock cini_Register(playerid, pass[])
{
new filename[cini_max_filename];
cini_GetFileName(playerid,filename);
new string[cini_max_string];
if(fexist(filename)) return false;
new File:file = fopen(filename,io_write);
string = "Password=";
cini_ES(pass);
strcat(string,pass,sizeof(string));
strcat(string,"\n",sizeof(string));
fwrite(file,string);
fclose(file);
if(fexist(filename)) return true;
return false;
}
stock cini_CheckAccount(playerid)
{
new filename[cini_max_filename];
cini_GetFileName(playerid,filename);
if(!fexist(filename)) return false;
return true;
}
stock cini_CheckLogin(playerid,pass[])
{
new filename[cini_max_filename];
cini_GetFileName(playerid,filename);
if(!fexist(filename)) return false;
new string[cini_max_string];
new File:file = fopen(filename,io_read);
while(fread(file,string))
{
if(!strfind(string,"Password=",true))
{
strdel(string,0,strfind(string,"=",true)+1);
strdel(string,strlen(string)-1,strlen(string));
if(!strcmp(pass,string,false))
{
fclose(file);
return true;
}
}
}
fclose(file);
return false;
}
stock cini_Save(playerid,typedefs[],{Float,_}:...)
{
new string[cini_max_string];
new filename[cini_max_filename];
cini_GetFileName(playerid,filename);
if(!fexist(filename))
{
printf("cini error: cini_Save account %s does not exist",filename);
return false;
}
if(strlen(typedefs) != (numargs() - 2) / 2)
{
printf("cini error: cini_Save type definitions expected: %d got: %d",strlen(typedefs),(numargs() - 2) / 2);
return false;
}
new File:file = fopen(filename,io_read);
while(fread(file,string))
{
if(!strfind(string,"Password=",false)) break;
}
if(!strlen(string)) //checks the account has a password
{
fclose(file);
printf("cini error: cini_Save, Password not found for %s",filename);
return false;
}
fclose(file);
file = fopen(filename,io_write);
for(new i=0,j=strlen(typedefs);i<j;i++)
{
new tstr[cini_string];
getstrarg(2 + (i * 2),tstr);
strcat(string,tstr,sizeof(string));
strcat(string,"=",sizeof(string));
switch(typedefs[i])
{
case 'd', 'i':
{
format(string,sizeof(string),"%s%d\n",string,getarg(3 + (i * 2)));
}
case 'f':
{
format(string,sizeof(string), "%s%f\n",string,Float:getarg(3 + (i * 2)));
}
case 's':
{
new tsrt[cini_string];
getstrarg(3 + (i * 2),tsrt);
cini_ES(tsrt);
strcat(tsrt,"\n",sizeof(tsrt));
strcat(string,tsrt,sizeof(string));
}
default:
{
printf("cini error: cini_Save unknown type passed in type definitions: %c",typedefs[i]);
strcat(string,"Error Adding Data\n",sizeof(string));
}
}
}
fwrite(file,string);
fclose(file);
return true;
}
stock cini_Add(playerid,typedefs[],{Float,_}:...)
{
new string[cini_max_string];
new filename[cini_max_filename];
cini_GetFileName(playerid,filename);
if(!fexist(filename))
{
printf("cini error: cini_Add account %s does not exist",filename);
return false;
}
if(strlen(typedefs) != (numargs() - 2) / 2)
{
printf("cini error: cini_Add type definitions expected: %d got: %d",strlen(typedefs),(numargs() - 2) / 2);
return false;
}
new File:file = fopen(filename,io_read);
while(fread(file,string))
{
if(strfind(string,"Password=",true) != -1) break;
}
if(!strlen(string)) //checks the account has a password
{
fclose(file);
printf("cini error: cini_Add, Password not found for %s",filename);
return false;
}
fclose(file);
string = "";
file = fopen(filename,io_append);
for(new i=0,j=strlen(typedefs);i<j;i++)
{
new tstr[cini_string];
getstrarg(2 + (i * 2),tstr);
strcat(string,tstr,sizeof(string));
strcat(string,"=",sizeof(string));
switch(typedefs[i])
{
case 'd', 'i':
{
format(string,sizeof(string),"%s%d\n",string,getarg(3 + (i * 2)));
}
case 'f':
{
format(string,sizeof(string), "%s%f\n",string,Float:getarg(3 + (i * 2)));
}
case 's':
{
new tsrt[cini_string];
getstrarg(3 + (i * 2),tsrt);
cini_ES(tsrt);
strcat(string,tsrt,sizeof(string));
strcat(string,"\n",sizeof(string));
}
default:
{
printf("cini error: cini_Add unknown type passed in type definitions: %c",typedefs[i]);
strcat(string,"Error Adding Data\n",sizeof(string));
}
}
}
fwrite(file,string);
fclose(file);
return true;
}
stock cini_Load(playerid,typedefs[],{Float,_}:...)
{
new args = numargs() - 2;
new filename[cini_max_filename];
cini_GetFileName(playerid,filename);
if(!fexist(filename))
{
printf("cini error: cini_Load account %s does not exist",filename);
return false;
}
if(strlen(typedefs) != args / 2)
{
printf("cini error: cini_Load type definitions expected: %d got: %d",strlen(typedefs),args / 2);
return false;
}
new string[cini_string];
new File:file = fopen(filename,io_read);
while(fread(file,string))
{
for(new i=0,l=strlen(typedefs);i<l;i++)
{
new tstr[cini_string];
getstrarg(2 + (i * 2),tstr);
if(strfind(string,tstr,true) || !strlen(tstr)) continue;
strdel(string,0,strfind(string,"=",true)+1);
strdel(string,strlen(string)-1,strlen(string));
switch(typedefs[i])
{
case 'd', 'i':
{
setarg(3 + (i * 2), 0, strval(string));
}
case 'f':
{
setarg(3 + (i * 2),0,_:floatstr(string));
}
case 's':
{
setstrarg(3 + (i * 2),string);
}
default:
{
printf("cini error: cini_FLoad unknown type passed in type definitions: %c",typedefs[i]);
}
}
}
}
fclose(file);
return true;
}
stock cini_Update(playerid,typedefs[],{Float,_}:...)
{
new args = numargs() - 2, updated;
new filename[cini_max_filename];
cini_GetFileName(playerid,filename);
if(!fexist(filename))
{
printf("cini error: cini_Update account %s does not exist",filename);
return false;
}
if(strlen(typedefs) != args / 2)
{
printf("cini error: cini_Update type definitions expected: %d got: %d",strlen(typedefs),args / 2);
return false;
}
new string[cini_string];
new store[cini_max_string];
new File:file = fopen(filename,io_read);
while(fread(file,string))
{
for(new i=0,l=strlen(typedefs);i<l;i++)
{
new tstr[cini_string];
getstrarg(2 + (i * 2),tstr);
if(strfind(string,tstr,true) || !strlen(tstr)) continue;
updated++;
strdel(string,strfind(string,"=",true)+1,strlen(string));
switch(typedefs[i])
{
case 'd', 'i':
{
format(string,sizeof(string),"%s%d\n",string,getarg(3 + (i * 2)));
}
case 'f':
{
format(string,sizeof(string), "%s%f\n",string,Float:getarg(3 + (i * 2)));
}
case 's':
{
new tsrt[cini_string];
getstrarg(3 + (i * 2),tsrt);
cini_ES(tsrt);
strcat(tsrt,"\n",sizeof(tsrt));
strcat(string,tsrt,sizeof(string));
}
default:
{
printf("cini error: cini_Update unknown type passed in type definitions: %c",typedefs[i]);
}
}
}
strcat(store,string,sizeof(store));
}
if(strlen(typedefs) != updated) printf("cini warning: cini_Update attempted to update %d keys, updated %d",strlen(typedefs),updated);
fclose(file);
file = fopen(filename,io_write);
fwrite(file,store);
fclose(file);
return true;
}
stock cini_DelKey(playerid,{Float,_}:...)
{
new args = numargs() - 1, deleted;
new filename[cini_max_filename];
cini_GetFileName(playerid,filename);
if(!fexist(filename))
{
printf("cini error: cini_DelKey account %s does not exist",filename);
return false;
}
new string[cini_string];
new store[cini_max_string];
new File:file = fopen(filename,io_read);
while(fread(file,string))
{
new skip;
for(new i=0;i<args;i++)
{
new tstr[cini_string];
getstrarg(1 + i,tstr);
if(!strfind(string,tstr,true) || !strlen(tstr))
{
deleted++;
skip=1;
continue;
}
}
if(!skip) strcat(store,string,sizeof(store));
}
if(args != deleted) printf("cini warning: cini_DelKey attempted to delete %d keys, deleted %d",args,deleted);
fclose(file);
file = fopen(filename,io_write);
fwrite(file,store);
fclose(file);
return true;
}
stock cini_DeleteAccount(playerid)
{
new filename[cini_max_filename];
cini_GetFileName(playerid,filename);
if(fremove(filename)) return true;
return false;
}
stock cini_EscapeString(text[])
{
new pos;
new counter;
while(strfind(text,"\n",false,pos) != -1)
{
pos = strfind(text,"\n",false,pos);
strdel(text,pos,pos+1);
counter++;
pos++;
}
pos = 0;
counter = 0;
while(strfind(text,"\r",false,pos) != -1)
{
pos = strfind(text,"\r",false,pos);
strdel(text,pos,pos+1);
counter++;
pos++;
}
}
/*==================/
/ for other files /
/==================*/
stock cini_Create(filename[])
{
if(fexist(filename)) return false;
new File:file = fopen(filename,io_write);
fclose(file);
if(!fexist(filename)) return false;
return true;
}
stock cini_FSave(filename[],typedefs[],{Float,_}:...)
{
new string[cini_max_string];
if(strlen(typedefs) != (numargs() - 2) / 2)
{
printf("cini error: cini_FSave type definitions expected: %d got: %d",strlen(typedefs),(numargs() - 2) / 2);
return false;
}
new File:file = fopen(filename,io_write);
for(new i=0,j=strlen(typedefs);i<j;i++)
{
new tstr[cini_string];
getstrarg(2 + (i * 2),tstr);
format(string,sizeof(string),"%s%s=",string,tstr);
switch(typedefs[i])
{
case 'd', 'i':
{
format(string,sizeof(string),"%s%d\n",string,getarg(3 + (i * 2)));
}
case 'f':
{
format(string,sizeof(string), "%s%f\n",string,Float:getarg(3 + (i * 2)));
}
case 's':
{
new tsrt[cini_string];
getstrarg(3 + (i * 2),tsrt);
cini_ES(tsrt);
format(string,sizeof(string),"%s%s\n",string,tsrt);
}
default:
{
printf("cini error: cini_FSave unknown type passed in type definitions: %c",typedefs[i]);
strcat(string,"Error Adding Data\n",sizeof(string));
}
}
}
fwrite(file,string);
fclose(file);
return true;
}
stock cini_FAdd(filename[],typedefs[],{Float,_}:...)
{
new string[cini_max_string];
if(!fexist(filename))
{
printf("cini error: cini_FAdd account %s does not exist",filename);
return false;
}
if(strlen(typedefs) != (numargs() - 2) / 2)
{
printf("cini error: cini_Add type definitions expected: %d got: %d",strlen(typedefs),(numargs() - 2) / 2);
return false;
}
new File:file = fopen(filename,io_append);
for(new i=0,j=strlen(typedefs);i<j;i++)
{
new tstr[cini_string];
getstrarg(2 + (i * 2),tstr);
strcat(string,tstr,sizeof(string));
strcat(string,"=",sizeof(string));
switch(typedefs[i])
{
case 'd', 'i':
{
format(string,sizeof(string),"%s%d\n",string,getarg(3 + (i * 2)));
}
case 'f':
{
format(string,sizeof(string), "%s%f\n",string,Float:getarg(3 + (i * 2)));
}
case 's':
{
new tsrt[cini_string];
getstrarg(3 + (i * 2),tsrt);
cini_ES(tsrt);
strcat(string,tsrt,sizeof(string));
strcat(string,"\n",sizeof(string));
}
default:
{
printf("cini error: cini_FAdd unknown type passed in type definitions: %c",typedefs[i]);
strcat(string,"Error Adding Data\n",sizeof(string));
}
}
}
fwrite(file,string);
fclose(file);
return true;
}
stock cini_FLoad(filename[],typedefs[],{Float,_}:...)
{
new args = numargs() - 2;
if(!fexist(filename))
{
printf("cini error: cini_FLoad account %s does not exist",filename);
return false;
}
if(strlen(typedefs) != args / 2)
{
printf("cini error: cini_FLoad type definitions expected: %d got: %d",strlen(typedefs),args / 2);
return false;
}
new string[cini_string];
new File:file = fopen(filename,io_read);
while(fread(file,string))
{
for(new i=0,l=strlen(typedefs);i<l;i++)
{
new tstr[cini_string];
getstrarg(2 + (i * 2),tstr);
if(strfind(string,tstr,true) || !strlen(tstr)) continue;
strdel(string,0,strfind(string,"=",true)+1);
cini_ES(string);
//strdel(string,strlen(string)-1,strlen(string));
switch(typedefs[i])
{
case 'd', 'i':
{
setarg(3 + (i * 2), 0, strval(string));
}
case 'f':
{
setarg(3 + (i * 2),0,_:floatstr(string));
}
case 's':
{
setstrarg(3 + (i * 2),string);
}
default:
{
printf("cini error: cini_FLoad unknown type passed in type definitions: %c",typedefs[i]);
}
}
}
}
fclose(file);
return true;
}
stock cini_FUpdate(filename[],typedefs[],{Float,_}:...)
{
new args = numargs() - 2, updated;
if(!fexist(filename))
{
printf("cini error: cini_FUpdate account %s does not exist",filename);
return false;
}
if(strlen(typedefs) != args / 2)
{
printf("cini error: cini_FUpdate type definitions expected: %d got: %d",strlen(typedefs),args / 2);
return false;
}
new key[cini_string];
new string[cini_string];
new store[cini_max_string];
new File:file = fopen(filename,io_read);
while(fread(file,string))
{
for(new i=0,l=strlen(typedefs);i<l;i++)
{
new tstr[cini_string];
getstrarg(2 + (i * 2),tstr);
strcat(key,string,sizeof(key));
strdel(key,strfind(key,"=",true),strlen(key));
if(strcmp(tstr,key,false) || !strlen(tstr)) continue;
updated++;
strdel(string,strfind(string,"=",true)+1,strlen(string));
switch(typedefs[i])
{
case 'd', 'i':
{
format(string,sizeof(string),"%s%d\n",string,getarg(3 + (i * 2)));
}
case 'f':
{
format(string,sizeof(string), "%s%f\n",string,Float:getarg(3 + (i * 2)));
}
case 's':
{
new tsrt[cini_string];
getstrarg(3 + (i * 2),tsrt);
cini_ES(tsrt);
strcat(tsrt,"\n",sizeof(tsrt));
strcat(string,tsrt,sizeof(string));
}
default:
{
printf("cini error: cini_FUpdate unknown type passed in type definitions: %c",typedefs[i]);
}
}
}
strcat(store,string,sizeof(store));
}
if(strlen(typedefs) != updated) printf("cini warning: cini_FUpdate attempted to update %d keys, updated %d",strlen(typedefs),updated);
fclose(file);
file = fopen(filename,io_write);
fwrite(file,store);
fclose(file);
return true;
}
stock cini_FDelKey(filename[],{Float,_}:...)
{
new args = numargs() - 1, deleted = 0;
if(!fexist(filename))
{
printf("cini error: cini_FDelKey account %s does not exist",filename);
return false;
}
new key[cini_string];
new string[cini_string];
new store[cini_max_string];
new File:file = fopen(filename,io_read);
while(fread(file,string))
{
for(new i=0;i<args;i++)
{
new tstr[cini_string];
getstrarg(1 + i,tstr);
format(key,cini_string,"%s",string);
strdel(key,strfind(key,"=",true),strlen(key));
if(!strcmp(tstr,key,false) || !strlen(tstr))
{
deleted++;
continue;
}
strcat(store,string,sizeof(store));
}
}
if(args != deleted) printf("cini warning: cini_FDelKey attempted to delete %d keys, deleted %d",args,deleted);
fclose(file);
file = fopen(filename,io_write);
fwrite(file,store);
fclose(file);
return true;
}
stock cini_FDelete(filen[])
{
if(fremove(filen)) return true;
return false;
}
pawn Код:
#define FILTERSCRIPT
#include <a_samp>
#include <cini>
#if defined FILTERSCRIPT
public OnFilterScriptInit()
{
print("\n /------------------------/");
print(" / cini test filterscript /");
print("/------------------------/\n");
return 1;
}
public OnFilterScriptExit()
{
print("goodbye my lover, goodbye my friend...");
return 1;
}
#endif
public OnPlayerConnect(playerid)
{
if(!cini_CheckAccount(playerid))
{
cini_Register(playerid,"default_pass");
cini_Save(playerid,"ssssdf",
"Props1","Slice",
"Props2","Grim_",
"Props3","Blacklite",
"Props4","Rachael",
"digit1",18,
"float1",1.24
);
cini_Add(playerid,"d","digit2",20);
}
if(!cini_CheckLogin(playerid,"wrong_pass")) print("wrong password");
if(cini_CheckLogin(playerid,"default_pass"))
{
print("correct password!");
new name[cini_string], Float:fl, digit2;
cini_Load(playerid,"sfd",
"Props3",name,
"float1",fl,
"digit2",digit2
);
printf("name = %s, fl = %.02f, digit2 = %d",name,fl,digit2);
cini_Update(playerid,"sf",
"Props3","Potassium",
"float1",floatmul(fl,2.0)
);
cini_Load(playerid,"sf","Props3",name,"float1",fl);
printf("name = %s, float = %.02f",name,fl);
}
print(cini_EscapeString("Password=pass\n\rAdminLevel=1337"));
return 1;
}
public OnPlayerDisconnect(playerid,reason)
{
if(cini_Delete(playerid)) print("deleted account!");
}
explanation of cini_Save
pawn Код:
cini_Save(playerid,"sdif", //here "s" string, "d" decimal, "i" integer, "f", float. These must be in order
"name","cessil", //string
"score",1000, //decimal
"kills",12, //int
"coolness",87.99 //float
);
/*type defs must be in order and match the amount of values you want to set.
the above code will save a string like.
name=cessil
score=1000
kills=12
coolness=87.99
*/
Forgive me if I misused some of the systems it was the first time I used sii, and fini.
I ran a test three times using cini, cini2, fini, bini2 and sii.
As you can see cini2 is the fastest in terms of write speed and is very fast in read speed.
All systems tested are very fast and were tested with a 100,000 loop
In a real situation you might save 50 stats in one go and cini2 would do it in about 22ms depending on the server.
Код:
write times: cini write time 4772 | 2.09 Per ms 4723 | 2.11 Per ms 4801 | 2.08 Per ms cini2 write time 4570 | 2.18 Per ms 4368 | 2.28 Per ms 4469 | 2.23 Per ms bini2 write time 5708 | 1.75 Per ms 5696 | 1.75 Per ms 5478 | 1.82 Per ms fini write time 10918 | 0.91 Per ms 10733 | 0.93 Per ms 11034 | 0.90 Per ms sii write time 6747 | 1.48 Per ms 6664 | 1.50 Per ms 6889 | 1.45 Per ms read times: cini read time 2811 | 3.55 Per ms 2794 | 3.57 Per ms 2786 | 3.58 Per ms cini2 read time 2008 | 4.98 Per ms 1994 | 5.01 Per ms 2040 | 4.90 Per ms bini2 read time 1237 | 8.08 Per ms 1237 | 8.08 Per ms 1262 | 7.92 Per ms fini read time 1320 | 7.57 Per ms 1319 | 7.58 Per ms 1353 | 7.39 Per ms sii read time 2669 | 3.74 Per ms 2638 | 3.79 Per ms 2677 | 3.73 Per ms
pawn Код:
#define FILTERSCRIPT
#include <a_samp>
#include <cini>
#include <cini2>
#include <fini>
#include <dini>
#include <sii>
#include <bini2>
#if defined FILTERSCRIPT
public OnFilterScriptInit()
{
print("\n-----------------------------");
print(" ini file system speed tests");
print("-----------------------------\n");
cini_Create("cini.ini");
cini2_Create("cini2.ini");
dini_Create("dini.ini");
Fini_Create("Fini.ini");
bINI_Create("bini.ini");
new super[20];
format(super,sizeof(super),"super dooper string");
print("write times:");
new ticks = GetTickCount();
new Float:average;
for(new i=0;i<10000;i++)
{
cini_FSave("cini.ini","sdf",
"cessil",super,
"digit",200,
"float",1.1
);
}
average = 10000.0 / (GetTickCount() - ticks);
printf("cini write time %d | %.2f Per ms",GetTickCount() - ticks,average);
ticks = GetTickCount();
for(new i=0;i<10000;i++)
{
cini2_FSave("cini2.ini","sdf",
"cessil",super,
"digit",200,
"float",1.1
);
}
average = 10000.0 / (GetTickCount() - ticks);
printf("cini2 write time %d | %.2f Per ms",GetTickCount() - ticks,average);
ticks = GetTickCount();
for(new i=0;i<10000;i++)
{
bINI_Open("bini.ini");
bINI_WriteString("cessil", super);
bINI_WriteInt("digit", 200);
bINI_WriteFloat("float",1.1);
bINI_Save();
bINI_Close();
}
average = 10000.0 / (GetTickCount() - ticks);
printf("bini2 write time %d | %.2f Per ms",GetTickCount() - ticks,average);
ticks = GetTickCount();
for(new i=0;i<10000;i++)
{
Fini_OpenFile("Fini.ini");
Fini_SetStr("cessil",super);
Fini_SetVal("digit",200);
Fini_SetFloat("float",1.1);
Fini_SaveFile();
Fini_CloseFile();
}
average = 10000.0 / (GetTickCount() - ticks);
printf("fini write time %d | %.2f Per ms",GetTickCount() - ticks,average);
ticks = GetTickCount();
for(new i=0;i<10000;i++)
{
INI_Open("sii.ini");
INI_WriteString("cessil",super);
INI_WriteInt("digit",200);
INI_WriteFloat("float",1.1);
INI_Save();
INI_Close();
}
average = 10000.0 / (GetTickCount() - ticks);
printf("sii write time %d | %.2f Per ms",GetTickCount() - ticks,average);
print("read times:");
new string[256], digit, Float:fl;
ticks = GetTickCount();
for(new i=0;i<10000;i++)
{
cini_FLoad("cini.ini","sdf",
"cessil",string,
"digit",digit,
"float",fl
);
}
average = 10000.0 / (GetTickCount() - ticks);
printf("cini read time %d | %.2f Per ms",GetTickCount() - ticks,average);
ticks = GetTickCount();
for(new i=0;i<10000;i++)
{
cini2_FLoad("cini2.ini","sdf",
"cessil",string,
"digit",digit,
"float",fl
);
}
average = 10000.0 / (GetTickCount() - ticks);
printf("cini2 read time %d | %.2f Per ms",GetTickCount() - ticks,average);
ticks = GetTickCount();
for(new i=0;i<10000;i++)
{
bINI_Open("bini.ini");
string = bINI_ReadString("cessil");
digit = bINI_ReadInt("digit");
fl = bINI_ReadFloat("float");
bINI_Close();
}
average = 10000.0 / (GetTickCount() - ticks);
printf("bini2 read time %d | %.2f Per ms",GetTickCount() - ticks,average);
ticks = GetTickCount();
for(new i=0;i<10000;i++)
{
Fini_OpenFile("Fini.ini");
string = Fini_GetStr("cessil");
digit = Fini_GetValue("digit");
fl = Fini_GetFloat("float");
Fini_CloseFile();
}
average = 10000.0 / (GetTickCount() - ticks);
printf("fini read time %d | %.2f Per ms",GetTickCount() - ticks,average);
ticks = GetTickCount();
for(new i=0;i<10000;i++)
{
INI_Open("sii.ini");
INI_ReadString("cessil",string,sizeof(string));
digit = INI_ReadInt("digit");
fl = INI_ReadFloat("float");
INI_Close();
}
average = 10000.0 / (GetTickCount() - ticks);
printf("sii read time %d | %.2f Per ms",GetTickCount() - ticks,average);
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
#endif
Slice BUD helped me understand undefined arguments.
Grim_ telling me to stop using dini
Rachael for being a pretty cool person
Blacklite 60% of the time he's helpful 100% of the time
****** for feedback with the initial release
Edit: small fix with some of the file functions