Advertisement
Guest User

Untitled

a guest
Jan 24th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.31 KB | None | 0 0
  1. local LoadedSounds
  2. if CLIENT then
  3.     LoadedSounds = {} -- this table caches existing CSoundPatches
  4. end
  5.  
  6. local function ReadSound( FileName )
  7.     local sound
  8.     local filter
  9.     if SERVER then
  10.         filter = RecipientFilter()
  11.         filter:AddAllPlayers()
  12.     end
  13.     if SERVER or !LoadedSounds[FileName] then
  14.         -- The sound is always re-created serverside because of the RecipientFilter.
  15.         sound = CreateSound( game.GetWorld(), FileName, filter ) -- create the new sound, parented to the worldspawn ( which always exists )
  16.         if sound then
  17.             sound:SetSoundLevel( 0 ) -- play everywhere
  18.             if CLIENT then
  19.                 LoadedSounds[FileName] = { sound, filter } -- cache the CSoundPatch
  20.             end
  21.         end
  22.     else
  23.         sound = LoadedSounds[FileName][1]
  24.         filter = LoadedSounds[FileName][2]
  25.     end
  26.     if sound then
  27.         if CLIENT then
  28.             sound:Stop() -- it won't play again otherwise
  29.         end
  30.         sound:Play()
  31.     end
  32.     return sound -- useful if you want to stop the sound yourself
  33. end
  34.  
  35. -- When we are ready, we play the sound:
  36. timer.Simple( 0, function() PrintMessage( HUD_PRINTCENTER,"Attention Server Restart In 30 Seconds" ) end )
  37. timer.Simple( 3, function() PrintMessage( HUD_PRINTCENTER,"Attention Server Restart In 30 Seconds" ) end )
  38. timer.Simple( 6, function() PrintMessage( HUD_PRINTCENTER,"Attention Server Restart In 30 Seconds" ) end )
  39. timer.Simple( 9, function() PrintMessage( HUD_PRINTCENTER,"Attention Server Restart In 30 Seconds" ) end )
  40. timer.Simple( 12, function() PrintMessage( HUD_PRINTCENTER,"Attention Server Restart In 30 Seconds" ) end )
  41. timer.Simple( 15, function() PrintMessage( HUD_PRINTCENTER,"Attention Server Restart In 30 Seconds" ) end )
  42. timer.Simple( 18, function() PrintMessage( HUD_PRINTCENTER,"Attention Server Restart In 30 Seconds" ) end )
  43. timer.Simple( 24, function() PrintMessage( HUD_PRINTCENTER,"Attention Server Restart In 30 Seconds" ) end )
  44. timer.Simple( 27, function() PrintMessage( HUD_PRINTCENTER,"Attention Server Restart In 30 Seconds" ) end )
  45. timer.Simple( 30, function() PrintMessage( HUD_PRINTCENTER,"Attention Server Restart In 30 Seconds" ) end )
  46. timer.Simple( 33, function() PrintMessage( HUD_PRINTCENTER,"Attention Server Restart In 30 Seconds" ) end )
  47. timer.Simple( 36, function() PrintMessage( HUD_PRINTCENTER,"Attention Server Restart In In 30 Seconds" ) end )
  48.  
  49. ReadSound( "ambient/alarms/alarm_citizen_loop1.wav" )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement