Need help about save money
#1

I added a money saving system in my server, but it doesn't work.

It save the informations with the ID of the player and not with the name.
I mean if ID0 left with Money=1500, the next ID0 will spawn with Money=1500, even if the don't have the same name.

And if the player "NAME1" was ID 0 and relog as ID 5, he will get the money of the old's ID 5.


Here are the scripts.
Код:
new Float:positionx;
new Float:positiony;
new Float:positionz;



public OnPlayerConnect(playerid)
  {
	LoadStats(playerid);
	return 1;
  }
  
public OnPlayerDisconnect(playerid, reason)
{
	new Float:x;
	new Float:y;
	new Float:z;

	GetPlayerPos(playerid,x,y,z);
	positionx = x;
	positiony = y;
	positionz = z;
	
	GetPlayerPCash(playerid);

	if (!dini_Exists(FileStats(playerid)))
	{
		dini_Create(FileStats(playerid));
	}

	SaveStats(playerid);
	return 1;
}





Player(playerid)
{
 new player[MAX_PLAYER_NAME];
 GetPlayerName(playerid, player, sizeof(player));
 return player;
}

FileStats(playerid)
{
  new a[256]; format(a, sizeof(a), "%s.ini",udb_encode(Player(playerid)));
  return a;
}

SaveStats(playerid)
{
  dini_IntSet(FileStats(playerid), "PositionX", floatround(positionx));
  dini_IntSet(FileStats(playerid), "PositionY", floatround(positiony));
  dini_IntSet(FileStats(playerid), "PositionZ", floatround(positionz));
  dini_IntSet(FileStats(playerid), "Pcash", GetPlayerPCash(playerid));

}

LoadStats(playerid)
{
  positionx = dini_Int(FileStats(playerid), "PositionX");
  positiony = dini_Int(FileStats(playerid), "PositionY");
  positionz = dini_Int(FileStats(playerid), "PositionZ");
  playerid = dini_Int(FileStats(playerid), "Pcash");
}
How can it be fixed ??
Reply
#2

positionx,positiony and positionz have to be arrays.
Reply
#3

Quote:
Originally Posted by MenaceX^
positionx,positiony and positionz have to be arrays.
In fact it's just bugged with the money system but not with the positions, i edited my first post.
Reply
#4

I will give you how i have mine :

Код:
new Euro[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
  Euro[playerid]=0; // This is very important to prevent bugs !
}

public OnPlayerDisconnect(playerid, reason)
{
  dUserSetINT(PlayerName(playerid)).("Euro",GetPlayerEuro(playerid));
}

stock GivePlayerEuro(playerid, money)
{
	Euro[playerid] = Euro[playerid] + money;
	return Euro[playerid];
}

stock ResetPlayerEuro(playerid)
{
	Euro[playerid] = 0;
	return Euro[playerid];
}

stock GetPlayerEuro(playerid)
{
	return Euro[playerid];
}
Btw welcome Alice to samp forum
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)