IsPlayerInAnyVehicle(playerid) in OnPlayerDeath - 0.3-DL
#1

Hello!
IsPlayerInAnyVehicle(playerid) is not working in OnPlayerDeath?

0.3-DL
Reply
#2

Quote:
Originally Posted by DBZdabIt3Bro7
View Post
OnPlayerDeath > Called when a player dies.
Player's HP goes below 0 > He dies > OnPlayerDeath

Player dies > Respawns > Usually teleported back to a position by script > Never put back inside of the vehicle



In conclusion, it is working, but unlike in GTA SA SP mode, dead players gets usually teleported to a coordinate. Fix this by using PutPlayerInVehicle(..);
WTF?
Reply
#3

I know right that is retarded? If you KNEW the vehicle id the player was in then you KNOW they are in a vehicle. If you slap a player in a vehicle in OnPlayerDeath() then DUH!!!! They're in a vehicle at that point what is the use of calling IsPlayerInAnyVehicle(playerid) because again you KNOW they are in a vehicle.

Try checking this ----> Look in OnPlayerWeaponShot() and when you have a kill shot see if IsPlayerInAnyVehicle(playerid) works then.
Reply
#4

Its not a bug, i mean, when they die they simple get ejected out, OnPlayerDeath is called the moment they die (once they exit the vehicle).

Although, OnPlayerStateChange can be very helpful, set a timer of 1500MS to see when a player has just gotten out of a vehicle if (newstate == 1 && (oldstate == 3 || oldstate == 2) ) to set a variable true and set it false after 1500MS to see when the player has just gotten out, then check for that variable's value at OnPlayerDeath.
Reply
#5

Quote:
Originally Posted by RogueDrifter
View Post
Its not a bug, i mean, when they die they simple get ejected out, OnPlayerDeath is called the moment they die (once they exit the vehicle).

Although, OnPlayerStateChange can be very helpful, set a timer of 1500MS to see when a player has just gotten out of a vehicle if (newstate == 1 && (oldstate == 3 || oldstate == 2) ) to set a variable true and set it false after 1500MS to see when the player has just gotten out, then check for that variable's value at OnPlayerDeath.
It's best to try non-time checking methods first.
Reply
#6

Quote:
Originally Posted by Pottus
View Post
I know right that is retarded? If you KNEW the vehicle id the player was in then you KNOW they are in a vehicle. If you slap a player in a vehicle in OnPlayerDeath() then DUH!!!! They're in a vehicle at that point what is the use of calling IsPlayerInAnyVehicle(playerid) because again you KNOW they are in a vehicle.

Try checking this ----> Look in OnPlayerWeaponShot() and when you have a kill shot see if IsPlayerInAnyVehicle(playerid) works then.
A very good alternative idea.

Quote:
Originally Posted by RogueDrifter
View Post
Its not a bug, i mean, when they die they simple get ejected out, OnPlayerDeath is called the moment they die (once they exit the vehicle).

Although, OnPlayerStateChange can be very helpful, set a timer of 1500MS to see when a player has just gotten out of a vehicle if (newstate == 1 && (oldstate == 3 || oldstate == 2) ) to set a variable true and set it false after 1500MS to see when the player has just gotten out, then check for that variable's value at OnPlayerDeath.
Your idea is the best.

Quote:
Originally Posted by Pottus
View Post
It's best to try non-time checking methods first.
Absolutely.

I thank you all for the help!
Below is the method I used and worked perfectly:
PHP Code:
new DiedInVeh[MAX_PLAYERS];
public 
OnPlayerStateChange(playeridnewstateoldstate)
{
    if(
newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGERSetPVarInt(playerid,#CurrentVeh,GetPlayerVehicleID(playerid));
    
else if(oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGERSetPVarInt(playerid,#LastVeh,GetPVarInt(playerid,#CurrentVeh));
    
if((oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER) &&
    
newstate == PLAYER_STATE_WASTEDDiedInVeh[playerid] = GetPVarInt(playerid,#LastVeh);
    
return 1;
}
public 
OnPlayerDeath(playeridkilleridreason)
{
    if(
DiedInVeh[playerid] != INVALID_VEHICLE_IDGameTextForPlayer(playerid"~r~died in vehicle"50003);
    return 
1;

Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)