I'm having an issue and I'm not really sure why this is happening, and to be honest I don't care. I just want it fixed and I've been pulling my hair out over it;
/sellcar works fine- /accept sellcar is what is bugging but I'll post both of them anyway.
pawn Код:
command(sellcar, playerid, params[])
{
new id, price, string[128];
if(sscanf(params, "dd", id, price))
{
return SendClientMessage(playerid, WHITE, "SYNTAX: /sellcar [playerid] [price]");
}
if(id == playerid) return SendClientMessage(playerid, WHITE, "You cannot sell your vehicle to yourself!");
else
{
if(IsPlayerConnectedEx(id))
{
if(IsPlayerInVehicle(playerid, Player[playerid][CarLinkID]))
{
if(Player[playerid][PlayerCarModel] >= 1)
{
if(GetDistanceBetweenPlayers(playerid, id) < 7)
{
if(Player[id][PlayerCarModel] <= 0 || Player[id][PlayerCarModel2] <= 0 || Player[id][PlayerCarModel3] <= 0)
{
Player[id][PendingCarReceival] = playerid;
Player[id][GivingSlot] = 1;
Player[id][CarSellPriceBeingCarried] = price;
format(string, sizeof(string), "You have requested to give your vehicle to %s from slot 1.", GetName(id));
SendClientMessage(playerid, WHITE, string);
format(string, sizeof(string), "%s is requesting to give you their vehicle (type /accept sellcar).", GetName(playerid));
SendClientMessage(id, LIGHTBLUE, string);
}
else
{
SendClientMessage(playerid, WHITE, "This player does not have any free open vehicle slots.");
return SendClientMessage(id, WHITE, "You do not have any free vehicle slots to take this vehicle!");
}
}
else
{
return SendClientMessage(playerid, WHITE, "You're too far away from the player.");
}
}
}
else if(IsPlayerInVehicle(playerid, Player[playerid][Car2LinkID]))
{
if(Player[playerid][PlayerCarModel] >= 1)
{
if(GetDistanceBetweenPlayers(playerid, id) < 7)
{
if(Player[id][PlayerCarModel] <= 0 || Player[id][PlayerCarModel2] <= 0 || Player[id][PlayerCarModel3] <= 0)
{
Player[id][PendingCarReceival] = playerid;
Player[id][GivingSlot] = 2;
Player[id][CarSellPriceBeingCarried] = price;
format(string, sizeof(string), "You have requested to give your vehicle to %s from slot 2.", GetName(id));
SendClientMessage(playerid, WHITE, string);
format(string, sizeof(string), "%s is requesting to give you their vehicle (type /accept sellcar).", GetName(playerid));
SendClientMessage(id, LIGHTBLUE, string);
}
else
{
SendClientMessage(playerid, WHITE, "This player does not have any free open vehicle slots.");
return SendClientMessage(id, WHITE, "You do not have any free vehicle slots to take this vehicle!");
}
}
else
{
return SendClientMessage(playerid, WHITE, "You're too far away from the player.");
}
}
}
else if(IsPlayerInVehicle(playerid, Player[playerid][Car3LinkID]))
{
if(Player[playerid][PlayerCarModel] >= 1)
{
if(GetDistanceBetweenPlayers(playerid, id) < 7)
{
if(Player[id][PlayerCarModel] <= 0 || Player[id][PlayerCarModel2] <= 0 || Player[id][PlayerCarModel3] <= 0)
{
Player[id][PendingCarReceival] = playerid;
Player[id][GivingSlot] = 3;
Player[id][CarSellPriceBeingCarried] = price;
format(string, sizeof(string), "You have requested to give your vehicle to %s from slot 3.", GetName(id));
SendClientMessage(playerid, WHITE, string);
format(string, sizeof(string), "%s is requesting to give you their vehicle (type /accept sellcar).", GetName(playerid));
SendClientMessage(id, LIGHTBLUE, string);
}
else
{
SendClientMessage(playerid, WHITE, "This player does not have any free open vehicle slots.");
return SendClientMessage(id, WHITE, "You do not have any free vehicle slots to take this vehicle! /abandoncar first.");
}
}
else
{
return SendClientMessage(playerid, WHITE, "You're too far away from the player.");
}
}
}
else
{
return SendClientMessage(playerid, WHITE, "Invalid vehicle slot.");
}
}
else
{
return SendClientMessage(playerid, WHITE, "That specified player not connected or isn't logged in.");
}
}
return 1;
}
// This is where /accept sellcar takes place
else if(strcmp(Usage, "sellcar", true) == 0)
{
if(Player[playerid][PendingCarReceival] >= 0)
{
if(IsPlayerConnectedEx(Player[playerid][PendingCarReceival]))
{
PurchaseSellCarInValidSlot(playerid);
format(string, sizeof(string), "You have bought %s's(%d) vehicle for $%d.", GetName(Player[playerid][PendingCarReceival]), Player[playerid][PendingCarReceival], Player[playerid][CarSellPriceBeingCarried]);
SendClientMessage(playerid, WHITE, string);
Player[playerid][Money] -= Player[playerid][CarSellPriceBeingCarried];
Player[Player[playerid][PendingCarReceival]][Money] += Player[playerid][CarSellPriceBeingCarried];
format(string, sizeof(string), "You have sold %s(%d) your vehicle for $%d.", GetName(playerid), playerid, Player[playerid][CarSellPriceBeingCarried]);
SendClientMessage(playerid, WHITE, string);
}
else
{
Player[playerid][PendingCarReceival] = -1;
SendClientMessage(playerid, WHITE, "The deal is off, that player is no longer connected!");
}
}
else
{
return SendClientMessage(playerid, WHITE, "There are no car trades to accept.");
}
}
What it's doing is when a player /accept sellcar's it says unknown command and sometimes it works- sometimes it doesn't. I don't really know how to explain. REP+
You shouldn't be checking if pCarRecival is more or equal to 0 if it's a playerID. You should be checking if they are connected / if it is not equal to INVALID_PLAYER_ID. Also, maybe there is something wrong with your IsPlayerConnectedEx function.