Major bank bug! - 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)
+--- Thread: Major bank bug! (
/showthread.php?tid=574608)
Major bank bug! -
baba1234 - 18.05.2015
When I deposit money and if I deposit negative number like -99999999 it gives me 99999999 dollars how to fix this?
Re: Major bank bug! -
amirm3hdi - 18.05.2015
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
Re: Major bank bug! -
baba1234 - 18.05.2015
Код:
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!");
}
Re: Major bank bug! -
nezo2001 - 18.05.2015
We want the withdraw not the deposit
Re: Major bank bug! -
Abagail - 18.05.2015
Just put something like:
pawn Код:
if(amount < 0) return SendClientMessage(playerid, -1, "You cannot deposit a negative amount.");
Re: Major bank bug! -
amirm3hdi - 18.05.2015
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!");
}
Re: Major bank bug! -
baba1234 - 18.05.2015
Yea my withdraw works but deposit dont Ill try amirm method first thing in the mornin I think he has the solution
Re: Major bank bug! -
Macluawn - 18.05.2015
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.