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

Solved [TF2] Don't Heal Me Plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
PC Gamer
Veteran Member
Join Date: Mar 2014
Old 11-07-2022 , 15:05   [TF2] Don't Heal Me Plugin
Reply With Quote #1

Please make and share a plugin that allows any player to type a command: !nomedic
When the command is entered Medic Bots are NOT able to able to target or heal the player with their medigun.
Players are able to reverse this action with the command: !medic

Why I want the plugin: I do a lot of development work on a live server. The sound and actions of the Medic Bot medigun annoy me while I'm testing things. They seem to fixate on me as a Human player and refuse to heal anyone else. In response to this I normally just change the class of all Medic Bots to something else. However, this has the negative effect of denying other Human players with Medic bots.

I'm hoping you'll be able to write and share a plugin that will prevent Medics from even targeting me with their healing medigun. That way there is no overhealing that impacts my testing, and no healing sound to annoy my ears.

Last edited by PC Gamer; 01-22-2023 at 19:11.
PC Gamer is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 11-10-2022 , 15:01   Re: [TF2] Don't Heal Me Plugin
Reply With Quote #2

...I have "fiddle about" little. If I'm lucky I post some kind example, soon.
Bacardi is offline
PC Gamer
Veteran Member
Join Date: Mar 2014
Old 11-10-2022 , 16:54   Re: [TF2] Don't Heal Me Plugin
Reply With Quote #3

Thanks Bacardi!

I made this plugin which works most of the time but it has two issues:
1. I'd prefer to find an solution that doesn't involve attributes.
2. Its buggy. The player will sometimes still get healed by a Medic.

If you have a better solution please share.

PHP Code:
#include <tf2_stocks>
#include <tf2attributes>

#pragma semicolon 1
#pragma newdecls required

#define PLUGIN_VERSION "1.0"
#define CHEER "/ambient_mp3/bumper_car_cheer3.mp3"

public Plugin myinfo 
{
    
name "No Healing",
    
author "PC Gamer",
    
description "Medics cannot heal Player",
    
version PLUGIN_VERSION,
    
url "https://forums.alliedmods.net/"
}

public 
void OnPluginStart() 
{
    
RegConsoleCmd("sm_noheal"No_Heal"Medics cannot heal you");
    
RegConsoleCmd("sm_nohealing"No_Heal"Medics cannot heal you");
    
RegConsoleCmd("sm_nomedic"No_Heal"Medics cannot heal you");    
    
RegConsoleCmd("sm_heal"Zombie_Mode"Medics can heal you");
    
RegConsoleCmd("sm_healing"Zombie_Mode"Medics can heal you");    
    
RegConsoleCmd("sm_medic"Zombie_Mode"Medics can heal you");    
}

public 
void OnMapStart()
{
    
PrecacheSound(CHEER);
}

public 
Action No_Heal(int clientint args)
{
    if(
IsValidClient(client))
    {
        
TF2Attrib_SetByName(client"mod weapon blocks healing"1.0);    

        
EmitSoundToAll(CHEER);
        
        
PrintToChat(client"You can no longer be healed by Medics");
        
PrintToChat(client"To reverse this effect type: !medic");
    }
    return 
Plugin_Handled;
}

public 
Action Zombie_Mode(int clientint args)
{    
    if(
IsValidClient(client))
    {
        
TF2Attrib_RemoveByName(client"mod weapon blocks healing");
        
        
PrintToChat(client"You can now be healed by Medics");
    }
    
    return 
Plugin_Handled;
}

