OnPlayerText problem
#1

Okay, so I am doing this bank system and it works fine for when I withdraw and checks if I have enough money in the account, etc

But, when I attempt to deposit, if I have $0 and I enter '5000' it will deposit it and just '-' it away from me

pawn Код:
if(GetPVarInt(playerid, "DepositingMoney") == 1)
    {
        new b = GetPVarInt(playerid, "BankIDSlot");
        if(IsNumeric(text))
        {
            if(strval(text) >= GetPlayerMoney(playerid))
            {
                GivePlayerMoney(playerid, -strval(text));
                PlayerInfo[playerid][pCash] -= strval(text);
                format(szMessage, sizeof(szMessage), "* You have deposited $%d into the account.", strval(text));
                SendClientMessage(playerid, COLOR_LIGHTBLUE, szMessage);
                DeletePVar(playerid, "DepositingMoney");
                BankData[playerid][b][bMoney] += strval(text);
            }
            else SendClientMessage(playerid, COLOR_GREY, "* You do not have that much to deposit!"); DeletePVar(playerid, "DepositingMoney");
        }
        else SendClientMessage(playerid, COLOR_WHITE, "* You did not enter a number!"); DeletePVar(playerid, "DepositingMoney");
    }
code ^^
Reply
#2

You placed your if statement in the wrong order

pawn Код:
if(GetPVarInt(playerid, "DepositingMoney") == 1)
    {
        new b = GetPVarInt(playerid, "BankIDSlot");
        if(IsNumeric(text))
        {
            if(GetPlayerMoney(playerid) >= strval(text)) // Here :P
            {
                GivePlayerMoney(playerid, -strval(text));
                PlayerInfo[playerid][pCash] -= strval(text);
                format(szMessage, sizeof(szMessage), "* You have deposited $%d into the account.", strval(text));
                SendClientMessage(playerid, COLOR_LIGHTBLUE, szMessage);
                DeletePVar(playerid, "DepositingMoney");
                BankData[playerid][b][bMoney] += strval(text);
            }
            else SendClientMessage(playerid, COLOR_GREY, "* You do not have that much to deposit!"); DeletePVar(playerid, "DepositingMoney");
        }
        else SendClientMessage(playerid, COLOR_WHITE, "* You did not enter a number!"); DeletePVar(playerid, "DepositingMoney");
    }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)