Forum

quakec cvar change

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

quakec cvar change

Postby behind_you » Tue Mar 01, 2011 5:48 pm

is there a way to change a cvar, every time i shoot with a shotgun for example?
User avatar
behind_you
 
Posts: 237
Joined: Sat Feb 05, 2011 6:57 am
Location: Tripoli, Libya

Re: quakec cvar change

Postby Nahuel » Tue Mar 01, 2011 6:22 pm

mmm. do you want that a specific function is realized as if it was lowering the command line and writes there something?
Is it that or I understood badly?
hi, I am nahuel, I love quake and qc.
User avatar
Nahuel
 
Posts: 492
Joined: Wed Jan 12, 2011 8:42 pm
Location: mar del plata

Postby behind_you » Tue Mar 01, 2011 6:30 pm

lets say i had a shotgun. Everytime i shoot with it, i want the sv_maxspeed to become 250. How do i accomplish this?
User avatar
behind_you
 
Posts: 237
Joined: Sat Feb 05, 2011 6:57 am
Location: Tripoli, Libya

Postby Ranger366 » Tue Mar 01, 2011 6:37 pm

behind_you wrote:lets say i had a shotgun. Everytime i shoot with it, i want the sv_maxspeed to become 250. How do i accomplish this?


stuffcmd (self, "sv_maxspeed 250\n");

called in W_FireShotgun or whatever, a very hacky thing
User avatar
Ranger366
 
Posts: 203
Joined: Thu Mar 18, 2010 5:51 pm

Postby Nahuel » Tue Mar 01, 2011 6:49 pm

Ranger366 wrote:
behind_you wrote:lets say i had a shotgun. Everytime i shoot with it, i want the sv_maxspeed to become 250. How do i accomplish this?


stuffcmd (self, "sv_maxspeed 250\n");

called in W_FireShotgun or whatever, a very hacky thing

I agree :D :D :D
hi, I am nahuel, I love quake and qc.
User avatar
Nahuel
 
Posts: 492
Joined: Wed Jan 12, 2011 8:42 pm
Location: mar del plata

Postby behind_you » Tue Mar 01, 2011 6:53 pm

thanks u guys!
User avatar
behind_you
 
Posts: 237
Joined: Sat Feb 05, 2011 6:57 am
Location: Tripoli, Libya

Postby behind_you » Tue Mar 01, 2011 7:29 pm

ok now whenever i shoot with the shotgun it says 'sv_maxspeed' changed to '250.' how do i make it not say that?
User avatar
behind_you
 
Posts: 237
Joined: Sat Feb 05, 2011 6:57 am
Location: Tripoli, Libya

Postby mh » Tue Mar 01, 2011 7:36 pm

behind_you wrote:ok now whenever i shoot with the shotgun it says 'sv_maxspeed' changed to '250.' how do i make it not say that?

You can't. It's a server cvar, which means that any changes made to it are broadcast to all connected clients.

By the way, if you're going to do this, do it carefully. People might have set their own values for cvars that suit the way they like to play the game, and they won't take kindly to you stomping all over their settings. At the very least save out the previous value and restore it properly when done - don't assume that it's always at the default.
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Postby behind_you » Tue Mar 01, 2011 7:44 pm

ok can i stop from broadcasting all server cvars? Im making a single player mod so it should matter, right? Or do bots get affected by this sort of thing?
User avatar
behind_you
 
Posts: 237
Joined: Sat Feb 05, 2011 6:57 am
Location: Tripoli, Libya

Postby Ranger366 » Tue Mar 01, 2011 8:09 pm

behind_you wrote:ok can i stop from broadcasting all server cvars? Im making a single player mod so it should matter, right? Or do bots get affected by this sort of thing?


Only clients (and fakeclients eventually) get affected by it.
I think with "bots" you mean enemies such as the ogre or the enforcer - they dont get affected.
User avatar
Ranger366
 
Posts: 203
Joined: Thu Mar 18, 2010 5:51 pm

Postby behind_you » Tue Mar 01, 2011 8:21 pm

im using frikbots, they arent getting affected, right? Nd that stupid broadcast message is pissin me off.
User avatar
behind_you
 
Posts: 237
Joined: Sat Feb 05, 2011 6:57 am
Location: Tripoli, Libya

Postby mh » Tue Mar 01, 2011 8:44 pm

You can't stop it broadcasting unless you modify the engine.
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Postby behind_you » Tue Mar 01, 2011 8:56 pm

mh wrote:You can't stop it broadcasting unless you modify the engine.


Where specifically? Thats what im currently trying to find out
User avatar
behind_you
 
Posts: 237
Joined: Sat Feb 05, 2011 6:57 am
Location: Tripoli, Libya

Postby Spike » Tue Mar 01, 2011 9:04 pm

stuffcmd(foo, "sv_foo\n");

forgive me while I vomit....

*vomits*

try localcmd("sv_foo\n"); instead. It'll probably work more reliably.

Won't silence the prints though.
You should use grep/find-in-files for that instead. "'%s' changed to '%s'\n" will probably turf something up.
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Postby mh » Tue Mar 01, 2011 9:05 pm

In the Cvar_Set function, this is the block of code that you need to remove:
Code: Select all
   if (var->server && changed)
   {
      if (sv.active)
         SV_BroadcastPrintf ("\"%s\" changed to \"%s\"\n", var->name, var->string);
   }
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Next

Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest