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

Solved L4d - Prevent infected cloning on servers with unlimited team switching


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
finishlast
Senior Member
Join Date: Nov 2018
Location: In Reno with the vitamin
Old 01-15-2022 , 14:58   L4d - Prevent infected cloning on servers with unlimited team switching
Reply With Quote #1

Hi,

is there already a plugin preventing cloning of infected on servers with unlimited team switching?

The problem will occur when you have only 3 survivors or less on versus servers with unlimited switching.

You basically spawn as infected, lets say as hunter, then you switch teams, then switch back.

This switch will leave the game with a bot hunter and you can spawn again.

Repeat this step and you will end with lots of bot hunters, smokers and boomers.

Would it be possible to hook the teamswitch event and just delete all bot hunter, smoker, boomers?

Instead of suicide the bots, is there a way to just delete them instead? I think suicide would cause smokers with smoker cloud plugin to still do harm. And boomers with the boomer splash and vomit.

So basically the plugin should just delete the special hunter, smoker, boomers.

I have a semi working plugin here:

PHP Code:
/****************************************************************************************************
* Plugin     : L4D - no clone of infected
* Version    : 0.0.1
* Game       : Left 4 Dead
* Author     : Finishlast
*
* Testers    : Myself 
* Website    : www.l4d.com
* Purpose    : 
* Code snippets: Martts tanks checks
****************************************************************************************************/
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>

static bool g_bL4D2;
static 
int g_iTankClass;
#define TEAM_INFECTED 3
#define L4D1_ZOMBIECLASS_TANK 5
#define L4D2_ZOMBIECLASS_TANK 8

#pragma newdecls required


public APLRes AskPluginLoad2(Handle myselfbool latechar[] errorint err_max)
{
    
EngineVersion engine GetEngineVersion();

    
g_bL4D2 = (engine == Engine_Left4Dead2);
    
g_iTankClass = (g_bL4D2 L4D2_ZOMBIECLASS_TANK L4D1_ZOMBIECLASS_TANK);

    return 
APLRes_Success;
}


public 
void OnPluginStart()
{
    
HookEvent("player_team"event_onplayerchangeteamEventHookMode_PostNoCopy);
}

public 
void event_onplayerchangeteam(Event event, const char[] namebool dontBroadcast)
{
    for(
int i 1<= MaxClientsi++)
    {
        
// remove bots
        
if(IsClientInGame(i) && GetClientTeam(i) == TEAM_INFECTED && IsFakeClient(i) && !IsPlayerTank(i))
        {
        
KickClient(i);
        
PrintToChatAll("Thats a bot right here.");

        } 

    }
}

bool IsPlayerTank(int client)
{
    if (
GetClientTeam(client) != TEAM_INFECTED)
        return 
false;

    if (!
IsPlayerAlive(client))
        return 
false;

    if (
IsPlayerGhost(client))
        return 
false;

    if (
GetZombieClass(client) != g_iTankClass)
        return 
false;

    return 
true;
}

int GetZombieClass(int client)
{
    return (
GetEntProp(clientProp_Send"m_zombieClass"));
}

