mirror of
https://github.com/tribufu/rust-gamedig
synced 2026-05-06 15:27:28 +00:00
Initial CSGO support
This commit is contained in:
parent
38d7758c4c
commit
8a93d2fb7d
3 changed files with 28 additions and 0 deletions
10
examples/csgo.rs
Normal file
10
examples/csgo.rs
Normal file
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
16
src/games/csgo.rs
Normal file
16
src/games/csgo.rs
Normal file
|
|
@ -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<u16>) -> Result<Response, GDError> {
|
||||
ValveProtocol::query(App::CSGO, address, match port {
|
||||
None => 27015,
|
||||
Some(port) => port
|
||||
}, GatheringSettings {
|
||||
players: true,
|
||||
rules: true
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
|
||||
pub mod tf2;
|
||||
pub mod the_ship;
|
||||
pub mod csgo;
|
||||
|
||||
pub use tf2::*;
|
||||
pub use the_ship::*;
|
||||
pub use csgo::*;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue