PDA

View Full Version : how to make the car dissapear and not respawn after 2 minutes ?


muka
25/09/2017, 02:02 PM
I have something like this:

if(response)
{
switch(listitem)
{
case 0:
{
GetPlayerFacingAngle(playerid, angle);
GetPlayerPos(playerid, x, y, z);
national_veh1 = CreateVehicle(481, x, y, z, angle, 144, 145, 120, 0);
PutPlayerInVehicle(playerid,national_veh1,0);
i[playerid] = 1;
reset1(playerid);
return 1;
}


As you can see,

national_veh1 = CreateVehicle(481, x, y, z, angle, 144, 145, 120, 0);

This will spawn me a vehicle.
If it has no driver/passager for 2 minutes it will respawn.

The problem is that it's respawning in the place you can request the vehicle, and not dissapearing from the map.

How can I make it DISSAPEAR and not RESPAWN ?

10MIN
25/09/2017, 02:09 PM
DISSAPEAR = DELETE = DestroyVehicle (http://wiki.sa-mp.com/wiki/DestroyVehicle)

Use a timer, and pass the vehicle id to delete it after a specified amount of time. (don't forget to put some checks, so a player won't have his vehicle gone)

muka
25/09/2017, 02:14 PM
ok, thanks for the idea

muka
25/09/2017, 04:45 PM
Ok, I have something like this:


new vehicleid;
// spawning the vehicle
case 0:
{
GetPlayerFacingAngle(playerid, angle);
GetPlayerPos(playerid, x, y, z);
ticau_veh1 = CreateVehicle(481, x, y, z, angle, 144, 145, 125, 0);
PutPlayerInVehicle(playerid,ticau_veh1,0);
vehicleid = GetPlayerVehicleID(playerid);
i[playerid] = 1;
reset1(playerid);
destroy1(playerid, vehicleid);
return 1;
}



public destroy1(playerid, vehicleid)
{
SetTimerEx("destroy2",1000,true,"d",playerid);
return 1;
}


forward destroy2(playerid, vehicleid);
public destroy2(playerid, vehicleid)
{

if (IsPlayerInVehicle(playerid, vehicleid) == 0)
{
DestroyVehicle(vehicleid);

} else {
destroy1(playerid, vehicleid);
}

return 1;
}


But it's not working . ( i can compile it BUT the vehicle is not dissapearing)

kAn3
25/09/2017, 10:49 PM
No, you need to check wheter the player left the vehicle or not.

SetPlayerNameTag
26/09/2017, 02:31 AM
start Timer when player exit vehicle
Kill timer when player enter vehicle