Raised This Month: $ Target: $400
 0% 

[TF2] Autobalance immunity/swapteam


Post New Thread Reply   
 
Thread Tools Display Modes
Stylee32
AlliedModders Donor
Join Date: Nov 2014
Old 12-24-2016 , 10:55   Re: [TF2] Autobalance immunity/swapteam
Reply With Quote #11

Quote:
Originally Posted by ZulukinG View Post
Friagram, would you mind explaining me how to use this code you just posted? Do I need to write into a specific file ? Can you give detailed explanations plz? Thank you !
Place in plugins folder
Attached Files
File Type: sp Get Plugin or Get Source (changeteamfix.sp - 466 views - 997 Bytes)
Stylee32 is offline
YoNer
Member
Join Date: Jul 2014
Old 12-24-2016 , 11:49   Re: [TF2] Autobalance immunity/swapteam
Reply With Quote #12

Quote:
Originally Posted by ZulukinG View Post
Friagram, would you mind explaining me how to use this code you just posted? Do I need to write into a specific file ? Can you give detailed explanations plz? Thank you !
You need to save the text as a .sp file and use the compiler, add it to your server's plugin folder and manually load it or restart your server.

Last edited by YoNer; 12-24-2016 at 11:49.
YoNer is offline
YoNer
Member
Join Date: Jul 2014
Old 12-24-2016 , 11:52   Re: [TF2] Autobalance immunity/swapteam
Reply With Quote #13

Quote:
Originally Posted by Benoist3012 View Post
You don't have to be sorry, the simple fact you used that plugin and gave feedbacks does not make you stupid

Code:
#pragma semicolon 1 #include <sourcemod> #include <sdktools> #include <tf2> #include <sdkhooks> public Plugin:myinfo =  {     name = "Change Team Fix",     author = "Friagram",     description = "burp",     version = "1.0",     url = "http://steamcommunity.com/groups/poniponiponi" }; public OnPluginStart() {     HookEvent("player_team", Event_PlayerTeam); } public Event_PlayerTeam(Handle:hEvent, const String:name[], bool:dontBroadcast) {     new userid = GetEventInt(hEvent, "userid");     new client = GetClientOfUserId(userid);     if(client && IsClientInGame(client))     {                  FakeClientCommand(client, "kill");          SDKHooks_TakeDamage(client, client, client, 9999.0);                RequestFrame(frame_respawn, userid);     } } public frame_respawn(any:userid) {     new client = GetClientOfUserId(userid);     if(client && IsClientInGame(client) && IsPlayerAlive(client))     {         TF2_RespawnPlayer(client);     } }

