Ok, so i got my /buycar command and what i want it to do is create a car when the player types /buycar, The car that gets created is the one the player will own, I'm not to sure on how to do that. Anyone mind helping me with this? SO for example. You type /buycar in the display car it creates a car then makes the car that was created when they type /buycar owned by that player.
pawn Code:
if(strcmp(cmd, "/buycar", true) == 0)
{
if(Carcheck(playerid) == 1){
if(PlayerInfo[playerid][pCKey] > 0)
{
SendClientMessage(playerid, COLOR_RED, "ERROR: You already own a car");
return 1;
}
if(!IsPlayerInAnyVehicle(playerid))
{
SendClientMessage(playerid, COLOR_RED, "ERROR: You are not in a vehicle!");
return 1;
}
new carid = GetPlayerVehicleID(playerid)-1;
if(!IsOwnable(carid))
{
SendClientMessage(playerid, COLOR_RED, "ERROR: This car is not purchasable");
return 1;
}
if(CInfo[carid][cBought] > 0)
{
format(string, sizeof(string), "ERROR: %s owns this vehicle, contact him to buy it", CInfo[carid][cOwner]);
SendClientMessage(playerid, COLOR_RED, string);
return 1;
}
if(CInfo[carid][cLevel] > PlayerInfo[playerid][pLevel])
{
format(string, sizeof(string), "ERROR: This car is for level %d+ players only", CInfo[carid][cLevel]);
SendClientMessage(playerid, COLOR_RED, string);
return 1;
}
if(CInfo[carid][cValue] > PlayerInfo[playerid][pCash])
{
format(string, sizeof(string), "ERROR: This car costs $%d, you need $%d more to buy it", CInfo[carid][cValue], CInfo[carid][cValue] - PlayerInfo[playerid][pCash]);
SendClientMessage(playerid, COLOR_RED, string);
return 1;
}
CInfo[carid][cBought] = 1;
PlayerInfo[playerid][pCKey] = carid+1;
GetPlayerName(playerid, sendername, sizeof(sendername));
strmid(CInfo[carid][cOwner], sendername, 0, strlen(sendername), 255);
AntiHack(playerid,-CInfo[carid][cValue]);
SendClientMessage(playerid, COLOR_GREEN, "Congratulations, you now own a car, type /carinfo");
CreateVehicle(CInfo[carid][cMod], 1601.3467,-1027.4048,23.7378,186.6128, CInfo[carid][cCol1], CInfo[carid][cCol2], never);
TogglePlayerControllable(playerid, 1);
RemovePlayerFromVehicle(playerid);
OnPropUpdate();
return 1;
}
}