Problem with car buy command
#1

Hi!
I have following command:

pawn Код:
if (strcmp(cmdtext, "/purchase", true)==0)
    {

      if (GetPlayerMoney(playerid) < 15000)
      {
            SendClientMessage(playerid,COLOR_YELLOW,"Car Dealer: Sorry, you don't have enough money to buy a car.");
        }
        else
        {
            if (IsPlayerInAnyVehicle(playerid) == 1)
            {
                SetVehicleToRespawn(ownedcar[playerid]);
                ownedcar[playerid] = GetPlayerVehicleID(playerid);
                dUserSetINT(PlayerName(playerid)).("car",ownedcar[playerid]);
                owner[ownedcar[playerid]] = playerid;
                GivePlayerMoney(playerid,-15000);
                SendClientMessage(playerid,COLOR_YELLOW,"Car Dealer: You've bought a new vehicle! We hope you enjoy it!");
            }
            else
            {
          SendClientMessage(playerid,COLOR_YELLOW,"Car Dealer: Please get in a vehicle to buy it.");
            }
        }
        return 1;
    }

And when I have enough money and when I'm in vehicle, it appears me only: Unknown Command. If I don't have enough money, it shows me: Car Dealer: Sorry, you don't have enough money to buy a car.


Why it doesn't show this: "Car Dealer: You've bought a new vehicle! We hope you enjoy it!" when I have enough money? While compiling there is no warnings or errors and all things are defined etc...
Reply
#2

Don't you need return 0 at the end instead of return 1? And in your first if statement you should have return 1 after the message.
Reply
#3

pawn Код:
if (GetPlayerMoney(playerid)<15000) return SendClientMessage(playerid,COLOR_YELLOW,"Car Dealer: Sorry, you don't have enough money to buy a car.");
Reply
#4

Quote:
Originally Posted by MenaceX^
pawn Код:
if (GetPlayerMoney(playerid)<15000) return SendClientMessage(playerid,COLOR_YELLOW,"Car Dealer: Sorry, you don't have enough money to buy a car.");
If I don't have money, it works correctly. When I have money, it doesnt work correctly
Reply
#5

Код:
if (strcmp(cmdtext, "/purchase", true)==0) 
{

	  if (GetPlayerMoney(playerid) < 15000)
	  {
			return SendClientMessage(playerid,COLOR_YELLOW,"Car Dealer: Sorry, you don't have enough money to buy a car.");
	  }
	  if (IsPlayerInAnyVehicle(playerid) == 1)
	  {
			SetVehicleToRespawn(ownedcar[playerid]);
			ownedcar[playerid] = GetPlayerVehicleID(playerid);
			dUserSetINT(PlayerName(playerid)).("car",ownedcar[playerid]);
			owner[ownedcar[playerid]] = playerid;
			GivePlayerMoney(playerid,-15000);
			SendClientMessage(playerid,COLOR_YELLOW,"Car Dealer: You've bought a new vehicle! We hope you enjoy it!");
		}
		else
		{
	        return SendClientMessage(playerid,COLOR_YELLOW,"Car Dealer: Please get in a vehicle to buy it.");
		}
		return 1;
}
return 0; //at the end of onplayercommandtext
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)