SA-MP Forums Archive
Money is losing each time I go off. - 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: Money is losing each time I go off. (/showthread.php?tid=453518)



Money is losing each time I go off. - Zlaja - 25.07.2013

It won't save my money, I give myself about 10.000$, than I go /q and when I come back, again I have 0$.
Somebody knows how to repair this ?


Re: Money is losing each time I go off. - JimmyCh - 25.07.2013

Are you sure you're saving the money information to a file OnPlayerDisconnect, and loading the information OnPlayerConnect? Show us your codes if so.


Re: Money is losing each time I go off. - Zlaja - 25.07.2013

Код:
public OnPlayerDisconnect(playerid, reason)
{
	new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File, "Level",PlayerInfo[playerid][pLevel]);
	INI_WriteInt(File, "Money",PlayerInfo[playerid][pCash]);
	INI_WriteInt(File, "Admin",PlayerInfo[playerid][pAdmin]);
	INI_WriteInt(File, "Tester",PlayerInfo[playerid][pTester]);
	INI_WriteInt(File, "Vip",PlayerInfo[playerid][pVip]);
	INI_WriteInt(File, "Spawn",PlayerInfo[playerid][pSpawn]);
	INI_WriteInt(File, "Model",PlayerInfo[playerid][pModel]);
	INI_WriteInt(File, "Locked",PlayerInfo[playerid][pLocked]);
	INI_WriteInt(File, "FirstJoined", PlayerInfo[playerid][pFirstJoined]);
	INI_WriteInt(File, "Sex", PlayerInfo[playerid][pSex]);
	INI_WriteInt(File, "Age", PlayerInfo[playerid][pAge]);
	INI_WriteInt(File, "Origin", PlayerInfo[playerid][pOrigin]);
	INI_WriteInt(File, "Respect", PlayerInfo[playerid][pExp]);
	INI_WriteInt(File, "Warns", PlayerInfo[playerid][pWarns]);
	INI_WriteInt(File, "Selected", PlayerInfo[playerid][pSelected]);
	INI_WriteInt(File, "Continent", PlayerInfo[playerid][pPlace]);
	INI_WriteInt(File, "Muted", PlayerInfo[playerid][pMuted]);
	INI_WriteInt(File, "MuteTime", PlayerInfo[playerid][pMuteTime]);
	INI_WriteInt(File, "Ph", PlayerInfo[playerid][pNumber]);
	INI_WriteInt(File, "DriveLic", PlayerInfo[playerid][pDriveLic]);
    INI_Close(File);
	return 1;
}
Код:
public OnPlayerConnect(playerid)
{
	if(!IsValidName(playerid))
	{
	    SCM(playerid,COLOR_RED,"Molimo vas promjenito svoje ime u sljedeči format: Firstname_Lastname");
	    Kick(playerid);
	}
	new string[128];
	new plname[MAX_PLAYER_NAME];
	GetPlayerName(playerid, plname, sizeof(plname));
	PlayerInfo[playerid][pLevel] = 0;
	PlayerInfo[playerid][pCash] = 0;
	PlayerInfo[playerid][pDriveLic] = 0;
	PlayerInfo[playerid][pVip] = 0;
	PlayerInfo[playerid][pAdmin] = 0;
	PlayerInfo[playerid][pTester] = 0;
	PlayerInfo[playerid][pSpawn] = 0;
	PlayerInfo[playerid][pSex] = 0;
	RefuelTime[playerid] = 0;
	TrackCar[playerid] = 0;
	PlayerInfo[playerid][pAge] = 0;
	PlayerInfo[playerid][pOrigin] = 0;
	PlayerInfo[playerid][pModel] = 23;
	PlayerInfo[playerid][pLocked] = 0;
	PlayerInfo[playerid][pExp] = 0;
	PlayerInfo[playerid][pWarns] = 0;
	PlayerNeedsHelp[playerid] = 0;
	Mobile[playerid] = 255;
	PlayerInfo[playerid][pMuted] = 0;
	PlayerInfo[playerid][pMuteTime] = 0;
	gPlayerTutorialing[playerid] = 0;
	format(string, sizeof(string), "/Users/%s.ini", plname);
	new DialogString[1024];
    format(DialogString, sizeof DialogString, "%s%s%s%s%s%s%s%s", reg1, reg2, reg3, reg4, reg5, reg6, reg7, reg8);
	ShowPlayerDialog(playerid,1234, DIALOG_STYLE_MSGBOX,"Introduction...", DialogString,"Prihvati","Odbij");



Re: Money is losing each time I go off. - Mitchy - 25.07.2013

pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File, "Level",PlayerInfo[playerid][pLevel]);
    INI_WriteInt(File, "Money",PlayerInfo[playerid][pCash]);
    GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
    INI_WriteInt(File, "Admin",PlayerInfo[playerid][pAdmin]);
    INI_WriteInt(File, "Tester",PlayerInfo[playerid][pTester]);
    INI_WriteInt(File, "Vip",PlayerInfo[playerid][pVip]);
    INI_WriteInt(File, "Spawn",PlayerInfo[playerid][pSpawn]);
    INI_WriteInt(File, "Model",PlayerInfo[playerid][pModel]);
    INI_WriteInt(File, "Locked",PlayerInfo[playerid][pLocked]);
    INI_WriteInt(File, "FirstJoined", PlayerInfo[playerid][pFirstJoined]);
    INI_WriteInt(File, "Sex", PlayerInfo[playerid][pSex]);
    INI_WriteInt(File, "Age", PlayerInfo[playerid][pAge]);
    INI_WriteInt(File, "Origin", PlayerInfo[playerid][pOrigin]);
    INI_WriteInt(File, "Respect", PlayerInfo[playerid][pExp]);
    INI_WriteInt(File, "Warns", PlayerInfo[playerid][pWarns]);
    INI_WriteInt(File, "Selected", PlayerInfo[playerid][pSelected]);
    INI_WriteInt(File, "Continent", PlayerInfo[playerid][pPlace]);
    INI_WriteInt(File, "Muted", PlayerInfo[playerid][pMuted]);
    INI_WriteInt(File, "MuteTime", PlayerInfo[playerid][pMuteTime]);
    INI_WriteInt(File, "Ph", PlayerInfo[playerid][pNumber]);
    INI_WriteInt(File, "DriveLic", PlayerInfo[playerid][pDriveLic]);
    INI_Close(File);
    return 1;
}
Try that, I had the same problem as you.


Re: Money is losing each time I go off. - Zlaja - 25.07.2013

Same shit again.


Re: Money is losing each time I go off. - Mitchy - 25.07.2013

pawn Код:
PlayerInfo[playerid][pCash] = GetPlayerMoney(playerid);
Try that, you should run the registration values under a stock function and call it if he registers.

Put it under OnPlayerConnect


Re: Money is losing each time I go off. - ScRipTeRi - 25.07.2013

https://sampforum.blast.hk/showthread.php?tid=234691 this will help you