SA-MP Forums Archive
Preventing the auto-respawn after the player dies - 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: Preventing the auto-respawn after the player dies (/showthread.php?tid=392781)



Preventing the auto-respawn after the player dies - decondelite - 15.11.2012

Hello.

After a few attemps that ended up unsuccessful, I'm now requesting your help to know if you've got a solution for my issue. You know that, by default, if we don't do anything special, when a player dies he falls on the floor, the camera goes on above view mode and the player respawns after a few seconds. What I'd like, is the player NOT to respawn automatically, WITHOUT using the spectate mode. I know that I already did it a long time ago (unintentionally), but I don't remember in what circumstances it was happening. I even had the camera that kept going up in the sky forever.

Does someone know how to do? I'd really need to decide when the player should respawn once he dies to add a little feature that I'm coding for my server. And I repeat: spectating is not an option to consider.

just to let you know: I already tried "return 0;" in a few callbacks, without meeting any success.

Thanks to those who know how to do!


Re: Preventing the auto-respawn after the player dies - iggy1 - 15.11.2012

You could try setting the players camera and freezing them (not sure if this would work good). May i ask why spectating is not an option? Seems like the best option to me. Can't really think of anything else.


Re : Preventing the auto-respawn after the player dies - decondelite - 15.11.2012

I did have tried SetCameraBehindPlayer (even in a looped timer), I also tried freezing them in OnPlayerDeath: none worked. Spectating is not an option because I want the body of the player to remain on the ground, for many reasons.


Re: Preventing the auto-respawn after the player dies - Azazelo - 15.11.2012

--on playerupdate
on player helt < 0.99
play animation (player lay on ground)
Take camera away to another spot

If you want to not respawn and keep body you must have some healt on player.
And make it look like kiled.


Something like this ?


Re: Preventing the auto-respawn after the player dies - Face9000 - 15.11.2012

Quote:
Originally Posted by Azazelo
Посмотреть сообщение
--on playerupdate
on player helt < 0.99
play animation (player lay on ground)
Take camera away to another spot

If you want to not respawn and keep body you must have some healt on player.
And make it look like kiled.


Something like this ?
[ame]http://www.youtube.com/watch?v=umDr0mPuyQc[/ame]

Did you tried to put a timer inside OnPlayerDeath and recall what you are trying to do?


Re : Re: Preventing the auto-respawn after the player dies - decondelite - 16.11.2012

Quote:
Originally Posted by Azazelo
Посмотреть сообщение
--on playerupdate
on player helt < 0.99
play animation (player lay on ground)
Take camera away to another spot

If you want to not respawn and keep body you must have some healt on player.
And make it look like kiled.


Something like this ?
KThxbai...
Have I said anywhere that I'm running a RP server? Because actually I'm scripter of a DM server. This kind of things: no thanks. If on a RP server you kill each other with a Colt 45, here on my DM server you can be killed by spaz, M4, deagle, sniper, minigun, tank, hydra, hunter, missiles or even bigass napalms. D'you think that a 100HP healthbar is enough to bear a napalm in your face without being emptied straight away?

@Logitech:
Actually I don't want anything to happen while the body is laying. I want the player to respawn when I decide to respawn him. This is because of the "undead" bug and also because I want to give the opportunity to a medic to save the guy in extremis by applying the "medic anim".


Re: Preventing the auto-respawn after the player dies - Treyvan - 16.11.2012

If I misunderstood what your looking for please let me know, from the looks of it what you want is basically how deaths are scripted on my GM which is as follows:

1) Player gets shot/run over/falls to death whatever.
2) HP falls to 0, and the player is down for the count like you described in your first post.
3) Player respawns, but immediately on respawn the death system takes over, applies the appropriate animation and the player cant get up until the script says so.


If that's what your looking for then it's simple. FYI I have not tested this, my death system is a little more advanced as its tailored specifically for my script but this is the basic jist of how it works. You can't stop a player from respawning because as soon as OnPlayerDeath is triggered and completes, the player in question goes through the camera cinematic + animation and OnPlayerRequestClass immediately follows to set the player up for its eventual respawn yadda yadda.

But basically what the following does is flag the player telling the script "He's dead" so it knows what to do with the player when it hits OnPlayerRequestClass.

pawn Код:
new bool:IsDead[playerid];

public OnPlayerDeath(playerid)
{
    IsDead[playerid] = true;
    return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
    if(IsDead[playerid] == true)
    {
        //SetSpawnInfo (see wiki for details) would be useful here to setup the players appearance/weapons and what not. I use a function I wrote to reload the player details specific for my GM.
        SpawnPlayer(playerid);
    }
    return 1;
}
public OnPlayerSpawn(playerid)
{
    if(IsDead[playerid] == true)
    {
        IsDead[playerid] = false);
        TogglePlayerControllable(playerid, false);
        //SetPlayerCameraPos(playerid,0.0,0.0,1000.0);
        //SetPlayerCameraLookAt(playerid,0.0,0.0,1001.0); // This and the one above set the players camera so he can't see anything
        ApplyAnimation(playerid,"PED","KO_skid_back",4.1,0,1,1,1,1);
    }
    return 1;
}
To release from death just make a function that clears animations, unfreezes the player and resets the cameras and your done.


It's crude in its basic form, and I'm sure some people around here could make it all fancy and what not, but does allow alot of room to manuever to fit your needs but it also fits the 'flow' samp follows with it's native triggers. Just make sure that you always reset the death flag (IsDead[playerid]) to 0 when the player has not died or it'll cause problems when spawning in general.

Hope this helps you out.


Re : Preventing the auto-respawn after the player dies - decondelite - 16.11.2012

Thanks for the help everyone.

The "best" solution was the last one suggested. I do have tried to implement it, it gave some results, but unfortunately, this solution has too many issues (like abuses, bugs, difficulty to process) that I have to give up with it.

I needed to be able to do this mainly for a new feature I was working on (medic), but I guess I'll just do something else to still satisfy my players.