Strings in localcmd's ?
Moderator: InsideQC Admins
7 posts
• Page 1 of 1
Strings in localcmd's ?
I was thinking something like this:
But, i'm not so sure it can be done.. Can it?
- 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
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.
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
Also look at the "sound" builtin:
If it does the job it may be preferable to stuffcmd/localcmd abuse.
- 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
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: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
- Spike
- Posts: 2892
- Joined: Fri Nov 05, 2004 3:12 am
- Location: UK
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
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
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
7 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest