Raised This Month: $32 Target: $400
 8% 

Plugin Hud message Only to Spectators


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
FreezerPT
Senior Member
Join Date: Mar 2017
Location: 127.0.0.1
Old 04-16-2020 , 19:16   Plugin Hud message Only to Spectators
Reply With Quote #1

Hello, its there any plugin that shows only a HUD message to spectators?
__________________
FreezerPT is offline
ThatOneGuy
Veteran Member
Join Date: Jul 2012
Location: Oregon, USA
Old 04-17-2020 , 17:11   Re: Plugin Hud message Only to Spectators
Reply With Quote #2

I have plugins that send messages to HUD with the location/color customizable. If you just need a simple repeating message, it could be coded very easily (free). What are the specifics of what you need?
__________________
ThatOneGuy is offline
NanoC
Veteran Member
Join Date: Jan 2016
Location: Argentina
Old 04-17-2020 , 18:05   Re: Plugin Hud message Only to Spectators
Reply With Quote #3

I didn't test it, tell me if it works.
PHP Code:
#include <sourcemod>
#include <sdktools>
#include <cstrike>
#include <multicolors>

#define RGBColor 0, 255, 0, 255

#pragma newdecls required
#pragma semicolon 1

#define PLUGIN_AUTHOR "Nano"
#define PLUGIN_VERSION "1.0"

bool b_ShowHudBoolean true;

public 
Plugin myinfo 
{
    
name "HUD message for spectators",
    
author PLUGIN_AUTHOR,
    
version PLUGIN_VERSION,
    
url ""
};

public 
void OnMapStart()
{
    
CreateTimer(1.0ShowText_TIMER_REPEAT); 
}

public 
void OnPluginStart()
{
    
RegAdminCmd("sm_togglehud"ToggleHudADMFLAG_GENERIC);
}

public 
Action ToggleHud(int clientint args)
{
    
ToggleHudSettings(client);
    return 
Plugin_Handled;
}

public 
void ToggleHudSettings(int client)
{
    
b_ShowHudBoolean = !b_ShowHudBoolean;
    
CPrintToChat(client"{green}[ToggleHud]{default} You have %s {default}the hud message for spectators."b_ShowHudBoolean "{blue}disabled" "{darkred}enabled");
}

