diff --git a/examples/csgo.rs b/examples/csgo.rs new file mode 100644 index 0000000..0b20adb --- /dev/null +++ b/examples/csgo.rs @@ -0,0 +1,10 @@ + +use gamedig::CSGO; + +fn main() { + let response = CSGO::query("51.38.142.109", None); + match response { + Err(error) => println!("Couldn't query, error: {error}"), + Ok(r) => println!("{:?}", r) + } +} diff --git a/src/games/csgo.rs b/src/games/csgo.rs new file mode 100644 index 0000000..b99fdb6 --- /dev/null +++ b/src/games/csgo.rs @@ -0,0 +1,16 @@ +use crate::errors::GDError; +use crate::valve::{ValveProtocol, App, GatheringSettings, Response}; + +pub struct CSGO; + +impl CSGO { + pub fn query(address: &str, port: Option) -> Result { + ValveProtocol::query(App::CSGO, address, match port { + None => 27015, + Some(port) => port + }, GatheringSettings { + players: true, + rules: true + }) + } +} diff --git a/src/games/mod.rs b/src/games/mod.rs index 02ecf0d..e6cb505 100644 --- a/src/games/mod.rs +++ b/src/games/mod.rs @@ -1,6 +1,8 @@ pub mod tf2; pub mod the_ship; +pub mod csgo; pub use tf2::*; pub use the_ship::*; +pub use csgo::*;