Death script problem.
#1

Hello, i am trying to make a death script here that when the player dies, he gets teleported back to the same position but frozen and with an animation and gets a timer that would teleport him to the hospital after that.

But there's a slight problem, when the player teleports back to his position, he doesn't get frozen nor an animation gets set, Here's my script:

pawn Код:
Under OnPlayerDeath there is this: Dead[playerid] = 1;
public SetPlayerSpawn(playerid)
{
    new string[128], rand;
    if(IsPlayerConnected(playerid))
    {
        if(!IsPlayerNPC(playerid))
        {
                if(Dead[playerid] == 1 && PlayerInfo[playerid][pJailed] == 0)
                {
                    new Float:pX, Float:pY, Float:pZ;
                    GetPlayerPos(playerid, pX, pY, pZ);
                    DeathPosX[playerid] = pX;
                    DeathPosY[playerid] = pY;
                    DeathPosZ[playerid] = pZ;
                    SetCameraBehindPlayer(playerid);
                    LoopingAnim(playerid,"PED","KO_skid_front",4.1,0,1,1,1,0);
                    SetPlayerHealth(playerid, 25.00);
                    SendClientMessage(playerid, COLOR_RED, "You are dying, Type /acceptdeath or wait for a medic.");
                    IsDead[playerid] = 1;
                return 1;

    if (strcmp(cmd, "/acceptdeath", true) == 0)
    {
     if (IsDead[playerid] == 0) { return 0; }
        else
        {
            IsDead[playerid] = 0;
            SendClientMessage(playerid,COLOR_RED,"------------------ Respawning -----------------");
            SendClientMessage(playerid,COLOR_WHITE,"You are respawning back to your spawn location in minutes.");
            SendClientMessage(playerid,COLOR_WHITE,"You have just forgot the past 30 minutes of your roleplay.");
            SendClientMessage(playerid,COLOR_WHITE,"If you died in a non-rp way, please /report to the admins.");
            SendClientMessage(playerid,COLOR_RED,"--------------------------------------------------------");
            SetPlayerPos(playerid,0, 0, 0);
            SetPlayerCameraPos(playerid,DeathPosX[playerid],DeathPosY[playerid],DeathPosZ[playerid]);
            SetPlayerCameraLookAt(playerid,DeathPosX[playerid],DeathPosY[playerid],DeathPosZ[playerid]+100);
            TogglePlayerControllable(playerid, 0);
            SetTimerEx("RespawnFromDeath",30000,true,"i",playerid);
            return 1;
         }
                }
Reply
#2

TogglePlayerControllable?
Reply
#3

Also maybe try these to stop any animations that are playing:

SetPlayerSpecialAction(playerid, SPECIAL_ACTION_NONE);
ClearAnimations(playerid);
Reply
#4

Ok i added this and the player still gets teleported back to the place without an animation nor getting frozen.

pawn Код:
if(Dead[playerid] == 1 && PlayerInfo[playerid][pJailed] == 0)
                {
                    new Float:pX, Float:pY, Float:pZ;
                    GetPlayerPos(playerid, pX, pY, pZ);
                    DeathPosX[playerid] = pX;
                    DeathPosY[playerid] = pY;
                    DeathPosZ[playerid] = pZ;
                    SetCameraBehindPlayer(playerid);
                    SetPlayerSpecialAction(playerid, SPECIAL_ACTION_NONE);
                    ClearAnimations(playerid);
                    LoopingAnim(playerid,"PED","KO_skid_front",4.1,0,1,1,1,0);
                    TogglePlayerControllable(playerid, 0);
                    SetPlayerHealth(playerid, 25.00);
                    SendClientMessage(playerid, COLOR_RED, "You are dying, Type /acceptdeath or wait for a medic.");
                    IsDead[playerid] = 1;
                return 1;
                }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)