Raised This Month: $9 Target: $400
 2% 

Solved Give the same functionality for the alive players to the dead players


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Natsheh
Veteran Member
Join Date: Sep 2012
Old 10-19-2021 , 01:36   Give the same functionality for the alive players to the dead players
Reply With Quote #1

As the title says i want to spawn a dead player but the player remains dead for example when all of the player teammates are officially dead the round ends even if the dead player is still alive.

I tried spawning the player and giving him the dead_dead flag but i assume the player functionality is changed on player think and the player returns to the dead spectating.
__________________
@Jailbreak Main Mod v2.6.6 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 10-21-2021 at 06:30.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 10-19-2021 , 05:45   Re: Give the same functionality for the alive players to the dead players
Reply With Quote #2

As I check in gamerules.cpp, it don't have to be DEAD_DEAD to trigger round end, only need to be not DEAD_NO.
Maybe try DEAD_DYING or DEAD_RESPAWNABLE after spawn?

Reference
Spoiler
__________________
My plugin:

Last edited by Celena Luna; 10-19-2021 at 05:53.
Celena Luna is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 10-19-2021 , 06:01   Re: Give the same functionality for the alive players to the dead players
Reply With Quote #3

Quote:
Originally Posted by Natsheh View Post

I tried spawning the player and giving him the dead_dead flag but i assume the player functionality is changed on player think and the player returns to the dead spectating.
__________________
@Jailbreak Main Mod v2.6.6 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 10-19-2021 , 06:35   Re: Give the same functionality for the alive players to the dead players
Reply With Quote #4

Quote:
Originally Posted by Natsheh View Post
I tried spawning the player and giving him the dead_dead flag but i assume the player functionality is changed on player think and the player returns to the dead spectating.
Did I misunderstand something?
I mean "anything other than DEAD_NO will count as DEAD and will treat it as dead player."
You said you set DEAD_DEAD and it turn player back to spec so I thought changing to DEAD_RESPAWNABLE will work.
__________________
My plugin:
Celena Luna is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 10-19-2021 , 06: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.6.6 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 10-19-2021 at 06:52.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 10-19-2021 , 09:31   Re: Give the same functionality for the alive players to the dead players
Reply With Quote #6

Hook CHalfLifeMultiplay::CheckWinConditions and check the number of alive players, excluding the ones who are supposed to be dead, then force the round to end. To finish the round, you'll need TerminateRound, you won't even need to hook that with orpheu, it can be implemented in amxx, it's just three lines.

https://github.com/s1lentq/reapi/blo...merules.h#L698


If using regamedll and reapi, there is RG_CSGameRules_CheckWinConditions and rg_round_end native.
There are two alternatives I can think of right now if you're not able to use orpheu at all to get the signature for CheckWinConditions.

You will do that same check
Quote:
check the number of alive players, excluding the ones who are supposed to be dead
but on Ham_Killed and client_remove, this may fail if you transfer a player from his team without actually killing him.

The other is to either set a loop task or create an entity and there do that check. To check if the round is not already ending you can use m_bRoundTerminating.


To show the player as dead in the scoreboard, hook ScoreAttrib and set the flag (1<<0), you don't need DEAD_DEAD.

There is also this plugin which does exactly what you are trying, you may want to check it. https://forums.alliedmods.net/showth...1851?p=1441851
__________________





Last edited by CrazY.; 10-19-2021 at 10:45.
CrazY. is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 10-19-2021 , 11:00   Re: Give the same functionality for the alive players to the dead players
Reply With Quote #7

i managed for it to work using this sequence of code

Code:
		ExecuteHamB(Ham_CS_RoundRespawn, id); 
		set_pev(id, pev_deadflag, DEAD_RESPAWNABLE);
		set_pev(id, pev_solid, SOLID_SLIDEBOX);
		set_pev(id, pev_movetype, MOVETYPE_WALK);
		set_pev(id, pev_health, 100.0);
		set_pev(id, pev_maxspeed, 250.0);
		give_item(id, "weapon_knife");
but now people can't see each other properly because there's a delay on the model location.
__________________
@Jailbreak Main Mod v2.6.6 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 10-19-2021 at 11:01.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Old 10-20-2021, 03:53
Natsheh
This message has been deleted by Natsheh. Reason: Nvm i found another solution
Natsheh
Veteran Member
Join Date: Sep 2012
Old 10-20-2021 , 06:04   Re: Give the same functionality for the alive players to the dead players
Reply With Quote #8

Quote:
Originally Posted by Natsheh View Post
but now people can't see each other properly because there's a delay on the model location.

Its because on player think post the player is thought dead and most of the alive functions are ignored.
__________________
@Jailbreak Main Mod v2.6.6 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Natsheh
Veteran Member
Join Date: Sep 2012
Old 10-20-2021 , 10:29   Re: Give the same functionality for the alive players to the dead players
Reply With Quote #9

New error there's a problem with switching weapons if anyone can post the function of switching weapons or deploying them because i can't find it.

The problem is when switching a weapon the holster weapon is been deployed again, the dead flag is some how preventing the new weapon from been deployed, i searched the SelectItem in player.cpp but I couldn't find anything useful.
__________________
@Jailbreak Main Mod v2.6.6 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 10-20-2021 at 14:29.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Natsheh
Veteran Member
Join Date: Sep 2012
Old 10-21-2021 , 06:29   Re: Give the same functionality for the alive players to the dead players
Reply With Quote #10

Quote:
Originally Posted by Natsheh View Post
New error there's a problem with switching weapons if anyone can post the function of switching weapons or deploying them because i can't find it.

The problem is when switching a weapon the holster weapon is been deployed again, the dead flag is some how preventing the new weapon from been deployed, i searched the SelectItem in player.cpp but I couldn't find anything useful.

Solved, by setting the player dead_flag to dead_no and re-executing the weapon selection then setting back the player to dead_respawn in client_command forward, the same thing for dropping the weapons.
__________________
@Jailbreak Main Mod v2.6.6 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 10-21-2021 at 06:32.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
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

Forum Jump


All times are GMT -4. The time now is 20:26.


Powered by vBulletin®
Copyright ©2000 - 2021, vBulletin Solutions, Inc.
Theme made by Freecode