Detecting if a player died...
#1

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!
Reply
#2

Use GetPlayerState in OnPlayerDeath
Reply
#3

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?
Reply
#4

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;
}
Reply
#5

I had the same idea. But I'm using
pawn Code:
OnPlayerSpawn
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);
                    }
                }
Reply
#6

You want to send the player to the hospital, but no the car, no?
Sorry for my bad english...
Reply
#7

Quote:
Originally Posted by FullCircle
View Post
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.
Reply
#8

Quote:
Originally Posted by Eyce
View Post
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?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)