Пример #1
0
//---------------------------------------------------------------------------------
// Purpose: Say string to single player in center of screen
//---------------------------------------------------------------------------------
void CSayToPlayer
(
player_t *player_ptr,
const char	*fmt, 
...
)
{
	va_list		argptr;
	char		tempString[1024];

	va_start ( argptr, fmt );
	vsnprintf( tempString, sizeof(tempString), fmt, argptr );
	va_end   ( argptr );

	MRecipientFilter mrf;
	mrf.MakeReliable();
	mrf.AddPlayer(player_ptr->index);

#if defined ( GAME_CSGO )
	CCSUsrMsg_TextMsg *msg = (CCSUsrMsg_TextMsg *)g_Cstrike15UsermessageHelpers.GetPrototype(CS_UM_TextMsg)->New(); // Show TextMsg type user message
	msg->set_msg_dst(4); // Center area
	// Client tries to read all 5 'params' and will crash if less
	msg->add_params(tempString);
	msg->add_params("");
	msg->add_params("");
	msg->add_params("");
	msg->add_params("");
	engine->SendUserMessage(mrf, CS_UM_TextMsg, *msg);
	delete msg;
#else
	msg_buffer = engine->UserMessageBegin( &mrf, text_message_index ); // Show TextMsg type user message

	msg_buffer->WriteByte(4); // Center area
	msg_buffer->WriteString(tempString);
	engine->MessageEnd();
#endif	
}
Пример #2
0
bool CHalfLife2::TextMsg(int client, int dest, const char *msg)
{
#ifndef USE_PROTOBUF_USERMESSAGES
	bf_write *pBitBuf = NULL;
#endif
	cell_t players[] = {client};

	if (dest == HUD_PRINTTALK)
	{
		const char *chat_saytext = g_pGameConf->GetKeyValue("ChatSayText");

		/* Use SayText user message instead */
		if (chat_saytext != NULL && strcmp(chat_saytext, "yes") == 0)
		{
			char buffer[253];
			ke::SafeSprintf(buffer, sizeof(buffer), "%s\1\n", msg);

#if SOURCE_ENGINE == SE_CSGO
			CCSUsrMsg_SayText *pMsg;
			if ((pMsg = (CCSUsrMsg_SayText *)g_UserMsgs.StartProtobufMessage(m_SayTextMsg, players, 1, USERMSG_RELIABLE)) == NULL)
			{
				return false;
			}

			pMsg->set_ent_idx(0);
			pMsg->set_text(buffer);
			pMsg->set_chat(false);
#else
			if ((pBitBuf = g_UserMsgs.StartBitBufMessage(m_SayTextMsg, players, 1, USERMSG_RELIABLE)) == NULL)
			{
				return false;
			}

			pBitBuf->WriteByte(0);
			pBitBuf->WriteString(buffer);
			pBitBuf->WriteByte(1);
#endif

			g_UserMsgs.EndMessage();

			return true;
		}
	}

#if SOURCE_ENGINE == SE_CSGO
	CCSUsrMsg_TextMsg *pMsg;
	if ((pMsg = (CCSUsrMsg_TextMsg *)g_UserMsgs.StartProtobufMessage(m_MsgTextMsg, players, 1, USERMSG_RELIABLE)) == NULL)
	{
		return false;
	}

	// Client tries to read all 5 'params' and will crash if less
	pMsg->set_msg_dst(dest);
	pMsg->add_params(msg);
	pMsg->add_params("");
	pMsg->add_params("");
	pMsg->add_params("");
	pMsg->add_params("");
#else
	if ((pBitBuf = g_UserMsgs.StartBitBufMessage(m_MsgTextMsg, players, 1, USERMSG_RELIABLE)) == NULL)
	{
		return false;
	}

	pBitBuf->WriteByte(dest);
	pBitBuf->WriteString(msg);
#endif

	g_UserMsgs.EndMessage();

	return true;
}
Пример #3
0
//---------------------------------------------------------------------------------
// Purpose: Write Text to chat area
//---------------------------------------------------------------------------------
void UTIL_SayText(int colour, MRecipientFilter *mrf, const char *say_text)
{
#if defined ( GAME_CSGO )
	CCSUsrMsg_TextMsg *msg = (CCSUsrMsg_TextMsg *)g_Cstrike15UsermessageHelpers.GetPrototype(CS_UM_TextMsg)->New(); // Show TextMsg type user message
	msg->set_msg_dst(3); // Say area
#else
	msg_buffer = engine->UserMessageBegin(mrf, text_message_index ); // Show TextMsg type user message


	msg_buffer->WriteByte(3); // Say area

	if ((gpManiGameType->IsGameType(MANI_GAME_CSS)))
	{
		switch (colour)
		{
			case ORANGE_CHAT:break;
			case GREY_CHAT: msg_buffer->WriteByte(-1); break;
			case LIGHT_GREEN_CHAT: msg_buffer->WriteByte(3);break; // Light Green
			case GREEN_CHAT: msg_buffer->WriteByte(4);break; // Darker Green
			default :break;
		}
	}
#endif
	/*
	\x01 = White
\x02 = Dark Red
\x03 = White
\x04 = Dark Green
\x05 = Moss Green
\x06 = Lime Green
\x07/8/9 = Light Red
*/
	if ((gpManiGameType->IsGameType(MANI_GAME_CSGO)))
	{
		//switch (colour)
		//{
		//	case WHITE_TEXT: break;
		//	case WHITE2_TEXT:break;
		//	case RED_TEXT: msg_buffer->WriteByte(2); break;
		//	case DARK_GREEN_TEXT: msg_buffer->WriteByte(4);break; // Light Green
		//	case MOSS_GREEN_TEXT: msg_buffer->WriteByte(5);break; // Light Green
		//	case LIME_GREEN_TEXT: msg_buffer->WriteByte(6);break; // Light Green
		//	case LIGHT_RED_TEXT: msg_buffer->WriteByte(7);break; // Darker Green
		//	default :break;
		//}
	}

#if defined ( GAME_CSGO )
	// Client tries to read all 5 'params' and will crash if less
	msg->add_params(say_text);
	msg->add_params("");
	msg->add_params("");
	msg->add_params("");
	msg->add_params("");
	engine->SendUserMessage(*mrf, CS_UM_TextMsg, *msg);
	delete msg;
#else
	msg_buffer->WriteString(say_text);
	engine->MessageEnd();
#endif	
}
Пример #4
0
//---------------------------------------------------------------------------------
// Purpose: Say admin string to all
//---------------------------------------------------------------------------------
void AdminCSayToAll
(
player_t	*player,
int			anonymous,
const char	*fmt, 
...
)
{
	va_list		argptr;
	char		tempString[1024];
	char	admin_final_string[2048];
	char	non_admin_final_string[2048];
	bool	found_player = false;
	bool	found_admin = false;

	va_start ( argptr, fmt );
	vsnprintf( tempString, sizeof(tempString), fmt, argptr );
	va_end   ( argptr );

	player_t	server_player;

	if (!player)
	{
		snprintf(admin_final_string, sizeof (admin_final_string), "(CONSOLE) : %s", tempString);
		snprintf(non_admin_final_string, sizeof (non_admin_final_string), "(CONSOLE) %s", tempString);
	}
	else
	{
		snprintf(admin_final_string, sizeof (admin_final_string), "(ADMIN) %s: %s", player->name, tempString);
		snprintf(non_admin_final_string, sizeof (non_admin_final_string), "(ADMIN) %s", tempString);
	}

	OutputToConsole(NULL, "%s\n", admin_final_string);

	if (anonymous == 1)
	{
		MRecipientFilter mrfadmin;
		MRecipientFilter mrf;
		mrf.MakeReliable();
		mrfadmin.MakeReliable();

		for (int i = 1; i <= max_players; i++)
		{
			bool is_admin;

			is_admin = false;
			server_player.index = i;
			if (!FindPlayerByIndex(&server_player))
			{
				continue;
			}

			if (server_player.is_bot)
			{
				continue;
			}

			is_admin = gpManiClient->HasAccess(server_player.index, ADMIN, ADMIN_BASIC_ADMIN);
			if (is_admin)
			{
				found_admin = true;
				mrfadmin.AddPlayer(i);
				if (!(gpManiGameType->IsGameType(MANI_GAME_CSS) ||
					  gpManiGameType->IsGameType(MANI_GAME_CSGO)))
				{
					OutputToConsole(&server_player, "%s\n", admin_final_string);
				}
			}
			else
			{
				found_player = true;
				mrf.AddPlayer(i);
				if (!(gpManiGameType->IsGameType(MANI_GAME_CSS) ||
					gpManiGameType->IsGameType(MANI_GAME_CSGO)))
				{
					OutputToConsole(&server_player, "%s\n", non_admin_final_string);
				}
			}
		}

		if (found_player)
		{
#if defined ( GAME_CSGO )
			CCSUsrMsg_TextMsg *msg = (CCSUsrMsg_TextMsg *)g_Cstrike15UsermessageHelpers.GetPrototype(CS_UM_TextMsg)->New(); // Show TextMsg type user message
			msg->set_msg_dst(4); // Center area
			// Client tries to read all 5 'params' and will crash if less
			msg->add_params(non_admin_final_string);
			msg->add_params("");
			msg->add_params("");
			msg->add_params("");
			msg->add_params("");
			engine->SendUserMessage(mrf, CS_UM_TextMsg, *msg);
			delete msg;
#else
			msg_buffer = engine->UserMessageBegin( &mrf, text_message_index ); // Show TextMsg type user message

			msg_buffer->WriteByte(4); // Center area
			msg_buffer->WriteString(non_admin_final_string);
			engine->MessageEnd();
#endif			
		}

		if (found_admin)
		{
#if defined ( GAME_CSGO )
			CCSUsrMsg_TextMsg *msg = (CCSUsrMsg_TextMsg *)g_Cstrike15UsermessageHelpers.GetPrototype(CS_UM_TextMsg)->New(); // Show TextMsg type user message
			msg->set_msg_dst(4); // Center area
			// Client tries to read all 5 'params' and will crash if less
			msg->add_params(admin_final_string);
			msg->add_params("");
			msg->add_params("");
			msg->add_params("");
			msg->add_params("");
			engine->SendUserMessage(mrfadmin, CS_UM_TextMsg, *msg);
			delete msg;
#else
			msg_buffer = engine->UserMessageBegin( &mrfadmin, text_message_index ); // Show TextMsg type user message

			msg_buffer->WriteByte(4); // Center area
			msg_buffer->WriteString(admin_final_string);
			engine->MessageEnd();
#endif			
		}
	}
	else
	{
		for (int i = 1; i <= max_players; i++)
		{
			server_player.index = i;
			if (!FindPlayerByIndex(&server_player))
			{
				continue;
			}

			if (server_player.is_bot)
			{
				continue;
			}

			found_player = true;
			if (!(gpManiGameType->IsGameType(MANI_GAME_CSS) ||
				gpManiGameType->IsGameType(MANI_GAME_CSGO)))
			{
				OutputToConsole(&server_player, "%s\n", admin_final_string);
			}
		}

		if (found_player)
		{
			MRecipientFilter mrf;
			mrf.MakeReliable();
			mrf.AddAllPlayers(max_players);

#if defined ( GAME_CSGO )
			CCSUsrMsg_TextMsg *msg = (CCSUsrMsg_TextMsg *)g_Cstrike15UsermessageHelpers.GetPrototype(CS_UM_TextMsg)->New(); // Show TextMsg type user message
			msg->set_msg_dst(4); // Center area
			// Client tries to read all 5 'params' and will crash if less
			msg->add_params(admin_final_string);
			msg->add_params("");
			msg->add_params("");
			msg->add_params("");
			msg->add_params("");
			engine->SendUserMessage(mrf, CS_UM_TextMsg, *msg);
			delete msg;
#else
			msg_buffer = engine->UserMessageBegin( &mrf, text_message_index ); // Show TextMsg type user message

			msg_buffer->WriteByte(4); // Center area
			msg_buffer->WriteString(admin_final_string);
			engine->MessageEnd();
#endif			
		}
	}
}
Пример #5
0
//---------------------------------------------------------------------------------
// Purpose: Show hud message for kill
//---------------------------------------------------------------------------------
static	
void ShowQuakeSound (player_t *attacker, player_t *victim, int mode, char *fmt, ...)
{
	va_list		argptr;
	char		temp_string[256];
	

	va_start ( argptr, fmt );
	vsnprintf( temp_string, sizeof(temp_string), fmt, argptr );
	va_end   ( argptr );

	MRecipientFilter mrf;

	if (mode == 1)
	{
		mrf.RemoveAllRecipients();
		mrf.MakeReliable();

		// All players must see
		for (int i = 1; i <= max_players; i++)
		{

			player_settings_t	*player_settings;
			player_t			sound_player;

			sound_player.index = i;
			if (!FindPlayerByIndex(&sound_player)) continue;
			if (sound_player.is_bot) continue;
			
			player_settings = FindPlayerSettings(&sound_player);
			if (player_settings && player_settings->quake_sounds) 
			{
				mrf.AddPlayer(sound_player.index);
			}
		}
	}
	else if (mode == 2)
	{
		player_settings_t	*player_settings;

		player_settings = FindPlayerSettings(attacker);
		if (player_settings && player_settings->quake_sounds)
		{
			mrf.AddPlayer(attacker->index);
		}

		player_settings = FindPlayerSettings(victim);
		if (player_settings && player_settings->quake_sounds)
		{
			mrf.AddPlayer(victim->index);
		}
	}
	else if (mode == 3)
	{
		player_settings_t	*player_settings;
		player_settings = FindPlayerSettings(attacker);
		if (player_settings && player_settings->quake_sounds)
		{
			// Attacker sees it.
			mrf.AddPlayer(attacker->index);
		}
	}
	else if (mode == 4)
	{
		player_settings_t	*player_settings;
		player_settings = FindPlayerSettings(victim);
		if (player_settings && player_settings->quake_sounds)
		{
			// Victim sees it.
			mrf.AddPlayer(victim->index);
		}
	}

#if defined ( GAME_CSGO )
	CCSUsrMsg_TextMsg *msg = (CCSUsrMsg_TextMsg *)g_Cstrike15UsermessageHelpers.GetPrototype(CS_UM_TextMsg)->New(); // Show TextMsg type user message
	msg->set_msg_dst(4); // Center area
	// Client tries to read all 5 'params' and will crash if less
	msg->add_params(temp_string);
	msg->add_params("");
	msg->add_params("");
	msg->add_params("");
	msg->add_params("");
	engine->SendUserMessage(mrf, CS_UM_TextMsg, *msg);
	delete msg;
#else
	msg_buffer = engine->UserMessageBegin( &mrf, text_message_index ); // Show TextMsg type user message

	msg_buffer->WriteByte(4); // Center area
	msg_buffer->WriteString(temp_string);
	engine->MessageEnd();
#endif	
}