SA-MP Forums Archive
Making bank interest code. - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Making bank interest code. (/showthread.php?tid=195063)



Making bank interest code. - Danny - 01.12.2010

Hi,

Does anyone know what's wrong with this piece of code? It gives the players wrong amounts of money (too much or negative amounts)

Код:
public Paycheck() {
	new pstring[128];
	for(new i=0; i<MAX_PLAYERS; i++) {
		if(gTeam[i] == TEAM_CIVILIAN) {
		    GetPlayerName(i, iname, sizeof(iname));
			pInfo[i][bankmoney] = dini_Int(iname,"bankmoney");
 			SendClientMessage(i, COLOR_YELLOW,"=============|PAYCHECK|=================");
			SendClientMessage(i, COLOR_GREEN,"Workless money: $500");
			GivePlayerMoney(i, 500);
			SendClientMessage(i, COLOR_GREEN,"Extra money due playtime: $500");
			GivePlayerMoney(i, 500);
			format(str, sizeof str,"Bank Interest: 2 percent ($%d + $%d)",pInfo[i][bankmoney],(pInfo[i][bankmoney]/100)*2);
			dini_IntSet((iname),"bankmoney",(pInfo[i][bankmoney]/100)*2);
			SendClientMessage(i, COLOR_GREEN, str);
			format(pstring, sizeof pstring,"Incoming Tax: -$%d",INCOMINGTAX);
			SendClientMessage(i, COLOR_RED, pstring);
			GivePlayerMoney(i, -INCOMINGTAX);
			SendClientMessage(i, COLOR_YELLOW,"=========================================");
		}
If someone can help me, please respond
Greetz,
Danny


Re: Making bank interest code. - Haegon - 01.12.2010

Are you wanting it to calculate the money before or after the bonuses?


Re: Making bank interest code. - leong124 - 01.12.2010

Код:
dini_IntSet((iname),"bankmoney",(pInfo[i][bankmoney]/100)*2);
Do you want to set the latest amount of money of that player?
If yes, why not
Код:
dini_IntSet((iname),"bankmoney",pInfo[i][bankmoney] + (pInfo[i][bankmoney]/100)*2);



Re: Making bank interest code. - Danny - 01.12.2010

@Haegon: After.
@Leon124: Damn, that was a dumb mistake, thanks. I'll let you know if its working or not.

EDIT: Working! Thanks