AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Trouble on Getting a Client Cvar? (https://forums.alliedmods.net/showthread.php?t=61982)

musaulker 10-15-2007 14:46

Trouble on Getting a Client Cvar?
 
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..

M249-M4A1 10-15-2007 14:52

Re: Trouble on Getting a Client Cvar?
 
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.

musaulker 10-15-2007 15:08

Re: Trouble on Getting a Client Cvar?
 
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 10-15-2007 15:42

Re: Trouble on Getting a Client Cvar?
 
is there anybody that knows the solution or can show me the way to the solution?

musaulker 10-15-2007 17:13

Re: Trouble on Getting a Client Cvar?
 
Quote:

Originally Posted by l33tnewb (Post 542485)
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?

ConnorMcLeod 10-15-2007 17:17

Re: Trouble on Getting a Client Cvar?
 
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) }

musaulker 10-15-2007 17:26

Re: Trouble on Getting a Client Cvar?
 
No :( I've tried and nothing successful.. what's the problem? :(

ConnorMcLeod 10-15-2007 17:28

Re: Trouble on Getting a Client Cvar?
 
Do you test it on a listenserver, or with bots ?
Or do you test it with real players ?

musaulker 10-15-2007 17:42

Re: Trouble on Getting a Client Cvar?
 
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?

alien 10-15-2007 21:57

Re: Trouble on Getting a Client Cvar?
 
The problem is that zoom_sensitivity_ratio is a client cvar. It cannot be retrieved with get_user_info. By get_user_info, you can retrieve any information from setinfo structure (which can be viewed by using setinfo command).

Field rate is a part of setinfo structure - that's why it's possible to get it.

This issue is very simmilar to the one with fps_max cvar. Many think that it's possible to get this value with this function (as it's written in example in funcwiki) - but it's meretricious disinformation.

I suggest using THIS function instead. I have no experience with it.
Edit: And as I read previous posts, it was suggested already. You should read carefully what they advice you. The way you're doing it won't work.


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

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