Raised This Month: $ Target: $400
 0% 

execute function on changed cvar


Post New Thread Reply   
 
Thread Tools Display Modes
stupok
Veteran Member
Join Date: Feb 2006
Old 10-31-2006 , 17:19   Re: execute function on changed cvar
Reply With Quote #11

Bah. Xanimos I still have faith in you, I hope he can find an example that proves VEN wrong

Thanks for the reply though, VEN. You at least shed some light on the issue

Last edited by stupok; 10-31-2006 at 17:59.
stupok is offline
Rolnaaba
Veteran Member
Join Date: May 2006
Old 11-01-2006 , 09:48   Re: execute function on changed cvar
Reply With Quote #12

Quote:
Originally Posted by VEN View Post
pre/postthink shouldn't be used for non-player issues, it should be checked every server frame or at least with a few time interval.
I understand that I was just using that function as an example for a constant called function...
__________________
DO NOT PM me about avp mod.
Rolnaaba is offline
Old 11-04-2006, 01:48
stupok
This message has been deleted by Brad. Reason: no bumps! i know you can't read this, but because you bumped this thread you are now banned from my CS server for a week.
Simon Logic
Senior Member
Join Date: Nov 2006
Location: RF
Old 12-22-2006 , 13:06   Re: execute function on changed cvar
Reply With Quote #13

Server cvar logging can not be catched with register_logevent(), although you can disable logging by setting appropriate flag to cvar.

Try that:
Code:
#include <amxmodx> #include <fakemeta> new g_fmCVarSetFloat = 0 public plugin_init() {   g_fmCVarSetFloat = register_forward(FM_CVarSetFloat, "onCVarSetFloat") } public onCVarSetFloat(const name[], Float:value) {   // TODO:   return FMRES_IGNORED }
Simon Logic is offline
Send a message via Skype™ to Simon Logic
stupok
Veteran Member
Join Date: Feb 2006
Old 12-22-2006 , 20:27   Re: execute function on changed cvar
Reply With Quote #14

From my testing, it seems that code doesn't do anything.
stupok is offline
cybermind
Senior Member
Join Date: Oct 2004
Old 12-23-2006 , 02:07   Re: execute function on changed cvar
Reply With Quote #15

A similar problem exists with server says. There is no way for a MetaMod plugin (and AMXModX plugins as a result) to hook them. They appear in the log, but because that is handled all internally by the engine. The mod is not using ServerPrint since the mod never gets called as a result of the server say or cvar change.

In a MetaMod plugin I worked on a while ago, I implemented a rudimentary rcon reader socket which ignored any data that didn't originate from either 127.0.0.1 or the IP in the "net_address" cvar. Using logaddress_add to point data to the local socket, I was able to retrieve server says. The same could be done to read cvar changes.

I suppose another way to do this would be to use some 3rd party library and hook the actual function used in the engine to print text to the console.
cybermind is offline
Simon Logic
Senior Member
Join Date: Nov 2006
Location: RF
Old 12-23-2006 , 15:42   Re: execute function on changed cvar
Reply With Quote #16

Quote:
Originally Posted by stupok69 View Post
From my testing, it seems that code doesn't do anything.
I have my own WORKING plugin which blocks some cvars from changing by engine using described above method. So, i think you problem is more specific.
Simon Logic is offline
Send a message via Skype™ to Simon Logic
stupok
Veteran Member
Join Date: Feb 2006
Old 12-23-2006 , 15:57   Re: execute function on changed cvar
Reply With Quote #17

Well, I may just be using it incorrectly. Could you show me the code you use?

Here is my attempt: (the message does not print to the server console)

Code:
#include <amxmodx> #include <fakemeta> new g_fmCVarSetFloat = 0 public plugin_init() {     g_fmCVarSetFloat = register_forward(FM_CVarSetFloat, "onCVarSetFloat") } public onCVarSetFloat(const name[], Float:value) {     server_print("This is a message!") //this message doesn't print     return FMRES_IGNORED }

Also, there is only FM_CVarSetFloat and FM_CVarSetString, so I'm assuming cvars that use single digit values would not be caught with these methods. Correct me if I'm wrong.
stupok is offline
cybermind
Senior Member
Join Date: Oct 2004
Old 12-23-2006 , 18:11   Re: execute function on changed cvar
Reply With Quote #18

Quote:
Originally Posted by stupok69 View Post
Well, I may just be using it incorrectly. Could you show me the code you use?

Here is my attempt: (the message does not print to the server console)
As far as I can tell, hooking this function would only allow you to prevent the mod from changing the cvar value. Changing it from the console should bypass this hook.

Quote:
Originally Posted by stupok69 View Post
Also, there is only FM_CVarSetFloat and FM_CVarSetString, so I'm assuming cvars that use single digit values would not be caught with these methods. Correct me if I'm wrong.
Those are the only 2 states a cvar can be in. As far as I can tell, CVarSetString sets the string value of the cvar to whatever you put, and then basically uses "strtonum" (it's actually called atof I believe, but I'm trying to use scripting terms) to set the float value. This is what happens when you change a cvar in the console. Also, I think CVarSetFloat sets the string value to a blank string after setting the float value.

Last edited by cybermind; 12-23-2006 at 18:17.
cybermind 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 04:51.


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