Quote: "Actually it works now, anyway to make it fade the sound out and in as you leave and enter? (Unrelated to distance)"
not 100% sure i needed all those arrays but it works so whatever
personally i find anything below that min_sound is too quiet to hear but you can adjust it easily - added comments to the settings
-- LUA Script - precede every function and global member with lowercase name of script + '_main'
-- Player Enters Sound Zone
local delay = {}
local volume = {}
local vol_change = {}
local min_sound = {}
local max_sound = {}
local time1 = {}
local time2 = {}
local timeset = {}
local timepassed = {}
local sound_triggered = {}
function soundinzone_init(e)
-- delay between volume adjustment (in seconds)
delay[e] = .5
--initial volume to play sound at
volume[e] = 99
--how much to adjust volume by each time delay is reached
vol_change[e] = 1
min_sound[e] = 80 --between 0 and 100
max_sound[e] = 100 --do not set above 100
time1[e] = 0
time2[e] = 0
timeset[e] = 0
timepassed[e] = 0
sound_triggered[e] = 0
end
function soundinzone_main(e)
if sound_triggered[e] == 1 then
SetSoundVolume(volume[e])
LoopSound(e,0);
if timeset[e] == 0 then
time1[e] = g_Time
timeset[e] = 1
end
time2[e] = g_Time
timepassed[e] = (time2[e] - time1[e]) / 1000
if timepassed[e] > delay[e] then
if volume[e] < max_sound[e] then
volume[e] = volume[e] + vol_change[e]
end
timeset[e] = 0
end
elseif sound_triggered[e] == 2 then
SetSoundVolume(volume[e])
LoopSound(e,0);
if timeset[e] == 0 then
time1[e] = g_Time
timeset[e] = 1
end
time2[e] = g_Time
timepassed[e] = (time2[e] - time1[e]) / 1000
if timepassed[e] > delay[e] then
if volume[e] > min_sound[e] then
volume[e] = volume[e] - vol_change[e]
timeset[e] = 0
else
StopSound(e,0)
sound_triggered[e] = 0
end
end
end
if g_Entity[e]['plrinzone'] == 1 then
sound_triggered[e] = 1
elseif sound_triggered[e] == 1 then
sound_triggered[e] = 2
end
end
life's one big game
windows vista ultimate
i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11