1- local resX , resY = guiGetScreenSize ()
2- local tbl = {}
3-
1+ local radioSpeakers = {}
2+ local blackColor = tocolor ( 0 , 0 , 0 , 255 )
3+ local textColor = tocolor ( 150 , 50 , 150 , 255 )
44local radioTable = {
55 {" [Top 40 Mix] BAYERN Radio - Top40" , " http://stream.antenne.de:80/top-40" },
66 {" [Top 40 Mix] 1.FM - Absolute Top 40" , " http://185.33.21.111:80/top40_32a" },
@@ -89,12 +89,13 @@ local radioTable = {
8989}
9090
9191function speakersysGUI ()
92-
9392 if (speakersys ) then
9493 return true
9594 end
9695
97- speakersys = guiCreateWindow ((resX - 325 ) / 1.1 , (resY - 380 ) / 1.4 , 325 , 380 , " SPEAKER MUSIC (RADIO/MP3)" , false )
96+ local screenX , screenY = guiGetScreenSize ()
97+
98+ speakersys = guiCreateWindow ((screenX - 325 ) / 1.1 , (screenY - 380 ) / 1.4 , 325 , 380 , " SPEAKER MUSIC (RADIO/MP3)" , false )
9899 guiSetAlpha (speakersys , 1 )
99100 guiWindowSetSizable (speakersys , false )
100101 urlGrid = guiCreateGridList (10 , 54 , 304 , 139 , false , speakersys )
@@ -192,36 +193,36 @@ end
192193addEventHandler (" onClientGUIClick" , resourceRoot , clickEvent )
193194
194195function setData (value , theType , serial )
195- if (not tbl [serial ]) then
196+ if (not radioSpeakers [serial ]) then
196197 return
197198 end
198199
199- if (not isElement (tbl [serial ][1 ])) then
200+ if (not isElement (radioSpeakers [serial ][1 ])) then
200201 return
201202 end
202203
203204 if (theType == " vol" ) then
204- setSoundVolume (tbl [serial ][1 ], value )
205+ setSoundVolume (radioSpeakers [serial ][1 ], value )
205206 elseif (theType == " dist" ) then
206- setSoundMaxDistance (tbl [serial ][1 ], 65 )
207+ setSoundMaxDistance (radioSpeakers [serial ][1 ], 65 )
207208 elseif (theType == " destroy" ) then
208- stopSound (tbl [serial ][1 ])
209- destroyElement (tbl [serial ][2 ])
210- tbl [serial ] = nil
209+ stopSound (radioSpeakers [serial ][1 ])
210+ destroyElement (radioSpeakers [serial ][2 ])
211+ radioSpeakers [serial ] = nil
211212 end
212213end
213214addEvent (" speaker.setData" , true )
214215addEventHandler (" speaker.setData" , root , setData )
215216
216217function setPaused (serial )
217- if (not tbl [serial ]) then
218+ if (not radioSpeakers [serial ]) then
218219 return
219220 end
220221
221- if (not isElement (tbl [serial ][1 ])) then
222+ if (not isElement (radioSpeakers [serial ][1 ])) then
222223 return
223224 end
224- setSoundPaused (tbl [serial ][1 ], not isSoundPaused (tbl [serial ][1 ]))
225+ setSoundPaused (radioSpeakers [serial ][1 ], not isSoundPaused (radioSpeakers [serial ][1 ]))
225226end
226227addEvent (" speaker.ps" , true )
227228addEventHandler (" speaker.ps" , root , setPaused )
@@ -233,9 +234,9 @@ function setBox(str)
233234
234235 for serial , ent in pairs (str ) do
235236
236- if (tbl [serial ] and isElement (tbl [serial ][1 ])) then
237- destroyElement (tbl [serial ][1 ])
238- destroyElement (tbl [serial ][2 ])
237+ if (radioSpeakers [serial ] and isElement (radioSpeakers [serial ][1 ])) then
238+ destroyElement (radioSpeakers [serial ][1 ])
239+ destroyElement (radioSpeakers [serial ][2 ])
239240 end
240241
241242 if (isElement (ent [1 ])) then
@@ -246,7 +247,7 @@ function setBox(str)
246247 setElementAlpha (dumm , 0 )
247248 setElementCollisionsEnabled (dumm , false )
248249 attachElements (dumm , ent [1 ], - 0.32 , - 0.22 , 0.8 )
249- tbl [serial ] = {radio , dumm }
250+ radioSpeakers [serial ] = {radio , dumm }
250251
251252 if (ent [6 ] and isElement (ent [6 ])) then
252253 attachElements (radio , ent [6 ])
@@ -265,16 +266,16 @@ addEvent("speaker.setBox", true)
265266addEventHandler (" speaker.setBox" , root , setBox )
266267
267268function getRadioInfo ()
268- for key , radio in pairs (tbl ) do
269+ for key , radio in pairs (radioSpeakers ) do
269270 if (radio [1 ] and isElement (radio [1 ])) then
270- tbl [key ][3 ] = nil
271- table.insert (tbl [key ], getSoundMetaTags (radio [1 ]).stream_title or getSoundMetaTags (radio [1 ]).title )
271+ radioSpeakers [key ][3 ] = nil
272+ table.insert (radioSpeakers [key ], getSoundMetaTags (radio [1 ]).stream_title or getSoundMetaTags (radio [1 ]).title )
272273 end
273274 end
274275end
275276
276277function drawData ()
277- for key , radio in pairs (tbl ) do
278+ for key , radio in pairs (radioSpeakers ) do
278279 if (radio [2 ] and isElement (radio [2 ] and radio [1 ])) then
279280 local eX , eY , eZ = getElementPosition (radio [2 ])
280281 eZ = (eZ + 1 )
@@ -285,7 +286,7 @@ function drawData()
285286 if (not enable and getElementData (radio [1 ], " ob" ) ~= getPlayerName (localPlayer )) then
286287 stopSound (radio [1 ])
287288 destroyElement (radio [2 ])
288- tbl [key ] = nil
289+ radioSpeakers [key ] = nil
289290 return false
290291 end
291292
@@ -302,8 +303,8 @@ function drawData()
302303
303304 local width = dxGetTextWidth (text , 1 , " default-bold" )
304305
305- dxDrawRectangle (sx - width / 2 - 5 , sy , width + 8 , height , tocolor ( 0 , 0 , 0 , 255 ) , false )
306- dxDrawText (text , sx - width / 2 , sy , sx - width / 2 , sy , tocolor ( 150 , 50 , 150 , 255 ) , 1 , " default-bold" )
306+ dxDrawRectangle (sx - width / 2 - 5 , sy , width + 8 , height , blackColor , false )
307+ dxDrawText (text , sx - width / 2 , sy , sx - width / 2 , sy , textColor , 1 , " default-bold" )
307308 end
308309 end
309310 end
0 commit comments