UPDATED! Version 1.4
.: Description :.
This include allows you to easily and freely read/write from/to INI/txt files.
It is fast and easy to learn and understand.
.: Features :.
Code: Select all
Features:
* SINI_Create(filename[]); - Create a specific file.
* SINI_Delete(filename[]); - Deletes a specific file.
* SINI_Open(filename[]); - Opens a specific file. <!> MUST BE USED WHEN READING/WRITING FILE!
* SINI_Exists(filename[]); - Checks if a specific file exists.
* SINI_Save(); - Saves the current opened file. <!> MUST BE USED WHEN WRITING TO FILE!
* SINI_Close(); - Closes the current opened file. <!> MUST BE USED WHEN FILE IS OPENED!
* SINI_WriteString(varname[], string[]); - Writes a String to a file. <!> FILE MUST BE OPENED TO USE THIS FUNCTION!
* SINI_WriteInt(varname[], number); - Writes a Integer to a file. <!> FILE MUST BE OPENED TO USE THIS FUNCTION!
* SINI_ReadString(varname[], data[], len); - Reads a String from a file. <!> FILE MUST BE OPENED TO USE THIS FUNCTION!
* SINI_ReadInt(varname[], integer); - Reads an Integer from a file. <!> FILE MUST BE OPENED TO USE THIS FUNCTION!
* SINI_RemoveVariable(varname[]); - Removes a variable from a file. <!> FILE MUST BE OPENED TO USE THIS FUNCTION!
* SINI_CountLines(); - Returns the number of lines in file. <!> FILE MUST BE OPENED TO USE THIS FUNCTION!
* SINI_VariableExists(varname[]); - Checks if given variable exists in file. <!> FILE MUST BE OPENED TO USE THIS FUNCTION!
* SINI_WriteFloat(varname[], Float: floatvar); - Writes a Float to a file. <!> FILE MUST BE OPENED TO USE THIS FUNCTION!
* SINI_ReadFloat(varname[], Float: floatvar); - Reads a Float from a file. <!> FILE MUST BE OPENED TO USE THIS FUNCTION!Code: Select all
SINI_Create("addons/amxmodx/data/SINI_Test.ini"); // Creating a .INI file named SINI_Test that will be located at addons/amxmodx/data/.
SINI_Open("addons/amxmodx/data/SINI_Test.ini"); // Opening the .INI file we created above.
SINI_WriteString("Variable1", "Hello World"); // Writing the variable "Variable1" with the string value "Hello World" assigned to it, this will end up as 'Variable1=Hello World' in the file.
SINI_WriteInt("Variable2", 555); // Writing the variable "Variable2" with the integer value "555" assinged to it, this will end up as 'Variable2=555' in the file.
SINI_WriteFloat("Variable3", 1337.1337); // Writing the variable "Variable3" with the float value "1337.1337" assinged to it, this will end up as 'Variable3=1337.1337' in the file.
SINI_Save(); // Saving the file as we wrote variables to it.
SINI_Close(); // Closing the file as we are done using it. Code: Select all
new variable1[35], variable2, Float: variable3; // Creating variables that will store our file reading.
SINI_Open("addons/amxmodx/data/SINI_Test.ini"); // Opening the .INI file SINI_Test which is located at addons/amxmodx/data/.
SINI_ReadString("Variable1", variable1, 35); // Reading the variable "Variable1" and storing its string value at variable1.
SINI_ReadInt("Variable2", variable2); // Reading the variable "Variable2" and storing its integer value at variable2.
SINI_ReadFloat("Variable3", variable3); // Reading the variable "Variable3" and storing its float value at variable3.
SINI_Close(); // Closing the file as we are done using it. Code: Select all
new lines = 0; // Creating a variable with will store our lines count in the file we'll open.
SINI_Open("addons/amxmodx/data/SINI_Test.ini"); // Opening a .INI file named SINI_Test which is located at addons/amxmodx/data/.
SINI_RemoveVariable("Variable3"); // Removing the variable "Variable3" from the file.
lines = SINI_CountLines(); // Getting the number of lines in the file and storing it in the variable lines.
SINI_Save(); // Saving the file as we removed a variable from it.
SINI_Close(); // Closing the file since we're done using it. Code: Select all
MAX_FILE_NAME_LEGNTH - Defines the max file name length. (DEFAULT: 80)
MAX_VARS_PER_FILE - Defines the max variables in file. (DEFAULT: 40)
MAX_VAR_NAME_LENGTH - Defines the max variable name. (DEFAULT: 60)There is also a small money saving script.
You can learn from it, Its located in the attachments.
