OnPlayerDeath
#1

Is there a way to disable that the player will respawn after he dies? I'm trying to set his position to where he died and apply an animation but the player respawns shortly after. I'm pretty sure i've seen it on a few RP servers before.
Reply
#2

pawn Код:
new Died[MAX_PLAYERS];

enum pInfo
{
    Float:pX,
    Float:pY,
    Float:pZ
}
new DeathPosition[MAX_PLAYERS][pInfo];

public OnPlayerDeath(playerid, killerid, reason)
{
    new Float:X, Float:Y, Float:Z;
    GetPlayerPos(playerid, X, Y, Z);
    DeathPosition[playerid][pX] = X;
    DeathPosition[playerid][pY] = Y;
    DeathPosition[playerid][pZ] = Z;
    Died[playerid] = 1;
    return 1;
}

public OnPlayerSpawn(playerid)
{
    if(Died[playerid] == 1)
    {
        SetPlayerPos(playerid, DeathPosition[playerid][pX], DeathPosition[playerid][pY], DeathPosition[playerid][pZ]);
    }
    return 1;
}
Reply
#3

pawn Код:
new Float:PosX[MAX_PLAYERS], Float:PosY[MAX_PLAYERS], PosZ[MAX_PLAYERS]; //to save players location
new died[MAX_PLAYERS]; //confirming he's dead
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    died[playerid] = 1; //he's dead
    GetPlayerPos(playerid, PosX[playerid], PosY[playerid], PosZ[playerid]); //get his position now
        return 1;
    }
pawn Код:
if(died[playerid] == 1) //if he's dead
        {
            died[playerid] = 0; //dead reset
            SetPlayerPos(playerid, PosX[playerid], PosY[playerid], PosZ[playerid]); //set his position back to where he was on respawn
            // Apply your animation here and more codes
        }
        return 1;
        }
Reply
#4

Nah, your code only makes him spawn on his previous position after he dies and respawns.
Reply
#5

Quote:
Originally Posted by PaulDinam
Посмотреть сообщение
Nah, your code only makes him spawn on his previous position after he dies and respawns.
If your intention is to avoid dying screen and being teleported to somewhere else, That's impossible, The least you can do is respawn him to where he died, Freeze him, Apply character animation where he's lying, And carry on the roleplay.
Reply
#6

There's nothing wrong with code.
Your code from OnPlayerSpawn() it's problem.
If it's teleporting them to position after dies, then it's ok, you asked for this. But if he got respawned after this it's from your codes.
So, check your OnPlayerSpawn() codes and try to solve problem.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)