18.05.2015, 21:10
When I deposit money and if I deposit negative number like -99999999 it gives me 99999999 dollars how to fix this?
if ( amount < 0 )
{
SendClientMessage(playerid, -1, "Some error here to let the player know...");
}
else
{
// now do the main function
}
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!");
}
if(amount < 0) return SendClientMessage(playerid, -1, "You cannot deposit a negative amount.");
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!");
}