18.04.2013, 17:03
Try this:
pawn Код:
if(strcmp(cmd, "/sellvehicle", true) == 0)
{
new pvehicleid = GetPlayerVehicleID(playerid);
if(IsPlayerConnected(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /sellvehicle [playerid/PartOfName] [price]");
return 1;
}
giveplayerid = ReturnUser(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /sellvehicle [playerid/PartOfName] [price]");
return 1;
}
if(playerid == giveplayerid)
{
SendClientMessageEx(playerid, COLOR_GREY, "You can not use this command on yourself.");
return 1;
}
new price = strvalEx(tmp);
if(IsPlayerConnected(giveplayerid))
{
if(ProxDetectorS(7.0, playerid, giveplayerid))
{
if(IsPlayerInAnyVehicle(playerid))
{
if(PlayerVehicleID1[playerid] == pvehicleid)
{
SellVehicleOffer[giveplayerid] = playerid;
SellVehicleOfferTime[giveplayerid] = 60;
SellVehiclePrice[giveplayerid] = price;
SellVehicleSlot[giveplayerid] = 1;
format(string,sizeof(string),"You have offered to sell your %s to %s for $%d.",vehName[GetVehicleModel(pvehicleid)-400],PlayerName(giveplayerid),price);
SendClientMessage(playerid,COLOR_YELLOW,string);
format(string,sizeof(string),"%s has just offered to sell you his %s for $%d, /accept vehicle to buy the vehicle.",PlayerName(playerid),vehName[GetVehicleModel(pvehicleid)-400],price);
SendClientMessage(giveplayerid,COLOR_YELLOW,string);
}
else if(PlayerVehicleID2[playerid] == pvehicleid)
{
SellVehicleOffer[giveplayerid] = playerid;
SellVehicleOfferTime[giveplayerid] = 60;
SellVehiclePrice[giveplayerid] = price;
SellVehicleSlot[giveplayerid] = 2;
format(string,sizeof(string),"You have offered to sell your %s to %s for $%d.",vehName[GetVehicleModel(pvehicleid)-400],PlayerName(giveplayerid),price);
SendClientMessage(playerid,COLOR_YELLOW,string);
format(string,sizeof(string),"%s has just offered to sell you his %s for $%d, /accept vehicle to buy the vehicle.",PlayerName(playerid),vehName[GetVehicleModel(pvehicleid)-400],price);
SendClientMessage(giveplayerid,COLOR_YELLOW,string);
}
else if(PlayerVehicleID3[playerid] == pvehicleid)
{
SellVehicleOffer[giveplayerid] = playerid;
SellVehicleOfferTime[giveplayerid] = 60;
SellVehiclePrice[giveplayerid] = price;
SellVehicleSlot[giveplayerid] = 3;
format(string,sizeof(string),"You have offered to sell your %s to %s for $%d.",vehName[GetVehicleModel(pvehicleid)-400],PlayerName(giveplayerid),price);
SendClientMessage(playerid,COLOR_YELLOW,string);
format(string,sizeof(string),"%s has just offered to sell you his %s for $%d, /accept vehicle to buy the vehicle.",PlayerName(playerid),vehName[GetVehicleModel(pvehicleid)-400],price);
SendClientMessage(giveplayerid,COLOR_YELLOW,string);
}
else if(PlayerVehicleID4[playerid] == pvehicleid)
{
SellVehicleOffer[giveplayerid] = playerid;
SellVehicleOfferTime[giveplayerid] = 60;
SellVehiclePrice[giveplayerid] = price;
SellVehicleSlot[giveplayerid] = 4;
format(string,sizeof(string),"You have offered to sell your %s to %s for $%d.",vehName[GetVehicleModel(pvehicleid)-400],PlayerName(giveplayerid),price);
SendClientMessage(playerid,COLOR_YELLOW,string);
format(string,sizeof(string),"%s has just offered to sell you his %s for $%d, /accept vehicle to buy the vehicle.",PlayerName(playerid),vehName[GetVehicleModel(pvehicleid)-400],price);
SendClientMessage(giveplayerid,COLOR_YELLOW,string);
}
else if(PlayerVehicleID5[playerid] == pvehicleid)
{
SellVehicleOffer[giveplayerid] = playerid;
SellVehicleOfferTime[giveplayerid] = 60;
SellVehiclePrice[giveplayerid] = price;
SellVehicleSlot[giveplayerid] = 5;
format(string,sizeof(string),"You have offered to sell your %s to %s for $%d.",vehName[GetVehicleModel(pvehicleid)-400],PlayerName(giveplayerid),price);
SendClientMessage(playerid,COLOR_YELLOW,string);
format(string,sizeof(string),"%s has just offered to sell you his %s for $%d, /accept vehicle to buy the vehicle.",PlayerName(playerid),vehName[GetVehicleModel(pvehicleid)-400],price);
SendClientMessage(giveplayerid,COLOR_YELLOW,string);
}
else
{
SendClientMessage(playerid,COLOR_GREY," You are not at a vehicle that you own.");
}
}
else
{
SendClientMessage(playerid,COLOR_GREY," You are not at any vehicle.");
}
}
else
{
SendClientMessage(playerid,COLOR_GREY," You are not near the player.");
}
}
else
{
SendClientMessage(playerid,COLOR_GREY," Player Not Connected.");
}
}
return 1;
}