Making bank interest code.
#1

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
Reply
#2

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

Код:
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);
Reply
#4

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

EDIT: Working! Thanks
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)