01.02.2014, 07:59
Not sure why it doesn't work, otherwise you can just use mine:
PHP код:
CMD:sellmycar(playerid, params[])
{
for(new d = 0 ; d < MAX_PLAYERVEHICLES; d++)
{
if(IsPlayerInVehicle(playerid, PlayerVehicleInfo[playerid][d][pvId]))
{
new Float:health;
GetVehicleHealth(PlayerVehicleInfo[playerid][d][pvId], health);
if(PlayerInfo[playerid][pLevel] == 1)
{
SendClientMessageEx(playerid, COLOR_GREY, "You have to be level 2 or higher to be able to sell vehicles.");
return 1;
}
if(health < 500) return SendClientMessageEx(playerid, COLOR_GREY, " Your vehicle is too damaged to sell it.");
new string[128], giveplayerid, price;
if(sscanf(params, "ud", giveplayerid, price)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /sellmycar [playerid] [price]");
if(price < 1) return SendClientMessageEx(playerid, COLOR_GREY, "Price must be higher than 0.");
if(PlayerInfo[giveplayerid][pLevel] == 1)
{
SendClientMessageEx(playerid, COLOR_GREY, "The player has to be Level 2 or higher to be able to sell vehicles to them.");
return 1;
}
if(playerid == giveplayerid)
{
SendClientMessageEx(playerid, COLOR_GREY, "You can not use this command on yourself.");
return 1;
}
if(!IsPlayerConnected(giveplayerid)) return SendClientMessageEx(playerid, COLOR_GREY, "Player is currently not connected to the server.");
if (ProxDetectorS(8.0, playerid, giveplayerid))
{
VehicleOffer[giveplayerid] = playerid;
VehicleId[giveplayerid] = d;
VehiclePrice[giveplayerid] = price;
format(string, sizeof(string), "* You offered %s to buy this %s for $%d.", GetPlayerNameEx(giveplayerid), GetVehicleName(PlayerVehicleInfo[playerid][d][pvId]), price);
SendClientMessageEx(playerid, COLOR_LIGHTBLUE, string);
format(string, sizeof(string), "* %s has offered you their %s for $%d, (type /accept car) to buy.", GetPlayerNameEx(playerid), GetVehicleName(PlayerVehicleInfo[playerid][d][pvId]), price);
SendClientMessageEx(giveplayerid, COLOR_LIGHTBLUE, string);
return 1;
}
else
{
SendClientMessageEx(playerid, COLOR_GREY, "That player is not near you.");
return 1;
}
}
}
SendClientMessageEx(playerid, COLOR_GREY, " You need to be inside a vehicle that you own.");
return 1;
}