DestroyVeh after an amount of time after the vehicle has been spawned
#1

Ok, so I have this :

- ok, so this is when the player will request 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);
					delay(playerid, vehicleid);
					return 1;
				}
- these are the fuctions for destroying the vehicle after 5 seconds if the player is not inside

Код:
public delay(playerid, vehicleid)
{
    SetTimerEx("destroy_veh", 5000, 1, "d");
}

public destroy_veh(playerid, vehicleid)
{
    if(IsPlayerInVehicle(playerid, vehicleid)==1)
    {
		delay(playerid, vehicleid);
    }
    else
    {
        DestroyVehicle(vehicleid);
    }
}
But it's not working. What did I do wrong ?
Reply
#2

You aren't specifying the playerid or vehicleid in SetTimerEx.

PHP код:
SetTimerEx("destroy_veh"50001"dd"playeridvehicleid); 
Also you should remove the delay() inside destroy_veh because a new timer will check it.
Reply
#3

Why not just set the respawn time in CreateVehicle and not worry about any extra code?
Reply
#4

^ because that's respawn time not destroy time.

Note: your timers auto reset / repeat value set to true but you never kill them, either disable the repeat or store their Id and kill them when finished.
Reply
#5

Thanks, it's working !
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)