Problem with YSI\y_ini
#1

So today I switched from using Dini to y_ini and my code just doesn't work for some weird reason.

I read lots of posts about y_ini and they all say that this should be working:

Код:
OnPlayerConnect(playerid)
{
	if(fexist(filename)) //I formatted the filename to be exactly my name(for testing purposes).
	{
	        print("Exists.");
		INI_ParseFile(filename, "LoadUser",.bExtra = true,.extra = playerid,.bPassTag = true);
	}
        return 1;
}

new score;
forward LoadUser(playerid, name[], value[]);
public LoadUser(playerid, name[], value[])
{
	print("Yep");
	INI_Int("score", score);
	SetPlayerScore(playerid, score);
	return 1;
}
Both "Exists." and "Yep" get printed but my score doesn't get set to 10 (that's what the ini file contains).

Can anyone help me?
Thanks in advanced

Btw this is just a test script.
Reply
#2

Read little about YINI

https://sampforum.blast.hk/showthread.php?tid=524344
Reply
#3

I read both beginner and advanced tutorials and this should work.

The public function gets called but INI_Int("score", score); doesn't work for some reason?

In my ini file, score is equal to 10...
score = 10
Reply
#4

Then start with basics and do like tutorial say
Reply
#5

Quote:
Originally Posted by ******
Посмотреть сообщение
The callback is called once per value in the script, for you to save the data in global variables and use later. It isn't designed for using the values in the callback itself, since nothing after `INI_Int` will be run.

It was a poor design choice, but it was the choice and now it's done.
Ohh ok, btw I didn't save anything to local variables only global but I think I found my problem.

I'm gonna test something out and if it doesn't work I'll edit this comment.

EDIT:

Why is this not loading?

Код:
OnPlayerConnect(playerid)
{
  	new PlayerFile[64];
	format(PlayerFile, sizeof(PlayerFile), "/Users/%s.ini", GetName(playerid));
  	if(fexist(PlayerFile))
  	{
		INI_ParseFile(PlayerFile, "LoadUser", .bExtra = true, .extra = playerid, .bPassTag = true);
		//INI_Load(PlayerFile);
		print("Exists!");
  	}
        return 1;
}

forward LoadUser(playerid, name[], value[]);
public LoadUser(playerid, name[], value[])
{
	INI_Int("Kills", pInfo[playerid][pKills]);
	INI_Int("Deaths", pInfo[playerid][pDeaths]);
	INI_Int("Admin", pInfo[playerid][pAdmin]);
	INI_Int("Vip", pInfo[playerid][pVip]);
        ...
	return 0;
}
Reply
#6

Quote:
Originally Posted by ******
Посмотреть сообщение
Because you set `bPassTag` but didn't provide a callback parameter for it.
So this should work:

Код:
OnPlayerConnect(playerid)
{
  	new PlayerFile[64];
	format(PlayerFile, sizeof(PlayerFile), "/Users/%s.ini", GetName(playerid));
  	if(fexist(PlayerFile))
  	{
		INI_ParseFile(PlayerFile, "LoadUser_%s", .bExtra = true, .extra = playerid);
		//INI_Load(PlayerFile);
		print("Exists!");
  	}
        return 1;
}

forward LoadUser_data(playerid, name[], value[]);
public LoadUser_data(playerid, name[], value[])
{
	INI_Int("Kills", pInfo[playerid][pKills]);
	INI_Int("Deaths", pInfo[playerid][pDeaths]);
	INI_Int("Admin", pInfo[playerid][pAdmin]);
	INI_Int("Vip", pInfo[playerid][pVip]);
        ...
	return 0;
}
But why:

Код:
INI_ParseFile(PlayerFile, "LoadUser_%s", .bExtra = true, .extra = playerid);
instead of:

Код:
INI_ParseFile(PlayerFile, "LoadUser_data", .bExtra = true, .extra = playerid);
?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)