SA-MP Forums Archive
Dini won't save my data. - 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 won't save my data. (/showthread.php?tid=396029)



[SOLVED] Dini won't save my data. - 9903286 - 28.11.2012

I don't get any errors, but when i exit the game it doesn't save data.
These are the things involving my dini code:
Код:
public OnPlayerConnect(playerid)
{
	AlreadyFished[playerid] = 0;
	IsFishing[playerid] = 0;
	
	//Get fishes in file
	FishWeight[playerid] = GetPlayerWeight(playerid);
	Fishes[playerid] = GetPlayerFishes(playerid);
	FishingTool[playerid] = GetPlayerRod(playerid);
	Worms[playerid] = GetPlayerBait(playerid);
	
	return 1;
}
Код:
public OnPlayerDisconnect(playerid, reason)
{
	AlreadyFished[playerid] = 0;
	IsFishing[playerid] = 0;
	
	//Set fishes in file
	SetPlayerFishes(playerid, FishWeight[playerid], Fishes[playerid], FishingTool[playerid], Worms[playerid]);
	
	return 1;
}
and these are the functions
Код:
stock SetPlayerFishes(playerid, weight, fishes, fishingtool, worms)
{
	new file[256], name[MAX_PLAYER_NAME];
	GetPlayerName(playerid, name, sizeof(name));
	format(file, sizeof(file), "%s.ost", name);
	dini_IntSet(file, "Weight", weight);
	dini_IntSet(file, "Fishes", fishes);
	dini_IntSet(file, "Fishingrod", fishingtool);
	dini_IntSet(file, "Baits", worms);
	return true;
}

stock GetPlayerWeight(playerid)
{
	new weight, file[256], name[MAX_PLAYER_NAME];
	GetPlayerName(playerid, name, sizeof(name));
	format(file, sizeof(file), "%s.ost", name);
	weight = dini_Int(file, "Weight");
	return weight;
}

stock GetPlayerFishes(playerid)
{
	new fishes, file[256], name[MAX_PLAYER_NAME];
	GetPlayerName(playerid, name, sizeof(name));
	format(file, sizeof(file), "%s.ost", name);
	fishes = dini_Int(file, "Fishes");
	return fishes;
}

stock GetPlayerRod(playerid)
{
	new rod, file[256], name[MAX_PLAYER_NAME];
	GetPlayerName(playerid, name, sizeof(name));
	format(file, sizeof(file), "%s.ost", name);
	rod = dini_Int(file, "Fishingrod");
	return rod;
}

stock GetPlayerBait(playerid)
{
	new bait, file[256], name[MAX_PLAYER_NAME];
	GetPlayerName(playerid, name, sizeof(name));
	format(file, sizeof(file), "%s.ost", name);
	bait = dini_Int(file, "Baits");
	return bait;
}
Oh and btw, this code is in an filterscript, i don't know if it matters, but if it does, that's probably why.


Re: Dini won't save my data. - maramizo - 28.11.2012

Can you copy paste the contents of any .ost file with fishes?


Re: Dini won't save my data. - 9903286 - 29.11.2012

Quote:
Originally Posted by maramizo
Посмотреть сообщение
Can you copy paste the contents of any .ost file with fishes?
Код:
Weight=0
Fishes=0
Fishingrod=0
Baits=0
And when i catch any fish and logout, it doesn't change.

EDIT: Those four lines are created inside the gamemode .pwn file.


Re: Dini won't save my data. - GiamPy. - 29.11.2012

Try debugging line by line the stocks with the vars you would like to write in the files and show us the results.


Re: Dini won't save my data. - 9903286 - 29.11.2012

Quote:
Originally Posted by GiamPy.
Посмотреть сообщение
Try debugging line by line the stocks with the vars you would like to write in the files and show us the results.
Sorry for such a noob question, but how do i do that?


Re: Dini won't save my data. - GiamPy. - 29.11.2012

printf("value: %s", thevar);
Change %s in %i if it's an integer.


Re: Dini won't save my data. - Shane_Kingston - 29.11.2012

same thing happens....... my dini not work in gates saving.........


Re: Dini won't save my data. - 9903286 - 29.11.2012

Quote:
Originally Posted by GiamPy.
Посмотреть сообщение
printf("value: %s", thevar);
Change %s in %i if it's an integer.
Changed it to:
Код:
stock SetPlayerFishes(playerid, weight, fishes, fishingtool, worms)
{
	new file[256], name[MAX_PLAYER_NAME];
	GetPlayerName(playerid, name, sizeof(name));
	format(file, sizeof(file), "%s.ost", name);
	dini_IntSet(file, "Weight", weight);
	dini_IntSet(file, "Fishes", fishes);
	dini_IntSet(file, "Fishingrod", fishingtool);
	dini_IntSet(file, "Baits", worms);
	printf("Weight: %d, Fishes: %d, Rod: %d, Baits: %d", weight, fishes, fishingtool, worms);
	return true;
}
But it doesn't seem like it's even calling the function, cause no text comes up when i disconnect.


Re: Dini won't save my data. - GiamPy. - 29.11.2012

That's probably the reason then.
Are you sure the filterscript has been even loaded properly?


Re: Dini won't save my data. - maramizo - 29.11.2012

Instead of:
pawn Код:
printf("Weight: %d, Fishes: %d, Rod: %d, Baits: %d", weight, fishes, fishingtool, worms);
Use:
pawn Код:
new string[128];
format(string, 128, "Weight: %d, Fishes: %d, Rod: %d, Baits: %d", weight, fishes, fishingtool, worms);
print(string);