SA-MP Forums Archive
OnPlayerDeath - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: OnPlayerDeath (/showthread.php?tid=510911)



OnPlayerDeath - AphexCCFC - 03.05.2014

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? ^


Re: OnPlayerDeath - Dignity - 03.05.2014

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.


Re: OnPlayerDeath - AphexCCFC - 03.05.2014

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.


Re: OnPlayerDeath - Dignity - 03.05.2014

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)



Re: OnPlayerDeath - AphexCCFC - 03.05.2014

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.


Re: OnPlayerDeath - Dignity - 03.05.2014

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


Re: OnPlayerDeath - AphexCCFC - 03.05.2014

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