Raised This Month: $51 Target: $400
 12% 

How can I get a cvar value from a client?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Reel mafioso
Member
Join Date: Oct 2014
Location: wouldn't you like to kno
Old 05-06-2015 , 15:33   How can I get a cvar value from a client?
Reply With Quote #1

The idea is simple. I need to get a integer, in this case, value of a client's cvar.
I'm trying to make a plugin that would set client's rate and cl_updaterate to fit my private server's limited bandwidth without the hassle of telling them to do it manually.

Code:
#include <amxmodx>
new rate,updrate;
public plugin_init()
{
	register_plugin("Networking cvars", "1", "Reel Mafioso");
}
public client_connect(id)
{
	rate == get_cvar_num("rate"); //This wont work
	updrate == get_cvar_num("cl_updaterate"); //Same
	console_cmd(id,"cl_updaterate %d",get_cvar_num("sv_maxupdaterate"));
	console_cmd(id,"rate %d",get_cvar_num("sv_maxrate"));
	client_print(id,print_console, "******************************************************");
	client_print(id,print_console, "Your rates have been changed for the best performance!");
	client_print(id,print_console, "Reset them back to normal upon leaving if you would like.");
	client_print(id,print_console, "******************************************************");
}
The plugin works in some way, it manages to SET the value to some handy cvars I can change in my config file. But It will not reset it when a client leaves. The main problem is getting and storing his current rate and cl_updaterate
Reel mafioso is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 05-06-2015 , 16:30   Re: How can I get a cvar value from a client?
Reply With Quote #2

This is slowhacking. Leave clients cvars for themselves to change.
__________________
Black Rose is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-06-2015 , 19:53   Re: How can I get a cvar value from a client?
Reply With Quote #3

Also, the statement "Your rates have been changed for the best performance!" is not true for everybody that connect to your server. You are likely making it worse for some people.

Also, the server has a way to to set player's rate, no plugin necessary!!! Simply set the follow cvars for your server and it will force them to use the rates you specify:

sv_minrate
sv_maxrate
sv_minudaterate
sv_maxupdaterate

Set the minimum and maximum for the range of values that you feel are acceptable. But remember, if you force people to use too high or too low of rates, you could actually make their performance worse.
__________________
fysiks is offline
aron9forever
Veteran Member
Join Date: Feb 2013
Location: Rromania
Old 05-07-2015 , 01:38   Re: How can I get a cvar value from a client?
Reply With Quote #4

it's beyond me how much people can avoid answering a goddamn question
PHP Code:
query_client_cvarid "cl_cmdrate" "Netcvar" );

public 
Netcvarid , const cvar[], const szrValue[])
{
   
client_printprint_chat "cl_cmdrate=%s" szrValue );  
}
don't forget to convert from string to int before using the value
and listen to fysiks if that'
s what you really need this for 
__________________
Meanwhile, in 2050:
Quote:
Originally Posted by aron9forever
useless small optimizations
Quote:
Originally Posted by Black Rose View Post
On a map that is 512x512x128 units you end up with 3,355,443,200,000 different "positions". To store each one of those positions individually in the variable "user_or" you need 12 terabytes of memory.
aron9forever is offline
Nextra
Veteran Member
Join Date: Apr 2008
Location: Germany
Old 05-07-2015 , 05:55   Re: How can I get a cvar value from a client?
Reply With Quote #5

Quote:
Originally Posted by aron9forever View Post
it's beyond me how much people can avoid answering a goddamn question
Yeah because he's attempting to do slowhacking which is forbidden by forum rules and generally a dumb thing you should not do. If someone asks for the tools explicitly to do dumb things, it's perfectly reasonable to inform them that they shouldn't be doing it in the first place, instead of blindly "helping".

