Car Destroy With SetTimter
#1

Hello!
I need some help to make a car destroy with settimter.
I make a car destroy with time but it not work it wher a player stay 15 sec in a car in auto exit player from vehicles:

Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
	if(newstate == PLAYER_STATE_DRIVER && oldstate == PLAYER_STATE_ONFOOT)
	{
	new vid = GetPlayerVehicleID(playerid);
 	SetTimerEx("destroy", 15000, false, "d", vid);
	}
	return 1;
}

forward destroy(vid);
public destroy(vid)
{
	DestroyVehicle(vid);
	return 1;
}
Thanks!
Reply
#2

So, if im right: If youre in a car, and after 15 seconds in the car, it needs to be destroyed?
Or: If youre in a car, and leave the car, wait 15 seconds, the car needs to be destroyed?
Reply
#3

Yes if a player in any car and player leave car it need to destroy car
Reply
#4

pawn Код:
AddStaticVehicleEx(carid, x, y, z, a, 15 /* Respawntime in seconds */ );
CreateVehicle(carid, x, y, z, a, 15 /* Respawntime in seconds aswell */ );
Use one of those, not sure if you can do it with the timer
Reply
#5

pawn Код:
if(newstate == PLAYER_STATE_DRIVER && oldstate == PLAYER_STATE_ONFOOT)
Should be:
pawn Код:
if(newstate == PLAYER_STATE_ONFOOT && oldstate == PLAYER_STATE_DRIVER)
Reply
#6

Ok, i go to try
Reply
#7

Now it is better but Timer not work :
Quote:

SetTimerEx("destroy", 15000, false, "d", vid);

Reply
#8

I think the "forward" should come before settimer.
Place it at the start of the script.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)