Will this Work?

Hi everyone, I wanted to make a little script thing, that if your in the model group, And you die it will play that one combinish biosignal death sound… Does this look like it would work? I want it so when they die, citizens around them will hear it, and so will the combine.

[lua]function playerDies( victim, weapon, killer )

local AllowedModels = {“models/player/police.mdl”,“models/player/biopolice.mdl”,“models/player/c08cop.mdl”,“models/player/e3_cpelite.mdl”,“models/player/leet_police_bt.mdl”,“models/player/policetrench.mdl”,“models/player/redice.mdl”,“models/player/rolice.mdl”,“models/player/rtbpolice.mdl”,“models/player/tribal.mdl”,“models/player/breen.mdl”,“models/player/combine_soldier_prisonguard.mdl”,“models/player/combine_super_soldier.mdl”,“models/player/police_female.mdl”}

if !table.HasValue(AllowedModels,ply:GetModel()) then return end



hook.Add( “PlayerDeath”, “playerDeathTest”, playerDies )[/lua]

Yes, it would work, but you should probably do it like this:
[lua]local AllowedModels =
function playerDies( victim, weapon, killer )
if table.HasValue(AllowedModels, ply:GetModel()) then
hook.Add( “PlayerDeath”, “playerDeathTest”, playerDies )

so that it checks if it DOES have the model instead of checking if it doesn’t. Plus you can access the models later in the script if you need to this way.
Assuming, of course, that the sound is correct. Also, I don’t see why you would want that for Breen.

Couldn’t you do just a simple loop?
function playerDies( player, weapon, killer )
for k,v in pairs(AllowedModels) do
if player:GetModel == v then
hook.Add( “PlayerDeath”, “playerDeathTest”, playerDies )

table.HasValue is faster I think

Oh, i forgot to take that ! off :3 I was using the same table for another script, Thanks! so both people around the dead body, and the dead guy will hear it?

[editline]1st July 2011[/editline]

Its not working, I have it in the Gamemodes Init file, I cant hear it, or do only people around me hear it?