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[] name, bool 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 client, int 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.0, CheckForHealer, GetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE|TIMER_REPEAT);
}
return Plugin_Handled;
}
Action Command_Heal(int client, int 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 timer, any userid)
{
int iClient = GetClientOfUserId(userid);
if (IsValidClient(iClient) && g_bNoMedic[iClient] == true)
{
for (int i, n = GetEntProp(iClient, Prop_Send, "m_nNumHealers"); i < n; i++)
{
int iHealerIndex = TF2Util_GetPlayerHealer(iClient, i);
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);
}