Garry's Mod

[HELP] Need script playSound when player get specific job

Submitted by heret1c, , Thread ID: 239387

Thread Closed
01-04-2022, 01:36 PM
#1
Hello. So, i need script or help to create it.

When player get specific job (ex.: SCP 106) - start playing mp3 sound from server to all players (all players must hear mp3 sound).

I know codesound.Play for playerloadout on jobs.lua, on specific position map, but idk its hear all players or only player with specific job.
Help pls

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

This post was last modified: 05-04-2022, 07:58 PM by Bambi_ID
#2
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

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: 2 Guest(s)