Hello Again ;)
#1

Hello again , i got again a problem ... When i get a payday it's a problem , i didn't get interest from bank account

Код:
public PayDay( )
{
	for(new i=0; i<MAX_PLAYERS; i++)
	{
		new String[128], String2[128], s[128], RandomSum;
		new Stringfm1[64], Stringfm2[64], //Stringfm3[64],
		Stringfm4[64];

		RandomSum = random(1000*pInfo[i][pLevel]-900*pInfo[i][pLevel]) + 900*pInfo[i][pLevel];

		format(String2, sizeof(String2), "PayCheck: $%s | Balance: $%s", FormatMoney(RandomSum, Stringfm1), FormatMoney(pInfo[i][pBankCash], Stringfm2));
		format(s, sizeof(s), "Interest gained: 0.1 | Gained money: $%i", 1/10/100 * pInfo[i][pBankCash]);
		format(String,sizeof(String), "New Balance: $%s", FormatMoney(pInfo[i][pBankCash] + 1/10/100 * pInfo[i][pBankCash], Stringfm4));

		SendClientMessage(i, FactColor[0], "___________________ [ BANK STATMENT ] _____________________");
		SendClientMessage(i, FactColor[0], "");
		SendClientMessage(i, FactColor[0], String2);
		SendClientMessage(i, FactColor[0], s);
		SendClientMessage(i, FactColor[0], "___________________ [ NEW STATEMENT ] _____________________");
		SendClientMessage(i, FactColor[0], String);

		pInfo[i][pBankCash] += (0.001 * pInfo[i][pBankCash]);

		GivePlayerMoney(i, RandomSum);
		pInfo[i][pRespectPoints] ++;

		if(pInfo[i][pRobPoints] < 10)
			pInfo[i][pRobPoints] ++;

		if(pInfo[i][pFBlackList] > 0)
			pInfo[i][pFBlackList] --;
	}

	return 1;
}
"Gained money: $%i" there i got anytime 0 ...

Please help
Reply
#2

Hello!

What is printing here?
PHP код:
printf("pBankCash: %d",pInfo[i][pBankCash]); 
Put this in the callback to check how many cash do you have.

EDIT:
By the way.
The format should be so:
PHP код:
format(ssizeof(s), "Interest gained: 0.1 | Gained money: $%f"1/10/100 pInfo[i][pBankCash]); 
You are crunching with a float.

- Mencent
Reply
#3

Lol , it spam me pBankCash: 0 ..
Reply
#4

Well, do you have really 0$ or it is a mistake?
If it is a mistake, you should send us your loading code.

Nevertheless you should convert the %i to %f, if you haven't already done this.

- Mencent
Reply
#5

Ok , i have a /stats command and there show correctly my balance .. When a payday it's coming it shot correct my balance .. but don't give me the interest .. if you need code i will give you ..
Reply
#6

Can I see how you defined pBankCash?

- Mencent
Reply
#7

ok :

Код:
enum PlayerInfo
{
	pPass, pLevel, pSex, pAge, pSpawnHealth, pCash, pBankCash,
	pPhoneNr, pRespectPoints, pWarnings, pFactionW, pLotto,
	pWanted, pJail, pRobPoints, pKills, pDeaths, pJob, pDrugs,
	pFBlackList, pMaterials, pAdmin, pHelper, pFaction, pLeader,
	pRank, pSkin, pTutorial
};

new pInfo[MAX_PLAYERS][PlayerInfo];
And when i load it:

Код:
public LoadUser_data(playerid,name[],value[])
{
	// .....
	INI_Int("Money", pInfo[playerid][pCash]);
	INI_Int("BankMoney", pInfo[playerid][pBankCash]);

        // ....
	return 1;
}
Reply
#8

PHP код:
enum PlayerInfo
{
    
pPasspLevelpSexpAgepSpawnHealthpCashpBankCash,
    
pPhoneNrpRespectPointspWarningspFactionWpLotto,
    
pWantedpJailpRobPointspKillspDeathspJobpDrugs,
    
pFBlackListpMaterialspAdminpHelperpFactionpLeader,
    
pRankpSkinpTutorial
}; 
to

PHP код:
enum PlayerInfo
{
    
pPasspLevelpSexpAgepSpawnHealthpCashFloat:pBankCash,
    
pPhoneNrpRespectPointspWarningspFactionWpLotto,
    
pWantedpJailpRobPointspKillspDeathspJobpDrugs,
    
pFBlackListpMaterialspAdminpHelperpFactionpLeader,
    
pRankpSkinpTutorial
}; 
pBankCash should be a float so you have to conert INI_Int to INI_Float and where you saving the player too.

- Mencent
Reply
#9

Quote:
Originally Posted by Mencent
Посмотреть сообщение
PHP код:
enum PlayerInfo
{
    
pPasspLevelpSexpAgepSpawnHealthpCashpBankCash,
    
pPhoneNrpRespectPointspWarningspFactionWpLotto,
    
pWantedpJailpRobPointspKillspDeathspJobpDrugs,
    
pFBlackListpMaterialspAdminpHelperpFactionpLeader,
    
pRankpSkinpTutorial
}; 
to

PHP код:
enum PlayerInfo
{
    
pPasspLevelpSexpAgepSpawnHealthpCashFloat:pBankCash,
    
pPhoneNrpRespectPointspWarningspFactionWpLotto,
    
pWantedpJailpRobPointspKillspDeathspJobpDrugs,
    
pFBlackListpMaterialspAdminpHelperpFactionpLeader,
    
pRankpSkinpTutorial
}; 
pBankCash should be a float so you have to conert INI_Int to INI_Float and where you saving the player too.

- Mencent
http://i.imgur.com/lIXNIuL.png
Reply
#10

1/10/100 * pBankCash returns a rounded integer value

1/10/100 is 0.001, but returns as 0, so 0 * pBankCash = 0.

Try using this for the code:
Код:
format(s, sizeof(s), "Interest gained: 0.1 | Gained money: $%f", float(1/10/100 * pInfo[i][pBankCash]));
and see if that will print something other than 0.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)