AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   [CSGO] New hint messages (https://forums.alliedmods.net/showthread.php?t=330193)

kratoss1812 01-23-2021 19:45

[CSGO] New hint messages
 
I've found a new way to display hint text to players.
Pros:
  • The font looks nicer that the usual one
  • The font is bigger by default
  • Nice animation when displayed
  • You can control the display time
  • You can change the colors


Cons:
  • It doesn't support html tags from what I've tested ( around 2 am btw so I might be wrong )
  • By default, you can't overlap hint texts. I you might need to create an event named "instructor_server_hint_stop" to stop and display another hint text. Not tested yet. I will come with updates

PHP Code:

public void OnPluginStart()
{
    
RegConsoleCmd("sm_test"Command_Test);
}

public 
Action Command_Test(int clientint args)
{
    
Event new_event CreateEvent("instructor_server_hint_create"true);
    
new_event.SetString("hint_caption""Ez New Hint by kRatoss");
    
new_event.SetInt("hint_timeout"5); // how many seconds to hold the hint text?
    
new_event.SetString("hint_color""255,0,0");// it does not support alpha, just "r,g,b" ( this format only);
    
new_event.Fire();


https://i.imgur.com/hC9MdaF.jpg

Right now it's 2 am for me and I'm tired. I just wanted to share this with you. I will update this post with a stock so it will be easier to display this kind of hint text.

If you want to contribute you can get all the data you need from here:
PHP Code:

//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose: An entity for creating instructor hints entirely with map logic
//
// $NoKeywords: $
//=============================================================================//

#include "cbase.h"
#include "baseentity.h"
#include "world.h"

#ifdef INFESTED_DLL
    #include "asw_marine.h"
    #include "asw_player.h"
#endif

// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
class CEnvInstructorHint : public CPointEntity
{
public:
    
DECLARE_CLASSCEnvInstructorHintCPointEntity );
    
DECLARE_DATADESC();

private:
    
void InputShowHintinputdata_t &inputdata );
    
void InputEndHintinputdata_t &inputdata );
    
    
string_t    m_iszReplace_Key;
    
string_t    m_iszHintTargetEntity;
    
int            m_iTimeout;
    
string_t    m_iszIcon_Onscreen;
    
string_t    m_iszIcon_Offscreen;
    
string_t    m_iszCaption;
    
string_t    m_iszActivatorCaption;
    
color32        m_Color;
    
float        m_fIconOffset;
    
float        m_fRange;
    
uint8        m_iPulseOption;
    
uint8        m_iAlphaOption;
    
uint8        m_iShakeOption;
    
bool        m_bStatic;
    
bool        m_bNoOffscreen;
    
bool        m_bForceCaption;
    
string_t    m_iszBinding;
    
string_t    m_iszGamepadBinding;
    
bool        m_bAllowNoDrawTarget;
    
bool        m_bLocalPlayerOnly;
};


LINK_ENTITY_TO_CLASSenv_instructor_hintCEnvInstructorHint );

BEGIN_DATADESCCEnvInstructorHint )

    
DEFINE_KEYFIELDm_iszReplace_KeyFIELD_STRING"hint_replace_key" ),
    
DEFINE_KEYFIELDm_iszHintTargetEntityFIELD_STRING"hint_target" ),
    
DEFINE_KEYFIELDm_iTimeoutFIELD_INTEGER"hint_timeout" ),
    
DEFINE_KEYFIELDm_iszIcon_OnscreenFIELD_STRING"hint_icon_onscreen" ),
    
DEFINE_KEYFIELDm_iszIcon_OffscreenFIELD_STRING"hint_icon_offscreen" ),
    
DEFINE_KEYFIELDm_iszCaptionFIELD_STRING"hint_caption" ),
    
DEFINE_KEYFIELDm_iszActivatorCaptionFIELD_STRING"hint_activator_caption" ),
    
DEFINE_KEYFIELDm_ColorFIELD_COLOR32"hint_color" ),
    
DEFINE_KEYFIELDm_fIconOffsetFIELD_FLOAT"hint_icon_offset" ),
    
