From 93be4e29b8256cc0c53981d6b6c51ef56bee3691 Mon Sep 17 00:00:00 2001 From: Scott Ehlert Date: Sat, 14 Apr 2007 04:49:08 +0000 Subject: [PATCH] Oh forgot this - QueryClientConVar returns 0 on bots now. --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40703 --- core/smn_console.cpp | 10 ++++++++-- plugins/include/console.inc | 11 ++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/core/smn_console.cpp b/core/smn_console.cpp index 8399ff18..c9c5d81a 100644 --- a/core/smn_console.cpp +++ b/core/smn_console.cpp @@ -369,9 +369,15 @@ static cell_t sm_QueryClientConVar(IPluginContext *pContext, const cell_t *param return pContext->ThrowNativeError("Player %d is not a valid player", params[1]); } - if (!pPlayer->IsConnected() || pPlayer->IsFakeClient()) + if (!pPlayer->IsConnected()) { - return pContext->ThrowNativeError("Player %d is either not connected or a bot", params[1]); + return pContext->ThrowNativeError("Player %d is not connected", params[1]); + } + + /* Trying a query on a bot results in callback not be fired, so don't bother */ + if (pPlayer->IsFakeClient()) + { + return 0; } pContext->LocalToString(params[2], &name); diff --git a/plugins/include/console.inc b/plugins/include/console.inc index 312ca21a..22c83749 100644 --- a/plugins/include/console.inc +++ b/plugins/include/console.inc @@ -18,6 +18,14 @@ #endif #define _console_included +/** + * Console variable query helper values. + */ +enum QueryCookie +{ + QUERYCOOKIE_FAILED = 0, +} + /** * Console variable query result values. */ @@ -447,6 +455,7 @@ funcenum ConVarQueryFinished * @param name Name of client convar to query. * @param callback A function to use as a callback when the query has finished. * @param value Optional value to pass to the callback function. - * @return A cookie that uniquely identifies the query. + * @return A cookie that uniquely identifies the query. + * Returns QUERYCOOKIE_FAILED on failure, such as when used on a bot. */ native QueryCookie:QueryClientConVar(client, const String:cvarName[], ConVarQueryFinished:callback, any:value=0);