OnPlayerDeath
#1

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    if(PlayerUsingLoopingAnim[playerid])
    {
        PlayerUsingLoopingAnim[playerid] = 0;
    }
    PlayerInfo[playerid][pDeath] = 1;
    return 1;
}
pawn Код:
public OnPlayerSpawn(playerid)
{
    if(PlayerInfo[playerid][pDeath] == 1)
    {
        new time = (1 + random(4)), string[200];
        new nurse = random(sizeof(NurseNames));
        new bill = time*120;
        SetPlayerCameraPos(playerid, -2660.750244, 580.064697, 29.793859);
        SetPlayerCameraLookAt(playerid, -2660.882568, 584.698120, 27.919254);
        SetTimerEx("OnDeath", 60000, false, "d", playerid);
        SetVirtualWorld(playerid, 50000);
        SendClientMessage(playerid, -1, ""Pink"Hospital"White": San Fierro");
        format(string, sizeof(string), ""Pink"Nurse"White": %s", NurseNames[nurse]);
        SendClientMessage(playerid, -1, string);
        format(string, sizeof(string), ""Pink"Bill"White": $%d", bill);
        SendClientMessage(playerid, -1, string);
        format(string, sizeof(string), ""Pink"Time"White": %d minute(s)", time);
        SendClientMessage(playerid, -1, string);
        PlayerInfo[playerid][pDeath] = time;
        GiveCash(playerid, -bill);
        return 1;
    }
    return 1;
}
When I die, it freezes me and shows me the spawn button like OnPlayerRequestClass? How do I make it so when I finish the dying process it takes me straight to the camera view I have above? ^
Reply
#2

You can use SetSpawnInfo to force OnPlayerSPawn to be called instead of OnPlayerRequestClass.

It basically does what you want it to do.

Put that function under OnPlayerDeath and make sure to re-specify the positions and skin you want a player to have.
Reply
#3

Under OnPlayerDeath I put:

pawn Код:
SetSpawnInfo(playerid, 0, PlayerInfo[playerid][pSkin], -2656.6123, 635.8759, 14.4531, 182.7413, 0, 0, 0, 0, 0, 0);
But it is still showing me the spawn bar.
Reply
#4

That's weird. I've had that issue before though but I can't exactly recall what caused it at the moment.

Can you try putting your SetSpawnInfo under

pawn Код:
public OnPlayerRequestClass(playerid, classid)
Reply
#5

I put SetSpawnInfo and SpawnPlayer under OnPlayerRequestClass and it works now, thanks.

One more problem is that if I log out and back in, it sends me to the hospital and displays the message twice instead of once.
Reply
#6

That probably happens because you didn't reset your variable properly.
Reply
#7

Yeah I'll think of a fix for that one aha. +rep, cheers.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)