Raised This Month: $51 Target: $400
 12% 

[CSGO] Detect death caused by team change


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Rozwel
Junior Member
Join Date: Apr 2019
Old 12-06-2020 , 16:39   [CSGO] Detect death caused by team change
Reply With Quote #1

I am looking for a code that would let me detect death caused by team switch, but i need to hook it before the death. I tried different things, but couldn't get this one, while i am pretty sure it should be simple, but i somehow missed it.

Would be very grateful if someone could share a function which does this. If there is something I should keep in mind using it, than reminding would be appreciated.

Thanks in advance!

Last edited by Rozwel; 12-06-2020 at 16:40.
Rozwel is offline
CowGod
Senior Member
Join Date: Feb 2015
Old 12-06-2020 , 19:49   Re: [CSGO] Detect death caused by team change
Reply With Quote #2

Name: switch_team
Structure:
short numPlayers number of active players on both T and CT
short numSpectators number of spectators
short avg_rank average rank of human players
short numTSlotsFree
short numCTSlotsFree

hook this, set boolean, hook death, check boolean, set back to false if it was true. That way you know it was team switch death.

Last edited by CowGod; 12-06-2020 at 19:51.
CowGod is offline
Send a message via Skype™ to CowGod
Rozwel
Junior Member
Join Date: Apr 2019
Old 12-07-2020 , 02:26   Re: [CSGO] Detect death caused by team change
Reply With Quote #3

Thanks for your reply, unfortunately it doesn't solve this case.

The solution, you have provided, allows me to check if someone died, after it happened. And, as i said(maybe not visibly enough, guess should have use caps :/ ), I need to get it early enough to prevent death in certain scenario. Also, it has to catch automatic team change, so listening for jointeam doesn't help as well.
Rozwel is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 12-07-2020 , 04:05   Re: [CSGO] Detect death caused by team change
Reply With Quote #4

You can prevent automatic team change and listen only for jointeam

PHP Code:

public void Event_PlayerConnect(Event event, const char[] namebool dontBroadcast
{
    
int client GetClientOfUserId(event.GetInt("userid"));
    if (!
client || !IsClientInGame(client))
    {
        return;
    }
    
    
SetEntPropFloat(clientProp_Send"m_fForceTeam"3600.0);

__________________
Ilusion9 is offline
FAQU
Member
Join Date: Sep 2020
Location: Romania
Old 12-07-2020 , 04:18   Re: [CSGO] Detect death caused by team change
Reply With Quote #5

Afaik changing the team will kill the player. So if you want to log deaths caused by changing the team you could maybe do something like this:

PHP Code:
public void OnPluginStart()
{
    
HookEvent("player_team"Event_PlayerTeamEventHookMode_Pre);
}

public 
Action Event_PlayerTeam(Handle event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(GetEventInt(event"userid"));
    if (
IsPlayerAlive(client))
    {
        
// LogAction(-1, -1, "%N died because of switchteam", client);
        // do other stuff
    
}
    return 
Plugin_Continue;

FAQU is offline
Rozwel
Junior Member
Join Date: Apr 2019
Old 12-07-2020 , 08:03   Re: [CSGO] Detect death caused by team change
Reply With Quote #6

Thanks for all the anserws.

Unfortunately, none of your solutions is what I am looking for, so I guess it`s not doable at the moment.

Thanks once again, and if you close threads as unsolved, than feel free to do so.

Last edited by Rozwel; 12-07-2020 at 08:03.
Rozwel is offline
SSheriFF
AlliedModders Donor
Join Date: May 2020
Location: Israel
Old 12-07-2020 , 10:22   Re: [CSGO] Detect death caused by team change
Reply With Quote #7

Quote:
Originally Posted by Rozwel View Post
Thanks for all the anserws.

Unfortunately, none of your solutions is what I am looking for, so I guess it`s not doable at the moment.

Thanks once again, and if you close threads as unsolved, than feel free to do so.
You can save the last position of the player and then respawn and teleport this player to his last location
__________________
Taking small private requests (Free) and big private requests (Paid).
Contact me via Discord: WilDick#1524

My Plugins:
SSheriFF is offline
Reply



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 11:21.


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