11.04.2011, 18:09
I made a vehicle dialog but when i sapwn a car and the i spawn it again i spawns two cars.I want when i spawn a car and spawn it again the first car desapiar and spanw the second car.
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { GetPlayerPos(playerid, X, Y, Z); GetPlayerFacingAngle(playerid, Angle); GetPlayerInterior(playerid); if(dialogid == vmenu) { if(response) { if(listitem == 0) // INFERNUS { new CurrentVeh = CreateVehicle(411, X, Y, Z+1, Angle, random(100), random(100), -1); PutPlayerInVehicle(playerid,veh,0); LinkVehicleToInterior(veh, pInt); } if(listitem == 1) // NRG-500 { new CurrentVeh = CreateVehicle(522, X+5, Y, Z+1, Angle, random(100), random(100), -1); PutPlayerInVehicle(playerid,veh,0); LinkVehicleToInterior(veh, pInt); } if(listitem == 2) // BF Injection { new CurrentVeh = CreateVehicle(424, X+5, Y, Z+1, Angle, random(100), random(100), -1); PutPlayerInVehicle(playerid,veh,0); LinkVehicleToInterior(veh, pInt); } if(listitem == 3) // Turismo { new CurrentVeh = CreateVehicle(451, X+5, Y, Z+1, Angle, random(100), random(100), -1); PutPlayerInVehicle(playerid,veh,0); LinkVehicleToInterior(veh, pInt); } if(listitem == 4) // Maverick { new CurrentVeh = CreateVehicle(487, X+5, Y, Z+1, Angle, random(100), random(100), -1); PutPlayerInVehicle(playerid,veh,0); LinkVehicleToInterior(veh, pInt); } if(listitem == 5) // Phoenix { new CurrentVeh = CreateVehicle(603, X+5, Y, Z+1, Angle, random(100), random(100), -1); PutPlayerInVehicle(playerid,veh,0); LinkVehicleToInterior(veh, pInt); } if(listitem == 6) // Kart { new CurrentVeh = CreateVehicle(571, X+5, Y, Z+1, Angle, random(100), random(100), -1); PutPlayerInVehicle(playerid,veh,0); LinkVehicleToInterior(veh, pInt); } if(listitem == 7) // Elegy { new CurrentVeh = CreateVehicle(562, X+5, Y, Z+1, Angle, random(100), random(100), -1); PutPlayerInVehicle(playerid,veh,0); LinkVehicleToInterior(veh, pInt); } if(listitem == 8) // Sultan { new CurrentVeh = CreateVehicle(560, X+5, Y, Z+1, Angle, random(100), random(100), -1); PutPlayerInVehicle(playerid,veh,0); LinkVehicleToInterior(veh, pInt); } } return 1; } return 0;
new bool:IsVehicleCreated = false;
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, Angle);
GetPlayerInterior(playerid);
if(dialogid == vmenu)
{
if(response)
{
if(listitem == 0) // INFERNUS
{
if(IsVehicleCreated == true) { DestroyVehicle(CurrentVeh); IsVehicleCreated = false; }
new CurrentVeh = CreateVehicle(411, X, Y, Z+1, Angle, random(100), random(100), -1);
PutPlayerInVehicle(playerid,veh,0);
LinkVehicleToInterior(veh, pInt);
IsVehicleCreated = true;
}
}
return 1;
}
return 0;
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
new SpawnedCar[MAX_PLAYERS] = 0;
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, Angle);
GetPlayerInterior(playerid);
if(dialogid == vmenu)
{
if(response)
{
if(listitem == 0) // INFERNUS
{
new CurrentVeh = CreateVehicle(411, X, Y, Z+1, Angle, random(100), random(100), -1);
if(SpawnedCar[playerid] = 1) {
DestroyVehicle(CurrectVeh);
SpawnedCar[playerid] = 0);
}
else {
PutPlayerInVehicle(playerid,veh,0);
LinkVehicleToInterior(veh, pInt);
}
}
if(listitem == 1) // NRG-500
{
new CurrentVeh = CreateVehicle(522, X+5, Y, Z+1, Angle, random(100), random(100), -1);
PutPlayerInVehicle(playerid,veh,0);
LinkVehicleToInterior(veh, pInt);
}
if(listitem == 2) // BF Injection
{
new CurrentVeh = CreateVehicle(424, X+5, Y, Z+1, Angle, random(100), random(100), -1);
PutPlayerInVehicle(playerid,veh,0);
LinkVehicleToInterior(veh, pInt);
}
if(listitem == 3) // Turismo
{
new CurrentVeh = CreateVehicle(451, X+5, Y, Z+1, Angle, random(100), random(100), -1);
PutPlayerInVehicle(playerid,veh,0);
LinkVehicleToInterior(veh, pInt);
}
if(listitem == 4) // Maverick
{
new CurrentVeh = CreateVehicle(487, X+5, Y, Z+1, Angle, random(100), random(100), -1);
PutPlayerInVehicle(playerid,veh,0);
LinkVehicleToInterior(veh, pInt);
}
if(listitem == 5) // Phoenix
{
new CurrentVeh = CreateVehicle(603, X+5, Y, Z+1, Angle, random(100), random(100), -1);
PutPlayerInVehicle(playerid,veh,0);
LinkVehicleToInterior(veh, pInt);
}
if(listitem == 6) // Kart
{
new CurrentVeh = CreateVehicle(571, X+5, Y, Z+1, Angle, random(100), random(100), -1);
PutPlayerInVehicle(playerid,veh,0);
LinkVehicleToInterior(veh, pInt);
}
if(listitem == 7) // Elegy
{
new CurrentVeh = CreateVehicle(562, X+5, Y, Z+1, Angle, random(100), random(100), -1);
PutPlayerInVehicle(playerid,veh,0);
LinkVehicleToInterior(veh, pInt);
}
if(listitem == 8) // Sultan
{
new CurrentVeh = CreateVehicle(560, X+5, Y, Z+1, Angle, random(100), random(100), -1);
PutPlayerInVehicle(playerid,veh,0);
LinkVehicleToInterior(veh, pInt);
}
}
return 1;
}
return 0;
}