MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / ConSayClient

Function ConSayClient

src/console_cmds.cpp:2020–2044  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2018}
2019
2020static bool ConSayClient(std::span<std::string_view> argv)
2021{
2022 if (argv.empty()) {
2023 IConsolePrint(CC_HELP, "Chat to a certain client in a multiplayer game. Usage: 'say_client <client-id> \"<msg>\"'.");
2024 IConsolePrint(CC_HELP, "For client-id's, see the command 'clients'.");
2025 return true;
2026 }
2027
2028 if (argv.size() != 3) return false;
2029
2030 auto client_id = ParseType<ClientID>(argv[1]);
2031 if (!client_id.has_value()) {
2032 IConsolePrint(CC_ERROR, "The given client-id is not a valid number.");
2033 return true;
2034 }
2035
2036 if (!_network_server) {
2037 NetworkClientSendChat(NETWORK_ACTION_CHAT_CLIENT, DESTTYPE_CLIENT, *client_id, argv[2]);
2038 } else {
2039 bool from_admin = (_redirect_console_to_admin < AdminID::Invalid());
2040 NetworkServerSendChat(NETWORK_ACTION_CHAT_CLIENT, DESTTYPE_CLIENT, *client_id, argv[2], CLIENT_ID_SERVER, from_admin);
2041 }
2042
2043 return true;
2044}
2045
2046/** All the known authorized keys with their name. */
2047static const std::initializer_list<std::pair<std::string_view, NetworkAuthorizedKeys *>> _console_cmd_authorized_keys{

Callers

nothing calls this directly

Calls 6

NetworkClientSendChatFunction · 0.85
InvalidFunction · 0.85
NetworkServerSendChatFunction · 0.85
IConsolePrintFunction · 0.70
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected