Raised This Month: $ Target: $400
 0% 

Solved [TF2] Don't Heal Me Plugin


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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
 


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:02.


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