28.12.2012, 08:52
Give this one a shot:
pawn Код:
CMD:sellmyveh(playerid, params[])
{
new id, price, Float: x, Float: y, Float: z, string[128];
new count = 0;
for(new v = 0; v < MAX_PLAYER_VEHICLES; v++)
{
if(IsPlayerInVehicle(playerid, playerVehicles[playerid][v][cID]))
{
count++;
}
else continue;
}
if(count == 0) return SendClientMessage(playerid, COLOR_GREY, "You need to be inside a vehicle that you own to do this!");
if(sscanf(params, "ud", id, price)) return SendClientMessage(playerid, COLOR_GREY, "[USAGE]: /sellmyveh [playerid] [price]");
if(!IsPlayerConnected(id) || id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_GREY, "Invalid player ID!");
GetPlayerPos(id, x, y, z);
if(!IsPlayerInRangeOfPoint(playerid, 5.0, x, y, z)) return SendClientMessage(playerid, COLOR_GREY, "You are not close enough to that player!");
format(string, sizeof(string), "%s has offered you to buy their %s for $%d. (/accept vehicle)", GetPlayerNameEx(playerid), VehicleName[playerVehicles[playerid][GetPlayerVehicleID(playerid)][(cModelID] - 400)]], price);
SendClientMessage(id, COLOR_LIGHTBLUE, string);
format(string, sizeof(string), "You have offered %s to buy your %s for $%d.", GetPlayerNameEx(id), VehicleName[playerVehicles[playerid][GetPlayerVehicleID(playerid)][(cModelID - 400)]], price);
SendClientMessage(playerid, COLOR_LIGHTGREEN, string);
SetPVarInt(id, "carSeller", playerid);
SetPVarInt(id, "carPrice", price);
SetPVarInt(id, "carSaleID", GetPlayerVehicleID(playerid));
return 1;
}