Y_ini: leaving a space just before tags?
#1

I'm trying to make my user files easier to read, so by using settag, is it possible to add a space before the settag?

What it looks like now:
Код:
[Player Data]
pPass = 51628CEBAA4B4CF20721C377531D444F2CD285CA7D9606AE607098C2575DF01C2438DACA992D2A9F31FE5D258C0F5622A96BDF360436EF118ACBF0B3CF484414
...
pPhonebook = 0
[Player Position]
pLastX = 151.069824
pLastY = -206.372817
pLastZ = 3.302008
[Player Vehicles]
pVehicleID = 0
...
pVehiclePrice = 0
[Player Bank]
pBankBalance = 0
pPendingDeposit = 0
What I want it to look like:
Код:
[Player Data]
pPass = 51628CEBAA4B4CF20721C377531D444F2CD285CA7D9606AE607098C2575DF01C2438DACA992D2A9F31FE5D258C0F5622A96BDF360436EF118ACBF0B3CF484414
...
pPhonebook = 0

[Player Position]
pLastX = 151.069824
pLastY = -206.372817
pLastZ = 3.302008

[Player Vehicles]
pVehicleID = 0
...
pVehiclePrice = 0

[Player Bank]
pBankBalance = 0
pPendingDeposit = 0
Reply
#2

It is possible to have multiple tags in one file, I read the y_ini topic and it states it's possible, I'm just unsure on how. Maybe you could figure it out by giving it a read.

https://sampforum.blast.hk/showthread.php?tid=175565

Quote:

If you had two modes (or even just two libraries) in dini, any user system would need to use separate files for each one. Wheras here the different modes' data are separated by tags (the bits in square brackets). This is where the odd syntax in the read function came in.

Reply
#3

I think you can do it like this:

Wherever you save your userfile stats:

pawn Код:
// first tag & input
INI_SetTag(ini, "Account Info");
INI_WriteString(ini, "NAME", "******");
INI_WriteInt(ini, "SCORE", gScore);

// second tag & input
INI_SetTag(ini, "House Info");
INI_WriteInt(ini, "House Owner", pInfo[playerid][HouseOwner]);
INI_WriteInt(ini, "House Keys", pInfo[playerid][HouseKeys]);

// third tag & input
INI_SetTag(ini, "Vehicle Info");
INI_WriteInt(ini, "Vehicle Owner", pInfo[playerid][VehicleOwner]);
INI_WriteInt(ini, "Vehicle Keys", pInfo[playerid][VehicleKeys]);

//etc
Reply
#4

Mionee is correct.

pawn Код:
public OnGameModeInit()
{
    new
    INI:ini = INI_Open("myini.ini");
    INI_SetTag(ini, "LVDM");
    INI_WriteString(ini, "NAME", "******");
    INI_SetTag(ini, "PD");
    INI_WriteString(ini, "GENDER", "Male");
    INI_Close(ini);
    return 1;
}
Output:
Код:
[LVDM]
NAME = ******
[PD]
GENDER = Male
Reply
#5

-_- Look at the pictures, then re-read the thread title. Rewriting the thread description for misleading you guys, sorry.
Reply
#6

Did you try adding \r\n on your last tags? Formatting the value of INI_Write might be able to help you with that.

pawn Код:
format(val, sizeof(val), "%d \n", PlayerInfo[playerid][variable]);
INI_WriteINT(ini, "Variable", val);
Reply
#7

Quote:
Originally Posted by Aerotactics
Посмотреть сообщение
-_- Look at the pictures, then re-read the thread title. Rewriting the thread description for misleading you guys, sorry.
Quote:
Originally Posted by Aerotactics
I'm trying to make my user files easier to read, so by using settag, is it possible to add a space before the settag?
No, you can not use SetTag to put a space in a file.
Reply
#8

Quote:
Originally Posted by Jack_Leslie
Посмотреть сообщение
No, you can not use SetTag to put a space in a file.
Actually, you can, but it ends up messing up the tags :P. I assume you'll have to edit y_ini's way of defining tags which isn't really recommended.

This:

pawn Код:
public OnGameModeInit()
{
    new
    INI:ini = INI_Open("myini.ini");
    INI_SetTag(ini, "LVDM");
    INI_WriteString(ini, "NAME", "******");
    INI_SetTag(ini, "\r\nPD");
    INI_WriteString(ini, "GENDER", "Male");
    INI_Close(ini);
    return 1;
}
Outputs:

Код:
[LVDM]
NAME = ******
[
PD]
GENDER = Male
Reply
#9

Quote:
Originally Posted by Mionee
Посмотреть сообщение
Actually, you can, but it ends up messing up the tags :P. I assume you'll have to edit y_ini's way of defining tags which isn't really recommended.

This:

pawn Код:
public OnGameModeInit()
{
    new
    INI:ini = INI_Open("myini.ini");
    INI_SetTag(ini, "LVDM");
    INI_WriteString(ini, "NAME", "******");
    INI_SetTag(ini, "\r\nPD");
    INI_WriteString(ini, "GENDER", "Male");
    INI_Close(ini);
    return 1;
}
Outputs:

Код:
[LVDM]
NAME = ******
[
PD]
GENDER = Male
He does not want multiple tags, that is what he is trying to say, how ever he did not word his request properly.

He wants this:
Код:
[User] <-- actual tag
Name = Test

[Position] <-- not a tag, manual string
x = 1.1
Y = 2.2
Z = 2.2
Reply
#10

Quote:
Originally Posted by Jack_Leslie
Посмотреть сообщение
He does not want multiple tags, that is what he is trying to say, how ever he did not word his request properly.

He wants this:
Код:
[User] <-- actual tag
Name = Test

[Position] <-- not a tag, manual string
x = 1.1
Y = 2.2
Z = 2.2
I don't care if there's multiple tags as long as theirs a space before the tag. I think multiple tags makes the file more organized anyways, if the space before them worked.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)