23.02.2013, 07:50
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
Withdraw
/bank
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));
}
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));
}
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;
}