AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How can I get a cvar value from a client? (https://forums.alliedmods.net/showthread.php?t=262523)

Reel mafioso 05-06-2015 15:33

How can I get a cvar value from a client?
 
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

Black Rose 05-06-2015 16:30

Re: How can I get a cvar value from a client?
 
This is slowhacking. Leave clients cvars for themselves to change.

fysiks 05-06-2015 19:53

Re: How can I get a cvar value from a client?
 
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.

aron9forever 05-07-2015 01:38

Re: How can I get a cvar value from a client?
 
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 


Nextra 05-07-2015 05:55

Re: How can I get a cvar value from a client?
 
Quote:

Originally Posted by aron9forever (Post 2294166)
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.

Reel mafioso 05-07-2015 07:40

Re: How can I get a cvar value from a client?
 
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.

Nextra 05-07-2015 08:31

Re: How can I get a cvar value from a client?
 
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.

fysiks 05-07-2015 08:53

Re: How can I get a cvar value from a client?
 
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.

Reel mafioso 05-07-2015 08:53

Re: How can I get a cvar value from a client?
 
Quote:

Originally Posted by Nextra (Post 2294229)
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.

fysiks 05-07-2015 08:56

Re: How can I get a cvar value from a client?
 
Quote:

Originally Posted by Reel mafioso (Post 2294233)
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.


All times are GMT -4. The time now is 00:40.

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