Edited friagram's code, I'm kinda surprised respawning a spectator does not cause a crash.
I remember it being a problem with my tf2 respawn api code (https://github.com/Benoist3012/-TF2--Respawn-System-API)

There is still one issue with this approach, if you launch a missile and or pipe bomb and join spec they are not destroyed and keep hurting other players. Couldnt this be fixed by killing all child entities as well?

Last edited by YoNer; 12-24-2016 at 12:04.
YoNer is offline
ZulukinG
Junior Member
Join Date: Dec 2016
Old 12-24-2016 , 12:53   Re: [TF2] Autobalance immunity/swapteam
Reply With Quote #14

Quote:
Originally Posted by Stylee32 View Post
Place in plugins folder

THANK YOU !!! Worked like a charm !
ZulukinG is offline
YoNer
Member
Join Date: Jul 2014
Old 12-24-2016 , 15:46   Re: [TF2] Autobalance immunity/swapteam
Reply With Quote #15

Ok, i found what seems to be the problem, the plugin was checking if player was alive in the next frame just after killing him

if(client && IsClientInGame(client) && IsPlayerAlive(client))

so this check was never passed and the TF2_RespawnPlayer(client); line was never executed, i removed the isplayeralive and now it seems to work correctly. Can someone else confirm?
Attached Files
File Type: sp Get Plugin or Get Source (changeteamfix.sp - 256 views - 984 Bytes)
File Type: smx changeteamfix.smx (4.7 KB, 92 views)
YoNer is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 12-25-2016 , 00:00   Re: [TF2] Autobalance immunity/swapteam
Reply With Quote #16

Shouldn't be required, as it kills them on the frame they change team, then checks the nest frame to see if they are still alive, and respawns them.

You could respawn them regardless, but that may interfere with some other mods.
If they die on that changeteam frame, then they shouldn't be alive, and it shouldn't need to respawn them. This is only for the spectator case though. If you want to change red/blue, you will have problems with some mods that do teambalance on their own.

which is why mine just worked for spectator case
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.

Last edited by friagram; 12-25-2016 at 00:00.
friagram is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 12-25-2016 , 00:21   Re: [TF2] Autobalance immunity/swapteam
Reply With Quote #17

Oh i see, you have to respawn them to remove the projectiles.
Change team no longer kills them.

PHP Code:
#pragma semicolon 1

#include <sourcemod>
#include <sdktools>
#include <tf2_stocks>
#include <sdkhooks>

public Plugin:myinfo =  {
    
name "Change Team Fix"
    
author "Friagram"
    
description "burp"
    
version "1.0"
    
url "http://steamcommunity.com/groups/poniponiponi"
};

public 
OnPluginStart()
{
    
HookEvent("player_team"Event_PlayerTeam);
    
    for (new 
client 1client <= MaxClientsclient++) // late load
    
{
        if (
IsClientInGame(client))
        {
            
OnClientPutInServer(client);
        }
    }
}

public 
OnClientPutInServer(client)
{
    
SDKHook(clientSDKHook_OnTakeDamageOnTakeDamage);
}

public 
Action:OnTakeDamage(client, &attacker, &inflictor, &Float:damage, &damagetype, &weaponFloat:damageForce[3], Float:damagePosition[3], damagecustom)
{
    if (
attacker && attacker <= MaxClients && IsClientInGame(attacker) && GetClientTeam(attacker) < 2)
    {
        
damage 0.0;
        return 
Plugin_Changed;
    }
    
    return 
Plugin_Continue;
}

public 
Event_PlayerTeam(Handle:hEvent, const String:name[], bool:dontBroadcast)
{
    if (
GetEventInt(hEvent"team") == 1)
    {
        new 
userid GetEventInt(hEvent"userid");
        new 
client GetClientOfUserId(userid);
        if (
client && IsClientInGame(client))
        {
            
FakeClientCommand(client"kill");
            
SDKHooks_TakeDamage(clientclientclient9999.0);
            
            
RequestFrame(frame_respawnuserid);
        }
    }
}

public 
frame_respawn(any:userid)
{
    new 
client GetClientOfUserId(userid);
    if (
client && IsClientInGame(client))
    {
        
TF2_RemoveAllWeapons(client); // engineer buildings
        
TF2_RespawnPlayer(client);
    }

here's an approach to stop the damage when they switch to spectator
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.

Last edited by friagram; 12-25-2016 at 01:02.
friagram is offline
ph
AlliedModders Donor
Join Date: Mar 2006
Old 12-25-2016 , 08:44   Re: [TF2] Autobalance immunity/swapteam
Reply With Quote #18

Quote:
Originally Posted by friagram View Post
Oh i see, you have to respawn them to remove the projectiles.
Change team no longer kills them.

PHP Code:
#pragma semicolon 1

#include <sourcemod>
#include <sdktools>
#include <tf2_stocks>
#include <sdkhooks>

public Plugin:myinfo =  {
    
name "Change Team Fix"
    
author "Friagram"
    
description "burp"
    
version "1.0"
    
url "http://steamcommunity.com/groups/poniponiponi"
};

public 
OnPluginStart()
{
    
HookEvent("player_team"Event_PlayerTeam);
    
    for (new 
client 1client <= MaxClientsclient++) // late load
    
{
        if (
IsClientInGame(client))
        {
            
OnClientPutInServer(client);
        }
    }
}

public 
OnClientPutInServer(client)
{
    
SDKHook(clientSDKHook_OnTakeDamageOnTakeDamage);
}

public 
Action:OnTakeDamage(client, &attacker, &inflictor, &Float:damage, &damagetype, &weaponFloat:damageForce[3], Float:damagePosition[3], damagecustom)
{
    if (
attacker && attacker <= MaxClients && IsClientInGame(attacker) && GetClientTeam(attacker) < 2)
    {
        
damage 0.0;
        return 
Plugin_Changed;
    }
    
    return 
Plugin_Continue;
}

public 
Event_PlayerTeam(Handle:hEvent, const String:name[], bool:dontBroadcast)
{
    if (
GetEventInt(hEvent"team") == 1)
    {
        new 
userid GetEventInt(hEvent"userid");
        new 
client GetClientOfUserId(userid);
        if (
client && IsClientInGame(client))
        {
            
FakeClientCommand(client"kill");
            
SDKHooks_TakeDamage(clientclientclient9999.0);
            
            
RequestFrame(frame_respawnuserid);
        }
    }
}

public 
frame_respawn(any:userid)
{
    new 
client GetClientOfUserId(userid);
    if (
client && IsClientInGame(client))
    {
        
TF2_RemoveAllWeapons(client); // engineer buildings
        
TF2_RespawnPlayer(client);
    }

here's an approach to stop the damage when they switch to spectator



Problem:

I applied your code, however when a player team swaps (!swapme) he is not killed and causes havoc in other players spawn area.


Can this be fixed ?
__________________

Last edited by ph; 12-25-2016 at 09:14.
ph is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 12-25-2016 , 12:52   Re: [TF2] Autobalance immunity/swapteam
Reply With Quote #19

remove
if (GetEventInt(hEvent, "team") == 1)
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.
friagram is offline
Stropy
Senior Member
Join Date: Feb 2016
Old 12-25-2016 , 16:50   Re: [TF2] Autobalance immunity/swapteam
Reply With Quote #20

Can you make this compatible with arena mod? If player is alive or dead and changes team, in this version it respawns him, which is not what should happen in arena mod.
Stropy 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 21:57.


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