Raised This Month: $ Target: $400
 0% 

Hud text is now supported in csgo!


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Kinsi
Senior Member
Join Date: Apr 2013
Old 03-20-2017 , 18:15   Re: Hud text is now supported in csgo!
Reply With Quote #1

Obligatory thanks to Alex Bel!

https://github.com/ValveSoftware/csg...ssue-146618900
Kinsi is offline
TheDS1337
Veteran Member
Join Date: Jun 2012
Old 03-19-2017 , 17:08   Re: Hud text is now supported in csgo!
Reply With Quote #2

Oh my god!
TheDS1337 is offline
Nexicon
Senior Member
Join Date: Feb 2017
Old 03-19-2017 , 17:20   Re: Hud text is now supported in csgo!
Reply With Quote #3

I hope some Server Advertisement would update to support this !
Nexicon is offline
hlstriker
Green Gaben
Join Date: Mar 2006
Location: OH-IO!
Old 03-19-2017 , 17:22   Re: Hud text is now supported in csgo!
Reply With Quote #4

About time :>

If you want to use the SourceMod HudMsg functions 1 2 you can add support in the following file:
addons/sourcemod/gamedata/core.games/common.games.txt

ctrl + F for "Which games support HudMsg?" and add "csgo" to the supported list.

Woooooooo
hlstriker is offline
Franc1sco
Veteran Member
Join Date: Oct 2010
Location: Spain (Madrid)
Old 03-19-2017 , 23:29   Re: Hud text is now supported in csgo!
Reply With Quote #5

Quote:
Originally Posted by hlstriker View Post
Really very usefull for the spectator list plugin. You can sharing it or we will need to recreate it?
__________________
Veteran Coder -> Activity channel
Coding on CS2 and taking paid and free jobs.

Contact: Steam, Telegram or discord ( franug ).

You like my work? +Rep in my steam profile comments or donate.

Franc1sco is offline
Send a message via MSN to Franc1sco
hlstriker
Green Gaben
Join Date: Mar 2006
Location: OH-IO!
Old 03-20-2017 , 11:15   Re: Hud text is now supported in csgo!
Reply With Quote #6

Quote:
Originally Posted by Franc1sco View Post
You can sharing it or we will need to recreate it?
Sure, it's a pretty old plugin I haven't used in many many years so why not. If you end up making a release you will want to use SourceMod's HudMsg functions and make the message buffer dynamic. Updating to the new syntax and giving admins the option to hide themselves from the list would be cool too. To optimize more just remove the prethink hook and lower the SPEC_MESSAGE_DELAY time. If you lower SPEC_MESSAGE_DELAY keep in mind it'll send messages over the network more often.

PHP Code:
#include <sourcemod>
#include <sdkhooks>

#pragma semicolon 1

new const String:PLUGIN_VERSION[] = "1.0";

public 
Plugin:myinfo 
{
    
name "Show Spectators",
    
author "hlstriker",
    
description "Shows who is spectating a specific player.",
    
version PLUGIN_VERSION,
    
url "www.swoobles.com"
}

const 
OBS_MODE_IN_EYE    4;
const 
OBS_MODE_CHASE    5;

const 
Float:SPEC_MESSAGE_DELAY 1.2;
new 
Float:g_fNextSpecMessage[MAXPLAYERS+1];
new 
g_iSpectating[MAXPLAYERS+1];

new 
UserMsg:g_msgHudMsg;


public 
OnPluginStart()
{
    
CreateConVar("hls_showspec_version"PLUGIN_VERSION"Show Spectators Version"FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_NOTIFY|FCVAR_PRINTABLEONLY);
    
    
g_msgHudMsg GetUserMessageId("HudMsg");
    
    for(new 
iClient=1iClient<=MaxClientsiClient++)
    {
        if(
IsClientInGame(iClient))
            
SDKHook(iClientSDKHook_PreThinkhook_PreThink);
    }
    
    
CreateTimer(SPEC_MESSAGE_DELAYTimerSpecMessage_TIMER_REPEAT);
}

