/withdraw command
#1

can someone help trying to make it that if your not in the bank or at the atm you cant use this command someone help?

pawn Код:
if(strcmp(cmd, "/withdraw", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(BizzInfo[PlayerInfo[playerid][InBusiness]][bType] == 8 || IsPlayerNearBank(playerid))
            {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_WHITE, "USAGE: /withdraw [Amount]");
                format(string, sizeof(string), "  You have $%d in your bank account.", PlayerInfo[playerid][pAccount]);
                SendClientMessage(playerid, COLOR_GRAD3, string);
                return 1;
            }
            new cashdeposit = strvalEx(tmp);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_WHITE, "USAGE: /withdraw [Amount]");
                format(string, sizeof(string), "  You have $%d in your bank account.", PlayerInfo[playerid][pAccount]);
                SendClientMessage(playerid, COLOR_GRAD3, string);
                return 1;
            }
            if(cashdeposit > PlayerInfo[playerid][pAccount] || cashdeposit < 1)
            {
                SendClientMessage(playerid, COLOR_GRAD2, "   You don't have that much!");
                return 1;
            }
            if(cashdeposit < 20)
            {
                SendClientMessage(playerid, COLOR_GREY, "You can only withdraw a minimum of $20!");
                return 1;
            }
            PlayerInfo[playerid][pCash] = PlayerInfo[playerid][pCash]+cashdeposit;
            GivePlayerMoney(playerid,cashdeposit);
            PlayerInfo[playerid][pAccount] = PlayerInfo[playerid][pAccount]-cashdeposit;
            format(string, sizeof(string), "  You have withdrawn $%d from your bank account, Total: $%d ", cashdeposit,PlayerInfo[playerid][pAccount]);
            SendClientMessage(playerid, COLOR_YELLOW, string);
            return 1;
        }
    }
        return 1;
    }
Reply
#2

Use this :
pawn Код:
forward IsAtBank(playerid);
public IsAtBank(playerid)
{
    if(IsPlayerConnected(playerid))
    {
        if(PlayerToPoint(1.0, playerid, Ur bank position here))
        {
            return 1;
        }
    }
    return 0;
}
And above your code put If(IsAtBank(playerid))
Reply
#3

I suggest using IsPlayerInRangeOfPoint
Reply
#4

sorry im confused could you write the code for me?
Reply
#5

try this:
pawn Код:
forward IsAtBank(playerid);
public IsAtBank(playerid)
{
    if(IsPlayerConnected(playerid))
    {
        if(IsPlayerInRangeOfPoint(1.0, playerid, Ur bank position here))
        {
            return 1;
        }
    }
    return 0;
}

if(strcmp(cmd, "/withdraw", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
      if(IsAtBank(playerid))
       {   
            if(BizzInfo[PlayerInfo[playerid][InBusiness]][bType] == 8 || IsPlayerNearBank(playerid))
            {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_WHITE, "USAGE: /withdraw [Amount]");
                format(string, sizeof(string), "  You have $%d in your bank account.", PlayerInfo[playerid][pAccount]);
                SendClientMessage(playerid, COLOR_GRAD3, string);
                return 1;
            }
            new cashdeposit = strvalEx(tmp);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_WHITE, "USAGE: /withdraw [Amount]");
                format(string, sizeof(string), "  You have $%d in your bank account.", PlayerInfo[playerid][pAccount]);
                SendClientMessage(playerid, COLOR_GRAD3, string);
                return 1;
            }
            if(cashdeposit > PlayerInfo[playerid][pAccount] || cashdeposit < 1)
            {
                SendClientMessage(playerid, COLOR_GRAD2, "   You don't have that much!");
                return 1;
            }
            if(cashdeposit < 20)
            {
                SendClientMessage(playerid, COLOR_GREY, "You can only withdraw a minimum of $20!");
                return 1;
            }
            PlayerInfo[playerid][pCash] = PlayerInfo[playerid][pCash]+cashdeposit;
            GivePlayerMoney(playerid,cashdeposit);
            PlayerInfo[playerid][pAccount] = PlayerInfo[playerid][pAccount]-cashdeposit;
            format(string, sizeof(string), "  You have withdrawn $%d from your bank account, Total: $%d ", cashdeposit,PlayerInfo[playerid][pAccount]);
            SendClientMessage(playerid, COLOR_YELLOW, string);
            return 1;
        }
    else
    {SendClientMessage, playerid, COLOR_??,"You are not in the bank !");
    }
        return 1;
    }
Reply
#6

This should be good.

Explaination:

IsPlayerInRangeOfPoint - Checks weather the player is in the range of specific location or not.

Synyax - if(IsPlayerInRangeOfPoint(playerid, range, X, Y, Z);

Here I have used !IsPlayerInRangeOfPoint , the exclamation mark there check if he is not. (! = not)

I have used the default X,Y,Z cords for bank. Change it with yours if it doesn't works.

pawn Код:
if(strcmp(cmd, "/withdraw", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
           if(!IsPlayerInRangeOfPoint(2.5,5,2316.6189,-10.1248,26.7422) return SendClientMessage(playerid,0xCCCCCCAA,"You're not at bank.");
               if(BizzInfo[PlayerInfo[playerid][InBusiness]][bType] == 8 || IsPlayerNearBank(playerid))
                {
                  tmp = strtok(cmdtext, idx);
                  if(!strlen(tmp))
                 {
                     SendClientMessage(playerid, COLOR_WHITE, "USAGE: /withdraw [Amount]");
                    format(string, sizeof(string), "  You have $%d in your bank account.", PlayerInfo[playerid][pAccount]);
                    SendClientMessage(playerid, COLOR_GRAD3, string);
                   return 1;
                 }
                  new cashdeposit = strvalEx(tmp);
                  if(!strlen(tmp))
                 {
                    SendClientMessage(playerid, COLOR_WHITE, "USAGE: /withdraw [Amount]");
                    format(string, sizeof(string), "  You have $%d in your bank account.", PlayerInfo[playerid][pAccount]);
                    SendClientMessage(playerid, COLOR_GRAD3, string);
                    return 1;
                  }
            if(cashdeposit > PlayerInfo[playerid][pAccount] || cashdeposit < 1)
            {
                SendClientMessage(playerid, COLOR_GRAD2, "   You don't have that much!");
                return 1;
            }
            if(cashdeposit < 20)
            {
                SendClientMessage(playerid, COLOR_GREY, "You can only withdraw a minimum of $20!");
                return 1;
            }
            PlayerInfo[playerid][pCash] = PlayerInfo[playerid][pCash]+cashdeposit;
            GivePlayerMoney(playerid,cashdeposit);
            PlayerInfo[playerid][pAccount] = PlayerInfo[playerid][pAccount]-cashdeposit;
            format(string, sizeof(string), "  You have withdrawn $%d from your bank account, Total: $%d ", cashdeposit,PlayerInfo[playerid][pAccount]);
            SendClientMessage(playerid, COLOR_YELLOW, string);
            return 1;
        }
    }
        return 1;
    }
Reply
#7

pawn Код:
if(!IsPlayerInRangeOfPoint(2.5,5,2316.6189,-10.1248,26.7422) return SendClientMessage(playerid,0xCCCCCCAA,"You're not at bank.");
got tag mismatch, expected token: ")", but found "return"
Reply
#8

Quote:
Originally Posted by Donvalley
Посмотреть сообщение
pawn Код:
if(!IsPlayerInRangeOfPoint(2.5,5,2316.6189,-10.1248,26.7422) return SendClientMessage(playerid,0xCCCCCCAA,"You're not at bank.");
got tag mismatch, expected token: ")", but found "return"
Change it to this:

pawn Код:
if(!IsPlayerInRangeOfPoint(2.5,5,2316.6189,-10.1248,26.7422)) return SendClientMessage(playerid,0xCCCCCCAA,"You're not at bank.");
You forgot an extra parenthesis before 'return'.
Reply
#9

still get

warning 213: tag mismatch
Reply
#10

never mind had to change to

pawn Код:
if(!IsPlayerInRangeOfPoint(playerid,5,2316.6189,-10.1248,26.7422)) return SendClientMessage(playerid,COLOR_GRAD3,"You're not at bank.");
changed 2.5 to playerid
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)