Bank command problem.
#1

I want to create a command that takes player's pCash (their serverside money) and stores it in to pBank. Now, I tried to make a /deposit command for that, but failed once again.

Here's the script:
pawn Код:
if(strcmp(cmdtext, "/deposit", true) == 0)
    {
        new tmp[256], idx, string[128];
        if(IsPlayerConnected(playerid))
        {
            tmp = strtok(cmdtext, idx);
            new cashdeposit = strval(tmp);
            if(!IsPlayerInRangeOfPoint(playerid, 5.0, 249.5040, -34.5105, 989.2328))
            {
                SendClientMessage(playerid, COLOR_GREY, "You are not at the bank.");
                return 1;
            }
            if(cashdeposit > PlayerInfo[playerid][pCash] || cashdeposit < 1)
            {
                SendClientMessage(playerid, COLOR_GREY, "You don't have that much.");
                return 1;
            }
            {
            PlayerInfo[playerid][pCash] = PlayerInfo[playerid][pCash]-cashdeposit;
            GivePlayerCash(playerid,-cashdeposit);
            new curfunds = PlayerInfo[playerid][pBank];
            PlayerInfo[playerid][pBank] = cashdeposit+PlayerInfo[playerid][pBank];
            SendClientMessage(playerid, COLOR_LIGHTBLUE, "|___ DEPOSIT INFO ___|");
            format(string, sizeof(string), "Old Balance: $%d", curfunds);
            SendClientMessage(playerid, COLOR_WHITE, string);
            format(string, sizeof(string), "Deposit: $%d", cashdeposit);
            SendClientMessage(playerid, COLOR_WHITE, string);
            SendClientMessage(playerid, COLOR_LIGHTBLUE, "|------------------------------------------|");
            format(string, sizeof(string), "New Balance: $%d", PlayerInfo[playerid][pBank]);
            SendClientMessage(playerid, COLOR_WHITE, string);
            return 1;
        }
        }
}
Now the problem is, when I come to the position of the bank and type in /deposit (with no value) it says "You don't have that much.", but when I type in /deposit with a value, for instance "/deposit 15", nothing happens, even no message appears.. So could anybody please help me?
Reply
#2

You need to minus/subtract the amount of money you currently have on hand and then add it to the bank.
Reply
#3

Quote:
Originally Posted by WarriorEd22
Посмотреть сообщение
You need to minus/subtract the amount of money you currently have on hand and then add it to the bank.
I did what you said right from the beginning. Now I modded a few lines, but it still doesn't work. Any ideas how to fix this?

pawn Код:
if(strcmp(cmdtext, "/deposit", true) == 0)
    {
        new tmp[256], idx, string[128];
        if(IsPlayerConnected(playerid))
        {
            tmp = strtok(cmdtext, idx);
            new cashdeposit = strval(tmp);
            if(!IsPlayerInRangeOfPoint(playerid, 5.0, 249.5040, -34.5105, 989.2328))
            {
                SendClientMessage(playerid, COLOR_GREY, "You are not at the bank.");
                return 1;
            }
            if(cashdeposit > PlayerInfo[playerid][pCash] || cashdeposit < 1)
            {
                SendClientMessage(playerid, COLOR_GREY, "You don't have that much.");
                return 1;
            }
            {
            PlayerInfo[playerid][pCash] = (GivePlayerCash(playerid, -strval(tmp)));
            GivePlayerCash(playerid,-strval(tmp));
            new curfunds = PlayerInfo[playerid][pBank];
            PlayerInfo[playerid][pBank] = (strval(tmp)+(PlayerInfo[playerid][pBank]));
            SendClientMessage(playerid, COLOR_LIGHTBLUE, "|___ DEPOSIT INFO ___|");
            format(string, sizeof(string), "Old Balance: $%d", curfunds);
            SendClientMessage(playerid, COLOR_WHITE, string);
            format(string, sizeof(string), "Deposit: $%d", cashdeposit);
            SendClientMessage(playerid, COLOR_WHITE, string);
            SendClientMessage(playerid, COLOR_LIGHTBLUE, "|------------------------------------------|");
            format(string, sizeof(string), "New Balance: $%d", PlayerInfo[playerid][pBank]);
            SendClientMessage(playerid, COLOR_WHITE, string);
            return 1;
        }
        }
}
Reply
#4

Try this :

pawn Код:
if(strcmp(cmdtext, "/deposit", true) == 0)
{
    new tmp[256], idx, string[128];
    if(IsPlayerConnected(playerid))
    {
        if(isnull(tmp)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /deposit [Money]");
       
        tmp = strtok(cmdtext, idx);
        new cashdeposit = strval(tmp);
        if(!IsPlayerInRangeOfPoint(playerid, 5.0, 249.5040, -34.5105, 989.2328))
        return SendClientMessage(playerid, COLOR_GREY, "You are not at the bank.");

        if(cashdeposit > PlayerInfo[playerid][pCash] || cashdeposit < 1)
        return SendClientMessage(playerid, COLOR_GREY, "You don't have that much.");

        PlayerInfo[playerid][pCash] = PlayerInfo[playerid][pCash]-cashdeposit;
        GivePlayerCash(playerid,-cashdeposit);
        new curfunds = PlayerInfo[playerid][pBank];
        PlayerInfo[playerid][pBank] = cashdeposit+PlayerInfo[playerid][pBank];
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "|___ DEPOSIT INFO ___|");
        format(string, sizeof(string), "Old Balance: $%d", curfunds);
        SendClientMessage(playerid, COLOR_WHITE, string);
        format(string, sizeof(string), "Deposit: $%d", cashdeposit);
        SendClientMessage(playerid, COLOR_WHITE, string);
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "|------------------------------------------|");
        format(string, sizeof(string), "New Balance: $%d", PlayerInfo[playerid][pBank]);
        SendClientMessage(playerid, COLOR_WHITE, string);
        return 1;
    }
}
Reply
#5

Quote:
Originally Posted by Shabi RoxX
Посмотреть сообщение
Try this :

pawn Код:
if(strcmp(cmdtext, "/deposit", true) == 0)
{
    new tmp[256], idx, string[128];
    if(IsPlayerConnected(playerid))
    {
        if(isnull(tmp)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /deposit [Money]");
       
        tmp = strtok(cmdtext, idx);
        new cashdeposit = strval(tmp);
        if(!IsPlayerInRangeOfPoint(playerid, 5.0, 249.5040, -34.5105, 989.2328))
        return SendClientMessage(playerid, COLOR_GREY, "You are not at the bank.");

        if(cashdeposit > PlayerInfo[playerid][pCash] || cashdeposit < 1)
        return SendClientMessage(playerid, COLOR_GREY, "You don't have that much.");

        PlayerInfo[playerid][pCash] = PlayerInfo[playerid][pCash]-cashdeposit;
        GivePlayerCash(playerid,-cashdeposit);
        new curfunds = PlayerInfo[playerid][pBank];
        PlayerInfo[playerid][pBank] = cashdeposit+PlayerInfo[playerid][pBank];
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "|___ DEPOSIT INFO ___|");
        format(string, sizeof(string), "Old Balance: $%d", curfunds);
        SendClientMessage(playerid, COLOR_WHITE, string);
        format(string, sizeof(string), "Deposit: $%d", cashdeposit);
        SendClientMessage(playerid, COLOR_WHITE, string);
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "|------------------------------------------|");
        format(string, sizeof(string), "New Balance: $%d", PlayerInfo[playerid][pBank]);
        SendClientMessage(playerid, COLOR_WHITE, string);
        return 1;
    }
}
Nope.. Still doesn't work :/
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)