コード例 #1
0
bool CHalfLife2::HintTextMsg(cell_t *players, int count, const char *msg)
{
#if SOURCE_ENGINE == SE_CSGO
	CCSUsrMsg_HintText *pMsg;
	if ((pMsg = (CCSUsrMsg_HintText *)g_UserMsgs.StartProtobufMessage(m_HinTextMsg, players, count, USERMSG_RELIABLE)) == NULL)
	{
		return false;
	}

	pMsg->set_text(msg);
#else
	bf_write *pBitBuf = NULL;

	if ((pBitBuf = g_UserMsgs.StartBitBufMessage(m_HinTextMsg, players, count, USERMSG_RELIABLE)) == NULL)
	{
		return false;
	}

	const char *pre_byte = g_pGameConf->GetKeyValue("HintTextPreByte");
	if (pre_byte != NULL && strcmp(pre_byte, "yes") == 0)
	{
		pBitBuf->WriteByte(1);
	}
	pBitBuf->WriteString(msg);
#endif

	g_UserMsgs.EndMessage();

	return true;
}
コード例 #2
0
//---------------------------------------------------------------------------------
// Purpose: Use Hint type message to ouput text
//---------------------------------------------------------------------------------
void UTIL_SayHint(MRecipientFilter *mrf_ptr, char *text_ptr)
{
	char text_out[192];

	// Copy to restricted size
	snprintf(text_out, sizeof(text_out), "%s", text_ptr);
#if defined ( GAME_CSGO )
	CCSUsrMsg_HintText *msg = (CCSUsrMsg_HintText *)g_Cstrike15UsermessageHelpers.GetPrototype(CS_UM_HintText)->New();
	msg->set_text(text_out);
	engine->SendUserMessage(*static_cast<IRecipientFilter *>(mrf_ptr), CS_UM_HintText, *msg);
	delete msg;
#else
	msg_buffer = engine->UserMessageBegin(static_cast<IRecipientFilter *>(mrf_ptr), hintMsg_message_index);
	msg_buffer->WriteByte(1);

	msg_buffer->WriteString(text_out);
	engine->MessageEnd();
#endif	
}