Dini Problems - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Dini Problems (
/showthread.php?tid=524697)
Dini Problems -
WhiteAngels - 08.07.2014
Can someone explain dini_create , dini_write , etc to me ?
Re: Dini Problems -
ABKPot - 08.07.2014
Here's a quick explanation:
pawn Код:
public OnPlayerConnect(playerid)
{
new playername[MAX_PLAYER_NAME]; //We will store the player name in this string.
GetPlayerName(playerid, playername, sizeof(playername));
//dini_Exists is used to check if a file with the specified parameter exists.
if(!dini_Exists(playername)) //If the file "playername" does not exist
{
dini_Create(playername); //We will create a file with the file name "playername", Check scriptfiles for it.
//dini_IntSet(file, key[], integer) is used to set a number or integer in the specified file.
dini_IntSet(playername, "Connected", 1); //This will add a key in the file "Connected=1"
//dini_Int(file, key[]) is used to return an integer value from a file key
//This will basically read the file for "Connected" and return the value from the file
if(dini_Int(playername, "Connected") == 1) SendClientMessage(playerid, "You are connected.");
//dini_Get and dini_Set is basically the same, except strings are used.
//You would store a string in the file like this, Ex. dini_Set(file, "ServerName", "MyServer");
}
return 1;
}
Re: Dini Problems -
WhiteAngels - 08.07.2014
Quote:
Originally Posted by ABKPot
Here's a quick explanation:
pawn Код:
public OnPlayerConnect(playerid) { new playername[MAX_PLAYER_NAME]; //We will store the player name in this string. GetPlayerName(playerid, playername, sizeof(playername));
//dini_Exists is used to check if a file with the specified parameter exists.
if(!dini_Exists(playername)) //If the file "playername" does not exist { dini_Create(playername); //We will create a file with the file name "playername", Check scriptfiles for it.
//dini_IntSet(file, key[], integer) is used to set a number or integer in the specified file.
dini_IntSet(playername, "Connected", 1); //This will add a key in the file "Connected=1"
//dini_Int(file, key[]) is used to return an integer value from a file key
//This will basically read the file for "Connected" and return the value from the file if(dini_Int(playername, "Connected") == 1) SendClientMessage(playerid, "You are connected.");
//dini_Get and dini_Set is basically the same, except strings are used. //You would store a string in the file like this, Ex. dini_Set(file, "ServerName", "MyServer"); } return 1; }
|
how to load the file / data ?
Re: Dini Problems -
ABKPot - 08.07.2014
It automatically opens/closes/reads/& and writes to the file and the data is read/written directly from the/to the file you are trying to read/write when using the dini Functions, as coded in the DINI include.
pawn Код:
//Writing a value to a file
dini_IntSet("settings.ini", "Locked", 1); //This will write to the file "Locked="1" (Key=Value) | dini_IntSet(file, Key, Value)
//Reading a value from a file
new Locked; //We will use this to store the value from the file key.
Locked = dini_Int("settings.ini", "Locked"); //Read the value from the file and store it in the variable "Locked"
if(Locked == 1) print("The key "Locked" in "settings.ini" was set to '1'");
Re: Dini Problems -
WhiteAngels - 08.07.2014
Quote:
Originally Posted by ABKPot
It automatically opens/closes/reads/& and writes to the file and the data is read/written directly from the/to the file you are trying to read/write when using the dini Functions, as coded in the DINI include.
pawn Код:
dini_IntSet("settings.ini", "Locked", 1); //This will write to the file "Locked="1" (Key=Value) | dini_IntSet(file, Key, Value)
new Locked; //We will use this to store the value from the file key.
Locked = dini_Int("settings.ini", "Locked"); //Read the value from the file and store it in the variable "Locked"
if(Locked == 1) printf("The key "Locked" in "settings.ini" was set to '1'");
|
Ok Thanks
Re: Dini Problems -
ABKPot - 08.07.2014
Quote:
Originally Posted by WhiteAngels
Ok Thanks 
|
Your welcome.