28.03.2014, 21:30
I am creating a vehicle system, I have done everything until i somehow am stumped on this dealership thing.
I am trying to create a dealership where the cars are parked outside and you walk up to them, when you try to enter a textdraw opens asking the player to type 1 to buy and 2 to close the textdraw. when the player buys a vehicle any vehicle in the lot, the player always ends up buying the first car in the lot. I am using loops and i am having a difficult time getting the player to buy the correct car.
Here's is my script when the player tries to buy the car:
If you need any other codes scriptlets to look at please let me know
Thank You
I am trying to create a dealership where the cars are parked outside and you walk up to them, when you try to enter a textdraw opens asking the player to type 1 to buy and 2 to close the textdraw. when the player buys a vehicle any vehicle in the lot, the player always ends up buying the first car in the lot. I am using loops and i am having a difficult time getting the player to buy the correct car.
Here's is my script when the player tries to buy the car:
Код:
public OnPlayerText(playerid, text[])
{
for(new idx=1; idx<MAX_CAR; idx++)
{
new vehicleid;
vehicleid = GetPlayerVehicleID(playerid);
if(PlayerInfo[playerid][BuyCarMenu] == 1 && CarInfo[idx][cStatus] == 2)
{
if(text[0] == '1') // Buy Car
{
PutPlayerInVehicle(playerid, CarInfo[idx][cVID], 0);
new name[MAX_PLAYER_NAME+1], string[24+MAX_PLAYER_NAME+1];
SendClientMessage(playerid, COLOR_RED, "Enjoy your new vehicle");
TextDrawHideForPlayer(playerid, BuyCar);
CarInfo[idx][cStatus] = 1;
CarInfo[idx][cDealership] = 0;
GetPlayerName(playerid, name, sizeof(name));
format(CarInfo[idx][cOwner], 32, "%s", name);
format(string, sizeof(string), "License Plate Expired");
Update3DTextLabelText(CarInfo[idx][Text3D:cText], COLOR_RED, "License Plate Expired");
Attach3DTextLabelToVehicle(CarInfo[idx][Text3D:cText], CarInfo[idx][cVID], 0.0, 0.0, 2.0);
return 0;
}
if(text[0] == '2') // Close
{
TextDrawHideForPlayer(playerid, BuyCar);
PlayerInfo[playerid][BuyCarMenu] = 0;
return 0;
}
}
}
}
Thank You

