From 55ffe37a794e7dba9eeaf3bb5fee618ec2989a60 Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Thu, 14 Dec 2023 12:42:13 +0100 Subject: [PATCH] #USERSOUND * Added USERSOUND:ToClient( Client, Delay ) --- Moose Development/Moose/Sound/UserSound.lua | 22 ++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/Moose Development/Moose/Sound/UserSound.lua b/Moose Development/Moose/Sound/UserSound.lua index cbccffe12..1c753a538 100644 --- a/Moose Development/Moose/Sound/UserSound.lua +++ b/Moose Development/Moose/Sound/UserSound.lua @@ -137,7 +137,7 @@ do -- UserSound return self end - --- Play the usersound to the given @{Wrapper.Unit}. + --- Play the usersound to the given @{Wrapper.Unit}. -- @param #USERSOUND self -- @param Wrapper.Unit#UNIT Unit The @{Wrapper.Unit} to play the usersound to. -- @param #number Delay (Optional) Delay in seconds, before the sound is played. Default 0. @@ -159,4 +159,24 @@ do -- UserSound return self end + + --- Play the usersound to the given @{Wrapper.Unit}. + -- @param #USERSOUND self + -- @param Wrapper.Client#CLIENT The @{Wrapper.Client} to play the usersound to. + -- @param #number Delay (Optional) Delay in seconds, before the sound is played. Default 0. + -- @return #USERSOUND The usersound instance. + -- @usage + -- local BlueVictory = USERSOUND:New( "BlueVictory.ogg" ) + -- local PlayerUnit = CLIENT:FindByPlayerName("Karl Heinz")-- Search for the active client with playername "Karl Heinz", a human player. + -- BlueVictory:ToClient( PlayerUnit ) -- Play the victory sound to the player unit. + -- + function USERSOUND:ToClient( Client, Delay ) + Delay=Delay or 0 + if Delay>0 then + SCHEDULER:New(nil, USERSOUND.ToClient,{self, Client}, Delay) + else + trigger.action.outSoundForUnit( Client:GetID(), self.UserSoundFileName ) + end + return self + end end \ No newline at end of file