PDA

View Full Version : [HELP] vehicle destroying


Korisnik
11/06/2012, 05:54 PM
I made simple dialog for vehicle spawn.It works but I want to destroy vehicle when player leave it.I made something and destroy vehicle on exit but only for 1 player,if 2 players spawn vehicle at same time,it will destroy it only for first player.

here is the code..

I add this to top of the script:
new spawnvehicle;


Here I defined it:
#define DIALOG_VEHICLESPAWN 2


There is the command:
CMD:veh(playerid, params[])
{
ShowPlayerDialog(playerid, DIALOG_VEHICLESPAWN, DIALOG_STYLE_LIST, "Izaberite koje vozilo da stvorite", "Infernus \nBullet \nTurismo \nSuper GT \nPhoenix \nHotring \nSultan \nSandKing \nMonster \nNRG \nSpeeder \nMaverick ", "Stvori", "Odustani");
return 1;
}

dialog response:
case DIALOG_VEHICLESPAWN:
{
if(response)
{
new Float:Pos[4];

switch(listitem)
{
case 0:
{


GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
spawnvehicle = CreateVehicle(411, Pos[0], Pos[1], Pos[2], Pos[3], 0, 0, -1);
PutPlayerInVehicle(playerid, spawnvehicle, 0);
}
case 1:
{


GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
spawnvehicle = CreateVehicle(541, Pos[0], Pos[1], Pos[2], Pos[3], 0, 0, -1);
PutPlayerInVehicle(playerid, spawnvehicle, 0);
}
case 2:
{

GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
spawnvehicle = CreateVehicle(451, Pos[0], Pos[1], Pos[2], Pos[3], 0, 0, -1);
PutPlayerInVehicle(playerid, spawnvehicle, 0);
}
case 3:
{



GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
spawnvehicle = CreateVehicle(506, Pos[0], Pos[1], Pos[2], Pos[3], 0, 0, -1);
PutPlayerInVehicle(playerid, spawnvehicle, 0);
}
case 4:
{


GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
spawnvehicle = CreateVehicle(603, Pos[0], Pos[1], Pos[2], Pos[3], 0, 0, -1);
PutPlayerInVehicle(playerid, spawnvehicle, 0);
}
case 5:
{


GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
spawnvehicle = CreateVehicle(502, Pos[0], Pos[1], Pos[2], Pos[3], 0, 0, -1);
PutPlayerInVehicle(playerid, spawnvehicle, 0);
}
case 6:
{


GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
spawnvehicle = CreateVehicle(560, Pos[0], Pos[1], Pos[2], Pos[3], 0, 0, -1);
PutPlayerInVehicle(playerid, spawnvehicle, 0);
}
case 7:
{


GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
spawnvehicle = CreateVehicle(495, Pos[0], Pos[1], Pos[2], Pos[3], 0, 0, -1);
PutPlayerInVehicle(playerid, spawnvehicle, 0);
}
case 8:
{


GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
spawnvehicle = CreateVehicle(557, Pos[0], Pos[1], Pos[2], Pos[3], 0, 0, -1);
PutPlayerInVehicle(playerid, spawnvehicle, 0);
}
case 9:
{


GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
spawnvehicle = CreateVehicle(522, Pos[0], Pos[1], Pos[2], Pos[3], 0, 0, -1);
PutPlayerInVehicle(playerid, spawnvehicle, 0);
}
case 10:
{


GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
spawnvehicle = CreateVehicle(452, Pos[0], Pos[1], Pos[2], Pos[3], 0, 0, -1);
PutPlayerInVehicle(playerid, spawnvehicle, 0);
}
case 11:
{


GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
spawnvehicle = CreateVehicle(487, Pos[0], Pos[1], Pos[2], Pos[3], 0, 0, -1);
PutPlayerInVehicle(playerid, spawnvehicle, 0);
}
}
}
}

and there is OnPlayerExitVehicle callback:
{
DestroyVehicle(spawnvehicle);
return 1;
}
sorry fo bad copy of the script lines.
please help