how to make the car dissapear and not respawn after 2 minutes ?
#1

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 ?
Reply
#2

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)
Reply
#3

ok, thanks for the idea
Reply
#4

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)
Reply
#5

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)