use crate::edicts::Edict;
use crate::ffi::vcall;
use std::ffi::{CStr, c_int};
const INVALID_QUERY_CVAR_COOKIE: c_int = -1;
interface! {
#[doc(alias = "IServerPluginHelpers")]
pub struct PluginHelpers(sys::IServerPluginHelpers) = Engine c"ISERVERPLUGINHELPERS001";
}
#[doc(alias = "QueryCvarCookie_t")]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct QueryCvarCookie(pub c_int);
impl<'s> PluginHelpers<'s> {
#[doc(alias = "ClientCommand")]
pub fn client_command(self, client: Edict<'_>, command: &CStr) {
unsafe {
vcall!(self.as_ptr() => IServerPluginHelpers_ClientCommand(client.as_ptr(), command.as_ptr()))
};
}
#[doc(alias = "StartQueryCvarValue")]
pub fn start_query_cvar_value(self, client: Edict<'_>, name: &CStr) -> Option<QueryCvarCookie> {
let cookie = unsafe {
vcall!(self.as_ptr() => IServerPluginHelpers_StartQueryCvarValue(client.as_ptr(), name.as_ptr()))
};
(cookie != INVALID_QUERY_CVAR_COOKIE).then_some(QueryCvarCookie(cookie))
}
}