Dini Problems
#1

Can someone explain dini_create , dini_write , etc to me ?
Reply
#2

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;
}
Reply
#3

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 ?
Reply
#4

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'");
Reply
#5

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
Reply
#6

Quote:
Originally Posted by WhiteAngels
Посмотреть сообщение
Ok Thanks
Your welcome.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)