Destroy vehicle
#1

Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
	if(vehicleid==CEM[playerid][createdv])
	{
	    CEM[playerid][vexited]=1;
		SendClientMessage(playerid,0xFF0000AA,"Please get in this vehicle else it will be destroyed after 15 seconds.");
 		CEM[playerid][timer]=SetTimerEx("destroycreatedv",15000,false,"i",vehicleid);
 	}
	return 1;
}
public OnPlayerEnterVehicle(playerid, vehicleid)
{
	if((vehicleid==CEM[playerid][createdv])&&(CEM[playerid][vexited]=1))
 	{
 	    SendClientMessage(playerid,0x33AA33AA,"This vehicle will not be destroyed now");
 	    CEM[playerid][vexited]=0;
 		KillTimer(CEM[playerid][timer]);
	}
	return 1;
}
Actually the is meant to do this : A players gets tp-ed with a vehicle. That vehicle ID is stored in CEM[playerid][createdv]. When a player exits a vehicle, a timer starts to destroy the vehicle. If a player enters the vehicle again the timer gets killed. But if an another player enters that vehicle, the vehicle is still destroyed and I dont want that.
Reply
#2

You could do a loop to see if the car is occupied like this function when the timer is called:
pawn Код:
stock IsVehicleOccupied(vehicleid) // Returns 1 if there is anyone in the vehicle
{
    foreach(Player,i)
    {
        if(IsPlayerInAnyVehicle(i))
        {
            if(GetPlayerVehicleID(i)==vehicleid)
            {
                return 1;
            }
            else
            {
                return 0;
            }
        }
    }
}
Reply
#3

and what about if a player exits and enter again
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)