diff --git a/resources/scripts/Global.lua b/resources/scripts/Global.lua index 1d85d15..c22cb70 100644 --- a/resources/scripts/Global.lua +++ b/resources/scripts/Global.lua @@ -314,3 +314,4 @@ registerCommand("wireframe", "commands/debug/ToggleWireframe.lua") registerCommand("invis", "commands/debug/ToggleInvisibility.lua") registerCommand("unlockaetheryte", "commands/debug/UnlockAetheryte.lua") registerCommand("teri", "commands/debug/ChangeTerritory.lua") +registerCommand("ost", "commands/debug/OnScreenTest.lua") diff --git a/resources/scripts/commands/debug/OnScreenTest.lua b/resources/scripts/commands/debug/OnScreenTest.lua new file mode 100644 index 0000000..9836a10 --- /dev/null +++ b/resources/scripts/commands/debug/OnScreenTest.lua @@ -0,0 +1,10 @@ +required_rank = GM_RANK_DEBUG + +CHAT_LOG = 1 +ON_SCREEN = 4 + +function onCommand(args, player) + player:send_message("this is a test of on-screen only", ON_SCREEN) + --player:send_message("this is an on-screen + chat log test", ON_SCREEN + CHAT_LOG) + player:send_message("this is a test of the chat log only, which omits a param") +end diff --git a/src/ipc/zone/mod.rs b/src/ipc/zone/mod.rs index 29a1565..ec389cd 100644 --- a/src/ipc/zone/mod.rs +++ b/src/ipc/zone/mod.rs @@ -186,7 +186,20 @@ pub enum ServerZoneIpcData { Warp(Warp), /// Sent by the server when they send a chat message ServerChatMessage { - unk: u8, // channel? + /* + * bits (properties will apply when set, but a final base 10 value of zero defaults to chat log only): + * 76543210 + * xxxxxSxC + * x = don't care/unused + * S = on-screen + * C = chat log + * all other bits are unused, therefore some possible examples are (base 10 values follow): + * 1 = chat log only + * 4 = on-screen only + * 5 = both + * ref: https://github.com/SapphireServer/Sapphire/blob/bf3368224a00c180cbb7ba413b52395eba58ec0b/src/common/Network/PacketDef/Zone/ServerZoneDef.h#L250 + */ + param: u8, #[brw(pad_after = 774)] #[br(count = 774)] #[br(map = read_string)] @@ -447,7 +460,7 @@ mod tests { ( ServerZoneIpcType::ServerChatMessage, ServerZoneIpcData::ServerChatMessage { - unk: 0, + param: 0, message: String::new(), }, ), diff --git a/src/world/connection.rs b/src/world/connection.rs index a352d4f..2b982d7 100644 --- a/src/world/connection.rs +++ b/src/world/connection.rs @@ -610,7 +610,7 @@ impl ZoneConnection { timestamp: timestamp_secs(), data: ServerZoneIpcData::ServerChatMessage { message: message.to_string(), - unk: 0, + param: 0, }, ..Default::default() }; diff --git a/src/world/lua.rs b/src/world/lua.rs index 910427e..dce8896 100644 --- a/src/world/lua.rs +++ b/src/world/lua.rs @@ -73,11 +73,11 @@ impl LuaPlayer { ); } - fn send_message(&mut self, message: &str) { + fn send_message(&mut self, message: &str, param: u8) { let op_code = ServerZoneIpcType::ServerChatMessage; let data = ServerZoneIpcData::ServerChatMessage { message: message.to_string(), - unk: 0, + param, }; self.create_segment_self(op_code, data); @@ -225,8 +225,9 @@ impl LuaPlayer { impl UserData for LuaPlayer { fn add_methods>(methods: &mut M) { - methods.add_method_mut("send_message", |_, this, message: String| { - this.send_message(&message); + methods.add_method_mut("send_message", |lua, this, (message, param): (String, Value)| { + let param: u8 = lua.from_value(param).unwrap_or(0); + this.send_message(&message, param); Ok(()) }); methods.add_method_mut(