public 
Action:TimerSpecMessage(Handle:hTimer)
{
    new 
Float:fCurTime GetEngineTime();
    for(new 
iClient=1iClient<=MaxClientsiClient++)
    {
        if(!
IsClientInGame(iClient) || IsPlayerAlive(iClient))
            continue;
        
        if(
g_fNextSpecMessage[iClient] > fCurTime)
            continue;
        
        
BuildSpecMessage(iClient);
    }
}

public 
OnClientPutInServer(iClient)
{
    
SDKHook(iClientSDKHook_PreThinkhook_PreThink);
}

public 
hook_PreThink(iClient)
{
    if(
IsPlayerAlive(iClient))
        return;
    
    if(!
UpdateSpectatingTarget(iClient))
        return;
    
    
BuildSpecMessage(iClient);
}

UpdateSpectatingTarget(iClient)
{
    
// Return true if the client is spectating a different player.
    
    
switch(GetEntProp(iClientProp_Send"m_iObserverMode"))
    {
        case 
OBS_MODE_IN_EYEOBS_MODE_CHASE:
        {
            new 
iSpectating GetEntPropEnt(iClientProp_Send"m_hObserverTarget");
            if(
iSpectating != g_iSpectating[iClient])
            {
                
g_iSpectating[iClient] = iSpectating;
                return 
true;
            }
        }
        default:
        {
            if(
g_iSpectating[iClient])
            {
                
// This client was spectating someone, but isn't anymore so clear their message.
                
g_iSpectating[iClient] = 0;
                
ShowSpecMessage(iClient" ");
            }
        }
    }
    
    return 
false;
}

BuildSpecMessage(iClient)
{
    
g_fNextSpecMessage[iClient] = GetEngineTime() + SPEC_MESSAGE_DELAY 0.2;
    
    if(
g_iSpectating[iClient] <= || !IsClientInGame(g_iSpectating[iClient]))
        return;
    
    static 
String:szBuffer[254], iBufLenString:szName[32];
    
iBufLen 0;
    
GetClientName(g_iSpectating[iClient], szNamesizeof(szName));
    
    
iBufLen += FormatEx(szBuffer[iBufLen], sizeof(szBuffer)-iBufLen"\nSpectating %s:\n"szName);
    
    for(new 
iSpectator=1iSpectator<=MaxClientsiSpectator++)
    {
        if(!
IsClientInGame(iSpectator) || IsPlayerAlive(iSpectator))
            continue;
        
        if(
g_iSpectating[iSpectator] != g_iSpectating[iClient])
            continue;
        
        
GetClientName(iSpectatorszNamesizeof(szName));
        
iBufLen += FormatEx(szBuffer[iBufLen], sizeof(szBuffer)-iBufLen"%s\n"szName);
    }
    
    
ShowSpecMessage(iClientszBuffer);
}

ShowSpecMessage(iClient, const String:szMessage[])
{
    
HudMsg(iClient1Float:{0.8, -1.0}, {25500255}, {02550255}, 00.10.1SPEC_MESSAGE_DELAY 0.10.0szMessage);
}

