17.03.2012, 10:44
Firstly, the owner of the vehicle would type this /givecar..It will send a request to the other party of giving a car..
Then, the party would type /approve givecar in order to receive the vehicle.
The ShowPlayerDialog code above..
The problem here is, the owner of the vehicle(The one who wants to give it still have the vehicle after giving it to the other party. In the easy word, it's duplicated..Something like that. Is there anyway to delete the first owner's car after sending it to the other party?
pawn Код:
command(givecar, playerid, params[])
{
new id, vehslot, string[128];
if(sscanf(params, "ud", id, vehslot))
{
SendClientMessage(playerid, ORANGE, "SYNTAX: /givecar [playerid] [1-3]");
}
else
{
if(IsPlayerConnectedEx(id))
{
if(vehslot >= 1 && vehslot < 4)
{
switch(vehslot)
{
case 1:
{
if(Player[playerid][PlayerCarModel] >= 1)
{
if(GetDistanceBetweenPlayers(playerid, id) < 7)
{
Player[id][PendingCarReceival] = playerid;
Player[id][GivingSlot] = 1;
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 /approve givecar).", GetName(playerid));
SendClientMessage(id, NICESKY, string);
}
else
{
SendClientMessage(playerid, WHITE, "You're too far away!");
}
}
else
{
SendClientMessage(playerid, WHITE, "You don't have a vehicle in this slot.");
}
}
case 2:
{
if(Player[playerid][PlayerCarModel2] >= 1)
{
if(GetDistanceBetweenPlayers(playerid, id) < 7)
{
Player[id][PendingCarReceival] = playerid;
Player[id][GivingSlot] = 2;
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 /approve givecar).", GetName(playerid));
SendClientMessage(id, NICESKY, string);
}
else
{
SendClientMessage(playerid, WHITE, "You're too far away!");
}
}
else
{
SendClientMessage(playerid, WHITE, "You don't have a vehicle in this slot.");
}
}
case 3:
{
if(Player[playerid][PlayerCarModel3] >= 1)
{
if(GetDistanceBetweenPlayers(playerid, id) < 7)
{
Player[id][PendingCarReceival] = playerid;
Player[id][GivingSlot] = 3;
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 /approve givecar).", GetName(playerid));
SendClientMessage(id, NICESKY, string);
}
else
{
SendClientMessage(playerid, WHITE, "You're too far away!");
}
}
else
{
SendClientMessage(playerid, WHITE, "You don't have a vehicle in this slot.");
}
}
}
}
else
{
SendClientMessage(playerid, WHITE, "Invalid vehicle slot.");
}
}
else
{
SendClientMessage(playerid, WHITE, "That specified player not connected or isn't logged in.");
}
}
return 1;
}
Then, the party would type /approve givecar in order to receive the vehicle.
pawn Код:
else if(strcmp(Usage, "GiveCar", true) == 0)
{
if(Player[playerid][PendingCarReceival] != -1)
{
if(IsPlayerConnectedEx(Player[playerid][PendingCarReceival]))
{
ShowPlayerDialog(playerid, 16, DIALOG_STYLE_LIST, "Slot to store in?", "Vehicle Slot 1\nVehicle Slot 2\nVehicle Slot 3\n", "Select", "Cancel");
}
else
{
Player[playerid][PendingCarReceival] = -1;
SendClientMessage(playerid, WHITE, "The deal is off, that player is no longer connected!");
}
}
else
{
SendClientMessage(playerid, WHITE, "There are no car trades to approve.");
}
}
The ShowPlayerDialog code above..
pawn Код:
case 16:
{
switch(listitem)
{
case 0:
{
if(Player[playerid][GivingSlot] == 1)
{
if(Player[playerid][CarLinkID] >= 1)
{
DestroyVehicle(Player[playerid][CarLinkID]);
Player[playerid][CarLinkID] = 0;
Player[playerid][PlayerCarModel] = 0;
}
GetVehiclePos(Player[Player[playerid][PendingCarReceival]][CarLinkID], Player[playerid][CarX], Player[playerid][CarY], Player[playerid][CarZ]);
DestroyVehicle(Player[Player[playerid][PendingCarReceival]][CarLinkID]);
Player[Player[playerid][PendingCarReceival]][CarLinkID] = 0;
Player[playerid][PlayerCarModel] = Player[Player[playerid][PendingCarReceival]][PlayerCarModel];
Player[playerid][PendingCarReceival] = -1;
SpawnOwnedCar(playerid, 1);
Player[Player[playerid][PendingCarReceival]][PlayerCarModel] = 0;
}
if(Player[playerid][GivingSlot] == 2)
{
if(Player[playerid][CarLinkID] >= 1)
{
DestroyVehicle(Player[playerid][CarLinkID]);
Player[playerid][CarLinkID] = 0;
Player[playerid][PlayerCarModel] = 0;
}
GetVehiclePos(Player[Player[playerid][PendingCarReceival]][Car2LinkID], Player[playerid][CarX], Player[playerid][CarY], Player[playerid][CarZ]);
DestroyVehicle(Player[Player[playerid][PendingCarReceival]][Car2LinkID]);
Player[Player[playerid][PendingCarReceival]][Car2LinkID] = 0;
Player[playerid][PlayerCarModel] = Player[Player[playerid][PendingCarReceival]][PlayerCarModel2];
Player[playerid][PendingCarReceival] = -1;
SpawnOwnedCar(playerid, 1);
Player[Player[playerid][PendingCarReceival]][PlayerCarModel2] = 0;
}
if(Player[playerid][GivingSlot] == 3)
{
if(Player[playerid][CarLinkID] >= 1)
{
DestroyVehicle(Player[playerid][CarLinkID]);
Player[playerid][CarLinkID] = 0;
Player[playerid][PlayerCarModel] = 0;
}
GetVehiclePos(Player[Player[playerid][PendingCarReceival]][Car3LinkID], Player[playerid][CarX], Player[playerid][CarY], Player[playerid][CarZ]);
DestroyVehicle(Player[Player[playerid][PendingCarReceival]][Car3LinkID]);
Player[Player[playerid][PendingCarReceival]][Car3LinkID] = 0;
Player[playerid][PlayerCarModel] = Player[Player[playerid][PendingCarReceival]][PlayerCarModel3];
Player[playerid][PendingCarReceival] = -1;
SpawnOwnedCar(playerid, 1);
Player[Player[playerid][PendingCarReceival]][PlayerCarModel3] = 0;
}
}
case 1:
{
if(Player[playerid][GivingSlot] == 1)
{
if(Player[playerid][Car2LinkID] >= 1)
{
DestroyVehicle(Player[playerid][Car2LinkID]);
Player[playerid][Car2LinkID] = 0;
Player[playerid][PlayerCarModel2] = 0;
}
GetVehiclePos(Player[Player[playerid][PendingCarReceival]][CarLinkID], Player[playerid][Car2X], Player[playerid][Car2Y], Player[playerid][Car2Z]);
DestroyVehicle(Player[Player[playerid][PendingCarReceival]][CarLinkID]);
Player[Player[playerid][PendingCarReceival]][CarLinkID] = 0;
Player[playerid][PlayerCarModel2] = Player[Player[playerid][PendingCarReceival]][PlayerCarModel];
Player[playerid][PendingCarReceival] = -1;
SpawnOwnedCar(playerid, 2);
Player[Player[playerid][PendingCarReceival]][PlayerCarModel] = 0;
}
if(Player[playerid][GivingSlot] == 2)
{
if(Player[playerid][Car2LinkID] >= 1)
{
DestroyVehicle(Player[playerid][Car2LinkID]);
Player[playerid][Car2LinkID] = 0;
Player[playerid][PlayerCarModel2] = 0;
}
GetVehiclePos(Player[Player[playerid][PendingCarReceival]][Car2LinkID], Player[playerid][Car2X], Player[playerid][Car2Y], Player[playerid][Car2Z]);
DestroyVehicle(Player[Player[playerid][PendingCarReceival]][Car2LinkID]);
Player[Player[playerid][PendingCarReceival]][Car2LinkID] = 0;
Player[playerid][PlayerCarModel2] = Player[Player[playerid][PendingCarReceival]][PlayerCarModel2];
Player[playerid][PendingCarReceival] = -1;
SpawnOwnedCar(playerid, 2);
Player[Player[playerid][PendingCarReceival]][PlayerCarModel2] = 0;
}
if(Player[playerid][GivingSlot] == 3)
{
if(Player[playerid][Car2LinkID] >= 1)
{
DestroyVehicle(Player[playerid][Car2LinkID]);
Player[playerid][Car2LinkID] = 0;
Player[playerid][PlayerCarModel2] = 0;
}
GetVehiclePos(Player[Player[playerid][PendingCarReceival]][Car3LinkID], Player[playerid][Car2X], Player[playerid][Car2Y], Player[playerid][Car2Z]);
DestroyVehicle(Player[Player[playerid][PendingCarReceival]][Car3LinkID]);
Player[Player[playerid][PendingCarReceival]][Car3LinkID] = 0;
Player[playerid][PlayerCarModel2] = Player[Player[playerid][PendingCarReceival]][PlayerCarModel3];
Player[playerid][PendingCarReceival] = -1;
SpawnOwnedCar(playerid, 2);
Player[Player[playerid][PendingCarReceival]][PlayerCarModel3] = 0;
}
}
case 2:
{
if(Player[playerid][GivingSlot] == 1)
{
if(Player[playerid][Car3LinkID] >= 1)
{
DestroyVehicle(Player[playerid][Car3LinkID]);
Player[playerid][Car3LinkID] = 0;
Player[playerid][PlayerCarModel3] = 0;
}
GetVehiclePos(Player[Player[playerid][PendingCarReceival]][CarLinkID], Player[playerid][Car3X], Player[playerid][Car3Y], Player[playerid][Car3Z]);
DestroyVehicle(Player[Player[playerid][PendingCarReceival]][CarLinkID]);
Player[Player[playerid][PendingCarReceival]][CarLinkID] = 0;
Player[playerid][PlayerCarModel3] = Player[Player[playerid][PendingCarReceival]][PlayerCarModel];
Player[playerid][PendingCarReceival] = -1;
SpawnOwnedCar(playerid, 3);
Player[Player[playerid][PendingCarReceival]][PlayerCarModel] = 0;
}
if(Player[playerid][GivingSlot] == 2)
{
if(Player[playerid][Car3LinkID] >= 1)
{
DestroyVehicle(Player[playerid][Car3LinkID]);
Player[playerid][Car3LinkID] = 0;
Player[playerid][PlayerCarModel3] = 0;
}
GetVehiclePos(Player[Player[playerid][PendingCarReceival]][Car2LinkID], Player[playerid][Car3X], Player[playerid][Car3Y], Player[playerid][Car3Z]);
DestroyVehicle(Player[Player[playerid][PendingCarReceival]][Car2LinkID]);
Player[Player[playerid][PendingCarReceival]][Car2LinkID] = 0;
Player[playerid][PlayerCarModel3] = Player[Player[playerid][PendingCarReceival]][PlayerCarModel2];
Player[playerid][PendingCarReceival] = -1;
SpawnOwnedCar(playerid, 3);
Player[Player[playerid][PendingCarReceival]][PlayerCarModel2] = 0;
}
if(Player[playerid][GivingSlot] == 3)
{
if(Player[playerid][Car3LinkID] >= 1)
{
DestroyVehicle(Player[playerid][Car3LinkID]);
Player[playerid][Car3LinkID] = 0;
Player[playerid][PlayerCarModel3] = 0;
}
GetVehiclePos(Player[Player[playerid][PendingCarReceival]][Car3LinkID], Player[playerid][Car3X], Player[playerid][Car3Y], Player[playerid][Car3Z]);
DestroyVehicle(Player[Player[playerid][PendingCarReceival]][Car3LinkID]);
Player[Player[playerid][PendingCarReceival]][Car3LinkID] = 0;
Player[playerid][PlayerCarModel3] = Player[Player[playerid][PendingCarReceival]][PlayerCarModel3];
Player[playerid][PendingCarReceival] = -1;
SpawnOwnedCar(playerid, 3);
Player[Player[playerid][PendingCarReceival]][PlayerCarModel3] = 0;
}
}
}
}
The problem here is, the owner of the vehicle(The one who wants to give it still have the vehicle after giving it to the other party. In the easy word, it's duplicated..Something like that. Is there anyway to delete the first owner's car after sending it to the other party?