Raised This Month: $32 Target: $400
 8% 

[L4D2]Why does "ChangeClientTeam" have target confusion when 5+ players?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
plug344
Member
Join Date: Dec 2021
Old 02-17-2022 , 22:30   [L4D2]Why does "ChangeClientTeam" have target confusion when 5+ players?
Reply With Quote #1

I want to create a command "team", its effect is that when the player use, if his team is infected, he will join survivors, and if he is a survivor, he will join infected. This is to be able to switch team freely when the team is full. Its code like
PHP Code:
RegConsoleCmd("team"Command_Team);

public 
Action Command_Team(int clientint args)
{
    if (
client && IsClientInGame(client))
    {
        if (
GetClientTeam(client) != 3ChangeClientTeam(client3);
        else 
ChangeClientTeam(client2);
    }

    return 
Plugin_Handled;

While it works, there are often strange situations when using it, when there are more than 5 real (non-bot) players in the infected's team, if an infected real player uses the "team" command join the survivors. At this time, in addition to this real player of the infected who used the command, there is another real player of the Infected who is inexplicably switched to the survivors despite not using the command.
But using the default vanilla "M" key of the game itself to switch teams no such problem(, but it can only use if there are fewer than four real players in the survivor team),

Even, I also want to make the dead survivor player auto take over other survivor bots, the code such as
PHP Code:
HookEvent("player_death"Event_PlayerDeath);

public 
void Event_PlayerDeath(Event event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(event.GetInt("userid"));
    if (
client && IsClientInGame(client) && GetClientTeam(client) != && !IsFakeClient(client)) TakeOverBot(client);

Although there is this part of "GetClientTeam(client) != 3" in the code, when there are more than 5 players including bots in both the survivors and infected teams, when a real (non-bot) player in the survivor's team dies, although this player takes over other survivor bots, but in addition to him, another real player in the infected team was also inexplicably switched to the survivor team.

If I comment out these two pieces of code, there will be no such inexplicable team change problem. What problems may it be related to?

Last edited by plug344; 03-02-2022 at 22:30.
plug344 is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 02-22-2022 , 04:59   Re: [L4D2]Why does "ChangeClientTeam" have target confusion when 5+ players..?
Reply With Quote #2

This seems like it is likely a bug (in the game) caused by the hackery to allow more players than L4D2 supports.
__________________
asherkin is offline
plug344
Member
Join Date: Dec 2021
Old 02-23-2022 , 08:56   Re: [L4D2]Why does "ChangeClientTeam" have target confusion when 5+ players..?
Reply With Quote #3

Thank you very much for your reply
plug344 is offline
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 21:27.


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