Death system.
#1

I made a basic death system, however, it seems to set you to when you logged in. I've also preloaded the anim library and it doesn't seem to put you in the Crack anim, no matter how many times you set it in the OPD callback.

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    TogglePlayerSpectating(playerid, true);
    new Float:X, Float:Y, Float:Z;
    GetPlayerPos(playerid, X, Y, Z);
    SetPlayerPos(playerid, X, Y, Z);
    SetPlayerHealth(playerid, 30);
    TogglePlayerSpectating(playerid, false);
    ApplyAnimation(playerid,"CRACK","crckdeth2",4.1,1,1,1,1,1);
    TogglePlayerControllable(playerid, false);
    SendClientMessage(playerid, COLOR_RED, "You've been killed.");
    return true;
}
Reply
#2

You should call a separate function on a timer after the death, this will allow a time gap in-between to pass the default death screen by SAMP and allow you to enable an anim after.
Reply
#3

Quote:
Originally Posted by Firewire
Посмотреть сообщение
You should call a separate function on a timer after the death, this will allow a time gap in-between to pass the default death screen by SAMP and allow you to enable an anim after.
I've done that, however still sets me in the samp position as I did when I logged in and doesn't set you in the animation.
Reply
#4

pawn Код:
TogglePlayerSpectating(playerid, false);
This calls OnPlayerSpawn, so you're instantly going to have issues with that.
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    SetPlayerHealth(playerid, 30); //Dunno why, but okay..
    ApplyAnimation(playerid, "CRACK", "crckdeth2", 4.1, 1, 1, 1, 1, 1);
    TogglePlayerControllable(playerid, false);
    SendClientMessage(playerid, COLOR_RED, "You've been killed.");
    return true;
}
If that doesn't work, then I dunno. I haven't really done animations in OnPlayerDeath.
Reply
#5

I tried doing it a different way, but it still sets them to their spawn position, and animations aren't loading, even after preloading them.
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    SavePlayerPosition(playerid);
    TogglePlayerSpectating(playerid, true);
    return true;
}

forward CheckPlayerDeath(playerid);
public CheckPlayerDeath(playerid)
{
    ApplyAnimation(playerid,"CRACK","crckdeth2",4.1,1,1,1,1,1);
    SetPlayerPos(playerid, PlayerInfo[playerid][pPosX], PlayerInfo[playerid][pPosY], PlayerInfo[playerid][pPosZ]);
    return true;
}

stock SavePlayerPosition(playerid)
{
    new Float:X, Float:Y, Float:Z;
    GetPlayerPos(playerid, X, Y, Z);
    PlayerInfo[playerid][pPosX] = X;
    PlayerInfo[playerid][pPosY] = Y;
    PlayerInfo[playerid][pPosZ] = Z;
   
    SpawnPlayer(playerid);
    TogglePlayerControllable(playerid, false);
    SendClientMessage(playerid, COLOR_RED, "You've been killed.");
    return 1;
}
//

public OnPlayerSpawn(playerid)
{
    TogglePlayerSpectating(playerid, false);
    SetTimerEx("CheckPlayerDeath", 500, false, "i", playerid);
    return 1;
}
Reply
#6

Because you're setting the player's position after playing the animation... I'm not sure why would would want to spawn the player to play an animation on death.

And remove this for god sakes!:
pawn Код:
TogglePlayerSpectating(playerid, false);
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)