DEFINE_KEYFIELDm_fRangeFIELD_FLOAT"hint_range" ),
    
DEFINE_KEYFIELDm_iPulseOptionFIELD_CHARACTER"hint_pulseoption" ),
    
DEFINE_KEYFIELDm_iAlphaOptionFIELD_CHARACTER"hint_alphaoption" ),
    
DEFINE_KEYFIELDm_iShakeOptionFIELD_CHARACTER"hint_shakeoption" ),
    
DEFINE_KEYFIELDm_bStaticFIELD_BOOLEAN"hint_static" ),
    
DEFINE_KEYFIELDm_bNoOffscreenFIELD_BOOLEAN"hint_nooffscreen" ),
    
DEFINE_KEYFIELDm_bForceCaptionFIELD_BOOLEAN"hint_forcecaption" ),
    
DEFINE_KEYFIELDm_iszBindingFIELD_STRING"hint_binding" ),
    
DEFINE_KEYFIELDm_iszGamepadBindingFIELD_STRING"hint_gamepad_binding" ),
    
DEFINE_KEYFIELDm_bAllowNoDrawTargetFIELD_BOOLEAN"hint_allow_nodraw_target" ),    
    
DEFINE_KEYFIELDm_bLocalPlayerOnlyFIELD_BOOLEAN"hint_local_player_only" ),
    
    
DEFINE_INPUTFUNCFIELD_STRING,    "ShowHint",    InputShowHint ),
    
DEFINE_INPUTFUNCFIELD_VOID,    "EndHint",    InputEndHint ),

END_DATADESC()


#define LOCATOR_ICON_FX_PULSE_SLOW        0x00000001
#define LOCATOR_ICON_FX_ALPHA_SLOW        0x00000008
#define LOCATOR_ICON_FX_SHAKE_NARROW    0x00000040
#define LOCATOR_ICON_FX_STATIC            0x00000100    // This icon draws at a fixed location on the HUD.

//-----------------------------------------------------------------------------
// Purpose: Input handler for showing the message and/or playing the sound.
//-----------------------------------------------------------------------------
void CEnvInstructorHint::InputShowHintinputdata_t &inputdata )
{
    static 
int s_InstructorServerHintEventCreate 0;
    
IGameEvent event gameeventmanager->CreateEvent"instructor_server_hint_create"false, &s_InstructorServerHintEventCreate );
    if ( 
event )
    {
        
CBaseEntity *pTargetEntity gEntList.FindEntityByNameNULLm_iszHintTargetEntity );
        if( 
pTargetEntity == NULL )
            
pTargetEntity inputdata.pActivator;

        if( 
pTargetEntity == NULL )
            
pTargetEntity GetWorldEntity();

        
char szColorString[128];
        
Q_snprintfszColorStringsizeofszColorString ), "%.3d,%.3d,%.3d"m_Color.rm_Color.gm_Color.);

        
int iFlags 0;
        
        
iFlags |= (m_iPulseOption == 0) ? : (LOCATOR_ICON_FX_PULSE_SLOW << (m_iPulseOption 1));
        
iFlags |= (m_iAlphaOption == 0) ? : (LOCATOR_ICON_FX_ALPHA_SLOW << (m_iAlphaOption 1));
        
iFlags |= (m_iShakeOption == 0) ? : (LOCATOR_ICON_FX_SHAKE_NARROW << (m_iShakeOption 1));
        
iFlags |= m_bStatic LOCATOR_ICON_FX_STATIC 0;

        
CBasePlayer *pActivator NULL;
        
bool bFilterByActivator m_bLocalPlayerOnly;
        if ( 
bFilterByActivator )
            
pActivator dynamic_cast<CBasePlayer*>( inputdata.pActivator );

#ifdef INFESTED_DLL
        
CASW_Marine *pMarine dynamic_cast<CASW_Marine*>( inputdata.pActivator );
        if ( 
pMarine )
        {
            
pActivator pMarine->GetCommander();
        }
#else
        
