SA-MP Forums Archive
Problem with car buy command - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Problem with car buy command (/showthread.php?tid=80584)



Problem with car buy command - Jakku - 05.06.2009

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...


Re: Problem with car buy command - lol2112 - 05.06.2009

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.


Re: Problem with car buy command - MenaceX^ - 05.06.2009

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



Re: Problem with car buy command - Jakku - 05.06.2009

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


Re: Problem with car buy command - lol2112 - 05.06.2009

Код:
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
}