From 8a93d2fb7dafd9f5fa0009b71d9f466454b34f75 Mon Sep 17 00:00:00 2001 From: cosminperram Date: Thu, 20 Oct 2022 11:24:45 +0300 Subject: [PATCH] Initial CSGO support --- examples/csgo.rs | 10 ++++++++++ src/games/csgo.rs | 16 ++++++++++++++++ src/games/mod.rs | 2 ++ 3 files changed, 28 insertions(+) create mode 100644 examples/csgo.rs create mode 100644 src/games/csgo.rs 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::*;