public 
Action ShowText(Handle timer)    
{
    if(
b_ShowHudBoolean)
    {
        for (
int i 1<= MaxClientsi++)
        {    
            if (
IsClientInGame(i) && GetClientTeam(i) == CS_TEAM_SPECTATOR)  
            {    
                
SetHudTextParams(-1.00.45.0RGBColor00.001.01.0);
                
ShowHudText(i3"CHANGE THIS AND WRITE WHATEVER YOU WANT.");
            }    
        }
    }
    else
    {
        return 
Plugin_Stop;
    }
    return 
Plugin_Handled;

Edit line 55 and write whatever you want to show to spectators
Also i've added a command for admins with generic flag to toggle enable/disable the hud message whenever you want, you just need to type !togglehud
__________________
NanoC is offline
Send a message via Skype™ to NanoC
FreezerPT
Senior Member
Join Date: Mar 2017
Location: 127.0.0.1
Old 04-17-2020 , 19:05   Re: Plugin Hud message Only to Spectators
Reply With Quote #4

Quote:
Originally Posted by ThatOneGuy View Post
I have plugins that send messages to HUD with the location/color customizable. If you just need a simple repeating message, it could be coded very easily (free). What are the specifics of what you need?

I need a plugin to display a message in the middle of the screen but only for the spectators! I am using a plugin that makes the spectators screen black, they can see only the minimap!

And when they enter, they don't think it's strange the screen is all black so have a message just for spectators

Plugin:

Quote:
#include <sdktools>

UserMsg g_FadeUserMsgId;


public void OnPluginStart()
{
g_FadeUserMsgId = GetUserMessageId("Fade");
HookEventEx("switch_team", switch_team);
}

public void switch_team(Event event, const char[] name, bool dontBroadcast)
{
int[] targets = new int[MaxClients]
int count;


for(int client = 1; client <= MaxClients; client++)
{
if(!IsClientInGame(client) || IsFakeClient(client)) continue;

if(GetClientTeam(client) > 1) continue;

if(CheckCommandAccess(client, "sm_allow_spec", ADMFLAG_GENERIC)) continue;

targets[count++] = client;
}

if(count == 0) return;

// sm_blind
int amount = 255;
int duration = 500;
int holdtime = 500;
int flags;
if (amount == 0)
{
flags = (0x0001 | 0x0010);
}
else
{
flags = (0x0002 | 0x000;
}

int color[4] = { 0, 0, 0, 0 };
color[3] = amount;

Handle message = StartMessageEx(g_FadeUserMsgId, targets, count);
if (GetUserMessageType() == UM_Protobuf)
{
Protobuf pb = UserMessageToProtobuf(message);
pb.SetInt("duration", duration);
pb.SetInt("hold_time", holdtime);
pb.SetInt("flags", flags);
pb.SetColor("clr", color);
}
else
{
BfWrite bf = UserMessageToBfWrite(message);
bf.WriteShort(duration);
bf.WriteShort(holdtime);
bf.WriteShort(flags);
bf.WriteByte(color[0]);
bf.WriteByte(color[1]);
bf.WriteByte(color[2]);
bf.WriteByte(color[3]);
}

EndMessage();
}
__________________
FreezerPT is offline
FreezerPT
Senior Member
Join Date: Mar 2017
Location: 127.0.0.1
Old 04-17-2020 , 19:18   Re: Plugin Hud message Only to Spectators
Reply With Quote #5

Quote:
Originally Posted by NanoC View Post
I didn't test it, tell me if it works.
PHP Code:
#include <sourcemod>
#include <sdktools>
#include <cstrike>
#include <multicolors>

#define RGBColor 0, 255, 0, 255

#pragma newdecls required
#pragma semicolon 1

#define PLUGIN_AUTHOR "Nano"
#define PLUGIN_VERSION "1.0"

bool b_ShowHudBoolean true;

public 
Plugin myinfo 
{
    
name "HUD message for spectators",
    
author PLUGIN_AUTHOR,
    
version PLUGIN_VERSION,
    
url ""
};

public 
void OnMapStart()
{
    
CreateTimer(1.0ShowText_TIMER_REPEAT); 
}

public 
void OnPluginStart()
{
    
RegAdminCmd("sm_togglehud"ToggleHudADMFLAG_GENERIC);
}

public 
Action ToggleHud(int clientint args)
{
    
ToggleHudSettings(client);
    return 
Plugin_Handled;
}

public 
void ToggleHudSettings(int client)
{
    
b_ShowHudBoolean = !b_ShowHudBoolean;
    
CPrintToChat(client"{green}[ToggleHud]{default} You have %s {default}the hud message for spectators."b_ShowHudBoolean "{blue}disabled" "{darkred}enabled");
}

public 
Action ShowText(Handle timer)    
{
    if(
b_ShowHudBoolean)
    {
        for (
int i 1<= MaxClientsi++)
        {    
            if (
IsClientInGame(i) && GetClientTeam(i) == CS_TEAM_SPECTATOR)  
            {    
                
SetHudTextParams(-1.00.45.0RGBColor00.001.01.0);
                
ShowHudText(i3"CHANGE THIS AND WRITE WHATEVER YOU WANT.");
            }    
        }
    }
    else
    {
        return 
Plugin_Stop;
    }
    return 
Plugin_Handled;

Edit line 55 and write whatever you want to show to spectators
Also i've added a command for admins with generic flag to toggle enable/disable the hud message whenever you want, you just need to type !togglehud
Work really nice, but i forget to say something! When the admins has the b flag they dont have the screen black, and they can see the game! So they dont need the hud message! Can you add this plugin to show to everyone, less the admins with b flag?
__________________
FreezerPT is offline
NanoC
Veteran Member
Join Date: Jan 2016
Location: Argentina
Old 04-17-2020 , 19:30   Re: Plugin Hud message Only to Spectators
Reply With Quote #6

Quote:
Originally Posted by FreezerPT View Post
Work really nice, but i forget to say something! When the admins has the b flag they dont have the screen black, and they can see the game! So they dont need the hud message! Can you add this plugin to show to everyone, less the admins with b flag?
PHP Code:
#include <sourcemod>
#include <sdktools>
#include <cstrike>
#include <multicolors>

#define RGBColor 0, 255, 0, 255

#pragma newdecls required
#pragma semicolon 1

#define PLUGIN_AUTHOR "Nano"
#define PLUGIN_VERSION "1.0"

bool b_ShowHudBoolean true;

public 
Plugin myinfo 
{
    
name "HUD message for spectators",
    
author PLUGIN_AUTHOR,
    
version PLUGIN_VERSION,
    
url ""
};

public 
void OnMapStart()
{
    
CreateTimer(1.0ShowText_TIMER_REPEAT); 
}

public 
void OnPluginStart()
{
    
RegAdminCmd("sm_togglehud"ToggleHudADMFLAG_GENERIC);
}

public 
Action ToggleHud(int clientint args)
{
    
ToggleHudSettings(client);
    return 
Plugin_Handled;
}

public 
void ToggleHudSettings(int client)
{
    
b_ShowHudBoolean = !b_ShowHudBoolean;
    
CPrintToChat(client"{green}[ToggleHud]{default} You have %s {default}the hud message for spectators."b_ShowHudBoolean "{blue}disabled" "{darkred}enabled");
}

public 
Action ShowText(Handle timer)    
{
    if(
b_ShowHudBoolean)
    {
        for (
int i 1<= MaxClientsi++)
        {    
            if (
IsClientInGame(i) && !GetUserAdmin(i).HasFlag(Admin_Generic) && GetClientTeam(i) == CS_TEAM_SPECTATOR)  
            {    
                
SetHudTextParams(-1.00.45.0RGBColor00.001.01.0);
                
ShowHudText(i3"CHANGE THIS AND WRITE WHATEVER YOU WANT.");
            }    
        }
    }
    else
    {
        return 
Plugin_Stop;
    }
    return 
Plugin_Handled;

Here we go
__________________
NanoC is offline
Send a message via Skype™ to NanoC
Reply



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 01:27.


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