SA-MP Forums Archive
how to make the car dissapear and not respawn after 2 minutes ? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: how to make the car dissapear and not respawn after 2 minutes ? (/showthread.php?tid=642139)



how to make the car dissapear and not respawn after 2 minutes ? - muka - 25.09.2017

I have something like this:

Код HTML:
	    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,

Код HTML:
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 ?


Re: how to make the car dissapear and not respawn after 2 minutes ? - 10MIN - 25.09.2017

DISSAPEAR = DELETE = 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)


Re: how to make the car dissapear and not respawn after 2 minutes ? - muka - 25.09.2017

ok, thanks for the idea


Re: how to make the car dissapear and not respawn after 2 minutes ? - muka - 25.09.2017

Ok, I have something like this:

Код HTML:
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)


Re: how to make the car dissapear and not respawn after 2 minutes ? - kAn3 - 25.09.2017

No, you need to check wheter the player left the vehicle or not.


Re: how to make the car dissapear and not respawn after 2 minutes ? - SetPlayerNameTag - 26.09.2017

start Timer when player exit vehicle
Kill timer when player enter vehicle