Код:
if(GetPlayerMoney(playerid) >= OwnableCarPrice[playerid])
{
if(IsPlayerConnected(OwnableCarOffer[playerid]))
{
GetPlayerName(OwnableCarOffer[playerid], giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
if(PlayerInfo[playerid][pPcarkey] == 999)
{
if(GetPlayerVehicleID(OwnableCarOffer[playerid]) == PlayerInfo[OwnableCarOffer[playerid]][pPcarkey])
{
PlayerInfo[playerid][pPcarkey] = PlayerInfo[OwnableCarOffer[playerid]][pPcarkey];
PlayerInfo[OwnableCarOffer[playerid]][pPcarkey] = 999;
}
else if(GetPlayerVehicleID(OwnableCarOffer[playerid]) == PlayerInfo[OwnableCarOffer[playerid]][pPcarkey2])
{
PlayerInfo[playerid][pPcarkey] = PlayerInfo[OwnableCarOffer[playerid]][pPcarkey2];
PlayerInfo[OwnableCarOffer[playerid]][pPcarkey2] = 999;
}
else if(GetPlayerVehicleID(OwnableCarOffer[playerid]) == PlayerInfo[OwnableCarOffer[playerid]][pPcarkey3])
{
PlayerInfo[playerid][pPcarkey] = PlayerInfo[OwnableCarOffer[playerid]][pPcarkey3];
PlayerInfo[OwnableCarOffer[playerid]][pPcarkey3] = 999;
}
else
{
SendClientMessage(playerid, COLOR_GREY, " Vehicle seller needs to be at his car !");
return 1;
}
format(string, sizeof(string), "* You bought a car for $%d from %s.",OwnableCarPrice[playerid],giveplayer);
SendClientMessage(playerid, COLOR_WHITE, string);
format(string, sizeof(string), "* %s has bought your car for $%d.",sendername,OwnableCarPrice[playerid]);
SendClientMessage(OwnableCarOffer[playerid], COLOR_WHITE, string);
RemovePlayerFromVehicle(OwnableCarOffer[playerid]);
SafeGivePlayerMoney(playerid, - OwnableCarPrice[playerid]);
SafeGivePlayerMoney(OwnableCarOffer[playerid], OwnableCarPrice[playerid]);
strmid(CarInfo[OwnableCarID[playerid]][cOwner], sendername, 0, strlen(sendername), 999);
}
else if(PlayerInfo[playerid][pPcarkey2] == 999)
{
if(GetPlayerVehicleID(OwnableCarOffer[playerid]) == PlayerInfo[OwnableCarOffer[playerid]][pPcarkey])
{
PlayerInfo[playerid][pPcarkey2] = PlayerInfo[OwnableCarOffer[playerid]][pPcarkey];
PlayerInfo[OwnableCarOffer[playerid]][pPcarkey] = 999;
}
else if(GetPlayerVehicleID(OwnableCarOffer[playerid]) == PlayerInfo[OwnableCarOffer[playerid]][pPcarkey2])
{
PlayerInfo[playerid][pPcarkey2] = PlayerInfo[OwnableCarOffer[playerid]][pPcarkey2];
PlayerInfo[OwnableCarOffer[playerid]][pPcarkey2] = 999;
}
else if(GetPlayerVehicleID(OwnableCarOffer[playerid]) == PlayerInfo[OwnableCarOffer[playerid]][pPcarkey3])
{
PlayerInfo[playerid][pPcarkey2] = PlayerInfo[OwnableCarOffer[playerid]][pPcarkey3];
PlayerInfo[OwnableCarOffer[playerid]][pPcarkey3] = 999;
}
else
{
SendClientMessage(playerid, COLOR_GREY, " Vehicle seller needs to be at his car !");
return 1;
}
format(string, sizeof(string), "* You bought a car for $%d from %s.",OwnableCarPrice[playerid],giveplayer);
SendClientMessage(playerid, COLOR_WHITE, string);
format(string, sizeof(string), "* %s has bought your car for $%d.",sendername,OwnableCarPrice[playerid]);
SendClientMessage(OwnableCarOffer[playerid], COLOR_WHITE, string);
RemovePlayerFromVehicle(OwnableCarOffer[playerid]);
SafeGivePlayerMoney(playerid, - OwnableCarPrice[playerid]);
SafeGivePlayerMoney(OwnableCarOffer[playerid], OwnableCarPrice[playerid]);
strmid(CarInfo[OwnableCarID[playerid]][cOwner], sendername, 0, strlen(sendername), 999);
}
else if(PlayerInfo[playerid][pPcarkey3] == 999)
{
if(GetPlayerVehicleID(OwnableCarOffer[playerid]) == PlayerInfo[OwnableCarOffer[playerid]][pPcarkey])
{
PlayerInfo[playerid][pPcarkey3] = PlayerInfo[OwnableCarOffer[playerid]][pPcarkey];
PlayerInfo[OwnableCarOffer[playerid]][pPcarkey] = 999;
}
else if(GetPlayerVehicleID(OwnableCarOffer[playerid]) == PlayerInfo[OwnableCarOffer[playerid]][pPcarkey2])
{
PlayerInfo[playerid][pPcarkey3] = PlayerInfo[OwnableCarOffer[playerid]][pPcarkey2];
PlayerInfo[OwnableCarOffer[playerid]][pPcarkey2] = 999;
}
else if(GetPlayerVehicleID(OwnableCarOffer[playerid]) == PlayerInfo[OwnableCarOffer[playerid]][pPcarkey3])
{
PlayerInfo[playerid][pPcarkey3] = PlayerInfo[OwnableCarOffer[playerid]][pPcarkey3];
PlayerInfo[OwnableCarOffer[playerid]][pPcarkey3] = 999;
}
else
{
SendClientMessage(playerid, COLOR_GREY, " Vehicle seller needs to be at his car !");
return 1;
}
format(string, sizeof(string), "* You bought a car for $%d from %s.",OwnableCarPrice[playerid],giveplayer);
SendClientMessage(playerid, COLOR_WHITE, string);
format(string, sizeof(string), "* %s has bought your car for $%d.",sendername,OwnableCarPrice[playerid]);
SendClientMessage(OwnableCarOffer[playerid], COLOR_WHITE, string);
RemovePlayerFromVehicle(OwnableCarOffer[playerid]);
SafeGivePlayerMoney(playerid, - OwnableCarPrice[playerid]);
SafeGivePlayerMoney(OwnableCarOffer[playerid], OwnableCarPrice[playerid]);
strmid(CarInfo[OwnableCarID[playerid]][cOwner], sendername, 0, strlen(sendername), 999);
}
else
{
SendClientMessage(playerid, COLOR_GREY, " You already have 3 cars ! ");
return 1;
}
DateProp(playerid);
DateProp(OwnableCarOffer[playerid]);
OnPropUpdate();
OnPlayerUpdate(playerid);
OnPlayerUpdate(OwnableCarOffer[playerid]);
OwnableCarOffer[playerid] = 999;
OwnableCarID[playerid] = 0;
OwnableCarPrice[playerid] = 0;
GameTextForPlayer(playerid, "~w~Congratulations~n~Don't forget to /v park it!", 5000, 3);
SendClientMessage(playerid, COLOR_GRAD2, "Congratulations on your new purchase!");
SendClientMessage(playerid, COLOR_GRAD2, "Type /vehiclemanual to view the vehicle manual!");
return 1;
}
else
{
SendClientMessage(playerid, COLOR_GREY, " Car seller is Offline !");
return 1;
}
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, " No-one offerd you any Ownable Car !");
return 1;
}
}