PDA

View Full Version : [HELP]Bank interest


[Aka]Dragonu
02/09/2011, 08:00 AM
Hello again, I made a bank interest sistem to give you 2% of your total stored in bank money every payday, but for example if I have stored in bank 100.000$ and on payday I recieve from interest let's say 1040$ it will only deposit 1000$ and the other 40$ not, why is that ? Here is the script :

new string[128];
for(new i=0; i<MAX_SLOTS; i++)
{
//if(IsPlayerConnected(i))
//{
format(string, sizeof(string), "_______< Bank of %s >________", GAMEMODE_MAP);
SendClientMessage(i, COLOR_BLUE, string);
format(string, sizeof(string), " Level: %d, Exp: %d", PlayerInfo[i][pLevel], PlayerInfo[i][pExp]);
SendClientMessage(i, COLOR_GREY, string);
format(string, sizeof(string), " Balance: %d$", PlayerInfo[i][pBank]);
SendClientMessage(i, COLOR_GREY, string);
format(string, sizeof(string), " Drugs: %d gram.", PlayerInfo[i][pDrugs]);
SendClientMessage(i, COLOR_GREY, string);

PlayerInfo[i][pExp] ++;
if(PlayerInfo[i][pVip] == 1){PlayerInfo[i][pExp] ++;} // 1 Extra exp for vips.
if(gTeam[i] != TEAM_COP && gTeam[i] != TEAM_ARMY)
{
PlayerInfo[i][pDrugs] += 2;
if(PlayerInfo[i][pVip] == 1){PlayerInfo[i][pDrugs] += 3;}
} // 1 Extra gram drugs for vips.
PlayerInfo[i][pBank] = PlayerInfo[i][pBank]+PlayerInfo[i][pBank]*2/100;

if(PlayerInfo[i][pExp] >= PlayerInfo[i][pLevel])
{
PlayerInfo[i][pExp] = 0;
PlayerInfo[i][pLevel] ++;
}

SendClientMessage(i, COLOR_WHITE, "|--------------------------------------------------|");
format(string, sizeof(string), " New Level: %d, New Exp: %d", PlayerInfo[i][pLevel], PlayerInfo[i][pExp]);
SendClientMessage(i, COLOR_GREY, string);
format(string, sizeof(string), " New Balance: %d$", PlayerInfo[i][pBank]);
SendClientMessage(i, COLOR_GREY, string);
format(string, sizeof(string), " Bank Interest: 2/100", PlayerInfo[i][pBank]);
SendClientMessage(i, COLOR_GREY, string);
format(string, sizeof(string), " New Drugs: %d gram.", PlayerInfo[i][pDrugs]);
SendClientMessage(i, COLOR_GREY, string);
SendClientMessage(i, COLOR_BLUE, "________________________________");
format(string, sizeof(string), "~b~PayDay~n~~w~Paycheck ~n~~g~%d$", PlayerInfo[i][pBank]*2/100);
GameTextForPlayer(i, string, 5000, 1);

UpdatePlayer(i); // Save the stats of the player.
//}
} If you need something else just let me know. Thanks in advance.

[Aka]Dragonu
02/09/2011, 05:20 PM
BUMP!!! ANY HELP PLEASE?

cessil
03/09/2011, 02:06 AM
this line here requires a float to store the data or the use of floatround, also the use of more brackets wouldn't hurt.
PlayerInfo[i][pBank] = PlayerInfo[i][pBank]+PlayerInfo[i][pBank]*2/100;

like this
PlayerInfo[i][pBank] = floatround(((PlayerInfo[i][pBank] + PlayerInfo[i][pBank] ) * 2 )/100,floatround_round);
now you can see more clearly what's going on.

also on this line, you could just send the message "Bank Interest: 2/100" since you're not using any %'s you're not formatting any number in.
IIRC if you use %%%% then it'll show as a % in game so you could use 2%%%% and in game it'll say 2%
format(string, sizeof(string), " Bank Interest: 2/100", PlayerInfo[i][pBank]);

[Aka]Dragonu
03/09/2011, 06:28 AM
Hey man now instead of increasing my payday interest it deacreases a lot! like from 100k when payday comes my money will be turned to 60k and so on. What can I do further?

[Aka]Dragonu
03/09/2011, 02:16 PM
BUMP!!!