bool IsPlayerGhost(int client)
{
    return (
GetEntProp(clientProp_Send"m_isGhost") == 1);

I'm facing some strange behavior though.

When I spawn a special and switch teams, then the bot gets kicked as intended, but myself sometimes gets incapped as survivor?!

I also see several messages in chat, I would expect to only see 1 entry of "Thats a bot right here."

Tested oon empty server with 4 bot survivors and myself as infected switching teams.

But infact I see:

Thats a bot right here.
Thats a bot right here.
Thats a bot right here.
Thats a bot right here.
Thats a bot right here.
__________________

Last edited by finishlast; 01-23-2022 at 09:34.
finishlast is offline
HarryPotter
Veteran Member
Join Date: Sep 2017
Location: Taiwan, Asia
Old 01-16-2022 , 14:12   Re: L4d - Prevent infected cloning on servers with unlimited team switching
Reply With Quote #2

"player_team" event trigger multi times in l4d1/2 both game.
If you use printochatall and investigate, you will find something interesting.

When you switch team from infected(Hunter) to survivor(Zoey).
1. Game puts you from team 3 (infected) to team 1 (spectator). (First "player_team" event)
2. Game puts you from team 1 (spectator) to team 2 (survivor). (Second "player_team" event)
3. Game creates bot and bot takes over hunter. (3rd "player_team" event)
4. Because you take over zoey, game removes zoey bot. (4th "player_team" event)
5. Because you kick hunter, game removes hunter bot. (5th "player_team" event)

When you kick someone even AI, game also triggers "player_team" event.
When bot replace survivor/infected, game also triggers "player_team" event.

So your best solution is to use CreateTimer. check client 0.1s later.
PHP Code:
public void event_onplayerchangeteam(Event event, const char[] namebool dontBroadcast)
{
    
int userid event.GetInt("userid");
    
CreateTimer(0.1,RealPlayerChangeTeamEvent,userid); //delay 
}

public 
Action RealPlayerChangeTeamEvent(Handle timerint userid)
{
    
int client GetClientOfUserId(userid);
    if (
client && IsClientInGame(client) && GetClientTeam(client) == TEAM_INFECTED && IsFakeClient(client) && !IsPlayerTank(client))
    {
        
KickClient(client);
        
PrintToChatAll("player_team event delay check. We have an infeced bot right here.");
    } 
    return 
Plugin_Continue;

__________________

Last edited by HarryPotter; 01-16-2022 at 21:11.
HarryPotter is offline
finishlast
Senior Member
Join Date: Nov 2018
Location: In Reno with the vitamin
Old 01-17-2022 , 11:21   Re: L4d - Prevent infected cloning on servers with unlimited team switching
Reply With Quote #3

Quote:
Originally Posted by HarryPotter View Post
"player_team" event trigger multi times in l4d1/2 both game.
That makes sense, unfortunately this does not solve the issue with being incapped.

I just tried that, I only see 1 message now, but when I become survivor again, the survivor gets incapped instantly.

No further investigation here, its not caused by the plugin, I can even reproduce this on Valve Vanilla Versus.

It is a game bug.
__________________

Last edited by finishlast; 01-23-2022 at 09:34.
finishlast is offline
HarryPotter
Veteran Member
Join Date: Sep 2017
Location: Taiwan, Asia
Old 01-17-2022 , 20:23   Re: L4d - Prevent infected cloning on servers with unlimited team switching
Reply With Quote #4

Quote:
Originally Posted by finishlast View Post
That makes sense, unfortunately this does not solve the issue with being incapped.

I just tried that, I only see 1 message now, but when I become survivor again, the survivor gets incapped instantly.

No further investigation here, its not caused by the plugin, I can even reproduce this on Valve Vanilla Versus.

It is a game bug.
If this is game bug, then I can't help fix that.

Either you limit team switch time ( set vs_max_team_switches 1)
or
punish player who uses this bug intentionally.

Here is my thought, just provide a solution.
After infected player spawns(player_spawn event), if player switches team to survivor(player_team event) within 1 second, ban/slay him
__________________

Last edited by HarryPotter; 01-17-2022 at 20:30.
HarryPotter is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 01-18-2022 , 01:12   Re: L4d - Prevent infected cloning on servers with unlimited team switching
Reply With Quote #5

Just block the "jointeam" command within X seconds of spawning.
__________________
Silvers is offline
finishlast
Senior Member
Join Date: Nov 2018
Location: In Reno with the vitamin
Old 01-18-2022 , 01:57   Re: L4d - Prevent infected cloning on servers with unlimited team switching
Reply With Quote #6

Blocking the jointeam within x seconds after spawn will not help, I tested that.
Even after 60 seconds it happens, my first guess was wrong, you don't have to switch immediately.

Restricting it might reduce the amount of incaps in a row but cannot prevent the initial one.

On some maps you can produce instant death though and you only need one try for that then.

vs_max_team_switches 1 cannot prevent the first try.

Might change it to that though to reduce the spam.
__________________

Last edited by finishlast; 01-18-2022 at 12:37.
finishlast is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 01-18-2022 , 02:01   Re: L4d - Prevent infected cloning on servers with unlimited team switching
Reply With Quote #7

Block for X seconds after spawning surely that's the issue if switching causes this. Or maybe that's for the other bug you PM'd me about. You could watch for change team, maybe the TakeOver bot stuff fires in this case, then kick the SI bot, forcing suicide would cause Smoker Cloud etc to trigger so kick instead.
__________________
Silvers is offline
HarryPotter
Veteran Member
Join Date: Sep 2017
Location: Taiwan, Asia
Old 01-18-2022 , 06:14   Re: L4d - Prevent infected cloning on servers with unlimited team switching
Reply With Quote #8

Quote:
Originally Posted by finishlast View Post
Blocking the jointeam within x seconds after join will not help, I tested that.
Even after 60 seconds it happens, my first guess was wrong, you don't have to switch immediately.
Okay, then use SDKHook(client, SDKHook_OnTakeDamage); and investigate what the hell is going on.
Maybe there will be some useful information

PHP Code:
public void OnClientPutInServer(int client)
{
    
SDKHook(clientSDKHook_OnTakeDamageOnTakeDamage);
}

public 
Action OnTakeDamage(int victimint &attackerint &inflictorfloat &damageint &damagetypeint &weapon,
        
float damageForce[3], float damagePosition[3], int damagecustom)
{
    
PrintToChatAll("OnTakeDamage victim: %d,attacker: %d, damage is %f"victimattackerdamage);

__________________

Last edited by HarryPotter; 01-18-2022 at 10:16.
HarryPotter is offline
finishlast
Senior Member
Join Date: Nov 2018
Location: In Reno with the vitamin
Old 01-18-2022 , 12:24   Re: L4d - Prevent infected cloning on servers with unlimited team switching
Reply With Quote #9

When I do it, I see:

On Dead Air
OnTakeDamage victim: 2,attacker: 667, damage is 100.000000 (only incap)

On Blood harvest
OnTakeDamage victim: 2,attacker: 297, damage is 500.000000 (instant death)

@Silvers, thats what I pm you about, took me a while to understand when and how to reproduce it.

I realized that I had that in the past on some normal games but never associated the incap with it.

And while testing the above script to remove the extra bots, i forced it during testing, so it happens so often, so I finally understood how.

It is happening after spawn but it doesn't matter if you wait to switch, you can wait really long and then do it and you still incap the bot.
__________________

Last edited by finishlast; 01-18-2022 at 12:36.
finishlast is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 01-18-2022 , 13:42   Re: L4d - Prevent infected cloning on servers with unlimited team switching
Reply With Quote #10

Better block the team switch and use some scramble plugin.
Reading the thread seems that it has split into two issues.
__________________
Marttt 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 03:07.


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