View Single Post
Natsheh
Veteran Member
Join Date: Sep 2012
Old 10-19-2021 , 05:48   Re: Give the same functionality for the alive players to the dead players
Reply With Quote #5

I found a solution i need to be able to hook PlayerDeathThink and block it for that specified player.

PHP Code:
void CBasePlayer::PlayerDeathThink(void)
{
    
float flForward;

    if (
FBitSet(pev->flagsFL_ONGROUND))
    {
        
flForward pev->velocity.Length() - 20;
        if (
flForward <= 0)
            
pev->velocity g_vecZero;
        else    
            
pev->velocity flForward pev->velocity.Normalize();
    }

    if ( 
HasWeapons() )
    {
        
// we drop the guns here because weapons that have an area effect and can kill their user
        // will sometimes crash coming back from CBasePlayer::Killed() if they kill their owner because the
        // player class sometimes is freed. It's safer to manipulate the weapons once we know
        // we aren't calling into any of their code anymore through the player pointer.
        
PackDeadPlayerItems();
    }


    if (
pev->modelindex && (!m_fSequenceFinished) && (pev->deadflag == DEAD_DYING))
    {
        
StudioFrameAdvance( );

        
m_iRespawnFrames++;                // Note, these aren't necessarily real "frames", so behavior is dependent on # of client movement commands
        
if ( m_iRespawnFrames 120 )   // Animations should be no longer than this
            
return;
    }

    
// once we're done animating our death and we're on the ground, we want to set movetype to None so our dead body won't do collisions and stuff anymore
    // this prevents a bug where the dead body would go to a player's head if he walked over it while the dead player was clicking their button to respawn
    
if ( pev->movetype != MOVETYPE_NONE && FBitSet(pev->flagsFL_ONGROUND) )
        
pev->movetype MOVETYPE_NONE;

    if (
pev->deadflag == DEAD_DYING)
        
pev->deadflag DEAD_DEAD;
    
    
StopAnimation();

    
pev->effects |= EF_NOINTERP;
    
pev->framerate 0.0;

    
BOOL fAnyButtonDown = (pev->button & ~IN_SCORE );
    
    
// wait for all buttons released
    
if (pev->deadflag == DEAD_DEAD)
    {
        if (
fAnyButtonDown)
            return;

        if ( 
g_pGameRules->FPlayerCanRespawnthis ) )
        {
            
m_fDeadTime gpGlobals->time;
            
pev->deadflag DEAD_RESPAWNABLE;
        }
        
        return;
    }

// if the player has been dead for one second longer than allowed by forcerespawn, 
// forcerespawn isn't on. Send the player off to an intermission camera until they 
// choose to respawn.
    
if ( g_pGameRules->IsMultiplayer() && ( gpGlobals->time > (m_fDeadTime 6) ) && !(m_afPhysicsFlags PFLAG_OBSERVER) )
    {
        
// go to dead camera. 
        
StartDeathCam();
    }

    if ( 
pev->iuser1 )    // player is in spectator mode
        
return;    
    
// wait for any button down,  or mp_forcerespawn is set and the respawn time is up
    
if (!fAnyButtonDown 
        
&& !( g_pGameRules->IsMultiplayer() && forcerespawn.value && (gpGlobals->time > (m_fDeadTime 5))) )
        return;

    
pev->button 0;
    
m_iRespawnFrames 0;

    
//ALERT(at_console, "Respawn\n");

    
respawn(pev, !(m_afPhysicsFlags PFLAG_OBSERVER) );// don't copy a corpse if we're in deathcam.
    
pev->nextthink = -1;

__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 10-19-2021 at 05:52.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh