How to spawn multiple entities at once? [+ another question in topic]
4 replies, posted
I've tried this:
[code] ent:Spawn(math.random(1,10))[/code]
But that didn't work.
I also want to have a sound when a player died, but that didn't work too:
[code]if GetConVarNumber( "kp_deathsounds" ) == 1 then
function OnPlayerDeath(ply)
ply:EmitSound("kp/male/death"..math.random(1,4)..".wav")
end
end[/code]
Um, you need to modify whatever code is spawning the entity, not calling "Spawn" on the entity itself (this calls Initialize), in a loop. Also, you need to make sure their origin (where they spawn) are different.
[code]for i=0,math.random(1,10) do
-- Spawn shit here
end[/code]
Please read up on hooks in garrys mod, your functions won't get magically called.
[code]
local function OnPlayerDeath(ply)
if GetConVarNumber( "kp_deathsounds" ) == 1 then
ply:EmitSound("kp/male/death"..math.random(1,4)..".wav")
end
end
hook.Add("PlayerDeath","crapshit",OnPlayerDeath)[/code]
Is it possible to remove original hearbeat sound when dead?
Sorry, you need to Log In to post a reply to this thread.