Hello everyone! :)
I got a problem you guys might be able to help me with, so here's the situation.
[CODE]function GM:PlayerFootstep( ply, pos, foot, sound, volume, rf )
if (!GAMEMODE.Snow) then return; end
local randSound = math.random(1, 3)
ply.lastFootSound = self.lastFootSound or 1;
while (randSound == ply.lastFootSound) do
randSound = math.random(1, 3);
end
ply.lastFootSound = randSound;
sound.Play(Sound("player/footsteps/snow" .. randSound .. ".wav", "GAME"), pos, 65);
return true
end[/CODE]
Can I not use math.random anymore or? although the error seams to be on the sound.Play line? maybe the part " ..randSound .." I don't know? I tried Google be I can't find any changes to it?
Here is the error: [CODE]bad key to sting index <number expected, got string>[/CODE]
Okay so I'm doing something wrong with the sting?
It's supposed to pick a random sound, from "player/footsteps/snow" and change the footstep sound to a snow sound... Which is cstrike sounds.
Any ideas?
[code]
sound.Play("player/footsteps/snow" .. randSound .. ".wav", pos, 65);
[/code]
Not sure why you had the Sound("soundname", "GAME") as it looks like it just wants a string.
[URL="http://gmodwiki.net/Lua/Libraries/sound/Play"]http://gmodwiki.net/Lua/Libraries/sound/Play[/URL]
It precaches the sound.
To OP: You should use ply:EmitSound( snd, vol, pitch )
[lua]
function GM:PlayerFootstep( ply, pos, foot, sound, volume, rf )
if (!GAMEMODE.Snow) then return; end
local randSound = math.random(1, 3)
ply.lastFootSound = self.lastFootSound or 1;
while (randSound == ply.lastFootSound) do
randSound = math.random(1, 3);
end
ply.lastFootSound = randSound;
sound.Play(Sound("player/footsteps/snow" .. randSound .. ".wav"), pos, 65);
return true
end
[/lua]
Sorry, you need to Log In to post a reply to this thread.