diff options
author | Tom Barham <me@cpdt.dev> | 2022-02-22 08:33:50 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-21 19:33:50 -0300 |
commit | ea9a2ed9b9698d891769fa8598b8262aad97ed77 (patch) | |
tree | 2bcac5590c8c12114b6a54febd7920506bbe66c4 /Northstar.CustomServers/mod/scripts/vscripts/_chat.gnut | |
parent | 1fad39a0d753fa905520ee858f3aa4e8a3ad96a5 (diff) | |
download | NorthstarMods-ea9a2ed9b9698d891769fa8598b8262aad97ed77.tar.gz NorthstarMods-ea9a2ed9b9698d891769fa8598b8262aad97ed77.zip |
Advanced chat: custom messages and client hooks (#217)
Co-authored-by: EmmaM <27428383+emma-miler@users.noreply.github.com>
Diffstat (limited to 'Northstar.CustomServers/mod/scripts/vscripts/_chat.gnut')
-rw-r--r-- | Northstar.CustomServers/mod/scripts/vscripts/_chat.gnut | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/Northstar.CustomServers/mod/scripts/vscripts/_chat.gnut b/Northstar.CustomServers/mod/scripts/vscripts/_chat.gnut new file mode 100644 index 00000000..97ed959c --- /dev/null +++ b/Northstar.CustomServers/mod/scripts/vscripts/_chat.gnut @@ -0,0 +1,51 @@ +untyped +globalize_all_functions + +enum eChatMessageType +{ + CHAT = 1, + WHISPER = 2 +} + +// Displays a chat message as if the player sent it. +void function Chat_Impersonate(entity player, string text, bool isTeamChat) { + NSSendMessage(player.GetPlayerIndex(), text, isTeamChat) +} + +// Sends a whisper message from one player that is only shown to another. Will be shown as a whisper if whisper is set. +void function Chat_PrivateMessage(entity fromPlayer, entity toPlayer, string text, bool whisper) { + NSBroadcastMessage( + fromPlayer.GetPlayerIndex(), + toPlayer.GetPlayerIndex(), + text, + false, + false, + whisper ? eChatMessageType.WHISPER : eChatMessageType.CHAT + ) +} + +// Broadcasts a message from the server to all players. +void function Chat_ServerBroadcast(string text) +{ + NSBroadcastMessage( + -1, + -1, + text, + false, + false, + eChatMessageType.CHAT + ) +} + +// Sends a message from the server to one player. Will be shown as a whisper if whisper is set. +void function Chat_ServerPrivateMessage(entity toPlayer, string text, bool whisper) +{ + NSBroadcastMessage( + -1, + toPlayer.GetPlayerIndex(), + text, + false, + false, + whisper ? eChatMessageType.WHISPER : eChatMessageType.CHAT + ) +} |