I tried this code on a timer, but it's not working...
Specifically, it's not working because if a medic is healing a person, their armor heals.....
but I only want the dispenser to heal the armor when healing a player.
PHP Code:
public Action:DispenserCheck(Handle:timer, any:client)
{
if (GetConVarBool(plugin_enable) && GetConVarBool(armor_from_spencer))
{
if (!GetConVarBool(cvBlu) && GetClientTeam(client) == 3)
return Plugin_Handled;
if (!GetConVarBool(cvRed) && GetClientTeam(client) == 2)
return Plugin_Handled;
decl String:clsname[32];
new spencerrepair = GetConVarInt(spencer_to_armor);
new dispenser = -1;
while ((dispenser = FindEntityByClassname2(dispenser, "obj_dispenser")) != -1)
{
if (IsValidEntity(dispenser)) GetEdictClassname(dispenser, clsname, sizeof(clsname));
if (IsValidEntity(client) && TF2_IsPlayerInCondition(client, TFCond_Healing) && strcmp(clsname, "obj_dispenser", false) == 0)
{
GetArmorClass(client);
if (MaxArmor[client] - armor[client] < spencerrepair)
spencerrepair = MaxArmor[client] - armor[client];
if (armor[client] < MaxArmor[client])
armor[client] += spencerrepair;
if (armor[client] > MaxArmor[client] && ArmorOverheal[client] == false)
armor[client] = MaxArmor[client];
}
}
}
return Plugin_Continue;
}
stock FindEntityByClassname2(startEnt, const String:classname[])
{
/* If startEnt isn't valid shifting it back to the nearest valid one */
while (startEnt > -1 && !IsValidEntity(startEnt)) startEnt--;
return FindEntityByClassname(startEnt, classname);
}
__________________