HudMsg(iClientiChannel, const Float:fPosition[2], const iColor1[4], const iColor2[4], iEffectFloat:fFadeInTimeFloat:fFadeOutTimeFloat:fHoldTimeFloat:fEffectTime, const String:szText[], any:...)
{
    if(
GetUserMessageType() != UM_Protobuf)
        return 
false;
    
    
decl String:szBuffer[256];
    
VFormat(szBuffersizeof(szBuffer), szText12);
    
    
decl iClients[1];
    
iClients[0] = iClient;
    
    new 
Handle:hMessage StartMessageEx(g_msgHudMsgiClients1);
    
PbSetInt(hMessage"channel"iChannel);
    
PbSetVector2D(hMessage"pos"fPosition);
    
PbSetColor(hMessage"clr1"iColor1);
    
PbSetColor(hMessage"clr2"iColor2);
    
PbSetInt(hMessage"effect"iEffect);
    
PbSetFloat(hMessage"fade_in_time"fFadeInTime);
    
PbSetFloat(hMessage"fade_out_time"fFadeOutTime);
    
PbSetFloat(hMessage"hold_time"fHoldTime);
    
PbSetFloat(hMessage"fx_time"fEffectTime);
    
PbSetString(hMessage"text"szBuffer);
    
EndMessage();
    
    return 
true;


Last edited by hlstriker; 03-20-2017 at 11:28.
hlstriker is offline
Dreizehnt
Junior Member
Join Date: Jan 2016
Location: Russian Federation
Old 04-17-2017 , 15:41   Re: Hud text is now supported in csgo!
Reply With Quote #7

Quote:
Originally Posted by hlstriker View Post
Sure, it's a pretty old plugin I haven't used in many many years so why not. If you end up making a release you will want to use SourceMod's HudMsg functions and make the message buffer dynamic. Updating to the new syntax and giving admins the option to hide themselves from the list would be cool too. To optimize more just remove the prethink hook and lower the SPEC_MESSAGE_DELAY time. If you lower SPEC_MESSAGE_DELAY keep in mind it'll send messages over the network more often.

PHP Code:
#include <sourcemod>
#include <sdkhooks>

#pragma semicolon 1

new const String:PLUGIN_VERSION[] = "1.0";

public 
Plugin:myinfo 
{
    
name "Show Spectators",
    
author "hlstriker",
    
description "Shows who is spectating a specific player.",
    
version PLUGIN_VERSION,
    
url "www.swoobles.com"
}

const 
OBS_MODE_IN_EYE    4;
const 
OBS_MODE_CHASE    5;

const 
Float:SPEC_MESSAGE_DELAY 1.2;
new 
Float:g_fNextSpecMessage[MAXPLAYERS+1];
new 
g_iSpectating[MAXPLAYERS+1];

new 
UserMsg:g_msgHudMsg;


public 
OnPluginStart()
{
    
CreateConVar("hls_showspec_version"PLUGIN_VERSION"Show Spectators Version"FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_NOTIFY|FCVAR_PRINTABLEONLY);
    
    
g_msgHudMsg GetUserMessageId("HudMsg");
    
    for(new 
iClient=1iClient<=MaxClientsiClient++)
    {
        if(
IsClientInGame(iClient))
            
SDKHook(iClientSDKHook_PreThinkhook_PreThink);
    }
    
    
CreateTimer(SPEC_MESSAGE_DELAYTimerSpecMessage_TIMER_REPEAT);
}

public 
Action:TimerSpecMessage(Handle:hTimer)
{
    new 
Float:fCurTime GetEngineTime();
    for(new 
iClient=1iClient<=MaxClientsiClient++)
    {
        if(!
IsClientInGame(iClient) || IsPlayerAlive(iClient))
            continue;
        
        if(
g_fNextSpecMessage[iClient] > fCurTime)
            continue;
        
        
BuildSpecMessage(iClient);
    }
}

public 
OnClientPutInServer(iClient)
{
    
SDKHook(iClientSDKHook_PreThinkhook_PreThink);
}

public 
hook_PreThink(iClient)
{
    if(
IsPlayerAlive(iClient))
        return;
    
    if(!
UpdateSpectatingTarget(iClient))
        return;
    
    
BuildSpecMessage(iClient);
}

UpdateSpectatingTarget(iClient)
{
    
// Return true if the client is spectating a different player.
    
    
switch(GetEntProp(iClientProp_Send"m_iObserverMode"))
    {
        case 
OBS_MODE_IN_EYEOBS_MODE_CHASE:
        {
            new 
iSpectating GetEntPropEnt(iClientProp_Send"m_hObserverTarget");
            if(
iSpectating != g_iSpectating[iClient])
            {
                
g_iSpectating[iClient] = iSpectating;
                return 
true;
            }
        }
        default:
        {
            if(
g_iSpectating[iClient])
            {
                
// This client was spectating someone, but isn't anymore so clear their message.
                
g_iSpectating[iClient] = 0;
                
ShowSpecMessage(iClient" ");
            }
        }
    }
    
    return 
false;
}

BuildSpecMessage(iClient)
{
    
g_fNextSpecMessage[iClient] = GetEngineTime() + SPEC_MESSAGE_DELAY 0.2;
    
    if(
g_iSpectating[iClient] <= || !IsClientInGame(g_iSpectating[iClient]))
        return;
    
    static 
String:szBuffer[254], iBufLenString:szName[32];
    
iBufLen 0;
    
GetClientName(g_iSpectating[iClient], szNamesizeof(szName));
    
    
iBufLen += FormatEx(szBuffer[iBufLen], sizeof(szBuffer)-iBufLen"\nSpectating %s:\n"szName);
    
    for(new 
iSpectator=1iSpectator<=MaxClientsiSpectator++)
    {
        if(!
IsClientInGame(iSpectator) || IsPlayerAlive(iSpectator))
            continue;
        
        if(
g_iSpectating[iSpectator] != g_iSpectating[iClient])
            continue;
        
        
GetClientName(iSpectatorszNamesizeof(szName));
        
iBufLen += FormatEx(szBuffer[iBufLen], sizeof(szBuffer)-iBufLen"%s\n"szName);
    }
    
    
ShowSpecMessage(iClientszBuffer);
}

ShowSpecMessage(iClient, const String:szMessage[])
{
    
HudMsg(iClient1Float:{0.8, -1.0}, {25500255}, {02550255}, 00.10.1SPEC_MESSAGE_DELAY 0.10.0szMessage);
}

HudMsg(iClientiChannel, const Float:fPosition[2], const iColor1[4], const iColor2[4], iEffectFloat:fFadeInTimeFloat:fFadeOutTimeFloat:fHoldTimeFloat:fEffectTime, const String:szText[], any:...)
{
    if(
GetUserMessageType() != UM_Protobuf)
        return 
false;
    
    
decl String:szBuffer[256];
    
VFormat(szBuffersizeof(szBuffer), szText12);
    
    
decl iClients[1];
    
iClients[0] = iClient;
    
    new 
Handle:hMessage StartMessageEx(g_msgHudMsgiClients1);
    
PbSetInt(hMessage"channel"iChannel);
    
PbSetVector2D(hMessage"pos"fPosition);
    
PbSetColor(hMessage"clr1"iColor1);
    
PbSetColor(hMessage"clr2"iColor2);
    
PbSetInt(hMessage"effect"iEffect);
    
PbSetFloat(hMessage"fade_in_time"fFadeInTime);
    
PbSetFloat(hMessage"fade_out_time"fFadeOutTime);
    
PbSetFloat(hMessage"hold_time"fHoldTime);
    
PbSetFloat(hMessage"fx_time"fEffectTime);
    
PbSetString(hMessage"text"szBuffer);
    
EndMessage();
    
    return 
true;


The plugin works, but there was a small problem, the author prompt please how to adjust the position of the HUD?

__________________
Dreizehnt is offline
sdz
Senior Member
Join Date: Feb 2012
Old 03-19-2017 , 18:35   Re: Hud text is now supported in csgo!
Reply With Quote #8

Quote:
Originally Posted by EasSidezz View Post
ooo bby it works
Spoiler

Last edited by sdz; 11-22-2018 at 02:22.
sdz is offline
lay295
Senior Member
Join Date: Sep 2013
Old 03-19-2017 , 19:14   Re: Hud text is now supported in csgo!
Reply With Quote #9

Great, re-implemented msay with this, no more messages blocking weapon switch
__________________

lay295 is offline
Bulletford
Junior Member
Join Date: Apr 2015
Old 03-19-2017 , 19:40   Re: Hud text is now supported in csgo!
Reply With Quote #10

Heres what I used it for:


Last edited by Bulletford; 03-19-2017 at 19:41.
Bulletford is offline
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 04:15.


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