Die outside the vehicle
#1

Is that possible not to die inside a vehicle after it explodes? I want to eject outside the vehicle before I die.
Reply
#2

Probably, but not well. Time between vehicle starting to burn, and explosion should be fix for all vehicles afaik (except its exploding instantly because of certain other explosions). You could check the vehicle health for dropping below 250 in OnPlayerUpdate, and then start a timer that ejects the player some 100ms before the vehicle explodes. But you would also need to teleport him away a bit, as he will still die standing next to the explosion.
Reply
#3

On a timer:
pawn Код:
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;
}
Reply
#4

Quote:
Originally Posted by clarencecuzz
Посмотреть сообщение
On a timer:
pawn Код:
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;
}
I think it works but in a different thing. What I mean is everytime time i'm in another world like VirtualWorld 1 and so on EXCEPT VirtualWorld 0. Everytime I died inside a vehicle it teleports me randomly sometimes in CJ near the house. Sometimes in ocean. Sometimes I fall from nowhere XD but when i'm onfoot I spawn in a place where I set the spawn point.

And the weird thing is that when i'm using the Lan server the problem is now gone after I died in vehicle it spawn me in the right place where I actually want to spawn.
Reply
#5

i don't really recommend using a loop. this is the best way to do it.

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;
}
By the way, i recommend you stop using/making useless variables.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)