Garry's Mod

[HELP] Need script playSound when player get specific job

Submitted by heret1c, , Thread ID: 239387

Thread Closed

RE: [HELP] Need script playSound when player get specific job

OP
This post was last modified: 11-04-2022, 09:40 PM by heret1c
Warned
#3
05-04-2022, 07:57 PM
Bambi_ID Wrote:
Maybe something like

The code below can be added to playerinitialspawn in job.lua so when they spawn as the job/role
Code:
--To all players
for k, v in pairs(player.GetAll())do
--Play sound file can be .mp3
sound.Play( "ambient/explosions/exp1.wav", v:GetPos() )

end

--Whats set in this example ply:GetJob()
local blacklisted_jobs = {
"Civilian",
"SCP001",
"SCP002",
"SCP003"
}

for k, v in pairs(player.GetAll())do
--Loop Through Blacklisted jobs
for i, t in pairs(blacklisted_jobs)do
--For Specific job. Depends on how gamemode set up for GetJob() function
if !(v:GetJob() == t)
--Play sound file can be .mp3
sound.Play( "ambient/explosions/exp1.wav", v:GetPos() )

end

end

end
I tested it. And test a EmitSound.
Players hear sounds if player is next to me. But if player further away from me - doesn`t hear sounds.
Need code with surface.Playsound, but it not work on jobs.lua on ex. PlayerSpawn.......

closed. i make addon and it work

Users browsing this thread: 4 Guest(s)