@@ -5,7 +5,7 @@ local streamedPlayers = {}
55local fDistDiff = fMinDistance - fMaxDistance
66
77local sx , sy = guiGetScreenSize ()
8- local nx , ny = sx / 1920 , sy / 1080
8+ local nx , ny = sx / 1920 , sy / 1080
99
1010local width = 108 * nx
1111local height = 180 * ny
@@ -18,7 +18,7 @@ local icon = dxCreateTexture("icon.png", "dxt5", true, "clamp")
1818
1919function preRender ()
2020 local x , y , z , lx , ly , lz = getCameraMatrix ()
21-
21+
2222 for player , talking in pairs (streamedPlayers ) do
2323 if player and isElement (player ) and getElementType (player ) == " player" then
2424 local x1 , y1 , z1 = getElementPosition (player )
@@ -33,7 +33,7 @@ function preRender()
3333 fVolume = mathexp (- (fDistance - fMinDistance ) * (5.0 / fDistDiff )) * 100
3434 end
3535
36- if isLineOfSightClear (x , y , z , x1 , y1 , z1 , false , false , false , false , true , true , true , localPlayer ) then
36+ if isLineOfSightClear (x , y , z , x1 , y1 , z1 , false , false , false , false , true , true , true , localPlayer ) then
3737 setSoundVolume (player , fVolume )
3838 setSoundEffectEnabled (player , " compressor" , false )
3939 else
@@ -45,7 +45,7 @@ function preRender()
4545 local boneX , boneY , boneZ = getPedBonePosition (player , 8 )
4646 local screenX , screenY = getScreenFromWorldPosition (boneX , boneY , boneZ + 0.5 )
4747 if screenX and screenY and fDistance < fMaxDistance then
48- fDistance = 1 / fDistance
48+ fDistance = 1 / fDistance
4949 dxDrawImage (screenX - halfWidth * fDistance , screenY - halfHeight * fDistance , width * fDistance , height * fDistance , icon , 0 , 0 , 0 , - 1 , false )
5050 end
5151 end
5555addEventHandler (" onClientPreRender" , root , preRender )
5656
5757function onStart ()
58- local x , y , z = getElementPosition (localPlayer )
59- for _ , player in ipairs (getElementsWithinRange (x , y , z , 250 , " player" )) do
60- if streamedPlayers [player ] == nil then
61- streamedPlayers [player ] = false
62- end
63- end
58+ local x , y , z = getElementPosition (localPlayer )
59+ for _ , player in ipairs (getElementsWithinRange (x , y , z , 250 , " player" )) do
60+ if streamedPlayers [player ] == nil then
61+ streamedPlayers [player ] = false
62+ end
63+ end
6464 triggerServerEvent (" voice:setPlayerBroadcast" , resourceRoot , localPlayer , streamedPlayers )
6565end
6666addEventHandler (" onClientResourceStart" , resourceRoot , onStart , false )
7676addEventHandler (" onClientPlayerJoin" , root , playerJoin )
7777
7878function playerQuit ()
79- if streamedPlayers [source ] ~= nil then
80- streamedPlayers [source ] = nil
81- setSoundVolume (source , 0 )
82- triggerServerEvent (" voice:removePlayerBroadcast" , resourceRoot , localPlayer , source )
79+ if streamedPlayers [source ] ~= nil then
80+ streamedPlayers [source ] = nil
81+ setSoundVolume (source , 0 )
82+ triggerServerEvent (" voice:removePlayerBroadcast" , resourceRoot , localPlayer , source )
8383 end
8484end
8585addEventHandler (" onClientPlayerQuit" , root , playerQuit )
8686
87-
8887-- Code considers this event's problem @ "Note" box: https://wiki.multitheftauto.com/wiki/OnClientElementStreamIn
8988-- It should be modified if said behavior ever changes
9089function streamIn ()
@@ -97,7 +96,6 @@ function streamIn()
9796end
9897addEventHandler (" onClientElementStreamIn" , root , streamIn )
9998
100-
10199-- To ensure table integrity, stream out & local player death into 2 separate, safer events
102100-- See the "Note" box at https://wiki.multitheftauto.com/wiki/OnClientElementStreamIn for reason why
103101-- Stream out event
@@ -114,10 +112,10 @@ addEventHandler("onClientElementStreamOut", root, streamOut)
114112
115113-- Local player death event
116114function onWasted ()
117- if streamedPlayers [localPlayer ] ~= nil then
118- streamedPlayers [localPlayer ] = nil
119- setSoundVolume (localPlayer , 0 )
120- triggerServerEvent (" voice:removePlayerBroadcast" , resourceRoot , localPlayer , localPlayer )
115+ if streamedPlayers [localPlayer ] ~= nil then
116+ streamedPlayers [localPlayer ] = nil
117+ setSoundVolume (localPlayer , 0 )
118+ triggerServerEvent (" voice:removePlayerBroadcast" , resourceRoot , localPlayer , localPlayer )
121119 end
122120end
123121addEventHandler (" onClientPlayerWasted" , localPlayer , onWasted )
@@ -129,29 +127,29 @@ end
129127addEventHandler (" onClientResourceStop" , resourceRoot , resourceStop , false )
130128
131129function voiceStart (source )
132- if (isElement (source ) and getElementType (source ) == " player" ) then
133- if streamedPlayers [source ] ~= nil then
134- streamedPlayers [source ] = true
135- end
136- end
130+ if (isElement (source ) and getElementType (source ) == " player" ) then
131+ if streamedPlayers [source ] ~= nil then
132+ streamedPlayers [source ] = true
133+ end
134+ end
137135end
138136addEvent (" voice_cl:onClientPlayerVoiceStart" , true )
139137addEventHandler (" voice_cl:onClientPlayerVoiceStart" , resourceRoot , voiceStart )
140138
141139function voiceStop (source )
142- if (isElement (source ) and getElementType (source ) == " player" ) then
143- if streamedPlayers [source ] ~= nil then
144- streamedPlayers [source ] = false
145- end
146- end
140+ if (isElement (source ) and getElementType (source ) == " player" ) then
141+ if streamedPlayers [source ] ~= nil then
142+ streamedPlayers [source ] = false
143+ end
144+ end
147145end
148146addEvent (" voice_cl:onClientPlayerVoiceStop" , true )
149147addEventHandler (" voice_cl:onClientPlayerVoiceStop" , resourceRoot , voiceStop )
150148
151149function table .empty (a )
152- if type (a ) ~= " table" then
153- return false
154- end
150+ if type (a ) ~= " table" then
151+ return false
152+ end
155153
156- return next (a ) == nil
154+ return next (a ) == nil
157155end
0 commit comments