Forum

Strings in localcmd's ?

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Strings in localcmd's ?

Postby DusterdooSmock » Tue Mar 22, 2011 5:13 pm

I was thinking something like this:
Code: Select all
local string snd;

if(something)
      snd = "misc/sound1.wav\n";
else
      snd = "misc/sound2.wav\n";

localcmd("play, snd");


But, i'm not so sure it can be done.. Can it?
DusterdooSmock
 
Posts: 170
Joined: Thu Aug 19, 2010 9:58 pm

Postby Spike » Tue Mar 22, 2011 5:40 pm

mysoundfile = "misc/somefunkysound.wav";

localcmd("play \"");
localcmd(mysoundfile);
localcmd("\"\n");

localcmd doesn't accept multiple arguments, but since its not actually execed until the end of the frame (or start of the next?) it doesn't matter, as you can just call it multiple times. the only important thing is that each command is terminated with a '\n' or a ';' char.... Oh, and that you also don't flood the buffer, but hey, who's going to do that...

The same applies to stuffcmd. Make sure you use localcmd where you mean 'server needs this', and stuffcmd where you mean 'client needs this'. Don't confuse the two.
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Postby mh » Tue Mar 22, 2011 6:10 pm

Also look at the "sound" builtin:
Code: Select all
sound (entity, channel, soundfilename, volume, attenuation);

If it does the job it may be preferable to stuffcmd/localcmd abuse.
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 DusterdooSmock » Tue Mar 22, 2011 6:22 pm

mh wrote:Also look at the "sound" builtin:
Code: Select all
sound (entity, channel, soundfilename, volume, attenuation);

If it does the job it may be preferable to stuffcmd/localcmd abuse.


Spike answered my question, because, the sound is for a multiplayer gametype, and i need it to play for everyone on the server, at the same volume.

Thanks guys.
DusterdooSmock
 
Posts: 170
Joined: Thu Aug 19, 2010 9:58 pm

Postby Spike » Tue Mar 22, 2011 8:53 pm

attenuation 0 means the sound will not fade with distance, it will be globally heard.
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Postby mh » Tue Mar 22, 2011 10:09 pm

You could also write an svc_sound message to selected clients. That would be a neat way of playing with their heads ("come here, come here" for one group, "keep away, keep away" for another) or sending different sounds to different teams.
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 DusterdooSmock » Wed Mar 23, 2011 1:46 am

Spike wrote:attenuation 0 means the sound will not fade with distance, it will be globally heard.


OK, so....like this?
Code: Select all
local string noise;

if(self.team == RED)
      noise = "multiplayer/ctf/red team/flag returned.wav";
else
      noise = "multiplayer/ctf/blue team/flag returned.wav";

sound(self, CHAN_VOICE, noise, 1, 0);


Btw; self is the flag spawnpoint..thats why i set it to play there.
DusterdooSmock
 
Posts: 170
Joined: Thu Aug 19, 2010 9:58 pm


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest