Raised This Month: $12 Target: $400
 3% 

Hud text is now supported in csgo!


Post New Thread Reply   
 
Thread Tools Display Modes
Cripix
Senior Member
Join Date: Sep 2016
Location: French, Bordeaux
Old 03-20-2017 , 10:55   Re: Hud text is now supported in csgo!
Reply With Quote #31

Update SM to -> 1.9

https://www.sourcemod.net/downloads.php?branch=dev

https://github.com/alliedmodders/sou...0a1e8c298fcc23
Cripix is offline
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 #32

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
sneaK
SourceMod Moderator
Join Date: Feb 2015
Location: USA
Old 03-20-2017 , 12:01   Re: Hud text is now supported in csgo!
Reply With Quote #33

This is also available on SM 1.8.

https://github.com/alliedmodders/sou...13da673673dee4
__________________

Last edited by sneaK; 03-20-2017 at 12:01.
sneaK is offline
Bchewy
AlliedModders Donor
Join Date: Nov 2014
Old 03-20-2017 , 13:08   Re: Hud text is now supported in csgo!
Reply With Quote #34

Sick!, this will definitely open up tons of ideas for more plugins.
__________________
Bchewy is offline
PUNKSNOTDEAF
Junior Member
Join Date: Oct 2015
Old 03-20-2017 , 13:10   Re: Hud text is now supported in csgo!
Reply With Quote #35

its a shame that we cant really adjust the size or colourize inside a line. do i miss something?
PUNKSNOTDEAF is offline
thorgot
AlliedModders Donor
Join Date: Aug 2013
Old 03-20-2017 , 16:40   Re: Hud text is now supported in csgo!
Reply With Quote #36

Quote:
Originally Posted by PUNKSNOTDEAF View Post
its a shame that we cant really adjust the size or colourize inside a line. do i miss something?
You can change the color of different lines, but not the size, which is good enough for me.

Last edited by thorgot; 03-20-2017 at 16:40.
thorgot is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 03-20-2017 , 16:58   Re: Hud text is now supported in csgo!
Reply With Quote #37

Has anyone tried basic html in the message?
__________________
Neuro Toxin is offline
Addicted.
AlliedModders Donor
Join Date: Dec 2013
Location: 0xA9D0DC
Old 03-20-2017 , 17:54   Re: Hud text is now supported in csgo!
Reply With Quote #38

Quote:
Originally Posted by Neuro Toxin View Post
Has anyone tried basic html in the message?
Doesn't look like it works
Addicted. is offline
Kinsi
Senior Member
Join Date: Apr 2013
Old 03-20-2017 , 18:15   Re: Hud text is now supported in csgo!
Reply With Quote #39

Obligatory thanks to Alex Bel!

https://github.com/ValveSoftware/csg...ssue-146618900
Kinsi is offline
Kriax
Senior Member
Join Date: Apr 2012
Old 03-20-2017 , 19:08   Re: Hud text is now supported in csgo!
Reply With Quote #40

Quote:
Originally Posted by oaaron99 View Post
Doesn't look like it works
Yeap

Kriax is offline
Reply


Thread Tools
Display Modes

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:28.


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