SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 23/09/2019, 09:20 PM   #1
Dokins
Banned
 
Join Date: Jun 2010
Posts: 1,648
Reputation: 53
Default Issue with Player Death System.

Hello,

The issue I'm facing is that on occasion I am met with (SPAWN) brackets when spawning back from death, but not all of the time. A few times when people die they get the SPAWN button, but most of the time they don't about 8/9 out of 10 times it's no brackets.

Under OnPlayerDeath

pawn Code:
stock PlayerDeath(playerid)
{
    if(PlayerIsDead[playerid] == 0)
    {
        PlayerIsDead[playerid] = 1;
        KnockedOut[playerid] = 0;
        DeathInt[playerid] = GetPlayerInterior(playerid);
        DeathVW[playerid] = GetPlayerVirtualWorld(playerid);
        new currentskin = GetPlayerSkin(playerid);
        GetPlayerPos(playerid, DeathPosX[playerid], DeathPosY[playerid], DeathPosZ[playerid]);
        new Float: ang;
        GetPlayerFacingAngle(playerid, ang);
        new skin = GetPlayerSkinEx(playerid);
        if(currentskin != skin && currentskin > 0)
        {
            DeathSkin[playerid] = GetPlayerSkin(playerid);
        }
        else
        {
            DeathSkin[playerid] = skin;
        }
        SetSpawnInfo(playerid, 0, DeathSkin[playerid], DeathPosX[playerid], DeathPosY[playerid], DeathPosZ[playerid],ang, 0,0,0,0,0,0);
        SpawnPlayer(playerid);
       
        new model, GunAmmo, id, string[128];
        format(string, sizeof(string), "You have "COL_RED"died."COL_WHITE" Please assist players with the use of "COL_GREEN"'/do' "COL_WHITE"and do not "COL_RED"RK.");
        SendClientMessage(playerid, COLOUR_WHITE, string);
        SendClientMessage(playerid, COLOUR_GREY, "Depending on your cause of death, you may be revived. You must wait 3 minutes before you can '/accept death'.");
        SendClientMessage(playerid, COLOUR_GREY, "EMT's have 4 minutes to respond before you cannot be revived.");
        TextDrawShowForPlayer(playerid, DeadDraw[playerid]);
        /*new Float: area[5];
        area[0] = 0.1;
        area[1] = 0.2;
        area[2] = 0.3;
        area[3] = 0.4;
        area[4] = 0.5;
    */

        if(Faction[playerid] != 1 && CauseOfDeath[playerid] != WEAPON_COLLISION)
        {
            for(new w = 0; w < 13; w++)
            {
                if(PlayerWeapons[playerid][w] > 0)
                {
                    id = PlayerWeapons[playerid][w];
                    model = WepModel[id];
                    GunAmmo = WepAmmo[id];

                    DropGun(playerid, id, model,GunAmmo,DeathPosX[playerid], DeathPosY[playerid], DeathPosZ[playerid] ,DeathVW[playerid],DeathInt[playerid]);
                }
            }
        }
    }
    return 1;
}

Under OnPlayerSpawn
pawn Code:
SetTimerEx("DeathCheck", 500,false,"i",playerid);

forward DeathCheck(playerid);
public DeathCheck(playerid)
{
    if(PlayerIsDead[playerid] == 1)
    {
        SetPlayerVirtualWorld(playerid, DeathVW[playerid]);
        SetPlayerInterior(playerid, DeathInt[playerid]);
        SetPlayerPos(playerid, DeathPosX[playerid], DeathPosY[playerid], DeathPosZ[playerid]);
        SetPlayerHealth(playerid, 99999);
        TogglePlayerControllable(playerid, 0);
        SetTimerEx("DeathAnim", 500,false,"i",playerid);
        SetPlayerSkin(playerid, DeathSkin[playerid]);
        DeathTimer[playerid] = 3;
        TextDrawHideForPlayer(playerid,BFText);
        KillTimer(BleedingTime[playerid]);
    }
    return 1;
}
forward DeathAnim(playerid);
public DeathAnim(playerid)
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        ApplyAnimation(playerid,"ped", "CAR_dead_LHS", 4.0, 0, 0, 0, 1, 0);
    }
    else
    {
        //ApplyAnimation(playerid, , 4.0, 0, 0, 0, 0, 0, 1);
        ApplyAnimation(playerid, "CRACK", "CRCKIDLE2", 4.0, 1, 0, 0, 0, 0, 1);
    }
    new string[128];
    format(string, sizeof(string), "D E A D\nB O D Y");
    UpdateDynamic3DTextLabelText(DeathLabel[playerid], COLOUR_RED, string);
    DeathTimer[playerid] = 3;
    TextDrawHideForPlayer(playerid,BFText);
    KillTimer(BleedingTime[playerid]);
    return 1;
}


I don't use the Death System anywhere else.

The goal is to get players to spawn immediately after they die in the spot where they died with no spawn selection.

Any help would be appreciated.
Dokins is offline   Reply With Quote
Old 23/09/2019, 09:35 PM   #2
Private200
High-roller
 
Private200's Avatar
 
Join Date: May 2012
Posts: 1,177
Reputation: 211
Default Re: Issue with Player Death System.

Are you trying not to or to get the brackets? Could not understand that part.
__________________
Private200 is offline   Reply With Quote
Old 23/09/2019, 09:37 PM   #3
Dokins
Banned
 
Join Date: Jun 2010
Posts: 1,648
Reputation: 53
Default Re: Issue with Player Death System.

Trying not to as in I want it to instantly spawn without the SPAWN button and Arrows.
Dokins is offline   Reply With Quote
Old 24/09/2019, 07:57 PM   #4
Markski
Big Clucker
 
Markski's Avatar
 
Join Date: Apr 2015
Location: La Plata, Argentina
Posts: 118
Reputation: 41
Default Re: Issue with Player Death System.

It could be happening because they're pressing F4 and that tells the server the player is requesting a class change after death. Test doing that and see if that causes it.

https://wiki.sa-mp.com/wiki/OnPlayerRequestClass
Markski is offline   Reply With Quote
Old 24/09/2019, 08:10 PM   #5
Dokins
Banned
 
Join Date: Jun 2010
Posts: 1,648
Reputation: 53
Default Re: Issue with Player Death System.

It's nothing to do with that. Testing it myself. It sort of displays sometimes and others it does not.
Dokins is offline   Reply With Quote
Old 28/09/2019, 06:37 AM   #6
MP2
Godfather
 
MP2's Avatar
 
Join Date: Jan 2011
Location: England
Posts: 6,234
Reputation: 1001
Default Re: Issue with Player Death System.

Are you forcibly spawning the player when they login or something, instead of relying on them pressing ‘SPAWN’? I have found that if you do so you the server thinks they haven’t selected a class and sends them back to class selection after death just like if they had pressed F4. You can then spawn them again with SpawnPlayer or TogglePlayerSpectating false.
__________________
Owner and developer of Mike's Cops and Robbers.

Click here to visit our site and find out more. Click here to view trailers.
Enter referral code SAMPFORUM after registering for a $5000 starting bonus!
MP2 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
on player death - cant spawn after death Oshery Scripting Help 20 29/12/2017 09:43 PM
Death window resolution issue. Lordzy Scripting Help 4 25/01/2015 10:15 PM
Issue with Death System (Very odd.) Dokins Scripting Help 4 11/04/2014 02:58 PM
Vehicle death issue MP2 Scripting Help 20 05/02/2014 09:49 PM
Weapon Drop on Death issue BlackWolf120 Help Archive 3 18/04/2011 02:37 PM


All times are GMT. The time now is 12:08 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.