AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Remove "DEAD" flag (https://forums.alliedmods.net/showthread.php?t=312301)

edon1337 11-25-2018 17:18

Remove "DEAD" flag
 
Hi, I've been going thru some issues with my latest code, I'm unable to remove the 'DEAD' flag from scoreboard for some reason, and I'm trying to do something: When Player1 infects Player2 it should show up in the kill-feed like this:

Player1 ☠️ Player2 or Player1 ☠️ Player2

Player2 color depending on his team, but instead it's always showing:
Player1 ☠️ Player2

PS: TEAM_MONSTER == 2 (TEAM_CT)

PHP Code:

InfectPlayeriVictimiAttacker )
{
    
InfectionMsgiVictimiAttacker );

    
cs_set_user_teamiVictimTEAM_MONSTER );
    
g_iPlayerTeamiVictim ] = TEAM_MONSTER;
    
    
RemoveDeadFlagiVictim );
}

RemoveDeadFlagiPlayer )
{
    
message_beginMSG_ALLg_iMsgScoreAttrib 
    { 
        
write_byteiPlayer 
        
write_byte
        
message_end( ) 
    }
}

InfectionMsgiVictimiAttacker )
{
    
message_beginMSG_BROADCASTg_iMsgDeath )
    
write_byteiAttacker // killer
    
write_byteiVictim // victim
    
write_byte// headshot flag
    
write_string"infection" // killer's weapon
    
message_end( )



edon1337 11-29-2018 17:00

Re: Remove "DEAD" flag
 
Here's the answer on how to solve the issues in case someone needs them since nobody helped me:

1. All I had to do to remove the "DEAD" flag was change MSG_ALL to MSG_BROADCAST for some reason.
2. Creating a 0.1s task after sending Infection Message and then changing the player team inside the task will make it work, the reason:

When you send infection message it is called twice, not sure about the in-between delay of the messages though. So:

• Attacker is CT, victim is T
• You send infection message
• Right message is sent, CT attacker kills T victim
• Victim team is changed to CT
• Message is sent again with changed teams (both CT)
That's why it always showed victim team CT.

Bugsy 11-29-2018 18:14

Re: Remove "DEAD" flag
 
Thanks for posting your solution. FWIW, I did try but it was not working for me so I didn't bother to reply. I dug up this thread which was of no help.

edon1337 11-30-2018 08:09

Re: Remove "DEAD" flag
 
Quote:

Originally Posted by Bugsy (Post 2626114)
Thanks for posting your solution. FWIW, I did try but it was not working for me so I didn't bother to reply. I dug up this thread which was of no help.

Thanks for your time.
I'm still not sure what's causing it to get called twice though.

Bugsy 11-30-2018 10:17

Re: Remove "DEAD" flag
 
What do you mean by twice

edon1337 11-30-2018 10:36

Re: Remove "DEAD" flag
 
Quote:

Originally Posted by Bugsy (Post 2626179)
What do you mean by twice

I debugged and DeathMsg was sent twice, first is because of what I sent manually but the second one?

Bugsy 11-30-2018 19:04

Re: Remove "DEAD" flag
 
InfectionMsg() does not trigger the actual DeathMsg event..if you hook DeathMsg and call InfectionMsg(), DeathMsg is not called. I would need to see more of your code.

edon1337 12-01-2018 12:05

Re: Remove "DEAD" flag
 
Quote:

Originally Posted by Bugsy (Post 2626217)
InfectionMsg() does not trigger the actual DeathMsg event..if you hook DeathMsg and call InfectionMsg(), DeathMsg is not called. I would need to see more of your code.

My bad, I was thinking InfectionMsg was somehow called twice, but now I see it's not.
So what's the reason I have to set a 0.1 second delay to make it work properly?

When I don't set a 0.1s delay it shows always CT, but when I set a 0.1s delay, it shows the right team.

Works:
PHP Code:

InfectPlayeriVictimiAttacker )
{    
    
InfectionMsgiVictimiAttacker );
    
set_task0.1"DelayedTeamChange"iVictim TASK_TEAM_DELAY );
}

public 
DelayedTeamChangeiVictim )
{
    
iVictim -= TASK_TEAM_DELAY;

    
cs_set_user_teamiVictimTEAM_MONSTER );
    
g_iPlayerTeamiVictim ] = TEAM_MONSTER;
    
    
RemoveDeadFlagiVictim );


Doesn't work:
PHP Code:

InfectPlayeriVictimiAttacker )
{    
    
InfectionMsgiVictimiAttacker );
    
    
cs_set_user_teamiVictimTEAM_MONSTER );
    
g_iPlayerTeamiVictim ] = TEAM_MONSTER;
    
    
RemoveDeadFlagiVictim );



HamletEagle 12-01-2018 13:08

Re: Remove "DEAD" flag
 
Things don't happen instantly, so DeathMsg is likely processed by the game after the team change you made. Setting the task delays the team change after DeathMsg was sent.

edon1337 12-01-2018 13:39

Re: Remove "DEAD" flag
 
Quote:

Originally Posted by HamletEagle (Post 2626274)
Things don't happen instantly, so DeathMsg is likely processed by the game after the team change you made. Setting the task delays the team change after DeathMsg was sent.

Yeah that must be it.


All times are GMT -4. The time now is 07:35.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.