y_ini problems
#1

Im working on a /adjustrankname but i have some problems with y_ini (Don't have much expierence with it)
After making this:
pawn Код:
new
    fileToWrite[] = "factionranks.INI",
    INI:iniFile = INI_Open(fileToWrite);
new rank1[128],rank2[128],rank3[128],rank4[128],rank5[128],rank6[128],rank7[128],rank8[128],rank9[128],rank10[128]
INI_SetTag(iniFile, "lspd");
INI_WriteString(iniFile, "rank1",rank1, sizeof(rank1);
INI_WriteString(IniFile, "rank2",rank2, sizeof(rank2);
INI_WriteString(IniFile, "rank3",rank3, sizeof(rank3);
INI_WriteString(IniFile, "rank4",rank4, sizeof(rank4);
INI_WriteString(IniFile, "rank5",rank5, sizeof(rank5);
INI_WriteString(IniFile, "rank6",rank6, sizeof(rank6);
INI_WriteString(IniFile, "rank7",rank7, sizeof(rank7);
INI_WriteString(IniFile, "rank8",rank8, sizeof(rank8);
INI_WriteString(IniFile, "rank9",rank9, sizeof(rank9);
INI_WriteString(IniFile, "rank10",rank10, sizeof(rank10);
INI_Close(iniFile);
If i try to compile i get the error Pawn Compiler has stopped working.
Solutions, Any help?
Reply
#2

Oh, I didn't knew it needed brackets. I just used your How to use y_ini tutorial. And saw no brackets there. Also what do you mean? i thought what i just made did this in factionranks.ini
pawn Код:
[lspd]
rank1 = rank1
OR
rank1 =
I didn't knew that for sure.
Can you explain me what im doing wrong?
Reply
#3

Quote:
Originally Posted by Facerafter
Посмотреть сообщение
Oh, I didn't knew it needed brackets. I just used your How to use y_ini tutorial. And saw no brackets there. Also what do you mean? i thought what i just made did this in factionranks.ini
pawn Код:
[lspd]
rank1 = rank1
OR
rank1 =
I didn't knew that for sure.
Can you explain me what im doing wrong?
about brackets , i will try to explain.
let say you want to save a float value that is 0.
you would do
Код:
INI_WriteFloat(IniFile, "MyFloatValueBlaBlaBla", 0);
now , if you want to save let say player health
Код:
INI_WriteFloat(IniFile, "ThePlayerHealthText", GetPlayerHealth(playerid));
do you see the difference with brackets ?

i mean you cant do something like this
Код:
yesterday  my sister ( daisy  came back to home ( in canada )
you have to do
Код:
yesterday  my sister ( daisy )  came back to home ( in canada )
each opening bracket need closing bracket

now your code should be like this
Код:
INI_SetTag(iniFile, "lspd");
INI_WriteString(iniFile, "rank1",rank1, sizeof(rank1));
INI_WriteString(IniFile, "rank2",rank2, sizeof(rank2));
INI_WriteString(IniFile, "rank3",rank3, sizeof(rank3));
INI_WriteString(IniFile, "rank4",rank4, sizeof(rank4));
INI_WriteString(IniFile, "rank5",rank5, sizeof(rank5));
INI_WriteString(IniFile, "rank6",rank6, sizeof(rank6));
INI_WriteString(IniFile, "rank7",rank7, sizeof(rank7));
INI_WriteString(IniFile, "rank8",rank8, sizeof(rank8));
INI_WriteString(IniFile, "rank9",rank9, sizeof(rank9));
INI_WriteString(IniFile, "rank10",rank10, sizeof(rank10));
Reply
#4

OH Now i see it... Sorry i really missed that...

Edit: Sorry for this im still a noob with y_ini and also not a very expierenced scripter.
But under what do i need to put this? Under a callback or do need to create a stock...?
Reply
#5

Quote:
Originally Posted by Facerafter
Посмотреть сообщение
OH Now i see it... Sorry i really missed that...

Edit: Sorry for this im still a noob with y_ini and also not a very expierenced scripter.
But under what do i need to put this? Under a callback or do need to create a stock...?
you are creating file , writing to file , saving file.
that mean you have two solution.

1: create a function and a timer which run this function each x time. ( the faster the timer is , the more lag you will have )
2 : THE BEST put that on OnPlayerDisconnect

and never put that genre of things on OnPlayerUpdate because this callback is called like each 500ms ( IF not faster ! ).
let say you have 15 player online , it mean you open , write , save afile 15 time per 500ms.
1 second = 30 time
Reply
#6

Thats not what i mean. I mean only with creating. I thought if i put the creating under OnGameModeInit
it creates the file agian everytime the servers turns on.
Reply
#7

leave it under OnPlayerDisconnect.

if file exist = just write
if file not exist = create and write

thats what you asked ?
Reply
#8

Does it do that automaticly? To check if it exists or not?
Reply
#9

no. you need something like this
Код:
if(fexist(Path(playerid)))
{
this is just an exemple !

i cant give you a full code you wont learn ( im still elarning too and i can tell you its true )

read some y_ini tutorial like register login you will get how it work
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)