[UNSOLVED] Big problem, cannot solve it.
#1

Well, I've been trying to fix this problem for a long time now and I just cant find a way to solve it.

This problem shows up on other functions like Admin Level and Ranks etc... is dosent even save money I earned, but now we will discuss about my Bank System.

When I'm logged in and earn some money I walk to the Bank and type /bank <amount>, I've double checked my %s.ini, it saves the amount.
But when I disconnect and checks the %s.ini the amount is gone, I had like $100 when I left and now it just dissapeard to $0.

When I connect again the money is still gone...

Basicly, my Register System seems to have a saving error when disconnecting...

If you want to take a look at my full script, here you go:

http://pastebin.com/f1f28ded1

Please, I hope you can solve this for me, thanks!
Reply
#2

You do know that OnPlayerUpdate gets called very very fast? You are doing your saving very wrong. Opening and writing into files under OnPlayerUpdate is bad. You should just read when the player logs in and save when the player leaves.
Reply
#3

Quote:
Originally Posted by Backwardsman97
You do know that OnPlayerUpdate gets called very very fast? You are doing your saving very wrong. Opening and writing into files under OnPlayerUpdate is bad. You should just read when the player logs in and save when the player leaves.
No, I didnt know that, hmm, you got a tips how I could make a better saving system?
Reply
#4

Pretty much I would just say to put the stuff under OnPlayerUpdate under OnPlayerDisconnect. And the reason I think this isn't working is because under OnPlayerUpdate you set the variable to store money to whatever the player has right then. Well if the player is leaving, it takes away their money and then saves it.
Reply
#5

Quote:
Originally Posted by Backwardsman97
Pretty much I would just say to put the stuff under OnPlayerUpdate under OnPlayerDisconnect. And the reason I think this isn't working is because under OnPlayerUpdate you set the variable to store money to whatever the player has right then. Well if the player is leaving, it takes away their money and then saves it.
Alright, I will do some experiments with it, I will make a update soon
Reply
#6

By putting it under OnPlayerDisconnect it dident save when I got the money ingame or at Disconnect...

Код:
public OnPlayerDisconnect(playerid, reason)
{
	gPlayerLogged[playerid] = 0;
  
  if(IsPlayerConnected(playerid))
	{
		if(gPlayerLogged[playerid])
		{
			new string3[32];
			new pname3[MAX_PLAYER_NAME];
			GetPlayerName(playerid, pname3, sizeof(pname3));
			format(string3, sizeof(string3), "%s.ini", pname3);
			new File: pFile = fopen(string3, io_write);
			if (pFile)
			{
				new var[32];
				format(var, 32, "%s\n", PlayerInfo[playerid][pPassword]);fwrite(pFile, var);
				fclose(pFile);
				new File: hFile = fopen(string3, io_append);
				PlayerInfo[playerid][pMoney] = GetPlayerMoney(playerid);
				format(var, 32, "Money:%d\n",PlayerInfo[playerid][pMoney]);fwrite(hFile, var);
				format(var, 32, "Bank:%d\n",PlayerInfo[playerid][pBank]);fwrite(hFile, var);
				fclose(hFile);
			}
		}
	}
	return 1;
}
Reply
#7

pawn Код:
gPlayerLogged[playerid] = 0;
 
  if(IsPlayerConnected(playerid))
    {
        if(gPlayerLogged[playerid])
What looks wrong there?
Reply
#8

Quote:
Originally Posted by Joe Staff
pawn Код:
gPlayerLogged[playerid] = 0;
 
  if(IsPlayerConnected(playerid))
    {
        if(gPlayerLogged[playerid])
What looks wrong there?
I will try this.
Reply
#9

Well, by deleting that line(s) it just shows the amount in the %s.ini, but when I get ingame the money is still gone...

And there is no such command like /update that updates the information from the %s.ini file?
Reply
#10

Sorry for double posting, but I cant continue on a script that got such an error.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)