Player death help
#1

Hello!

I'm making a RP server and I'm making the death system. At these point I have done a system that works something like this:

1. Death - > OnPlayerDeath sets variable Death[playerid] to 1.
2. OnPlayerSpawn -> if(Death[playerid]) -> Apply animation etc.

What I want to do is not respawn the player if he deaths. I need to avoid the default death system of SAMP so, when player life arrives 0 or minus (I suppose if I have 6hp and someone shots me, my life will not 0, will be -10 or something like this) automatically the player enters on the death mode, without respawn and with full life.

If someone can give me an example it will be apreciated. Thanks!
Reply
#2

i have a similar question about a system, can someone answer pls
Reply
#3

You must create a server-sided damage system.
Here's a tutorial: https://sampforum.blast.hk/showthread.php?tid=558839
Reply
#4

Or maybe consider 1-2 HP as player is dead... Apply anim & kill him.
Reply
#5

Quote:
Originally Posted by iLearner
Посмотреть сообщение
Or maybe consider 1-2 HP as player is dead... Apply anim & kill him.
What I need is to avoid the OnPlayerDeath to avoid a Respawn player.
Reply
#6

Quote:
Originally Posted by HidroDF
Посмотреть сообщение
What I need is to avoid the OnPlayerDeath to avoid a Respawn player.
Read my post above.
Reply
#7

Quote:
Originally Posted by GoldenLion
Посмотреть сообщение
Read my post above.
Yes but this is a damage system. What I need is to avoid the vertical camera when player death and spawn him inmediately.
Reply
#8

You can save the player pos and after he dies TP him back and set him in an anim, toggle controllable
Reply
#9

At these time I set up this:

Код:
public OnPlayerDeath(playerid, killerid, reason)
{
	if(PlayerInfo[playerid][pDeath] == 0)
	{
		PlayerInfo[playerid][pDeath] = 1;
		Update(playerid, pDeathu);
	}
	else if(PlayerInfo[playerid][pDeath] == 1)
	{
	    PlayerInfo[playerid][pDeath] = 2;
		Update(playerid, pDeathu);
	}
        SaveCoords(playerid);

public OnPlayerSpawn(playerid)
{
	if (!IsPlayerNPC(playerid))
	{
	    if(IsPlayerConnected(playerid))
		{
if(PlayerInfo[playerid][pDeath] == 1)
			{
				SetPlayerPos(playerid, PlayerInfo[playerid][pX], PlayerInfo[playerid][pY], PlayerInfo[playerid][pZ]);
				SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
                SetPlayerVirtualWorld(playerid, PlayerInfo[playerid][pVW]);
                SetPlayerInterior(playerid, PlayerInfo[playerid][pInterior]);
    			DeathLabel[playerid] = CreateDynamic3DTextLabel("{8A0808}This person is injured", 0xFFFFFFFF, 10.0, -0.45, -0.5, 15, playerid, INVALID_VEHICLE_ID, 0, -1, -1);
				SendClientMessage(playerid, -1, "If you don't get healed in 8 minutes you will be respawned at hospital.");
                SendToHospital[playerid] = SetTimerEx("Hospital", 60000*8, false, "i", playerid);
                TogglePlayerControllable(playerid, 1);
				AnimDeath[playerid] = SetTimerEx("DeathAnimation", 2500, false, "i", playerid);
			}
			else if(PlayerInfo[playerid][pDeath] == 2)
			{
			    DeathLabel[playerid] = CreateDynamic3DTextLabel("{8A0808}This person is death", 0xFFFFFFFF, 10.0, -0.45, -0.5, 15, playerid, INVALID_VEHICLE_ID, 0, -1, -1);
			    Hospital(playerid);
			}
			else
			{
			    TogglePlayerControllable(playerid, 1);
			    ClearAnimations(playerid);
			}
What I need is to remove the camera going up and execute the OnPlayerSpawn code in OnPlayerDeath inmediately he deaths.

Tried OnPlayerDeath return 0, TogglePlayerControlable, Give Health and nothing.
Reply
#10

Oh, I see what you want now. What you need to do is spawn the player and set the player's health above 0.
Like this:
Код:
SpawnPlayer(playerid);
SetPlayerHealth(playerid, 100.0);
Setting the health is important, otherwise it will start doing some strange stuff.
Like this:
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
	if (PlayerInfo[playerid][pDeath] == 0)
	{
		PlayerInfo[playerid][pDeath] = 1;
		Update(playerid, pDeathu);
	}
	else if (PlayerInfo[playerid][pDeath] == 1)
	{
	        PlayerInfo[playerid][pDeath] = 2;
		Update(playerid, pDeathu);
	}
        SaveCoords(playerid);
        
        SpawnPlayer(playerid);
        SetPlayerHealth(playerid, 100.0);
        
        return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)