Money not saving FS -
Devix - 31.10.2012
Hey guys!
At a dialog you buy a car you have the following code:
Код:
GivePlayerMoney(playerid, -VehicleValue[ids]);
PlayerInfo[playerid][pMoney] = PlayerInfo[playerid][pMoney]-VehicleValue[ids];
printf("Money: %i",PlayerInfo[playerid][pMoney]);
SaveData(playerid);
Now if the player had 2000 dollars and the vehicle costs 50, the print would read: 1950.
Even at SaveData (include file with all playerinfo's in it) I have the following:
Код:
public SaveData(playerid)
{
UserDataSave_data(playerid);
return 1;
}
UserDataSave_data(playerid)
{
new uFile[35];
format(uFile, 35, USER_FILE, GetName(playerid));
new INI:file = INI_Open(uFile); //will open their file
INI_WriteInt(file,"Money",PlayerInfo[playerid][pMoney]);
printf("Money:%i", PlayerInfo[playerid][pMoney]);
}
And guess what? Its still 1950 yet it didnt save into the file! So next time I spawn I still have 200 dollars!
How to fix this?
Re: Money not saving FS -
Yamakei - 01.11.2012
Are you making sure it goes by server sided money?
Re: Money not saving FS -
Biesmen - 01.11.2012
First of all: You are missing INI_Close
Second of all: Your format is incorrect?
pawn Код:
format(uFile, 35, USER_FILE, GetName(playerid));
It should be (depends on your user files tho)
pawn Код:
format(uFile, sizeof(uFile), "%s", GetName(playerid));
Re: Money not saving FS -
Devix - 01.11.2012
USER_FILE is basically #define USER_FILE "Users/%s"
INI_Close is actually there at the end of the code, but I couldnt be bothered sending the whole code to annoy you guys.
Re: Money not saving FS -
gtakillerIV - 01.11.2012
Yes INI_Close saves your .ini file and closes it.
Re: Money not saving FS -
Devix - 01.11.2012
But there is a ini_close at the end of the userdatasave :P.
Re: Money not saving FS -
Biesmen - 01.11.2012
Here is an example from ******'s tutorial:
pawn Код:
new
// The name of the file, can be any string variable or literal.
fileToWrite[] = "mine.INI",
// "INI_Open" returns a variable with tag "INI".
INI:iniFile = INI_Open(fileToWrite);
//
// y_ini supports tags, that is:
//
// [tag]
// key = value
//
INI_SetTag(iniFile, "examples");
// Write an integer value with the key "some_integer" under the current tag:
INI_WriteInt(iniFile, "some_integer", 42);
// Now close the current file:
INI_Close(iniFile);
Maybe this would help.
Re: Money not saving FS -
Devix - 01.11.2012
I think you misunderstand the issue. The saving and all works when I call the function from within my gamemode. However, it doesnt when I call the function from the filterscript. So basically the function is called from the FS, it prints the correct money YET it doesnt save the correct money. But if I change the pMoney from my GM it will save correctly.
Just incase you guys still think it is about the saving function:
Код:
UserDataSave_data(playerid)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid,x,y,z);
PlayerInfo[playerid][pX] = x;
PlayerInfo[playerid][pY] = y;
PlayerInfo[playerid][pZ] = z;
new uFile[35];
format(uFile, 35, USER_FILE, GetName(playerid));
new INI:file = INI_Open(uFile);
INI_WriteInt(file,"Admin",PlayerInfo[playerid][pAdmin]);
INI_WriteString(file,"Nationality",PlayerInfo[playerid][pNat]);
INI_WriteString(file,"City",PlayerInfo[playerid][pCity]);
INI_WriteInt(file,"Phone",PlayerInfo[playerid][pPhone]);
INI_WriteInt(file,"BankAccount",PlayerInfo[playerid][pBaccount]);
INI_WriteInt(file,"Kills",PlayerInfo[playerid][pKills]);
INI_WriteInt(file,"Deaths",PlayerInfo[playerid][pDeaths]);
INI_WriteInt(file,"Bankmoney",PlayerInfo[playerid][pBankmoney]);
INI_WriteInt(file,"Money",PlayerInfo[playerid][pMoney]);
INI_WriteInt(file,"Online",PlayerInfo[playerid][pOnline]);
INI_WriteInt(file,"Age",PlayerInfo[playerid][pAge]);
INI_WriteInt(file,"Pin",PlayerInfo[playerid][pPin]);
INI_WriteFloat(file,"Xpos",PlayerInfo[playerid][pX]);
INI_WriteFloat(file,"Ypos",PlayerInfo[playerid][pY]);
INI_WriteFloat(file,"Zpos",PlayerInfo[playerid][pZ]);
INI_WriteInt(file,"Skin",PlayerInfo[playerid][pSkin]);
INI_WriteInt(file,"Gender",PlayerInfo[playerid][pGender]);
INI_WriteInt(file,"Faction",PlayerInfo[playerid][pFaction]);
INI_WriteInt(file,"Rank",PlayerInfo[playerid][pRank]);
INI_Close(file);
return 1;
}
Re: Money not saving FS -
Devix - 05.11.2012
I still have this issue, and I have been looking at the code for hours now
.
Re: Money not saving FS -
Devix - 13.11.2012
Still got this issue, help please!
.