The X/Y problem is also a real thing (no matter how hard you try to pretend it isn't), and often there is very good reason to go a longer way of discussion instead of fulfilling every request wihtout second thought, no matter how silly it sounds. This is how you can really help people do the right thing and learn, instead of programming by clobbering together dozens of random code snippets and wasting countless hours going in the wrong directions.

Experience is how you can actually help people. In programming "why?" is most often the more important question than "how?". Telling someone how to use query_client_cvar is, these days, a matter of simply linking to the API documentation page.
__________________
In Flames we trust!
Nextra is offline
Reel mafioso
Member
Join Date: Oct 2014
Location: wouldn't you like to kno
Old 05-07-2015 , 07:40   Re: How can I get a cvar value from a client?
Reply With Quote #6

Well Idk why it's so hatred this slowhacking, nobody bothers to explain why it's hated and why I should avoid using it with a clear example. My only intention was to set their rates up according to the server, as the most common reason for loss (sometimes choke too) are cvars not set the best. Which alternative function should I use then?. What can happen when I use console_cmd or client_cmd ?
Also for making it worse for some people, it can be for people who have slower internet, but the only thing that matters most is updaterate. Clients have mostly 30 or 60 maybe even higher, they request too much updates and get choke then blame the server "Hurr i only get ping here wtf". My updaterate set on the server is 24 as I have a low bandwidth for a server i'm planning to use privately and not all the time anyway.
Reel mafioso is offline
Nextra
Veteran Member
Join Date: Apr 2008
Location: Germany
Old 05-07-2015 , 08:31   Re: How can I get a cvar value from a client?
Reply With Quote #7

Slowhacking or not, 24 is a terrible update rate, and suggests you shouldn't be running a server on that connection in the first place.

The issue with slowhacking is that, given your server connection, you will "optimize" the client to your server which then in turn makes their experience on literally every other server shit aswell. So they have a sub-par experience on your server because it can't do better, and they will have a sub-par experience on every other server because you fucked with their settings. This doesn't just apply to rates, but also to binds and other random variables.

Use the commands fysiks suggested, and stay away from people's configs. They will hate your server more for slowhacking than for a nonoptimal experience on an already bad connection.
__________________
In Flames we trust!
Nextra is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-07-2015 , 08:53   Re: How can I get a cvar value from a client?
Reply With Quote #8

Also, since it hasn't been mentioned, it's impossible to send commands to a client after they leave.

But, as Nextra (and myself said) the server already had this functionality built into the game. Simply use the server settings I posted above and there will be no need to use any client commands and there is nothing to "set back" for the player.
__________________
fysiks is offline
Reel mafioso
Member
Join Date: Oct 2014
Location: wouldn't you like to kno
Old 05-07-2015 , 08:53   Re: How can I get a cvar value from a client?
Reply With Quote #9

Quote:
Originally Posted by Nextra View Post
Slowhacking or not, 24 is a terrible update rate, and suggests you shouldn't be running a server on that connection in the first place.

The issue with slowhacking is that, given your server connection, you will "optimize" the client to your server which then in turn makes their experience on literally every other server shit aswell. So they have a sub-par experience on your server because it can't do better, and they will have a sub-par experience on every other server because you fucked with their settings. This doesn't just apply to rates, but also to binds and other random variables.

Use the commands fysiks suggested, and stay away from people's configs. They will hate your server more for slowhacking than for a nonoptimal experience on an already bad connection.
Okay. Thank you for trying to explain, but you didn't quite hit the target. Why do people say "Don't do this" without a reason? I specifically ask for a reason not to use console/client_cmd. Hopefully someone can tell me the reason. I removed the plugin and added sv_minupaderate and sv_minrate commands (I only had max counterparts). Theoretically you can host a server on dial up, but you will have to have a ridiculously low rate and updaterate. I have found some guides on setting maxrate and maxupdaterate, and the numbers I use are the above mentioned.

Last edited by Reel mafioso; 05-07-2015 at 08:55.
Reel mafioso is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-07-2015 , 08:56   Re: How can I get a cvar value from a client?
Reply With Quote #10

Quote:
Originally Posted by Reel mafioso View Post
Theoretically you can host a server on dial up
Not really. The game was originally designed for ONE player to use dial-up. It was NOT designed for a server to be hosted on dial-up which equates to MANY players using that same connection.
__________________
fysiks 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 13:28.


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