SA-MP Forums Archive
My Bank System - 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: My Bank System (/showthread.php?tid=417948)



My Bank System - TheCancler - 23.02.2013

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;
}



Re: My Bank System - TheCancler - 23.02.2013

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);



Re: My Bank System - California_ - 23.02.2013

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,