Major bank bug!
#1

When I deposit money and if I deposit negative number like -99999999 it gives me 99999999 dollars how to fix this?
Reply
#2

You shouldn't allow amount less than 1$, do something like this:
Код:
if ( amount < 0 )
{
    SendClientMessage(playerid, -1, "Some error here to let the player know...");
}

else 
{
   // now do the main function
}
If you don't get any part of it, send me your code
Reply
#3

Код:
This is what I have
if(DepositAmmount>CurrentAmmount) return SendClientMessage(playerid,COLOR_RED,"Nemate toliko novca za poloziti!");//if he has 20,and tries to deposit 21,he won't be able
		 else
		 {
	       new INI:bFile=INI_Open(BankDB(playerid));//else we open his DataBase
	       INI_SetTag(bFile,"BankData");//we set the tag
	       BankInfo[playerid][DepositedMoney]=BankInfo[playerid][DepositedMoney]+DepositAmmount;//we modify the deposit variable by adding to it the number inserted through the dialog
	       INI_WriteInt(bFile,"DepositedMoney",BankInfo[playerid][DepositedMoney]);//and of course we store it
	       INI_Close(bFile);//then we close the file
	       GivePlayerMoney(playerid,-DepositAmmount);//BUT the player looses the deposited ammount(he had 40$,deposited 20$,now he has 20$)
	       SendClientMessage(playerid,COLOR_YELLOW,"Uspjesno ste polozili novac,za informacije pisi /racuninfo!");
	     }
Reply
#4

We want the withdraw not the deposit
Reply
#5

Just put something like:
pawn Код:
if(amount < 0) return SendClientMessage(playerid, -1, "You cannot deposit a negative amount.");
Reply
#6

Is this want you need ?
Код:
if ( DepositAmmount > CurrentAmmount ) 
{
    return SendClientMessage(playerid,COLOR_RED,"Nemate toliko novca za poloziti!");//if he has 20,and tries to deposit 21,he won't be able
}

else if ( DepositAmmount > 0 )
{
    return SendClientMessage(playerid,COLOR_RED,"You need to deposit atleast 1$ or more!"); // if he wants  to deposit 0 or -1 or -99999
}

else
{
    new INI:bFile=INI_Open(BankDB(playerid));//else we open his DataBase
    INI_SetTag(bFile,"BankData");//we set the tag
    BankInfo[playerid][DepositedMoney]=BankInfo[playerid][DepositedMoney]+DepositAmmount;//we modify the deposit variable by adding to it the number inserted through the dialog
    INI_WriteInt(bFile,"DepositedMoney",BankInfo[playerid][DepositedMoney]);//and of course we store it
    INI_Close(bFile);//then we close the file
    GivePlayerMoney(playerid,-DepositAmmount);//BUT the player looses the deposited ammount(he had 40$,deposited 20$,now he has 20$)
    SendClientMessage(playerid,COLOR_YELLOW,"Uspjesno ste polozili novac,za informacije pisi /racuninfo!");
}
Reply
#7

Yea my withdraw works but deposit dont Ill try amirm method first thing in the mornin I think he has the solution
Reply
#8

The reason is just simple arithmetic - two negatives make a positive. When you subtract funds from the player, you probably do it like this GivePlayerMoney(playerid, -amount). But what happens if the variable amount is negative, ex., -100? In that case, it is interpreted as --100, which simplifies to +100.

The solution? Just have a separate condition when a player tries to deposit negative funds.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)