My Bank System
#1

Well I'm trying to create a bank system right now and it is my first time doing so. The problem is that it ignores me telling it to check if I have the money and everything else and sometimes just takes $1 or gives me $1 regardless of what I have on hand or what I have in the bank. It is very strange, it also doesn't affect my MySQL at all. I'm hoping there is a simple error somewhere in here that one of you can find.

Deposit
pawn Код:
if (dialogid == 5)//deposit
    {
    new cashonhand, amount, previousbank;
    cashonhand = GetPlayerMoney(playerid);
    amount = response;
    previousbank = UserStats[playerid][Bank];
    if (amount > cashonhand)
    {
    SendClientMessage(playerid, COLOR_RED, "SYSTEM: You don't have that much money.");
    ShowPlayerDialog(playerid,5, DIALOG_STYLE_INPUT, "Deposit:", "Enter amount to deposit:", "Deposit", "Cancel");
    return 1;
    }
    UserStats[playerid][Bank] = (previousbank + amount);
    SetPlayerMoney(playerid, (cashonhand - amount));
    }
Withdraw
pawn Код:
if (dialogid == 6)//withdraw
    {
    new cashonhand, amount, previousbank;
    cashonhand = GetPlayerMoney(playerid);
    amount = response;
    previousbank = UserStats[playerid][Bank];
    if (amount > previousbank)
    {
    SendClientMessage(playerid, COLOR_RED, "SYSTEM: You don't have that much money in your bank account.");
    ShowPlayerDialog(playerid,5, DIALOG_STYLE_INPUT, "Withdraw:", "Enter amount to withdraw:", "Withdraw", "Cancel");
    return 1;
    }
    UserStats[playerid][Bank] = (previousbank - amount);
    SetPlayerMoney(playerid, (cashonhand + amount));
    }
/bank
pawn Код:
CMD:bank(playerid, params[])
{
if (IsPlayerInRangeOfPoint(playerid, 1, 2308.8147,-13.2479,26.7422))
{
ShowPlayerDialog(playerid, 4, DIALOG_STYLE_LIST, "Bank","Deposit\nWithdraw","Select","Cancel");
}
return 1;
}
Reply
#2

Sorry for bumping my own post but I think this may help others in the future.
All I had to do is change -
pawn Код:
amount = response;
to
pawn Код:
amount = strval(inputtext);
Reply
#3

Change this

pawn Код:
if (amount < cashonhand)  
    {

You did ">" which tells the script does he have over The cash when you put "<" it tells if he doesnt have it.


Please reputate me.

Thanks,
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)