Bug: I had to disable locker for every class or medic could regenerate his weapons.
If somebody know how could i disable it just for medic, let me know. Thanks.
Description: Medics have godmode, but they can't use their weapons, except their medigun.
PHP Code:
#pragma semicolon 1
#include <sourcemod>
#include <tf2_stocks>
public Plugin:myinfo =
{
name = "[TF2] Medic Godmode",
author = "[FG] Silent",
description = "Medics have godmode but they can't use their weapons, except their medigun",
version = "1.0.0",
url = "www.finalgaming.co.uk",
}
public OnPluginStart()
{
HookEvent("player_hurt", Event_player_hurt);
HookEvent("player_spawn", Event_player_spawn);
}
public Action:Event_player_hurt(Handle:event, const String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));
new TFClassType:class = TF2_GetPlayerClass(client);
if(class == TFClass_Medic)
{
SetEntProp(client, Prop_Send, "m_iHealth", 150);
SetEntProp(client, Prop_Data, "m_iHealth", 150);
}
else
{
return;
}
}
public Action:Event_player_spawn(Handle:event, const String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));
new TFClassType:class = TF2_GetPlayerClass(client);
new weapon = GetPlayerWeaponSlot(client, 1);
new iRegenerate = -1;
if(class == TFClass_Medic)
{
for(new i = 0; i <= 5; i++)
{
if(i == 1)
{
continue;
}
TF2_RemoveWeaponSlot(client, i);
}
while((iRegenerate = FindEntityByClassname(iRegenerate, "func_regenerate")) != -1)
{
AcceptEntityInput(iRegenerate, "Disable");
}
SetEntPropEnt(client, Prop_Send, "m_hActiveWeapon", weapon);
PrintToChat(client, "\x01\x04[MGM] \x01You have a godmode but you can't use your weapons, except your medigun!");
}
else
{
return;
}
}