stock bool IsValidClient(int client)
{
    if (
client <= 0) return false;
    if (
client MaxClients) return false;
    return 
IsClientInGame(client);

PC Gamer is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 11-10-2022 , 18:07   Re: [TF2] Don't Heal Me Plugin
Reply With Quote #4

I have test this far, with (Windows only)
Code:
CTFPlayer *CTFBotMedicHeal::SelectPatient( CTFBot *me, CTFPlayer *current )
bool CTFBotMedicHeal::IsStable( CTFPlayer *patient ) const
Medic not heal human player, if there are no other teammates in close range.

I have to look at least one more thing also
Code:
CFindMostInjuredNeighbor( CTFBot *me, float maxRange, bool isInCombat )
- When medic heal primary patient, medic also try heal other teammates close by who have low health.

I go sleep
Attached Files
File Type: sp Get Plugin or Get Source (test.sp - 33 views - 1.3 KB)
File Type: txt test.games.txt (3.3 KB, 25 views)
__________________
Do not Private Message @me

Last edited by Bacardi; 11-10-2022 at 18:07.
Bacardi is offline
PC Gamer
Veteran Member
Join Date: Mar 2014
Old 01-22-2023 , 19:10   Re: [TF2] Don't Heal Me Plugin
Reply With Quote #5

I'm marking this thread as 'solved' after receiving help from Bacardi, nosoop, and Pelipoika. Thanks!

Final version:
PHP Code:
//#include <tf2attributes>
#include <tf2utils> //tf2utils by nosoop

#pragma semicolon 1
#pragma newdecls required

#define PLUGIN_VERSION "1.0"
#define CHEER "/ambient_mp3/bumper_car_cheer3.mp3"

bool g_bNoMedic[MAXPLAYERS 1];

public 
Plugin myinfo 
{
    
name "No Healing",
    
author "PC Gamer",
    
description "Prevent Medics from Healing You",
    
version PLUGIN_VERSION,
    
url "www.sourcemod.net"
}

public 
void OnPluginStart() 
{
    
RegConsoleCmd("sm_noheal"Command_No_Heal"Medics cannot heal you");
    
RegConsoleCmd("sm_nohealing"Command_No_Heal"Medics cannot heal you");
    
RegConsoleCmd("sm_heal"Command_Heal"Medics can heal you");
    
RegConsoleCmd("sm_healing"Command_Heal"Medics can heal you");    

    
HookEvent("player_healed"EventPlayerHealed);
}

public 
void OnMapStart()
{
    
PrecacheSound(CHEER);
}

public 
void EventPlayerHealed(Handle event, const char[] namebool dontBroadcast
{
    
int iMedic GetClientOfUserId(GetEventInt(event"healer"));
    
int iPatient GetClientOfUserId(GetEventInt(event"patient"));
    
    if (
g_bNoMedic[iPatient] && iMedic !=iPatient)
    {
        
PrintToChat(iMedic"%N does not want to be healed"iPatient);
        
PrintToChat(iPatient"Doesn't want %N healing them"iMedic);        
        
ForcePlayerSuicide(iMedic);
    }
}

Action Command_No_Heal(int clientint args)
{
    if(
IsValidClient(client))
    {
        
//TF2Attrib_SetByName(client, "mod weapon blocks healing", 1.0);    

        
g_bNoMedic[client] = true;
        
EmitSoundToAll(CHEER);
        
        
PrintToChat(client"You can no longer be healed by Medics");
        
PrintToChat(client"To reverse this effect type: !healing");
        
CreateTimer(1.0CheckForHealerGetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE|TIMER_REPEAT);
    }
    return 
Plugin_Handled;
}

Action Command_Heal(int clientint args)
{    
    if(
IsValidClient(client))
    {
        
//TF2Attrib_RemoveByName(client, "mod weapon blocks healing");
        
        
g_bNoMedic[client] = false;
        
PrintToChat(client"You can now be healed by Medics");
        return 
Plugin_Stop;
    }
    
    return 
Plugin_Handled;
}

Action CheckForHealer(Handle timerany userid)
{
    
int iClient GetClientOfUserId(userid);
    
    if (
IsValidClient(iClient) && g_bNoMedic[iClient] == true)
    {
        for (
int iGetEntProp(iClientProp_Send"m_nNumHealers"); ni++)
        {
            
int iHealerIndex TF2Util_GetPlayerHealer(iClienti);
            
bool bIsClient = (iHealerIndex <= MaxClients);
            
            if(
bIsClient && iClient != iHealerIndex)
            {
                
//PrintToServer("\"%N\" <- healed by player \"%N\" [%i]", iClient, iHealerIndex, iHealerIndex);
                
PrintToChat(iHealerIndex"%N does not want to be healed"iClient);
                
ForcePlayerSuicide(iHealerIndex);
            }
        }
    }
    else
    {
        return 
Plugin_Stop;
    }
    
    return 
Plugin_Handled;
}

bool IsValidClient(int client)
{
    if (
client <= 0) return false;
    if (
client MaxClients) return false;
    return 
IsClientInGame(client);

PC Gamer 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 22:54.


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