mirror of
https://github.com/alliedmodders/hl2sdk.git
synced 2025-09-19 20:16:10 +08:00
First version of the SOurce SDK 2013
This commit is contained in:
46
game/server/sdk/sdk_env_message.cpp
Normal file
46
game/server/sdk/sdk_env_message.cpp
Normal file
@ -0,0 +1,46 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Simple entity to transmit message to the client
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
|
||||
class CGameMessageEntity : public CLogicalEntity
|
||||
{
|
||||
public:
|
||||
DECLARE_CLASS( CGameMessageEntity, CLogicalEntity );
|
||||
DECLARE_DATADESC();
|
||||
|
||||
CGameMessageEntity( void ) {};
|
||||
|
||||
void InputDisplayMessage( inputdata_t &data );
|
||||
|
||||
string_t m_strText;
|
||||
};
|
||||
|
||||
LINK_ENTITY_TO_CLASS( logic_game_message, CGameMessageEntity );
|
||||
|
||||
BEGIN_DATADESC( CGameMessageEntity )
|
||||
|
||||
DEFINE_KEYFIELD( m_strText, FIELD_STRING, "text" ),
|
||||
|
||||
DEFINE_INPUTFUNC( FIELD_VOID, "DisplayMessage", InputDisplayMessage ),
|
||||
|
||||
END_DATADESC()
|
||||
|
||||
void CGameMessageEntity::InputDisplayMessage( inputdata_t &data )
|
||||
{
|
||||
// Only send this message the local player
|
||||
CSingleUserRecipientFilter user( UTIL_PlayerByIndex(1) );
|
||||
user.MakeReliable();
|
||||
|
||||
// Start the message block
|
||||
UserMessageBegin( user, "GameMessage" );
|
||||
|
||||
// Send our text to the client
|
||||
WRITE_STRING( STRING( m_strText ) );
|
||||
|
||||
// End the message block
|
||||
MessageEnd();
|
||||
}
|
Reference in New Issue
Block a user