mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2025-01-07 08:01:16 +00:00
Added discord IDs to /players chat command
This commit is contained in:
parent
11649ce1d8
commit
622c9b79b1
2 changed files with 12 additions and 3 deletions
|
@ -1,4 +1,5 @@
|
|||
#include "pc/network/network.h"
|
||||
#include "pc/network/socket/socket.h"
|
||||
#include "pc/lua/smlua_hooks.h"
|
||||
#include "pc/djui/djui_chat_message.h"
|
||||
#include "chat_commands.h"
|
||||
|
@ -88,7 +89,11 @@ bool exec_chat_command(char* command) {
|
|||
for (int i = 0; i < MAX_PLAYERS; i++) {
|
||||
struct NetworkPlayer* np = &gNetworkPlayers[i];
|
||||
if (!np->connected) { continue; }
|
||||
snprintf(line, 128, "\\#82f9ff\\%u \\#fff982\\- %s%s\n", np->globalIndex, network_get_player_text_color_string(np->localIndex), np->name);
|
||||
if (gNetworkSystem == &gNetworkSystemSocket) {
|
||||
snprintf(line, 128, "\\#82f9ff\\%u\\#fff982\\ - %s%s\n", np->globalIndex, network_get_player_text_color_string(np->localIndex), np->name);
|
||||
} else {
|
||||
snprintf(line, 128, "\\#82f9ff\\%u\\#fff982\\ - \\#82f9ff\\%s\\#fff982\\ - %s%s\n", np->globalIndex, gNetworkSystem->get_id_str(np->localIndex), network_get_player_text_color_string(np->localIndex), np->name);
|
||||
}
|
||||
strncat(message, line, 599);
|
||||
}
|
||||
djui_chat_message_create(message);
|
||||
|
|
|
@ -41,13 +41,17 @@ void discord_network_flush(void) {
|
|||
}
|
||||
|
||||
s64 ns_discord_get_id(u8 localId) {
|
||||
if (localId == 0) { return app.userId; }
|
||||
return gNetworkUserIds[localId];
|
||||
}
|
||||
|
||||
char* ns_discord_get_id_str(u8 localId) {
|
||||
if (localId == UNKNOWN_LOCAL_INDEX) { localId = 0; }
|
||||
static char id_str[22] = { 0 };
|
||||
snprintf(id_str, 22, "%lld", (long long int)gNetworkUserIds[localId]);
|
||||
if (localId == UNKNOWN_LOCAL_INDEX) {
|
||||
snprintf(id_str, 22, "???");
|
||||
} else {
|
||||
snprintf(id_str, 22, "%lld", (long long int)ns_discord_get_id(localId));
|
||||
}
|
||||
return id_str;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue