quakec cvar change
Moderator: InsideQC Admins
28 posts
• Page 2 of 2 • 1, 2
Spike wrote: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.
<rant>
It always bemuses me why "stuffcmd" is seen as being the way to do anything through QC. There's already a perfectly good "cvar_set" builtin; you don't need stuffcmd at all here. True, it'll only work on the server, but this is a server cvar anyway.
- Code: Select all
cvar_set ("sv_maxspeed", "250");
There's also a perfectly good "cvar" builtin that you can use to get the original value, so that you can restore it properly when you're finished having your evil ways with it.
Would people please stop recommending "stuffcmd" unless you're absolutely certain that it's the only way?
</rant>
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
We knew the words, we knew the score, we knew what we were fighting for
-

mh - Posts: 2292
- Joined: Sat Jan 12, 2008 1:38 am
mh wrote: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);
}
Thanks a million. Compiling code now.
Btw stuffcmd and localcmd. Is the dfference that local affects only the client who changed the cvar and stuff affects everyone no matter what? Correct me if im mistaken
-

behind_you - Posts: 237
- Joined: Sat Feb 05, 2011 6:57 am
- Location: Tripoli, Libya
mh wrote:<rant>
It always bemuses me why "stuffcmd" is seen as being the way to do anything through QC. There's already a perfectly good "cvar_set" builtin; you don't need stuffcmd at all here. True, it'll only work on the server, but this is a server cvar anyway.
- Code: Select all
cvar_set ("sv_maxspeed", "250");
There's also a perfectly good "cvar" builtin that you can use to get the original value, so that you can restore it properly when you're finished having your evil ways with it.
Would people please stop recommending "stuffcmd" unless you're absolutely certain that it's the only way?
</rant>
Hold the phone. Used cvar_set and got a warning: 'type mismatch on parm 0. Expected string, found entity'. Never got this with stuff cmd. Localcmd gave me 4 warnings similar to cvar_set.
-

behind_you - Posts: 237
- Joined: Sat Feb 05, 2011 6:57 am
- Location: Tripoli, Libya
stuffcmd lets you specify a specific client to send the command to whereas localcmd executes the command locally on the server (Quake has a client/server architecture which you'd need to become familiar with for anything more detailed to make sense). The differences really only apply to multiplayer games, but you should be aware of them.
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
We knew the words, we knew the score, we knew what we were fighting for
-

mh - Posts: 2292
- Joined: Sat Jan 12, 2008 1:38 am
behind_you wrote:mh wrote:<rant>
It always bemuses me why "stuffcmd" is seen as being the way to do anything through QC. There's already a perfectly good "cvar_set" builtin; you don't need stuffcmd at all here. True, it'll only work on the server, but this is a server cvar anyway.
- Code: Select all
cvar_set ("sv_maxspeed", "250");
There's also a perfectly good "cvar" builtin that you can use to get the original value, so that you can restore it properly when you're finished having your evil ways with it.
Would people please stop recommending "stuffcmd" unless you're absolutely certain that it's the only way?
</rant>
Hold the phone. Used cvar_set and got a warning: 'type mismatch on parm 0. Expected string, found entity'. Never got this with stuff cmd. Localcmd gave me 4 warnings similar to cvar_set.
That's likely because you just replaced the text "stuffcmd" with "cvar_set", as in:
- Code: Select all
cvar_set (self, "sv_maxspeed 250\n");
It doesn't work that way; if you want to set the value of sv_maxspeed to 250 you need this:
- Code: Select all
cvar_set ("sv_maxspeed", "250");
Don't worry that 250 is a string here, the engine will convert it behind the scenes.
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
We knew the words, we knew the score, we knew what we were fighting for
-

mh - Posts: 2292
- Joined: Sat Jan 12, 2008 1:38 am
mh wrote:You should see some of the mistakes I've made in the past...
Probably not as bad as i am now! Im a mess...
-

behind_you - Posts: 237
- Joined: Sat Feb 05, 2011 6:57 am
- Location: Tripoli, Libya
mh wrote:stuffcmd lets you specify a specific client to send the command to whereas localcmd executes the command locally on the server (Quake has a client/server architecture which you'd need to become familiar with for anything more detailed to make sense). The differences really only apply to multiplayer games, but you should be aware of them.
Whoa, sorry forgot that its serverside urgh.
Im feeling bad now.
I apologise for that.
I thought he could use stuffcmd because he is doing a SinglePlayer shooter.
-

Ranger366 - Posts: 203
- Joined: Thu Mar 18, 2010 5:51 pm
Ranger366 wrote:I thought he could use stuffcmd because he is doing a SinglePlayer shooter.
Well he can, but he really should use cvar_set to set a cvar.
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
We knew the words, we knew the score, we knew what we were fighting for
-

mh - Posts: 2292
- Joined: Sat Jan 12, 2008 1:38 am
well, did some comparison testing
Theyre the same, but cvar_set takes effect a tiny bit faster than the others. Im now making the player slow down when crouched. I tried rapidly ducking and 'un'ducking and stuffcmd didnt restore the speed AKA i was standing but moving at crouching speed. Cvar_set didnt do this. But its a very small time difference. Thank u very much!!!
Theyre the same, but cvar_set takes effect a tiny bit faster than the others. Im now making the player slow down when crouched. I tried rapidly ducking and 'un'ducking and stuffcmd didnt restore the speed AKA i was standing but moving at crouching speed. Cvar_set didnt do this. But its a very small time difference. Thank u very much!!!
-

behind_you - Posts: 237
- Joined: Sat Feb 05, 2011 6:57 am
- Location: Tripoli, Libya
28 posts
• Page 2 of 2 • 1, 2
Who is online
Users browsing this forum: No registered users and 1 guest