06.05.2018, 00:24
Hello!
IsPlayerInAnyVehicle(playerid) is not working in OnPlayerDeath?
0.3-DL
IsPlayerInAnyVehicle(playerid) is not working in OnPlayerDeath?
0.3-DL
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(..); |
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. |
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. |
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. |
new DiedInVeh[MAX_PLAYERS];
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER) SetPVarInt(playerid,#CurrentVeh,GetPlayerVehicleID(playerid));
else if(oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER) SetPVarInt(playerid,#LastVeh,GetPVarInt(playerid,#CurrentVeh));
if((oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER) &&
newstate == PLAYER_STATE_WASTED) DiedInVeh[playerid] = GetPVarInt(playerid,#LastVeh);
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
if(DiedInVeh[playerid] != INVALID_VEHICLE_ID) GameTextForPlayer(playerid, "~r~died in vehicle", 5000, 3);
return 1;
}