Detecting if a player died... -
Eyce - 13.12.2014
Hey everyone,
I'm doing a role-play game mode and I currently have a death and hospital system. If the player dies (the first time), they spawn right where they died without being able to move. If the player gets killed again, they are sent to the hospital. What's weird about this, is; if the player gets killed while being inside a vehicle, they go straight to the hospital. Is there a way to detect if a player dies while being inside a vehicle?
Thanks!
Re: Detecting if a player died... -
FullCircle - 13.12.2014
Use
GetPlayerState in OnPlayerDeath
Re: Detecting if a player died... -
Eyce - 13.12.2014
Thanks for the tip. Though it still remains the same, the player goes straight to the hospital. I noticed that this only happens if the player is the driver of the vehicle. It works fine for passengers. Anymore thoughts?
Re: Detecting if a player died... -
Abagail - 13.12.2014
pawn Code:
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
new vehicleid = GetPlayerVehicleID(playerid);
new Float: pos[3];
GetVehiclePos(vehicleid, pos[0], pos[1], pos[2]);
SetPlayerPos(playerid, pos[0], pos[1]+1.75, pos[2]);
RemovePlayerFromVehicle(playerid);
return 1;
}
Re: Detecting if a player died... -
Eyce - 13.12.2014
I had the same idea. But I'm using
This is what I actually have under OnPlayerDeath:
pawn Code:
if(IsPlayerInAnyVehicle(playerid))
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
new veh = GetPlayerVehicleID(playerid);
new Float:vdPos[4];
GetVehiclePos(veh, vdPos[0], vdPos[1], vdPos[2]);
GetVehicleZAngle(veh, vdPos[3]);
RemovePlayerFromVehicle(playerid);
SetSpawnInfo(playerid, 0, PlayerInfo[playerid][pSkin], vdPos[0], vdPos[1], vdPos[2], vdPos[3], 0, 0, 0, 0, 0, 0);
}
}
Re: Detecting if a player died... -
FullCircle - 13.12.2014
You want to send the player to the hospital, but no the car, no?
Sorry for my bad english...
Re: Detecting if a player died... -
Eyce - 13.12.2014
Quote:
Originally Posted by FullCircle
You want to send the player to the hospital, but no the car, no?
Sorry for my bad english...
|
It's okay. Here's what I mean, if the player dies while being the driver of the vehicle - he stays in his position but not sent to the hospital.
Re: Detecting if a player died... -
FullCircle - 13.12.2014
Quote:
Originally Posted by Eyce
It's okay. Here's what I mean, if the player dies while being the driver of the vehicle - he stays in his position but not sent to the hospital.
|
You tried to remove player from the vehicle before teleport?
You freeze the player when the player is teleported?