Notice: Undefined index: HTTP_ACCEPT_LANGUAGE in /var/www/sa-mp.com/forum/showthread.php on line 25
IsPlayerInAnyVehicle(playerid) in OnPlayerDeath - 0.3-DL - SA-MP Forums
SA-MP Forums

Go Back   SA-MP Forums > SA-MP > Bug Reports

Reply
 
Thread Tools Display Modes
Old 06/05/2018, 12:24 AM   #1
JR_Junior
Huge Clucker
 
Join Date: Nov 2011
Location: Brazil
Posts: 228
Reputation: 54
Default IsPlayerInAnyVehicle(playerid) in OnPlayerDeath - 0.3-DL

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

0.3-DL
JR_Junior is offline   Reply With Quote
Old 06/05/2018, 03:18 PM   #2
JR_Junior
Huge Clucker
 
Join Date: Nov 2011
Location: Brazil
Posts: 228
Reputation: 54
Default Re: IsPlayerInAnyVehicle(playerid) in OnPlayerDeath - 0.3-DL

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?
JR_Junior is offline   Reply With Quote
Old 08/05/2018, 12:16 AM   #3
Pottus
Godfather
 
Pottus's Avatar
 
Join Date: Jun 2012
Posts: 5,412
Reputation: 1240
Default Re: IsPlayerInAnyVehicle(playerid) in OnPlayerDeath - 0.3-DL

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.
Pottus is offline   Reply With Quote
Old 08/05/2018, 01:10 AM   #4
RogueDrifter
High-roller
 
RogueDrifter's Avatar
 
Join Date: Dec 2017
Location: SA-MP Drifting world.
Posts: 1,143
Reputation: 344
Default Re: IsPlayerInAnyVehicle(playerid) in OnPlayerDeath - 0.3-DL

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.
__________________
Quote:
I'm not using the forum to release stuff anymore, if you want updates for my releases or to check my new releases check the links below >
Quote:
Originally Posted by Escobar ⚠
Life sucked me in and shat me on the cruel world.

[Github]:Link [Gists]:Link [Forum]:Link [Server]:Link [Discord]:Link


RogueDrifter is offline   Reply With Quote
Old 08/05/2018, 05:08 AM   #5
Pottus
Godfather
 
Pottus's Avatar
 
Join Date: Jun 2012
Posts: 5,412
Reputation: 1240
Default Re: IsPlayerInAnyVehicle(playerid) in OnPlayerDeath - 0.3-DL

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.
Pottus is offline   Reply With Quote
Old 08/05/2018, 10:08 PM   #6
JR_Junior
Huge Clucker
 
Join Date: Nov 2011
Location: Brazil
Posts: 228
Reputation: 54
Default Re: IsPlayerInAnyVehicle(playerid) in OnPlayerDeath - 0.3-DL

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;

JR_Junior is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
IsPlayerInAnyVehicle(playerid) caoraivoso3 Portuguкs/Portuguese 2 13/09/2013 06:54 PM
IsPlayerInAnyVehicle jackci Scripting Help 3 27/05/2013 06:58 AM
вопрос по OnPlayerDeath(playerid,reason) safari Русский/Russian 9 06/03/2012 10:07 AM
[AJUDA] OnPlayerDeath(playerid, killerid, reason) lucas_mdr1235 Portuguкs/Portuguese 10 03/05/2011 08:53 PM
[HELP] OnPlayerDeath - PlayerName|PlayerID|KilledBy? Larsey123IsMe Help Archive 29 25/12/2010 09:34 AM


All times are GMT. The time now is 03:11 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.