Destroy vehicle - 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: Destroy vehicle (
/showthread.php?tid=403126)
Destroy vehicle -
Virus. - 29.12.2012
Код:
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.
Re: Destroy vehicle -
[HiC]TheKiller - 29.12.2012
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;
}
}
}
}
Re: Destroy vehicle -
Virus. - 29.12.2012
and what about if a player exits and enter again