diff --git a/client.d.ts b/client.d.ts index 2834978..8a67919 100644 --- a/client.d.ts +++ b/client.d.ts @@ -243,6 +243,8 @@ export declare namespace matchmaking { setJoinable(joinable: boolean): boolean getData(key: string): string | null setData(key: string, value: string): boolean + getMemberData(steamId64: bigint, key: string): string | null + setMemberData(key: string, value: string): void deleteData(key: string): boolean /** Get an object containing all the lobby data */ getFullData(): Record diff --git a/src/api/matchmaking.rs b/src/api/matchmaking.rs index 441c9e6..485866e 100644 --- a/src/api/matchmaking.rs +++ b/src/api/matchmaking.rs @@ -5,7 +5,7 @@ pub mod matchmaking { use crate::api::localplayer::PlayerSteamId; use napi::bindgen_prelude::{BigInt, Error}; use std::collections::HashMap; - use steamworks::LobbyId; + use steamworks::{LobbyId, SteamId}; use tokio::sync::oneshot; #[napi] @@ -95,6 +95,27 @@ pub mod matchmaking { .set_lobby_data(self.lobby_id, &key, &value) } + #[napi] + pub fn get_member_data(&self, steam_id64: BigInt, key: String) -> Option { + let client = crate::client::get_client(); + client + .matchmaking() + .get_lobby_member_data( + self.lobby_id, + SteamId::from_raw(steam_id64.get_u64().1), + &key, + ) + .map(|s| s.to_string()) + } + + #[napi] + pub fn set_member_data(&self, key: String, value: String) { + let client = crate::client::get_client(); + client + .matchmaking() + .set_lobby_member_data(self.lobby_id, &key, &value) + } + #[napi] pub fn delete_data(&self, key: String) -> bool { let client = crate::client::get_client();