-- LUA Script - precede every function and global member with lowercase name of script + '_main' -- Player Enters Sound Zone function loopsoundinzone_init( e ) end local maxSqDist = 1500 * 1500 local sound = {} function loopsoundinzone_main( e ) local Ent = g_Entity[ e ] if Ent.plrinzone == 1 and not sound[ e ] then LoopSound( e, 0 ) SetSound( e, 0 ) SetSoundVolume( 0 ) sound[ e ] = true elseif sound[ e ] then local PDX, PDY, PDZ = Ent.x - g_PlayerPosX, Ent.y - g_PlayerPosY, Ent.z - g_PlayerPosZ; local sQdist = PDX*PDX + PDY*PDY + PDZ*PDZ local vol = 60 + ( 40 * ( maxSqDist - sQdist ) / maxSqDist ) SetSound( e, 0 ) SetSoundVolume( vol ) PromptLocal( e, vol ) end end