PHP Code:
#include <sourcemod>
#include <sdktools>
#include <colors>
#pragma semicolon 1
#pragma newdecls required
#define HIDE_RADAR_CSGO 1<<12
#define HIDE_SCORE_CSGO 1<<13
#define HIDE_HEALTH_CSGO 1<<4
//#define HIDE_HINTTEXT_CSGO 1<<6
//#define HIDE_ALL_CSGO 1<<2
public void OnPluginStart()
{
RegConsoleCmd("sm_showhud", fwShowHud);
RegConsoleCmd("sm_hidehud", fwHideHud);
HookEvent("player_spawn", fwPlayerSpawn);
}
public Action fwPlayerSpawn( Handle hEvent, const char[] sName, bool bDontBroadcast )
{
int client = GetClientOfUserId( GetEventInt(hEvent, "userid") );
if ( IsPlayerAlive(client) )
CreateTimer(1.0, fwHudTask, client);
}
public Action fwHudTask(Handle hTimer, any client)
{
SetEntProp( client, Prop_Send, "m_iHideHUD", GetEntProp(client, Prop_Send, "m_iHideHUD") | HIDE_RADAR_CSGO );
SetEntProp( client, Prop_Send, "m_iHideHUD", GetEntProp(client, Prop_Send, "m_iHideHUD") | HIDE_SCORE_CSGO );
SetEntProp( client, Prop_Send, "m_iHideHUD", GetEntProp(client, Prop_Send, "m_iHideHUD") | HIDE_HEALTH_CSGO );
return Plugin_Handled;
}
public Action fwShowHud(int client, int args)
{
SetEntProp( client, Prop_Send, "m_iHideHUD", GetEntProp(client, Prop_Send, "m_iHideHUD") & ~HIDE_RADAR_CSGO );
SetEntProp( client, Prop_Send, "m_iHideHUD", GetEntProp(client, Prop_Send, "m_iHideHUD") & ~HIDE_SCORE_CSGO );
SetEntProp( client, Prop_Send, "m_iHideHUD", GetEntProp(client, Prop_Send, "m_iHideHUD") & ~HIDE_HEALTH_CSGO );
CPrintToChat(client, "[{olive}Timer{default}] Your hud is visible again.");
return Plugin_Handled;
}
public Action fwHideHud(int client, int args)
{
CreateTimer(0.0, fwHudTask, client);
CPrintToChat(client, "[{olive}Timer{default}] Your hud is now hidden.");
}