27.09.2012, 00:14
Is that possible not to die inside a vehicle after it explodes? I want to eject outside the vehicle before I die.
public OnGameModeInit() //Or OnFilterScriptInit()
{
SetTimer("CarTimer", 1000, true);
return 1;
}
forward CarTimer();
public CarTimer()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(IsPlayerInAnyVehicle(i))
{
new vehicleid = GetPlayerVehicleID(i);
new Float:health;
GetVehicleHealth(vehicleid, health);
if(health <= 250)
{
RemovePlayerFromVehicle(i);
}
}
}
}
return 1;
}
On a timer:
pawn Код:
|
new timer[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
timer[playerid] = SetTimerEx("vehicleup",1000,true,"i",playerid);
return 1;
}
public OnPlayerDisconnect(playerid)
{
KillTimer(timer[playerid]);
}
forward vehicleup(playerid);
public vehicleup(playerid)
{
if(!IsPlayerInAnyVehicle(playerid)) return false; // is not in vehicle.
static Float:health;
GetVehicleHealth(GetPlayerVehicleID(playerid), health); // get vehicle health.
if(health > 250) return false; // if it's bigger return 0.
RemovePlayerFromVehicle(playerid); // he's inside a vehicle.
return true;
}