NeoPhoenix
09-03-2012, 08:16 PM
just built a small include which manages files (unpacked strings only) including INI standarts. functions:
native INI::Create(const path[],bool:overwrite=false);
native INI::Remove(const path[]);
native INI::Copy(const oldpath[], const newpath[],bool:delete_oldpath=true,bool:overwrite=false);
native INI::GetValue(const path[],const key[],const section[]='''');
native INI::GetValueAsInt(const path[],const key[],const section[]='''');
native Float:INI::GetValueAsFloat(const path[],const key[],const section[]='''');
native bool:INI::GetValueAsBool(const path[],const key[],const section[]='''');
native INI::SetValue(const path[],const key[],value[],const section[]);
native INI::SetInt(const path[],const key[],value,const section[]);
native INI::SetFloat(const path[],const key[],Float:value,const section[]);
native INI::SetBool(const path[],const key[],bool:value,const section[]);
structure of a file
; Comment
[Section]
key=value
comments can be set at the beginning of a line only (';' has to be the first character, can be changed with COMMENTVAULTCHARACTER). every section can be used only one time and every key in a section has a unique name - but two or more key can have the same name if theyre in different sections. by default the system works case insensitivity but you can toggle it with "IGNOREVAULTCASE".
usage example:
; Userfile.ini
[General]
name=Asdf
age=18
logins=1
[InGame]
class=Human
age=38
dead=false
[Position]
x=1363.00
y=5479.00
z=7844.13
#include <INI>
new logins = INI::GetValueAsInt(''Userfile.ini'',''logins'',''G eneral'');
INI::SetInt(''Userfile.ini'',''logins'',++logins,' 'General'');
new Float:x = INI::GetValueAsFloat(''Userfile.ini'',''x'',''Posi tion'');
new Float:y = INI::GetValueAsFloat(''Userfile.ini'',''y'',''Posi tion'');
new Float:z = INI::GetValueAsFloat(''Userfile.ini'',''z'',''Posi tion'');
SetPos(ID,x,y,z);
download: https://dl.dropbox.com/u/93111829/VaultMP/Downloads/INI.inc
not all functions are tested so please give feedback if it works ;)
native INI::Create(const path[],bool:overwrite=false);
native INI::Remove(const path[]);
native INI::Copy(const oldpath[], const newpath[],bool:delete_oldpath=true,bool:overwrite=false);
native INI::GetValue(const path[],const key[],const section[]='''');
native INI::GetValueAsInt(const path[],const key[],const section[]='''');
native Float:INI::GetValueAsFloat(const path[],const key[],const section[]='''');
native bool:INI::GetValueAsBool(const path[],const key[],const section[]='''');
native INI::SetValue(const path[],const key[],value[],const section[]);
native INI::SetInt(const path[],const key[],value,const section[]);
native INI::SetFloat(const path[],const key[],Float:value,const section[]);
native INI::SetBool(const path[],const key[],bool:value,const section[]);
structure of a file
; Comment
[Section]
key=value
comments can be set at the beginning of a line only (';' has to be the first character, can be changed with COMMENTVAULTCHARACTER). every section can be used only one time and every key in a section has a unique name - but two or more key can have the same name if theyre in different sections. by default the system works case insensitivity but you can toggle it with "IGNOREVAULTCASE".
usage example:
; Userfile.ini
[General]
name=Asdf
age=18
logins=1
[InGame]
class=Human
age=38
dead=false
[Position]
x=1363.00
y=5479.00
z=7844.13
#include <INI>
new logins = INI::GetValueAsInt(''Userfile.ini'',''logins'',''G eneral'');
INI::SetInt(''Userfile.ini'',''logins'',++logins,' 'General'');
new Float:x = INI::GetValueAsFloat(''Userfile.ini'',''x'',''Posi tion'');
new Float:y = INI::GetValueAsFloat(''Userfile.ini'',''y'',''Posi tion'');
new Float:z = INI::GetValueAsFloat(''Userfile.ini'',''z'',''Posi tion'');
SetPos(ID,x,y,z);
download: https://dl.dropbox.com/u/93111829/VaultMP/Downloads/INI.inc
not all functions are tested so please give feedback if it works ;)