if ( inputdata.value.StringID() != NULL_STRING )
        {
            
CBaseEntity *pTarget gEntList.FindEntityByNameNULLinputdata.value.String() );
            
pActivator dynamic_cast<CBasePlayer*>( pTarget );
            if ( 
pActivator )
            {
                
bFilterByActivator true;
            }
        }
        else
        {
            if ( 
GameRules()->IsMultiplayer() == false )
            {
                
pActivator UTIL_GetLocalPlayer(); 
            }
            else
            {
                if ( !
pTargetEntity )
                {
                    
Warning"Failed to play server side instructor hint: no player specified for hint\n" );
                    
Assert);
                }
            }
        }
#endif

        
const char *pActivatorCaption m_iszActivatorCaption.ToCStr();
        if ( !
pActivatorCaption || pActivatorCaption] == '\0' )
        {
            
pActivatorCaption m_iszCaption.ToCStr();
        }

        
event->SetString"hint_name"GetEntityName().ToCStr() );
        
event->SetString"hint_replace_key"m_iszReplace_Key.ToCStr() );
        
event->SetInt"hint_target"pTargetEntity->entindex() );
        
event->SetInt"hint_activator_userid", ( pActivator pActivator->GetUserID() : ) );
        
event->SetInt"hint_timeout"m_iTimeout );
        
event->SetString"hint_icon_onscreen"m_iszIcon_Onscreen.ToCStr() );
        
event->SetString"hint_icon_offscreen"m_iszIcon_Offscreen.ToCStr() );
        
event->SetString"hint_caption"m_iszCaption.ToCStr() );
        
event->SetString"hint_activator_caption"pActivatorCaption );
        
event->SetString"hint_color"szColorString );
        
event->SetFloat"hint_icon_offset"m_fIconOffset );
        
event->SetFloat"hint_range"m_fRange );
        
event->SetInt"hint_flags"iFlags );
        
event->SetString"hint_binding"m_iszBinding.ToCStr() );
        
event->SetString"hint_gamepad_binding"m_iszGamepadBinding.ToCStr() );
        
event->SetBool"hint_allow_nodraw_target"m_bAllowNoDrawTarget );
        
event->SetBool"hint_nooffscreen"m_bNoOffscreen );
        
event->SetBool"hint_forcecaption"m_bForceCaption );
        
event->SetBool"hint_local_player_only"bFilterByActivator );

        
gameeventmanager->FireEventevent );
    }
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void CEnvInstructorHint::InputEndHintinputdata_t &inputdata )
{
    static 
int s_InstructorServerHintEventStop 0;
    
IGameEvent event gameeventmanager->CreateEvent"instructor_server_hint_stop"false, &s_InstructorServerHintEventStop );
    if ( 
event )
    {
        
event->SetString"hint_name"GetEntityName().ToCStr() );

        
gameeventmanager->FireEventevent );
    }
}

//-----------------------------------------------------------------------------
// Purpose: A generic target entity that gets replicated to the client for instructor hint targetting
//-----------------------------------------------------------------------------
class CInfoInstructorHintTarget : public CPointEntity
{
public:
    
DECLARE_CLASSCInfoInstructorHintTargetCPointEntity );

    
virtual int UpdateTransmitStatevoid )    // set transmit filter to transmit always
    
{
        return 
SetTransmitStateFL_EDICT_ALWAYS );
    }

    
DECLARE_DATADESC();
};

LINK_ENTITY_TO_CLASSinfo_target_instructor_hintCInfoInstructorHintTarget );

BEGIN_DATADESCCInfoInstructorHintTarget )

END_DATADESC() 


FroGeX 01-24-2021 01:44

Re: [CSGO] New hint messages
 
Nice !

thug90life 01-24-2021 01:50

Re: [CSGO] New hint messages
 
Niceee

zipcore 01-24-2021 04:22

Re: [CSGO] New hint messages
 
https://forums.alliedmods.net/showpo...2&postcount=30


it's known years, but thanks for the effort


All times are GMT -4. The time now is 09:50.

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