Raised This Month: $ Target: $400
 0% 

Trouble on Getting a Client Cvar?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
musaulker
Junior Member
Join Date: Oct 2007
Old 10-15-2007 , 14:46   Trouble on Getting a Client Cvar?
Reply With Quote #1

Hello,

I try to write a simple plugin reading a cvar from the client but i get errors and i cannot read the value Whats the problem? (I also tried client_putinserver and also client_authorized but same problem..)
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <engine>


#define PLUGIN "TestingCvarPlugin"
#define VERSION "1.0"
#define AUTHOR "test"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
// Add your code here...
}

public 
client_connect(id)
{
    
client_cmd(id"say %s""testing cvar reading from client");
    
query_client_cvar(id"zoom_sensitivity_ratio""get_zoom_result_func");
}

public 
get_zoom_result_func(id, const cvar[], const value[])
{
    new 
name[32];
    
get_user_name(idname31);
    
    
log_amx("Client %d(%s)'s zoom_sensitivity_ratio is ^"%s^""idnamevalue);

and the error message on the console is:
PHP Code:
Host_ErrorUserMsgNot Present on Client 58

Can
't "say", not connect 
I understand the second message; if i cannot connect, i cannot send a command like "say" but what does thie means? "Host_Error: UserMsg: Not Present on Client 58" and how can i solve this problem?

Thanks..
musaulker is offline
M249-M4A1
I <3 Mac
Join Date: May 2005
Location: Not interested
Old 10-15-2007 , 14:52   Re: Trouble on Getting a Client Cvar?
Reply With Quote #2

You should use client_putinserver instead of client_connect, because in client_connect, the user isn't in the game yet, he is still in the middle of connecting. client_putinserver the client is ready to play.
__________________
M249-M4A1 is offline
musaulker
Junior Member
Join Date: Oct 2007
Old 10-15-2007 , 15:08   Re: Trouble on Getting a Client Cvar?
Reply With Quote #3

I've changed it to client_putinserver error is gone but i cannot still read from log file the client cvar's value and also nothing is printed on screen(using say)
the log file includes only:
PHP Code:
L 10/15/2007 22:06:32: -------- Mapchange to aim_akfrenzy -------- 
musaulker is offline
musaulker
Junior Member
Join Date: Oct 2007
Old 10-15-2007 , 15:42   Re: Trouble on Getting a Client Cvar?
Reply With Quote #4

is there anybody that knows the solution or can show me the way to the solution?
musaulker is offline
Old 10-15-2007, 17:06
l33tnewb
This message has been deleted by l33tnewb. Reason: nvm
musaulker
Junior Member
Join Date: Oct 2007
Old 10-15-2007 , 17:13   Re: Trouble on Getting a Client Cvar?
Reply With Quote #6

Quote:
Originally Posted by l33tnewb View Post
Try
Code:
#include <amxmodx>
#include <amxmisc>
#include <engine>


#define PLUGIN "TestingCvarPlugin"
#define VERSION "1.0"
#define AUTHOR "test"
Code:
public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR)
    
    // Add your code here...
}

Code:
public client_connect(id)
{
    client_cmd(id, "say %s", "testing cvar reading from client", id, name);
    query_client_cvar(id, "zoom_sensitivity_ratio", "get_zoom_result_func");
}

public get_zoom_result_func(id, const cvar[], const value[])
{
    new name[32];
    get_user_name(id, name, 31);
    
    log_amx("Client %d(%s)'s zoom_sensitivity_ratio is ^"%s^"", id, name, value);
}  
whats the difference from my post?
musaulker is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 10-15-2007 , 17:17   Re: Trouble on Getting a Client Cvar?
Reply With Quote #7

Basically your first code is good.
Try this one and tell me if it logs something :

Code:
#include <amxmodx> #define PLUGIN "TestingCvarPlugin" #define VERSION "1.0" #define AUTHOR "test" public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     // Add your code here... } public client_putinserver(id) {     client_cmd(id, "say %s", "testing cvar reading from client")     query_client_cvar(id, "zoom_sensitivity_ratio", "cvar_result")     query_client_cvar(id, "cl_cmdrate", "cvar_result") } public cvar_result(id, const cvar[], const value[]) {     new name[32]     get_user_name(id, name, 31)     if(equal(value, "Bad CVAR request"))         log_amx("Client %d(%s) has blocked his cvar %s", id, name, cvar)     else         log_amx("Client %d(%s)'s %s is %s", id, name, cvar, value) }
ConnorMcLeod is offline
musaulker
Junior Member
Join Date: Oct 2007
Old 10-15-2007 , 17:26   Re: Trouble on Getting a Client Cvar?
Reply With Quote #8

No I've tried and nothing successful.. what's the problem?
musaulker is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 10-15-2007 , 17:28   Re: Trouble on Getting a Client Cvar?
Reply With Quote #9

Do you test it on a listenserver, or with bots ?
Or do you test it with real players ?
ConnorMcLeod is offline
musaulker
Junior Member
Join Date: Oct 2007
Old 10-15-2007 , 17:42   Re: Trouble on Getting a Client Cvar?
Reply With Quote #10

I'm trying it on my local computer and local server and connecting locally to my server also developing it on the same computer everything is local..

From a friend advice i try function get_user_name:
PHP Code:
public client_putinserver(id)
{
    new 
rate[32]
    
get_user_info(id"rate"rate31
    new 
name[32];
    
get_user_name(idname31);
    
log_amx("Client %d(%s)'s %s is %s"idname"rate"rate)

and on the log its written like:

PHP Code:
L 10/16/2007 00:34:04: [test.amxxClient 1(Player)'s rate is 7000 
but i try this one:

PHP Code:
public client_putinserver(id)
{
    new 
zoom_sensitivity_ratio[32]
    
get_user_info(id"zoom_sensitivity_ratio"zoom_sensitivity_ratio31
    new 
name[32];
    
get_user_name(idname31);
    
log_amx("Client %d(%s)'s %s is %s"idname"zoom_sensitivity_ratio"zoom_sensitivity_ratio)

and the log is:
PHP Code:
L 10/16/2007 00:37:04: [test.amxxClient 1(Player)'s zoom_sensitivity_ratio is 
Now whats the problem?
musaulker is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:22.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode