ULX

Author Topic: Ambient Sounds  (Read 1905 times)

0 Members and 1 Guest are viewing this topic.

Offline Yanami

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
Ambient Sounds
« on: February 12, 2016, 02:01:56 PM »
Hey there!
I tried to get a code to work in the last days. I want some sounds to play randomly when a player is in a specific building. Any idea how it could work? I tried it with sound.play and stuff like that. Any ideas?

Sorry for being kinda stupid but i just cant get this working. Thanks for answering anyways.

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Ambient Sounds
« Reply #1 on: February 15, 2016, 02:39:53 PM »
Without editing the map, you will struggle to detect when they are in a building. If this is your first time doing something in Lua, I'd suggest trying something simpler first.
Experiencing God's grace one day at a time.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Ambient Sounds
« Reply #2 on: February 15, 2016, 07:01:02 PM »
Find some lua script that has a specified 'admin area', or forcefield. This lua script you find shouldn't be limited to just certain maps, though even those could help.
That would be a good start to look behind the scenes to detect how lua determines if a player is attempting to cross a border or 'box'.
Then you could review the gmod lua wiki to determine how to play sounds that only the player can hear, or a sound entity that can't be heard outside the border.

Just some ideas of where I'd start looking.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming