[Help] Armour cmd
#1

Hi why won't this work it gives me the armour but it wont take the money for it.

Код:
if(strcmp(cmd,"/armour",true)==0)
	{
   			if(GetPlayerMoney(playerid) < 1500)
   			{
   			SendClientMessage(playerid,COLOR_RED,"** Sorry, you do not have enough cash. You need $1500!");
   			}
   			else
   			{
   			SetPlayerArmour(playerid,100);
   			}
   		if(!IsPlayerInRangeOfPoint(playerid, 10, 316.524994,-167.706985,999.661987) || IsPlayerInRangeOfPoint(playerid, 3,316.524994,-167.706985,999.661987))
   			{
   			SendClientMessage(playerid,COLOR_RED,"** Sorry, you are not in a store.");
   			}
	  return 1;
 	}
Reply
#2

Try this.
pawn Код:
if(strcmp(cmd,"/armour",true)==0)
    {
            if(GetPlayerMoney(playerid) < 1500)
            {
            SendClientMessage(playerid,COLOR_RED,"** Sorry, you do not have enough cash. You need $1500!");
            }
            else
            {
            SetPlayerArmour(playerid,100);
                        GivePlayerMoney(playerid, -1500); //
            }
        if(!IsPlayerInRangeOfPoint(playerid, 10, 316.524994,-167.706985,999.661987) || IsPlayerInRangeOfPoint(playerid, 3,316.524994,-167.706985,999.661987))
            {
            SendClientMessage(playerid,COLOR_RED,"** Sorry, you are not in a store.");
            }
      return 1;
    }
Reply
#3

Thanks man
worked out :P
Reply
#4

CMD:

pawn Код:
OnPlayerCommandText(playerid,cmdtext)
{
    if(strcmp(cmd,"/armour",true) == 0)
    {
        if(GetPlayerMoney(playerid) < 1500) // you need 1500 dolars to buy it or else you cant buy
        {
            SendClientMessage(playerid,COLOR_RED,"** Sorry, you do not have enough cash. You need $1500!");
            }
            else
            {
                SetPlayerArmour(playerid,100);
                GivePlayerMoney(playerid, -1500); // It Takes 1500 dolars
            }
            if(!IsPlayerInRangeOfPoint(playerid, 10, 316.524994,-167.706985,999.661987) || IsPlayerInRangeOfPoint(playerid, 3,316.524994,-167.706985,999.661987))
            {
                SendClientMessage(playerid,COLOR_RED,"** Sorry, you are not in a store.");
            }
            return 1;
        }
    }
}
DCMD:

pawn Код:
OnPlayerCommandText(playerid,cmdtext)
{
    dcmd(armour ,6 ,cmdtext);
    return 1;
}

dcmd_armour(playerid, params[])
{
    if(GetPlayerMoney(playerid) < 1500) // you need 1500 dolars to buy it or else you cant buy
    {
        SendClientMessage(playerid,COLOR_RED,"** Sorry, you do not have enough cash. You need $1500!");
    }
    else
    {
        SetPlayerArmour(playerid,100);
        GivePlayerMoney(playerid, -1500); // It Takes 1500 dolars
    }
    if(!IsPlayerInRangeOfPoint(playerid, 10, 316.524994,-167.706985,999.661987) || IsPlayerInRangeOfPoint(playerid, 3,316.524994,-167.706985,999.661987))
    {
        SendClientMessage(playerid,COLOR_RED,"** Sorry, you are not in a store.");
    }
        return 1;
    }
}
ZCMD:

pawn Код:
CMD:armour(playerid, params[])
{
    if(GetPlayerMoney(playerid) < 1500) // you need 1500 dolars to buy it or else you cant buy
    {
        SendClientMessage(playerid,COLOR_RED,"** Sorry, you do not have enough cash. You need $1500!");
    }
    else
    {
        SetPlayerArmour(playerid,100);
        GivePlayerMoney(playerid, -1500); // It Takes 1500 dolars
    }
    if(!IsPlayerInRangeOfPoint(playerid, 10, 316.524994,-167.706985,999.661987) || IsPlayerInRangeOfPoint(playerid, 3,316.524994,-167.706985,999.661987))
    {
        SendClientMessage(playerid,COLOR_RED,"** Sorry, you are not in a store.");
    }
        return 1;
    }
}
Reply
#5

Your welcome.
Sorry for the bad identation.
Reply
#6

maybe just.
if(strcmp(cmd,"/armour",true) == 0)
{
if(GetPlayerMoney(playerid) < 1500) return SendClientMessage(playerid,COLOR_RED,"** Sorry, you do not have enough cash. You need $1500!");
if(!IsPlayerInRangeOfPoint(playerid, 10, 316.524994,-167.706985,999.661987) || IsPlayerInRangeOfPoint(playerid, 3,316.524994,-167.706985,999.661987)) return SendClientMessage(playerid,COLOR_RED,"** Sorry, you are not in a store.");
SetPlayerArmour(playerid,100);
GivePlayerMoney(playerid, -1500); // It Takes 1500 dolars
return 1;
}
Reply
#7

i put dcmd,zcmd and cmd because someone maybe need zcmd or dcmd command
Reply
#8

Then you might as well check program flow. The armor command you put up will always work if the player has sufficient money, regardless of their current position. The position is only checked after the main part.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)